/* Lead Desk dashboard. Owner: module W. Self-hosted, no outside fonts or assets (R116).
   Look: the Meta Lead Journey map (midnight-blue dark theme, card shapes) plus a light theme.
   Colour tokens live on :root; dark mode follows the system unless the toggle sets data-theme. */

:root {
  color-scheme: light;
  --bg: #f3f5fb;
  --dot: rgba(10, 20, 48, 0.07);
  --surface: #ffffff;
  --surface-2: #eef2fa;
  --line: rgba(10, 20, 48, 0.14);
  --line-strong: rgba(10, 20, 48, 0.3);
  --ink: #0b1430;
  --muted: #45537a;
  --faint: #5d6a93;
  --link: #1d4ed8;
  --focus: #1d4ed8;
  --btn: #0b1430;
  --btn-ink: #ffffff;
  --good: #15803d;
  --watch: #a15c07;
  --act: #be123c;
  --off: #5d6a93;
  --good-bg: rgba(21, 128, 61, 0.09);
  --watch-bg: rgba(161, 92, 7, 0.1);
  --act-bg: rgba(190, 18, 60, 0.08);
  --off-bg: rgba(93, 106, 147, 0.1);
  --banner: #fff4d6;
  --banner-line: #e3b341;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1430;
    --dot: rgba(255, 255, 255, 0.075);
    --surface: #11204a;
    --surface-2: #13234f;
    --line: rgba(255, 255, 255, 0.17);
    --line-strong: rgba(255, 255, 255, 0.34);
    --ink: #f2f5ff;
    --muted: #b3bfe2;
    --faint: #94a1c6;
    --link: #9cc3ff;
    --focus: #ffffff;
    --btn: #f2f5ff;
    --btn-ink: #0a1430;
    --good: #4ade80;
    --watch: #fbbf24;
    --act: #fb7185;
    --off: #94a1c6;
    --good-bg: rgba(74, 222, 128, 0.12);
    --watch-bg: rgba(251, 191, 36, 0.12);
    --act-bg: rgba(251, 113, 133, 0.13);
    --off-bg: rgba(148, 161, 198, 0.12);
    --banner: #3a2c06;
    --banner-line: #fbbf24;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1430;
  --dot: rgba(255, 255, 255, 0.075);
  --surface: #11204a;
  --surface-2: #13234f;
  --line: rgba(255, 255, 255, 0.17);
  --line-strong: rgba(255, 255, 255, 0.34);
  --ink: #f2f5ff;
  --muted: #b3bfe2;
  --faint: #94a1c6;
  --link: #9cc3ff;
  --focus: #ffffff;
  --btn: #f2f5ff;
  --btn-ink: #0a1430;
  --good: #4ade80;
  --watch: #fbbf24;
  --act: #fb7185;
  --off: #94a1c6;
  --good-bg: rgba(74, 222, 128, 0.12);
  --watch-bg: rgba(251, 191, 36, 0.12);
  --act-bg: rgba(251, 113, 133, 0.13);
  --off-bg: rgba(148, 161, 198, 0.12);
  --banner: #3a2c06;
  --banner-line: #fbbf24;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -40px; background: var(--surface); padding: 6px 10px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-good { color: var(--good); }
.ic-watch { color: var(--watch); }
.ic-act { color: var(--act); }
.ic-off { color: var(--off); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--btn);
  background: var(--btn); color: var(--btn-ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn-wide { width: 100%; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.iconbtn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: transparent; cursor: pointer; display: grid; place-items: center; }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.iconbtn svg .fill { fill: currentColor; stroke: none; }

input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], select {
  min-height: 40px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); max-width: 100%;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--link); }

.notice, .error {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
}
.error { border-color: var(--act); background: var(--act-bg); }
.hint { color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------------ "?" terms (R133) */
.term { display: inline-block; position: relative; }
.term summary {
  list-style: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 13px; font-weight: 700;
  color: var(--muted);
}
.term summary::-webkit-details-marker { display: none; }
.term[open] summary { color: var(--ink); border-color: var(--ink); }
.term p {
  position: absolute; z-index: 5; top: 28px; right: 0; width: min(260px, 80vw); padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; font-size: 14px;
  font-weight: 400; color: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* ------------------------------------------------------------------ header */
.bar {
  position: sticky; top: 0; z-index: 4; display: grid; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.brand { font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.bar-end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.live { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.signout { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.who { color: var(--muted); }
.states { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600;
}
.pill.tone-good { background: var(--good-bg); }
.pill.tone-watch { background: var(--watch-bg); }
.pill.tone-act { background: var(--act-bg); border-color: var(--act); }
.pill.tone-off { background: var(--off-bg); }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px;
  background: var(--banner); border-bottom: 2px solid var(--banner-line);
}
.banner p { flex: 1 1 280px; }

/* ------------------------------------------------------------------ main */
.main { max-width: 1280px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 20px; }

.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.field.check label { font-size: 14px; color: var(--ink); font-weight: 500; }
.label-row { display: flex; align-items: center; gap: 6px; }

/* stage cards (R120) */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 16px 16px 14px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 18px;
  box-shadow: inset 4px 0 0 var(--off);
}
.card.st-good { box-shadow: inset 4px 0 0 var(--good); }
.card.st-watch { box-shadow: inset 4px 0 0 var(--watch); }
.card.st-act { box-shadow: inset 4px 0 0 var(--act); border-color: var(--act); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card h2 { font-size: 16px; font-weight: 700; line-height: 1.25; }
.num { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sentence { color: var(--ink); }
.later { color: var(--muted); font-size: 14px; border-left: 2px dashed var(--line-strong); padding-left: 8px; }
.status { margin-top: auto; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; padding-top: 8px; border-top: 1px solid var(--line); }

/* latest enquiries (masked contacts, R118) */
.latest { display: grid; gap: 10px; }
.section-head { display: grid; gap: 2px; }
.section-head h2 { font-size: 18px; }
.empty { color: var(--muted); }
.leadlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lead {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.6fr); gap: 8px 16px;
  align-items: start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.lead-name { font-weight: 700; overflow-wrap: anywhere; }
.lead-meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.lead-state { font-weight: 600; }
.lead-contact { display: grid; gap: 4px; justify-items: start; }
.contact { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.contact.masked { color: var(--muted); }
.shown { font-size: 13px; color: var(--watch); font-weight: 600; }
.reveal { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reveal select { min-height: 34px; padding: 4px 8px; font-size: 14px; max-width: 100%; }

/* ------------------------------------------------------------------ sign-in pages */
.public { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.public-card {
  width: min(440px, 100%); display: grid; gap: 14px; padding: 24px 22px; background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 18px;
}
.brand-public { font-weight: 800; font-size: 15px; color: var(--muted); letter-spacing: 0.02em; }
.public-card h1 { font-size: 24px; line-height: 1.25; }
.stack { display: grid; gap: 8px; }
.stack label { font-weight: 600; font-size: 14px; }
.stack .btn { margin-top: 6px; }
.demo { border-top: 1px solid var(--line); padding-top: 14px; }
.qr-box { justify-self: start; padding: 0; border-radius: 8px; overflow: hidden; line-height: 0; }
.qr { width: 196px; height: 196px; }
.key { font-family: var(--mono); font-size: 15px; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.codes { margin: 0; padding-left: 26px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.codes code { font-family: var(--mono); font-size: 16px; }

/* ------------------------------------------------------------------ shared page bits */
.page-title { font-size: 24px; line-height: 1.25; letter-spacing: -0.01em; }
.crumbs a { font-weight: 600; text-decoration: none; }
.see-all, .zoom { font-size: 14px; font-weight: 600; }
.zoom { margin-left: auto; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong);
  font-size: 12px; font-weight: 700; color: var(--muted); vertical-align: middle;
}
.tag-later { border-style: dashed; color: var(--watch); border-color: var(--watch); }
.flag { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.flag-red { color: var(--act); }
.flag-amber { color: var(--watch); }
.mono { font-family: var(--mono); font-size: 13px; }
.wrap { overflow-wrap: anywhere; }
.field-wide { flex: 1 1 280px; }
.more-filters { flex: 1 1 100%; }
.more-filters > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--link); padding: 4px 0; }
.more-filters > div { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding-top: 10px; }
.field-wide input { width: 100%; }
input[type="search"] {
  min-height: 40px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); max-width: 100%;
}
.filter-go { display: flex; align-items: center; gap: 12px; }
.list-head { display: grid; gap: 2px; }
.count { font-weight: 700; }
.searched { font-weight: 400; color: var(--muted); margin-left: 6px; }
.lead-next { color: var(--muted); font-size: 14px; }
.lead.flag-red { border-color: var(--act); box-shadow: inset 4px 0 0 var(--act); }
.lead.flag-amber { box-shadow: inset 4px 0 0 var(--watch); }
.lead.is-later, .is-later { border-style: dashed !important; }
.lead-state { display: grid; gap: 4px; }

/* worker not checking in (R127) */
.stale {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--act-bg);
  border-bottom: 2px solid var(--act); font-weight: 700;
}
.stale[hidden] { display: none; }

/* ------------------------------------------------------------------ one enquiry (R123-R126) */
.lead-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: start;
  padding: 16px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 18px;
}
.lead-title { display: grid; gap: 6px; min-width: 0; }
.state-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 20px; align-items: start; }
.lead-main, .lead-side { display: grid; gap: 16px; min-width: 0; }
.panel-box {
  display: grid; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-box h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.story p { font-size: 16px; line-height: 1.6; }
.next { box-shadow: inset 4px 0 0 var(--good); }
.next.tone-watch { box-shadow: inset 4px 0 0 var(--watch); }
.next.tone-act { box-shadow: inset 4px 0 0 var(--act); }
.next.tone-off { box-shadow: inset 4px 0 0 var(--off); }
.scrub-head { display: flex; align-items: center; gap: 8px; }
.scrub-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.scrub { flex: 1 1 200px; min-width: 0; accent-color: var(--link); }
.scrub-out { font-family: var(--mono); font-size: 13px; color: var(--muted); min-height: 1em; }
.facts { margin: 0; display: grid; gap: 8px; }
.facts div { display: grid; gap: 1px; }
.facts dt { font-size: 13px; font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; }
.quote { white-space: pre-wrap; overflow-wrap: anywhere; }

/* the timeline */
.timeline { display: grid; gap: 8px; }
.timeline > h2 { font-size: 18px; }
.day { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 8px; }
.tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tl-item {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--line-strong);
}
.tl-item.tone-good { box-shadow: inset 3px 0 0 var(--good); }
.tl-item.tone-watch { box-shadow: inset 3px 0 0 var(--watch); }
.tl-item.tone-act { box-shadow: inset 3px 0 0 var(--act); }
.tl-item.tone-off { box-shadow: inset 3px 0 0 var(--off); }
.tl-item.quiet { padding: 6px 12px; background: transparent; font-size: 14px; color: var(--muted); }
.tl-item.quiet .tl-title { font-weight: 500; }
.tl-time { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 2px; }
.tl-body { display: grid; gap: 6px; min-width: 0; }
.tl-title { font-weight: 700; overflow-wrap: anywhere; }
.tl-line { color: var(--ink); }
.why { overflow-wrap: anywhere; }
.checks summary, .tech summary, .forward summary, .as-text summary {
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px;
}
.checks ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.checks li { display: flex; align-items: flex-start; gap: 6px; }
.check-failed { display: flex; align-items: flex-start; gap: 6px; font-weight: 700; color: var(--act); }
.tech summary { color: var(--muted); font-weight: 500; }
.tech dl { margin: 8px 0 0; display: grid; gap: 4px; font-size: 13px; }
.tech dl div { display: grid; grid-template-columns: minmax(110px, 180px) minmax(0, 1fr); gap: 8px; }
.tech dt { color: var(--muted); }
.tech dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

/* messages exactly as they looked (R124) */
.bubble {
  display: grid; gap: 6px; max-width: 520px; padding: 10px 12px; border-radius: 16px;
  border: 1px solid var(--line-strong); background: var(--surface-2); margin: 0;
}
.bubble.chat { justify-self: end; border-bottom-right-radius: 4px; background: var(--good-bg); }
.bubble.chat-whatsapp { background: rgba(37, 211, 102, 0.14); }
.bubble.them { justify-self: start; border-bottom-left-radius: 4px; border-bottom-right-radius: 16px; background: var(--surface-2); }
.bubble.email { max-width: 100%; justify-self: stretch; border-radius: 12px; }
.bubble.bad { border-color: var(--act); }
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: inherit; }
.bubble-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.bubble-status { display: flex; align-items: center; gap: 6px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.subject { font-weight: 700; }
.practice { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--off); }
.mail { width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.ticks { font-weight: 800; letter-spacing: -0.12em; color: var(--muted); }
.ticks-read { color: var(--link); }
.ticks-bad { color: var(--act); }
.statuses { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.statuses time { font-family: var(--mono); }
.statuses .tone-act { color: var(--act); font-weight: 700; }

/* ------------------------------------------------------------------ activity (R174) */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.feed-line {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid transparent; box-shadow: inset 3px 0 0 var(--line);
}
.feed-line time { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 2px; }
.feed-line p { overflow-wrap: anywhere; }
.feed-line.tone-good { box-shadow: inset 3px 0 0 var(--good); }
.feed-line.tone-watch { box-shadow: inset 3px 0 0 var(--watch); }
.feed-line.tone-act { box-shadow: inset 3px 0 0 var(--act); }
.feed-line.is-later { border: 1px dashed var(--watch); }
.sys { font-weight: 600; color: var(--muted); }

/* ------------------------------------------------------------------ how it works: map + side panel (R121) */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.map-wrap:has(.inline-panel) { grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); }
.map { display: grid; gap: 14px; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px 30px; counter-reset: step; }
.node { position: relative; min-width: 0; }
.flow:not(.exits) .node:not(:last-child)::after {
  content: ""; position: absolute; top: 50%; right: -24px; width: 18px; height: 2px; background: var(--line-strong);
}
.flow:not(.exits) .node:not(:last-child)::before {
  content: ""; position: absolute; top: calc(50% - 5px); right: -26px; border: 5px solid transparent;
  border-left-color: var(--line-strong);
}
.node-link {
  display: grid; gap: 4px; height: 100%; padding: 14px; border-radius: 18px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong); box-shadow: inset 4px 0 0 var(--good);
}
.node.st-watch .node-link { box-shadow: inset 4px 0 0 var(--watch); }
.node.st-act .node-link { box-shadow: inset 4px 0 0 var(--act); border-color: var(--act); }
.node.is-open .node-link { outline: 2px solid var(--link); outline-offset: 2px; }
.node-link:hover { border-color: var(--link); }
.node-title { font-weight: 700; }
.node-num { font-size: 34px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.node-sentence { font-size: 14px; color: var(--muted); }
.node-fail { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--act); }
.exits-h { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.flow.exits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inline-panel, .drawer .panel { background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 18px; }
.panel { display: grid; gap: 12px; padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: 18px; }
.close { text-decoration: none; font-size: 22px; color: var(--ink); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 6px 10px; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a[aria-selected="true"] { color: var(--ink); background: var(--surface-2); }
.tab { display: grid; gap: 8px; }
.tab h3 { font-size: 15px; }
.tab h4 { font-size: 14px; color: var(--muted); }
.tab ul, .tab ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.js .tabs-on .tab h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.js .tabs-on .tab[hidden] { display: none; }
.drawer {
  position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); overflow-y: auto;
  padding: 12px; background: var(--bg); border-left: 1px solid var(--line-strong);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
}
.drawer[hidden] { display: none; }

/* ------------------------------------------------------------------ help (R133) */
.tabs-plain { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tabs-plain a { font-weight: 600; text-decoration: none; padding: 4px 10px; border-radius: 8px; }
.tabs-plain a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.prose { max-width: 760px; gap: 10px; }
.prose h2 { font-size: 20px; }
.prose h3 { font-size: 16px; margin-top: 8px; }
.glossary { margin: 0; }
.glossary div { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); gap: 4px 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; }
@media (max-width: 560px) { .glossary div { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ narrower screens */
@media (min-width: 1101px) {
  .flow:not(.exits) .node:nth-child(4n)::after, .flow:not(.exits) .node:nth-child(4n)::before { display: none; }
}
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-grid, .map-wrap:has(.inline-panel) { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow:not(.exits) .node:nth-child(2n)::after, .flow:not(.exits) .node:nth-child(2n)::before { display: none; }
}
@media (max-width: 760px) {
  .lead { grid-template-columns: minmax(0, 1fr); }
  .lead-head { grid-template-columns: minmax(0, 1fr); }
  .flow, .flow.exits { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .flow:not(.exits) .node:not(:last-child)::after { display: block; top: auto; bottom: -16px; right: auto; left: 28px; width: 2px; height: 12px; }
  .flow:not(.exits) .node:not(:last-child)::before { display: block; top: auto; bottom: -24px; right: auto; left: 24px; border: 5px solid transparent; border-top-color: var(--line-strong); }
  .drawer { width: 100vw; border-left: 0; }
  .bar-end { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .num { font-size: 38px; }
  .filters, .more-filters > div { flex-direction: column; align-items: stretch; }
  .field-wide { flex: none; }
  .filters select, .filters input[type="datetime-local"] { width: 100%; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .tl-item, .feed-line { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tech dl div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .bubble { max-width: 100%; }
  .filter-go { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- W2-APP: the clinic's own pages (second nav bar, home tiles, scoreboard, Clinic Map, settings) */
.nav-clinic { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; }
.nav-clinic a { padding: 4px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; font-size: 0.92em; }
.nav-clinic a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 0; list-style: none; }
.tile { border: 1px solid var(--line, #ddd); border-radius: 10px; padding: 12px; background: var(--surface, transparent); }
.tile .figure { font-size: 1.8em; font-weight: 700; margin: 4px 0; }
.tile .status { font-weight: 600; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: 0.85em; }
.stop { margin: 16px 0; }
.cards { list-style: none; padding: 0; display: grid; gap: 10px; }
.is-missing { color: #b00020; font-weight: 700; }
table.history { border-collapse: collapse; width: 100%; }
table.history th, table.history td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line, #ddd); }
