/* ===========================================================================
   socio — Direction B · "Neutral Enterprise" design system
   Cool near-white untextured canvas · slate rail (#1B2027) · ONE grotesk
   (Hanken Grotesk) + JetBrains Mono for data · persimmon DEMOTED to an
   action/active accent only · flat white cards · dense SLDS-style data grid.

   This shared stylesheet defines the look of all 73 screens. It preserves the
   complete legacy class API (.rail/.app/.topbar/.crumb/.kpi/.seg/.tabs/.card/
   .row/.ev/.st-…/.btn/.dialog/.cmdk/.chip/.badge/tables/forms/…) so screens
   inherit Direction B with NO per-screen edits, while adding token, density,
   and content-fit helpers.
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- cool neutral ramp (canvas / surfaces / borders / ink) ---- */
  --paper:    #F6F7F9;   /* app canvas — cool near-white, ZERO texture */
  --paper-2:  #F2F4F7;   /* surface-2: subhead fills, wells, sticky header, zebra */
  --canvas:   #F6F7F9;
  --lifted:   #FBFBFC;   /* lifted canvas / hover base */
  --card:     #FFFFFF;   /* flat cards */
  --surface:  #FFFFFF;
  --surface-2:#F2F4F7;

  --line:     #E3E7ED;   /* hairline 1px cool-gray border */
  --line-2:   #D4DAE2;   /* stronger divider / input border */
  --line-3:   #C2CAD5;   /* control border on hover */

  --ink:      #11161D;   /* primary text — near-black slate */
  --ink-2:    #3D4651;   /* secondary text */
  --ink-3:    #6B7785;   /* tertiary / mono labels */
  --ink-4:    #97A1AD;   /* placeholder / disabled */

  /* ---- accent: persimmon DEMOTED to action + active state only ---- */
  --accent:    #E2492B;   /* persimmon */
  --accent-d:  #C53A1F;   /* darker fill — AA white text */
  --accent-soft:#FCEAE5;
  --accent-on: #C53A1F;   /* primary fill behind white text (AA both themes) */

  /* ---- data-viz: NEVER the brand accent on charts ---- */
  --viz-blue: #3B6FD4;    /* primary cool series */
  --viz-gray: #9AA7BC;    /* secondary neutral series */
  --viz-soft: #E7EDF9;    /* tint / focus glow */
  --viz-teal: #1F7A87;    /* 3rd cool series */
  --viz-indigo: #5A86DE;  /* 4th cool series */
  /* legacy aliases used by chart helpers */
  --data:      var(--viz-blue);
  --data-2:    var(--viz-gray);
  --data-soft: var(--viz-soft);

  /* ---- status (cooled, conventional SaaS · AA on the white card) ---- */
  --st-draft:     #6B7785;
  --st-scheduled: #1F7A87;   /* teal */
  --st-approval:  #B07A12;   /* amber */
  --st-published: #2E7D52;   /* green */
  --st-failed:    #C23B22;   /* red */
  /* -solid variants stay dark enough for white text in BOTH themes (the base
     status colours lighten in dark mode, dropping #fff below AA on the fill) */
  --st-failed-solid:    #C23B22;
  --st-published-solid: #2E7D52;
  /* solid chip fills + AA chip text */
  --st-draft-bg:     #EFF1F4;  --st-draft-tx:     #4A535E;
  --st-scheduled-bg: #E4F2F4;  --st-scheduled-tx: #145A65;
  --st-approval-bg:  #FBF1DC;  --st-approval-tx:  #8A5E0B;
  --st-published-bg: #E5F2EB;  --st-published-tx: #1E5E3D;
  --st-failed-bg:    #FBE9E5;  --st-failed-tx:    #97301B;
  /* legacy text aliases */
  --st-approval-text: var(--st-approval-tx);
  --st-draft-text:    var(--st-draft-tx);

  /* ---- sentiment ---- */
  --sent-pos: #2E7D52; --sent-pos-bg: #E5F2EB;
  --sent-neu: #6B7785; --sent-neu-bg: #EFF1F4;
  --sent-neg: #C23B22; --sent-neg-bg: #FBE9E5;

  /* ---- network ---- */
  --ig: #DD2A7B;
  --fb: #1877F2;

  /* ---- fonts: ONE grotesk for chrome, mono for data ---- */
  --font-body:    'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  /* --font-display is INTENTIONALLY IDENTICAL to --font-body post-Direction-B
     (the display serif was dropped). It is kept only so the ~57 screens that
     already reference it keep resolving; applying or omitting it is a no-op and
     carries no meaning — do not read it as a deliberate typographic contrast. */
  --font-display: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-ui:      var(--font-body);
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* ---- TYPE RAMP — snapped to whole px (11,12,13,14,16,20,26,32) ---- */
  --fs-11: 11px;   /* micro / mono labels */
  --fs-12: 12px;   /* dense table / captions */
  --fs-13: 13px;   /* body-dense / controls */
  --fs-14: 14px;   /* body default */
  --fs-16: 16px;   /* lead / card title */
  --fs-20: 20px;   /* section / modal title */
  --fs-26: 26px;   /* page title */
  --fs-32: 32px;   /* KPI numerals */
  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-body:  1.5;

  /* ---- 8pt SPACING SCALE ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* ---- radius / elevation (flat, cool, minimal) ---- */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 8px;
  --radius: var(--r-1);   /* legacy alias */
  --shadow-1: 0 1px 2px rgba(17,22,29,.04), 0 1px 1px rgba(17,22,29,.04);
  --shadow-2: 0 1px 2px rgba(17,22,29,.05), 0 4px 12px -6px rgba(17,22,29,.12);
  --shadow-3: 0 1px 2px rgba(17,22,29,.06), 0 12px 36px -16px rgba(17,22,29,.24);
  --shadow: var(--shadow-2);   /* legacy alias */
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px #2F6BD0;

  /* ---- fixed control sizes (deliberate, aliased not magic) ---- */
  --ctl: 34px;       /* icon-btn / topbar control */
  --av: 30px;        /* avatar */
  --rail-w: 240px;

  /* ---- density hooks (overridden under [data-density="compact"]) ---- */
  --row-py: var(--sp-4);     /* list row vertical padding */
  --cell-py: var(--sp-3);    /* table cell vertical padding */
  --kpi-pad: var(--sp-4);

  /* ---- surfaces that must stay dark-on-light and invert under dark mode ---- */
  --rail:      #1B2027;   /* slate rail — always the darkest surface */
  --rail-2:    #232A33;   /* rail hover / me-card */
  --rail-line: #2E3640;   /* rail internal border */
  --rail-ink:  #C5CCD6;   /* rail idle label */
  --rail-ink-2:#8B95A3;   /* rail muted */
  --solid:     #11161D;   /* solid (non-accent) buttons / segmented-on / toasts */
  --solid-ink: #FFFFFF;
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  /* Direction B: cool untextured canvas — no paper grain */
}

::selection { background: #D6E2F7; color: var(--ink); }
html[data-theme="dark"] ::selection { background: #33405C; color: var(--ink); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; background-color: transparent; }
/* inherit --ink so button text inverts in dark mode (the UA default black doesn't), and drop the
   UA 'buttonface' fill (#EFEFEF) for the same reason: any button that doesn't declare its own
   background was rendering as a light-grey pill on the dark canvas. Class rules still win. */
em { font-style: normal; }   /* Direction B: editorial italics flattened (accent on h1 em is set explicitly) */
h1 em, h2 em, h3 em, h4 em, .cnum em, .bn-h em { font-style: normal !important; }  /* override page-local heading-italic flourishes on 21 screens */

/* ---------- app frame ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }

/* ---------- sidebar rail (slate) ---------- */
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--rail-line);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-4); min-width: 0; }
.brand .mark {
  font-family: var(--font-body);
  font-weight: 700; font-size: var(--fs-16); letter-spacing: -.02em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.brand .mark b { color: var(--accent); font-style: normal; }
.brand .tag {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--rail-ink-2);
  border: 1px solid var(--rail-line); padding: 2px 6px; border-radius: 20px;
  margin-left: auto; flex: none;
}

.rail nav { display: flex; flex-direction: column; gap: 1px; margin-top: var(--sp-1); }
.rail .nav-label {
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--rail-ink-2); padding: var(--sp-4) var(--sp-2) var(--sp-2);
}
.rail a.item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px var(--sp-2); border-radius: var(--r-1);
  color: var(--rail-ink); font-weight: 500; font-size: var(--fs-13);
  transition: background .12s, color .12s;
  position: relative;
  /* FIT: single-line label, never wrap, ellipsis fallback */
  white-space: nowrap; overflow: hidden; min-width: 0;
}
.rail a.item svg { width: 17px; height: 17px; stroke-width: 1.7; flex: none; }
/* label text node flexes & ellipsizes; icon + count stay pinned */
.rail a.item > svg ~ * { min-width: 0; }
.rail a.item:hover { background: var(--rail-2); color: #fff; }
.rail a.item.active { background: var(--rail-2); color: #fff; font-weight: 600; }
.rail a.item.active svg { color: #fff; }
/* active = persimmon edge marker (accent reserved for active state) */
.rail a.item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail a.item .count {
  margin-left: auto; flex: none;
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--rail-line); color: var(--rail-ink);
  padding: 1px 6px; border-radius: 20px; min-width: 24px; text-align: center;
}
.rail a.item.active .count { background: var(--accent-on); color: #fff; }

.rail .spacer { flex: 1; min-height: var(--sp-4); }
.rail .me {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2);
  border: 1px solid var(--rail-line); border-radius: var(--r-2);
  background: var(--rail-2); margin-top: var(--sp-3);
  cursor: pointer; min-width: 0;
}
.rail .me .av {
  width: 32px; height: 32px; border-radius: var(--r-2); flex: none;
  background: linear-gradient(135deg, var(--viz-blue), var(--viz-teal));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: var(--fs-12);
}
/* FIT: both .who lines truncate — name AND role overflow the 240px rail */
.rail .me .who { line-height: var(--lh-snug); min-width: 0; flex: 1; }
.rail .me .who b {
  font-size: var(--fs-13); color: #fff; font-weight: 600; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail .me .who span {
  font-family: var(--font-mono); font-size: var(--fs-11); color: var(--rail-ink-2); display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--paper); }

.topbar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5); height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
/* FIT: crumb shrinks/ellipsizes; right cluster stays flex:none */
.topbar .crumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-body); font-size: var(--fs-13); color: var(--ink-3);
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.topbar .crumb b {
  color: var(--ink); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* legacy account pill (kept) — Direction-B flat */
.profile-pill {
  display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; flex: none;
  border: 1px solid var(--line-2); border-radius: 20px; padding: 3px var(--sp-3) 3px 4px;
  background: var(--surface); cursor: pointer;
}
.profile-pill:hover { border-color: var(--line-3); }
.profile-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-published); flex: none; }
.profile-pill span {
  font-size: var(--fs-12); font-weight: 600;
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-pill .avs { display: flex; flex: none; }
.profile-pill .avs i {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-style: normal; font-size: 10px; font-weight: 700; color: #fff; margin-left: -6px; border: 2px solid var(--surface);
}

.icon-btn {
  width: var(--ctl); height: var(--ctl); border-radius: var(--r-2); border: 1px solid var(--line-2);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  position: relative; flex: none;
}
.icon-btn:hover { border-color: var(--line-3); color: var(--ink); background: var(--lifted); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
/* notification badge — budget for 3 glyphs ("99+") */
.icon-btn .badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent-on); color: #fff; border-radius: 20px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: grid; place-items: center; border: 2px solid var(--surface);
}

.content { padding: var(--sp-5); flex: 1; }
.content.flush { padding: 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-5); margin-bottom: var(--sp-5); flex-wrap: wrap; }
/* flex items default to min-width:auto, so a long title/sub or an action row is
   sized to its min-content and overflows the viewport on phones even though the
   header itself wraps. Let them shrink, and let an action row wrap internally so
   a wide CTA drops to the next line instead of off-screen. (Used by 45 screens;
   flex-wrap is inert on the non-flex title block.) */
.page-head > * { min-width: 0; flex-wrap: wrap; }
.page-head h1 {
  font-family: var(--font-body); font-weight: 700; font-size: var(--fs-26);
  letter-spacing: -.02em; line-height: var(--lh-tight); color: var(--ink);
}
.page-head h1 em { font-style: normal; color: var(--accent); }
.page-head .btn.accent { padding: 8px var(--sp-4); font-size: var(--fs-13); }
.page-head .sub { font-size: var(--fs-13); color: var(--ink-3); margin-top: var(--sp-2); }
.page-head .sub b { font-weight: 600; color: var(--ink-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-13);
  padding: 8px var(--sp-3); border-radius: var(--r-2); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  transition: background .12s, border-color .12s, box-shadow .08s, transform .08s;
  /* FIT: command labels never wrap mid-word, never ellipsize */
  white-space: nowrap; max-width: 100%;
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--lifted); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
/* disabled buttons must not read as enabled (they kept full contrast + pointer + hover) */
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
/* NB: the disabled guard lives ON the variant hovers below — a separate rule here would
   lose to them (same specificity, declared later), and `background:inherit` would take the
   PARENT background rather than the button's own resting fill. */
.btn svg { width: 15px; height: 15px; stroke-width: 2; flex: none; }
/* persimmon primary == .accent (legacy) / .primary (sample) */
.btn.accent, .btn.primary { background: var(--accent-on); border-color: var(--accent-on); color: #fff; }
.btn.accent:hover:not(:disabled):not([aria-disabled="true"]),
.btn.primary:hover:not(:disabled):not([aria-disabled="true"]) { background: #B43419; border-color: #B43419; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--line-3); background: var(--surface); }
.btn.sm { padding: 5px var(--sp-2); font-size: var(--fs-12); }
.btn.danger { background: var(--st-failed-solid); border-color: var(--st-failed-solid); color: #fff; }
.btn.danger:hover:not(:disabled):not([aria-disabled="true"]) { background: #A8341D; border-color: #A8341D; }

/* shared form controls (socio.css had none — Direction-B adds them) */
input, select, textarea { font-family: var(--font-body); color: var(--ink); }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
select.inp, input.inp {
  width: 100%; min-width: 0; font-size: var(--fs-14); line-height: var(--lh-body);
  padding: 8px var(--sp-3); border: 1px solid var(--line-2); border-radius: var(--r-2);
  background: var(--surface); color: var(--ink); outline: none;
}
.field input:not([type="checkbox"]):not([type="radio"]):focus-visible,
.field select:focus-visible { border-color: var(--line-3); box-shadow: 0 0 0 3px var(--viz-soft); }

/* ---------- chips / badges ---------- */
/* Direction-B: flat square 4px, solid status fills, mixed-case, AA on white.
   nowrap + max-width + ellipsis so a long variant label truncates, never bursts. */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-body); font-size: var(--fs-11); font-weight: 600; letter-spacing: .01em;
  padding: 2px var(--sp-2); border-radius: var(--r-1); border: 0; color: var(--ink-2);
  background: var(--surface-2);
  white-space: nowrap; max-width: 26ch; overflow: hidden; text-overflow: ellipsis;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
/* opt-in uppercase code modifier (the only place uppercase/tracking survives) */
.chip--code { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }
/* non-status content "pills" are allowed to wrap / go full width */
.pill, .meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-12); color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); padding: 3px var(--sp-2); border-radius: var(--r-2);
  white-space: normal; max-width: 100%;
}

.st-draft     { background: var(--st-draft-bg);     color: var(--st-draft-tx); }
.st-scheduled { background: var(--st-scheduled-bg); color: var(--st-scheduled-tx); }
.st-approval  { background: var(--st-approval-bg);  color: var(--st-approval-tx); }
.st-published { background: var(--st-published-bg); color: var(--st-published-tx); }
.st-failed    { background: var(--st-failed-bg);    color: var(--st-failed-tx); }
.st-draft .dot{ background: var(--st-draft); }
.st-scheduled .dot{ background: var(--st-scheduled); }
.st-approval .dot{ background: var(--st-approval); }
.st-published .dot{ background: var(--st-published); }
.st-failed .dot{ background: var(--st-failed); }

/* sentiment chip — ONE canonical contract (+ legacy aliases) */
.sent, .senti, .sent-chip, .sent-human, .md-sent-rcl {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-11); font-weight: 600; padding: 2px var(--sp-2); border-radius: var(--r-1);
  white-space: nowrap;
}
.sent .dot, .senti .dot, .sent-chip .dot, .sent-human .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.sent.pos { background: var(--sent-pos-bg); color: var(--sent-pos); } .sent.pos .dot { background: var(--sent-pos); }
.sent.neu { background: var(--sent-neu-bg); color: var(--sent-neu); } .sent.neu .dot { background: var(--sent-neu); }
.sent.neg { background: var(--sent-neg-bg); color: var(--sent-neg); } .sent.neg .dot { background: var(--sent-neg); }

.net { width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; color: #fff; font-size: 9px; font-weight: 800; flex: none; }
.net.ig { background: radial-gradient(120% 120% at 30% 110%, #FEDA75, #FA7E1E 28%, #D62976 60%, #962FBF 85%, #4F5BD5); }
.net.fb { background: var(--fb); }

/* generic tag chip (one notch below status chips) */
.tags { display: flex; gap: var(--sp-1); flex-wrap: wrap; align-items: flex-start; }
.tag {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 3px; flex: none;
  white-space: nowrap; max-width: 18ch; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- cards / panels ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: none; overflow: hidden; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); }

/* KPI tiles — flat separate cards (Direction B) */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.kpis > * { min-width: 0; }   /* tiles must shrink with their track, not overflow it */
.kpi { padding: var(--kpi-pad); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); min-width: 0; }
.kpi:last-child { border-right: 1px solid var(--line); }
.kpi .label {
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  /* FIT: long labels (24ch) wrap to 2 lines, never force the tile wider */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: var(--lh-snug);
}
.kpi .val {
  font-family: var(--font-mono); font-weight: 600; letter-spacing: -.02em; margin-top: var(--sp-2); color: var(--ink);
  /* FIT: clamp font so 1/4-width tiles never clip numerals; digits stay whole */
  font-size: clamp(var(--fs-26), 5vw, var(--fs-32)); line-height: 1.05; white-space: nowrap;
}
.kpi .delta {
  font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 600; margin-top: 6px;
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: var(--r-1);
}
.kpi .delta.up { color: var(--st-published-tx); background: var(--st-published-bg); }
.kpi .delta.down { color: var(--st-failed-tx); background: var(--st-failed-bg); }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
/* segmented control — FIT: scroll instead of clip; segments size to content */
.seg { display: flex; border: 1px solid var(--line-2); border-radius: var(--r-2); overflow-x: auto; max-width: 100%; }
.seg::-webkit-scrollbar { height: 0; }
.seg button {
  font-family: var(--font-body); font-size: var(--fs-12); font-weight: 600; letter-spacing: .02em;
  padding: 6px var(--sp-3); background: var(--surface); border: none; cursor: pointer;
  color: var(--ink-2); border-right: 1px solid var(--line); white-space: nowrap; flex: 0 0 auto;
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--solid); color: var(--solid-ink); }
/* inactive segments must respond to pointer-over — the transition rule below
   already lists `.seg button`, so the hover state was assumed but never declared */
.seg button:not(.on):hover { background: var(--surface-2); color: var(--ink); }
.seg--equal button { flex: 1; }

.cal { border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; background: var(--card); }
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-dow div { padding: var(--sp-2) var(--sp-3); font-family: var(--font-mono); font-size: var(--fs-11); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); border-right: 1px solid var(--line); }
.cal-dow div:last-child { border-right: none; }
/* FIT: min-height (not fixed) so stacked events grow the cell instead of clipping */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(132px, auto); }
.cal-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: var(--sp-2); position: relative; overflow: hidden; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.dim { background: var(--lifted); }
.cal-cell .dnum { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); }
.cal-cell.today .dnum { background: var(--accent-on); color: #fff; padding: 1px 6px; border-radius: 20px; }
.cal-cell:hover .add, .cal-cell:focus-within .add { opacity: 1; }
.cal-cell .add { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .12s; width: 24px; height: 24px; border-radius: var(--r-1); border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; font-size: 13px; }

.ev { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 5px 7px; border-radius: var(--r-1); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; transition: transform .08s, box-shadow .12s; min-width: 0; }
.ev:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.ev .bar { width: 3px; align-self: stretch; border-radius: 3px; flex: none; }
.ev .t { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); flex: none; }
.ev .txt { font-size: var(--fs-12); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ev.s-scheduled .bar { background: var(--st-scheduled); } .ev.s-approval .bar { background: var(--st-approval); }
.ev.s-published .bar { background: var(--st-published); } .ev.s-draft .bar { background: var(--st-draft); }
.ev.s-failed .bar { background: var(--st-failed); }

/* ---------- composer ---------- */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 392px; gap: 0; min-height: calc(100vh - 56px); }
.compose-left { padding: var(--sp-5) var(--sp-6); border-right: 1px solid var(--line); min-width: 0; }
.compose-right { padding: var(--sp-5); background: var(--surface-2); min-width: 0; }

.netbar { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); flex-wrap: wrap; }
/* net-toggle — FIT: flat radius, nowrap, inner label can ellipsize, ✕/check pinned */
.net-toggle {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-2);
  padding: 6px var(--sp-3) 6px var(--sp-2); cursor: pointer; font-weight: 600; font-size: var(--fs-13);
  color: var(--ink-2); white-space: nowrap; max-width: 220px; min-width: 0;
}
.net-toggle:hover { border-color: var(--line-3); }
.net-toggle.on, .net-toggle[aria-pressed="true"] { border-color: var(--ink); background: var(--lifted); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.net-toggle .x { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); flex: none; }
.net-toggle .check { width: 14px; height: 14px; color: var(--ink-4); flex: none; }
.net-toggle.on .check, .net-toggle[aria-pressed="true"] .check { color: var(--st-published); }

/* tabs — FIT: scroll instead of wrap; active underline stays on baseline */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); overflow-x: auto; flex-wrap: nowrap; }
.tabs::-webkit-scrollbar { height: 0; }
.tabs button { background: none; border: none; cursor: pointer; padding: 10px var(--sp-3); font-family: var(--font-body); font-weight: 600; font-size: var(--fs-13); color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; align-items: center; gap: var(--sp-2); white-space: nowrap; flex: none; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.editor { border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); }
.editor:focus-within { border-color: var(--line-3); box-shadow: 0 0 0 3px var(--viz-soft); }
.editor textarea { width: 100%; border: none; background: none; resize: vertical; padding: var(--sp-4); font-family: var(--font-body); font-size: var(--fs-14); line-height: var(--lh-body); color: var(--ink); outline: none; min-height: 150px; }
/* wrap: the .count child is flex:none + white-space:nowrap, so on phones it
   cannot shrink and pushed the page into horizontal overflow — let it drop to
   its own line instead. */
.editor .foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--line); }
.editor .foot .tool { color: var(--ink-3); cursor: pointer; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-1); flex: none; }
.editor .foot .tool svg { width: 17px; height: 17px; stroke-width: 1.8; }
.editor .foot .tool:hover { color: var(--ink); background: var(--lifted); }
/* FIT: counter pinned single-line; left tools shrink, counter never wraps */
.editor .foot .count { margin-left: auto; flex: none; white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-3); }
.editor .foot .count b { color: var(--ink); }
.editor .foot .count.warn b { color: var(--st-failed); }

.ai-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }
.ai-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px dashed var(--accent); color: var(--accent-d); background: var(--accent-soft); border-radius: var(--r-2); padding: 6px var(--sp-3); font-size: var(--fs-12); font-weight: 600; cursor: pointer; white-space: nowrap; }
.ai-pill svg { width: 14px; height: 14px; flex: none; }

.field { margin-top: var(--sp-5); }
.field > label, .field-label {
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: var(--sp-2);
}
.radioset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.radio { display: flex; align-items: flex-start; gap: var(--sp-3); border: 1px solid var(--line-2); border-radius: var(--r-2); padding: 11px var(--sp-3); cursor: pointer; background: var(--surface); min-width: 0; }
.radio.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.radio .r { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--line-2); margin-top: 2px; flex: none; }
.radio.on .r { border-color: var(--accent); background: radial-gradient(circle at center, var(--accent) 0 4px, transparent 5px); }
.radio b { font-size: var(--fs-13); } .radio span { display: block; font-size: var(--fs-11); color: var(--ink-3); font-family: var(--font-mono); margin-top: 2px; }

/* phone preview (mimics the real social apps; kept light) */
.preview-head { font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--sp-4); display: flex; align-items: center; gap: var(--sp-2); }
.phone { width: 300px; margin: 0 auto; background: #fff; border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow-2); overflow: hidden; }
.phone .pf-top { display: flex; align-items: center; gap: var(--sp-2); padding: 11px var(--sp-3); border-bottom: 1px solid #EEF0F3; }
.phone .pf-top .pav { width: 30px; height: 30px; border-radius: 50%; flex: none; background: linear-gradient(135deg, var(--viz-blue), var(--viz-teal)); }
.phone .pf-top .pn { font-size: var(--fs-12); font-weight: 700; color: #111; line-height: 1.2; } .phone .pf-top .pn span { display: block; font-size: 10px; color: #999; font-weight: 500; font-family: var(--font-mono); }
.phone .pf-img { aspect-ratio: 1/1; background: linear-gradient(135deg, #C9A37A, #8A5A33 70%); display: grid; place-items: center; color: rgba(255,255,255,.92); font-family: var(--font-body); font-style: normal; font-weight: 700; font-size: var(--fs-16); letter-spacing: .04em; }
.phone .pf-actions { display: flex; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) 4px; color: #222; }
.phone .pf-actions svg { width: 21px; height: 21px; stroke-width: 1.8; }
.phone .pf-cap { padding: 2px var(--sp-3) var(--sp-3); font-size: var(--fs-12); line-height: var(--lh-body); color: #222; }
.phone .pf-cap b { font-weight: 700; }
.phone .pf-cap .tags, .phone .pf-cap .more { color: #385898; }
.phone .pf-cap .more { color: #999; }

/* fb variant */
.phone.fb .pf-img { aspect-ratio: 1.91/1; }
.phone.fb .pf-cap { order: -1; }

/* ---------- list / table rows (approvals, accounts) ---------- */
.rows { border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; background: var(--card); }
.row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--row-py) var(--sp-4); border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--lifted); }
.row .thumb { width: 46px; height: 46px; border-radius: var(--r-2); flex: none; background: linear-gradient(135deg, var(--viz-indigo), var(--viz-teal)); }
.row .grow { flex: 1; min-width: 0; }
.row .grow .h { font-weight: 600; font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* FIT: prose meta (review quotes to 130ch) clamps to 2 lines, predictable row height */
.row .grow .m { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); margin-top: 3px; display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row .acts { display: flex; gap: var(--sp-2); flex: none; }

/* dashboard "up next" list reuses .row inside .upnext */
.upnext { display: flex; flex-direction: column; }
.upnext .row { gap: var(--sp-3); }
.upnext .when { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); text-align: center; flex: none; width: 52px; line-height: var(--lh-snug); }
.upnext .when b { display: block; font-size: var(--fs-13); color: var(--ink); font-weight: 600; }
.upnext .body { min-width: 0; flex: 1; }
.upnext .body p { font-size: var(--fs-13); color: var(--ink); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upnext .body .tline { display: flex; align-items: center; gap: var(--sp-2); }

/* approval flow dots */
.flow { display: flex; align-items: center; gap: 0; }
.flow .step { display: flex; align-items: center; gap: 7px; }
.flow .node { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-11); border: 1.5px solid var(--line-2); color: var(--ink-3); background: var(--surface); }
.flow .node.done { background: var(--st-published-solid); border-color: var(--st-published-solid); color: #fff; }
.flow .node.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.flow .link { width: 26px; height: 1.5px; background: var(--line-2); }
.flow .link.done { background: var(--st-published); }

/* health bar */
.health { display: flex; align-items: center; gap: 9px; }
.health .track { width: 120px; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.health .fill { height: 100%; border-radius: 6px; }

/* ---------- right meta column on accounts ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); align-items: start; }
.two-col > * { min-width: 0; }
.side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--sp-5); }
.side-card h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-20); letter-spacing: -.01em; margin-bottom: var(--sp-1); line-height: var(--lh-snug); }
.side-card p { font-size: var(--fs-12); color: var(--ink-2); line-height: var(--lh-body); }

/* ---------- misc ---------- */
.note { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); }
/* long unbroken code tokens (CSV headers, keys, URLs) must not blow out the
   layout on phones — allow them to break anywhere */
code { overflow-wrap: anywhere; }
/* notice container — promotes .note's siblings into a real readable box */
.notice {
  font-family: var(--font-body); font-size: var(--fs-13); line-height: var(--lh-body); color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-4); max-width: 72ch;
}
.notice.info  { box-shadow: inset 3px 0 0 var(--viz-blue); }
.notice.warn  { background: var(--st-approval-bg); box-shadow: inset 3px 0 0 var(--st-approval); }
.notice.danger{ background: var(--st-failed-bg);   box-shadow: inset 3px 0 0 var(--st-failed); }
.divider { height: 1px; background: var(--line); margin: var(--sp-5) 0; }
hr.acc { border: none; height: 2px; width: 40px; background: var(--accent); margin: var(--sp-4) 0; }

/* staggered entrance */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { opacity: 0; animation: rise .5s cubic-bezier(.2,.7,.3,1) forwards; }
.d1{animation-delay:.04s}.d2{animation-delay:.09s}.d3{animation-delay:.14s}.d4{animation-delay:.19s}
.d5{animation-delay:.24s}.d6{animation-delay:.29s}.d7{animation-delay:.34s}.d8{animation-delay:.39s}

/* index / cover */
.cover { min-height: 100vh; display: flex; flex-direction: column; }
.cover-top { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-7); border-bottom: 1px solid var(--line); }
.cover-hero { flex: 1; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: var(--sp-7); align-items: center; padding: 0 var(--sp-7); max-width: 1240px; margin: 0 auto; width: 100%; }
.cover-hero h1 { font-family: var(--font-body); font-weight: 700; font-size: 56px; line-height: 1.02; letter-spacing: -.03em; }
.cover-hero h1 em { font-style: normal; color: var(--accent); }
.cover-hero p { font-size: var(--fs-16); color: var(--ink-2); margin-top: var(--sp-5); max-width: 46ch; line-height: var(--lh-body); }
.screen-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); padding: var(--sp-6) var(--sp-7) var(--sp-7); max-width: 1240px; margin: 0 auto; width: 100%; }
.screen-card { display: block; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--card); overflow: hidden; transition: transform .12s, box-shadow .15s; }
.screen-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.screen-card .cap { display: flex; align-items: baseline; justify-content: space-between; padding: var(--sp-4); border-top: 1px solid var(--line); }
.screen-card .cap b { font-family: var(--font-body); font-size: var(--fs-20); font-weight: 700; }
.screen-card .cap .n { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); letter-spacing: .08em; }
.thumb-wrap { aspect-ratio: 16/10; background: var(--surface-2); position: relative; overflow: hidden; }

@media (max-width: 1080px) { .composer { grid-template-columns: minmax(0, 1fr); } .compose-right { border-top: 1px solid var(--line); } .two-col { grid-template-columns: minmax(0, 1fr); } .cover-hero { grid-template-columns: minmax(0, 1fr); } .cover-hero h1 { font-size: 42px; } }

/* taller nav (expanded IA) — keep footer pinned, scroll nav if needed */
.rail nav { overflow-y: auto; min-height: 0; flex-shrink: 1; }
.rail nav::-webkit-scrollbar { width: 0; }

/* ===========================================================================
   Empty / first-run states (grotesk, no serif/italic)
   =========================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: var(--sp-8) var(--sp-6); border: 1px dashed var(--line-2); border-radius: var(--r-3); background: var(--card); }
.empty .ico { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent); margin-bottom: var(--sp-4); }
.empty .ico svg { width: 27px; height: 27px; stroke-width: 1.5; }
.empty h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-26); letter-spacing: -.01em; line-height: var(--lh-snug); }
.empty h3 em { font-style: normal; color: var(--accent); }
.empty p { font-size: var(--fs-14); color: var(--ink-2); max-width: 44ch; margin-top: 9px; line-height: var(--lh-body); }
.empty .actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); flex-wrap: wrap; justify-content: center; }
.empty .hint { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); margin-top: var(--sp-4); }

/* ===========================================================================
   Responsive — tablet then phone (rail collapses to a bottom tab bar)
   =========================================================================== */
@media (max-width: 1000px) {
  /* minmax(0,1fr), NOT a bare 1fr: `1fr` is `minmax(auto,1fr)`, so the track is
     floored by its content's min-content width (fixed-width sub-navs, pipelines,
     wide toolbars) and grows past the viewport — the single biggest source of
     horizontal page overflow on phones/tablets. The companion min-width:0 lets
     the grid items themselves shrink instead of re-inflating the track. */
  .two-col, .composer, .an-grid, .wiz-grid, .cd-body, .listen-grid, .settings,
  .tg-grid, .build, .post-grid, .cases, .inbox, .queue, .fields, .mini, .wf-grid, .case {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .two-col > *, .composer > *, .an-grid > *, .wiz-grid > *, .cd-body > *, .listen-grid > *,
  .settings > *, .tg-grid > *, .build > *, .post-grid > *, .cases > *, .inbox > *,
  .queue > *, .fields > *, .mini > *, .wf-grid > *, .case > * {
    min-width: 0;
  }
  .cases, .inbox, .cd-body, .composer { height: auto !important; min-height: 0 !important; }
  .compose-right { border-left: none; border-top: 1px solid var(--line); }
  .compose-left { border-right: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* KPI values are nowrap for numbers, but some tiles hold text ("Expired
     tokens") that then overflows the tile on phones — let those wrap. */
  .kpi .val { white-space: normal; overflow-wrap: anywhere; }
}

/* drop the acct-pill / profile-pill label to avatar-only below ~900px */
@media (max-width: 900px) {
  .profile-pill span { display: none; }
}

/* tablet band (621–1000px): collapse the rail to an icon-only sidebar.
   Labels stay in the a11y tree (font-size:0, not display:none) + native title
   tooltips via socio-ui.js so the icon rail stays learnable. */
@media (min-width: 621px) and (max-width: 1000px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .rail { padding: 18px 8px; }
  .brand { display: none; }
  .rail .nav-label { display: none; }
  .rail a.item { justify-content: center; gap: 0; padding: 11px 0; font-size: 0; position: relative; }
  .rail a.item svg { width: 20px; height: 20px; }
  .rail a.item.active::before { left: 0; }
  /* numeric count pill -> small corner dot */
  .rail a.item .count {
    position: absolute; top: 6px; right: 11px; margin: 0; padding: 0;
    min-width: 6px; width: 6px; height: 6px; font-size: 0; border-radius: 50%; background: var(--accent);
  }
  .rail a.item.active .count { background: #fff; }
  .rail .me { justify-content: center; padding: 10px 0; }
  .rail .me .who { display: none; }
}

@media (max-width: 620px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  /* rail -> fixed bottom tab bar (icon + tiny label, horizontal scroll) */
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: auto;
    flex-direction: row; align-items: stretch; padding: 4px 6px; gap: 0;
    border-right: none; border-top: 1px solid var(--rail-line); overflow-x: auto; z-index: 60; }
  .rail .brand, .rail .nav-label, .rail .spacer, .rail .me { display: none; }
  .rail nav { flex-direction: row; gap: 2px; margin: 0; overflow-x: auto; }
  .rail nav::-webkit-scrollbar { height: 0; }
  .rail a.item { flex-direction: column; align-items: center; gap: 3px; padding: 7px 11px;
    font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 76px; border-radius: var(--r-3); }
  .rail a.item svg { width: 19px; height: 19px; }
  .rail a.item.active::before { display: none; }
  .rail a.item .count { display: none; }
  .main { padding-bottom: 66px; }

  .topbar { height: 54px; padding: 0 16px; gap: 10px; }
  .topbar .crumb { font-size: var(--fs-12); }
  .profile-pill span { display: none; }
  .profile-pill { padding: 5px; }

  .content { padding: var(--sp-4); }
  .content.flush { padding: 0; }
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
  .page-head h1 { font-size: var(--fs-26); }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* KPI values are nowrap for numbers, but some tiles hold text ("Expired
     tokens") that then overflows the tile on phones — let those wrap. */
  .kpi .val { white-space: normal; overflow-wrap: anywhere; }

  /* calendar scrolls horizontally on phones */
  .cal { overflow-x: auto; }
  .cal-dow, .cal-grid { min-width: 680px; }

  .phone { width: 100%; max-width: 320px; }
  .empty { padding: var(--sp-7) var(--sp-5); }
  .axis, .lane { grid-template-columns: 90px minmax(0, 1fr); }
  .stepper { overflow-x: auto; }
}

/* ===========================================================================
   DENSITY HOOKS — [data-density="compact"] tightens rows for a future toggle
   =========================================================================== */
[data-density="compact"] {
  --sp-5: 16px; --sp-4: 12px; --row-py: 9px; --cell-py: 6px; --kpi-pad: 12px;
}
[data-density="compact"] .row { padding: var(--row-py) var(--sp-4); }
[data-density="compact"] table.grid td,
[data-density="compact"] .chart-table td,
[data-density="compact"] .chart-table th { padding: var(--cell-py) var(--sp-3); }
[data-density="compact"] .kpi { padding: var(--kpi-pad); }

/* ===========================================================================
   Polish — focus rings, smoother interactions, scrollbars
   =========================================================================== */
.btn, .icon-btn, .net-toggle, .seg button, .radio, .view, .chip, a.item, .tabs button { transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .08s; }
:where(a, button, .btn, .icon-btn, input, textarea, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-1); }
.rail :where(a, button, [tabindex]):focus-visible { outline-color: #6FA0F0; }
.btn.accent:focus-visible, .btn.primary:focus-visible, .bulkbar :focus-visible { outline-color: var(--ink); outline-offset: 2px; }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.main ::-webkit-scrollbar { width: 10px; height: 10px; }
.main ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
.main ::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ===========================================================================
   Overlays & modals
   =========================================================================== */
.overlay { position: fixed; inset: 0; background: rgba(17,22,29,.46); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--sp-6); z-index: 100; animation: fade .18s ease both; }
.overlay.right { place-items: stretch; justify-content: end; padding: 0; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3);
  box-shadow: var(--shadow-3); width: 100%; max-width: 460px; padding: var(--sp-6);
  animation: pop .22s cubic-bezier(.2,.7,.3,1) both; }
.modal.wide { max-width: 600px; }
.modal .m-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent); margin-bottom: var(--sp-4); }
.modal.danger .m-ico { background: var(--st-failed-bg); color: var(--st-failed); }
.modal .m-ico svg { width: 23px; height: 23px; stroke-width: 1.8; }
.modal h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-20); letter-spacing: -.01em; line-height: var(--lh-snug); }
.modal > p { font-size: var(--fs-14); color: var(--ink-2); line-height: var(--lh-body); margin-top: var(--sp-2); }
.modal .m-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* drawer (right slide-in) */
.drawer { width: 400px; max-width: 92vw; height: 100vh; background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px -30px rgba(17,22,29,.5); display: flex; flex-direction: column; animation: slidein .22s ease both; }
.drawer .d-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.drawer .d-head h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-20); }
.drawer .d-body { flex: 1; overflow-y: auto; }

/* ===========================================================================
   Skeleton / loading shimmer
   =========================================================================== */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-1); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: shimmer 1.5s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel.line { height: 10px; } .skel.line.lg { height: 26px; } .skel.block { height: 100%; }

/* ===========================================================================
   Toast — FIT: bounded width, wraps, top-aligned icon
   =========================================================================== */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: var(--sp-2); z-index: 120; }
.toast { display: flex; align-items: flex-start; gap: var(--sp-3); background: var(--solid); color: var(--solid-ink);
  border-radius: var(--r-2); padding: var(--sp-3) 15px; box-shadow: var(--shadow-3);
  min-width: 280px; max-width: min(420px, calc(100vw - 2 * var(--sp-5))); animation: pop .22s ease both; }
.toast .t-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; margin-top: 1px; }
.toast.ok .t-ico { background: var(--st-published); } .toast.err .t-ico { background: var(--st-failed); }
.toast .t-msg { font-size: var(--fs-13); line-height: var(--lh-snug); white-space: normal; } .toast .t-msg b { font-weight: 600; }

/* ===========================================================================
   Command palette (Cmd+K)
   =========================================================================== */
.cmdk { width: 580px; max-width: 94vw; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-3);
  box-shadow: var(--shadow-3); overflow: hidden; animation: pop .2s ease both; align-self: start; margin-top: 12vh; }
.cmdk .cmd-in { display: flex; align-items: center; gap: 11px; padding: var(--sp-4); border-bottom: 1px solid var(--line); }
.cmdk .cmd-in svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.cmdk .cmd-in input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-family: var(--font-body); font-size: var(--fs-16); color: var(--ink); }
.cmdk .cmd-in:focus-within { border-color: var(--line-3); box-shadow: inset 0 0 0 2px var(--viz-soft); }
.cmdk .cmd-in kbd { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: var(--r-1); padding: 2px 6px; flex: none; }
.cmdk .cmd-grp { font-family: var(--font-mono); font-size: var(--fs-11); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding: var(--sp-3) var(--sp-4) 5px; }
/* FIT: label flexes & ellipsizes; icon + .k meta pinned */
.cmdk .cmd-row { display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-4); cursor: pointer; }
.cmdk .cmd-row svg { width: 16px; height: 16px; color: var(--ink-2); flex: none; }
.cmdk .cmd-row > span:not(.k) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk .cmd-row.on, .cmdk .cmd-row:hover { background: var(--accent-on); color: #fff; }
.cmdk .cmd-row.on svg, .cmdk .cmd-row:hover svg { color: #fff; }
.cmdk .cmd-row .k { margin-left: auto; flex: none; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }
.cmdk .cmd-row.on .k, .cmdk .cmd-row:hover .k { color: rgba(255,255,255,.85); }

/* ===========================================================================
   Dark theme — cool slate inversion of Direction B
   Applied via <html data-theme="dark">; socio-theme.js auto-detects OS pref and
   renders the floating toggle. The .phone IG/FB previews keep their light
   treatment on purpose — they mimic the real social apps.
   =========================================================================== */
html[data-theme="dark"] {
  --paper:#0E1217; --paper-2:#161B22; --canvas:#0E1217; --lifted:#161B22;
  --card:#151A21; --surface:#151A21; --surface-2:#1B212A;
  --ink:#E7ECF2; --ink-2:#B7C0CC; --ink-3:#8B95A3; --ink-4:#5F6B79;
  --line:#262D37; --line-2:#323A45; --line-3:#414B57;

  --accent:#F2583B; --accent-d:#E2492B; --accent-soft:#34201A; --accent-on:#C53A1F;

  --viz-blue:#5A86DE; --viz-gray:#7E8B9F; --viz-soft:#1C2738; --viz-teal:#2E9CA8; --viz-indigo:#6E97E6;

  --st-draft:#8B95A3; --st-scheduled:#3FA0AD; --st-approval:#D8A33D;
  --st-published:#5EAB6F; --st-failed:#E55E44;
  --st-draft-bg:#222A33;     --st-draft-tx:#AEB7C2;
  --st-scheduled-bg:#163039; --st-scheduled-tx:#7FCAD4;
  --st-approval-bg:#332714;  --st-approval-tx:#E2B45B;
  --st-published-bg:#16301F; --st-published-tx:#79C78D;
  --st-failed-bg:#371A14;    --st-failed-tx:#F0866F;
  --st-approval-text:var(--st-approval-tx); --st-draft-text:var(--st-draft-tx);

  --sent-pos:#79C78D; --sent-pos-bg:#16301F;
  --sent-neu:#8B95A3; --sent-neu-bg:#222A33;
  --sent-neg:#F0866F; --sent-neg-bg:#371A14;

  --rail:#0A0E13; --rail-2:#151B22; --rail-line:#222A33; --rail-ink:#C5CCD6; --rail-ink-2:#7E8997;
  --solid:#E7ECF2; --solid-ink:#0E1217;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px -6px rgba(0,0,0,.6);
  --shadow-3: 0 1px 2px rgba(0,0,0,.5), 0 12px 36px -16px rgba(0,0,0,.7);
  --shadow: var(--shadow-2);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px #6E97E6;
}
html[data-theme="dark"] body { background: var(--paper); }
html[data-theme="dark"] .toast .t-msg, html[data-theme="dark"] .toast { color: var(--solid-ink); }
html[data-theme="dark"] .phone { box-shadow: 0 14px 36px -18px rgba(0,0,0,.85); }
/* dark: solid buttons read on the dark canvas; keep skeleton sweep cool */
html[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }

/* floating theme toggle (injected by socio-theme.js) */
#socio-theme-toggle {
  position: fixed; right: 18px; bottom: 18px; z-index: 90; /* below .overlay (100) so modals cover it */
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-2);
  transition: color .15s, border-color .15s, transform .08s;
}
#socio-theme-toggle:hover { color: var(--accent); border-color: var(--line-3); }
#socio-theme-toggle:active { transform: translateY(1px); }
#socio-theme-toggle svg { width: 19px; height: 19px; stroke-width: 1.7; fill: none; stroke: currentColor; }
@media (max-width: 620px) { #socio-theme-toggle { bottom: 74px; right: 12px; width: 38px; height: 38px; } }
#socio-theme-toggle[data-in-bar] { position: static; right: auto; bottom: auto; box-shadow: none; width: var(--ctl); height: var(--ctl); border-radius: var(--r-2); }

/* ===========================================================================
   Accessibility — screen-reader utility + reduced-motion guard
   =========================================================================== */
.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;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0ms !important; /* kill staggered .rise delays → no blank-flash */
    transition-duration: .001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important;
  }
}

/* ===========================================================================
   Shared interaction components (consistency engine)
   Canonical switch · list bulk-select · attention row · keyboard cheat-sheet.
   =========================================================================== */
.switch { width: 42px; height: 24px; border-radius: 30px; background: var(--surface-2); border: 1px solid var(--line-2); position: relative; flex: none; cursor: pointer; transition: background .18s, border-color .18s; display: inline-block; vertical-align: middle; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s; }
.switch.on, .switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch.on::after, .switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch.sm { width: 34px; height: 20px; } .switch.sm::after { width: 14px; height: 14px; } .switch.sm.on::after, .switch.sm[aria-checked="true"]::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* list bulk-select (generic) */
.ck { position: relative; width: 16px; height: 16px; border: 1.5px solid var(--line-2); border-radius: var(--r-1); cursor: pointer; display: grid; place-items: center; opacity: 0; transition: opacity .12s; flex: none; }
.ck::before { content: ""; position: absolute; inset: -4px; }
.rows:hover .ck, [data-listnav]:hover .ck, .rows:focus-within .ck, [data-listnav]:focus-within .ck, [data-listnav].has-sel .ck, .row.checked .ck, [role="option"].checked .ck, .row.sel .ck, [role="option"].sel .ck { opacity: 1; }
.ck.on { background: var(--accent); border-color: var(--accent); }
.ck svg { width: 11px; height: 11px; color: #fff; opacity: 0; stroke-width: 3; }
.ck.on svg { opacity: 1; }
.row.checked, [role="option"].checked { background: var(--viz-soft); }

/* native checkbox (Direction-B dense data grid) */
.ckbox {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border: 1.5px solid var(--line-3);
  border-radius: var(--r-1); background: var(--surface); cursor: pointer;
  display: inline-grid; place-items: center; flex: none; vertical-align: middle;
  position: relative; transition: background .1s, border-color .1s;
}
.ckbox:hover { border-color: var(--ink-3); }
.ckbox:checked { background: var(--accent-on); border-color: var(--accent-on); }
.ckbox:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: none; border-right: none; transform: rotate(-45deg) translateY(-1px); }
.ckbox:indeterminate { background: var(--accent-on); border-color: var(--accent-on); }
.ckbox:indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border: none; transform: none; }

.bulkbar { display: none; align-items: center; gap: var(--sp-2); padding: 9px var(--sp-4); background: var(--accent-on); color: #fff; flex: none; }
[data-listnav].has-sel ~ .bulkbar, .has-sel > .bulkbar, .bulkbar.show { display: flex; }
.bulkbar .cnt { font-weight: 700; font-size: var(--fs-13); }
.bulkbar .bb-act { border: 1px solid rgba(255,255,255,.42); color: #fff; background: transparent; padding: 5px 10px; border-radius: var(--r-2); font-size: var(--fs-12); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bulkbar .bb-act svg { width: 13px; height: 13px; stroke-width: 2; }
.bulkbar .bb-act:hover { background: rgba(255,255,255,.16); }
.bulkbar .bb-x { margin-left: auto; cursor: pointer; display: grid; place-items: center; width: 28px; height: 28px; }
.bulkbar .bb-x svg { width: 16px; height: 16px; }

/* selectable / attention rows + keyboard focus (generic) */
[data-listnav] [role="option"], [data-listnav] .row { cursor: pointer; }
.row.sel, [role="option"][aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
[data-listnav]:focus-visible, [data-listnav] [role="option"]:focus-visible, .row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.attn { box-shadow: inset 3px 0 0 var(--st-failed); }
.attn.warn { box-shadow: inset 3px 0 0 var(--st-approval); }

/* keyboard cheat-sheet (shared overlay body) */
.kbd-help { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2) var(--sp-5); }
.kbd-help .kr { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-13); color: var(--ink-2); }
.kbd-help .kr kbd { font-family: var(--font-mono); font-size: var(--fs-11); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 7px; color: var(--ink); }
.kbd-hint { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 30px; padding: 3px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.kbd-hint:hover { border-color: var(--line-3); color: var(--ink); }

/* row hover quick-actions (generic) */
[data-listnav] .row, [data-listnav] [role="option"] { position: relative; }
.qa { position: absolute; right: 12px; top: 10px; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); padding: 3px; box-shadow: var(--shadow-2); z-index: 2; }
@media (hover: none) { .ck, .qa, .cal-cell .add { opacity: 1; } }
.row:hover .qa, [role="option"]:hover .qa, .row:focus-within .qa, [role="option"]:focus-within .qa, .row.sel .qa, [role="option"].sel .qa { opacity: 1; }
.qa button { width: 26px; height: 26px; border: none; background: none; border-radius: 5px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
.qa button:hover { background: var(--surface-2); color: var(--ink); }
.qa svg { width: 15px; height: 15px; stroke-width: 1.8; }

/* chart "view as table" affordance — toggle pins right of any chart header */
.ct-toggle { margin-left: auto; align-self: center; flex: none; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font: inherit; font-family: var(--font-body); font-size: var(--fs-12); font-weight: 600; padding: 4px 9px; border-radius: var(--r-2); cursor: pointer; white-space: nowrap; }
.ct-toggle:hover { color: var(--ink); border-color: var(--line-3); }
.ct-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ct-toggle--float { position: absolute; top: 14px; right: 16px; margin: 0; z-index: 2; }

/* ===========================================================================
   Data tables — legacy .chart-table retrofit + Direction-B dense .grid engine.
   FIT: every real table lives in an overflow-x:auto wrapper with a min-width.
   =========================================================================== */
/* generic scroller wrapper helper (use on legacy tables that lack one) */
.table-scroll, .grid-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }

.chart-table { width: 100%; min-width: 560px; border-collapse: collapse; margin-top: var(--sp-4); font-size: var(--fs-12); }
.chart-table caption { text-align: left; }
.chart-table th, .chart-table td { padding: var(--cell-py) 10px; border-bottom: 1px solid var(--line); text-align: left; }
.chart-table thead th { color: var(--ink-3); font-weight: 600; font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.chart-table tbody th[scope="row"] { font-weight: 600; color: var(--ink); }
.chart-table td.num, .chart-table th.num { text-align: right; font-family: var(--font-mono); font-size: var(--fs-12); white-space: nowrap; }
.chart-table tbody tr:last-child th, .chart-table tbody tr:last-child td { border-bottom: 0; }

/* Direction-B dense SLDS grid */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 940px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left;
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3); padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-2); white-space: nowrap; user-select: none;
}
table.grid thead th.sortable { cursor: pointer; }
table.grid thead th.sortable:hover { color: var(--ink); background: var(--surface-2); }
html[data-theme="dark"] table.grid thead th.sortable:hover { background: var(--surface-3, #26303E); }
table.grid thead th .th-inner { display: inline-flex; align-items: center; gap: 5px; }
table.grid thead th .caret { display: inline-flex; flex-direction: column; line-height: 0; color: var(--ink-4); }
table.grid thead th .caret svg { width: 8px; height: 8px; display: block; }
table.grid thead th[aria-sort="ascending"] .caret .up,
table.grid thead th[aria-sort="descending"] .caret .down { color: var(--accent); }
table.grid td { padding: var(--cell-py); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); font-size: var(--fs-13); color: var(--ink-2); vertical-align: top; }
table.grid td:last-child, table.grid th:last-child { border-right: none; }
table.grid th:first-child, table.grid td:first-child { border-right: 1px solid var(--line); }
table.grid tbody tr:hover td { background: var(--lifted); }
table.grid tbody tr.selected td { background: var(--viz-soft); }
.grid-wrap.compact table.grid td { padding: 6px var(--sp-3); font-size: var(--fs-12); }
.grid-wrap.compact table.grid thead th { padding: 6px var(--sp-3); }
.grid-wrap.compact .ct-name .av { width: 24px; height: 24px; }
th.col-check, td.col-check { width: 40px; text-align: center; vertical-align: middle; }

/* grid cell internals */
.ct-name { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.ct-name .av { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: var(--fs-11); }
.ct-name b { color: var(--ink); font-weight: 600; font-size: var(--fs-13); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-handle { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 20ch; }
.ct-net { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--ink-2); }
.ct-active { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap; }

/* table toolbar + filter chips + density toggle + pager (Direction-B) */
.table-toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); background: var(--surface); }
.tb-search { display: flex; align-items: center; gap: var(--sp-2); border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--lifted); padding: 0 var(--sp-2); height: 32px; width: 240px; min-width: 0; }
.tb-search:focus-within { border-color: var(--line-3); box-shadow: 0 0 0 3px var(--viz-soft); }
.tb-search svg { width: 14px; height: 14px; stroke-width: 1.8; color: var(--ink-3); flex: none; }
.tb-search input { border: none; background: none; outline: none; width: 100%; min-width: 0; font-size: var(--fs-13); }
.tb-spacer { flex: 1; }
.tb-count { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); margin-right: var(--sp-2); white-space: nowrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); padding: 5px var(--sp-2); cursor: pointer; font-size: var(--fs-12); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.filter-chip:hover { border-color: var(--line-3); color: var(--ink); }
.filter-chip svg { width: 13px; height: 13px; stroke-width: 2; color: var(--ink-3); flex: none; }
.filter-chip .v { color: var(--ink); }
.filter-chip.dismiss { border-style: dashed; }
.density { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-2); overflow: hidden; background: var(--surface); }
.density button { border: none; background: var(--surface); cursor: pointer; font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); padding: 5px var(--sp-3); border-right: 1px solid var(--line-2); white-space: nowrap; }
.density button:last-child { border-right: none; }
.density button[aria-pressed="true"] { background: var(--solid); color: var(--solid-ink); }  /* --ink inverts in dark; --solid/--solid-ink is the theme-stable inverse pair */

/* search field in topbar (Direction-B) */
.search { margin-left: var(--sp-3); flex: 1; max-width: 420px; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--lifted); padding: 0 var(--sp-3); height: 34px; }
.search:focus-within { border-color: var(--line-3); box-shadow: 0 0 0 3px var(--viz-soft); }
.search svg { width: 15px; height: 15px; stroke-width: 1.8; color: var(--ink-3); flex: none; }
.search input { border: none; background: none; outline: none; width: 100%; min-width: 0; font-size: var(--fs-13); color: var(--ink); }
.search .kbd { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); border: 1px solid var(--line-3); border-radius: 3px; padding: 1px 5px; background: var(--surface); flex: none; }

/* breadcrumb internals (Direction-B markup) */
.crumb { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); color: var(--ink-3); min-width: 0; overflow: hidden; }
.crumb a:hover { color: var(--ink-2); }
.crumb .sep { color: var(--ink-4); flex: none; }
.crumb b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* topbar right cluster + account pill (Direction-B markup) */
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.acct-pill { display: flex; align-items: center; gap: var(--sp-2); border: 1px solid var(--line-2); border-radius: 20px; padding: 3px var(--sp-3) 3px 4px; background: var(--surface); cursor: pointer; flex: none; }
.acct-pill:hover { border-color: var(--line-3); }
.acct-pill .av { width: 26px; height: 26px; border-radius: 50%; flex: none; background: linear-gradient(135deg, var(--viz-blue), var(--viz-teal)); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 10px; }
.acct-pill b { font-size: var(--fs-12); font-weight: 600; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-pill .net-dots { display: flex; gap: 3px; margin-left: 2px; flex: none; }
.acct-pill .net-dots i { width: 7px; height: 7px; border-radius: 2px; }

/* dashboard chart + card head + legend (Direction-B markup) */
.dash-headrow { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: 1.6fr minmax(0, 1fr); gap: var(--sp-3); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: var(--fs-16); font-weight: 700; letter-spacing: -.01em; }
.card-head .meta { font-size: var(--fs-12); color: var(--ink-3); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.legend-inline { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-12); color: var(--ink-2); flex-wrap: wrap; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.kpi .foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.kpi .vs { font-size: var(--fs-11); color: var(--ink-3); }  /* --ink-4 is 2.6:1 — placeholder/disabled only */
.kpi .delta svg { width: 11px; height: 11px; stroke-width: 2.4; }

/* CSS bar chart — FIT: fluid bars (never exceed track), no absolute labels */
.chart-body { padding: var(--sp-4); }
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--sp-3); align-items: end; height: 200px; padding-bottom: var(--sp-4); position: relative; border-bottom: 1px solid var(--line-2); }
.chart .grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; position: relative; z-index: 1; min-width: 0; }
.chart .pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: clamp(8px, 60%, 16px); border-radius: 3px 3px 0 0; transition: opacity .12s; }
.chart .bar.ig { background: var(--viz-blue); }
.chart .bar.fb { background: var(--viz-gray); }
.chart .col:hover .bar { opacity: .82; }
.chart .xlab { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); position: absolute; bottom: -22px; white-space: nowrap; }
.chart-yaxis { display: flex; justify-content: space-between; margin-top: var(--sp-4); }
.chart-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2); font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); padding: var(--sp-3) var(--sp-4) 0; }

/* compose dirty hint + actions (Direction-B markup) */
.compose-actions { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); flex-wrap: wrap; }
.compose-actions .spacer { flex: 1; }
.dirty-hint { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--st-approval-tx); font-weight: 600; }
.dirty-hint .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--st-approval); box-shadow: 0 0 0 0 rgba(176,122,18,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(176,122,18,.5); } 70% { box-shadow: 0 0 0 6px rgba(176,122,18,0); } 100% { box-shadow: 0 0 0 0 rgba(176,122,18,0); } }

/* generic pager (Direction-B markup) */
.grid-foot { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); background: var(--surface); }
.grid-foot .range { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap; }
.grid-foot .range b { color: var(--ink); font-weight: 600; }
.grid-foot .pager { margin-left: auto; display: flex; align-items: center; gap: var(--sp-1); }
.pgbtn { width: 30px; height: 30px; border-radius: var(--r-1); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.pgbtn:hover:not(:disabled) { border-color: var(--line-3); color: var(--ink); background: var(--lifted); }
.pgbtn:disabled { opacity: .4; cursor: not-allowed; }
.pgbtn svg { width: 14px; height: 14px; stroke-width: 2; }
.pgnum { min-width: 30px; height: 30px; border-radius: var(--r-1); border: 1px solid transparent; background: none; cursor: pointer; font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-2); padding: 0 6px; }
.pgnum.on { background: var(--solid); color: var(--solid-ink); }  /* --ink inverts in dark; --solid/--solid-ink is the theme-stable inverse pair */
.pgnum:hover:not(.on) { background: var(--lifted); }

/* ===========================================================================
   Generic data-table engine: sortable headers + pager + select-all (legacy)
   =========================================================================== */
[data-sort-key] { cursor: pointer; background: none; border: none; font: inherit; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px; padding: 0; }
[data-sort-key]:hover { color: var(--ink); }
[data-sort-key] .th-arr { font-size: 9px; opacity: 0; transition: opacity .12s, transform .12s; color: var(--accent-d); }
[data-sort-key]:hover .th-arr { opacity: .5; }
[data-sort-key][data-sort="asc"], [data-sort-key][data-sort="desc"] { color: var(--ink); font-weight: 600; }
[data-sort-key][data-sort="asc"] .th-arr, [data-sort-key][data-sort="desc"] .th-arr { opacity: 1; }
[data-sort-key][data-sort="desc"] .th-arr { transform: rotate(180deg); }
th[aria-sort] { white-space: nowrap; }
.ck[data-select-all] { opacity: 1; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: 11px 2px 2px; margin-top: 10px; border-top: 1px solid var(--line); }
.dt-count { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); }
.dt-count b { color: var(--ink); font-weight: 600; }
.dt-pager { display: inline-flex; align-items: center; gap: var(--sp-2); }
.dt-pageno { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); }
.dt-pg { font-family: var(--font-body); font-size: var(--fs-12); font-weight: 600; color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: var(--r-1); padding: 5px 11px; cursor: pointer; }
.dt-pg:hover:not(:disabled) { border-color: var(--line-3); background: var(--surface); }
.dt-pg:disabled { opacity: .4; cursor: default; }

/* ===========================================================================
   Enterprise hardening — skip-link, account menu, identity/security surfaces
   =========================================================================== */
.skip-link { position: fixed; top: 10px; left: 10px; z-index: 9999; transform: translateY(-160%);
  background: var(--solid); color: var(--solid-ink); font-size: var(--fs-13); font-weight: 600;
  padding: 9px 15px; border-radius: var(--r-2); box-shadow: var(--shadow-2); text-decoration: none; transition: transform .16s; }
.skip-link:focus-visible { transform: translateY(0); outline: 2px solid var(--accent); outline-offset: 2px; }

/* account / sign-out menu on the .me rail pill */
.menu-host { position: relative; }
.me-menu { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 8px); z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-3); padding: 5px; }
.me-menu[hidden] { display: none; }
.me-menu [role="menuitem"] { display: block; width: 100%; text-align: left; background: none; border: none;
  font-family: var(--font-body); font-size: var(--fs-13); color: var(--ink); padding: 8px 10px; border-radius: 5px; cursor: pointer; text-decoration: none; }
.me-menu [role="menuitem"]:hover { background: var(--surface-2); }
.me-menu [role="menuitem"]:focus-visible { background: var(--surface-2); outline: 2px solid var(--accent); outline-offset: -2px; }
.me-menu .me-sep { height: 1px; background: var(--line); margin: 5px 2px; }
.me-menu .me-signout { color: var(--accent-d); font-weight: 600; }

/* identity / security surfaces (settings, 2FA setup) */
.mfa-badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 10px;
  font-weight: 600; letter-spacing: .02em; padding: 2px 8px; border-radius: 30px; border: 1px solid var(--line-2); color: var(--ink-2); }
.mfa-badge.on { color: var(--st-published); border-color: color-mix(in srgb, var(--st-published) 40%, var(--line-2)); background: color-mix(in srgb, var(--st-published) 9%, transparent); }
.mfa-badge.off { color: var(--st-failed); border-color: color-mix(in srgb, var(--st-failed) 40%, var(--line-2)); background: color-mix(in srgb, var(--st-failed) 8%, transparent); }
.mfa-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.sess-list { display: flex; flex-direction: column; gap: 0; }
.sess { display: flex; align-items: center; gap: var(--sp-4); padding: 13px 2px; border-top: 1px solid var(--line); }
.sess:first-child { border-top: none; }
.sess .s-ico { width: var(--ctl); height: var(--ctl); flex: none; border-radius: var(--r-3); display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.sess .s-ico svg { width: 18px; height: 18px; stroke-width: 1.7; }
.sess .s-meta { flex: 1; min-width: 0; }
.sess .s-meta b { font-size: var(--fs-13); font-weight: 600; }
.sess .s-meta .s-sub { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--ink-3); margin-top: 2px; }
.sess .s-here { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--st-published);
  border: 1px solid color-mix(in srgb, var(--st-published) 40%, var(--line-2)); border-radius: 30px; padding: 2px 8px; flex: none; }

.sso-card { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--card); }
.sso-card .s-ico { width: 38px; height: 38px; flex: none; border-radius: var(--r-3); display: grid; place-items: center; background: var(--surface-2); color: var(--ink); font-weight: 700; }
.sso-card .s-body { flex: 1; min-width: 0; }
.sso-card .s-body b { font-size: var(--fs-14); }
.sso-card .s-body p { font-size: var(--fs-12); color: var(--ink-2); margin-top: 2px; line-height: var(--lh-body); }

.backup-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: var(--sp-4) 0;
  padding: var(--sp-4); background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r-3); }
.backup-codes code { font-family: var(--font-mono); font-size: var(--fs-14); letter-spacing: .04em; color: var(--ink); }

.danger-zone { border: 1px solid color-mix(in srgb, var(--st-failed) 45%, var(--line)); border-radius: var(--r-3); overflow: hidden; }
.danger-zone > .dz-head { background: var(--st-failed-bg); padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid color-mix(in srgb, var(--st-failed) 30%, var(--line)); }
.danger-zone > .dz-head b { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-16); color: var(--st-failed); }
.danger-zone .dz-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border-top: 1px solid var(--line); }
.danger-zone .dz-row:first-of-type { border-top: none; }
.danger-zone .dz-row .dz-txt { flex: 1; min-width: 0; }
.danger-zone .dz-row .dz-txt b { font-size: var(--fs-13); }
.danger-zone .dz-row .dz-txt p { font-size: var(--fs-12); color: var(--ink-2); margin-top: 2px; line-height: var(--lh-body); }
