/* Infusion Assistant: styled to sit with Infusion Online (see docs/ux/2026-11-30-ux-review.md).
   Colours are Infusion Online's own (--inf-* tokens from its stylesheet): navy chrome, zeal-green
   places (active menu item, page-title band), pop-blue things you click. */

/* Roboto, self-hosted (the site's CSP allows no outside fonts). Apache 2.0: fonts/LICENSE-roboto.txt */
@font-face { font-family: Roboto; font-weight: 400; font-display: swap; src: url(/fonts/roboto-400.woff2) format("woff2"); }
@font-face { font-family: Roboto; font-weight: 500; font-display: swap; src: url(/fonts/roboto-500.woff2) format("woff2"); }
@font-face { font-family: Roboto; font-weight: 700; font-display: swap; src: url(/fonts/roboto-700.woff2) format("woff2"); }

:root {
  /* brand */
  --inf-deep-blue: #050033;
  --inf-deep-blue-2: #08004e;
  --inf-zeal: #00a483;
  --inf-zeal-strong: #008369;
  --inf-pop-blue: #2344c3;
  --inf-pop-blue-strong: #1c369c;
  --inf-light-cyan: #d8f1ed;

  /* surfaces and text */
  --bg: #f2f2f2;
  --card: #ffffff;
  --toolbar: #eaecef;
  --text: #212529;
  --muted: #605e72;
  --placeholder: #7b798f;
  --line: #e3e2e9;
  --input-border: #7b798f;
  --grid-head-bg: #fafafa;
  --grid-head-text: #484756;
  --grid-stripe: #f9f9fb;
  --grid-hover: #d8f1ed;

  /* roles */
  --accent: var(--inf-pop-blue);
  --accent-hover: var(--inf-pop-blue-strong);
  --accent-text: #ffffff;
  --brand: var(--inf-zeal);
  --chrome-bg: var(--inf-deep-blue);
  --chrome-text: #ffffff;
  --chrome-muted: #c9c8d6;
  --nav-active-bg: var(--inf-zeal);
  --nav-sub-bg: var(--inf-deep-blue-2);
  --focus: 0 0 0 3px rgb(35 68 195 / 0.35);
  --chart-bg: #ffffff;

  --error: #cf222e;
  --error-bg: #fceff0;
  --success: #0c7a2c;
  --success-bg: #eef8f1;
  --warning: #9a6700;
  --warning-bg: #fffbed;

  /* type, space, shape */
  --font: Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-size: 14px;
  --font-size-small: 12px;
  --font-size-title: 20px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --radius: 4px;
  --control-height: 36px;
  --topbar-height: 56px;
  --nav-width: 200px;
  --shadow-1: 0 2px 1px -1px rgb(0 0 0 / .2), 0 1px 1px 0 rgb(0 0 0 / .14), 0 1px 3px 0 rgb(0 0 0 / .12);

  color-scheme: light;
}

/* Infusion has no dark mode; ours keeps the same navy chrome and lightened brand colours. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0b24;
    --card: #16152a;
    --toolbar: #1e1c38;
    --text: #f1f0f4;
    --muted: #b1b0be;
    --placeholder: #9694a7;
    --line: #2e2d45;
    --input-border: #7b798f;
    --grid-head-bg: #1e1c38;
    --grid-head-text: #cdccd7;
    --grid-stripe: #1a1930;
    --grid-hover: #1f3a3a;
    --accent: #84a0ff;
    --accent-hover: #a7b4e7;
    --accent-text: #050033;
    --brand: #33c9a6;
    --nav-active-bg: #008369;
    --focus: 0 0 0 3px rgb(132 160 255 / 0.5);
    --chart-bg: #f2f2f2;
    --error: #ff6b6b;
    --error-bg: #3a1620;
    --success: #4cc38a;
    --success-bg: #12301f;
    --warning: #e5be4b;
    --warning-bg: #332a10;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--font-size)/1.5 var(--font);
}

/* ---------- shell: navy top bar, navy left menu, content ---------- */
body:not(.signed-out) {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) 1fr;
  min-height: 100vh;
}
.bar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--topbar-height);
  padding: 0 var(--space-3);
  background: var(--chrome-bg);
  color: var(--chrome-text);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .01em; color: var(--chrome-text); white-space: nowrap; }
.brand img { display: block; height: 32px; width: auto; }
.brand b { color: var(--inf-zeal); font-weight: 500; }
.who { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); color: var(--chrome-muted); font-size: 13px; min-width: 0; }
#who-company { color: var(--chrome-text); font-weight: 500; }
.who button.link { color: var(--chrome-text); min-height: 40px; text-decoration: underline; text-underline-offset: 3px; }
.bar .icon { background: none; border: 0; color: var(--chrome-text); font-size: 22px; min-width: 44px; min-height: 44px; padding: 0; display: none; }

.tabs {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  background: var(--chrome-bg);
  padding: var(--space-2) 0;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}
.tab {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--chrome-text);
  font-weight: 700;
  text-align: left;
}
.tab:hover { background: var(--nav-sub-bg); }
.tab.active { background: var(--nav-active-bg); text-decoration: underline; text-underline-offset: 3px; }
.tab:focus-visible { box-shadow: inset 0 0 0 3px var(--inf-light-cyan); }

main { grid-row: 2; min-width: 0; padding: 0 0 var(--space-4); }
main > section { margin: var(--space-3); min-width: 0; }
main > section.narrow { margin: var(--space-4) auto; }

/* ---------- page-title band (green, as Infusion's) ---------- */
.page-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-height: 48px;
  padding: var(--space-1) var(--space-3);
  background: var(--inf-zeal-strong);
  color: #fff;
}
.page-title h1 { margin: 0; font-size: var(--font-size-title); font-weight: 500; color: #fff; }
.page-title .row { gap: var(--space-2); }
.page-title button { background: transparent; border-color: rgb(255 255 255 / .6); color: #fff; font-weight: 700; font-size: 13px; }
.page-title button:hover { background: rgb(255 255 255 / .12); }
.page-title button.primary { background: #fff; color: var(--inf-zeal-strong); border-color: #fff; }

/* ---------- signed out: Infusion's navy sign-in page ---------- */
body.signed-out { background: var(--inf-deep-blue); }
body.signed-out .bar { position: static; }
body.signed-out main > section.narrow { margin: 48px auto; }

/* ---------- cards, forms, controls ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
}
.narrow { max-width: 440px; width: calc(100% - 32px); }
.settings { display: grid; gap: var(--space-3); }

h1 { font-size: var(--font-size-title); font-weight: 500; margin: 0 0 8px; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 500; }

form, .stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
label > select, label > input { width: 100%; }
label { display: grid; gap: 4px; font-weight: 500; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }

input, select, textarea {
  font: inherit;
  min-height: var(--control-height);
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  max-width: 100%;
}
input { width: 100%; }
textarea { width: 100%; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--placeholder); }

button {
  font: inherit;
  font-weight: 500;
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.link { border: none; background: none; color: var(--accent); padding: 0 4px; min-height: 32px; }
button:disabled { opacity: 0.6; cursor: default; }
:is(button, input, select, textarea, summary, a):focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }

.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.error { color: var(--error); margin: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; overflow-wrap: anywhere; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card > .row h2 { margin: 0; }

.list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

details { margin-top: 8px; }
summary { cursor: pointer; color: var(--accent); min-height: 32px; display: list-item; }
details form { margin-top: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; min-width: 0; }

.switch { display: flex; gap: 8px; align-items: center; }
.switch input { width: 20px; }
.notice { margin: 0; padding: 8px 12px; border-radius: var(--radius); background: var(--warning-bg); border: 1px solid var(--line); }
.chip { display: inline-flex; gap: 2px; align-items: center; border-radius: 999px; padding: 0 8px; margin: 2px; font-size: 12px; background: var(--inf-light-cyan); color: #050033; }

/* ---------- data grid (Infusion's look) ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: var(--space-2) 0 var(--space-3);
}
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--grid-head-bg);
  color: var(--grid-head-text);
  font-size: var(--font-size-small);
  font-weight: 600;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table-wrap td { padding: 4px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; }
.table-wrap td:last-child { border-right: 0; }
.table-wrap tbody tr:nth-child(even) td { background: var(--grid-stripe); }
.table-wrap tbody tr:hover td { background: var(--grid-hover); }
.table-wrap td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap td.neg { color: var(--error); }
.table-wrap input:not([type="checkbox"]) { min-height: 30px; padding: 2px 6px; }
#licensees input[type="number"] { width: 7em; }

/* ---------- admin tables: filters, sorting, count and paging (table-controls.mjs) ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.admin > .card { min-width: 0; }
.filters { margin: 0 0 4px; gap: 8px 12px; }
.filters input[type="search"] { width: 16em; }
.table-wrap.scroll { max-height: min(70vh, 720px); overflow: auto; }
.table-wrap th[data-sort] { padding: 0; }
.table-wrap th button.sort {
  display: flex; align-items: center; width: 100%; min-height: 32px; padding: 6px 10px; border: 0; border-radius: 0;
  background: none; color: inherit; font: inherit; text-align: left; white-space: nowrap; cursor: pointer;
}
.table-wrap th button.sort:hover { background: var(--toolbar); }
.table-wrap th button.sort:focus-visible { box-shadow: inset var(--focus); }
.table-wrap th[aria-sort] { color: var(--text); }
.sort-arrow { font-size: 10px; margin-left: 2px; }
.table-footer { margin: -4px 0 8px; }
.table-footer button { min-height: 32px; padding: 0 12px; }
.table-count { white-space: nowrap; }
.table-wrap td.empty { text-align: center; padding: 16px; white-space: normal; }
.table-wrap table[aria-busy="true"] tbody { opacity: .6; }
button.small { min-height: 28px; padding: 0 8px; font-size: 12px; }
.chip.warn { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--line); }
.w-12 { width: 12em; }
.w-16 { width: 16em; }
#roles td:last-child { width: 1%; }
#licensees td { vertical-align: top; }

/* ---------- assistant ---------- */
.assistant-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-3); }
.sidebar {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; align-self: start;
  position: sticky; top: var(--space-3); max-height: calc(100vh - 150px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 8px;
}
.side-search { padding: 0 4px 4px; }
.side-search input { width: 100%; min-height: 34px; font-size: 13px; }
.side-section + .side-section { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 2px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between; margin: 8px 8px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.side-head .count { background: var(--toolbar); color: var(--grid-head-text); border-radius: 10px; padding: 1px 7px; font-size: 11px; letter-spacing: 0; }
.side-empty { margin: 2px 4px 6px; padding: 8px 10px; font-size: 12px; line-height: 1.4; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.side-list li { position: relative; display: flex; align-items: center; border-radius: 6px; min-width: 0; }
.side-list li:hover { background: var(--grid-stripe); }
.side-list li.current { background: var(--grid-hover); box-shadow: inset 3px 0 0 var(--brand); }
.side-list li.group { display: block; padding: 8px 10px 2px; font-size: 11px; font-weight: 600; color: var(--grid-head-text); background: none; box-shadow: none; }
.side-list button.open {
  flex: 1; min-width: 0; min-height: 0; padding: 6px 4px 6px 10px; border: none; background: none;
  text-align: left; color: var(--text); font-weight: 400; cursor: pointer;
}
.side-list .open .t { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list .open .m { display: block; margin-top: 1px; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list li.current .open .t { font-weight: 600; }
.side-list li.elsewhere .open .t { color: var(--muted); }
.side-list button.remove {
  flex: none; width: 28px; height: 28px; min-height: 0; margin-right: 4px; padding: 0; border: none; border-radius: 4px;
  background: none; color: var(--muted); font-size: 16px; line-height: 1; opacity: 0; cursor: pointer;
}
.side-list li:hover button.remove, .side-list li:focus-within button.remove { opacity: 1; }
.side-list button.remove:hover { background: var(--toolbar); color: var(--error); }
@media (hover: none) { .side-list button.remove { opacity: 1; } }
.list.compact { margin: 0; gap: 2px; }
.list.compact li { display: flex; align-items: center; gap: 4px; padding: 2px 0; border: none; }
.list.compact li > .title { min-width: 0; }
.list.compact .title { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.list.compact .remove { color: var(--muted); }

.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.conversation { display: flex; flex-direction: column; gap: 16px; }
.message { max-width: 100%; }
.message.user .body {
  background: var(--inf-light-cyan);
  color: #050033;
  border-radius: var(--radius);
  padding: 8px 12px;
  white-space: pre-wrap;
  margin-left: auto;
  width: fit-content;
  max-width: 80%;
}
.message.assistant .body { overflow-wrap: anywhere; }
.message.assistant .body p { margin: 0 0 8px; }
.message.failed .body { color: var(--error); }
.message .hint { margin: 4px 0 0; }
.chart { margin: 0 0 8px; max-width: 640px; }
.chart svg { width: 100%; height: auto; background: var(--chart-bg); border-radius: var(--radius); }
.composer { display: grid; gap: 8px; position: sticky; bottom: 0; background: var(--card); padding-top: 8px; }

/* ---------- dialogs ---------- */
dialog.terms {
  max-width: 720px;
  width: calc(100% - 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
dialog.terms::backdrop { background: rgb(5 0 51 / 0.5); }
.terms .summary { background: var(--bg); border-radius: var(--radius); padding: 10px 12px; }
.terms .summary p, .terms-body p { margin: 0 0 8px; }
.terms-body { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }
.terms-body h3 { font-size: 14px; margin: 12px 0 4px; }

/* dialogs: Infusion-style green header, fields that fit, actions always in reach */
dialog.terms form, dialog.terms fieldset { min-width: 0; }
dialog.terms select { max-width: 100%; width: 100%; }
dialog.terms > form > h2:first-child { margin: -20px -20px 16px; padding: 12px 20px; background: var(--inf-zeal-strong); color: #fff; font-size: 16px; border-radius: var(--radius) var(--radius) 0 0; }
dialog.terms > form > .row:last-child { position: sticky; bottom: -20px; background: var(--card); padding: 12px 0; margin-bottom: -8px; }

/* ---------- tasks, admin ---------- */
#alerts td { vertical-align: top; }
#alerts .actions { white-space: nowrap; }
#alerts .attention { color: var(--error); white-space: normal; max-width: 260px; }
#outbox pre { white-space: pre-wrap; font: inherit; background: var(--bg); padding: 8px; border-radius: var(--radius); }

#audit td.detail { white-space: normal; min-width: 240px; max-width: 420px; overflow-wrap: anywhere; }
.danger { border: 1px solid var(--error); border-radius: var(--radius); padding: 12px; margin-top: 16px; }
.danger h3 { color: var(--error); margin-top: 0; }
label.inline { white-space: nowrap; }
.row select { max-width: 260px; }

/* ---------- company picker ---------- */
.list.choices li { border: none; padding: 0; }
.list.choices button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: var(--space-2); text-align: left; font-size: 15px; font-weight: 500; }
.list.choices button::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; }
.chip.recent { color: var(--inf-zeal-strong); font-size: 11px; font-weight: 600; text-transform: uppercase; }
#choose-cancel { min-height: 44px; }

/* ---------- monitor ---------- */
.monitor-table th button.sort { min-height: 0; padding: 0; font: inherit; color: inherit; background: none; border: 0; text-align: left; white-space: nowrap; }
.monitor-table tr.row-overdue td { color: var(--error); }
.monitor-table tr.row-today td { color: var(--success); }
.monitor-status[data-kind="stale"], .monitor-status[data-kind="error"] {
  color: var(--error); background: var(--error-bg); border: 1px solid var(--error); border-radius: var(--radius); padding: 8px 12px; font-size: 14px;
}

/* ---------- phone: the left menu becomes a drawer ---------- */
@media (max-width: 760px) {
  body:not(.signed-out) { grid-template-columns: minmax(0, 1fr); }
  .bar { gap: var(--space-2); padding: 0 var(--space-2); }
  .bar .icon { display: inline-flex; align-items: center; justify-content: center; }
  .tabs {
    position: fixed;
    inset: var(--topbar-height) auto 0 0;
    width: min(80vw, var(--nav-width));
    height: auto;
    transform: translateX(-100%);
    transition: transform .2s;
    z-index: 20;
  }
  body.nav-open .tabs { transform: none; box-shadow: 4px 0 16px rgb(0 0 0 / .3); }
  main { grid-column: 1; }
  #who-email { display: none; }
  .who { font-size: 12px; gap: var(--space-2); }
  #who-company { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
  main > section { margin: var(--space-2); }
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { order: 2; position: static; max-height: none; }
  .brand { font-size: 16px; gap: 6px; }
  .brand img { height: 26px; }
  .filters > label.inline { flex: 1 1 100%; min-width: 0; white-space: normal; }
  .filters > label.inline > :is(input, select) { flex: 1; min-width: 0; width: auto; max-width: none; }
  #role-form > label.inline { flex: 1 1 100%; }
  #role-form > label.inline > :is(input, select) { flex: 1; min-width: 0; width: auto; }
  .table-wrap.scroll { max-height: 75vh; }
}

/* Billing */
#bill-table tr.clickable { cursor: pointer; }
#bill-table td.strong { font-weight: 600; }
#bill-table td.error-text { color: var(--error); }
#bill-table table.inner { width: 100%; margin: 4px 0 8px; }
.admin details { margin: 12px 0; }
.admin details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
/* Card payment link (public/stripe-ui.mjs) under a company's users */
.card-pay { white-space: normal; max-width: 720px; gap: 8px; margin: 4px 0 8px; }
.card-pay p { margin: 0; }
#price-bands input { width: 8em; }
.w-7 { width: 7em; }
.w-8 { width: 8em; }

/* Links to the public pages (sign-in card, top bar) */
.sign-in-links { margin: 16px 0 0; }
.sign-in-links a { color: var(--accent); }
.who a.who-guide { color: var(--chrome-text); text-underline-offset: 3px; min-height: 40px; display: inline-flex; align-items: center; }
@media (max-width: 760px) { .who a.who-guide { display: none; } }

/* Company switcher in the top bar */
.who button.company-switch { color: var(--chrome-text); text-decoration: none; font-weight: 500; }
.who button.company-switch:hover { text-decoration: underline; }
#company-password { margin-top: 12px; }

/* Conversation history and saving questions */
.answer-actions { margin: 6px 0 0; }

/* Invoices */
.error-text { color: var(--error); }
.admin h4 { margin: 12px 0 6px; font-size: 14px; }

/* A change to Infusion waiting for approval */
.write-card { margin: 10px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--card); }
.write-card.pending { border-left-color: var(--warning, #c98a00); background: var(--warning-bg); }
.write-card.done { border-left-color: var(--brand); }
.write-card.failed { border-left-color: var(--error); }
.write-card h4 { margin: 0 0 4px; font-size: 14px; }
.write-card .write-tool { margin: 0 0 6px; font-weight: 600; }
.write-card .write-args { margin: 0 0 8px; font-size: 13px; }
.write-card .write-args dd { overflow-wrap: anywhere; }
.write-card .write-state { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.write-card.failed .write-state { color: var(--error); }

/* ---------- Admin: menu heading, status badges, clickable company rows ---------- */
.tab-group {
  margin: var(--space-3) var(--space-3) 4px;
  padding-top: var(--space-2);
  border-top: 1px solid rgb(255 255 255 / 0.15);
  color: var(--chrome-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--inf-light-cyan); color: var(--inf-zeal-strong); }
.badge.info { background: #e8ecfb; color: var(--inf-pop-blue-strong); }
.badge.warn { background: var(--warning-bg); color: #7a5200; }
.badge.bad { background: #fde8e8; color: #a12020; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--grid-hover); }
button.row-link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; text-align: left; cursor: pointer; }
button.row-link:hover { text-decoration: underline; }
td.muted { color: var(--muted); }
td.strong { font-weight: 600; }

/* ---------- The company panel: a dialog sliding in from the right ---------- */
dialog.drawer {
  margin: 0 0 0 auto;
  width: min(640px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  box-shadow: -8px 0 24px rgb(5 0 51 / 0.18);
}
dialog.drawer[open] { display: flex; flex-direction: column; }
dialog.drawer::backdrop { background: rgb(5 0 51 / 0.35); }
.drawer-head {
  display: flex; align-items: flex-start; gap: var(--space-2); justify-content: space-between;
  padding: 16px 20px; background: var(--inf-zeal-strong); color: #fff;
}
.drawer-head h2 { margin: 0; font-size: 18px; color: #fff; }
.drawer-head .hint { margin: 4px 0 0; color: rgb(255 255 255 / 0.85); font-size: 12px; overflow-wrap: anywhere; }
.icon-button { border: 0; background: none; color: inherit; font-size: 26px; line-height: 1; min-width: 40px; min-height: 40px; cursor: pointer; border-radius: 4px; }
.icon-button:hover { background: rgb(255 255 255 / 0.15); }
.drawer-body { overflow-y: auto; padding: 4px 20px 24px; }
.cp-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.cp-section:last-child { border-bottom: 0; }
.cp-section h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--grid-head-text); }
.cp-section .hint { margin: 6px 0 0; }
.cp-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cp-inline input[type="email"] { flex: 1; min-width: 12em; }
.cp-field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 16px; padding: 6px 0; align-items: start; }
.cp-label { color: var(--muted); padding-top: 8px; font-size: 13px; }
.cp-value select { max-width: 100%; }
.cp-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-top: 6px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.cp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cp-table th { text-align: left; font-size: 12px; color: var(--grid-head-text); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.cp-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cp-table .center { text-align: center; }
.cp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
@media (max-width: 640px) {
  dialog.drawer { width: 100vw; border-left: 0; }
  .cp-field { grid-template-columns: minmax(0, 1fr); }
  .cp-label { padding-top: 0; }
}

/* ---------- Site settings ---------- */
.role-guide { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 8px 0 16px; font-size: 14px; }
.role-guide dt { font-weight: 600; }
.role-guide dd { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px; margin-bottom: 12px; background: var(--grid-head-bg); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.toolbar label.grow { flex: 1; min-width: 14em; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.admin-list li:last-child { border-bottom: 0; }
.danger-card { border-color: var(--error); }
.danger-card h2 { color: var(--error); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.danger-row .hint { margin: 4px 0 0; max-width: 60ch; }
.danger-row .switch input { width: 24px; height: 24px; }

/* ---------- Group analysis ---------- */
.group-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px; border-radius: var(--radius); background: var(--inf-light-cyan); color: #050033; }
.group-bar .hint { color: #23304d; }
.groups-list { display: grid; gap: 10px; margin: 8px 0 12px; }
.group-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.group-item .row { gap: 10px; align-items: center; }
.group-item p.hint { margin: 6px 0; }
.group-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.group-form legend { font-weight: 600; padding: 0 4px; }

/* ---------- Business picker (groups) ---------- */
.picker { display: grid; gap: 10px; }
.picker-top { display: flex; flex-wrap: wrap; gap: 12px; }
.picker-top label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; min-width: 14em; }
.picker-selected { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--grid-head-bg); }
.picker-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.picker-count { color: var(--muted); font-size: 13px; }
.picker-count.over { color: var(--error); }
.picker-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 28px; align-items: center; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.picker-list li { border-bottom: 1px solid var(--line); }
.picker-list li:last-child { border-bottom: 0; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; font-weight: 400; }
.picker-row:hover { background: var(--grid-stripe); }
.picker-row.on { background: var(--grid-hover); }
.picker-text { display: flex; flex-direction: column; min-width: 0; }
.picker-name { overflow-wrap: anywhere; }
.picker-detail { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.picker-empty { padding: 10px; }
.picker-shown { margin: 0; }
