/* MediaVibes AI Headquarters (base styles shared with MediaVibes Accounting) — tokens first, then layout, then components */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f0efec;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --text: #141416;
  --text-2: #52514e;
  --muted: #7d7b76;
  --brand-orange: #f15a29;
  --brand-blue: #1c9ad6;
  --brand-yellow: #e2b42b;
  --accent: #1d6fc0;
  --accent-ink: #ffffff;
  --accent-soft: #e5effa;
  --good: #0a7d2c;
  --good-soft: #e3f4e7;
  --bad: #c13030;
  --bad-soft: #fbe7e6;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --focus: #1d6fc0;
  /* charts (validated reference palette) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --status-good: #0ca30c;
  --status-critical: #d03b3b;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0f;
    --surface: #18181a;
    --surface-2: #1d1d20;
    --surface-3: #26262a;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f3f3f1;
    --text-2: #c3c2b7;
    --muted: #94928b;
    --accent: #4d97ec;
    --accent-ink: #0b0b0b;
    --accent-soft: #1b2a3d;
    --good: #4cc56a;
    --good-soft: #13281a;
    --bad: #f07272;
    --bad-soft: #351819;
    --warn: #f2bf4c;
    --warn-soft: #33270d;
    --focus: #7fb4f2;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2c2c2a;
    --axis: #383835;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0f;
  --surface: #18181a;
  --surface-2: #1d1d20;
  --surface-3: #26262a;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f3f3f1;
  --text-2: #c3c2b7;
  --muted: #94928b;
  --accent: #4d97ec;
  --accent-ink: #0b0b0b;
  --accent-soft: #1b2a3d;
  --good: #4cc56a;
  --good-soft: #13281a;
  --bad: #f07272;
  --bad-soft: #351819;
  --warn: #f2bf4c;
  --warn-soft: #33270d;
  --focus: #7fb4f2;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2c2c2a;
  --axis: #383835;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
.h3, h3 { font-size: 14px; font-weight: 620; }
p { margin: 0 0 8px; }
code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.boot { padding: 40px; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: auto; }
.brand strong { font-size: 16px; letter-spacing: -0.01em; display: block; }
.brand span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 520; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .sep { height: 1px; background: var(--border); margin: 10px 6px; }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.sidebar-foot .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

.shell > div { min-width: 0; }
.main { min-width: 0; padding: 22px 28px 60px; }
td.contact { min-width: 150px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin-right: auto; }
.topbar select { width: auto; min-width: 96px; }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
  }
  .mobile-bar img { width: 28px; }
  .main { padding: 16px 16px 60px; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 550 13px/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 28px; padding: 4px 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { min-height: 30px; width: 30px; padding: 0; }

input, select, textarea {
  font: 14px/1.3 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; width: 100%; min-height: 34px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 560; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
label.check input { width: auto; min-height: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 120px; }
.filters input[type="search"] { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: 550 13px var(--font); color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin-right: auto; }
.card-head .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.hero { border-top: 3px solid var(--brand-blue); }
.kpi.hero.orange { border-top-color: var(--brand-orange); }
.kpi.hero.yellow { border-top-color: var(--brand-yellow); }
.delta { font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: var(--surface); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 650; border-bottom: 0; border-top: 1px solid var(--border-strong); }
td.desc { max-width: 380px; }
td.desc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable { cursor: pointer; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.statement td { padding: 7px 4px; }
.statement tr.total td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.statement tr.grand td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--text); }
.statement td.indent { padding-left: 18px; color: var(--text-2); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.paid { background: var(--good-soft); color: var(--good); }
.pill.unpaid { background: var(--warn-soft); color: var(--warn); }
.pill.overdue { background: var(--bad-soft); color: var(--bad); }
.pill.partial { background: var(--accent-soft); color: var(--accent); }
.pill.cancelled { background: var(--surface-3); color: var(--muted); }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.review { background: var(--warn-soft); color: var(--warn); }

/* ---------- notices ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 13px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--text); }
.notice .grow { flex: 1; }
.alerts { display: grid; gap: 8px; margin-bottom: 16px; }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.view-toggle { flex: none; }

/* ---------- invoice editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
@media (max-width: 1200px) { .editor { grid-template-columns: 1fr; } }
.form-grid { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
legend { font-weight: 620; font-size: 13px; padding: 0 6px; }
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 140px 30px; gap: 8px; align-items: center; }
.line .amount { text-align: right; }
.totals-row { display: flex; justify-content: flex-end; gap: 24px; font-size: 14px; }
.totals-row strong { font-size: 18px; }
.dir-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dir-toggle button { text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font: inherit; color: var(--text-2); }
.dir-toggle button strong { display: block; color: var(--text); }
.dir-toggle button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 12px 0 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* paper preview — always light, mirrors the Excel template */
.paper-wrap { position: sticky; top: 16px; }
.paper {
  color-scheme: light; background: #fff; color: #111; border-radius: 4px; box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
  font-family: "Century Gothic", "URW Gothic", "Avant Garde", Futura, var(--font); font-size: 11px; line-height: 1.35;
  padding: 26px 30px 30px; aspect-ratio: 210 / 297; overflow: hidden; container-type: inline-size;
}
.paper .banner { width: 100%; display: block; margin-bottom: 6px; }
.paper .title { font-size: 26px; font-weight: 700; margin: 4px 0 10px; letter-spacing: 0.01em; }
.paper .head { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.paper .head .meta { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-content: start; }
.paper .head .meta b { white-space: nowrap; }
.paper .bill { white-space: pre-line; }
.paper table { margin-top: 18px; border-collapse: collapse; width: 100%; }
.paper th { color: #111; background: transparent; text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 400; border-bottom: 1px solid #bfbfbf; padding: 6px 4px; }
.paper td { border-bottom: 1px solid #d9d9d9; padding: 7px 4px; color: #111; }
.paper tbody tr:hover { background: none; }
.paper td.amt, .paper th.amt { text-align: right; width: 32%; border-left: 1px solid #a6a6a6; }
.paper .sum td { border-bottom: 1px solid #d9d9d9; }
.paper .sum td.lbl { text-align: right; font-weight: 700; color: #595959; }
.paper .sum tr.total td { background: #f2f2f2; font-weight: 700; color: #111; }
.paper .vat { background: #f2f2f2; padding: 6px 8px; white-space: pre-line; }
.paper .foot { margin-top: 14px; display: grid; gap: 6px; }
.paper .foot b { font-weight: 700; }
.paper .issuer { font-size: 18px; font-weight: 700; margin-bottom: 4px; }

/* ---------- modal / toast ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog .dlg-body { padding: 20px; display: grid; gap: 12px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
#toast .t { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); }
#toast .t.err { background: var(--bad); color: #fff; }

/* ---------- auth / install ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.auth-card.wide { width: min(640px, 100%); }
.auth-logo { width: 54px; }
.auth-card .wordmark { width: 190px; max-width: 70%; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.checks .ok { color: var(--good); }
.checks .bad { color: var(--bad); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }
.waterfall-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.timeline { display: grid; gap: 8px; }
.timeline .step { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.timeline .step.next { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 560px) { .timeline .step { grid-template-columns: 1fr auto; } .timeline .step .when { grid-column: 1 / -1; } }

/* ---------- recurring invoicing, invoice log ---------- */
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog .dlg-body { max-height: calc(100vh - 160px); overflow-y: auto; }
.pill.sent, .pill.issued, .pill.successful, .pill.partner, .pill.completed { background: var(--good-soft); color: var(--good); }
.pill.failed, .pill.unsuccessful, .pill.bounced, .pill.do_not_contact, .pill.no_show { background: var(--bad-soft); color: var(--bad); }
.pill.queued, .pill.sending, .pill.awaiting_approval, .pill.awaiting_outcome, .pill.draft, .pill.approved, .pill.scheduled, .pill.meeting_scheduled { background: var(--accent-soft); color: var(--accent); }
.pill.not_sent, .pill.not_recorded, .pill.voided, .pill.written_off, .pill.paused, .pill.skipped, .pill.new, .pill.no_email, .pill.not_interested { background: var(--surface-3); color: var(--muted); }
.pill.active, .pill.generated, .pill.contacted, .pill.replied, .pill.met, .pill.drafted { background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; font: 560 13px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .badge { margin-left: 6px; }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.status-list li { display: flex; gap: 8px; align-items: flex-start; }
.status-list li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.status-list li.ok::before { background: var(--good); }
.status-list li.bad::before { background: var(--bad); }
.status-list li.warn::before { background: var(--warn); }
.sched-lines { display: grid; gap: 8px; }
.sched-line { display: grid; grid-template-columns: 1fr 80px 120px 110px 30px; gap: 8px; align-items: center; }
.sched-line .amount, .sched-line input[data-k="quantity"] { text-align: right; }
@media (max-width: 640px) { .sched-line { grid-template-columns: 1fr 1fr; } .sched-line input[data-k="description"] { grid-column: 1 / -1; } }
.email-preview { white-space: pre-wrap; font-size: 13px; background: var(--surface-2, var(--surface-3)); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; max-height: 320px; overflow: auto; }
.prospect-meta { font-size: 12px; color: var(--muted); }
.check-col { width: 28px; }
.filters label.check input { min-width: 0; width: auto; }
.check-col input { width: auto; min-height: 0; }

/* ---------- shareholders, ANAF guide ---------- */
.split-bar { display: flex; height: 26px; border-radius: 99px; overflow: hidden; font-size: 11px; font-weight: 650; }
.split-bar span { display: flex; align-items: center; justify-content: center; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.c0 { --c: var(--brand-blue); }
.c1 { --c: var(--brand-orange); }
.c2 { --c: var(--brand-yellow); }
.c3 { --c: var(--series-3); }
.split-bar span[class^="c"] { background: var(--c); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); margin-right: 8px; vertical-align: 0; }
table.split { margin-top: 10px; }
table.split th { padding: 6px 4px; }
.guide { display: grid; gap: 4px; margin-top: 18px; }
.guide-step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.guide-step .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent); }
.guide-step h3 { margin: 5px 0 6px; }
.guide-step p, .guide-step li { font-size: 13px; color: var(--text-2); }
.guide-step ul, .guide-step ol { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 5px; }

/* ---------- evaluation ---------- */
.value-range { margin-top: 16px; padding: 16px 18px; border-radius: var(--radius-sm); background: var(--accent-soft); position: relative; overflow: hidden; }
.value-range::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand-grad, var(--accent)); }
.value-range .big { font-size: clamp(22px, 2.4vw, 30px); font-weight: 750; letter-spacing: -0.02em; margin: 4px 0; }
.ev-inputs label { font-size: 11px; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix input { text-align: right; }
.input-suffix span { color: var(--muted); font-weight: 600; min-width: 14px; }
.kpis.compact .kpi { padding: 12px 14px; box-shadow: none; }
.kpis.compact .kpi .value { font-size: 20px; }
ul.tight { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 900px) { .grid-3.ev-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- visual refinements (layered over the base styles above) ---------- */
:root {
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 14px rgba(16, 24, 40, 0.05);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, 0.05), 0 12px 28px rgba(16, 24, 40, 0.09);
  --brand-grad: linear-gradient(90deg, var(--brand-blue), #6b63d9 55%, var(--brand-orange));
}
body { font-size: 14px; letter-spacing: -0.003em; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { letter-spacing: -0.01em; }

.sidebar { padding: 18px 12px; background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); }
.brand { padding-bottom: 20px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.nav a { position: relative; transition: background 0.15s ease, color 0.15s ease; }
.nav a.active { font-weight: 620; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-orange); }
.main { padding: 26px 32px 64px; max-width: 1480px; }
.topbar { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }

.btn { transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { box-shadow: 0 1px 2px rgba(29, 111, 192, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
.seg { background: var(--surface-3); padding: 2px; gap: 2px; border-color: transparent; }
.seg button { border-radius: 6px; background: transparent; }
.seg button + button { border-left: 0; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.card { transition: box-shadow 0.2s ease; }
.card:hover { box-shadow: var(--shadow-lift); }
.card-head { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }

.kpis { gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; padding: 16px 18px; transition: box-shadow 0.2s ease, transform 0.2s ease; }
.kpi:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.kpi .label { text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px; color: var(--muted); font-weight: 650; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.kpi .value { font-size: clamp(20px, 1.6vw, 26px); font-weight: 700; margin-top: 8px; }
.kpi.hero { border-top: 1px solid var(--border); }
.kpi.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-blue); }
.kpi.hero.orange::before { background: var(--brand-orange); }
.kpi.hero.yellow::before { background: var(--brand-yellow); }

th { background: var(--surface-2); border-bottom-color: var(--border-strong); }
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background 0.12s ease; }
.statement th { background: transparent; }

.notice { border: 1px solid transparent; border-left-width: 4px; padding: 11px 14px; line-height: 1.5; }
.notice.info { border-color: color-mix(in srgb, var(--accent) 22%, transparent); border-left-color: var(--accent); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 22%, transparent); border-left-color: var(--warn); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 22%, transparent); border-left-color: var(--bad); }
.notice.good { border-color: color-mix(in srgb, var(--good) 22%, transparent); border-left-color: var(--good); }

.auth-page { background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { position: relative; overflow: hidden; box-shadow: var(--shadow-lift); }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-grad); }
dialog { border-radius: 16px; }
dialog .dlg-body h2 { font-size: 17px; }

@media (max-width: 900px) {
  .main { padding: 16px 16px 60px; }
  .nav a.active::before { left: -12px; }
}
@media (prefers-reduced-motion: reduce) {
  .kpi, .card, .btn, .nav a, tbody tr { transition: none; }
  .kpi:hover { transform: none; }
}

@media print {
  .sidebar, .mobile-bar, .topbar .btn, .filters, .sticky-actions, .tabs, .view-toggle { display: none !important; }
  .card, .kpi { break-inside: avoid; }
  .shell { display: block; }
  body { background: #fff; }
}

/* ================= AI Headquarters additions ================= */
:root { --seq-1: #cde2fb; --seq-2: #86b6ef; --seq-3: #3987e5; --seq-4: #1c5cab; --seq-5: #0d366b; }
.pill.queued, .pill.retry, .pill.waiting, .pill.running, .pill.outreach_ready, .pill.qualified, .pill.meeting_proposed, .pill.booking_link_shared, .pill.requested, .pill.pending { background: var(--accent-soft); color: var(--accent); }
.pill.succeeded, .pill.won, .pill.confirmed, .pill.meeting_confirmed, .pill.meeting_held, .pill.positive, .pill.meeting_request { background: var(--good-soft); color: var(--good); }
.pill.lost, .pill.rejected, .pill.canceled, .pill.negative, .pill.opt_out, .pill.bounce, .pill.blocked { background: var(--bad-soft); color: var(--bad); }
.pill.researched, .pill.discovered, .pill.nurture, .pill.unclassified, .pill.neutral, .pill.auto_reply, .pill.withdrawn, .pill.not_started { background: var(--surface-3); color: var(--muted); }
.pill.proposal_sent, .pill.negotiation, .pill.in_progress, .pill.awaiting_approval { background: var(--warn-soft); color: var(--warn); }
.pill.critical, .pill.high { background: var(--bad-soft); color: var(--bad); }
.pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.low { background: var(--surface-3); color: var(--muted); }
.badge.soft { background: var(--accent-soft); color: var(--accent); }
.nc { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }
.nc.on { background: var(--good-soft); color: var(--good); }
.nc::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card { display: grid; gap: 10px; cursor: pointer; }
.agent-card .who { display: flex; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-size: 16px; color: #fff; background: var(--c, var(--accent)); flex: none; }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
.agent-card .role { font-size: 12px; color: var(--muted); }
.mini-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.mini-stats b { font-variant-numeric: tabular-nums; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: grid; gap: 4px; cursor: pointer; font-size: 13px; }
.lead-card:hover { border-color: var(--accent); }
.score { font-variant-numeric: tabular-nums; font-weight: 700; }
.conf { font-size: 11px; color: var(--muted); }
.scorebar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.scorebar > span { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }
.factor { display: grid; grid-template-columns: 1fr 64px; gap: 4px 10px; align-items: center; font-size: 13px; }
.factor small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

.chat { display: grid; grid-template-columns: 240px 1fr; gap: 16px; min-height: calc(100vh - 140px); }
@media (max-width: 900px) { .chat { grid-template-columns: 1fr; } .chat .threads { display: none; } }
.threads { display: flex; flex-direction: column; gap: 4px; }
.threads a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.threads a.on, .threads a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.convo { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.msgs { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.msg { max-width: 860px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg .from { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 12px; margin-bottom: 6px; color: var(--text-2); white-space: normal; }
.composer { display: flex; gap: 8px; position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 25%); }
.composer textarea { min-height: 52px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { font-size: 12px; }

.md { white-space: normal; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; font-size: 15px; }
.md ul { margin: 4px 0 8px; padding-left: 20px; }
.md p { margin: 0 0 8px; }

.heat td.cell { text-align: center; width: 64px; font-size: 12px; font-weight: 650; }
.heat td.on { background: var(--seq-3); color: #fff; }
.heat td.off { background: var(--surface-2); color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; }
.checklist li::before { content: "✓"; color: var(--good); font-weight: 700; }
.checklist li.fail::before { content: "✗"; color: var(--bad); }
.flow { width: 100%; height: auto; }
.flow text { font: 600 12px var(--font); fill: var(--text); }
.flow .sub { font-weight: 400; fill: var(--muted); font-size: 11px; }
.flow rect.node { fill: var(--surface); stroke: var(--border-strong); }
.flow path { fill: none; stroke: var(--axis); stroke-width: 2; }
.flow path.active { stroke: var(--series-1); }
.flow .count { fill: var(--accent); font-weight: 700; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.explain { margin-top: 10px; }
/* ================= company structure & workflow flowcharts ================= */
/* department colours: validated categorical slots 1-8 in fixed order (9th+ department = neutral grey, never a reused hue) (light + dark), always paired with the department name as text */
:root { --dept-1: #2a78d6; --dept-2: #eb6834; --dept-3: #1baf7a; --dept-4: #eda100; --dept-5: #e87ba4; --dept-6: #008300; --dept-7: #6250d6; --dept-8: #e34948; --dept-other: #9a9890; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dept-1: #3987e5; --dept-2: #d95926; --dept-3: #199e70; --dept-4: #c98500; --dept-5: #d55181; --dept-6: #008300; --dept-7: #9085e9; --dept-8: #e66767; --dept-other: #6f6e69; } }
:root[data-theme="dark"] { --dept-1: #3987e5; --dept-2: #d95926; --dept-3: #199e70; --dept-4: #c98500; --dept-5: #d55181; --dept-6: #008300; --dept-7: #9085e9; --dept-8: #e66767; --dept-other: #6f6e69; }

.org-wrap { overflow-x: auto; margin: 0 -18px; padding: 4px 18px 8px; }
svg.org { width: 100%; height: auto; display: block; }
svg.org text { font-family: var(--font); }
.org-card { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; transition: stroke 0.15s ease; }
.org-band { fill: var(--dc); }
.org-name { font-size: 14px; font-weight: 700; fill: var(--text); }
.org-title { font-size: 11.5px; fill: var(--text-2); }
.org-dept { font-size: 10.5px; fill: var(--muted); }
.org-node.ceo .org-card, .wf-step.ceo .org-card { fill: var(--accent-soft); stroke: var(--accent); }
.org-node.paused { opacity: 0.55; }
[data-agent] { cursor: pointer; outline: none; }
[data-agent]:hover .org-card, [data-agent]:focus-visible .org-card { stroke: var(--accent); stroke-width: 2; }

/* reporting lines draw themselves in, then a slow flow runs upward toward the CEO */
.org-line { fill: none; stroke: var(--axis); stroke-width: 2; stroke-dasharray: 6 6; stroke-linecap: round;
  animation: org-draw 0.9s ease-out both, org-flow 1.6s linear infinite; animation-delay: calc(var(--i) * 90ms), calc(0.9s + var(--i) * 90ms); }
@keyframes org-draw { from { stroke-dashoffset: 400; opacity: 0; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes org-flow { to { stroke-dashoffset: 24; } }
.org-dotted { fill: none; stroke: var(--text-2); stroke-width: 1.6; stroke-dasharray: 2 6; stroke-linecap: round; opacity: 0.8; animation: org-flow 3s linear infinite reverse; }
.org-hand { fill: none; stroke: var(--series-1); stroke-width: 1.4; opacity: 0.35; }
.org-hand-n { font-size: 11px; font-weight: 700; fill: var(--accent); }
.token { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.token.big { fill: var(--brand-orange); }

/* nodes enter one after another */
.org-node, .wf-step { animation: org-in 0.45s ease-out both; animation-delay: calc(var(--i) * 70ms); transform-box: fill-box; transform-origin: center; }
@keyframes org-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
/* agents with queued/running work glow */
.org-pulse { fill: none; stroke: var(--dc); stroke-width: 3; animation: org-pulse 1.8s ease-in-out infinite; }
@keyframes org-pulse { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.8; } }

.wf-arrow { fill: none; stroke: var(--axis); stroke-width: 2; stroke-dasharray: 5 5; animation: org-draw 0.6s ease-out both, org-flow 1.2s linear infinite; animation-delay: calc(var(--i) * 110ms), calc(0.6s + var(--i) * 110ms); }
.wf-head { fill: var(--axis); }
.wf-num { font-size: 11px; font-weight: 700; fill: var(--muted); }

svg.org.still *, svg.org.still { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .org-line, .org-dotted, .wf-arrow, .org-node, .wf-step, .org-pulse { animation: none !important; }
  .token { display: none; }
}
@media print { .token { display: none; } .org-line, .wf-arrow { animation: none; } }
.org-pos { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--text-2); margin-top: 4px; }
/* people vs AI agents in the structure */
.org-badge { fill: var(--surface-3); }
.org-badge-t { font-size: 10px; font-weight: 700; fill: var(--text-2); letter-spacing: 0.03em; }
.org-node.is-agent .org-badge { fill: var(--accent-soft); }
.org-node.is-agent .org-badge-t { fill: var(--accent); }
.org-node.is-person .org-card { stroke-width: 1.5; }
.org-node.open .org-card { stroke-dasharray: 5 4; fill: var(--surface-2); }
.org-node.open .org-name { fill: var(--muted); font-style: italic; }
[data-person], [data-ceo] { cursor: pointer; outline: none; }
[data-person]:hover .org-card, [data-person]:focus-visible .org-card, [data-ceo]:hover .org-card, [data-ceo]:focus-visible .org-card { stroke: var(--accent); stroke-width: 2; }