/* ==========================================================================
   Websie AI Assistant : design system for both dashboards.

   Layout language: a dark navy rail that never scrolls away, against a light
   working canvas. The rail carries identity and navigation, the canvas carries
   the work. Brand lives in colour, not in a display typeface.

   Locks (deliberate, do not break piecemeal):
     Type    : one family, hierarchy by weight and size. Numerals in mono.
     Colour  : navy is structure, gold is the single accent. Nothing else
               introduces a hue except semantic status and tenant widget colour.
     Radius  : 8 small controls, 12 buttons and inputs, 16 cards and panels,
               999 status pills only.
     Shadow  : always navy-tinted, never neutral black.
     Motion  : transform and opacity only, feedback and state changes only.
   ========================================================================== */

:root {
  /* Structure */
  --nav-980: #050F22;
  --nav-950: #071228;
  --nav-900: #0D2047;
  --nav-800: #14295A;
  --nav-700: #1B3A6B;

  /* Single accent */
  --gold-600: #A97E2C;
  --gold-500: #C4963A;
  --gold-400: #D8B368;
  --gold-100: #F7EFDF;

  /* Canvas */
  --bg: #F3F6FC;
  --surface: #FFFFFF;
  --sunk: #EDF1F9;
  --line: #E1E8F4;
  --line-2: #CDD8EC;

  /* Ink */
  --ink: #0E1B33;
  --ink-2: #3D4B69;
  --mut: #6A7995;
  --on-dark: #EAF0FA;
  --on-dark-2: rgba(234, 240, 250, .62);

  /* Semantic status */
  --ok: #1F7A4C;
  --ok-bg: #E6F4EC;
  --warn: #8A6011;
  --warn-bg: #FBF2E0;
  --err: #A82F35;
  --err-bg: #FBECEC;

  /* Radius lock */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Elevation: base surface, raised card, floating overlay */
  --sh-1: 0 1px 2px rgba(13, 32, 71, .05), 0 1px 3px rgba(13, 32, 71, .04);
  --sh-2: 0 2px 4px rgba(13, 32, 71, .04), 0 10px 24px -10px rgba(13, 32, 71, .18);
  --sh-3: 0 18px 48px -14px rgba(13, 32, 71, .32), 0 4px 12px rgba(13, 32, 71, .08);

  --rail: 264px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --sans: 'Geist', 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', 'Cascadia Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
body { margin: 0; min-height: 100dvh; }

h1, h2, h3 { letter-spacing: -.022em; line-height: 1.18; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mono { font-family: var(--mono); }
.muted { color: var(--mut); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── App shell ────────────────────────────────────────────────────────────
   Grid rather than fixed positioning: the canvas column can never slide under
   the rail, and it collapses to one column with a single media query. */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100dvh; display: flex; flex-direction: column;
  padding: 20px 16px 16px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(196, 150, 58, .10), transparent 62%),
    linear-gradient(180deg, #0B1A36 0%, var(--nav-950) 58%, var(--nav-980) 100%);
  border-right: 1px solid rgba(255, 255, 255, .07);
  color: var(--on-dark);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 18px; }
.brand-mark {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: .85rem; color: #10203C;
  background: linear-gradient(145deg, var(--gold-400), var(--gold-600));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 4px 12px -4px rgba(196, 150, 58, .55);
}
.brand-name { font-size: .95rem; font-weight: 650; letter-spacing: -.015em; line-height: 1.15; }
.brand-sub { font-size: .7rem; color: var(--on-dark-2); margin-top: 1px; }

.rail-card {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--r-md);
  padding: 11px 12px; margin-bottom: 18px;
}
.rail-card .k { font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; color: var(--on-dark-2); }
.rail-card .v { font-size: .875rem; font-weight: 600; margin-top: 3px; word-break: break-word; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  font-size: .875rem; font-weight: 500; color: var(--on-dark-2);
  transition: background-color .16s ease, color .16s ease;
}
.side-link i { flex: none; width: 17px; text-align: center; font-size: .875rem; opacity: .78; }
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-link:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.side-link[aria-current="page"] { background: rgba(196, 150, 58, .15); color: #fff; font-weight: 600; }
.side-link[aria-current="page"] i { color: var(--gold-400); opacity: 1; }
.side-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -9px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--gold-500);
}

.rail-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }

/* ── Canvas ─────────────────────────────────────────────────────────────── */
.canvas { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 10px 24px;
  background: rgba(243, 246, 252, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .crumb { font-size: .95rem; font-weight: 600; letter-spacing: -.015em; }
.topbar .spacer { flex: 1; }

.view { width: 100%; max-width: 1140px; margin: 0 auto; padding: 26px 24px 72px; }
.view-narrow { max-width: 840px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 1.6rem; font-weight: 650; }
.page-head .lede { font-size: .9rem; color: var(--mut); margin-top: 6px; max-width: 62ch; line-height: 1.6; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.section-title { font-size: 1.05rem; font-weight: 640; margin-bottom: 12px; }
.stack > * + * { margin-top: 12px; }

/* ── Surfaces ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 1rem; font-weight: 640; }
.card-accent { border-color: var(--gold-400); background: linear-gradient(180deg, #FEFBF4, #FFFFFF); }

.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-1);
}
.tile .n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.75rem; font-weight: 600; line-height: 1; letter-spacing: -.035em; }
.tile .unit { font-family: var(--sans); font-size: .58em; font-weight: 500; color: var(--mut); margin-left: .18em; }
.tile .l { font-size: .78rem; color: var(--mut); margin-top: 7px; line-height: 1.35; }

.grid-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (min-width: 1024px) { .grid-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.snippet {
  font-family: var(--mono); font-size: .74rem; line-height: 1.65;
  background: var(--nav-950); color: #D7E2F5;
  border-radius: var(--r-md); padding: 14px 16px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .875rem; font-weight: 600; line-height: 1;
  padding: .62rem 1.05rem; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-align: center;
  transition: background-color .16s ease, border-color .16s ease, transform .12s ease, box-shadow .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { font-size: .78rem; padding: .45rem .75rem; }
.btn i { font-size: .82em; }

.btn-primary { background: var(--nav-900); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover:not(:disabled) { background: var(--nav-800); box-shadow: var(--sh-2); }

.btn-gold { background: var(--gold-500); color: #16233D; box-shadow: 0 1px 2px rgba(169, 126, 44, .25); }
.btn-gold:hover:not(:disabled) { background: var(--gold-400); box-shadow: 0 6px 16px -6px rgba(169, 126, 44, .55); }

.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: var(--sunk); border-color: var(--mut); }

.btn-subtle { background: transparent; color: var(--ink-2); }
.btn-subtle:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }

.btn-danger { background: var(--surface); color: var(--err); border-color: var(--line-2); }
.btn-danger:hover:not(:disabled) { background: var(--err-bg); border-color: var(--err); }

.btn-onrail { background: rgba(255, 255, 255, .06); color: var(--on-dark); border-color: rgba(255, 255, 255, .12); width: 100%; }
.btn-onrail:hover:not(:disabled) { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); }
.btn-onrail:focus-visible { outline-color: var(--gold-400); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: block; }
.field + .field { margin-top: 18px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.field input, .field select, .field textarea, .input {
  width: 100%; font-family: inherit; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: .6rem .8rem; transition: border-color .16s ease, box-shadow .16s ease;
}
.field textarea { min-height: 104px; resize: vertical; line-height: 1.6; }
.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--mut) 50%), linear-gradient(135deg, var(--mut) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
.field input::placeholder, .field textarea::placeholder { color: #92A0B8; }
.field input:hover, .field select:hover, .field textarea:hover, .input:hover { border-color: var(--mut); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(196, 150, 58, .22);
}
.field .help { font-size: .76rem; color: var(--mut); margin-top: .4rem; line-height: 1.5; }
.field .error, .form-error { font-size: .8rem; color: var(--err); font-weight: 500; margin-top: .4rem; }
.counter { font-family: var(--mono); font-size: .7rem; color: var(--mut); text-align: right; margin-top: .3rem; }
.counter.over { color: var(--err); font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .field + .field { margin-top: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 639px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.segmented { display: inline-flex; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented button {
  font-family: inherit; font-size: .78rem; font-weight: 600; color: var(--mut);
  background: transparent; border: 0; border-radius: 9px; padding: .38rem .7rem; cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.segmented button:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 1px; }

/* ── Status ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .01em;
  border-radius: var(--r-pill); padding: .2rem .6rem; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-wait { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-off { background: var(--sunk); color: var(--mut); }
.badge-gold { background: var(--gold-100); color: var(--gold-600); }

.empty {
  background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  padding: 48px 24px; text-align: center;
}
.empty .ico {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--sunk); color: var(--mut); font-size: 1.05rem;
}
.empty h2 { font-size: 1.05rem; font-weight: 640; margin-bottom: 6px; }
.empty p { font-size: .875rem; color: var(--mut); max-width: 44ch; margin: 0 auto 18px; line-height: 1.6; }

.skeleton {
  background: linear-gradient(90deg, var(--sunk) 25%, #F6F9FD 50%, var(--sunk) 75%);
  background-size: 200% 100%; animation: sk 1.3s infinite linear; border-radius: var(--r-md);
}
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  z-index: 200; max-width: min(92vw, 26rem);
  display: flex; align-items: center; gap: .6rem;
  background: var(--nav-900); color: #fff; border-radius: var(--r-md);
  padding: .7rem 1.1rem; font-size: .875rem; box-shadow: var(--sh-3);
  animation: toast-in .28s var(--ease);
}
.toast.err { background: var(--err); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Rows and lists ─────────────────────────────────────────────────────── */
.row {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); padding: 18px 20px;
  transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
button.row, a.row { cursor: pointer; }
button.row:hover, a.row:hover { border-color: var(--line-2); box-shadow: var(--sh-2); }
button.row:focus-visible, a.row:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.row[aria-current="true"] { border-color: var(--nav-700); box-shadow: 0 0 0 1px var(--nav-700), var(--sh-2); }
.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.row-title { font-size: .95rem; font-weight: 640; letter-spacing: -.01em; }
.row-meta { font-size: .76rem; color: var(--mut); }
.row-body { font-size: .875rem; color: var(--ink-2); line-height: 1.6; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 148px; }
.bar-chart .bar {
  flex: 1 1 0; min-width: 3px; max-width: 26px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--nav-700), var(--nav-900));
  transition: opacity .16s ease;
}
.bar-chart .bar:hover { opacity: .72; }

/* ── Chat surfaces (preview and transcripts) ────────────────────────────── */
.chat {
  height: 420px; overflow-y: auto; background: var(--sunk);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px;
}
.cmsg {
  max-width: 86%; padding: 9px 13px; border-radius: 14px; margin-bottom: 8px;
  font-size: .875rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.cmsg.bot { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cmsg.user { background: var(--nav-900); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.src { font-size: .68rem; color: var(--mut); margin: -4px 0 10px 2px; }

/* ── Widget colour picker ───────────────────────────────────────────────── */
.picker { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.picker .color-well {
  flex: none; width: 46px; height: 46px; padding: 0; cursor: pointer;
  background: none; border: 1px solid var(--line-2); border-radius: var(--r-md);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.picker .color-well:hover { border-color: var(--mut); }
.picker .color-well:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.color-well::-webkit-color-swatch-wrapper { padding: 3px; }
.color-well::-webkit-color-swatch { border: 0; border-radius: 9px; }
.color-well::-moz-color-swatch { border: 0; border-radius: 9px; }

.picker .hex-input { width: 9.5rem; flex: none; font-family: var(--mono); text-transform: uppercase; letter-spacing: .04em; }

.swatches { display: grid; grid-template-columns: repeat(5, 30px); gap: 8px; margin-top: 10px; }
.swatch {
  width: 30px; height: 30px; padding: 0; cursor: pointer;
  border: 1px solid rgba(14, 27, 51, .16); border-radius: var(--r-sm);
  transition: transform .15s var(--ease), box-shadow .15s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

/* Live preview of the real widget, painted from the derived theme. */
.wpreview {
  position: relative; background: var(--sunk); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 20px 20px 30px; overflow: hidden;
}
.wpreview-panel {
  width: 100%; max-width: min(268px, calc(100% - 76px)); background: var(--surface); border-radius: 14px;
  box-shadow: 0 12px 34px -12px var(--wp-shadow, rgba(13, 32, 71, .35)); overflow: hidden;
}
.wpreview-head { background: var(--wp-accent, var(--nav-900)); color: var(--wp-on, #fff); padding: 11px 13px; }
.wpreview-head .n { font-size: .8rem; font-weight: 700; }
.wpreview-head .c { font-size: .68rem; opacity: .78; }
.wpreview-body { padding: 12px 13px; display: flex; flex-direction: column; gap: 7px; background: #F4F6FB; }
.wpreview-msg { max-width: 84%; font-size: .72rem; line-height: 1.45; padding: 7px 10px; border-radius: 11px; }
.wpreview-msg.bot { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.wpreview-msg.user { background: var(--wp-accent, var(--nav-900)); color: var(--wp-on, #fff); align-self: flex-end; border-bottom-right-radius: 3px; }
.wpreview-in { display: flex; gap: 6px; padding: 9px; border-top: 1px solid var(--line); }
.wpreview-in .fake { flex: 1; height: 26px; border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.wpreview-in .go {
  font-size: .68rem; font-weight: 700; padding: 0 11px; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--wp-accent, var(--nav-900)); color: var(--wp-on, #fff);
}
.wpreview-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; border: 2px solid var(--surface); background: #E5243B; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1; display: none;
  align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
}
#wpreview.shows-nudge .wpreview-badge { display: flex; }

.wpreview-bubble {
  position: absolute; right: 20px; bottom: 22px; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem;
  background: var(--wp-accent, var(--nav-900)); color: var(--wp-on, #fff);
  box-shadow: 0 8px 22px var(--wp-shadow, rgba(13, 32, 71, .35));
}

/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(90% 70% at 15% 0%, rgba(196, 150, 58, .16), transparent 58%),
    radial-gradient(80% 70% at 100% 100%, rgba(27, 58, 107, .55), transparent 60%),
    linear-gradient(160deg, #0B1A36, var(--nav-980));
}
.auth-card {
  width: 100%; max-width: 25rem; background: var(--surface);
  border-radius: var(--r-lg); padding: 34px 30px; box-shadow: var(--sh-3);
}
.auth-card h1 { font-size: 1.3rem; font-weight: 650; }
.auth-card .lede { font-size: .85rem; color: var(--mut); margin-top: 6px; }
.auth-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #10203C; font-size: .95rem; margin-bottom: 16px;
  background: linear-gradient(145deg, var(--gold-400), var(--gold-600));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
}

/* ── Mobile: rail becomes a drawer ──────────────────────────────────────── */
#hamburger {
  display: none; flex: none; width: 40px; height: 40px; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md);
  color: var(--ink); cursor: pointer; transition: background-color .18s ease, border-color .18s ease;
}
#hamburger:hover { background: var(--sunk); border-color: var(--mut); }
#hamburger:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.ham-lines { display: flex; flex-direction: column; gap: 5px; width: 18px; pointer-events: none; }
.ham-line {
  display: block; height: 1.5px; background: currentColor; border-radius: 2px;
  transition: transform .32s cubic-bezier(.34, 1.2, .64, 1), opacity .2s ease, width .32s cubic-bezier(.34, 1.2, .64, 1);
}
.ham-line:nth-child(2) { width: 12px; }
#hamburger.is-open .ham-line:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
#hamburger.is-open .ham-line:nth-child(2) { opacity: 0; width: 0; }
#hamburger.is-open .ham-line:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

#drawerClose {
  display: none; flex: none; width: 34px; height: 34px; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px; color: var(--on-dark); font-size: .95rem; cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease;
}
#drawerClose:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .26); }
#drawerClose:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }

#drawerBackdrop {
  position: fixed; inset: 0; z-index: 590; background: rgba(7, 18, 40, .5);
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
#drawerBackdrop.open { opacity: 1; pointer-events: auto; }

@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  #hamburger { display: flex; }
  #drawerClose { display: flex; }
  .topbar { padding: 10px 16px; }
  .view { padding: 20px 16px 72px; }
  .page-head h1 { font-size: 1.35rem; }

  .rail {
    position: fixed; top: 0; bottom: 0; right: 0; left: auto;
    z-index: 600; width: min(310px, 86vw);
    min-height: 100dvh; height: 100dvh;
    border-right: 0; border-left: 1px solid rgba(255, 255, 255, .08);
    background: #071228;
    transform: translateX(100%); visibility: hidden;
    transition: transform .42s var(--ease), visibility 0s linear .42s;
  }
  .rail.open { transform: translateX(0); visibility: visible; transition: transform .42s var(--ease), visibility 0s linear 0s; }
  .side-link[aria-current="page"]::before { left: -9px; }
}

@media (max-width: 767px) {
  .grid-tiles { gap: 10px; }
  .tile { padding: 14px 15px; }
  .tile .n { font-size: 1.45rem; }
  .card-pad { padding: 18px; }
  .card-head { padding: 14px 18px; }
  .chat { height: 340px; }
  .btn { padding: .58rem .9rem; }
  .page-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .rail { transition: none; }
}

/* ── Utilities ──────────────────────────────────────────────────────────────
   A deliberately small set. These exist so markup can express layout without
   pulling a whole utility framework over the wire. If a pattern needs more
   than three of these, it wants a named component class instead. */
.flex { display: flex; }
.grid { display: grid; }
.wrap { flex-wrap: wrap; }
.col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.gap-1 { gap: .3rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: .3rem; } .mt-2 { margin-top: .6rem; } .mt-3 { margin-top: 1rem; } .mt-5 { margin-top: 1.75rem; }
.mb-1 { margin-bottom: .3rem; } .mb-2 { margin-bottom: .6rem; } .mb-3 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.75rem; }
.text-xs { font-size: .76rem; line-height: 1.5; }
.text-sm { font-size: .875rem; line-height: 1.6; }
.semibold { font-weight: 600; }
.w-full { width: 100%; }
.underline { text-decoration: underline; text-underline-offset: 2px; }
.break { word-break: break-word; }
[hidden] { display: none !important; }

/* Conversations: a picker column beside the transcript, stacked on narrow
   screens so the transcript is never squeezed into an unreadable strip. */
.conv-split { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) {
  .conv-split { grid-template-columns: minmax(0, 1fr); }
  .conv-split #list { display: flex; flex-direction: column; max-height: 268px; overflow-y: auto; padding-right: 4px; }
  .conv-split #list > * + * { margin-top: 10px; }
}

/* ── Qualification builder ──────────────────────────────────────────────── */
.qb-master .qb-checklabel { font-size: 1rem; }
.qb-off > .card { opacity: .55; pointer-events: none; }
.qb-field { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--surface); transition: border-color .16s ease, background-color .16s ease; }
.qb-field.is-on { border-color: var(--line-2); background: #FBFCFE; }
.qb-details { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.qb-rule { background: var(--sunk); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.qb-num { width: 7rem; }

.qb-checkrow { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.qb-check { position: absolute; opacity: 0; width: 1px; height: 1px; }
.qb-checkbox { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--surface); display: grid; place-items: center; color: #fff; font-size: .7rem; margin-top: 1px; transition: background-color .15s ease, border-color .15s ease; }
.qb-checkbox i { opacity: 0; transform: scale(.6); transition: opacity .15s ease, transform .15s var(--ease); }
.qb-check:checked + .qb-checkbox { background: var(--nav-900); border-color: var(--nav-900); }
.qb-check:checked + .qb-checkbox i { opacity: 1; transform: scale(1); }
.qb-check:focus-visible + .qb-checkbox { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.qb-checklabel { display: block; font-size: .9rem; font-weight: 600; }
.qb-checksub { display: block; font-size: .8rem; color: var(--mut); margin-top: 2px; line-height: 1.5; }

.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.radio-row:hover { border-color: var(--line-2); }
.qb-radio { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio-dot { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); margin-top: 2px; position: relative; transition: border-color .15s ease; }
.radio-dot::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--nav-900); transform: scale(0); transition: transform .15s var(--ease); }
.qb-radio:checked + .radio-dot { border-color: var(--nav-900); }
.qb-radio:checked + .radio-dot::after { transform: scale(1); }
.qb-radio:checked ~ .grow .radio-label { color: var(--ink); }
.radio-row:has(.qb-radio:checked) { border-color: var(--nav-700); background: #F7F9FE; }
.qb-radio:focus-visible + .radio-dot { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.radio-label { display: block; font-size: .9rem; font-weight: 600; }
.radio-sub { display: block; font-size: .78rem; color: var(--mut); margin-top: 2px; }

/* ── Leads ──────────────────────────────────────────────────────────────── */
.lead.is-qualified { border-color: rgba(196, 150, 58, .55); box-shadow: 0 0 0 1px rgba(196, 150, 58, .18), var(--sh-1); }
.lead-headline { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.lead-summary { font-size: .9rem; color: var(--ink-2); line-height: 1.6; margin-top: 4px; font-style: italic; }
.lead-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 12px 0 0; font-size: .875rem; }
.lead-facts dt { color: var(--mut); }
.lead-facts dd { margin: 0; color: var(--ink); font-weight: 500; }
.lead-contact { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 600; color: var(--nav-800); text-decoration: underline; text-underline-offset: 3px; }
.lead-contact i { font-size: .8em; color: var(--mut); }
.lead-action { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; color: var(--gold-600); background: var(--gold-100); border-radius: var(--r-pill); padding: .25rem .7rem; }
.lead-events { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.timeline li { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; align-items: baseline; }
.timeline .tl-time { color: var(--mut); font-size: .72rem; }
.timeline .tl-label { font-weight: 600; }
.timeline .tl-extra { color: var(--mut); }
.timeline li.is-err .tl-label { color: var(--err); }
@media (max-width: 639px) { .lead-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; } .lead-facts dt { margin-top: 6px; font-size: .75rem; } }
