/* ── Site Intelligence tab ────────────────────────────────────────────────
 *
 * Styling for the super-only analytics tab rendered by js/site-intel.js.
 *
 * BOTH-THEMES RULE (learned the hard way on the upload-gate closed card):
 * this file contains ZERO hex literals and ZERO rgb() literals. Every colour is
 * a theme token or a color-mix of one, so light and dark are correct by
 * construction rather than by a second set of overrides.
 *
 * `--card-bg` is a solid colour in both themes and safe to color-mix.
 * `--bg-main` is a GRADIENT in the light theme and must NEVER be passed to
 * color-mix — it silently produces an invalid colour and the element renders
 * transparent. See css/theme-tokens.css.
 *
 * Also: no `content:` string in this file carries a non-ASCII character. A
 * CSS content string is the one place an encoding slip becomes visible mojibake
 * on the page; every glyph the tab draws is an inline SVG built in JS.
 */

#site-intel {
    --si-gap: 18px;
    --si-radius: 14px;
    --si-line: color-mix(in srgb, var(--border) 70%, transparent);
    --si-raise: color-mix(in srgb, var(--card-bg) 88%, var(--text-primary) 4%);
    --si-sink: color-mix(in srgb, var(--card-bg) 94%, var(--text-primary) 6%);
    --si-high: var(--danger);
    --si-med: var(--warning);
    --si-low: var(--primary);
}

/* ── Header ───────────────────────────────────────────────────────────── */

/* The header is a RAISED PANEL, not bare text on the page background. It is the
 * one band that stays put while the h1, the subtitle and every panel below it
 * change with the active sub-tab, so it needs to read as a fixed frame rather
 * than as the first paragraph of whatever tab happens to be open.
 *
 * The tint is mixed off `--primary`, not off a fixed grey: in the light theme
 * `--card-bg` is white and the page behind it is a warm beige gradient, so a
 * plain white panel would sink INTO the page rather than lift off it. Mixing a
 * little primary in gives the band its own hue in both themes, which is the
 * thing that actually makes it legible as a header. `--card-bg` is solid in both
 * themes and safe to mix; `--bg-main` is a gradient in light and must not be
 * mixed (see the file header). */
.si-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--si-gap);
    margin-bottom: var(--si-gap);
    position: relative;
    overflow: hidden;
    padding: 22px 24px;
    border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
    border-radius: var(--si-radius);
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--primary) 13%, var(--card-bg)) 0%,
            color-mix(in srgb, var(--primary) 5%, var(--card-bg)) 52%,
            color-mix(in srgb, var(--accent) 5%, var(--card-bg)) 100%);
}

/* Accent wash in the top-right corner. Decorative only: `pointer-events: none`
 * and it sits at z-index 0 under the copy, so it can never eat a click on the
 * freshness stamp or cover the title. */
.si-head::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(660px 190px at 94% -40%,
        color-mix(in srgb, var(--primary) 16%, transparent), transparent 72%);
}

.si-head-copy,
.si-head .si-freshness {
    position: relative;
    z-index: 1;
}

.si-head-copy { min-width: 0; }

/* The brand line. Stays put while the h1 below it follows the active sub-tab,
 * so the user always knows both WHERE they are and WHAT they are reading. */
.si-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 6px;
}

.si-eyebrow svg { width: 16px; height: 16px; }

.si-eyebrow-note {
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: none;
    color: var(--text-muted);
    padding-left: 8px;
    border-left: 1px solid var(--si-line);
}

.si-head h1 {
    margin: 0;
    font-size: 2.1rem;
    font-weight: 750;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.si-head h1 svg { width: 30px; height: 30px; color: var(--primary); flex: none; }

.si-head .si-sub {
    margin: 8px 0 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 78ch;
    line-height: 1.55;
}

.si-freshness {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.si-stamp {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border-radius: 999px;
    background: var(--si-raise);
    border: 1px solid var(--si-line);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.25;
}

.si-stamp b { color: var(--text-primary); font-weight: 650; }
.si-stamp small { display: block; color: var(--text-muted); font-size: 0.72rem; }

.si-pulse {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent);
    animation: si-pulse 2.6s ease-out infinite;
    flex: 0 0 auto;
}

.si-stamp.is-stale .si-pulse { background: var(--warning); animation: none; }
.si-stamp.is-dead .si-pulse { background: var(--danger); animation: none; }

@keyframes si-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); }
    70%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--success) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
    .si-pulse { animation: none; }
}

.si-btn {
    appearance: none;
    border: 1px solid var(--si-line);
    background: var(--si-raise);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.si-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.si-btn:disabled { opacity: .55; cursor: default; transform: none; }
.si-btn.si-primary { background: var(--primary-gradient); color: var(--text-inverse); border-color: transparent; }

/* ── Filter bar ───────────────────────────────────────────────────────── */

.si-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    padding: 16px;
    border-radius: var(--si-radius);
    background: var(--card-bg);
    border: 1px solid var(--si-line);
    margin-bottom: var(--si-gap);
    position: sticky;
    top: 0;
    z-index: 6;
}

.si-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.si-field label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.si-field select {
    appearance: none;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--si-line);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 550;
    cursor: pointer;
}

.si-field select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.si-field select:disabled { opacity: .5; cursor: default; }

.si-scope {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--si-line);
    padding-top: 12px;
}

.si-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--si-sink);
    border: 1px solid var(--si-line);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.si-chip b { color: var(--text-primary); }

/* The tier chip. Deliberately the most prominent thing in the scope row: a plus
 * caller must be able to see at a glance that what they are reading is their own
 * country, not the estate. */
.si-chip.is-scoped {
    background: color-mix(in srgb, var(--warning) 14%, var(--card-bg));
    border-color: color-mix(in srgb, var(--warning) 45%, transparent);
    color: var(--text-primary);
}

.si-chip.is-super {
    background: color-mix(in srgb, var(--primary) 12%, var(--card-bg));
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    color: var(--text-primary);
}

.si-chip.is-scoped svg, .si-chip.is-super svg { width: 13px; height: 13px; }

/* A locked picker reads as a fact, not a choice: dimmed, not clickable, with the
 * reason on the label itself rather than in a tooltip nobody hovers. */
.si-field.is-locked select {
    cursor: default;
    opacity: 1;
    background: var(--si-sink);
    border-style: dashed;
    color: var(--text-secondary);
}

.si-field label { display: flex; align-items: center; gap: 6px; }

.si-lock-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 999px;
    letter-spacing: .04em;
    font-size: 0.6rem;
    background: color-mix(in srgb, var(--warning) 18%, var(--card-bg));
    border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
    color: var(--text-secondary);
}

.si-lock-tag svg { width: 10px; height: 10px; }

.si-lock-tag.is-count {
    background: color-mix(in srgb, var(--primary) 16%, var(--card-bg));
    border-color: color-mix(in srgb, var(--primary) 38%, transparent);
}

/* ── Selected sites ───────────────────────────────────────────────────────
 * One chip per selected site. Shown only when something IS selected, so the
 * default "every site in scope" costs no vertical space in the sticky bar. */
.si-sitechips {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    border-top: 1px dashed var(--si-line);
    padding-top: 12px;
}

.si-sitechips-h {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 2px;
}

.si-sitechip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--primary) 14%, var(--card-bg));
    border: 1px solid color-mix(in srgb, var(--primary) 42%, transparent);
}

.si-sitechip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.si-sitechip-x svg { width: 11px; height: 11px; }
.si-sitechip-x:hover { background: var(--danger); color: var(--text-inverse); }
.si-sitechip-x:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.si-sitechip-clear {
    margin-left: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--si-line);
}

.si-sitechip-clear:hover { border-color: var(--danger); color: var(--danger); }

/* ── KPI tiles ────────────────────────────────────────────────────────── */

.si-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: var(--si-gap);
}

.si-kpi {
    position: relative;
    padding: 16px 18px;
    border-radius: var(--si-radius);
    background: var(--card-bg);
    border: 1px solid var(--si-line);
    overflow: hidden;
}

.si-kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
}

.si-kpi.si-accent::before { background: var(--accent); }
.si-kpi.si-good::before { background: var(--success); }
.si-kpi.si-warn::before { background: var(--warning); }
.si-kpi.si-bad::before { background: var(--danger); }

.si-kpi .si-k-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.si-kpi .si-k-value {
    margin-top: 7px;
    font-size: 1.9rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.si-kpi .si-k-note { margin-top: 5px; font-size: 0.8rem; color: var(--text-muted); }

/* ── Panels ───────────────────────────────────────────────────────────── */

/* Twelve explicit columns rather than `auto-fit`, because the panels are not
 * interchangeable: a chart or a wide table needs the full row while a bar list
 * is happy in a third of it. `auto-fit` cannot express that - it only knows a
 * minimum width - so every panel got the same middling column and the page
 * never used the screen it had. The page itself has no max-width (only
 * `.page-content` padding), so 12 columns here IS the full page width.
 *
 * Spans are set on the TRACK COUNT, one media query per breakpoint, so a panel
 * never has to know how wide the window is. `si-wide` stays 1 / -1 at every
 * size and so always owns a whole row. */
/* ── Sub-tabs ─────────────────────────────────────────────────────────────
 * One horizontal strip inside #si-body, above the active pane. Scrolls
 * sideways rather than wrapping: a wrapped strip changes height as the active
 * tab moves and the whole page jumps under the cursor. */
.si-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 5px;
    margin-bottom: var(--si-gap);
    border-radius: var(--si-radius);
    background: var(--si-sink);
    border: 1px solid var(--si-line);
    scrollbar-width: thin;
}

.si-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1 0 auto;
    justify-content: center;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.005em;
    cursor: pointer;
    white-space: nowrap;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.si-tab svg { width: 17px; height: 17px; flex: none; }
.si-tab:hover { color: var(--text-primary); background: var(--si-raise); }
.si-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.si-tab.is-on {
    background: var(--card-bg);
    border-color: color-mix(in srgb, var(--primary) 45%, transparent);
    color: var(--text-primary);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.si-tab.is-on svg { color: var(--primary); }

/* How many panels sit behind the tab, so the strip itself says where the depth
 * is instead of making the user open all six to find out. */
.si-tab-count {
    min-width: 19px;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--si-sink);
    border: 1px solid var(--si-line);
    color: var(--text-muted);
}

.si-tab.is-on .si-tab-count {
    background: color-mix(in srgb, var(--primary) 18%, var(--card-bg));
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    color: var(--text-primary);
}

.si-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--si-gap);
    align-items: start;
}

/* ── A sub-tab pane ───────────────────────────────────────────────────────
 * A pane holds 1-4 panels, not 17, which flips the layout maths back the other
 * way. The 12-column spans above exist because `auto-fit` gave all SEVENTEEN
 * panels the same middling track and left the page half empty; with four it does
 * the opposite and is exactly right: `auto-fit` DROPS the empty tracks and the
 * survivors share the full width, so one panel fills the row, two go side by
 * side, three go three-up on a wide screen, and a fourth wraps and stretches
 * rather than sitting in a third-width orphan column.
 *
 * `min(100%, 520px)` is the floor, not `520px`: a bare 520px track overflows a
 * narrower viewport instead of collapsing to one column. */
.si-pane {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
}

/* Beats the `span 6` / `span 4` media queries on specificity (two classes vs
 * one), so pane layout does not depend on which rule comes last in the file. */
.si-pane > .si-panel { grid-column: auto; }

/* A panel that asked for a whole row still gets one. Scoped through the id so it
 * outranks the rule above whatever the source order. */
#site-intel .si-pane > .si-panel.si-wide { grid-column: 1 / -1; }

.si-panel {
    background: var(--card-bg);
    border: 1px solid var(--si-line);
    border-radius: var(--si-radius);
    padding: 20px 22px;
    min-width: 0;
    grid-column: span 12;
}

.si-panel.si-wide { grid-column: 1 / -1; }

/* Two panels per row from tablet up. */
@media (min-width: 1080px) {
    .si-panel { grid-column: span 6; }
}

/* Three per row on a normal laptop, so a 1440-1920 screen is actually filled. */
@media (min-width: 1560px) {
    .si-panel { grid-column: span 4; }
}

/* A side-by-side pair INSIDE one panel (e.g. templates next to categories).
 * Deliberately not `.si-grid`: nesting that would inherit the 12-column spans
 * above and the inner blocks would each claim a third of the panel. */
.si-duo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: var(--si-gap);
    margin-top: 16px;
    align-items: start;
}

/* A labelled section heading inside a panel body. */
.si-subhead {
    margin: 18px 0 8px;
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--text-muted);
}

.si-duo > div > .si-subhead:first-child { margin-top: 0; }

.si-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.si-panel > header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.si-panel > header h2 svg { width: 19px; height: 19px; color: var(--primary); }
.si-panel > header .si-hint { font-size: 0.79rem; color: var(--text-muted); }

/* ── Tables ───────────────────────────────────────────────────────────── */

.si-scroll { overflow: auto; max-height: 520px; border-radius: 10px; }
.si-scroll.si-tall { max-height: 680px; }

table.si-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
}

table.si-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--si-sink);
    text-align: left;
    padding: 10px 11px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--si-line);
}

table.si-table td {
    padding: 9px 11px;
    color: var(--text-secondary);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
    vertical-align: top;
}

table.si-table td.si-num,
table.si-table th.si-num { text-align: right; font-variant-numeric: tabular-nums; }
table.si-table td.si-strong { color: var(--text-primary); font-weight: 650; }
table.si-table tbody tr:hover td { background: var(--si-sink); }
table.si-table tbody tr.si-row-flag td { background: color-mix(in srgb, var(--danger) 8%, transparent); }
table.si-table tbody tr.si-row-flag td.si-strong { color: var(--danger-dark); }
table.si-table td.si-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }

.si-empty {
    padding: 26px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.86rem;
}

/* These three live inside `.si-dates`, whose `span` rule is more specific than a
 * bare class would be, so they are qualified rather than forced with
 * !important. */
.si-dates span.si-muted {
    color: var(--text-muted);
    background: transparent;
    font-family: inherit;
}

/* A site with no order in scope: it HAS ordered before, so the cell states when.
 * Warning-toned, not danger-toned - lapsed is a different problem from never. */
.si-dates span.si-was {
    color: var(--warning-dark);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    white-space: normal;
}

/* A site with no SUGGLE invoice in ANY year. */
.si-dates span.si-never {
    color: var(--danger-dark);
    font-weight: 700;
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

/* ── Bars / distributions ─────────────────────────────────────────────── */

.si-bars { display: flex; flex-direction: column; gap: 9px; }

.si-bar-row {
    display: grid;
    grid-template-columns: minmax(96px, 34%) 1fr auto;
    gap: 10px;
    align-items: center;
    font-size: 0.87rem;
}

.si-bar-row .si-bar-name {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.si-bar-track {
    height: 8px;
    border-radius: 999px;
    background: var(--si-sink);
    overflow: hidden;
}

.si-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary-gradient);
    transition: width .35s ease;
}

.si-bar-row.si-alt .si-bar-fill { background: var(--accent); }
.si-bar-row .si-bar-value {
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-weight: 650;
    min-width: 5ch;
    text-align: right;
}

/* Month / day columns */
.si-spark {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-top: 6px;
}

.si-spark-col {
    flex: 1 1 0;
    min-width: 6px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
}

.si-spark-col i {
    display: block;
    border-radius: 4px 4px 0 0;
    background: var(--primary);
    opacity: .82;
    min-height: 2px;
    transition: opacity .15s ease;
}

.si-spark-col:hover i { opacity: 1; }
.si-spark-col.is-selected i { background: var(--accent); opacity: 1; }

.si-spark-axis {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.si-spark-axis span {
    flex: 1 1 0;
    min-width: 6px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
}

/* ── Flag board ───────────────────────────────────────────────────────── */

.si-flags { display: flex; flex-direction: column; gap: 10px; }

.si-flag {
    display: grid;
    grid-template-columns: 4px 1fr;
    gap: 12px;
    border: 1px solid var(--si-line);
    border-radius: 12px;
    background: var(--si-raise);
    overflow: hidden;
}

.si-flag .si-flag-edge { background: var(--si-low); }
.si-flag.sev-high .si-flag-edge { background: var(--si-high); }
.si-flag.sev-medium .si-flag-edge { background: var(--si-med); }

.si-flag .si-flag-body { padding: 12px 14px 12px 0; min-width: 0; }

.si-flag-title {
    font-size: 0.85rem;
    font-weight: 650;
    color: var(--text-primary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.si-badge {
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 5px;
    color: var(--text-inverse);
    background: var(--si-low);
}

.si-flag.sev-high .si-badge { background: var(--si-high); }
.si-flag.sev-medium .si-badge { background: var(--si-med); }

.si-flag-site {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .05em;
}

.si-flag-detail { margin-top: 5px; font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }

.si-evidence { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }

.si-evidence span {
    font-size: 0.68rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--si-sink);
    color: var(--text-secondary);
    border: 1px solid var(--si-line);
}

/* ── Misc ─────────────────────────────────────────────────────────────── */

.si-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 11px; }

.si-stat {
    padding: 13px 15px;
    border-radius: 11px;
    background: var(--si-sink);
    border: 1px solid var(--si-line);
}

.si-stat .si-s-label { font-size: 0.71rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; }
.si-stat .si-s-value { margin-top: 5px; font-size: 1.3rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.si-expand {
    appearance: none;
    border: 1px solid var(--si-line);
    background: transparent;
    color: var(--primary);
    border-radius: 7px;
    padding: 1px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.si-dates { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

.si-dates span {
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 3px 8px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--text-primary);
    white-space: nowrap;
}

.si-dates span b { color: var(--primary-dark); }

.si-note {
    margin-top: 12px;
    padding: 11px 13px;
    border-left: 3px solid var(--warning);
    border-radius: 0 9px 9px 0;
    background: color-mix(in srgb, var(--warning) 9%, transparent);
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Charts (hand-rolled SVG) ─────────────────────────────────────────────
 *
 * No chart library is loaded on this surface, so every plot is SVG built in JS.
 * The one rule that matters: the JS emits CLASSES ONLY, never an inline colour,
 * so a chart is themed by this file exactly like the rest of the tab. Fills use
 * `fill`/`stroke` here rather than `color`, because an SVG shape ignores
 * `color` unless the JS asked for `currentColor`.
 *
 * `preserveAspectRatio="none"` on the viewBox lets a chart stretch to whatever
 * column width the 12-column grid gave it; the height is pinned below so the
 * stretch never distorts the type (text is drawn at a fixed viewBox size and
 * scaled uniformly by the browser). */

.si-chart {
    margin-top: 14px;
    width: 100%;
}

.si-chart svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.si-gridline { stroke: var(--si-line); stroke-width: 1; }
.si-axis-line { stroke: color-mix(in srgb, var(--border) 100%, transparent); stroke-width: 1.5; }

.si-axis {
    fill: var(--text-muted);
    font-size: 15px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.si-axis-y { text-anchor: end; }
.si-axis-x { text-anchor: middle; }

/* The scope-average guide: value divided by headcount across everything in
 * scope. A site above the line spends more per head than the estate does. */
.si-guide {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 7 6;
    opacity: .85;
}

.si-dot {
    fill: color-mix(in srgb, var(--primary) 62%, transparent);
    stroke: var(--primary-dark);
    stroke-width: 1.2;
}

.si-dot.is-flagged {
    fill: color-mix(in srgb, var(--danger) 58%, transparent);
    stroke: var(--danger-dark);
}

.si-dot-label {
    fill: var(--text-secondary);
    font-size: 14px;
    font-family: inherit;
    text-anchor: middle;
}

.si-col-a { fill: color-mix(in srgb, var(--primary) 78%, transparent); }
.si-col-b { fill: color-mix(in srgb, var(--accent) 82%, transparent); }
.si-col-group:hover .si-col-a,
.si-col-group:hover .si-col-b { fill: var(--text-primary); }

.si-chart-axis {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    font-size: 0.74rem;
    font-weight: 650;
    color: var(--text-muted);
}

.si-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 9px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.si-legend-dot {
    width: 11px; height: 11px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 62%, transparent);
    border: 1px solid var(--primary-dark);
}

.si-legend-line {
    width: 22px; height: 0;
    margin-left: 12px;
    border-top: 2px dashed var(--accent);
}

.si-legend-key {
    width: 13px; height: 13px;
    border-radius: 3px;
    margin-left: 10px;
}

.si-legend-key:first-child { margin-left: 0; }
.si-legend-a { background: color-mix(in srgb, var(--primary) 78%, transparent); }
.si-legend-b { background: color-mix(in srgb, var(--accent) 82%, transparent); }

.si-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 34px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    justify-content: center;
}

.si-spin {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--si-line);
    border-top-color: var(--primary);
    animation: si-spin .8s linear infinite;
}

@keyframes si-spin { to { transform: rotate(360deg); } }

.si-gate {
    max-width: 520px;
    margin: 60px auto;
    text-align: center;
    padding: 30px;
    border-radius: var(--si-radius);
    background: var(--card-bg);
    border: 1px solid var(--si-line);
}

.si-gate h2 { margin: 0 0 8px; font-size: 1.1rem; color: var(--text-primary); }
.si-gate p { margin: 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

@media (max-width: 720px) {
    .si-filters { position: static; }
    .si-bar-row { grid-template-columns: minmax(70px, 40%) 1fr auto; }
    .si-head h1 { font-size: 1.6rem; }
    .si-head h1 svg { width: 24px; height: 24px; }
    /* The panel keeps its tint on a phone but gives the copy its width back. */
    .si-head { padding: 16px 16px; }
    /* Let the strip scroll instead of squeezing six labels into 360px. */
    .si-tab { flex: 0 0 auto; padding: 10px 14px; font-size: 0.88rem; }
    .si-eyebrow-note { display: none; }
}
