/* ImmiDesk UI. One stylesheet, no framework, no build step.
   Designed for long days: calm surfaces, high-contrast text, generous hit
   targets, and a dense-but-readable table rhythm. */

:root {
  --ink:            #11181c;
  --ink-2:          #38454d;
  --ink-3:          #5c6b73;
  --ink-4:          #8696a0;
  --line:           #dfe5e8;
  --line-2:         #eef2f4;
  --surface:        #ffffff;
  --surface-2:      #f6f8f9;
  --surface-3:      #eef2f4;
  --brand:          #17506b;
  --brand-2:        #1f6f8b;
  --brand-ink:      #ffffff;
  --brand-wash:     #e8f1f5;
  --accent:         #0f766e;
  --ok:             #166534;
  --ok-wash:        #e7f5ec;
  --warn:           #92610b;
  --warn-wash:      #fdf4e3;
  --danger:         #a3261c;
  --danger-wash:    #fdeeec;
  --info:           #1d4ed8;
  --info-wash:      #eaf0ff;
  --radius:         8px;
  --radius-sm:      5px;
  --shadow-1:       0 1px 2px rgba(17, 24, 28, .06), 0 1px 3px rgba(17, 24, 28, .04);
  --shadow-2:       0 4px 12px rgba(17, 24, 28, .08), 0 1px 3px rgba(17, 24, 28, .05);
  --shadow-pop:     0 12px 32px rgba(17, 24, 28, .16);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 232px;
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:         #e8edef;
    --ink-2:       #c3ced4;
    --ink-3:       #93a2aa;
    --ink-4:       #71838c;
    --line:        #2a353b;
    --line-2:      #222c31;
    --surface:     #151d21;
    --surface-2:   #1b242a;
    --surface-3:   #222c32;
    --brand:       #5fb3d4;
    --brand-2:     #7cc4e0;
    --brand-ink:   #08141a;
    --brand-wash:  #16303c;
    --accent:      #2dd4bf;
    --ok:          #6ee7a8;
    --ok-wash:     #14301f;
    --warn:        #f0c674;
    --warn-wash:   #33280f;
    --danger:      #f98f84;
    --danger-wash: #361914;
    --info:        #93b4ff;
    --info-wash:   #18213a;
    --shadow-1:    0 1px 2px rgba(0,0,0,.5);
    --shadow-2:    0 4px 14px rgba(0,0,0,.5);
    --shadow-pop:  0 14px 36px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink:         #e8edef;
  --ink-2:       #c3ced4;
  --ink-3:       #93a2aa;
  --ink-4:       #71838c;
  --line:        #2a353b;
  --line-2:      #222c31;
  --surface:     #151d21;
  --surface-2:   #1b242a;
  --surface-3:   #222c32;
  --brand:       #5fb3d4;
  --brand-2:     #7cc4e0;
  --brand-ink:   #08141a;
  --brand-wash:  #16303c;
  --accent:      #2dd4bf;
  --ok:          #6ee7a8;
  --ok-wash:     #14301f;
  --warn:        #f0c674;
  --warn-wash:   #33280f;
  --danger:      #f98f84;
  --danger-wash: #361914;
  --info:        #93b4ff;
  --info-wash:   #18213a;
  --shadow-1:    0 1px 2px rgba(0,0,0,.5);
  --shadow-2:    0 4px 14px rgba(0,0,0,.5);
  --shadow-pop:  0 14px 36px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--surface-2);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* A wide table or a long reference number scrolls inside its own container.
     The page itself must never scroll sideways on a phone. */
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.011em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0 0 .75em; }

code, .mono { font-family: var(--mono); font-size: .92em; }

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line-2);
}
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  color: var(--brand-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -.5px;
}
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: -.012em; }
.brand-org { font-size: 11.5px; color: var(--ink-4); margin-top: 1px; }

.nav { padding: 10px 8px; flex: 1; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-label {
  font-size: 10.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-4);
  padding: 0 8px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-wash); color: var(--brand); font-weight: 600; }
.nav a .ico { width: 16px; text-align: center; flex: 0 0 16px; opacity: .85; font-size: 13px; }
.nav a .count {
  margin-left: auto; font-size: 11px; font-weight: 650;
  background: var(--surface-3); color: var(--ink-3);
  padding: 1px 6px; border-radius: 10px; min-width: 20px; text-align: center;
}
.nav a.active .count { background: var(--brand); color: var(--brand-ink); }
.nav a .count.alert { background: var(--danger-wash); color: var(--danger); }

.sidebar-foot {
  border-top: 1px solid var(--line-2);
  padding: 10px;
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px; border-radius: var(--radius-sm); width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left; color: inherit;
  font: inherit;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-size: 11.5px; font-weight: 650; letter-spacing: -.3px;
}
.user-name { font-size: 13px; font-weight: 550; line-height: 1.25; }
.user-role { font-size: 11px; color: var(--ink-4); text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 11px 22px;
  display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { font-size: 12.5px; color: var(--ink-4); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content { padding: 20px 22px 60px; flex: 1; }
.content.wide { max-width: none; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot {
  padding: 11px 16px; border-top: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; gap: 8px; align-items: center;
}

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-aside { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1180px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------- stat tiles */

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px;
  box-shadow: var(--shadow-1);
}
.stat-label {
  font-size: 11.5px; font-weight: 600; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .05em;
}
.stat-value {
  font-size: 26px; font-weight: 650; letter-spacing: -.025em;
  margin-top: 5px; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat.alert { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.stat.alert .stat-value { color: var(--danger); }
.stat.good .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }
.stat-link { cursor: pointer; }
.stat-link:hover { border-color: var(--brand-2); box-shadow: var(--shadow-2); }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px;
}
table.data th {
  text-align: left; font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-4);
  padding: 9px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0;
}
table.data td {
  padding: 10px 14px; border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }
.t-primary { font-weight: 550; }
.t-sub { font-size: 12px; color: var(--ink-4); margin-top: 2px; }

.empty {
  padding: 36px 20px; text-align: center; color: var(--ink-4);
}
.empty .empty-icon { font-size: 26px; opacity: .45; margin-bottom: 8px; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 46ch; margin: 0 auto .9em; }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5;
  padding: 2px 8px; border-radius: 11px;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.pill.ok     { background: var(--ok-wash);     color: var(--ok); }
.pill.warn   { background: var(--warn-wash);   color: var(--warn); }
.pill.danger { background: var(--danger-wash); color: var(--danger); }
.pill.info   { background: var(--info-wash);   color: var(--info); }
.pill.brand  { background: var(--brand-wash);  color: var(--brand); }
.pill.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 6px;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 550 13.5px/1 var(--sans);
  padding: 8px 13px; min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
}
.btn.primary:hover:not(:disabled) { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
.btn.sm { min-height: 28px; padding: 5px 10px; font-size: 12.5px; }
.btn.lg { min-height: 42px; padding: 11px 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 14px; }
.field label, .label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--ink-4); margin: -1px 0 6px; line-height: 1.45; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 500; }

input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=month], input[type=number], input[type=search],
select, textarea {
  width: 100%; font: 400 14px/1.4 var(--sans);
  padding: 8px 10px; min-height: 36px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2); outline: 2px solid color-mix(in srgb, var(--brand-2) 25%, transparent);
  outline-offset: 0;
}
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] {
  border-color: var(--danger);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
select { appearance: none; background-image: none; padding-right: 28px; cursor: pointer; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: '⌄'; position: absolute; right: 11px; top: 6px;
  color: var(--ink-4); pointer-events: none; font-size: 14px;
}

.check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13.5px; cursor: pointer; margin-bottom: 9px; line-height: 1.45;
}
.check input { width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 16px; cursor: pointer; accent-color: var(--brand); }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; cursor: pointer; margin: 0;
  background: var(--surface);
}
.radio-row label:has(input:checked) {
  border-color: var(--brand); background: var(--brand-wash); color: var(--brand); font-weight: 600;
}
.radio-row input { accent-color: var(--brand); }

.form-row { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .form-row, .form-row.c3 { grid-template-columns: minmax(0, 1fr); } }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
  max-width: 100%;
}
.filters > * { max-width: 100%; }
.filters input, .filters select { min-height: 34px; width: auto; min-width: 150px; max-width: 100%; }
.filters .select-wrap { flex: 0 1 auto; min-width: 0; }
.filters .search { min-width: 0; flex: 1 1 200px; max-width: 360px; }

/* -------------------------------------------------------------- key/value */

.kv { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 9px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-4); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: minmax(0,1fr); gap: 2px 0; } .kv dd { margin-bottom: 8px; } }

/* --------------------------------------------------------------- progress */

.meter {
  height: 7px; border-radius: 4px; background: var(--surface-3);
  overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--brand-2); transition: width .3s; }
.meter.good > span { background: var(--ok); }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .meter { flex: 1; min-width: 60px; }
.meter-row .meter-val { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

/* -------------------------------------------------------------- pipeline */

.pipeline { display: flex; gap: 2px; align-items: stretch; overflow-x: auto; padding-bottom: 4px; }
.pipeline-stage {
  flex: 1; min-width: 108px; padding: 11px 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  position: relative;
}
.pipeline-stage:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.pipeline-stage:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.pipeline-stage.done { background: var(--ok-wash); border-color: color-mix(in srgb, var(--ok) 25%, var(--line)); }
.pipeline-stage.active { background: var(--brand-wash); border-color: var(--brand-2); box-shadow: inset 0 -2px 0 var(--brand-2); }
.pipeline-stage .ps-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.pipeline-stage .ps-count { font-size: 19px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.pipeline-stage .ps-meta { font-size: 11px; color: var(--ink-4); margin-top: 2px; }

/* --------------------------------------------------------------- stepper */

.stepper { display: flex; flex-direction: column; gap: 0; }
.step {
  display: flex; gap: 12px; padding: 0 0 2px;
  position: relative;
}
.step-rail { flex: 0 0 22px; display: flex; flex-direction: column; align-items: center; }
.step-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-4);
  border: 2px solid var(--surface); font-size: 10px; font-weight: 700;
  z-index: 1;
}
.step.done .step-dot { background: var(--ok); color: #fff; }
.step.active .step-dot { background: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 3px var(--brand-wash); }
.step-line { width: 2px; flex: 1; background: var(--line); min-height: 14px; }
.step:last-child .step-line { display: none; }
.step-body { padding: 0 0 16px; flex: 1; min-width: 0; }
.step-name { font-size: 13.5px; font-weight: 600; line-height: 20px; }
.step.done .step-name { color: var(--ink-3); }
.step-meta { font-size: 12px; color: var(--ink-4); margin-top: 1px; }

/* ----------------------------------------------------------------- alerts */

.alert {
  border-radius: var(--radius); padding: 12px 14px;
  border: 1px solid; font-size: 13.5px; line-height: 1.5;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert + .alert { margin-top: 9px; }
.alert .alert-icon { flex: 0 0 16px; font-size: 14px; line-height: 1.4; }
.alert-body { flex: 1; min-width: 0; }
.alert strong { font-weight: 650; }
.alert.danger { background: var(--danger-wash); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--ink); }
.alert.warn   { background: var(--warn-wash);   border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.alert.ok     { background: var(--ok-wash);     border-color: color-mix(in srgb, var(--ok) 28%, transparent); color: var(--ink); }
.alert.info   { background: var(--info-wash);   border-color: color-mix(in srgb, var(--info) 28%, transparent); color: var(--ink); }
.alert-action { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert li { margin-bottom: 3px; }

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin-bottom: 18px; overflow-x: auto;
}
.tab {
  padding: 9px 13px; font-size: 13.5px; font-weight: 550;
  color: var(--ink-3); background: none; border: 0; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
  font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }
.tab .tab-count {
  font-size: 11px; background: var(--surface-3); color: var(--ink-3);
  padding: 1px 5px; border-radius: 8px; margin-left: 5px; font-weight: 650;
}
.tab.active .tab-count { background: var(--brand-wash); color: var(--brand); }

/* ----------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(17, 24, 28, .45);
  display: grid; place-items: center; padding: 20px;
  overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-pop);
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px;
}
.modal-head h2 { font-size: 16px; }
.modal-close {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  font-size: 20px; color: var(--ink-4); line-height: 1; padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--line-2);
  display: flex; gap: 9px; justify-content: flex-end;
  background: var(--surface-2); border-radius: 0 0 10px 10px;
}

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; max-width: 390px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 11px 13px; font-size: 13.5px; line-height: 1.45;
  display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.ok { border-left-color: var(--ok); }
.toast.danger { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast-title { font-weight: 650; margin-bottom: 1px; }
.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-x { background: none; border: 0; cursor: pointer; color: var(--ink-4); font-size: 16px; line-height: 1; padding: 0 2px; }

/* ---------------------------------------------------------------- loading */

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px;
  border: 2px solid var(--line); border-top-color: var(--brand-2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; padding: 36px; justify-content: center; color: var(--ink-4); font-size: 13.5px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite; border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------- timeline */

.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 5px; bottom: 5px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 15px; }
.tl-item::before {
  content: ''; position: absolute; left: -19px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-2); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.tl-item.ok::before { background: var(--ok); }
.tl-item.danger::before { background: var(--danger); }
.tl-item.warn::before { background: var(--warn); }
.tl-summary { font-size: 13.5px; line-height: 1.45; }
.tl-meta { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; }

/* -------------------------------------------------------------- checklist */

.cl-item {
  display: flex; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--line-2); align-items: flex-start;
}
.cl-item:last-child { border-bottom: 0; }
.cl-status {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--ink-4); margin-top: 1px;
}
.cl-item.accepted .cl-status { background: var(--ok); color: #fff; }
.cl-item.rejected .cl-status { background: var(--danger); color: #fff; }
.cl-item.uploaded .cl-status, .cl-item.under_review .cl-status { background: var(--warn); color: #fff; }
.cl-item.waived .cl-status { background: var(--info); color: #fff; }
.cl-main { flex: 1; min-width: 0; }
.cl-title { font-size: 13.5px; font-weight: 550; line-height: 1.4; }
.cl-why { font-size: 12px; color: var(--ink-4); margin-top: 3px; line-height: 1.45; }
.cl-instruction { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.5; }
.cl-tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.cl-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* -------------------------------------------------------------- the shell */

.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: 20px; background: var(--surface-2);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2); padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; font-size: 15px; }
.auth-title { font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.auth-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }
.auth-note {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-4); line-height: 1.55;
}
.auth-note code {
  background: var(--surface-3); padding: 1px 5px; border-radius: 3px;
  font-size: 11.5px;
}

/* ------------------------------------------------------------ public pages */

.public { max-width: 820px; margin: 0 auto; padding: 28px 18px 70px; }
.public-head { text-align: center; margin-bottom: 26px; }
.public-head .brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; margin: 0 auto 12px; }
.public-head h1 { font-size: 26px; letter-spacing: -.02em; }
.public-head p { color: var(--ink-3); margin-top: 7px; font-size: 14.5px; }

.service-list { display: grid; gap: 10px; }
.service-card {
  display: flex; gap: 14px; align-items: flex-start; text-align: left;
  padding: 15px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; width: 100%;
  font: inherit; color: inherit;
}
.service-card:hover { border-color: var(--brand-2); box-shadow: var(--shadow-2); }
.service-card.selected { border-color: var(--brand); background: var(--brand-wash); box-shadow: inset 0 0 0 1px var(--brand); }
.service-name { font-size: 15px; font-weight: 600; }
.service-desc { font-size: 13px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.service-meta { font-size: 12px; color: var(--ink-4); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.service-price { margin-left: auto; font-weight: 650; font-size: 15px; white-space: nowrap; }

.slot-day { margin-bottom: 18px; }
.slot-day h3 { font-size: 13px; color: var(--ink-3); margin-bottom: 9px; font-weight: 600; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 7px; }
.slot {
  padding: 9px; text-align: center; font-size: 13px; font-weight: 550;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-family: inherit; color: inherit;
  font-variant-numeric: tabular-nums;
}
.slot:hover { border-color: var(--brand-2); background: var(--brand-wash); }
.slot.selected { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.score-ring {
  width: 128px; height: 128px; margin: 0 auto 14px;
  display: grid; place-items: center; position: relative;
}
.score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.score-ring .score-num { font-size: 32px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.score-ring .score-of { font-size: 11px; color: var(--ink-4); }

.legalese {
  font-size: 11.5px; color: var(--ink-4); line-height: 1.6;
  padding: 13px 15px; background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  margin-top: 18px;
}

/* ---------------------------------------------------------------- portal */

.portal-shell { max-width: 880px; margin: 0 auto; padding: 0 16px 70px; }
.portal-top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.portal-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.portal-nav button {
  padding: 7px 12px; border-radius: 20px; border: 1px solid transparent;
  background: none; font: 550 13px var(--sans); color: var(--ink-3); cursor: pointer;
}
.portal-nav button:hover { background: var(--surface-3); color: var(--ink); }
.portal-nav button.active { background: var(--brand); color: var(--brand-ink); }

.todo-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 15px; margin-bottom: 11px;
}
.todo-card.rejected { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--danger-wash); }
.todo-title { font-size: 14.5px; font-weight: 600; }
.todo-why { font-size: 12.5px; color: var(--ink-4); margin-top: 4px; }
.todo-instruction { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; line-height: 1.55; }
.upload-zone {
  margin-top: 12px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 18px; text-align: center; cursor: pointer; background: var(--surface-2);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--brand-2); background: var(--brand-wash); }
.upload-zone .uz-main { font-size: 13.5px; font-weight: 550; }
.upload-zone .uz-sub { font-size: 12px; color: var(--ink-4); margin-top: 3px; }

/* ----------------------------------------------------------- utilities */

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--ink-4); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nums { font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; }
.mb0 { margin-bottom: 0; } .mb1 { margin-bottom: 8px; } .mb2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 16px 0; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: sticky; top: 0;
    border-right: 0; border-bottom: 1px solid var(--line); z-index: 30;
  }
  .nav { display: flex; gap: 2px; overflow-x: auto; padding: 8px; }
  .nav-group { display: flex; gap: 2px; }
  .nav-group + .nav-group { margin-top: 0; }
  .nav-label { display: none; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { position: absolute; top: 10px; right: 10px; border: 0; padding: 0; }
  .sidebar-foot .user-name, .sidebar-foot .user-role { display: none; }
  .brand { padding: 11px 14px; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 11px 14px; }
}

@media (max-width: 560px) {
  .filters { flex-direction: column; align-items: stretch; }
  .filters > *, .filters .search, .filters .select-wrap, .filters .btn { width: 100%; max-width: none; }
  .filters .spacer { display: none; }
}

@media (max-width: 420px) {
  table.data th, table.data td { padding: 8px 10px; }
  .stat-value { font-size: 22px; }
  .modal { max-width: 100%; }
  .content { padding: 14px 12px 40px; }
}

@media print {
  .sidebar, .topbar-actions, .btn, .toasts { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* --- client induction form ----------------------------------------------- */

.intake-steps {
  display: flex; gap: 6px; margin-bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px;
}
.intake-step {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 6px 8px; border: 0; border-radius: calc(var(--radius) - 3px);
  background: transparent; color: var(--ink-4); font: inherit; font-size: 12.5px;
  font-weight: 550; cursor: pointer; min-width: 0;
}
.intake-step:hover { background: var(--surface-3); color: var(--ink-2); }
.intake-step.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-1); font-weight: 650; }
.intake-step.done { color: var(--ok); }
.intake-step .is-num {
  flex: 0 0 19px; width: 19px; height: 19px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--ink-3); font-size: 11px; font-weight: 650;
}
.intake-step.active .is-num { background: var(--brand); color: var(--brand-ink); }
.intake-step.done .is-num { background: var(--ok); color: #fff; }
.intake-step .is-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-list { display: grid; gap: 8px; }
.doc-chip {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); padding: 10px 12px;
}

.read-list { display: grid; gap: 2px; }
.read-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px 16px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.read-row:last-child { border-bottom: 0; }
.read-row.settled .rr-value input { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.read-row .rr-value input { width: 100%; }

.send-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ss-item {
  flex: 1 1 110px; text-align: center; padding: 12px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.ss-num { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ss-label { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; }

@media (max-width: 560px) {
  .read-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .intake-step .is-name { display: none; }
  .intake-step { flex: 0 0 auto; }
  .intake-steps { justify-content: space-between; }
}
