/* DIT Immersion - tokens and components (phone first) */
:root {
  --brand: #1d4ed8;
  --brand-600: #2563eb;
  --brand-700: #1e40af;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --bg: #f6f8fb;
  --card: #ffffff;
  --green: #15803d; --green-bg: #dcfce7;
  --amber: #b45309; --amber-bg: #fef3c7;
  --red: #b91c1c;   --red-bg: #fee2e2;
  --gray: #475569;  --gray-bg: #e2e8f0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: #e8eef3; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li { margin-bottom: 6px; }
img, svg { vertical-align: middle; }
.ic { flex: none; }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.xs { font-size: .76rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.break { overflow-wrap: anywhere; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--brand); color: #fff; font: 600 14px/1.2 var(--font); cursor: pointer;
  text-decoration: none !important; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand-100); outline-offset: 1px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-outline { background: #fff; color: var(--ink-2); border-color: #cbd5e1; }
.btn-outline:hover { background: var(--line-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { background: #dc2626; } .btn-danger:hover { background: #b91c1c; }
.btn-success { background: #16a34a; } .btn-success:hover { background: #15803d; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 20px; font-size: 16px; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn.red { color: var(--red); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.card-body { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }

/* badges and state dots */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge-final, .badge-green { background: var(--green-bg); color: var(--green); }
.badge-progress, .badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-none, .badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-blue { background: var(--brand-100); color: var(--brand-700); }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: #cbd5e1; }
.dot.final { background: #22c55e; }
.dot.progress { background: #f59e0b; }
.dot.none { background: #e2e8f0; border: 1px solid #cbd5e1; }

/* forms */
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  font: 16px/1.4 var(--font); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; margin-top: 1px; }
.form-error { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red); font-size: 14px; margin-bottom: 14px; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); background: #fbfcfd; white-space: nowrap; }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th.c, .table td.c { text-align: center; }
.table .sticky { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 132px; max-width: 170px; }
.table th.sticky { background: #fbfcfd; }

/* flash, toast, modal */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.flash-ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.flash-close { margin-left: auto; background: none; border: 0; font-size: 18px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; width: min(448px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .25s ease-out; cursor: pointer; }
.toast.error { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 1100; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(440px, 100%); box-shadow: var(--shadow-lg); padding: 20px; }
.modal h3 { margin-bottom: 6px; }
.modal .row { margin-top: 18px; }

/* misc */
.progress { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), #60a5fa); border-radius: 999px; transition: width .2s; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); font-weight: 700; font-size: 13px; flex: none; }
.callout { padding: 12px 14px; border-radius: 12px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-700); font-size: 14px; margin-bottom: 14px; }
.callout.amber { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.callout.red { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--line-2); font-size: 13px; }
.chip.me { background: var(--brand-100); color: var(--brand-700); font-weight: 600; }

/* phone shell */
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
@media (min-width: 680px) { .app { box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); } }
.app-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(246, 248, 251, .94); backdrop-filter: blur(10px); }
.app-header .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .hbtn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--ink-2); background: #fff; border: 1px solid var(--line); }
.app-header .avatar { width: 38px; height: 38px; text-decoration: none; }
.app-main { padding: 4px 16px 24px; }

.next { border-radius: 18px; padding: 18px; color: #fff; background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 70%, #60a5fa 140%); box-shadow: 0 10px 26px rgba(37, 99, 235, .3); margin: 6px 0 16px; }
.next .n-label { font-size: 12.5px; opacity: .85; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.next h2 { font-size: 19px; margin: 4px 0 6px; }
.next p { font-size: 14px; opacity: .92; margin-bottom: 12px; }
.next .btn { background: #fff; color: var(--brand-700); }
.next .progress { background: rgba(255, 255, 255, .25); margin-top: 14px; }
.next .progress > span { background: #fde68a; }
.next .n-count { font-size: 13px; margin-top: 6px; opacity: .92; }
.next.done { background: linear-gradient(145deg, #14532d 0%, #16a34a 80%); box-shadow: 0 10px 26px rgba(22, 163, 74, .3); }

.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 2px 8px; }
.sec-head h2 { font-size: 15px; margin: 0; }
.sec-head a, .sec-head span { font-size: 13px; }

.list { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 14px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: #fafcff; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 14.5px; }
.list-item .li-sub { font-size: 12.5px; color: var(--muted); }
.list-item .li-code { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: 12.5px; }
.list-item .li-code.final { background: var(--green-bg); color: var(--green); }
.list-item .li-code.progress { background: var(--amber-bg); color: var(--amber); }
.list-item .chev { color: #cbd5e1; }

.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 640px; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 600; color: #94a3b8; text-decoration: none !important; }
.bottom-nav a.active { color: var(--brand); }

.auth-hero { padding: calc(34px + env(safe-area-inset-top)) 24px 24px; background: linear-gradient(160deg, #1e3a8a, #2563eb); color: #fff; border-radius: 0 0 26px 26px; }
.auth-hero h1 { font-size: 23px; margin: 0 0 4px; }
.auth-hero p { margin: 0; opacity: .88; font-size: 14px; }
.auth-body { padding: 20px 20px 40px; }
.name-list { display: grid; gap: 8px; }
.name-list label { display: block; position: relative; }
.name-list input { position: absolute; opacity: 0; }
.name-list span { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 600; }
.name-list input:checked + span { border-color: var(--brand-600); background: var(--brand-50); }

/* files */
.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.file .thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: var(--line-2); flex: none; display: grid; place-items: center; color: var(--muted); }
.file .f-main { flex: 1; min-width: 0; }
.file .f-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .f-sub { font-size: 12px; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 520px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.gallery .g { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line-2); display: grid; place-items: center; color: var(--muted); }
.gallery .g img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .g .tag { position: absolute; left: 4px; bottom: 4px; right: 4px; font-size: 10.5px; color: #fff; background: rgba(15, 23, 42, .62); border-radius: 6px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery .g .vid { position: absolute; top: 4px; right: 4px; font-size: 10.5px; color: #fff; background: rgba(15, 23, 42, .7); border-radius: 6px; padding: 1px 5px; }
.gallery .g form { position: absolute; top: 3px; left: 3px; }
.gallery .g .x { width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(15, 23, 42, .65); color: #fff; cursor: pointer; display: grid; place-items: center; }

.uploader { margin-top: 10px; }
.uploader input[type=file] { display: none; }
.up-list { display: grid; gap: 8px; margin-top: 10px; }
.up-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 13px; }
.up-item .up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .up-msg { color: var(--muted); font-size: 12px; margin-top: 4px; }
.up-item.error { border-color: #fecaca; background: #fef2f2; }
.up-item.error .up-msg { color: var(--red); }
.up-item.done { border-color: #bbf7d0; background: #f0fdf4; }
.up-item .progress { margin-top: 6px; }

.rule { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.rule:last-child { border-bottom: 0; }
.rule .count { margin-left: auto; white-space: nowrap; font-weight: 700; font-size: 13px; color: var(--ink-2); }

@media print {
  .bottom-nav, .app-header, .toasts, .no-print { display: none !important; }
  body, .app { background: #fff; }
  .app { max-width: none; padding: 0; box-shadow: none; }
}
