/* Layout: clinical app shell — fixed left rail (desktop) / bottom tab bar (phone), white work surfaces on a cool field */
:root {
  --field: #eef3f9;
  --surface: #ffffff;
  --sunk: #f4f7fb;
  --ink: #0c1b2e;
  --ink-2: #33465e;
  --muted: #64758b;
  --line: #dbe3ee;
  --line-2: #e9eef5;
  --brand: #0b5bd3;
  --brand-ink: #ffffff;
  --brand-soft: #e7effd;
  --brand-deep: #08306b;
  --rail: #0a2147;
  --rail-ink: #c9d6ea;
  --ok: #138049;  --ok-soft: #e3f4ea;
  --warn: #a76200; --warn-soft: #fdf0dc;
  --bad: #c42b1c;  --bad-soft: #fde6e3;
  --device: #2d3a48; --device-2: #3d4c5c;
  --display: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --shadow: 0 1px 2px rgba(12, 27, 46, .05), 0 4px 16px rgba(12, 27, 46, .05);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --field: #08111d; --surface: #0f1b2b; --sunk: #0b1624; --ink: #e8eef7; --ink-2: #c3cfdf; --muted: #8798ae;
  --line: #1f3047; --line-2: #18273b; --brand: #5b9cff; --brand-ink: #04142c; --brand-soft: #12284a; --brand-deep: #9cc2ff;
  --rail: #060e1a; --rail-ink: #a9b9cf;
  --ok: #4fcf88; --ok-soft: #0f2d1f; --warn: #f2b14f; --warn-soft: #332410; --bad: #ff7a6b; --bad-soft: #3a1714;
  --device: #4a5a6c; --device-2: #5b6c7f; --shadow: none; color-scheme: dark; } }
:root[data-theme="dark"] {
  --field: #08111d; --surface: #0f1b2b; --sunk: #0b1624; --ink: #e8eef7; --ink-2: #c3cfdf; --muted: #8798ae;
  --line: #1f3047; --line-2: #18273b; --brand: #5b9cff; --brand-ink: #04142c; --brand-soft: #12284a; --brand-deep: #9cc2ff;
  --rail: #060e1a; --rail-ink: #a9b9cf;
  --ok: #4fcf88; --ok-soft: #0f2d1f; --warn: #f2b14f; --warn-soft: #332410; --bad: #ff7a6b; --bad-soft: #3a1714;
  --device: #4a5a6c; --device-2: #5b6c7f; --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
td b, .mono { white-space: nowrap; }
html, body { height: 100%; }
body { margin: 0; background: var(--field); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; text-wrap: balance; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.45rem, 2.4vw, 1.85rem); font-weight: 800; }
h2 { font-size: 1.08rem; font-weight: 800; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: .84em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { font: 700 .7rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex: none; }

/* ---------- shell ---------- */
.demo { background: var(--brand-deep); color: var(--field); font-size: .78rem; text-align: center; padding: 5px 16px; }
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: calc(100% - 26px); }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; gap: 22px; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: #fff; }
.logo b { font: 800 1.08rem var(--display); display: block; line-height: 1.05; letter-spacing: -.01em; }
.logo span { font-size: .72rem; color: var(--rail-ink); opacity: .8; }
.rail nav { display: grid; gap: 2px; }
.rail nav button { display: flex; align-items: center; gap: 12px; border: 0; background: none; color: var(--rail-ink); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; text-align: left; }
.rail nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.rail nav button[aria-current="page"] { background: rgba(91,156,255,.16); color: #fff; box-shadow: inset 3px 0 0 #5b9cff; }
.rail nav .count { margin-left: auto; background: #c42b1c; color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.rail .sect { font: 700 .66rem var(--body); letter-spacing: .12em; text-transform: uppercase; opacity: .55; padding: 0 12px; margin-bottom: 4px; }
.role { margin-top: auto; background: rgba(255,255,255,.05); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.role select { width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.14); border-radius: 7px; padding: 7px 8px; font: 600 .85rem var(--body); }
.role select option { color: #0c1b2e; }
.me { display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 700 .75rem var(--display); background: #5b9cff; color: #04142c; flex: none; }

.topbar { position: sticky; top: 0; z-index: 6; background: color-mix(in srgb, var(--field) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); padding-block: 14px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line-2); }
.search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; background: none; outline: none; padding: 9px 0; width: 100%; font: inherit; color: var(--ink); }
.top-date { margin-left: auto; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.mobile-logo { display: none; }
main { padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); padding-block: 24px 80px; }
.page { max-width: 1240px; margin: 0 auto; display: grid; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head p { color: var(--muted); margin-top: 4px; }

.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); top: env(safe-area-inset-top, 0px); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--field); }
  .mobile-logo { display: flex; align-items: center; gap: 8px; font: 800 1rem var(--display); }
  .search { display: none; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--muted); padding: 4px 0; cursor: pointer; }
  .tabbar button[aria-current="page"] { color: var(--brand); }
  .tabbar .scanbtn span.ring { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; margin-top: -20px; box-shadow: 0 6px 16px rgba(11,91,211,.35); }
}

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stack { display: grid; gap: 12px; }
.g-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.g-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
@media (max-width: 1080px) { .g-main, .g-2 { grid-template-columns: minmax(0, 1fr); } }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 9px 14px; font-weight: 700; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); color: var(--brand-ink); }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
label.field { display: grid; gap: 5px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }

.pill { display: inline-flex; align-items: center; gap: 6px; font: 700 .7rem var(--body); letter-spacing: .07em; text-transform: uppercase; padding: 4px 10px 4px 8px; border-radius: 99px; white-space: nowrap; }
.pill svg.lucide { width: 14px; height: 14px; stroke-width: 2.4; }
.s-READY { background: var(--ok-soft); color: var(--ok); }
.s-DUE { background: var(--warn-soft); color: var(--warn); }
.s-ATTN { background: var(--bad-soft); color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-weight: 600; font-size: .85rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { color: var(--muted); font-weight: 700; } .chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.seg { display: inline-flex; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: .85rem; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font: 700 .68rem var(--body); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--sunk); }
.t-bad { color: var(--bad); font-weight: 700; } .t-warn { color: var(--warn); font-weight: 700; }

/* ---------- overview ---------- */
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; padding: 26px; }
.hero h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); line-height: 1.2; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.hstat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; text-align: left; background: var(--surface); cursor: pointer; }
.hstat:hover { border-color: var(--brand); }
.hstat .k { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .8rem; }
.hstat strong { font: 800 1.9rem/1.1 var(--display); font-variant-numeric: tabular-nums; color: var(--ink); }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } .hero-stats { grid-template-columns: 1fr; text-align: left; } }

.alert { display: grid; grid-template-columns: 4px auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px 12px 0; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); text-align: left; width: 100%; overflow: hidden; }
.alert:hover { border-color: var(--brand); }
.alert .stripe { align-self: stretch; }
.alert .why { font-size: .85rem; color: var(--muted); }
@media (max-width: 560px) { .alert { grid-template-columns: 4px minmax(0, 1fr) auto; } .alert .dev { display: none; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cbar { display: grid; grid-template-columns: minmax(110px, 190px) minmax(0, 1fr) 46px; gap: 12px; align-items: center; padding: 7px 0; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.cbar:hover .cname { color: var(--brand); }
.cname { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stackbar { display: flex; gap: 2px; height: 22px; }
.stackbar i { display: grid; place-items: center; font: 700 .72rem var(--body); font-style: normal; color: #fff; min-width: 0; }
.stackbar i:first-child { border-radius: 5px 0 0 5px; } .stackbar i:last-child { border-radius: 0 5px 5px 0; } .stackbar i:only-child { border-radius: 5px; }
.cpct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .88rem; }

.cols { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; align-items: end; height: 170px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; cursor: default; }
.col .v { font: 700 .75rem var(--body); color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.col .b { width: min(26px, 80%); border-radius: 4px 4px 0 0; background: var(--brand); }
.col:hover .b { filter: brightness(1.12); }
.col-l { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; font-size: .7rem; color: var(--muted); text-align: center; padding-top: 6px; }

.agenda { display: grid; gap: 4px; }
.ag { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 6px; border-radius: 9px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.ag:hover { background: var(--sunk); }
.cal { border: 1px solid var(--line); border-radius: 8px; text-align: center; overflow: hidden; background: var(--surface); }
.cal b { display: block; font: 800 1.05rem/1.4 var(--display); }
.cal span { display: block; font: 700 .6rem/1.6 var(--body); text-transform: uppercase; letter-spacing: .08em; color: #fff; background: var(--brand); }
.cal.bad span { background: var(--bad); } .cal.warn span { background: var(--warn); }
.feed { display: grid; gap: 14px; }
.fi { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.fi .ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.fi .ic svg.lucide { width: 15px; height: 15px; }

/* ---------- fleet ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 200px; }
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.unit { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; display: grid; gap: 14px; cursor: pointer; text-align: left; width: 100%; }
.unit:hover { border-color: var(--brand); transform: translateY(-1px); }
@media (prefers-reduced-motion: no-preference) { .unit { transition: transform .15s, border-color .15s; } }
.unit-top { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; }
.unit-top .id { font: 800 1.02rem var(--display); }
.unit-top .loc { font-size: .83rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.meter { display: grid; gap: 4px; font-size: .74rem; color: var(--muted); }
.meter b { color: var(--ink); font-size: .8rem; font-variant-numeric: tabular-nums; }
.track { height: 5px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 99px; }

/* ---------- AED detail ---------- */
.dhead { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 24px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; color: var(--muted); }
.crumbs svg.lucide { width: 14px; height: 14px; }
.dhead h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.dhead .acts { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
@media (max-width: 760px) { .dhead { grid-template-columns: 1fr; } .dhead .dev-big { display: none; } .dhead .acts { flex-direction: row; flex-wrap: wrap; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-pressed="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.reasons { display: grid; gap: 8px; }
.reason { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px; background: var(--sunk); font-size: .9rem; }
.reason svg.lucide { margin-top: 1px; }
.gauges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.gauge { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; }
.gauge .t { font-weight: 700; font-size: .9rem; } .gauge .s { font-size: .8rem; color: var(--muted); }
@media (max-width: 520px) { .gauges { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: minmax(140px, 42%) minmax(0, 1fr); gap: 0; margin: 0; font-size: .9rem; }
dl.kv dt, dl.kv dd { padding: 9px 0; border-bottom: 1px solid var(--line-2); margin: 0; }
dl.kv dt { color: var(--muted); padding-right: 12px; } dl.kv dd { font-weight: 600; overflow-wrap: anywhere; }
.yes { color: var(--ok); } .no { color: var(--bad); }
.timeline { display: grid; gap: 0; position: relative; }
.ti { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; position: relative; }
.ti::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: var(--line); }
.ti:last-child::before { display: none; }
.ti .ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); color: var(--muted); }
.ti .ic svg.lucide { width: 16px; height: 16px; }
.ti.ok .ic { border-color: var(--ok); color: var(--ok); } .ti.bad .ic { border-color: var(--bad); color: var(--bad); } .ti.warn .ic { border-color: var(--warn); color: var(--warn); }
.qrcard { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; border: 2px dashed var(--line); border-radius: 12px; padding: 14px; }
.qr { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.qr img, .qr canvas { width: 104px; height: 104px; }

/* ---------- inspect ---------- */
.scanner { position: relative; background: radial-gradient(120% 90% at 50% 40%, #233650, #070f1c); border-radius: 18px; aspect-ratio: 4 / 3; max-width: 100%; overflow: hidden; display: grid; place-items: center; color: #dbe6f5; }
.scanner .frame { width: 54%; aspect-ratio: 1; position: relative; }
.scanner .frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.scanner .frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.scanner .frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.scanner .frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.scanner .frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.scanner .line { position: absolute; left: 8%; right: 8%; height: 2px; background: #5b9cff; box-shadow: 0 0 14px 3px rgba(91,156,255,.7); top: 50%; }
@media (prefers-reduced-motion: no-preference) { .scanner .line { animation: scan 2.4s ease-in-out infinite alternate; } }
@keyframes scan { from { top: 10%; } to { top: 88%; } }
.scanner .fake-qr { width: 60%; opacity: .2; }
.scanner .hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: .85rem; opacity: .85; }
.ins-head { position: sticky; top: 63px; z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; display: grid; gap: 10px; box-shadow: var(--shadow); }
@media (max-width: 900px) { .ins-head { top: calc(58px + env(safe-area-inset-top, 0px)); } }
.progress { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
@media (prefers-reduced-motion: no-preference) { .progress i { transition: width .25s; } }
.qitem { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line-2); }
.qitem:last-child { border-bottom: 0; }
.qnum { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 800 .8rem var(--display); background: var(--sunk); color: var(--muted); }
.qitem.done .qnum { background: var(--ok); color: #fff; } .qitem.flag .qnum { background: var(--bad); color: #fff; } .qitem.na .qnum { background: var(--muted); color: #fff; }
.qitem .qt { font-weight: 700; } .qitem .qh { font-size: .85rem; color: var(--muted); }
.crit { font: 700 .62rem var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--bad); background: var(--bad-soft); padding: 2px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 2px; }
.answers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; max-width: 460px; }
.answers button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 6px; font-weight: 700; font-size: .85rem; cursor: pointer; display: inline-flex; gap: 6px; justify-content: center; align-items: center; color: var(--ink-2); }
.answers button svg.lucide { width: 16px; height: 16px; }
.answers button.on-PASS { background: var(--ok); border-color: var(--ok); color: #fff; }
.answers button.on-ATTN { background: var(--bad); border-color: var(--bad); color: #fff; }
.answers button.on-NA { background: var(--muted); border-color: var(--muted); color: #fff; }
.qitem textarea { margin-top: 10px; }
canvas.sig { width: 100%; height: 150px; background: var(--sunk); border: 1px dashed var(--line); border-radius: 10px; touch-action: none; display: block; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photos img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px; display: grid; justify-items: center; gap: 6px; color: var(--muted); cursor: pointer; text-align: center; }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.success { text-align: center; display: grid; justify-items: center; gap: 12px; padding: 36px 20px; }
.success .big { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.success .big svg.lucide { width: 38px; height: 38px; stroke-width: 2.4; }

/* ---------- actions board ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 980px) { .board { grid-template-columns: 1fr; } }
.lane { background: var(--sunk); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.lane-h { display: flex; align-items: center; gap: 8px; font-weight: 800; font-family: var(--display); padding: 4px 4px 2px; }
.lane-h .n { margin-left: auto; color: var(--muted); font-family: var(--body); font-size: .85rem; }
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; display: grid; gap: 8px; text-align: left; width: 100%; cursor: pointer; box-shadow: var(--shadow); }
.ticket:hover { border-color: var(--brand); }
.ticket .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .78rem; color: var(--muted); align-items: center; }
.ticket .meta span { display: inline-flex; gap: 4px; align-items: center; }
.ticket .meta svg.lucide { width: 14px; height: 14px; }
.mini-av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font: 700 .6rem var(--display); background: var(--brand-soft); color: var(--brand); }
.drawer-bg { position: fixed; inset: 0; background: rgba(6, 14, 26, .45); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); z-index: 31; overflow-y: auto; display: grid; align-content: start; gap: 18px;
  padding: calc(22px + env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) 22px; box-shadow: -10px 0 40px rgba(0,0,0,.2); }

/* ---------- clients ---------- */
.clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.client { display: grid; gap: 14px; }
.client .ring-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; }

/* ---------- report ---------- */
.rep-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .rep-wrap { grid-template-columns: 1fr; } }
.paper { background: #fff; color: #0c1b2e; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 18px 50px rgba(12,27,46,.14); padding: clamp(20px, 5vw, 56px); display: grid; gap: 26px; min-width: 0; }
.paper .muted { color: #5c6c80; }
.paper th { color: #5c6c80; border-bottom-color: #d6dee9; } .paper td { border-bottom-color: #edf1f6; }
.paper .table-wrap { margin: 0; padding: 0; }
.letterhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 3px solid #0b5bd3; }
.rep-sum { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 26px; align-items: center; background: #f3f7fc; border-radius: 10px; padding: 20px; }
@media (max-width: 560px) { .rep-sum { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.rep-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.rep-kpis div { display: grid; } .rep-kpis strong { font: 800 1.6rem var(--display); font-variant-numeric: tabular-nums; }
.paper .pill.s-READY { background: #e3f4ea; color: #138049; } .paper .pill.s-DUE { background: #fdf0dc; color: #a76200; } .paper .pill.s-ATTN { background: #fde6e3; color: #c42b1c; }
.sign { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; padding-top: 10px; }
.sign div { border-top: 1px solid #0c1b2e; padding-top: 6px; font-size: .8rem; color: #5c6c80; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 10px; font-weight: 600; z-index: 40; max-width: calc(100% - 32px); display: flex; gap: 8px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
@media (max-width: 900px) { .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); } }
.empty { text-align: center; padding: 28px; color: var(--muted); }
.toast[hidden] { display: none; }
.bell { position: relative; padding: 9px 11px; }
.bell .dotn { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; border-radius: 99px; background: var(--bad); color: #fff; font: 700 .68rem/19px var(--body); text-align: center; padding: 0 5px; border: 2px solid var(--field); }
.nlist { display: grid; gap: 6px; }
.nitem { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 11px 12px; cursor: pointer; width: 100%; }
.nitem > span:last-child { display: grid; gap: 2px; }
.nitem .ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--muted); }
.nitem.unread { border-color: var(--brand); background: var(--brand-soft); } .nitem.unread .ic { background: var(--brand); color: var(--brand-ink); }
.nitem:hover { border-color: var(--brand); }
.choice { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 14px; align-items: center; text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 16px; cursor: pointer; width: 100%; }
.choice:hover { border-color: var(--brand); } .choice > span:last-child { display: grid; gap: 2px; }
.choice .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; }
label.cb { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; color: var(--ink); padding: 6px 0; cursor: pointer; }
label.cb input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
div.field { display: grid; gap: 2px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.probs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; } @media (max-width: 480px) { .probs { grid-template-columns: 1fr; } }
.repl { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; display: grid; gap: 6px; }
.banner-note { display: flex; gap: 8px; align-items: center; background: var(--brand-soft); color: var(--brand-deep); border-radius: 10px; padding: 10px 14px; font-size: .88rem; font-weight: 600; }
tr.sel td { background: var(--brand-soft); }
.email { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .88rem; }
.email-h { background: var(--sunk); padding: 10px 14px; display: grid; gap: 3px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.email-h .muted { display: inline-block; width: 58px; }
.email-b { padding: 16px; display: grid; gap: 10px; background: var(--surface); }
.email-btn { justify-self: start; background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 8px 14px; border-radius: 8px; }
.sms { background: var(--sunk); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.bubble { justify-self: start; max-width: 88%; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px 13px; font-size: .88rem; }
.phase2 { background: linear-gradient(135deg, var(--brand-soft), var(--surface)); }
.phase2 .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); flex: none; }
.site-cta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } @media (max-width: 640px) { .site-cta { grid-template-columns: 1fr; } }

.paper td.num, .paper td:first-child { white-space: nowrap; }
@media (max-width: 900px) { .top-date, #top-scan { display: none; } }
@media (max-width: 560px) { .alert .pill { display: none; } .alert { grid-template-columns: 4px minmax(0, 1fr); } }

/* Client workspace: records first, one clear next action. */
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 99; background: var(--surface); padding: 12px; color: var(--brand); }
.skip-link:focus { top: 10px; }
.client-head { align-items: center; }
.client-head .eyebrow { color: var(--brand); margin-bottom: 7px; }
.client-head h1 { font-size: clamp(1.65rem, 3vw, 2.1rem); }
.client-head .account { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--muted); }
.client-summary { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr); gap: 24px; padding: 28px; background: linear-gradient(115deg, var(--surface), var(--brand-soft)); }
.client-summary h2 { font-size: clamp(1.35rem,2.3vw,1.75rem); line-height: 1.3; margin: 8px 0; }
.client-summary .summary-note { max-width: 48ch; color: var(--ink-2); }
.client-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; align-self: center; }
.client-metric { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 17px 13px; display: grid; gap: 8px; text-align: left; cursor: pointer; }
.client-metric:hover { border-color: var(--brand); transform: translateY(-2px); }
.client-metric strong { font: 800 2.2rem/1 var(--display); }
.client-metric .metric-label { font-size: .8rem; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.client-metric .metric-label svg { width: 15px; height: 15px; }
.client-metric small { font-size: .72rem; color: var(--muted); }
.record-note { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: flex-start; gap: 8px; font-size: .8rem; color: var(--muted); }
.client-layout { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(280px,1fr); gap: 22px; align-items: start; }
.client-tasks { display: grid; }
.client-task { padding: 18px 0; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 38px minmax(0,1fr) auto; gap: 12px; align-items: start; }
.client-task:last-child { border-bottom: 0; padding-bottom: 0; }
.task-icon { height: 36px; width: 36px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; }
.task-icon.urgent { background: var(--bad-soft); color: var(--bad); }
.client-task h3 { margin: 3px 0 4px; }
.client-task p { font-size: .84rem; color: var(--muted); }
.task-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; color: var(--warn); }
.task-tag.overdue { color: var(--bad); }
.task-next { margin-top: 9px !important; color: var(--ink-2) !important; }
.client-task .btn { align-self: center; }
.section-caption { color: var(--muted); font-size: .83rem; margin-top: 4px; }
.client-help .choice { grid-template-columns: 36px minmax(0,1fr) 16px; gap: 10px; padding: 14px 0; border: 0; border-radius: 0; box-shadow: none; border-top: 1px solid var(--line-2); background: transparent; }
.client-help .choice:hover { background: var(--sunk); }
.client-help .choice .ic { width: 36px; height: 36px; }
.client-help .choice b { font-size: .9rem; }
.client-help .choice .small { display: block; margin-top: 3px; font-size: .8rem; }
.client-help .choice > svg { margin-left: auto; }
.client-device-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.client-device { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; color: var(--ink); text-align: left; cursor: pointer; min-width: 0; }
.client-device:hover { border-color: var(--brand); background: var(--sunk); }
.client-device-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 13px; }
.client-device h3 { margin-bottom: 4px; }
.client-device .location { font-size: .82rem; color: var(--muted); min-height: 2.8em; }
.client-device footer { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 13px; display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--muted); }
.client-device footer svg { width: 15px; height: 15px; color: var(--brand); }
.client-agenda { display: grid; }
.client-agenda .ag { grid-template-columns: 40px minmax(0,1fr); }
.client-agenda .ag .when { display: block; font-size: .75rem; margin-top: 2px; }
.client-report { display: flex; align-items: flex-start; gap: 12px; background: var(--brand-soft); border-color: transparent; }
.client-report > svg { width: 24px; height: 24px; color: var(--brand); }
.client-report p { font-size: .83rem; color: var(--ink-2); margin: 6px 0 13px; }
.client-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 4px; font-size: .76rem; color: var(--muted); }
.demo { background: var(--brand-soft); color: var(--ink-2); border-bottom: 1px solid var(--line); }
@media (max-width: 1150px) { .client-summary { grid-template-columns: 1fr; gap: 18px; } .client-layout { grid-template-columns: minmax(0,1fr) 300px; } }
@media (max-width: 760px) { .client-layout { grid-template-columns: 1fr; } .client-head .row { width: 100%; } .client-head .row .btn { flex: 1; justify-content: center; } .client-summary { padding: 20px; } }
@media (max-width: 480px) { .client-metric { padding: 13px 8px; } .client-metric .metric-label { font-size: .72rem; } .client-metric .metric-label svg { display: none; } .client-metric strong { font-size: 1.8rem; } .client-device-grid { grid-template-columns: 1fr; } .client-task { grid-template-columns: 32px minmax(0,1fr); gap: 10px; } .client-task .btn { grid-column: 2; justify-self: start; } .task-icon { width: 32px; height: 32px; } .client-head .account { font-size: .8rem; } }
@media (prefers-reduced-motion: no-preference) { .client-metric { transition: transform .15s, border-color .15s; } }

/* ---------- production additions ---------- */
.logo-card { background: #fff; border-radius: 12px; padding: 10px 12px 8px; display: grid; gap: 4px; justify-items: center; }
.logo-card img { width: 100%; height: auto; display: block; }
.logo-card span { font: 700 .68rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: #33465e; }
.mobile-logo img { border-radius: 6px; background: #fff; }
.rail-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; flex: 1; justify-content: center; }
.rail-btn:hover { color: #fff; border-color: #5b9cff; }
.mobile-only { display: none; }
@media (max-width: 900px) { .mobile-only { display: inline-flex; } }
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 16px; }
.auth-card .brand { background: #fff; border-radius: 10px; padding: 8px; }
.auth-card .brand img { width: 100%; height: auto; display: block; }
.auth-card input { width: 100%; }
.auth-card .btn { justify-content: center; }
.form-err { color: var(--bad); font-weight: 600; font-size: .88rem; min-height: 1.2em; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.thumbs img.sigimg { width: 120px; object-fit: contain; background: #fff; }
.scan-help { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; align-items: center; background: var(--sunk); border-radius: 12px; padding: 16px; }
.scan-help .ic { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.scan-help .ic svg.lucide { width: 28px; height: 28px; }
button[disabled] { opacity: .55; cursor: default; }
@media print {
  .rail, .topbar, .tabbar, .toast, .page-head, .rep-wrap > aside, .skip-link, #overlay { display: none !important; }
  body { background: #fff; } main { padding: 0 !important; } .shell { display: block; }
  .rep-wrap { display: block; } .paper { box-shadow: none; padding: 0; }
}

canvas.sig { background: #fff; }
