/* =====================================================================
   BFS Retention Command Center — design tokens
   Measured from Klaviyo app screenshots (help.klaviyo.com, Nov 2026):
     primary button #1d1e20 · body text #1c1c1c · column headers #4c4c4c
     canvas #f3f4f5 · dividers #ebedef · row rule #efefef · input border #949494
     status pill #ecedef · link blue ~#4374a5 · selected menu row: pale blue + 3px blue bar
   Inferred (not visible in any screenshot we could obtain): the sidebar's exact width and
   active-row fill, and the typeface name. Screens render in the platform UI face, so we use
   the system stack. See DESIGN.md.
   ===================================================================== */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-title: 24px;
  --fw-reg: 400; --fw-med: 500; --fw-semi: 600;

  --bg: #ffffff; --canvas: #f3f4f5; --surface: #ffffff;
  --ink: #1c1c1c; --ink-2: #4c4c4c; --ink-3: #6b6f76; --ink-inverse: #ffffff;
  --line: #ebedef; --row-line: #efefef; --input-line: #949494; --input-line-quiet: #c4c7cc;
  --primary: #1d1e20; --primary-hover: #3a3b3e;
  --link: #3d6d9e; --link-hover: #2a527a;
  --hover: #f6f7f8; --selected: #eef5fc; --selected-bar: #3d6d9e; --focus: #a9cdf2;
  --pill: #ecedef; --pill-ink: #2c2f33;
  --danger: #b42318;

  --st-draft-bg: #ecedef;     --st-draft-ink: #3b3f45;
  --st-progress-bg: #e4eefa;  --st-progress-ink: #1f4f86;
  --st-review-bg: #fcf0d9;    --st-review-ink: #7a4a00;
  --st-ready-bg: #e1f3f0;     --st-ready-ink: #0f5c4f;
  --st-live-bg: #e1f2e5;      --st-live-ink: #1d6b34;
  --st-archived-bg: #ecedef;  --st-archived-ink: #5b5f66;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --radius: 4px; --radius-lg: 8px;
  --row-h: 52px; --ctl-h: 36px; --chip-h: 32px;
  --sidebar-w: 236px; --drawer-w: 460px;
  --shadow-menu: 0 4px 16px rgba(16, 24, 40, .12), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-drawer: -8px 0 24px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fw-reg) var(--fs-md)/1.45 var(--font);
  -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: var(--radius); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line);
  background: var(--surface); padding: var(--s-4) var(--s-3); overflow-y: auto; }
.main { min-width: 0; }

/* ---------- Sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 2px var(--s-2) var(--s-5); }
.mark { width: 28px; height: 28px; border-radius: 6px; background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; letter-spacing: .02em; }
.brand b { display: block; font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: 1.15; }
.brand span { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 var(--s-2); border-radius: var(--radius);
  color: var(--ink); font-weight: var(--fw-reg); }
.nav a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--canvas); font-weight: var(--fw-semi); }
.nav a .n { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: var(--fw-reg); }
.nav .sep { height: 1px; background: var(--line); margin: var(--s-2) var(--s-2); }
.side h4 { margin: var(--s-5) var(--s-2) var(--s-1); font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-3); }
.recent a { display: block; padding: 5px var(--s-2); font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-radius: var(--radius); }
.recent a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.side-foot { margin-top: auto; padding: var(--s-4) var(--s-2) 0; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--ink-3); }
.side-foot .row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-size: var(--fs-xs); }
.linkbtn:hover { text-decoration: underline; }
.linkbtn:disabled { color: var(--ink-3); cursor: default; text-decoration: none; }

/* ---------- Page header ---------- */
.head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-4); border-bottom: 1px solid var(--line); }
.head h1 { margin: 0; font-size: var(--fs-title); font-weight: var(--fw-semi); letter-spacing: -.01em; }
.head .spacer { flex: 1; }
.menu-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl-h); padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--input-line); background: var(--surface); color: var(--ink);
  font-weight: var(--fw-med); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--ink-inverse); }
.btn.primary:hover { background: var(--primary-hover); color: var(--ink-inverse); }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: var(--radius); border: 1px solid var(--input-line-quiet); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.bare { border-color: transparent; background: transparent; }

/* ---------- Filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-6); }
.search { position: relative; flex: 0 1 300px; min-width: 200px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
.search input { width: 100%; height: var(--chip-h); padding: 0 10px 0 32px; border: 1px solid var(--input-line); border-radius: var(--radius); background: var(--surface); }
.search input::placeholder { color: var(--ink-3); }
.chip { position: relative; }
.chip > button { height: var(--chip-h); display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px dashed var(--input-line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--ink); white-space: nowrap; }
.chip > button:hover { background: var(--hover); }
.chip.on > button { border-style: solid; border-color: var(--ink-2); }
.chip.on > button b { font-weight: var(--fw-semi); }
.filters .clear { margin-left: var(--s-1); }
.filters .count { margin-left: auto; color: var(--ink-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* bulk bar replaces the filters while rows are selected */
.bulk { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-6); min-height: 64px; }
.bulk b { font-weight: var(--fw-semi); margin-right: var(--s-2); }

/* ---------- Menus / popovers ---------- */
.menu { position: absolute; z-index: 40; min-width: 200px; max-height: 340px; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-menu); padding: 4px 0; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; border: 0; border-left: 3px solid transparent;
  background: none; text-align: left; cursor: pointer; color: var(--ink); white-space: nowrap; font-size: var(--fs-md); }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--hover); text-decoration: none; outline: none; }
.menu [aria-checked="true"] { background: var(--selected); border-left-color: var(--selected-bar); color: #1b3e63; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu .label { padding: 8px 14px 4px; font-size: var(--fs-xs); color: var(--ink-3); }
.menu .danger { color: var(--danger); }

/* ---------- Table ---------- */
.tablewrap { padding: 0 var(--s-6) var(--s-6); }
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th { height: 44px; text-align: left; font-weight: var(--fw-reg); color: var(--ink-2); font-size: var(--fs-md);
  border-bottom: 1px solid var(--line); padding: 0 var(--s-3); white-space: nowrap; }
.grid th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.grid th button:hover { color: var(--ink); }
.grid th button:focus-visible { outline: 3px solid var(--focus); }
.grid td { height: var(--row-h); border-bottom: 1px solid var(--row-line); padding: 8px var(--s-3); vertical-align: middle; }
.grid tbody tr.row { cursor: pointer; }
.grid tbody tr.row:hover { background: var(--hover); }
.grid tbody tr.row.sel { background: var(--selected); }
.grid .c-check { width: 44px; padding-right: 0; }
.grid .c-title { width: auto; }
.grid .c-cat { width: 170px; } .grid .c-prod { width: 160px; } .grid .c-status { width: 132px; }
.grid .c-date { width: 128px; } .grid .c-act { width: 84px; text-align: right; } .grid .c-caret { width: 28px; padding: 0; }
.cb { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.ptitle { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ptitle a { font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-3); min-width: 0; }
.psub .host { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin { color: var(--ink-2); display: inline-flex; }
.muted { color: var(--ink-3); }
.cell-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act { display: inline-flex; gap: 4px; justify-content: flex-end; }
.date { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--pill);
  color: var(--pill-ink); font-size: var(--fs-sm); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.st-draft { background: var(--st-draft-bg); color: var(--st-draft-ink); }
.pill.st-in_progress { background: var(--st-progress-bg); color: var(--st-progress-ink); }
.pill.st-in_review { background: var(--st-review-bg); color: var(--st-review-ink); }
.pill.st-ready { background: var(--st-ready-bg); color: var(--st-ready-ink); }
.pill.st-live { background: var(--st-live-bg); color: var(--st-live-ink); }
.pill.st-archived { background: var(--st-archived-bg); color: var(--st-archived-ink); }
.pill.st-none { background: transparent; color: var(--ink-3); padding: 0; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: var(--fs-xs);
  background: var(--pill); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: var(--st-review-bg); color: var(--st-review-ink); }
.tag.err { background: #fde8e6; color: var(--danger); }
/* Vercel's technical deployment state: deliberately a different visual language from workflow status */
.dstate { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 3px; color: var(--ink-2); }
.dstate.ERROR, .dstate.CANCELED { color: var(--danger); border-color: #f3c7c2; }
.dstate.BUILDING, .dstate.QUEUED, .dstate.INITIALIZING { color: var(--st-review-ink); border-color: #f0dcb4; }

/* ---------- Slot sub-table (campaigns) ---------- */
tr.slots td { background: #fafbfb; padding: 0 var(--s-3) var(--s-4) 72px; height: auto; cursor: default; }
.slotbox h5 { margin: var(--s-3) 0 var(--s-1); font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-3); }
table.mini { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.mini th { text-align: left; font-weight: var(--fw-reg); color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mini td { padding: 6px 8px; border-bottom: 1px solid var(--row-line); vertical-align: top; }
.mini td.s { font-weight: var(--fw-semi); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini tr.child td { color: var(--ink-2); }
.mini tr.child td:nth-child(2) { padding-left: 22px; }
.slotnote { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s-2); }
.caret { width: 24px; height: 24px; border: 0; background: none; cursor: pointer; color: var(--ink-2); border-radius: var(--radius); display: grid; place-items: center; }
.caret:hover { background: var(--canvas); }
.caret svg { transition: transform .15s; }
.caret[aria-expanded="true"] svg { transform: rotate(90deg); }

/* ---------- Empty / loading ---------- */
.empty { padding: 72px var(--s-6); text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: var(--fs-lg); font-weight: var(--fw-semi); margin-bottom: 4px; }
.skeleton td div { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #f0f1f3, #f7f8f9, #f0f1f3); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .18); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--drawer-w), 100vw); background: var(--surface); z-index: 51;
  box-shadow: var(--shadow-drawer); display: flex; flex-direction: column; }
.dhead { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-4); border-bottom: 1px solid var(--line); }
.dhead h2 { margin: 0; font-size: 18px; font-weight: var(--fw-semi); line-height: 1.3; flex: 1; }
.dhead .psub { margin-top: 4px; }
.dactions { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.dbody { flex: 1; overflow-y: auto; padding: 0 var(--s-5) var(--s-5); }
.dsec { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.dsec:last-child { border-bottom: 0; }
.dsec h3 { margin: 0 0 var(--s-3); font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.field { display: grid; gap: 4px; margin-bottom: var(--s-3); }
.field label { font-size: var(--fs-sm); color: var(--ink-2); }
.field input, .field select, .field textarea { height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--input-line); border-radius: var(--radius); background: var(--surface); width: 100%; }
.field textarea { height: 72px; padding: 8px 10px; resize: vertical; }
.field .hint { font-size: var(--fs-xs); color: var(--ink-3); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.savebar { display: flex; gap: var(--s-2); align-items: center; }
.savebar .msg { font-size: var(--fs-sm); color: var(--ink-3); }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 6px var(--s-3); font-size: var(--fs-sm); }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.rel { list-style: none; margin: 0 0 var(--s-2); padding: 0; }
.rel li { display: flex; align-items: center; gap: var(--s-2); padding: 6px 0; border-bottom: 1px solid var(--row-line); font-size: var(--fs-sm); }
.rel li a { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel li .tag { flex: none; }
.suggest { font-size: var(--fs-xs); color: var(--ink-3); margin: var(--s-3) 0 var(--s-1); }

/* ---------- Modal ---------- */
.modal { position: fixed; z-index: 61; top: 8vh; left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 32px));
  max-height: 84vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-menu); }
.modal .mhead { display: flex; align-items: center; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.modal .mhead h2 { margin: 0; font-size: 18px; font-weight: var(--fw-semi); flex: 1; }
.modal .mbody { padding: var(--s-4) var(--s-5) var(--s-5); }
.modal .mfoot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--input-line); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s-4); }
.seg button { height: 32px; padding: 0 14px; border: 0; background: var(--surface); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--input-line); }
.seg button[aria-pressed="true"] { background: var(--canvas); font-weight: var(--fw-semi); }
.tpls { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-bottom: var(--s-4); }
.tpl { text-align: left; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s-3); background: var(--surface); cursor: pointer; }
.tpl:hover { border-color: var(--input-line); }
.tpl[aria-pressed="true"] { border-color: var(--selected-bar); background: var(--selected); }
.tpl b { display: block; font-weight: var(--fw-semi); margin-bottom: 2px; }
.tpl span { font-size: var(--fs-xs); color: var(--ink-2); }
.notice { font-size: var(--fs-sm); background: var(--canvas); border-radius: var(--radius); padding: var(--s-3); color: var(--ink-2); margin: var(--s-2) 0; }
.notice.ok { background: var(--st-live-bg); color: var(--st-live-ink); }
.notice.err { background: #fde8e6; color: var(--danger); }
.files { font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: var(--radius); font-size: var(--fs-sm); z-index: 80; box-shadow: var(--shadow-menu); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .grid .c-prod { display: none; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 70; left: 0; width: 272px; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-drawer); }
  .side.open { transform: none; }
  .menu-toggle { display: inline-grid; }
  .head { padding: var(--s-4) var(--s-4) var(--s-3); }
  .head h1 { font-size: 20px; }
  .filters, .bulk { padding: var(--s-3) var(--s-4); }
  .search { flex: 1 1 100%; }
  .tablewrap { padding: 0 var(--s-4) var(--s-5); }
  .grid .c-cat, .grid .c-date, .grid .c-check, .grid .c-caret { display: none; }
  .grid .c-status { width: 112px; } .grid .c-act { width: 44px; }
  .grid .act .pinbtn { display: none; }
  tr.slots td { padding-left: var(--s-3); }
  .head .btn.primary span { display: none; }
}
@media (max-width: 480px) { .grid .c-status { display: none; } .two { grid-template-columns: 1fr; } .tpls { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- fixes after visual QA ---------- */
.icon-btn.menu-toggle { display: none; }
.side-foot .row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .linkbtn { flex: none; }
.grid tr.row .pinbtn { opacity: 0; }
.grid tr.row:hover .pinbtn, .grid tr.row .pinbtn:focus-visible { opacity: 1; }
@media (max-width: 860px) { .icon-btn.menu-toggle { display: inline-grid; } }
@media (hover: none) { .grid tr.row .pinbtn { opacity: 1; } }
.filters .ftail { margin-left: auto; display: inline-flex; align-items: center; gap: var(--s-2); }
.filters .ftail .count { margin-left: 0; }
