/* Kyo Campaign Monitor: "Navy & Kyo blue" (Justin 2026-11-12, from his reference picture; replaced A "Bright & airy").
   Dark navy side menu, light grey page, plain white cards with small corners and a faint shadow, light type in the
   system font (San Francisco / Segoe UI / Roboto: nothing to download, CSP unchanged). Accent: Kyo blue from the logo;
   orange is the second chart series (palette checked for colour blindness, light and dark). Light by default. */

:root {
  color-scheme: light;
  --bg: #F2F4F8; --surface: #FFFFFF; --surface-2: #F6F7FA; --border: #E6E9EF; --border-strong: #D3D8E1;
  --card-border: transparent;
  --text: #27303F; --text-2: #4F5869; --muted: #848D9E;
  --accent: #226897; --accent-hover: #1B577F; --accent-ink: #FFFFFF; --accent-text: #226897; --accent-soft: #E7F0F7;
  --accent-2: #E8704A;               /* orange: second chart series (fills only) */
  --good: #15803D; --warning: #B45309; --critical: #C62828;
  --good-bg: #E3F6E9; --warning-bg: #FDF2DC; --critical-bg: #FDE7E7;
  --side: #222B3C; --side-line: #2E384B; --side-text: #B8C0CE; --side-hover: #2A3447; --side-muted: #6F7A8E;
  --side-strong: #FFFFFF; --side-active: #2C3A50; --side-mark: #5AA9DD;
  --input: #FFFFFF;
  --shadow: 0 1px 3px rgba(20, 28, 45, .06), 0 1px 2px rgba(20, 28, 45, .04);
  --radius: 6px; --radius-sm: 4px;
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151B26; --surface: #1E2635; --surface-2: #253042; --border: #2C3647; --border-strong: #3A4559;
  --card-border: #2C3647;
  --text: #E6EAF0; --text-2: #B3BCCB; --muted: #8893A5;
  --accent: #3A8FC7; --accent-hover: #5AA9DD; --accent-ink: #FFFFFF; --accent-text: #6DB3E4; --accent-soft: #1D3347;
  --accent-2: #DB6640;               /* a deeper orange: the light-mode one is too light on the dark surface */
  --good: #4ADE80; --warning: #FBBF24; --critical: #FF8A8A;
  --good-bg: #13291D; --warning-bg: #2A2312; --critical-bg: #2A1719;
  --side: #10151E; --side-line: #222A38; --side-text: #A9B2C1; --side-hover: #1A2130; --side-muted: #667085;
  --side-strong: #FFFFFF; --side-active: #1E2A3C; --side-mark: #5AA9DD;
  --input: #151B26;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }   /* honeypot */
.muted { color: var(--muted); } .small { font-size: 12px; }
.err { color: var(--critical); min-height: 1.2em; margin: 0; font-weight: 500; }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 400; margin: 0; line-height: 1.15; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 8px 14px;
  border-radius: var(--radius-sm); cursor: pointer; font: 600 13px var(--body); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: var(--radius-sm);
  width: 36px; height: 36px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* shell: dark side menu + main column */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 0 0 228px; background: var(--side); border-right: 1px solid var(--side-line); padding: 24px 14px 16px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; color: var(--side-strong); }
.side-brand:hover { text-decoration: none; }
.side-brand img { height: 20px; width: auto; display: block; filter: brightness(0) invert(1); }   /* white mark on navy */
.side-brand span { font: 600 15px var(--display); }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { padding: 20px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); }
#nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--side-text); font-weight: 400; font-size: 14px; }
#nav a svg { flex: none; }
#nav a:hover { background: var(--side-hover); color: var(--side-strong); text-decoration: none; }
#nav a.active { background: var(--side-active); color: var(--side-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--side-mark); }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--side-line); display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.avatar { grid-row: span 2; width: 32px; height: 32px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 700 13px var(--display); }
.side-foot .who { color: var(--side-strong); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .role { color: var(--side-muted); font-size: 12px; }
.side-foot .foot-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.side-foot .ver { color: var(--side-muted); font-size: 11px; }
.side-btn { background: transparent; color: var(--side-text); border-color: var(--side-line); }
.side-btn:hover { background: var(--side-hover); color: var(--side-strong); }

.main-col { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 30px 36px 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.view { padding: 22px 36px 40px; display: grid; gap: 16px; align-content: start; }
.view > * { min-width: 0; }      /* a section is never wider than the page (wide tables then fit, see fitTables) */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px 22px; min-width: 0; box-shadow: var(--shadow); }
.hero { background: var(--surface); color: var(--text-2); border: 1px solid var(--card-border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 20px 24px; display: grid; gap: 6px; box-shadow: var(--shadow); }
.hero .label { font-weight: 400; font-size: 14px; color: var(--text-2); }
.hero .big { font: 500 44px/1.05 var(--display); letter-spacing: -.01em; color: var(--text); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 30px; display: grid; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand img { height: 22px; width: auto; }
.login-brand span { font: 600 16px var(--display); }
.login-card h1 { font-size: 30px; margin-top: 10px; }
.login-card .lede { color: var(--muted); margin: -6px 0 6px; }
.login-card label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.login-card input { font: 15px var(--body); padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.login-card .btn.primary { padding: 12px; font-size: 15px; margin-top: 4px; }
.login-card .alt { margin: 0; text-align: center; }
.login-card .hint { margin: -4px 0 0; color: var(--muted); font-size: 12.5px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent-text); font: 600 13px var(--body); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.ok { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--good-bg); color: var(--good); font-weight: 500; }

.login-card.wide { width: min(460px, 100%); }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.qr-box { display: grid; place-items: center; }
.qr { width: 200px; height: 200px; border-radius: var(--radius-sm); background: #fff; padding: 6px; image-rendering: pixelated; }
code, .secret { font-family: var(--mono); font-size: 13px; }
.secret { display: inline-block; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.codes span { font: 600 15px var(--mono); padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border); text-align: center; user-select: all; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.stack { display: grid; gap: 12px; justify-items: start; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-pill.on { background: var(--good-bg); color: var(--good); }
.status-pill.off { background: var(--warning-bg); color: var(--warning); }
.card h2 .status-pill { margin-left: 8px; vertical-align: 2px; }

/* tables */
.table-wrap { overflow-x: auto; margin: 4px -4px 0; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table tr.user-row td { border-bottom: 0; padding-bottom: 6px; }
.table tr.act-row td { padding-top: 0; padding-bottom: 14px; }
/* Every column stays visible. When a table is wider than its card, fitTables() (app.js) adds .stack to its wrapper
   and each row becomes a compact card: the row's name (its one unlabelled cell) across the top, every labelled value in
   a grid below. It is measured again on every resize, so the table is back as soon as it fits. Nothing scrolls. */
.table-wrap.stack { overflow: visible; margin: 4px 0 0; }
.table-wrap.stack thead { display: none; }
.table-wrap.stack table, .table-wrap.stack tbody { display: block; width: 100%; min-width: 0; }
.table-wrap.stack tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 26px;
  padding: 12px 6px; border-bottom: 1px solid var(--border); }
.table-wrap.stack tr:last-child { border-bottom: 0; }
.table-wrap.stack td, .table-wrap.stack th { display: block; padding: 0; border: 0; text-align: left; min-width: 0;
  max-width: none; white-space: normal; background: none; }
.table-wrap.stack td[data-label] { flex: 0 1 auto; max-width: 100%; }
.table-wrap.stack td:not([data-label]), .table-wrap.stack th, .table-wrap.stack td.wide { flex: 1 1 100%; }
.table-wrap.stack td.wide { order: 1; }          /* long text last, after the short values */
.table-wrap.stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.table-wrap.stack td:empty { display: none; }
.table-wrap.stack tbody th { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); }
.table-wrap.stack tr.user-row { border-bottom: 0; padding-bottom: 4px; }
.table-wrap.stack tr.act-row { padding-top: 0; }
.table-wrap.stack .bar-cell { width: auto; }
/* a value shown in the row's title when the row is a card (e.g. status), and as its own column in the table */
.card-only { display: none; }
.table-wrap.stack .card-only { display: inline; }
.table-wrap.stack .table-only { display: none; }

/* Data health */
.seg { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; justify-self: start; box-shadow: var(--shadow); }
.seg-btn { border: 0; background: transparent; color: var(--text-2); font: 500 13px var(--body); padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer; }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 4px; box-shadow: var(--shadow); align-content: start; }
.kpi .k { font-size: 14px; font-weight: 400; color: var(--text-2); }
.kpi .v { font: 500 24px/1.2 var(--display); letter-spacing: 0; margin-top: 2px; }
.src-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 8px 0 6px; }
.src-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: grid; gap: 4px; background: var(--surface-2); }
.src-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h3.sub { font-size: 13px; font-weight: 600; margin: 16px 0 6px; font-family: var(--body); letter-spacing: 0; }
.badge.bad { background: var(--critical-bg); color: var(--critical); border-color: transparent; }
.badge.cpl-excellent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge.cpl-good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.cpl-watch { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge.cpl-weak { background: var(--critical-bg); color: var(--critical); border-color: transparent; }
.warn-text { color: var(--warning); } .bad-text { color: var(--critical); }
.num { text-align: right; white-space: nowrap; }
.bar-cell { width: 34%; min-width: 120px; vertical-align: middle; }
.bar { width: 100%; height: 8px; display: block; }
.bar-bg { fill: var(--surface-2); } .bar-fg { fill: var(--accent-2); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.plain-list li:last-child { border-bottom: 0; }

/* Overview */
.kpis .delta { font-size: 12px; font-weight: 500; }
.kpi-head { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin: 18px 0 8px; }
.good-text { color: var(--good); }
.funnel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.f-step { display: grid; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-width: 92px; }
.f-val { font: 500 22px/1.1 var(--display); letter-spacing: 0; }
.f-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.f-rate { font-size: 12px; font-weight: 600; color: var(--accent-text); white-space: nowrap; }
.chart-box { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--body); }
.chart .bar-spend { fill: var(--accent-2); }
.chart .bar-leads { fill: var(--accent); }
.chart path.on { opacity: .75; stroke: var(--text); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; z-index: 2; pointer-events: none; display: grid; gap: 2px; padding: 8px 10px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); white-space: nowrap; }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: 13px; }
.ad-list { list-style: none; margin: 0; padding: 0; }
.ad-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ad-list li:last-child { border-bottom: 0; }
.ad-nums { display: grid; justify-items: end; gap: 4px; text-align: right; }
.ad-nums .badge { white-space: nowrap; }
/* Campaigns: tree table */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.camp-table td { vertical-align: middle; }
.camp-table th .sort-btn { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.camp-table th .sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.camp-table th[aria-sort="ascending"], .camp-table th[aria-sort="descending"] { color: var(--text); }
.camp-table .name-cell { min-width: 220px; max-width: 320px; }
.tree { display: flex; align-items: flex-start; gap: 8px; }
.tree-btn { flex: none; width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; font-size: 12px; line-height: 1; }
.tree-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tree-pad { flex: none; width: 24px; }
.camp-table tr.lvl-1 td { background: var(--surface); }
.camp-table tr.lvl-2 .tree { padding-left: 22px; }
.camp-table tr.lvl-3 .tree { padding-left: 44px; }
.camp-table tr.lvl-3 strong { font-weight: 600; }
.camp-table tr.lvl-2 td, .camp-table tr.lvl-3 td { background: var(--surface-2); }
.spark { width: 92px; height: 24px; display: block; }
.spark rect { fill: var(--accent); }
.spark-base { stroke: var(--border-strong); stroke-width: 1; }
.camp-table th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.camp-table th .sort-btn { display: inline-block; }
/* as cards: the whole row is indented by level and shaded like the table rows */
.table-wrap.stack .camp-table tr.lvl-2 { padding-left: 28px; background: var(--surface-2); }
.table-wrap.stack .camp-table tr.lvl-3 { padding-left: 52px; background: var(--surface-2); }
.table-wrap.stack .camp-table tr .tree { padding-left: 0; }
.table-wrap.stack .camp-table tr.lvl-2, .table-wrap.stack .camp-table tr.lvl-3 { border-bottom-color: var(--surface); }
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.confirm { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; margin: 6px 0 12px; }
.confirm p { margin: 0 0 4px; font-weight: 600; }

/* forms inside pages */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; margin-top: 6px; }
.form-grid label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.form-grid input, .form-grid select { font: 14px var(--body); padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--input); color: var(--text); }
.form-grid .btn.primary { padding: 10px 14px; }
.card .ok, .card .err { margin-top: 12px; }
/* Creatives (Phase 5) */
.cr-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.field-inline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.field-inline select { font: 14px var(--body); padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); }
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 12px; }
.cr-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0; }
.cr-pic { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--surface-2); }
.cr-nopic { display: grid; place-items: center; }
.cr-text { padding: 14px 16px 0; display: grid; gap: 6px; min-width: 0; }
.cr-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cr-rank { font: 600 13px var(--display); color: var(--accent-text); }
.cr-head { margin: 4px 0 0; font-weight: 600; }
.cr-body { margin: 0; font-size: 13px; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cr-body.open { display: block; }
.cr-more { justify-self: start; font-size: 12px; }
.cr-link { overflow-wrap: anywhere; }
.cr-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 12px 16px 0; padding: 10px 0 0; border-top: 1px solid var(--border); }
.cr-nums div { display: grid; gap: 2px; min-width: 0; }
.cr-nums dt { font-size: 11px; color: var(--muted); font-weight: 600; }
.cr-nums dd { margin: 0; font-weight: 500; font-size: 14px; }
.cr-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 14px; margin-top: auto; flex-wrap: wrap; }
.cr-foot .check { padding: 0; }
.cr-compare th[scope="col"] { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); vertical-align: top; min-width: 170px; white-space: normal; }
.cr-compare th[scope="row"] { color: var(--muted); }
.cr-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); display: block; margin-bottom: 6px; background: var(--surface-2); }
div.cr-thumb { display: grid; place-items: center; font-size: 10px; text-align: center; }
/* compare: a table when it fits, else one card per ad (fitTables sets .stack on the table's wrapper) */
.cmp-cards { display: none; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 8px; }
.cmp-wrap.stack { display: none; }
.cmp-wrap.stack + .cmp-cards { display: grid; }
.cmp-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; }
.cmp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; min-width: 0; }
.cmp-head .cr-thumb { width: 56px; height: 56px; margin: 0; flex: none; }
.cmp-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0; }
.cmp-card dt { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cmp-card dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.cmp-card .cmp-wide { grid-column: 1 / -1; }
/* Email (Phase 5b) */
.em-table th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.em-table th .sort-btn { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; display: inline-block; }
.em-table th .sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.em-table th[aria-sort="ascending"], .em-table th[aria-sort="descending"] { color: var(--text); }
.em-table .name-cell { min-width: 200px; max-width: 320px; }
.em-table td { vertical-align: middle; }
.note { margin: 0; }

/* Winners & losers (Phase 6a) */
.wl-controls { align-items: center; gap: 12px; }
.count-pill { display: inline-block; min-width: 22px; padding: 1px 8px; margin-left: 6px; border-radius: 999px; font-size: 12px;
  font-weight: 600; text-align: center; background: var(--surface-2); color: var(--text-2); vertical-align: 2px; }
.count-pill.good { background: var(--good-bg); color: var(--good); }
.count-pill.bad { background: var(--critical-bg); color: var(--critical); }
.wl-table .name-cell { min-width: 200px; max-width: 300px; }
.wl-table td { vertical-align: middle; }
.wl-table td.why { min-width: 220px; color: var(--text-2); }
.rules { margin: 6px 0 10px; padding: 0; list-style: none; display: grid; gap: 8px; }
.rules li { line-height: 1.7; }
.rules li .badge { margin-right: 8px; min-width: 52px; text-align: center; }

/* Slack (Phase 6b) */
.slack-tools { margin-top: 14px; }
.slack-preview { margin: 10px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 480px; overflow: auto; }
.err-inline { color: var(--critical); font-size: 13px; }
#setSlack .check { align-items: flex-start; margin: 6px 0; }
.alert-rules { display: grid; gap: 4px; }
.alert-rule { padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-rule:last-child { border-bottom: 0; }
.alert-rule .form-grid { margin: 6px 0 0 26px; grid-template-columns: repeat(auto-fill, minmax(200px, 280px)); }
.alert-rule p { margin: 4px 0 0 26px; }

/* Settings (Phase 4c) */
#setCards { display: grid; gap: 16px; }
.form-grid input:disabled { opacity: .5; cursor: not-allowed; }
.conn-list { list-style: none; margin: 8px 0 0; padding: 0; }
.conn-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.conn-list li:last-child { border-bottom: 0; }
.conn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn-detail { margin-top: 4px; overflow-wrap: anywhere; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.form-actions .btn.primary { padding: 10px 18px; }
fieldset.pick { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 14px 0 0; min-width: 0; }
fieldset.pick legend { font-weight: 600; font-size: 13px; color: var(--text-2); padding: 0 6px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 5px 0; cursor: pointer; min-width: 0; }
.check span { min-width: 0; overflow-wrap: anywhere; }
.check input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent-text); }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 18px; max-height: 280px;
  overflow: auto; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.check-list.off { opacity: .6; }
.check-list.off .check { cursor: default; }
.pipe-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.3fr); gap: 8px 18px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.pipe-row .field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.pipe-row select { font: 14px var(--body); padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); }
.pipe-stages { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
@media (max-width: 760px) { .pipe-row, .pipe-stages { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  /* narrow: the side menu becomes one compact bar that scrolls sideways, so the page starts on screen one */
  .shell { align-content: flex-start; }        /* short pages: no stretched gap under the menu bar */
  .side { position: static; height: auto; flex: 1 1 100%; padding: 12px 12px 10px; gap: 8px; }
  .side-brand { padding: 0 4px 4px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  #nav a { white-space: nowrap; padding: 8px 10px; }
  .nav-group { display: none; }
  .side-foot { margin-top: 0; padding: 8px 4px 0; grid-template-columns: auto 1fr auto; }
  .side-foot .avatar { grid-row: auto; width: 26px; height: 26px; font-size: 11px; }
  .side-foot .role { display: none; }
  .side-foot .foot-row { grid-column: auto; margin-top: 0; gap: 8px; }
  .top, .view { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 28px; }
}
