/* ===================================== fonts (same files as myinvoicestudio.com) */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }

/* ======================================= tokens — LedgerHive palette (light only) */
:root {
  --ink: #0f172a;          /* navy: top bar, sign-in panel, text */
  --ink-soft: #1e293b;
  --bg: #f8fafc;           /* slate-50 */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;       /* slate-200 */
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;        /* slate-500 */
  --primary: #f59e0b;      /* amber-500: main action, focus */
  --primary-hover: #d97706;
  --primary-text: #b45309; /* amber-700: amber text on white */
  --primary-soft: #fffbeb;
  --primary-line: #fde68a;
  --on-primary: #0f172a;   /* navy text on amber, as on LedgerHive */
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --edit: #0f172a;
  --edit-soft: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(15 23 42 / .04);
  --ring: 0 0 0 3px rgb(245 158 11 / .25);
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "IBM Plex Sans", ui-sans-serif, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  --label: #334155;
  --pick-on-text: #78350f;
  --chip-bg: #f1f5f9;
  --alert-line: #fecaca;
  --hover-line: #94a3b8;
  --sel-bg: #0f172a;       /* selected Yes/No, edit mode */
  --sel-bg-hover: #1e293b;
  --sel-fg: #ffffff;
  --sel-accent: #fbbf24;
  color-scheme: light;
}

/* Dark theme — chosen per browser with the sun/moon button (cookie qf_theme). */
:root[data-theme="dark"] {
  --ink: #020617;
  --ink-soft: #0f172a;
  --bg: #0b1120;
  --surface: #111a2c;
  --surface-2: #0d1526;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --label: #cbd5e1;
  --primary: #f59e0b;
  --primary-hover: #fbbf24;
  --primary-text: #fbbf24;
  --primary-soft: rgb(245 158 11 / .12);
  --primary-line: rgb(245 158 11 / .35);
  --on-primary: #0f172a;
  --ok: #34d399;
  --ok-soft: rgb(16 185 129 / .14);
  --warn: #fbbf24;
  --warn-soft: rgb(245 158 11 / .14);
  --danger: #f87171;
  --danger-soft: rgb(239 68 68 / .14);
  --edit: #94a3b8;
  --edit-soft: rgb(148 163 184 / .1);
  --pick-on-text: #fcd34d;
  --chip-bg: #1e293b;
  --alert-line: rgb(239 68 68 / .35);
  --hover-line: #475569;
  --sel-bg: #e2e8f0;
  --sel-bg-hover: #f8fafc;
  --sel-fg: #0f172a;
  --sel-accent: #b45309;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  --ring: 0 0 0 3px rgb(245 158 11 / .35);
  color-scheme: dark;
}
:root[data-theme="dark"] .topbar { border-bottom: 1px solid var(--border); }
:root[data-theme="dark"] .auth-panel { border-right: 1px solid var(--border); }

/* ============================================================ theme switch */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / .12);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
}
.theme-toggle:hover { background: rgb(255 255 255 / .06); color: #fff; }
.theme-toggle:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.auth-main { position: relative; }
.auth-main > .theme-toggle { position: absolute; top: 20px; right: 20px; border-color: var(--border); color: var(--muted); }
.auth-main > .theme-toggle:hover { background: var(--surface-2); color: var(--text); }


/* ================================================================== base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; line-height: 1.25; font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
a { color: var(--primary-text); }
.muted { color: var(--muted); }
kbd {
  font: 500 .7rem/1 var(--font-mono);
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

/* ================================================================ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--ink);
  color: #fff;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.brand-logo { width: 26px; height: 26px; color: var(--primary); flex: none; }
.brand-name { font: 700 1.05rem/1 var(--font-display); letter-spacing: -.01em; }
.brand-tag {
  font: 600 .68rem/1 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgb(245 158 11 / .15);
  color: #fbbf24;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  text-decoration: none;
  font-size: .9rem;
}
.nav a:hover { background: rgb(255 255 255 / .06); color: #fff; }
.nav a.active { background: rgb(245 158 11 / .15); color: #fbbf24; font-weight: 500; }
.nav a:focus-visible, .who a:focus-visible, .brand:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.who-name { font-weight: 500; color: #fff; }
.logout { color: #94a3b8; text-decoration: none; }
.logout:hover { color: #fff; }
.role {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.topbar .role { background: rgb(255 255 255 / .08); border-color: transparent; color: #cbd5e1; }
.role-admin, .topbar .role-admin { background: rgb(245 158 11 / .15); color: var(--primary-text); border-color: transparent; }
.topbar .role-admin { color: #fbbf24; }

/* ================================================================ layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 20px;
  max-width: 1640px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}
.page { max-width: 1100px; margin: 0 auto; padding: 20px; display: grid; gap: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.meta { margin: 4px 0 0; font-size: .85rem; }

/* ================================================================= forms */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: .8rem;
  font-weight: 500;
  color: var(--label);
}
.field > legend { margin-bottom: 5px; }
.req { color: var(--danger); }
.key-hint { margin-left: auto; font-weight: 500; }

input[type="text"], input[type="tel"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.field.invalid input, .field.invalid textarea, .field.invalid .seg { border-color: var(--danger); }
.err { color: var(--danger); font-size: .78rem; min-height: 0; }
.err:empty { display: none; }

.age-chip {
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--primary-text);
}

/* major illness quick-fill */
.label-note { font-weight: 400; font-size: .75rem; margin-left: auto; }
.illness-picks {
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.pick-group { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.pick-title {
  margin-right: 2px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.pick {
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 500 .76rem/1.3 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.pick:hover { border-color: var(--primary); color: var(--primary-text); }
.pick.on { background: var(--warn-soft); border-color: var(--primary); color: var(--pick-on-text); font-weight: 600; }
.pick.on::before { content: "✓ "; }
.pick-none.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* segmented Yes/No controls */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 44px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: grid;
  place-items: center;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--muted);
  background: var(--surface);
  user-select: none;
  transition: background .12s, color .12s;
}
.seg label + input + label { border-left: 1px solid var(--border-strong); }
.seg label:hover { background: var(--surface-2); color: var(--text); }
.seg input:checked + label { background: var(--sel-bg); color: var(--sel-fg); }
.seg input:focus-visible + label { box-shadow: inset 0 0 0 3px rgb(245 158 11 / .55); }
.seg:focus-within { box-shadow: var(--ring); border-color: var(--primary); }

/* ================================================================ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 500 .9rem/1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--hover-line); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary kbd { background: rgb(15 23 42 / .08); border-color: rgb(15 23 42 / .2); color: var(--on-primary); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: .8rem; }
.btn.block { width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.actions .btn.primary { min-width: 150px; }
.shortcuts { margin: 14px 0 0; font-size: .78rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }

.is-editing .btn.primary { background: var(--sel-bg); border-color: var(--sel-bg); color: var(--sel-fg); }
.is-editing .btn.primary:hover { background: var(--sel-bg-hover); border-color: var(--sel-bg-hover); }
.is-editing .btn.primary kbd { background: transparent; border-color: currentColor; color: inherit; opacity: .75; }
.mode-badge {
  flex: none;
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--ok-soft);
  color: var(--ok);
}
.mode-badge.editing { background: var(--sel-bg); color: var(--sel-accent); }
.form-card:has(.is-editing) { border-color: var(--edit); }

.preview { margin-top: 16px; font-size: .85rem; }
.preview summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.copy-preview {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid #5b5fc7; /* Teams purple */
  border-radius: var(--radius-sm);
  font: .9rem/1.6 "Segoe UI", system-ui, sans-serif;
  word-break: break-word;
}
.copy-preview p { margin: 0 0 8px; }
.copy-preview p:last-child { margin-bottom: 0; color: var(--muted); }

/* ============================================================ recent list */
.list-card {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 92px);
  padding: 18px;
}
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.today { font-size: .8rem; font-weight: 600; color: var(--ok); white-space: nowrap; }
.list-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.list-tools input { flex: 1; min-height: 38px; padding: 8px 10px; }
.list-tools select { width: auto; max-width: 180px; min-height: 38px; padding: 6px 8px; }
.list-tools .btn { min-height: 38px; }

.recent {
  list-style: none;
  margin: 0 -4px;
  padding: 0 4px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 80px;
}
.recent .empty { padding: 32px 12px; text-align: center; color: var(--muted); font-size: .9rem; }
.rec {
  position: relative;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .12s, background .12s;
}
.rec:hover { border-color: var(--border-strong); background: var(--surface-2); }
.rec.active { border-color: var(--edit); background: var(--edit-soft); }
.rec.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0% { background: var(--ok-soft); border-color: var(--ok); }
  100% { background: var(--surface); }
}
.rec-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.rec-main:focus-visible { outline: none; box-shadow: var(--ring); }
.rec-top { display: flex; align-items: baseline; gap: 8px; }
.rec-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 1.05rem var(--font-display); letter-spacing: -.01em; }
.rec-time { flex: none; font-size: .78rem; color: var(--muted); }
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 16px;
  margin-top: 8px;
}
.rec-detail { display: flex; flex-direction: column; min-width: 0; }
.rec-wide { grid-column: 1 / -1; }
.rec-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.rec-value { font-size: .92rem; overflow-wrap: anywhere; }
.rec-phone .rec-value { font: 500 .92rem var(--font-mono); font-variant-numeric: tabular-nums; }
.rec-wide .rec-value { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rec-empty { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  font-size: .76rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-yes { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-no { background: var(--surface-2); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-agent { background: var(--chip-bg); color: var(--text); border-color: transparent; }
.chip-muted { font-style: italic; }
.rec-actions { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 6px 6px 0; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--warn-soft); color: var(--primary-text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
#loadMore { margin-top: 10px; flex: none; }

/* ================================================================ toasts */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: .9rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / .25);
  animation: toast-in .18s ease-out;
}
.toast-success { background: #065f46; }
.toast-error { background: #991b1b; }
.toast button {
  border: 0;
  background: rgb(255 255 255 / .15);
  color: #fff;
  font: 600 .82rem/1 var(--font-sans);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.toast button:hover { background: rgb(255 255 255 / .28); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================================================================== auth */
.auth-shell { min-height: 100vh; display: flex; }
.auth-panel {
  flex: 0 0 44%;
  display: flex;
  flex-direction: column;
  padding: 56px 52px;
  background: var(--ink);
  color: #fff;
}
.auth-panel .brand-logo { width: 32px; height: 32px; }
.auth-panel .brand-name { font-size: 1.25rem; }
.auth-pitch { margin-top: auto; }
.auth-headline { margin: 0; font: 600 2.6rem/1.12 var(--font-display); letter-spacing: -.02em; }
.auth-sub { margin: 20px 0 0; max-width: 28rem; color: #94a3b8; font-size: 1rem; line-height: 1.6; }
.auth-stats { display: flex; gap: 36px; margin-top: auto; }
.auth-stat { margin: 0; font: 600 1.25rem var(--font-display); color: #fbbf24; }
.auth-stat-label { margin: 4px 0 0; font-size: .75rem; line-height: 1.5; color: #64748b; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { margin: 0 0 6px; font-size: 1.6rem; }
.auth-form > .muted { margin: 0 0 22px; font-size: .92rem; }
.stack { display: grid; gap: 14px; }
.stack .btn { margin-top: 6px; min-height: 46px; }
.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--alert-line);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .9rem;
}

/* ================================================================ agents */
.agent-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.3fr .8fr auto;
  gap: 12px;
  align-items: start;
}
.field-btn { padding-top: 24px; }
.field-btn .btn { min-height: 44px; }
.pw-wrap { display: flex; gap: 6px; }
.pw-wrap .btn { min-height: 44px; flex: none; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--bg);
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { text-align: right; }
.row-off td { opacity: .55; }
.status { font-size: .78rem; font-weight: 600; }
.status.on { color: var(--ok); }
.status.off { color: var(--danger); }
.status.pending { color: var(--warn); }

.dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  box-shadow: 0 20px 50px rgb(0 0 0 / .3);
}
.dialog::backdrop { background: rgb(15 23 42 / .45); }
.dialog form { display: grid; gap: 14px; }
.dialog .actions { margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; }

/* ================================================ lead form: compact layout */
.form-card { padding: 16px 18px; }
.form-card .card-head { align-items: center; gap: 10px; margin-bottom: 10px; }
.form-card .card-head h1 { font-size: 1.15rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-card .meta { margin: 0 auto 0 0; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-card .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 12px; }
.c-3 { grid-column: span 3; }
.c-4 { grid-column: span 4; }
.c-5 { grid-column: span 5; }
.c-6 { grid-column: span 6; }
.form-card .field { gap: 4px; }
.form-card .field > legend { margin-bottom: 4px; }
.form-card input[type="text"], .form-card input[type="tel"], .form-card textarea { min-height: 40px; padding: 8px 11px; }
.form-card .seg { min-height: 40px; }
.form-card .actions { margin-top: 12px; }
.lower {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: 12px;
  margin-top: 10px;
}
.lower-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.illness-field textarea { min-height: 64px; }
.notes-field textarea { min-height: 48px; }
.rec-notes .rec-value { white-space: pre-line; font-style: italic; }
.auth-links { margin: 16px 0 0; text-align: center; font-size: .88rem; }
.picks-head { font-size: .8rem; font-weight: 600; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; margin-bottom: 2px; }
.picks-head .muted { font-weight: 400; font-size: .72rem; }
.suggest {
  list-style: none;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.suggest li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
}
.suggest li:hover { background: var(--surface-2); }
.suggest li.sel { background: var(--warn-soft); color: var(--pick-on-text); font-weight: 600; }
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.dialog-wide h2 { margin-bottom: 12px; }
.dialog-wide .actions { margin-top: 16px; }

/* Desktop: the whole page fits the screen — no page scrolling; the list scrolls inside its card. */
@media (min-width: 1101px) and (min-height: 560px) {
  body[data-page="form"] .topbar { height: 54px; padding-top: 0; padding-bottom: 0; }
  body[data-page="form"] .layout {
    height: calc(100vh - 54px);
    padding: 14px 20px;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }
  .form-card { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
  #leadForm { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .lower { flex: 1; min-height: 150px; grid-template-rows: minmax(0, 1fr); }
  .lower-left { min-height: 0; }
  .illness-field { flex: 1.3; min-height: 0; }
  .notes-field { flex: 1; min-height: 0; }
  .illness-field textarea, .notes-field textarea { flex: 1; min-height: 40px; resize: none; }
  .illness-picks { overflow-y: auto; min-height: 0; }
  .list-card { position: static; max-height: none; min-height: 0; }
}

/* Short laptop screens: drop group names and flow all picks together so they fit. */
@media (min-width: 1101px) and (max-height: 720px) {
  .illness-picks { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; }
  .pick-group { display: contents; }
  .pick-title { display: none; }
}

/* ============================================================ responsive */
@media (max-width: 1023px) {
  .auth-shell { flex-direction: column; }
  .auth-panel { flex: none; padding: 28px; }
  .auth-pitch { margin-top: 28px; }
  .auth-headline { font-size: 1.6rem; }
  .auth-sub { font-size: .9rem; margin-top: 12px; }
  .auth-stats { display: none; }
  .auth-main { align-items: flex-start; padding-top: 32px; }
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .list-card { position: static; max-height: none; }
  .recent { overflow: visible; }
  .agent-form { grid-template-columns: 1fr 1fr; }
  .field-btn { padding-top: 0; }
}
@media (max-width: 760px) {
  .lower { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .who { margin-left: 0; width: 100%; order: 3; font-size: .85rem; flex-wrap: wrap; }
  .topbar .brand-tag { display: none; }
  .layout, .page { padding: 12px 16px; gap: 14px; }
  .card { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-card .grid { grid-template-columns: 1fr; }
  .form-card .grid > .field { grid-column: 1 / -1; }
  .form-card .meta { display: none; }
  .actions .btn { flex: 1; }
  .btn kbd, .key-hint, .shortcuts { display: none; }
  .agent-form { grid-template-columns: 1fr; }
}

.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-version { text-align: center; font-size: .75rem; color: var(--muted); margin: 0; }

/* Type-ahead list floats over the Notes box instead of being squeezed under it. */
.illness-field { position: relative; }
.illness-field .suggest {
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgb(15 23 42 / .18);
}
.illness-field .suggest.up { top: auto; bottom: 100%; box-shadow: 0 -10px 24px rgb(15 23 42 / .18); }

/* Reset-password window */
.dialog-sub { margin: -6px 0 0; font-size: .9rem; }
.dialog-step { display: grid; gap: 14px; }
.dialog-note { margin: 0; font-size: .82rem; line-height: 1.5; }
.ok-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  color: var(--ok);
  font-size: .9rem;
}
.creds {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: .85rem/1.6 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
}
.row-actions .btn { margin-left: 6px; }
.row-actions .btn:first-child { margin-left: 0; }

/* Teams @mention picker in the form header */
.mention-pick { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: .78rem; color: var(--muted); }
.mention-pick select {
  width: auto;
  min-height: 30px;
  padding: 3px 8px;
  border-radius: 6px;
  font: 600 .82rem var(--font-sans);
  color: var(--primary-text);
  background: var(--warn-soft);
  border-color: var(--primary-line);
}
@media (max-width: 600px) { .mention-pick > span { display: none; } }
