
/* Outtel dashboard: one token set for light + dark (docs/brand.md "Colour system"). Signal Amber marks actions and
   "live" only; amber text on light uses --accent-ink; amber is never a chart colour. */

:root {
    --brand: #FFB224;
    --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-ar: 'Readex Pro', 'Segoe UI', Tahoma, sans-serif;
    --mono: 'DM Mono', ui-monospace, Menlo, monospace;
    --radius: 10px;
    --radius-sm: 7px;
    --sidebar-w: 232px;
    --sidebar-w-collapsed: 64px;
    --topbar-h: 60px;

    /* light theme */
    --bg: #F6F6F4;
    --surface: #FFFFFF;
    --surface-2: #F0F0ED;
    --surface-3: #E7E7E3;
    --border: #E3E3DF;
    --border-strong: #C9C9C3;
    --input-border: #8A8D93;
    --text: #16171A;
    --text-2: #3F4147;
    --text-3: #62656C;           /* >= 4.5:1 on --surface and --bg */
    --accent: var(--brand);
    --accent-ink: #8F5600;       /* links / accent text on light */
    --accent-bg: #FFF4DE;
    --accent-border: #F3D08A;
    --btn-primary: #FFB224;
    --btn-primary-hover: #F5A20F;
    --on-primary: #111111;
    --focus: #B87400;
    --ok: #146C43; --ok-bg: #E3F4EA; --ok-border: #A9DCBF;
    --warn: #B54708; --warn-bg: #FFF0E5; --warn-border: #F5C29E;
    --bad: #B3261E; --bad-bg: #FDECEB; --bad-border: #F3B6B1;
    --info: #0B5C8A; --info-bg: #E5F2FB; --info-border: #A8D2EF;
    --violet: #8E5BE0;
    --neutral-bg: #EEEEEB;
    --shadow: 0 1px 2px rgba(22, 23, 26, .06), 0 1px 3px rgba(22, 23, 26, .08);
    --shadow-lg: 0 12px 32px rgba(22, 23, 26, .18);
    --overlay: rgba(15, 16, 18, .45);
    --media-bg: #ECECE8;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0F1012;
    --surface: #17181B;
    --surface-2: #1E1F23;
    --surface-3: #26282C;
    --border: #2A2C31;
    --border-strong: #3A3D43;
    --input-border: #6A6E76;
    --text: #EDEDEB;
    --text-2: #C4C6CB;
    --text-3: #9A9DA5;
    --accent-ink: #FFC65C;
    --accent-bg: rgba(255, 178, 36, .14);
    --accent-border: rgba(255, 178, 36, .38);
    --btn-primary: #FFB224;
    --btn-primary-hover: #FFC14D;
    --on-primary: #111111;
    --focus: #FFB224;
    --ok: #6FD69E; --ok-bg: rgba(46, 160, 99, .14); --ok-border: rgba(111, 214, 158, .35);
    --warn: #FFA36B; --warn-bg: rgba(255, 163, 107, .14); --warn-border: rgba(255, 163, 107, .35);
    --bad: #FF8F8F; --bad-bg: rgba(220, 70, 60, .15); --bad-border: rgba(255, 143, 143, .35);
    --info: #86C9F2; --info-bg: rgba(50, 140, 210, .15); --info-border: rgba(134, 201, 242, .35);
    --violet: #9B6EE9;
    --neutral-bg: #222428;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    --overlay: rgba(0, 0, 0, .6);
    --media-bg: #0B0B0D;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
[lang="ar"] body, body:lang(ar) { font-family: var(--font-ar); }
/* Arabic is a joined script: never letter-space it, never use a Latin monospace font on it */
[lang="ar"] * { letter-spacing: 0 !important; }
bdi[dir="ltr"] { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }

img { max-width: 100%; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
details > summary { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100;
    background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.skip-link:focus { top: 8px; }

/* ---------- typography helpers ---------- */
.h1 { font-size: 22px; font-weight: 600; line-height: 1.25; }
.h2 { font-size: 19px; font-weight: 600; }
.h3 { font-size: 16px; font-weight: 600; }
.h4 { font-size: 14px; font-weight: 600; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 600; }
.block { display: block; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.minw0 { min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }
.upper { text-transform: uppercase; }
.num { font-variant-numeric: tabular-nums; }
.text-body p + p { margin-top: 8px; }
.lbl { display: block; font-size: 12px; font-weight: 500; color: var(--text-3); }
.tone-ok-text { color: var(--ok); }
.tone-warn-text { color: var(--warn); }
.tone-bad-text { color: var(--bad); }
.tone-info-text { color: var(--info); }
.tone-violet-text { color: var(--violet); }

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 14px; }
.row.gap-sm { gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-wrap.center { justify-content: center; }
.row-wrap.end { justify-content: flex-end; }
.row-wrap.align-end { align-items: flex-end; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-between.wrap { flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 10px; }
.stack-xs > * + * { margin-top: 6px; }
.stack-xxs { display: flex; flex-direction: column; gap: 2px; }
.stack-xxs.end { align-items: flex-end; text-align: end; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.grid-2.tight { gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.view > * + * { margin-top: 18px; }
.tab-body > * + * { margin-top: 16px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
    background: var(--surface); border-inline-end: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 12px 10px; gap: 8px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
/* the symbol stays when the sidebar collapses; the wordmark sits in .brand-text (hidden when collapsed). -l = for light
   grounds, -d = for dark grounds (static/brand). */
.brand-mark { flex: 0 0 28px; width: 28px; height: 28px; display: none; place-items: center; }   /* only when the sidebar is collapsed */
.brand-mark img { display: block; width: 28px; height: 28px; }
.brand-logo { display: block; height: 22px; width: auto; }
.logo-d, :root[data-theme="dark"] .logo-l { display: none !important; }
:root[data-theme="dark"] .logo-d { display: block !important; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; padding-top: 2px; }
.brand-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500; font-size: 14px; min-height: 38px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-bg); color: var(--accent-ink); }
.nav-link .ic { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.collapse-btn { align-self: flex-end; }
body.sidebar-collapsed .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 8px; position: relative; }
body.sidebar-collapsed .nav-badge { position: absolute; top: 2px; inset-inline-end: 2px; padding: 0 5px; line-height: 16px; font-size: 10px; }
body.sidebar-collapsed .brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .brand-mark { display: grid; }
body.sidebar-collapsed .collapse-btn { align-self: center; }
[dir="rtl"] .collapse-btn svg { transform: scaleX(-1); }
.sidebar-backdrop { display: none; }

.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; min-height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.icon-btn.menu-btn { display: none; }
.client-switch {
    display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 4px 0 10px; min-height: 38px; max-width: 220px; color: var(--text-3);
}
[dir="rtl"] .client-switch { padding: 0 10px 0 4px; }
.client-switch select { border: 0; background: transparent; min-height: 36px; padding: 0 4px; color: var(--text); max-width: 180px; cursor: pointer; }
.client-switch select:focus-visible { outline: none; }
.client-switch:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.top-search { flex: 1 1 260px; max-width: 460px; min-width: 0; }
.search-field {
    position: relative; display: flex; align-items: center; gap: 8px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 10px; min-height: 38px; color: var(--text-3);
}
.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-field input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); min-height: 36px; }
.search-field .ic { width: 16px; height: 16px; flex: 0 0 16px; }
.kbd { font-family: inherit; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; white-space: nowrap; }
.sched {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--text-2); background: var(--surface); white-space: nowrap;
}
.sched .ic { width: 14px; height: 14px; }
.sched.tone-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.sched.tone-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.scan-btn.busy .ic { animation: spin 1.2s linear infinite; }

main { flex: 1 1 auto; padding: 22px 24px 64px; max-width: 1440px; width: 100%; margin: 0 auto; }
main:focus { outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.page-head .muted { margin-top: 2px; }
.crumbs { color: var(--text-3); }

/* ---------- controls ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn .ic { width: 16px; height: 16px; flex: 0 0 16px; }
.btn.sm .ic { width: 15px; height: 15px; }
.btn-primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0605; }
.btn-danger:hover { filter: brightness(.95); background: var(--bad); }
.btn-danger-ghost { color: var(--bad); border-color: var(--bad-border); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.icon-btn {
    display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ic { width: 15px; height: 15px; }
.icon-btn.save.on { color: var(--warn); }
.icon-btn.save.on svg { fill: currentColor; }
.icon-btn.save span { font-size: 13px; }
.btn.save, .icon-btn.save:has(span) { width: auto; padding: 0 10px; gap: 6px; display: inline-flex; border-color: var(--border-strong); height: 32px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; font: inherit; }
.linklike:hover { text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; min-width: 38px; min-height: 36px; padding: 0 10px; cursor: pointer; color: var(--text-2); font-weight: 600; }
.seg button + button { border-inline-start: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-ink); }
.seg button .ic { width: 16px; height: 16px; }
.lang-seg button[lang="ar"] { font-family: var(--font-ar); font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-sm { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; }
.hint { font-size: 12px; color: var(--text-3); }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input:not([type]), select, textarea {
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    min-height: 38px; padding: 6px 10px; color: var(--text); width: 100%; min-width: 0;
}
.field-sm input, .field-sm select { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.inline-field select { width: auto; }
textarea { resize: vertical; }
input[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
.search-field input[type="search"] { border: 0; padding: 0; min-height: 36px; background: transparent; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; min-height: 28px; }
.check input { width: 16px; height: 16px; accent-color: var(--btn-primary); flex: 0 0 auto; }
.checklist { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.indent { padding-inline-start: 24px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; flex: 0 0 auto; transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: inset-inline-start .15s, background .15s; }
.switch input:checked + .switch-ui { background: var(--btn-primary); border-color: var(--btn-primary); }
.switch input:checked + .switch-ui::after { inset-inline-start: 18px; background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.notice {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: 13px;
}
.notice > .ic { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; }
.notice.tone-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--text); }
.notice.tone-ok > .ic { color: var(--ok); }
.notice.tone-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--text); }
.notice.tone-warn > .ic { color: var(--warn); }
.notice.tone-bad { background: var(--bad-bg); border-color: var(--bad-border); color: var(--text); }
.notice.tone-bad > .ic { color: var(--bad); }
.notice.tone-info { background: var(--info-bg); border-color: var(--info-border); color: var(--text); }
.notice.tone-info > .ic { color: var(--info); }
.notice.tone-neutral { background: var(--surface-2); }
.banner { align-items: center; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 18px 4px; font-size: 13px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent-ink); animation: spin .8s linear infinite; flex: 0 0 auto; display: inline-block; }
.spinner.sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .scan-btn.busy .ic { animation-duration: 3s; } }
.empty { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty p { max-width: 520px; }

.badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1.2;
    padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--neutral-bg); color: var(--text-2); white-space: nowrap;
}
.badge .ic { width: 13px; height: 13px; }
.tone-ok.badge, .chip.tone-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.tone-warn.badge, .chip.tone-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.tone-bad.badge, .chip.tone-bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.tone-info.badge, .chip.tone-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip {
    display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; max-width: 100%;
}
a.chip:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.chip .ic { width: 13px; height: 13px; }
.count-pill { display: inline-block; font-size: 12px; font-weight: 600; min-width: 20px; text-align: center; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); line-height: 20px; }
.ev-link { font-size: 13px; font-weight: 500; color: var(--accent-ink); }
.ic { width: 16px; height: 16px; flex: 0 0 auto; }
svg.ic, .ic svg { stroke-width: 2; }

/* key-point type chips (text + tinted background, AA in both themes) */
.chip.kp-scaling, .chip.kp-longevity { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.kp-new_offer { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.kp-launch_burst, .chip.kp-seasonal { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip.kp-stopped { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.chip.kp-audience { color: var(--accent-ink); background: color-mix(in oklab, var(--accent-ink) 10%, transparent); border-color: color-mix(in oklab, var(--accent-ink) 30%, transparent); }
.chip.kp-market_expansion { color: var(--violet); background: color-mix(in oklab, var(--violet) 12%, transparent); border-color: color-mix(in oklab, var(--violet) 35%, transparent); }

/* ---------- KPIs / insights ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.compact .kpi-value { font-size: 17px; }
.kpi-value.na { color: var(--text-3); }
.kpi-sub { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.kpi-sub.na { font-style: italic; }
.kp-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.kp { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.kp > .chip { flex: 0 0 auto; margin-top: 1px; }
.kp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.kp-text { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.kp.compact .kp-text { font-size: 13.5px; }
.kp-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.kp-comp { font-weight: 600; color: var(--text); }
.change-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.deltas { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.spark-card { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.spark-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.spark { color: var(--accent-ink); display: block; max-width: 100%; }
.spark-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* competitor insights: change strip, headline KPIs, collapsible KPI groups */
.chg-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr)); gap: 8px; }
.chg-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.chg-n { font-size: 22px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.chg-l { font-size: 12px; font-weight: 500; color: var(--text-2); }
.chg-stat.zero .chg-n { color: var(--text-3); font-weight: 500; }
.chg-stat .ev-link { font-size: 12px; margin-top: 2px; }
.kpi-grid.headline { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.kpi-grid.headline .kpi { background: var(--surface); padding: 14px 16px; gap: 4px; }
.kpi-grid.headline .kpi-label { font-size: 13px; color: var(--text-2); }
.kpi-grid.headline .kpi-value { font-size: 28px; line-height: 1.15; }
.inline-ic { width: 13px; height: 13px; vertical-align: -2px; }
.kpi-groups { border-top: 1px solid var(--border); }
.kpi-group { border-bottom: 1px solid var(--border); }
.kpi-group > summary, .disclosure-card > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi-group > summary::-webkit-details-marker, .disclosure-card > summary::-webkit-details-marker { display: none; }
.kpi-group > summary { padding: 12px 4px; border-radius: var(--radius-sm); }
.kpi-group > summary:hover { background: var(--surface-2); }
.kpi-group > .kpi-grid { padding: 2px 0 14px; }
.kpi-group-chev { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-3); transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
[dir="rtl"] .kpi-group-chev { transform: scaleX(-1); }
details[open] > summary > .kpi-group-chev { transform: rotate(90deg); }
.kpi-group-title { font-size: 14px; font-weight: 600; flex: 0 0 auto; }
.kpi-group-preview { font-size: 13px; color: var(--text-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-inline-start: auto; }
.kpi-group-preview strong { color: var(--text-2); font-weight: 600; }
.kpi-group-preview .sep { margin: 0 8px; }
.disclosure-card > summary { margin: -18px; padding: 18px; border-radius: var(--radius); }
.disclosure-card[open] > summary { margin-bottom: 0; padding-bottom: 12px; }
.disclosure-card > summary:hover .h3 { color: var(--accent-ink); }
@media (prefers-reduced-motion: reduce) { .kpi-group-chev { transition: none; } }
.bullets { padding-inline-start: 18px; display: flex; flex-direction: column; gap: 3px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 8px; margin: 0; }
.facts > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--text-3); }
.facts dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.facts.compact > div { padding: 6px 9px; }

/* ---------- overview ---------- */
.alert-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); border-inline-start-width: 4px; background: var(--surface); }
.alert-row.tone-bad { border-inline-start-color: var(--bad); }
.alert-row.tone-warn { border-inline-start-color: var(--warn); }
.alert-row.tone-neutral { border-inline-start-color: var(--border-strong); }
.alert-ic { color: var(--text-3); margin-top: 2px; }
.alert-row.tone-bad .alert-ic { color: var(--bad); }
.alert-row.tone-warn .alert-ic { color: var(--warn); }
.alert-row .badge { margin-inline-start: 6px; }
.alert-act { flex: 0 0 auto; }
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.comp-card { display: flex; flex-direction: column; gap: 12px; }
.avatar { position: relative; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; font-weight: 600; color: var(--text-2); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; flex-basis: 52px; font-size: 20px; }
.flags-inline { display: inline-flex; flex-wrap: wrap; gap: 2px; font-size: 16px; line-height: 1; align-items: center; }
.flags-inline .more, .flags .more { font-size: 12px; color: var(--text-3); margin-inline-start: 4px; }
.mini-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-kpi .lbl { font-size: 12px; }
.mini-kpi .val { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-kpi .val.na { color: var(--text-3); }
.mini-kpi .ev-link { font-size: 12px; }
.glance { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.rows { list-style: none; display: flex; flex-direction: column; }
.rows > li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.rows > li:last-child { border-bottom: 0; }
.rows.compact > li { padding: 5px 0; }
.onboarding .steps { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.step-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent-ink); font-weight: 700; flex: 0 0 28px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl thead th { font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--surface-2); white-space: nowrap; }
.tbl tbody tr:last-child td, .tbl tbody tr:last-child th { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 60%, transparent); }
.tbl td.num { font-variant-numeric: tabular-nums; }
.tbl td.actions { text-align: end; white-space: nowrap; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.th-sort .sort-ic { width: 13px; height: 13px; opacity: .7; }
.card > .table-wrap .tbl { font-size: 13.5px; }

/* ---------- competitor page ---------- */
.comp-head { align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent-ink); }
.tabs .ic { width: 16px; height: 16px; }
.danger-zone { border-color: var(--bad-border); }

/* ---------- ad library ---------- */
.filterbar {
    position: sticky; top: calc(var(--topbar-h) + 1px); z-index: 10; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 10px;
}
.fb-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fb-top .search-field { flex: 1 1 240px; }
.fb-toggle { display: none; }
.fb-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-items: end; }
.fb-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.fb-right { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.fchip { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--text); border-radius: 999px; padding: 1px 2px 1px 10px; max-width: 100%; }
[dir="rtl"] .fchip { padding: 1px 10px 1px 2px; }
.fchip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip button { width: 24px; height: 24px; border: 0; background: transparent; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.fchip button:hover { background: var(--surface-3); }
.fchip button .ic { width: 13px; height: 13px; }
.result-count { font-size: 13px; font-weight: 600; white-space: nowrap; }
.dd { position: relative; align-self: end; }
.select-like { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 34px; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }
.select-like::-webkit-details-marker { display: none; }
.dd-menu { position: absolute; top: calc(100% + 4px); inset-inline-start: 0; z-index: 15; min-width: 240px; max-width: min(320px, 90vw); max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; }
.dd-menu .check { padding: 4px 6px; border-radius: 5px; justify-content: flex-start; }
.dd-menu .check:hover { background: var(--surface-2); }
.dd-menu .check .muted { margin-inline-start: auto; }

.ad-results.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.ad-results.list { display: flex; flex-direction: column; gap: 8px; }
.load-more { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 0; }
/* Instagram tab */
.ig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.ig-post { padding: 10px; min-width: 0; }
.ig-thumb { display: block; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--media-bg); }
.ig-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-thumb.empty-media { display: grid; place-items: center; color: var(--text-3); }
.ig-stats { gap: 10px; color: var(--text-2); }
.ig-caption { color: var(--text-2); overflow-wrap: anywhere; }
.ad-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); cursor: pointer; min-width: 0; }
.ad-card:hover { border-color: var(--border-strong); }
.ad-card:focus-within { border-color: var(--focus); }
.ad-media { position: relative; aspect-ratio: 4 / 3; background: var(--media-bg); overflow: hidden; display: grid; place-items: center; }
.ad-media > img, .ad-media > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ad-media > video { z-index: 1; background: #000; }
.ad-media > video.frame { z-index: 0; background: transparent; opacity: 0; transition: opacity .2s; pointer-events: none; }
.ad-media > video.frame.ready { opacity: 1; }
.ad-media.empty-media { color: var(--text-3); gap: 4px; font-size: 12px; align-content: center; justify-items: center; }
.video-ph { color: var(--text-3); }
.video-ph .ic { width: 28px; height: 28px; }
.ad-media .play { position: absolute; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .62); color: #fff; cursor: pointer; }
.ad-media .play .ic { width: 20px; height: 20px; margin-inline-start: 2px; }
.ad-media.playing .play { opacity: 0; pointer-events: none; }
.ad-media.playing .play:focus-visible { opacity: 1; }
.media-type, .media-count { position: absolute; z-index: 2; bottom: 8px; font-size: 11px; font-weight: 600; background: rgba(0, 0, 0, .7); color: #fff; padding: 2px 7px; border-radius: 5px; }
.media-type { inset-inline-end: 8px; }
.media-count { inset-inline-start: 8px; }
.media-broken { display: none; position: absolute; inset: 0; z-index: 3; background: var(--media-bg); color: var(--text-3); font-size: 12px; text-align: center; padding: 12px; align-content: center; justify-items: center; gap: 4px; }
.ad-media.broken .media-broken { display: grid; }
.ad-media.broken .play, .ad-media.broken .media-type { display: none; }
.ad-media.video-gone .play { display: none; }
.ad-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ad-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ad-adv { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1 1 auto; }
.ad-head .icon-btn { width: 32px; height: 32px; margin-inline-end: -6px; }
.ad-title { all: unset; cursor: pointer; font-size: 13.5px; line-height: 1.45; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ad-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ad-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.flags { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.flag { display: inline-flex; align-items: center; gap: 3px; font-size: 14px; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }
.flag .code { font-size: 11px; font-weight: 600; color: var(--text-2); }
.ad-chips { display: flex; flex-wrap: wrap; gap: 4px; }
/* list layout */
.ad-results.list .ad-card { flex-direction: row; }
.ad-results.list .ad-media { flex: 0 0 132px; aspect-ratio: auto; min-height: 104px; }
.ad-results.list .ad-body { flex: 1 1 auto; }
.ad-results.list .ad-title { -webkit-line-clamp: 1; }

/* ---------- layers (modal / drawer) ---------- */
body.has-layer { overflow: hidden; }
.layer { position: fixed; inset: 0; z-index: 60; display: flex; }
.layer-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.layer-panel { position: relative; background: var(--surface); color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); outline: none; max-height: 100%; }
.layer-modal { align-items: center; justify-content: center; padding: 16px; }
.layer-modal .layer-panel { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); border-radius: var(--radius); border: 1px solid var(--border); }
.layer-modal .layer-panel.wide { max-width: 760px; }
.layer-drawer { justify-content: flex-end; }
.layer-drawer .layer-panel { width: min(100%, 520px); height: 100%; border-inline-start: 1px solid var(--border); }
.layer-drawer .layer-panel.wide { width: min(100%, 640px); }
.layer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.layer-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.layer-body { padding: 16px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.layer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.dsec { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.dsec.dashed { border-style: dashed; }
.subsec { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; display: flex; flex-direction: column; gap: 4px; }
.d-media-list { display: flex; flex-direction: column; gap: 8px; }
.d-media { background: var(--media-bg); border-radius: var(--radius-sm); overflow: hidden; display: grid; place-items: center; }
.d-media img, .d-media video { width: 100%; max-height: 380px; object-fit: contain; display: block; }
.d-media.empty-media { min-height: 120px; color: var(--text-3); gap: 4px; font-size: 13px; }
.flag-lg { font-size: 18px; }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 84px; align-items: center; gap: 8px; font-size: 12.5px; }
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--info); border-radius: 999px; }
.bar-val { text-align: end; font-variant-numeric: tabular-nums; }

.toasts { position: fixed; z-index: 80; bottom: 16px; inset-inline-end: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-inline-start-width: 4px; border-radius: var(--radius-sm); padding: 10px 8px 10px 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; }
.toast-msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast.tone-ok { border-inline-start-color: var(--ok); }
.toast.tone-warn { border-inline-start-color: var(--warn); }
.toast.tone-bad { border-inline-start-color: var(--bad); }
.toast.tone-info { border-inline-start-color: var(--info); }

/* ---------- scan modal ---------- */
.scan-status { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.scan-status .ic { width: 15px; height: 15px; vertical-align: -2px; }
.picker { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.picker-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex-wrap: wrap; }
.pick:has(input:checked) { border-color: var(--accent-ink); background: var(--accent-bg); }
.pick input { width: 16px; height: 16px; accent-color: var(--btn-primary); }
.pick-logo { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); flex: 0 0 28px; object-fit: cover; }

/* ---------- reports ---------- */
.report-builder { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.report-form { position: sticky; top: calc(var(--topbar-h) + 16px); }
.preview-card { display: flex; flex-direction: column; min-height: 70vh; }
.preview-head { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.preview-card iframe { width: 100%; flex: 1 1 auto; min-height: 70vh; border: 0; background: #fff; }

/* ---------- compare ---------- */
.pick-chips { gap: 6px; }
.pick-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-size: 13.5px; background: var(--surface); }
.pick-chip.on { background: var(--accent-bg); border-color: var(--accent-ink); color: var(--text); }
.pick-chip:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.pick-chip input { width: 15px; height: 15px; accent-color: var(--btn-primary); }
.pick-chip:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.cmp-table th[scope="row"] { font-weight: 500; color: var(--text-2); min-width: 170px; background: var(--surface); }
.cmp-table td { min-width: 150px; vertical-align: top; }
.cmp-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-table td.na .cmp-val { color: var(--text-3); font-weight: 500; }
.cmp-table td.hi { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent-ink); }
[dir="rtl"] .cmp-table td.hi { box-shadow: inset -3px 0 0 var(--accent-ink); }
.hi-tag { font-size: 11px; font-weight: 600; color: var(--accent-ink); border: 1px solid var(--accent-border); border-radius: 999px; padding: 0 6px; margin-inline-start: 4px; vertical-align: 2px; }
.cmp-table tr.differ th[scope="row"] { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- patterns / clients ---------- */
.dim { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dim > summary { padding: 10px 12px; }
.dim > .table-wrap { padding: 0 12px 12px; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.chip.tone-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.pat-list { list-style: none; display: grid; gap: 10px; }
.pat-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.pat-title { font-size: 14px; font-weight: 600; }
.pat-title .muted { font-weight: 500; }
.pat-bars { display: grid; gap: 6px; }
.pat-bar { display: grid; grid-template-columns: 110px minmax(80px, 1fr) minmax(120px, auto); align-items: center; gap: 10px; font-size: 13px; }
.pat-bar-l { color: var(--text-2); }
.pat-bar-track { block-size: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.pat-bar-fill { display: block; block-size: 100%; background: var(--border-strong); border-radius: 999px; }
.pat-bar-fill.is-lead { background: var(--accent-ink); }
.pat-bar-v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.pat-bar-v .muted { font-weight: 400; font-size: 12px; }

/* ---------- Phase 2: "What changed" feed, Concepts tab, Alerts page ---------- */
.chip.tone-neutral { color: var(--text-2); background: var(--neutral-bg); border-color: var(--border-strong); }
.chip-btn {
    display: inline-flex; align-items: center; min-height: 30px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-weight: 500;
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }
.chip-btn[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-ink); }
.ev-filters { gap: 6px; }
.ev-day + .ev-day { margin-top: 14px; }
.ev-day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text-2); }
.ev-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ev-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ev-chip { flex: 0 0 auto; margin-top: 1px; }
.ev-main { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.ev-text { font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; flex: 1 1 320px; min-width: 0; }
.ev-main .ev-link { white-space: nowrap; }

/* timeline chart */
.tl-wrap { width: 100%; min-height: 60px; }
.tl-svg { display: block; max-width: 100%; touch-action: pan-y; direction: ltr; }   /* positions are mirrored in JS for RTL */
.tl-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tl-grid { stroke: var(--border); stroke-width: 1; }
.tl-zero { stroke: var(--border-strong); stroke-width: 1; }
.tl-tick, .tl-cap { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.tl-cap { font-weight: 500; }
.tl-line { fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tl-area { fill: var(--accent-bg); stroke: none; }
.tl-launch { fill: var(--info); }
.tl-stop { fill: var(--bad); }
.tl-cursor { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.tl-dot { fill: var(--accent-ink); stroke: var(--surface); stroke-width: 2; }
.tl-legend { gap: 6px 16px; color: var(--text-2); }
.tl-readout { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; min-height: 22px; color: var(--text-2); }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.key-line { height: 3px; border-radius: 2px; vertical-align: 3px; background: var(--accent-ink); }
.key-launch { background: var(--info); }
.key-stop { background: var(--bad); }
.tl-table > summary { color: var(--accent-ink); margin-top: 4px; }
.tl-table .table-wrap { max-height: 320px; overflow-y: auto; margin-top: 8px; }

/* concept cards */
.concept-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.concept-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); min-width: 0; cursor: default; }
.concept-card .ad-media[data-open] { cursor: pointer; }
.concept-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.concept-snippet { font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.concept-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.concept-facts dd { font-variant-numeric: tabular-nums; }

/* Phase 3: winning-concept badges, paid from organic, saved by concept (docs/winners.md) */
.win-section { margin-bottom: 16px; }
.concept-foot { margin-top: auto; }
.win-brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wb-badges { gap: 6px; }
button.wbadge { cursor: pointer; font: inherit; font-size: 12px; min-height: 26px; }
button.wbadge:hover { border-color: var(--border-strong); }
button.wbadge[aria-expanded="true"] { outline: 2px solid currentColor; outline-offset: 1px; }
button.wbadge:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wb-why { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); line-height: 1.45; }
.org-line { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.org-thumb { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--media-bg); display: grid; place-items: center; color: var(--text-3); }
.org-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.org-text { min-width: 0; flex: 1 1 auto; }
.org-text p { line-height: 1.45; overflow-wrap: anywhere; }
.op-eng { gap: 10px; color: var(--text-2); }
[data-op-filters] .chip-btn { gap: 6px; }
.op-eng .ic { width: 13px; height: 13px; vertical-align: -2px; }
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 12px; }
.op-pair { padding: 12px; min-width: 0; }
.op-sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
.op-side { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.op-img { display: grid; place-items: center; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--media-bg); color: var(--text-3); }
.op-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.op-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-3); max-width: 84px; text-align: center; }
.op-arrow { width: 18px; height: 18px; }
[dir="rtl"] .op-arrow { transform: scaleX(-1); }
.saved-groups { display: flex; flex-direction: column; gap: 18px; }
.saved-group { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.saved-group-head { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); gap: 6px 12px; }
.saved-group-head .row-wrap { gap: 6px 8px; align-items: center; }
.saved-group-head .ic { width: 15px; height: 15px; }

/* alerts page */
.al-steps { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.al-steps > li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.al-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; font-weight: 600; padding: 2px 8px; border-radius: 5px; background: var(--surface); border: 1px solid var(--border-strong); letter-spacing: .04em; user-select: all; }
.al-kinds { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.al-kinds > li { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.al-kinds .switch { align-items: flex-start; }
.al-kinds .switch-ui { margin-top: 2px; }
fieldset[disabled] .al-kinds { opacity: .6; }
fieldset[disabled] .switch { cursor: not-allowed; }
.seg button[disabled] { opacity: .55; cursor: not-allowed; }

/* Phase 4: promotions calendar + market radar (docs/plays.md) */
.nowrap { white-space: nowrap; }
.row.gap-xs { gap: 6px; }
.pc-scroll { position: relative; overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); scrollbar-width: thin; }
.pc-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pc { --pc-label: 180px; min-width: 680px; position: relative; }
.pc-body { position: relative; }
.pc-row { display: grid; grid-template-columns: var(--pc-label) minmax(0, 1fr); min-height: 30px; border-bottom: 1px solid var(--border); }
.pc-body > .pc-row:last-child { border-bottom: 0; }
.pc-label { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface); border-inline-end: 1px solid var(--border);
    display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: 12.5px; min-width: 0; }
.pc-label .truncate { min-width: 0; }
.pc-label .ic { width: 14px; height: 14px; flex: 0 0 auto; }
.pc-track { position: relative; min-height: 30px; min-width: 0; }
.pc-axis .pc-track { min-height: 24px; }
.pc-axis .pc-label, .pc-axis { background: var(--surface-2); }
.pc-month { position: absolute; top: 5px; padding-inline-start: 4px; font-size: 11px; color: var(--text-3); white-space: nowrap; border-inline-start: 1px solid var(--border-strong); line-height: 14px; }
.pc-overlay { position: absolute; top: 0; bottom: 0; inset-inline-start: var(--pc-label); inset-inline-end: 0; pointer-events: none; z-index: 0; }
.pc-mline { position: absolute; top: 0; bottom: 0; border-inline-start: 1px solid var(--border); }
.pc-band { position: absolute; top: 0; bottom: 0; background: color-mix(in oklab, var(--violet) 9%, transparent);
    border-inline: 1px dashed color-mix(in oklab, var(--violet) 35%, transparent); }
.pc-brand { background: color-mix(in oklab, var(--surface-2) 70%, transparent); }
.pc-brand .pc-label { background: var(--surface-2); font-size: 13px; }
.pc-brand-sum { display: flex; align-items: center; padding: 4px 8px; z-index: 1; }
.pc-brand-sum .chip { font-size: 11.5px; }
.pc-none { display: flex; align-items: center; padding: 0 8px; }
.pc-bar, .pc-season { position: absolute; top: 5px; bottom: 5px; min-inline-size: 6px; border: 0; margin: 0; padding: 0 4px; cursor: pointer; z-index: 1;
    font: inherit; font-size: 11px; font-weight: 600; line-height: 1; overflow: hidden; white-space: nowrap; text-align: start; display: flex; align-items: center; }
.pc-bar { border-radius: 4px; color: var(--text); background: color-mix(in oklab, var(--btn-primary) var(--mix, 78%), var(--surface-3)); }
.pc-bar.on-dark { color: #fff; }
.pc-bar.always { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, .22) 6px 9px); }
.pc-bar.ongoing { border-start-end-radius: 0; border-end-end-radius: 0; box-shadow: inset -3px 0 0 var(--ok); }
[dir="rtl"] .pc-bar.ongoing { box-shadow: inset 3px 0 0 var(--ok); }
.pc-bar:hover, .pc-season:hover { filter: brightness(1.08); }
.pc-bar:focus-visible, .pc-season:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 3; }
.pc-bar > span, .pc-season > span { overflow: hidden; text-overflow: clip; }
.pc-season { border-radius: 999px; color: var(--violet); background: color-mix(in oklab, var(--violet) 16%, var(--surface));
    border: 1px solid color-mix(in oklab, var(--violet) 40%, transparent); font-weight: 500; }
.pc-season-row .pc-track { min-height: 26px; }
.pc-always-tag { flex: 0 0 auto; font-size: 10.5px; font-weight: 600; color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 999px; padding: 0 5px; line-height: 16px; }
.pc-legend { gap: 6px 16px; color: var(--text-2); }
.pc-key-grad { background: linear-gradient(90deg, color-mix(in oklab, var(--btn-primary) 30%, var(--surface-3)), var(--btn-primary)); width: 28px; }
.pc-key-solid { background: var(--btn-primary); }
.pc-key-always { background: var(--btn-primary) repeating-linear-gradient(135deg, transparent 0 3px, rgba(255, 255, 255, .35) 3px 5px); }
.pc-key-ongoing { background: var(--btn-primary); box-shadow: inset -3px 0 0 var(--ok); border-radius: 3px 0 0 3px; }
.pc-key-disc { width: auto; height: auto; background: none; font-style: normal; font-weight: 700; color: var(--text-2); }
.pc-key-season { background: color-mix(in oklab, var(--violet) 18%, transparent); border: 1px dashed var(--violet); }
.pr-disc-line { fill: none; stroke: var(--warn); stroke-width: 2; stroke-dasharray: 5 3; stroke-linejoin: round; }
.pr-disc-dot { fill: var(--warn); stroke: var(--surface); stroke-width: 2; }
.tl-dot-s { fill: var(--accent-ink); }
.pr-key-disc { height: 0; border-top: 2px dashed var(--warn); border-radius: 0; vertical-align: 3px; }
.pr-up + .pr-up { border-top: 1px solid var(--border); padding-top: 10px; }
.pr-up > * + * { margin-top: 6px; }
.inline-ic { width: 14px; height: 14px; vertical-align: -2px; }

.rd-wrap { position: relative; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; }
.rd-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rd-matrix { border-collapse: separate; border-spacing: 0; }
.rd-matrix th, .rd-matrix td { padding: 6px 10px; white-space: nowrap; }
.rd-matrix thead th { position: sticky; top: 0; z-index: 2; }
.rd-matrix .rd-sticky { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); border-inline-end: 1px solid var(--border); text-align: start; font-weight: 500; }
.rd-matrix thead .rd-sticky { z-index: 3; background: var(--surface-2); }
.rd-matrix tbody tr:hover .rd-sticky { background: var(--surface-2); }
.rd-brand a { display: inline-block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: var(--text-2); }
.rd-cell { text-align: center; min-width: 72px; }
.rd-cell .rd-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.rd-cell .rd-st .ic { width: 15px; height: 15px; }
.rd-reach { display: block; font-size: 11px; color: var(--text-3); }
.rd-cell.rd-present { background: var(--ok-bg); }
.rd-cell.rd-present .rd-num { color: var(--ok); }
.rd-cell.rd-watch { box-shadow: inset 0 0 0 1px var(--warn-border); background: color-mix(in oklab, var(--warn-bg) 60%, transparent); color: var(--warn); }
.rd-cell.rd-left { background: var(--neutral-bg); color: var(--text-3); }
.rd-cell.rd-none { color: var(--text-3); }
.rd-country { white-space: nowrap; }
.rd-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.rd-swatch.rd-present { background: var(--ok-bg); border-color: var(--ok-border); }
.rd-swatch.rd-watch { background: var(--warn-bg); border-color: var(--warn-border); }
.rd-swatch.rd-left { background: var(--neutral-bg); border-color: var(--border-strong); }
.rd-swatch.rd-none { background: var(--surface); }
.rd-legend { gap: 6px 16px; }
.chip.rd-present { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.rd-watch { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.rd-left { color: var(--text-2); background: var(--neutral-bg); border-color: var(--border-strong); }
.rd-prio { font-size: 11px; }
.rd-prio-dot { color: var(--warn); }
.rd-prio-dot .ic { width: 12px; height: 12px; vertical-align: -1px; }
.rd-aud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.rd-aud { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.rd-aud .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rd-aud .facts > div { background: var(--surface); }
.rd-bars { display: flex; flex-direction: column; gap: 6px; }
.rd-bar-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.rd-age { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rd-tracks { display: flex; flex-direction: column; gap: 2px; }
.rd-track { display: block; height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.rd-fill { display: block; height: 100%; border-radius: 4px; }
.rd-f, .rd-key-f { background: var(--violet); }
.rd-m, .rd-key-m { background: var(--info); }
.rd-vals { line-height: 1.1; color: var(--text-3); text-align: end; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
    .pc { --pc-label: 118px; }
    .rd-brand a { max-width: 96px; }
    .rd-matrix th, .rd-matrix td { padding: 6px 8px; }
    .rd-country .xsmall { display: none; }
}

/* ---------- benchmarks (Phase 5) ---------- */
.bm-wrap { position: relative; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; }
.bm-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bm-table { border-collapse: separate; border-spacing: 0; }
.bm-table th, .bm-table td { padding: 8px 10px; vertical-align: top; }
.bm-table thead th { position: sticky; top: 0; z-index: 2; white-space: normal; min-width: 92px; max-width: 140px; line-height: 1.3; }
.bm-table .num { text-align: end; }
.bm-table .bm-sticky { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); border-inline-end: 1px solid var(--border);
    text-align: start; font-weight: 500; min-width: 150px; max-width: 200px; }
.bm-table thead .bm-sticky { z-index: 3; background: var(--surface-2); }
.bm-table tbody tr:hover .bm-sticky { background: var(--surface-2); }
.bm-mh { display: inline-block; border-bottom: 1px dotted var(--border-strong); cursor: help; }
.bm-brand { display: inline-block; vertical-align: top; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bm-sub { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-3); white-space: normal; }
.bm-cell, .bm-table td.num { white-space: nowrap; }
.bm-cell > div { margin-top: 3px; }
.bm-median th, .bm-median td { background: var(--surface-2); border-bottom: 2px solid var(--border-strong); }
.bm-median .bm-sticky { background: var(--surface-3); }
.bm-flags { display: block; font-size: 12px; line-height: 1.2; }
.chip.bm-pos { font-size: 11px; padding: 1px 6px; gap: 3px; }
.chip.bm-pos .ic { width: 11px; height: 11px; }
.chip.bm-above { color: var(--violet); background: color-mix(in oklab, var(--violet) 12%, transparent); border-color: color-mix(in oklab, var(--violet) 35%, transparent); }
.chip.bm-below { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip.bm-typical { color: var(--text-2); background: var(--neutral-bg); border-color: var(--border-strong); }
.bm-legend { gap: 6px 10px; }
.bm-defs summary { padding: 4px 0; }
.bm-deflist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 8px 16px; margin: 8px 0; }
.bm-deflist dt { font-size: 13px; font-weight: 600; }
.bm-deflist dd { margin: 0; font-size: 12.5px; color: var(--text-2); }
.bm-cat { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.bm-cat .bm-wrap { background: var(--surface); }
.bm-pending { display: block; }
.bm-pending > summary { list-style: none; cursor: pointer; }
.bm-pending > summary::-webkit-details-marker { display: none; }
.bm-pending > summary .ic { color: var(--info); }
.bm-pending[open] .bm-pending-open { display: none; }
.bm-pending-body { margin-top: 10px; }
.bm-pending-list { list-style: none; }
.bm-pending-list > li { padding: 10px 0; border-top: 1px solid var(--info-border); }
.bm-sigs { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.bm-sig { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 4px 10px; font-size: 13px; }
.bm-sig-src { color: var(--text-3); font-size: 12px; padding-top: 1px; }
.bm-sig-body { min-width: 0; overflow-wrap: anywhere; }
.bm-sig-line { gap: 4px 8px; }
.bm-val { font-weight: 500; color: var(--text); }
.bm-terms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip.bm-conf-high { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.bm-conf-medium { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.bm-conf-low { color: var(--text-2); background: var(--neutral-bg); border-color: var(--border-strong); }
.bm-cat-pick select { width: auto; max-width: 100%; }
@media (max-width: 720px) {
    .bm-table .bm-sticky { min-width: 116px; max-width: 128px; }
    .bm-table th, .bm-table td { padding: 6px 8px; }
    .bm-table thead th { min-width: 80px; }
    .bm-sig { grid-template-columns: 1fr; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    body:not(.sidebar-expanded) .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
    body:not(.sidebar-expanded) .brand-text, body:not(.sidebar-expanded) .nav-label { display: none; }
    body:not(.sidebar-expanded) .nav-link { justify-content: center; padding: 8px; position: relative; }
    body:not(.sidebar-expanded) .nav-badge { position: absolute; top: 2px; inset-inline-end: 2px; padding: 0 5px; line-height: 16px; font-size: 10px; }
    body:not(.sidebar-expanded) .brand { justify-content: center; padding-inline: 0; }
    body:not(.sidebar-expanded) .brand-mark { display: grid; }
    .collapse-btn { display: none; }
    .kbd { display: none; }
    .report-builder { grid-template-columns: 1fr; }
    .report-form { position: static; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100%;
        width: min(280px, 84vw) !important; flex-basis: auto !important;
        transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); z-index: 50;
    }
    [dir="rtl"] .sidebar { transform: translateX(105%); }
    body.nav-open .sidebar { transform: none; }
    body .sidebar .brand-text, body .sidebar .nav-label { display: flex !important; }
    body .sidebar .nav-label { display: block !important; }
    body .sidebar .nav-link { justify-content: flex-start !important; padding: 10px !important; }
    body .sidebar .nav-badge { position: static !important; }
    body .sidebar .brand { justify-content: flex-start !important; padding-inline: 6px !important; }
    body .sidebar .brand-mark { display: none !important; }
    body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 45; }
    .icon-btn.menu-btn { display: inline-grid; }
    .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .top-search { order: 10; flex: 1 1 100%; max-width: none; }
    .client-switch { max-width: 44vw; }
    .client-switch select { max-width: 32vw; }
    .sched { display: none !important; }
    main { padding: 16px 16px 56px; }
    .fb-toggle { display: inline-flex; }
    .fb-panel { display: none; }
    .filterbar.open .fb-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filterbar { position: static; }
    .fb-top .search-field { flex-basis: 100%; }
    .inline-field .lbl { display: none; }
    .alert-row { grid-template-columns: auto minmax(0, 1fr); }
    .alert-act { grid-column: 2; }
    .layer-modal { padding: 0; align-items: flex-end; }
    .layer-modal .layer-panel { max-width: none; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; }
    .layer-drawer .layer-panel, .layer-drawer .layer-panel.wide { width: 100%; }
}

@media (max-width: 720px) {
    /* tables become stacked cards */
    .tbl.stack-mobile thead { display: none; }
    .tbl.stack-mobile, .tbl.stack-mobile tbody, .tbl.stack-mobile tr, .tbl.stack-mobile td, .tbl.stack-mobile th[scope="row"] { display: block; width: 100%; }
    .tbl.stack-mobile tr { border-bottom: 1px solid var(--border); padding: 8px 12px; }
    .tbl.stack-mobile tbody tr:last-child { border-bottom: 0; }
    .tbl.stack-mobile td, .tbl.stack-mobile th[scope="row"] { border: 0; padding: 4px 0; }
    .tbl.stack-mobile td[data-label] { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: end; }
    .tbl.stack-mobile td[data-label]::before { content: attr(data-label); font-size: 12px; font-weight: 500; color: var(--text-3); text-align: start; flex: 0 0 auto; max-width: 45%; }
    .tbl.stack-mobile td[data-label] > * { min-width: 0; }
    .tbl.stack-mobile td.actions { text-align: start; padding-top: 8px; }
    .tbl.stack-mobile td.actions .row-wrap { justify-content: flex-start; }
    .cmp-table th[scope="row"] { font-weight: 600; color: var(--text); padding-top: 6px; }
    .cmp-table td { min-width: 0; }
    .cmp-table td.hi { box-shadow: none; border-radius: 6px; padding-inline: 6px; }
    .ad-results.list .ad-media { flex-basis: 96px; min-height: 96px; }
    .mini-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi { padding: 8px 10px; }
    .kpi-value { font-size: 18px; }
    .kpi-grid.headline .kpi { padding: 10px 12px; }
    .kpi-grid.headline .kpi-value { font-size: 22px; }
    .kpi-group-preview { display: none; }
    .pat-bar { grid-template-columns: 1fr auto; }
    .pat-bar-track { grid-column: 1 / -1; grid-row: 2; }
    .disclosure-card > summary { margin: -14px; padding: 14px; }
    .h1 { font-size: 20px; }
    .card { padding: 14px; }
    .page-head { align-items: flex-start; }
    .comp-head .row.gap { align-items: flex-start; }
}

@media (max-width: 420px) {
    .client-switch > .ic { display: none; }
    .client-switch { padding-inline: 4px; max-width: calc(100vw - 230px); }
    .client-switch select { max-width: 100%; }
    .icon-btn { width: 36px; height: 36px; }
    .seg button { min-width: 34px; padding: 0 6px; }
    .scan-label { display: none; }
    .scan-btn { padding: 0 10px; }
    .top-actions { gap: 4px; }
    .ad-results.grid { grid-template-columns: 1fr; }
    .filterbar.open .fb-panel { grid-template-columns: 1fr; }
    .mini-kpi .val { font-size: 16px; }
    .bar-row { grid-template-columns: 56px 1fr 70px; }
}

@media print {
    .sidebar, .topbar, .filterbar, .load-more { display: none !important; }
}

/* ---------- account menu (top bar) ---------- */
.user-menu { position: relative; }
.user-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 8px 0 4px; max-width: 200px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit;
}
[dir="rtl"] .user-btn { padding: 0 4px 0 8px; }
.user-btn:hover { background: var(--surface-2); color: var(--text); }
.user-btn .ic { width: 15px; height: 15px; flex: 0 0 15px; }
.user-avatar {
    width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-bg); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.user-pop {
    position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 40; min-width: 220px; max-width: min(300px, 92vw);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px;
    display: flex; flex-direction: column; gap: 2px;
}
.user-pop[hidden] { display: none; }
.user-pop-head { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-wrap: anywhere; }
.user-pop [role="menuitem"] {
    display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 5px;
    background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: start; cursor: pointer; width: 100%;
}
.user-pop [role="menuitem"]:hover, .user-pop [role="menuitem"]:focus-visible { background: var(--surface-2); text-decoration: none; }
.user-pop [role="menuitem"] .ic { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-3); }
.team-actions { justify-content: flex-end; gap: 6px; }

/* ---------- sign-in / first-run page ---------- */
.auth-body { min-height: 100vh; }
.auth-wrap {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 72px 16px 48px; gap: 16px; max-width: none; position: relative;
}
.auth-tools { display: flex; align-items: center; gap: 8px; position: absolute; top: 16px; inset-inline-end: 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-width: 0; }
.auth-card .h2 { margin: 0; }
.auth-card form { margin-top: 8px; }
.auth-submit { width: 100%; justify-content: center; min-height: 42px; }
.auth-noscript { color: var(--text-2); }
@media (max-width: 420px) {
    .auth-card { padding: 20px 16px; }
    .user-name, .user-btn > .ic { display: none; }
    .user-btn { padding: 0 4px; }
}

/* Meta page search (static/js/pagesearch.js) */
.page-search:empty { display: none; }
.page-search { display: flex; flex-direction: column; gap: 6px; margin-top: -4px; }
.ps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.ps-item.on, .ps-item:hover { border-color: var(--accent-ink); background: var(--accent-bg); }
.ps-item .badge { margin-inline-start: 4px; }
.ps-picked { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--accent-ink); border-radius: var(--radius-sm); background: var(--accent-bg); flex-wrap: wrap; }
.tg-steps { margin: 0; padding-inline-start: 20px; }
.view-as-bar { margin: 8px 16px 0; }
.org-switch select { max-width: 180px; }
/* the agency / client switchers keep a readable width; the search box gives way first */
@media (min-width: 900px) { .client-switch select { min-width: 96px; } .top-search { min-width: 160px; } }
@media (max-width: 1400px) { .sched { display: none !important; } }   /* room for the switchers + account menu */

@media (max-width: 560px) {
    .ev-row { flex-direction: column; gap: 6px; }
    .ev-text { flex-basis: 100%; }
    .al-steps > li { flex-direction: column; }
    .op-mid { max-width: 64px; }
}

/* ---------- Phase 6 AI (static/js/ai.js): AI label, tags, gaps, briefs, status ---------- */
.ai-badge {
    display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; letter-spacing: .02em; line-height: 18px;
    padding: 0 7px; border-radius: 999px; white-space: nowrap; cursor: help;
    color: var(--violet); background: color-mix(in oklab, var(--violet) 12%, transparent); border: 1px solid color-mix(in oklab, var(--violet) 35%, transparent);
}
.ai-badge .ic { width: 12px; height: 12px; }
.ai-mini { display: inline-block; font-size: 10px; font-weight: 700; line-height: 14px; padding: 0 4px; border-radius: 4px; vertical-align: 1px;
    color: var(--violet); background: color-mix(in oklab, var(--violet) 12%, transparent); }
.chip.ai-chip { color: var(--text); border-color: color-mix(in oklab, var(--violet) 30%, var(--border)); background: color-mix(in oklab, var(--violet) 6%, var(--surface-2)); }
a.chip.ai-chip:hover { border-color: var(--violet); }
.ai-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ai-chips .chip { overflow: hidden; text-overflow: ellipsis; }
.ai-block { border-inline-start: 3px solid color-mix(in oklab, var(--violet) 55%, transparent); padding-inline-start: 12px; }
.ai-ocr { margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 13px; max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
.ai-opt .check { flex-wrap: wrap; }
.ai-written { margin: 0; font-size: 13px; color: var(--text-2); }

/* gaps matrix (reuses the market radar table: pinned first column, sticky header) */
.gp-seg { max-width: 100%; overflow-x: auto; }
.gp-seg button { white-space: nowrap; }
.gp-matrix .rd-sticky { max-width: 220px; }
.gp-matrix th.rd-sticky { white-space: normal; min-width: 140px; }
.gp-val { display: block; }
.gp-matrix th.rd-sticky .chip { margin-top: 3px; }
.chip.gp-crowded { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.gp-open { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.gp-cell { text-align: center; min-width: 72px; font-variant-numeric: tabular-nums; background: color-mix(in oklab, var(--violet) calc(var(--gp, 0%) * .3), transparent); }
.gp-cell a, .gp-cell > span { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; }
.gp-cell.gp-hot { font-weight: 700; }
.gp-cell.gp-none { color: var(--text-3); }
.gp-n { font-size: 11px; font-weight: 400; color: var(--text-3); }
.gp-small { font-size: 11px; font-weight: 500; color: var(--warn); display: inline-flex; align-items: center; gap: 3px; }
.gp-small .ic { width: 12px; height: 12px; }
.gp-summary { gap: 6px 18px; }

/* briefs */
.brief-form { align-items: flex-end; }
.brief-text { max-width: 76ch; line-height: 1.7; font-size: 14.5px; overflow-wrap: anywhere; }
.brief-text p { margin: 0 0 10px; }
.brief-text h3, .brief-text h4, .brief-text h5 { margin: 18px 0 6px; line-height: 1.35; }
.brief-text h3 { font-size: 17px; } .brief-text h4 { font-size: 15.5px; } .brief-text h5 { font-size: 14.5px; }
.brief-text > :first-child { margin-top: 0; }
.brief-text ul, .brief-text ol { margin: 0 0 10px; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 4px; }
.brief-text hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.brief-text:lang(ar) { font-size: 15px; line-height: 1.85; }
.cites { white-space: normal; color: var(--text-3); font-size: 12px; }
a.cite { font-size: 12px; font-weight: 500; padding: 0 4px; border-radius: 4px; background: var(--accent-bg); color: var(--accent-ink); white-space: nowrap; }
a.cite:hover { text-decoration: underline; }
.brief-flags ul { margin: 4px 0 0; }
.brief-flag-items { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.brief-list a { font-weight: 500; }

/* AI status card */
.bar.ai-spend { max-width: 360px; }
.bar.ai-spend > span { background: var(--violet); }
.bar.ai-spend > span.high { background: var(--warn); }
.bar.ai-spend > span.full { background: var(--bad); }
@media (max-width: 560px) {
    .gp-matrix th.rd-sticky { min-width: 112px; max-width: 150px; }
    .brief-form { align-items: stretch; }
    .brief-form .btn { justify-content: center; }
}
.gp-cell.gp-low a, .gp-cell.gp-low > span { opacity: .75; font-style: italic; }

/* Phase 7 (docs/weaknesses.md): weak spots, positioning mix, share of voice, openings.
   Categorical series: the brand palette (docs/brand.md), colour-blind safe in both themes; charts keep a legend and a table. */
:root {
    --series-1: #1C8FC4; --series-2: #D9481F; --series-3: #8E5BE0; --series-4: #283C8F;
    --series-5: #B5486B; --series-6: #7A2560; --series-7: #0B7468; --series-8: #3D7F1F; --series-other: #8A8F9A;
}
:root[data-theme="dark"] {
    --series-1: #65C6FD; --series-2: #F47420; --series-3: #9B6EE9; --series-4: #6C85A7;
    --series-5: #D0878C; --series-6: #F9C8DA; --series-7: #2BB3A0; --series-8: #6DBA4A; --series-other: #7D818A;
}
.sr-1 { --sr: var(--series-1); } .sr-2 { --sr: var(--series-2); } .sr-3 { --sr: var(--series-3); } .sr-4 { --sr: var(--series-4); }
.sr-5 { --sr: var(--series-5); } .sr-6 { --sr: var(--series-6); } .sr-7 { --sr: var(--series-7); } .sr-8 { --sr: var(--series-8); }
.sr-other { --sr: var(--series-other); }
.key[class*="sr-"] { background: var(--sr); }
.pos-seg { fill: var(--sr); }
.pos-seg:hover { filter: brightness(1.1); }
.pos-empty { fill: none; stroke: var(--border-strong); stroke-dasharray: 4 3; }
.pos-hit { fill: transparent; }
.pos-n { font-size: 10px; }
.sov-line { fill: none; stroke: var(--sr); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sov-legend > li { gap: 4px 12px; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.ws-card { border: 1px solid var(--warn-border); background: color-mix(in oklab, var(--warn-bg) 45%, var(--surface)); border-radius: var(--radius-sm);
    padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ws-card h3 .ic { width: 16px; height: 16px; color: var(--warn); }
.ws-vs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); }
.ws-meter { position: relative; flex: 0 0 90px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: visible; }
.ws-meter-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 3px; background: var(--warn); }
.ws-meter-thr { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-inline-start: -1px; background: var(--text); }
.ws-open { color: var(--ok); }
.ws-checked summary { cursor: pointer; }
.ws-checked .rows { margin: 6px 0 0; padding: 0; }
.op-brand + .op-brand { border-top: 1px solid var(--border); padding-top: 8px; }
.op-list { margin: 0; padding: 0; }
