/* ───────────────────────────────────────────────────────────────────────────
   The layout system. Every screen inherits it, so the rules hold everywhere
   rather than per page.

   FLAG-060 — full width by default. There is no max-width on the content
   column. A 900px column centred on a 1920px monitor throws away half the
   data, and these screens exist to be read densely.

   FLAG-061 — one layout, four sizes: phone (<640), tablet (640-1023),
   laptop (1024-1439), desktop (1440+). The sidebar collapses to a bottom bar
   on a phone; tables become stacked cards rather than scrolling sideways.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --bg: #f8fafc;
  --panel: #ffffff;
  --brand: #128c7e;
  --brand-ink: #0b5f55;
  --brand-wash: #e6f4f1;
  --good: #15803d;
  --warn: #b45309;
  --warn-wash: #fffbeb;
  --bad: #b91c1c;
  --bad-wash: #fef2f2;

  --r: 10px;
  --r-sm: 7px;
  --gap: 16px;
  --rail: 232px;
  --head: 56px;
  --bar: 0px;              /* phone bottom bar height, set in the media query */
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8edf5; --ink-2: #a9b6c9; --muted: #6b7a90;
    --line: #27303f; --line-2: #1b222e;
    --bg: #0d1117; --panel: #151b24;
    --brand: #25d366; --brand-ink: #7ae6a3; --brand-wash: #10251b;
    --warn-wash: #241c0a; --bad-wash: #2a1414;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --ink: #e8edf5; --ink-2: #a9b6c9; --muted: #6b7a90;
  --line: #27303f; --line-2: #1b222e;
  --bg: #0d1117; --panel: #151b24;
  --brand: #25d366; --brand-ink: #7ae6a3; --brand-wash: #10251b;
  --warn-wash: #241c0a; --bad-wash: #2a1414;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;                     /* FLAG-061: never sideways */
}
a { color: var(--brand-ink); }

/* ── Shell ─────────────────────────────────────────────────────────────────
   Grid, not floats: the rail is a column that disappears at phone width
   instead of being pushed off-screen. */
.shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  grid-template-rows: var(--head) 1fr;
  grid-template-areas: "rail head" "rail main";
  height: 100vh; height: 100dvh;          /* dvh: phone browser chrome */
  width: 100%;
}
.shell[data-full="1"] { --rail: 0px; }
.shell[data-full="1"] .rail { display: none; }

.rail {
  grid-area: rail; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 9px; padding: 0 16px;
  height: var(--head); font-weight: 700; letter-spacing: -.01em; flex: 0 0 auto;
  border-bottom: 1px solid var(--line-2);
}
.brand .mark {
  width: 24px; height: 24px; border-radius: 6px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-size: 13px; flex: 0 0 24px;
}
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none;
  font-weight: 500; white-space: nowrap; min-width: 0;
}
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-wash); color: var(--brand-ink); font-weight: 650; }
.nav .ico { width: 18px; text-align: center; flex: 0 0 18px; opacity: .85; }
.nav .lbl { overflow: hidden; text-overflow: ellipsis; }
.rail-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }

.head {
  grid-area: head; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 14px; min-width: 0;
}
.head h1 { font-size: 16px; margin: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .spacer { flex: 1 1 auto; min-width: 0; }

.main { grid-area: main; overflow: auto; padding: var(--gap); padding-bottom: calc(var(--gap) + var(--bar)); min-width: 0; }

/* Full-width content. Deliberately no max-width — FLAG-060. */
.stack { display: flex; flex-direction: column; gap: var(--gap); width: 100%; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel > header { padding: 13px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel > header h2 { font-size: 14.5px; margin: 0; font-weight: 650; }
.panel > .body { padding: 16px; }

/* Tiles: auto-fit, so the same markup is 1-up on a phone and 4-up on a monitor. */
/* A box inside a panel: a form, a sequence step, a pack, a widget snippet.
   WRITTEN AT ELEVEN CALL SITES ACROSS SIX SCREENS AND DEFINED AT NONE, so
   every one of them drew as a bare div — no border, no padding, no
   separation from the thing above it. The same failure as the undefined
   note modifiers and the bare label in FLAG-062: a class that reads as
   styling and does nothing, silently, on screens nobody thought to
   re-examine. */
.card { background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--r-sm); padding: 13px 15px; min-width: 0; }
.card + .card { margin-top: 11px; }
.card > header { display: flex; align-items: center; gap: 8px;
                 margin-bottom: 7px; }
.card > p { margin: 0 0 7px; color: var(--ink-2); font-size: 13.5px; }
.card .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
           color: var(--muted); font-weight: 650; }
.card .v { font-size: 22px; font-weight: 680; letter-spacing: -.02em;
           margin-top: 3px; font-variant-numeric: tabular-nums; }

.tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.tile .v { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tile .n { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ── Controls ──────────────────────────────────────────────────────────── */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 13px; min-height: 38px; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
button[disabled] { opacity: .5; cursor: not-allowed; }
button.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; min-height: 38px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field { min-width: 0; }
.grid-2 { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 650; border: 1px solid var(--line); }
.pill.ok { background: var(--brand-wash); color: var(--brand-ink); border-color: transparent; }
.pill.warn { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-wash); color: var(--bad); border-color: transparent; }
.note { border-radius: var(--r-sm); padding: 11px 13px; font-size: 13.5px;
        background: var(--line-2); }
.note.warn { background: var(--warn-wash); color: var(--warn); }
.note.bad { background: var(--bad-wash); color: var(--bad); }
/* `ok` and `info` were written at twenty-six call sites across this console
   and defined at none of them, so every one of them drew as a neutral block:
   the "it worked" after a connector test and the "your contacts leave India"
   on the residency screen were the same grey. The same failure as the bare
   label in FLAG-062 — a class that reads as styling and does nothing — and
   the check now asserts that every modifier used in app.js is defined
   here. */
.note.ok { background: var(--brand-wash); color: var(--brand-ink); }
.note.info { background: var(--brand-wash); color: var(--brand-ink); }
.muted { color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ── DataTable (FLAG-062, FLAG-063) ────────────────────────────────────────
   Search bar with a suggestion popover, a sticky header, a scrolling body and
   a footer that always states what is shown out of what exists. */
.dt { display: flex; flex-direction: column; min-width: 0; }
.dt-tools { display: flex; gap: 9px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.dt-search { position: relative; flex: 1 1 260px; min-width: 0; }
.dt-search input { padding-left: 32px; }
.dt-search .mag { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 14px; }
/* IN THE FLOW, NOT OVER THE LIST. An absolutely-positioned popover here
   overlapped the first rows and swallowed clicks meant for them — see the
   note in datatable.js. It is a block between the search box and the
   results, so no result can ever be underneath it. */
.dt-sugg {
  /* `.dt` is a flex column, so without this the suggestions are shrunk to
     nothing by the scrolling list beside them and are present, populated
     and zero pixels tall — which is worse than the overlay it replaced. */
  flex: 0 0 auto;
  margin: 0 13px 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; max-height: 320px; overflow-y: auto;
}
.dt-sugg[hidden] { display: none; }
.dt-sugg li { list-style: none; padding: 9px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.dt-sugg ul { margin: 0; padding: 0; }
.dt-sugg li:hover, .dt-sugg li[aria-selected="true"] { background: var(--brand-wash); }
.dt-sugg .what { color: var(--muted); font-size: 11.5px; margin-left: auto; text-transform: uppercase; letter-spacing: .04em; }
/* Search hits are marked everywhere, never with the browser's yellow. */
mark { background: var(--brand-wash); color: var(--brand-ink); font-weight: 700; border-radius: 3px; padding: 0 1px; }
.dt-sugg mark { background: transparent; }

.dt-scroll { overflow: auto; max-height: var(--dt-h, 62vh); min-width: 0; }
.dt table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.8px; }
.dt thead th {
  position: sticky; top: 0; z-index: 2; background: var(--panel);
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 680; padding: 9px 13px; white-space: nowrap;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
.dt thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
.dt thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
.dt tbody td { padding: 10px 13px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.dt tbody tr:hover td { background: var(--line-2); }
.dt-foot { padding: 10px 13px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dt-empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* ── Inbox ─────────────────────────────────────────────────────────────────
   List beside thread. The list column is fixed and the thread takes the rest,
   because the thread is what benefits from a wide screen. */
.inbox {
  display: grid; gap: var(--gap); min-width: 0;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: calc(100vh - var(--head) - var(--gap) * 2);
  height: calc(100dvh - var(--head) - var(--gap) * 2);
}
.inbox-list, .inbox-thread { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.inbox-list .dt { min-height: 0; flex: 1 1 auto; }
.inbox-list .dt-scroll { --dt-h: none; max-height: none; flex: 1 1 auto; }
.inbox-thread > header { flex: 0 0 auto; }
.inbox-thread .spacer { min-width: 0; }
/* Inputs are full width by default; these two are header controls. */
.inbox-thread > header select { width: auto; max-width: 180px; min-height: 32px;
                                padding: 4px 8px; font-size: 13px; }
.inbox-thread > header h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 11px; }
.chip.on { background: var(--brand-wash); border-color: transparent; color: var(--brand-ink); }

.conv { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.conv-top { display: flex; gap: 8px; align-items: baseline; }
.conv-top strong { font-weight: 600; }
.conv.unread .conv-top strong { font-weight: 750; }
.conv-top .muted { margin-left: auto; flex: 0 0 auto; font-size: 11.5px; }
.conv-last { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-last { color: var(--ink); }
.conv-meta { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.dot-new { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); display: inline-block; }

.thread { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: min(70%, 620px); border-radius: 12px; padding: 9px 12px; border: 1px solid var(--line); }
.msg.in  { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 3px; }
.msg.out { align-self: flex-end; background: var(--brand-wash); border-color: transparent; border-bottom-right-radius: 3px; }
.msg.bad { background: var(--bad-wash); }
.msg.note { align-self: center; max-width: min(80%, 700px); background: var(--warn-wash); border-color: transparent; }
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg-tpl { font-size: 11px; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }

/* The options an interactive message offered. Deliberately NOT styled as
   buttons: they are a record of what went out, and nothing here is
   clickable — an agent who taps one and sees nothing happen has learned
   something false about the product. */
.msg-opts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px;
            padding-top: 7px; border-top: 1px dashed var(--line-2); }
.msg-opt { font-size: 11.5px; line-height: 1.5; padding: 1px 8px; border-radius: 999px;
           border: 1px solid var(--line-2); color: var(--muted); background: transparent; }

/* Thread beside the contact panel. The panel is the width of a fact, not a
   second column of content. */
.thread-wrap { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 240px; min-height: 0; }
.contact-panel { border-left: 1px solid var(--line-2); padding: 14px; overflow-y: auto; font-size: 13px; }
.cp-row { margin-bottom: 11px; min-width: 0; }
.cp-k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.cp-v { margin-top: 2px; word-break: break-word; }
.cp-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; }

/* CSV import — the mapping step, where a wrong column gets caught. */
.maprows { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.maprow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
          gap: 10px; align-items: center; }
.maprow code { background: var(--line-2); padding: 5px 8px; border-radius: var(--r-sm);
               font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maprow select { width: 100%; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.rejects { margin-top: 6px; font-size: 12.5px; color: var(--warn);
           background: var(--warn-wash); border-radius: var(--r-sm); padding: 9px 12px;
           display: flex; flex-direction: column; gap: 3px; }

/* One contact, with everything that happened to them. */
.contact-sheet { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 20px; }
@media (max-width: 639px) { .contact-sheet { grid-template-columns: 1fr; } }
.timeline { display: flex; flex-direction: column; gap: 11px; margin-top: 6px;
            max-height: 48vh; overflow-y: auto; }
.tl-item { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 11px;
           font-size: 13px; padding-left: 9px; border-left: 2px solid var(--line); }
.tl-item.tl-note { border-left-color: var(--warn); }
.tl-item.tl-event { border-left-color: var(--muted); }
.tl-when { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tl-body { color: var(--ink-2); margin-top: 2px; word-break: break-word; }
@media (max-width: 639px) { .tl-item { grid-template-columns: 1fr; gap: 2px; } }

/* Tags — triage marks the whole team sees. */
.tagrow { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
          padding: 8px 14px; border-bottom: 1px solid var(--line-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650;
       padding: 2px 6px 2px 9px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); }
.tag-ok   { background: var(--brand-wash); color: var(--brand-ink); }
.tag-warn { background: var(--warn-wash);  color: var(--warn); }
.tag-bad  { background: var(--bad-wash);   color: var(--bad); }
.conv-meta .tag { padding: 1px 7px; }
.tag-x { border: 0; background: none; color: inherit; font-size: 14px; line-height: 1;
         padding: 0 2px; min-height: 0; cursor: pointer; opacity: .55; }
.tag-x:hover { opacity: 1; }
.tag-add { width: auto; min-height: 26px; padding: 2px 6px; font-size: 12px; }

/* A saved view is a chip like any other filter. */
.chip.view { border-style: dashed; }
.chip.add { color: var(--muted); border-style: dashed; }

/* Media in the thread. */
.msg-media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px;
             margin-bottom: 6px; background: var(--line-2); }
.msg-file { display: inline-block; padding: 7px 11px; border-radius: 8px;
            background: var(--line-2); color: var(--ink-2); font-size: 13px;
            text-decoration: none; margin-bottom: 6px; }
a.msg-file:hover { color: var(--ink); }

/* Collision banner — the gap Wati leaves open. */
.collide { flex: 0 0 auto; background: var(--warn-wash); color: var(--warn);
           padding: 8px 14px; font-size: 13px; font-weight: 600;
           border-bottom: 1px solid var(--line-2); }
.collide[hidden] { display: none; }

.msg.pending { opacity: .55; }

/* Quick replies, offered when the composer starts with "/". */
.qr-pop { position: absolute; bottom: calc(100% + 6px); left: 13px; right: 13px; z-index: 30;
          background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
          box-shadow: 0 10px 28px rgba(15,23,42,.16); max-height: 260px; overflow-y: auto; }
.qr-pop[hidden] { display: none; }
.qr-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.qr-item:last-child { border-bottom: 0; }
.qr-item:hover { background: var(--brand-wash); }
.qr-item code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.composer { position: relative; flex: 0 0 auto; border-top: 1px solid var(--line); padding: 11px 13px; display: flex; flex-direction: column; gap: 9px; }
.composer .row { display: flex; gap: 9px; align-items: flex-start; }
.composer .row.end { justify-content: flex-end; }
.composer textarea { resize: vertical; min-height: 44px; }
.only-phone { display: none; }

/* Below 1440 the contact panel stacks above the thread rather than stealing
   240px from it — the thread is what people read. */
@media (max-width: 1439px) {
  .thread-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .contact-panel { border-left: 0; border-bottom: 1px solid var(--line-2);
                   display: flex; flex-wrap: wrap; gap: 16px; padding: 11px 14px; max-height: 128px; }
  .cp-row { margin-bottom: 0; }
  .cp-actions { flex-direction: row; margin-top: 0; width: 100%; }
}

@media (max-width: 1023px) {
  /* One pane at a time below a laptop: a 380px list plus a thread does not
     fit, and a squeezed thread is unreadable. */
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-thread { display: none; }
  .inbox[data-open="1"] .inbox-list { display: none; }
  .inbox[data-open="1"] .inbox-thread { display: flex; height: calc(100dvh - var(--head) - var(--bar) - var(--gap) * 2); }
  .only-phone { display: inline-block; }
  .msg { max-width: 85%; }
}

/* ── Phone: < 640px ───────────────────────────────────────────────────────
   The rail becomes a bottom bar; every table becomes stacked cards, which is
   the only honest way to show a 7-column row on a 360px screen. */
@media (max-width: 639px) {
  :root { --bar: 58px; --gap: 12px; }
  .shell { grid-template-columns: 1fr; grid-template-areas: "head" "main"; }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50;
    flex-direction: row; height: var(--bar); border-right: 0; border-top: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden;
  }
  .shell[data-full="1"] .rail { display: flex; }   /* navigation is not chrome */
  .brand, .rail-foot { display: none; }
  .nav { flex-direction: row; padding: 0; width: 100%; }
  .nav a { flex: 1 1 0; flex-direction: column; gap: 2px; padding: 7px 4px; font-size: 10.5px; border-radius: 0; justify-content: center; }
  .nav .ico { font-size: 17px; }
  .nav .lbl { max-width: 100%; }

  .main { padding: var(--gap); }
  .tile .v { font-size: 22px; }

  .dt-scroll { max-height: none; overflow: visible; }
  .dt table, .dt thead, .dt tbody, .dt tr, .dt td { display: block; width: auto; }
  .dt thead { display: none; }
  .dt tbody { padding: 0 11px 4px; }       /* padding on the body, not margins
                                              on the row: a block row with side
                                              margins overflows its table */
  .dt tbody tr {
    border: 1px solid var(--line); border-radius: var(--r-sm);
    margin: 10px 0; padding: 4px 0; background: var(--panel);
  }
  .dt tbody td { border: 0; display: flex; gap: 12px; padding: 6px 12px; }
  /* An empty field is a wasted line on a 360px screen. The label is a
     ::before, which does not count towards :empty. */
  .dt tbody td:empty { display: none; }
  /* A cell that is already a card gets no field label and the full width. */
  .dt tbody td[data-card]::before { content: none; }
  .dt tbody td[data-card] { display: block; padding: 10px 12px; }
  .dt tbody td::before {
    content: attr(data-k); flex: 0 0 38%; color: var(--muted);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 650;
  }
  .dt tbody td[data-k=""] { display: none; }
  .head h1 { font-size: 15px; }
}

/* ── Tablet: 640-1023 — rail collapses to icons, content stays full width. */
@media (min-width: 640px) and (max-width: 1023px) {
  :root { --rail: 62px; }
  .brand .name, .nav .lbl, .rail-foot { display: none; }
  .nav a { justify-content: center; padding: 11px 0; }
}

/* ── Laptop: 1024-1439 — the 13-inch case. Tighter rows, taller tables. */
@media (min-width: 1024px) and (max-width: 1439px) {
  :root { --rail: 208px; --gap: 15px; }
  .dt-scroll { --dt-h: 66vh; }
}

/* ── Desktop: 1440+ — use the space rather than centring a column. */
@media (min-width: 1440px) {
  :root { --gap: 20px; }
  .dt-scroll { --dt-h: 70vh; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* A backfilled message is real but historical: readable, visibly not live.
   The reply window above the thread may be closed despite its timestamp. */
.msg.hist { opacity: .82; border-style: dashed; }

/* ── Campaigns ───────────────────────────────────────────────────────────
   The builder is form beside preview on a laptop and stacked on a phone,
   with the preview FIRST when stacked: on a small screen the question
   "how many people will get this" matters more than the field you just
   left. (FLAG-060/061.) */
.camp-build { display: grid; gap: var(--gap); align-items: start; }
.camp-preview { position: sticky; top: var(--gap); }

@media (max-width: 1023px) {
  .camp-build { grid-template-columns: 1fr; }
  .camp-preview { position: static; order: -1; }
}
@media (min-width: 1024px) {
  .camp-build { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); }
}

.camp-big { font-size: 15px; }
.camp-big strong { font-size: 30px; font-weight: 650; display: block; line-height: 1.15; }

.camp-bar { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.camp-bar-fill { height: 100%; width: 0; background: var(--brand); transition: width .35s ease; }

.camp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.camp-actions button { flex: 0 1 auto; }
.camp-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }

/* A panel header that pushes its last control to the right. */
.panel > header .spacer { flex: 1 1 auto; min-width: 0; }
.tile.bad .v { color: var(--bad); }

button.danger { border-color: var(--bad); color: var(--bad); }
button.danger:hover { background: var(--bad-wash); }

/* Three across on a laptop, one per row on a phone — never a squeezed row
   of unreadable inputs. */
.grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Label-and-value pairs: stats, costs, exclusion reasons. */
table.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.kv th { text-align: left; font-weight: 450; color: var(--muted); padding: 5px 0; }
table.kv td { text-align: right; font-variant-numeric: tabular-nums; padding: 5px 0; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--line); }

label.check { display: flex; gap: 8px; align-items: center; min-height: 38px; font-weight: 400; }
/* A list of checkboxes is a list, not a stack of form rows: the default
   gap leaves nine scopes taller than the dialog they live in. */
.stack.tight { gap: 2px; }
.stack.tight label.check { min-height: 26px; align-items: flex-start; }
.stack.tight label.check input { margin-top: 5px; }

/* The developer screen. A key and a curl line are things people copy, so
   they are monospaced, selectable and allowed to wrap rather than scroll. */
.api-url { display: inline-block; padding: 4px 8px; border-radius: 6px;
           background: var(--bg); border: 1px solid var(--line-2);
           font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.api-sample { margin: 0; padding: 10px 12px; border-radius: 8px; overflow-x: auto;
              background: var(--bg); border: 1px solid var(--line-2);
              font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
              font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.api-key-out { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
               font-size: 12.5px; width: 100%; resize: none; word-break: break-all; }
/* `flex: none` IS THE LOAD-BEARING PART, not `width: auto`.
   A `label.check` is a flex row, and a flex item with `width: auto` shrinks
   to fit when the row is crowded — so a tick box beside a SHORT label kept
   its 13px and the same tick box beside a two-line warning was squeezed to
   ZERO WIDTH. Invisible, unclickable, and nothing anywhere said so: the
   control was in the DOM, checked() worked from a script, and the person
   sitting in front of it could not tick it. Found live on the RCS screen,
   whose two confirmations are the longest checkbox labels in the product.
   The mirror image of FLAG-062's full-width rectangle, and the same lesson:
   a control that renders wrong renders silently. */
label.check input { width: auto; flex: 0 0 auto; min-height: 0; }

ul.plain { margin: 0; padding-left: 18px; font-size: 13.5px; }
ul.plain li { padding: 1px 0; }
.small { font-size: 12.5px; }
.pill.sub, .muted.sub { margin-left: 6px; }

/* The cost block under the audience preview. Separated by a rule, because it
   answers a different question from the one above it. */
.camp-cost { border-top: 1px dashed var(--line); padding-top: 13px; margin-top: 4px; }

/* ── Billing ─────────────────────────────────────────────────────────────
   The quota table is a kv table with a bar column, so it inherits the same
   type and spacing as every other label-and-value block. */
table.kv.quota td:first-of-type { width: 38%; text-align: left; }
table.kv.quota .camp-bar { margin: 0; }
.camp-bar-fill.near { background: var(--warn); }
.camp-bar-fill.over { background: var(--bad); }

/* The current plan, marked without shouting. */
.tile.current { border-color: var(--brand); background: var(--brand-wash); }
.tile button { margin-top: 10px; width: 100%; }

/* ── Usage: a day-by-day sparkline ───────────────────────────────────────
   Bars, not a chart library. Twenty-eight numbers do not need 90KB of
   JavaScript, and a hover title carries the exact figures — which is what
   somebody chasing "what happened on the 14th" actually wants. */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 110px;
         padding: 6px 0 10px; }
.spark-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 3px; }
.spark-bar { width: 100%; background: var(--brand); border-radius: 2px 2px 0 0;
             min-height: 2px; transition: background .15s; }
.spark-col:hover .spark-bar { background: var(--brand-ink); }

/* ── Login ─────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth .panel { width: 100%; max-width: 380px; }   /* the one place a cap is right */

/* Development sign-in. Rendered only on a loopback host (FLAG-039), and
   marked clearly enough that nobody mistakes a dev build for the real one. */
.devbar { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.devbar .note { background: var(--warn-wash); color: var(--warn); margin-bottom: 9px; }
.devbar-row { display: flex; flex-wrap: wrap; gap: 8px; }
.devbar-row button { flex: 1 1 auto; }

@media print { .rail, .head { display: none; } .main { overflow: visible; } }

/* ── Analytics ───────────────────────────────────────────────────────────
   The funnel is five bars whose widths are the counts, not a chart: the
   shape of the drop-off is the whole message, and a drawn chart would put a
   library between the reader and five numbers they can already read. */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-step { position: relative; padding: 8px 12px; border-radius: 6px;
               background: var(--line-2); overflow: hidden; }
.funnel-bar { position: absolute; inset: 0 auto 0 0; background: var(--brand-wash);
              border-right: 2px solid var(--brand); }
.funnel-txt { position: relative; display: flex; align-items: baseline; gap: 2px;
              flex-wrap: wrap; }
.funnel-txt strong { font-size: 20px; font-weight: 650; }

/* A failure group: the count, then what it means, then what to do about it.
   The fix line is as prominent as the meaning line, because a breakdown
   that only names the problem gets read once and then ignored. */
.fgroup { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.fgroup + .fgroup { margin-top: 10px; }
.fgroup-head { display: flex; align-items: baseline; gap: 8px; }
.fgroup-head .num { font-size: 18px; font-weight: 650; }
.fcodes { list-style: none; margin: 10px 0 0; padding: 0; }
.fcodes li { padding: 8px 0; border-top: 1px dashed var(--line); }
.fcodes li .num { font-weight: 650; }

@media (max-width: 680px) {
  .funnel-txt strong { font-size: 17px; }
}

/* ── Leaving ─────────────────────────────────────────────────────────────
   Styled like any other screen on purpose. A page about cancelling that
   looks graver than the rest of the product is a page that is trying to
   change somebody's mind. */
.promise { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.promise li { line-height: 1.45; }

.checklist { display: grid; gap: 10px; }
.checkrow { display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
            line-height: 1.4; }
.checkrow input { margin-top: 3px; flex: 0 0 auto; }

.release-form { border: 1px solid var(--line); border-radius: 8px; padding: 12px;
                margin-top: 4px; }
.release-form + .release-form { margin-top: 10px; }

/* A download link that reads as an action without pretending to be a button
   it is not — it is a link, it opens a file, and middle-click should work. */
a.dl { color: var(--brand); text-decoration: none; font-weight: 600;
       border: 1px solid var(--line); border-radius: var(--r-sm);
       padding: 5px 10px; display: inline-block; font-size: 13px; }
a.dl:hover { border-color: var(--brand); background: var(--brand-wash); }

/* A credit in the wallet ledger. Only the positives are coloured: a debit is
   the normal case and colouring both turns the list into a traffic light. */
.num.pos { color: var(--good); }

/* ── the flow editor ────────────────────────────────────────────────────────
   Three columns on a laptop, stacked on a phone. The canvas is the only part
   of this product with a fixed height: it is a map, and a map that grows to
   fit its contents is a page you scroll instead of a map you read.
   ─────────────────────────────────────────────────────────────────────────── */
.flow-top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: var(--gap);
}
.flow-top h2 { margin: 0; font-size: 20px; }
.flow-top .back { font-size: 13px; color: var(--ink-2); text-decoration: none; }
.flow-top .back:hover { color: var(--brand); }

.flow-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: 230px minmax(0, 1fr) 320px;
  align-items: start;
}
/* FLAG-061: a grid track will not shrink below its content without this, and
   a canvas is the widest content there is. */
.flow-grid > * { min-width: 0; }

.fc-pane {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px;
  max-height: 70vh; overflow-y: auto;
}
.fc-pane h3 { margin: 14px 0 8px; font-size: 14px; }
.fc-pane h3:first-child { margin-top: 0; }
.fc-pane input[type="search"] { width: 100%; }

.fc-palette-list { display: grid; gap: 8px; margin-top: 10px; }
.fc-pal {
  display: grid; gap: 2px; text-align: left; width: 100%;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); cursor: pointer; font: inherit; color: var(--ink);
}
.fc-pal:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-wash); }
.fc-pal:disabled { opacity: .55; cursor: default; }
.fc-pal-label { font-weight: 620; font-size: 13.5px; }
.fc-pal-sum { font-size: 12px; color: var(--muted); }

.fc-canvas {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden;
}
.fc {
  position: relative; height: 70vh; min-height: 420px; overflow: hidden;
  /* The grid is what makes dragging feel like placing rather than dropping. */
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 20px 20px;
  touch-action: none;          /* a finger pans the canvas, not the page */
  cursor: grab;
}
.fc:active { cursor: grabbing; }
.fc-surface { position: absolute; inset: 0; transform-origin: 0 0; }
.fc-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.fc-layer { position: absolute; left: 0; top: 0; }

.fc-wire { fill: none; stroke: var(--muted); stroke-width: 2; }
.fc-wire.dragging { stroke: var(--brand); stroke-dasharray: 5 4; }
.fc-arrowhead { fill: var(--muted); }

.fc-node {
  position: absolute; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 11px 16px; box-shadow: var(--shadow);
  cursor: grab; user-select: none;
}
.fc-node:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fc-node.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-wash); }
.fc-node.start { border-left: 3px solid var(--good); }
.fc-node.waits { border-style: dashed; }
.fc-head { display: flex; align-items: baseline; gap: 6px; }
.fc-label { font-weight: 640; font-size: 13.5px; }
.fc-start { font-size: 10.5px; color: var(--good); text-transform: uppercase;
            letter-spacing: .06em; margin-left: auto; }
.fc-id { font-size: 12px; color: var(--muted); margin-top: 2px;
         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fc-outs {
  position: absolute; left: 0; right: 0; bottom: -9px;
  display: flex; justify-content: space-evenly; pointer-events: none;
}
.fc-out {
  pointer-events: auto; width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--muted); cursor: crosshair;
  position: relative;
}
.fc-out.wired { background: var(--brand); border-color: var(--brand); }
/* The socket's name, under it. A dot nobody can read is a wire drawn by
   guesswork — which output "no" was is exactly what somebody forgets. */
.fc-out i {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-style: normal; font-size: 10px; color: var(--muted); white-space: nowrap;
}

.fc-tools {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 4px;
}

.fc-inspector h3 { margin-top: 0; }
.fc-paths { margin: 10px 0; }
.fc-options { display: grid; gap: 6px; }
.fc-opt-row { display: flex; gap: 6px; }
.fc-opt-row input { flex: 1 1 auto; min-width: 0; }
.fc-issues { display: grid; gap: 8px; }
.fc-test { display: grid; gap: 6px; margin-top: 10px; }
.fc-effect {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 9px; font-size: 12.5px; background: var(--bg);
  overflow-wrap: anywhere;
}

@media (max-width: 1023px) {
  .flow-grid { grid-template-columns: 1fr; }
  .fc-pane { max-height: none; }
  /* Shorter on a phone, because the panes are above and below it now and a
     70vh canvas between them means scrolling past a map to reach a form. */
  .fc { height: 52vh; min-height: 320px; }
}

/* The file input behind "Import a flow". Hidden from sight but not from
   assistive technology or from the keyboard — `display: none` would take it
   out of the tab order and leave the button with nothing to open. */
.hidden-file {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The demo band. Deliberately not dismissible: it is there so a screenshot
   of made-up data is obviously made-up data, and a band you can close is a
   band that is closed in every screenshot. */
.demo-band {
/* WHOSE WORKSPACE THIS IS. Loud on purpose and with no close button: the
   cost of missing it is one school's message sent to another school's
   parents (FLAG-141). */
.acting-band { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--bad-wash, #fdeceb); border: 1px solid var(--bad);
  border-radius: var(--r); padding: 9px 13px; font-size: 13px; }
.acting-band strong { color: var(--bad); }
.acting-band button { margin-left: auto; }
  position: sticky; top: calc(var(--gap) * -1); z-index: 30;
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  margin: 0 0 var(--gap);
  padding: 9px 14px; font-size: 13px;
  background: #fff7ed; color: #7c2d12;
  border: 1px solid #fdba74; border-radius: var(--r-sm);
}
.demo-band strong { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .demo-band {
    background: #2a1a0d; color: #fdba74; border-color: #7c2d12;
  }
}
:root[data-theme="dark"] .demo-band {
  background: #2a1a0d; color: #fdba74; border-color: #7c2d12;
}

/* ── The sequence editor ────────────────────────────────────────────────────
   A sequence is a list, so the editor is a column of cards rather than a
   canvas. Three rules carried over from the rest of the console (FLAG-060,
   FLAG-061): full width, nothing centred, and every row wraps rather than
   scrolls sideways at 360px. */
.seq-step {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; display: grid; gap: 9px;
}
.seq-step > header {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  margin: 0; padding: 0; border: 0; background: none;
}
/* The one thing this layout must not do is put a number input next to a
   message box and give them the same width. `narrow` is the day/hour/minute
   box; everything else takes the room that is left. */
.row {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}
.row > .field { flex: 1 1 180px; min-width: 0; }
.row > .field.narrow { flex: 0 0 104px; }
.row > .field.narrow input { width: 100%; }
label.inline {
  display: inline-flex; gap: 7px; align-items: center;
  font-size: 13px; text-transform: none; letter-spacing: 0;
}
label.inline input { margin: 0; }
label.inline span { text-transform: capitalize; }

@media (max-width: 599px) {
  /* Three number boxes side by side are 312px before gaps, which overflows a
     360px phone once the labels are in. Two per line instead. */
  .row > .field.narrow { flex: 1 1 calc(50% - 10px); }
}

/* ── The admissions board ───────────────────────────────────────────────────
   Twelve stages, and the three that matter are the three everybody wants to
   merge: allotted, reported, enrolled. They get three cells, and the row
   scrolls rather than wrapping them into a shape that reads as one column —
   because a board where "allotted" sits above "enrolled" invites exactly the
   reading FLAG-091 exists to prevent. */
.stage-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: thin;
}
.stage-cell {
  flex: 0 0 104px; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 10px; background: var(--bg);
  display: grid; gap: 2px; align-content: start;
}
/* A terminal stage is where somebody stopped. Marked, not hidden: a funnel
   that buries its exits is a funnel that flatters the team. */
.stage-cell.terminal { background: var(--bg-sunk, var(--bg)); opacity: .82; }
.stage-n { font-size: 21px; font-weight: 650; line-height: 1.1; }
.stage-label {
  font-size: 11.5px; color: var(--muted); line-height: 1.25;
  overflow-wrap: anywhere;
}

@media (max-width: 599px) {
  /* Narrower cells on a phone so three are visible at once — the three that
     have to be seen apart. */
  .stage-cell { flex: 0 0 88px; padding: 8px; }
  .stage-n { font-size: 18px; }
}

/* A row of buttons under a panel's body — the hostname screen's check and
   release, side by side and wrapping on a phone rather than overflowing. */
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* The boot failure screen. Deliberately plain: it renders before the shell
   exists, so it can depend on nothing the shell sets up. */
.boot-problem { max-width: 460px; margin: 15vh auto; padding: 0 20px;
  text-align: center; display: grid; gap: 14px; justify-items: center; }
.boot-problem h1 { font-size: 22px; margin: 0; }
.boot-problem p { margin: 0; color: var(--ink-2); }


/* ── the guided tour ────────────────────────────────────────────────────────
   A callout beside the thing being pointed at, and a ring on the thing. The
   ring is an outline rather than a border so that adding it cannot move the
   element it is on — a tour that reflows the page while describing it is a
   tour that is describing something else by the time you read the sentence. */
.tour-pop {
  position: fixed; z-index: 70; width: 320px; max-width: calc(100vw - 16px);
  /* `--panel`, which is the variable this sheet actually defines. The
     first version used `--card`, which does not exist — so the rule
     resolved to nothing, the callout was transparent, and the thread
     underneath read straight through the sentence explaining it. A missing
     custom property fails silently, which is why this was found by looking
     at it rather than by anything else. */
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(0,0,0,.18);
  padding: 12px 13px; font-size: 13.5px; line-height: 1.5;
}
.tour-head { margin-bottom: 6px; }
.tour-says { margin-bottom: 10px; }
.tour-row { display: flex; gap: 6px; justify-content: flex-end; }
.tour-spot {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (max-width: 720px) {
  /* On a phone the callout sits at the bottom rather than chasing an
     element that may be most of the screen. */
  .tour-pop { left: 8px !important; right: 8px; width: auto;
              top: auto !important; bottom: 10px; }
}
