/* AFM Global — tokens from brief section 9. Dark only (matches hooks family). */
:root {
  --bg: #0E1116; --surface: #161A21; --surface-2: #1D222B; --border: #2A303B;
  --text: #E7EAEE; --muted: #97A1B0; --faint: #6B7484;
  --accent: #2DD4BF; --accent-ink: #062B27; --accent-soft: rgba(45, 212, 191, .12);
  --success: #22C55E; --warning: #F59E0B; --danger: #EF4444; --info: #60A5FA;
  --success-soft: rgba(34, 197, 94, .12); --warning-soft: rgba(245, 158, 11, .12); --danger-soft: rgba(239, 68, 68, .12); --info-soft: rgba(96, 165, 250, .12);
  --wa: #25D366; --sms: #A78BFA; --wa-soft: rgba(37, 211, 102, .12); --sms-soft: rgba(167, 139, 250, .14);
  --r-card: 12px; --r-ctl: 8px;
  --side: 232px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[x-cloak] { display: none !important; }
.num, td.num { font-variant-numeric: tabular-nums; }
h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12px; } .xs { font-size: 11px; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }

/* ───── shell ───── */
.shell { display: flex; min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #0A0D11; border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px; display: grid; place-items: center; flex: none; }
.wordmark { font-weight: 700; font-size: 14px; line-height: 1.1; }
.caption { color: var(--faint); font-size: 11px; }
.side-chip { margin: 4px 16px 10px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.nav-group { color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 35px; padding: 0 10px; border-radius: var(--r-ctl); color: var(--muted); white-space: nowrap; overflow: hidden; }
.nav a span.lbl { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 16px; height: 16px; flex: none; }
.badge { background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 17px; }
.side-foot { border-top: 1px solid var(--border); padding: 10px 16px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; overflow: hidden; }
.side-foot .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { margin-left: var(--side); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(14, 17, 22, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; gap: 12px; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-global { background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 10.5px; letter-spacing: .08em; padding: 2px 7px; border-radius: 5px; }
.clock { color: var(--muted); font-size: 12px; white-space: nowrap; }
.banners { padding: 12px 24px 0; display: grid; gap: 8px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: var(--r-ctl); border: 1px solid; font-size: 12.5px; }
.banner.warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, .35); color: #FCD34D; }
.banner.danger { background: var(--danger-soft); border-color: rgba(239, 68, 68, .35); color: #FCA5A5; }
.banner.info { background: var(--info-soft); border-color: rgba(96, 165, 250, .35); color: #BFDBFE; }
.banner b { color: var(--text); }
.content { padding: 20px 24px 48px; display: grid; gap: 16px; }

@media (max-width: 899px) {
  :root { --side: 64px; }
  .brand .wordmark, .brand .caption, .nav-group, .nav a span.lbl, .side-foot .who, .side-chip .chip-text { display: none; }
  .brand { justify-content: center; padding: 14px 0 8px; }
  .side-chip { margin: 4px 8px 8px; display: flex; justify-content: center; }
  .nav a { justify-content: center; padding: 0; position: relative; }
  .nav a .badge { position: absolute; top: 2px; right: 4px; padding: 0 4px; min-width: 0; font-size: 9.5px; line-height: 14px; }
  .nav a:hover::after { content: attr(data-tip); position: absolute; left: 60px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 50; }
  .nav { overflow: visible; }
  .side-foot { justify-content: center; padding: 10px 0; }
  .topbar { padding: 12px 16px; } .content, .banners { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .side { display: none; }
  .main { margin-left: 0; }
  .mobile-nav { display: flex !important; }
  .clock { display: none; }
}
.mobile-nav { display: none; gap: 6px; overflow-x: auto; padding: 8px 16px; border-bottom: 1px solid var(--border); background: #0A0D11; }
.mobile-nav a { padding: 6px 10px; border-radius: 99px; background: var(--surface); color: var(--muted); white-space: nowrap; font-size: 12px; }
.mobile-nav a.active { background: var(--accent-soft); color: var(--accent); }

/* ───── components ───── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .g3, .g2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack { display: grid; gap: 8px; align-content: start; }

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > i { background: var(--warning); } .bar.over > i { background: var(--danger); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid transparent; white-space: nowrap; line-height: 16px; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.chip.ok { color: var(--success); background: var(--success-soft); }
.chip.warn { color: var(--warning); background: var(--warning-soft); }
.chip.bad { color: var(--danger); background: var(--danger-soft); }
.chip.info { color: var(--info); background: var(--info-soft); }
.chip.off { color: var(--muted); background: var(--surface-2); }
.chip.accent { color: var(--accent); background: var(--accent-soft); }
.chip.wa { color: var(--wa); background: var(--wa-soft); }
.chip.sms { color: var(--sms); background: var(--sms-soft); }
.chip.big { font-size: 11.5px; padding: 4px 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3A4250; background: #232934; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger-soft); border-color: rgba(239, 68, 68, .45); color: #FCA5A5; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 6px 10px; height: 32px; min-width: 0; }
textarea { height: auto; min-height: 80px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: 0; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }

/* toggle 34x20 + state text */
.tg { display: inline-flex; align-items: center; gap: 8px; }
.toggle { position: relative; width: 34px; height: 20px; border-radius: 99px; background: #3A4250; border: 0; cursor: pointer; padding: 0; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(14px); }
.toggle:disabled { opacity: .4; cursor: not-allowed; }
.state { font-size: 11px; font-weight: 700; letter-spacing: .04em; min-width: 26px; }
.state.on { color: var(--accent); } .state.off { color: var(--faint); } .state.held { color: var(--warning); }

/* switchboard */
.switch-list { display: grid; }
.sw { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sw:last-child { border-bottom: 0; }
.sw .lbl { flex: 1; min-width: 0; }
.sw .lbl div:first-child { font-weight: 500; }
.sw .why { color: var(--warning); font-size: 11.5px; }

/* tables */
.tbl-wrap { overflow: auto; max-height: 70vh; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th { position: sticky; top: 0; background: var(--surface); color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: rgba(255, 255, 255, .02); }
table.t tr.click { cursor: pointer; }
table.t td.num, table.t th.num { text-align: right; }
tr.group-row td { background: var(--surface-2) !important; font-weight: 600; font-size: 12px; }
@media (max-width: 560px) {
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.t.cards td { border: 0; padding: 3px 12px; }
  table.t.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--faint); font-size: 11px; }
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { width: 240px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; font: inherit; cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; padding: 3px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

/* drawer + modal + toast */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border); z-index: 41; display: flex; flex-direction: column; }
.drawer.wide { width: min(640px, 100vw); }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: grid; gap: 16px; align-content: start; }
.modal { position: fixed; z-index: 60; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal h2 { font-size: 15px; }
.modal .consequence { background: var(--warning-soft); border: 1px solid rgba(245, 158, 11, .3); border-radius: var(--r-ctl); padding: 10px 12px; color: #FDE68A; margin: 8px 0 16px; }
.modal-scrim { z-index: 59; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 80; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-ctl); padding: 10px 14px; min-width: 240px; max-width: 380px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.toast.err { border-left-color: var(--danger); }

.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 6px 0; }
.tl .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-top: 6px; }
.tl .dot.sent, .tl .dot.delivered, .tl .dot.seen, .tl .dot.enrolled { background: var(--accent); }
.tl .dot.failed, .tl .dot.suppressed, .tl .dot.exited { background: var(--danger); }
.tl .dot.replied, .tl .dot.paused { background: var(--warning); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; font-size: 12.5px; }
.kv dt { color: var(--faint); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-2), #252b35, var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.cal .day { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-height: 96px; padding: 7px 8px; cursor: pointer; display: grid; align-content: start; gap: 3px; text-align: left; font: inherit; color: inherit; }
.cal .day:hover { border-color: #3A4250; }
.cal .day.other { opacity: .4; }
.cal .day.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal .day.sel { border-color: var(--accent); }
.cal .day.blackout { background-image: repeating-linear-gradient(135deg, rgba(239, 68, 68, .10) 0 8px, transparent 8px 16px); }
.cal .dn { font-weight: 600; font-size: 12px; display: flex; justify-content: space-between; }
.cal .ln { font-size: 11px; display: flex; gap: 6px; align-items: center; }
.cal .ln i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.cal.week .day { min-height: 200px; }
@media (max-width: 700px) { .cal .day { min-height: 64px; } .cal .ln span.t { display: none; } }

/* step cards */
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: start; cursor: pointer; }
.step.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.step .n { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.step .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.step .stats { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.step .stats b { color: var(--text); font-weight: 600; }
.wa-bubble { background: #0B3B33; border-radius: 10px 10px 10px 2px; padding: 10px 12px; white-space: pre-wrap; max-width: 380px; color: #E6FFFA; font-size: 13px; }
.sms-bubble { background: #2A2440; border-radius: 10px 10px 10px 2px; padding: 10px 12px; white-space: pre-wrap; max-width: 380px; font-size: 13px; }
.var { background: rgba(45, 212, 191, .2); color: var(--accent); border-radius: 4px; padding: 0 3px; }
.thread { display: grid; gap: 8px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { background: var(--surface-2); justify-self: start; border-bottom-left-radius: 2px; }
.msg.out { background: #0B3B33; justify-self: end; border-bottom-right-radius: 2px; }
.msg .when { color: var(--faint); font-size: 10.5px; margin-top: 3px; }

.chart { width: 100%; height: 180px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.copy { display: flex; gap: 6px; align-items: center; }
.copy code { background: var(--surface-2); border: 1px solid var(--border); padding: 5px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.hint { color: var(--faint); font-size: 11.5px; }
.prose { max-width: 820px; } .prose p, .prose li { color: #C9D0DA; } .prose h2 { margin-top: 20px; } .prose ol, .prose ul { padding-left: 20px; }
.funnel { display: grid; gap: 6px; }
.funnel .fr { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; font-size: 12px; }
.funnel .fb { height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel .fb i { display: block; height: 100%; background: var(--accent); opacity: .85; }

/* two-column page splits */
.split { gap: 16px; }
.split-320 { grid-template-columns: minmax(0, 1fr) 320px; }
.split-340 { grid-template-columns: minmax(0, 1fr) 340px; }
.split-420 { grid-template-columns: minmax(0, 1fr) 420px; }
.split-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
@media (max-width: 1180px) { .split-320, .split-340, .split-420, .split-even { grid-template-columns: minmax(0, 1fr); } .split-420 > aside { position: static !important; } }
