/* ============================================================
   RADAR V2 — Stylesheet (option B "Softer": Fluent-familiar, soft-tinted,
   light+dark). One file, linked by every page.

   Referenced as radar-v2-style.css?v=N in every page's <link>, same
   convention as radar-v2-shell.js?v=N — a real host's cache headers
   (unlike the local dev server) will otherwise keep serving a stale
   copy to anyone who already loaded a page. Bump N and bulk-update
   every page (sed -i 's/style\.css?v=N/style.css?v=N+1/g' radar-v2-*.html)
   whenever this file changes.
   ============================================================ */

/* ── tokens ── (brand v2, option B "Deep Teal leads": Paper ground, white surfaces; Deep Teal for actions and active states,
   Instrument Blue for links and data, Signal Teal for graphics. Names kept from before so every page picks it up:
   --trace is the action / active colour (it was blue; it is Deep Teal now), --link and --data are the blue.) */
:root {
    --ink: #1B2433;
    --paper: #F7F9FC;
    --card: #FFFFFF;
    --steel: #5B6675;
    --steel-light: #9AA6B8;
    --line: #DCE4F0;
    --trace: #0B6B61;           /* Deep Teal — buttons, active nav, focus, eyebrow labels */
    --on-primary: #FFFFFF;      /* text on --trace */
    --link: #0F6CBD;            /* Instrument Blue — links */
    --data: #0F6CBD;            /* Instrument Blue — chart lines and data marks */
    --accent: #1C9E8E;          /* Signal Teal — graphics, indicators */
    --brand-teal: #1C9E8E;
    --text: #1B2433;
    --text-mute: #5F6B7D;
    --hover: #EDF5F3;
    --tint: #E1F2EF;

    /* condition scale — functional, not decorative. Do not restyle per-screen. Brand scale: Healthy, Watch, Alert, Critical;
       the app's fifth level (Urgent) is one step darker than Critical (#8E2420, not in the palette). Always paired with a label. */
    --sat: #2F9E6B;
    --nodata: #C7C3B6;
    --incons: #3E9FBF;
    --watch: #D9A400;
    --monitor: #E58A00;
    --action: #C8372D;
    --urgent: #8E2420;
    --overdue: #44546A;
    --bias: #7030A0;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(20,40,80,0.05), 0 1px 3px rgba(20,40,80,0.04);
    --shadow-md: 0 8px 24px rgba(20,40,80,0.12);
    --font: 'Public Sans','Segoe UI',system-ui,-apple-system,Arial,sans-serif;
    --mono: var(--font);
}

/* dark theme — toggle by setting data-theme="dark" on <html> or <body> */
:root[data-theme="dark"] {
    --paper: #14171A;
    --card: #1B212B;
    --line: #2C3644;
    --trace: #3CCFBA;
    --on-primary: #06201C;
    --link: #4FA3E8;
    --data: #4FA3E8;
    --accent: #3CCFBA;
    --text: #E6ECF5;
    --text-mute: #97A3B6;
    --steel-light: #6F7C90;
    --hover: #1E2A2B;
    --tint: #123A36;
    --monitor: #F5A524;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.5);
}

/* ── reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--text);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--link); }
a:hover { color: color-mix(in srgb, var(--link) 75%, black); }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   LAYOUT SHELLS
   Two variants: staff pages use .shell + .panel (sidebar nav).
   Site Access / Insights use .shell-flat + .topbar (lighter chrome).
   ============================================================ */

.shell {
    display: grid;
    grid-template-rows: 56px 1fr;
    min-height: 600px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.shell-body { display: grid; grid-template-columns: 184px 1fr; }
.shell-flat {
    max-width: 1000px;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* top command bar — every page: white bar, original RADAR logo, pill search */
.appbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: var(--card);
    color: var(--text);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(20,40,80,0.06);
    position: relative;
    z-index: 5;
}
/* brand v2 logo: light and dark artwork, switched by theme; below the phone breakpoint the mark stands alone */
.appbar .brand { display: flex; align-items: center; }
.appbar .brand img { display: none; height: 30px; width: auto; }
.appbar .brand .lg-l { display: block; }
:root[data-theme="dark"] .appbar .brand .lg-l { display: none; }
:root[data-theme="dark"] .appbar .brand .lg-d { display: block; }
@media (max-width: 420px) {
    .appbar .brand .lg-l, .appbar .brand .lg-d { display: none !important; }
    .appbar .brand .mk-l { display: block !important; }
    :root[data-theme="dark"] .appbar .brand .mk-l { display: none !important; }
    :root[data-theme="dark"] .appbar .brand .mk-d { display: block !important; }
}
.appbar .search {
    display: flex; align-items: center; gap: 9px;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: 999px; padding: 7px 16px; width: 320px;
}
.appbar .search:focus-within { border-color: var(--trace); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--trace) 18%, transparent); }
.appbar .search input {
    background: transparent; border: none; outline: none; color: var(--text);
    font-family: var(--font); font-size: 12px; width: 100%;
}
.appbar .search input::placeholder { color: var(--text-mute); }
.appbar .avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--trace); color: var(--on-primary);
    display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600;
}
/* a profile photo (set by js/auth.js applyAvatar): the picture replaces the initials, which pages go on writing as text */
.appbar .avatar.has-photo { background-size: cover; background-position: center; background-repeat: no-repeat; color: transparent; font-size: 0; }
.theme-toggle {
    width: 36px; height: 20px; border-radius: 10px; background: var(--steel-light);
    position: relative; cursor: pointer; transition: background 180ms ease;
}
.theme-toggle.on { background: var(--trace); }
.theme-toggle .knob {
    width: 16px; height: 16px; border-radius: 50%; background: #fff; position: absolute;
    top: 2px; left: 2px; transition: left 180ms ease; box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.theme-toggle.on .knob { left: 18px; }

/* sidebar nav (staff pages) — pill items, brand-tint when active */
.panel {
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 16px 0;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--text-mute);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background 150ms ease, color 150ms ease;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a .nav-ico { flex-shrink: 0; opacity: 0.85; }
.nav a.active { color: var(--trace); background: var(--tint); font-weight: 600; }
.nav a.active .nav-ico { opacity: 1; }
.nav-group-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--steel-light); padding: 16px 12px 5px; }
.nav-group-label:first-child { padding-top: 0; }

/* lighter top bar (Site Access / Insights) — legacy alias, prefer .appbar */
.topbar { background: var(--card); color: var(--text); border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; }
.site-switch { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-mute); }
.site-switch b { color: var(--text); font-weight: 500; }
.chev { color: var(--steel-light); font-size: 9px; }
.period { font-size: 11.5px; color: var(--text-mute); }

/* ============================================================
   CONTENT AREA
   ============================================================ */

.main { padding: 24px 28px; animation: fadeSlideIn 320ms ease; }

.titleblock {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(120deg, color-mix(in srgb, var(--trace) 12%, var(--card)) 0%, var(--card) 62%);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.tb-left .eyebrow { font-size: 10.5px; color: var(--trace); font-weight: 600; letter-spacing: 0.8px; margin-bottom: 4px; }
.tb-left h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.2px; }
.tb-right { text-align: right; font-size: 11px; color: var(--text-mute); }

.section-head { margin: 20px 0 10px; }
.section-head h2 { font-size: 13.5px; font-weight: 700; }
.section-head .note { font-size: 10.5px; color: var(--text-mute); margin-top: 2px; }
.section-head a { font-size: 11px; color: var(--link); text-decoration: none; }

.wave { display: none; }

/* ── task-page header pattern: action bar, breadcrumb, hero card ── */
.action-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.crumbs { font-size: 12px; color: var(--text-mute); margin-bottom: 12px; }
.crumbs a { color: var(--text-mute); text-decoration: none; }
.crumbs a:hover { color: var(--trace); }
.crumbs b { color: var(--text); font-weight: 600; }
.hero { background: linear-gradient(120deg, color-mix(in srgb, var(--trace) 16%, var(--card)) 0%, var(--card) 70%); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: var(--shadow-sm); }
.hero h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.2px; }
.hero-sub { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.hero-fields { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.hf { border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent); border-radius: var(--radius-md); padding: 8px 14px; min-width: 150px; }
.hf .lbl { font-size: 10.5px; color: var(--text-mute); }
.hf .val { font-size: 13.5px; font-weight: 600; margin-top: 1px; }
.prog { min-width: 200px; margin-left: 20px; }
.prog-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.prog-top span { font-weight: 600; }
.prog-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.prog-fill { height: 100%; width: 0; background: var(--trace); border-radius: 3px; transition: width 250ms ease; }
.hero .status-chip { margin-left: auto; align-self: flex-start; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.action-bar .btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── inline alarm-threshold editor (js/threshold-editor.js) ── */
.thr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.thr-sum { font-size: 10.5px; color: var(--text-mute); }
.thr-btn { font-family: inherit; font-size: 11px; font-weight: 600; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.thr-btn:hover:not(:disabled) { background: var(--hover); }
.thr-btn.primary { background: var(--trace); color: var(--on-primary); border-color: var(--trace); }
.thr-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.thr-editor { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.thr-title { font-size: 11px; font-weight: 600; margin-bottom: 8px; }
.thr-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.thr-row select, .thr-row input { font-family: inherit; font-size: 11.5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--text); }
.thr-row input { width: 72px; }
.thr-unit { font-size: 10.5px; color: var(--text-mute); }
.thr-rm { color: var(--text-mute); cursor: pointer; font-size: 11px; padding: 0 4px; }
.thr-rm:hover { color: var(--action); }
.thr-alert { font-size: 10.5px; color: var(--action); margin-top: 6px; }
.thr-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ============================================================
   KPI TILES
   ============================================================ */

.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 26px;
}
.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: transform 180ms ease, box-shadow 180ms ease;
}
.kpi:hover { box-shadow: var(--shadow-md); }
.kpi .label { font-size: 10.5px; letter-spacing: 0.3px; color: var(--text-mute); margin-bottom: 8px; font-weight: 600; }
.kpi .value { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.kpi .value.accent { color: var(--trace); }
.kpi .sub { font-size: 10px; margin-top: 4px; color: var(--steel-light); }
.kpi .sub.up { color: var(--action); }
.kpi .sub.down { color: var(--sat); }
.kpi .spark { display: block; }

/* ============================================================
   CONDITION TRACKER
   ============================================================ */

.tracker {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 14px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}
.trow {
    display: grid;
    grid-template-columns: 1.6fr repeat(6, 0.6fr);
    align-items: center;
    height: 34px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
}
.trow:last-child { border-bottom: none; }
.trow.head {
    background: color-mix(in srgb, var(--trace) 6%, var(--card));
    color: var(--text-mute);
    font-size: 10.5px;
    letter-spacing: 0.3px;
    font-weight: 600;
    height: 34px;
}
/* period labels (Mar, Apr...) must center-align to match the centered
   .cell dots below them — only the first column (Machine) stays left */
.trow.head > div:not(:first-child) { text-align: center; }
.mname { font-size: 11.5px; font-weight: 700; }
.mid { font-family: var(--mono); font-size: 9.5px; color: var(--text-mute); }
.cell { width: 16px; height: 16px; border-radius: var(--radius-sm); justify-self: center; display: inline-block; }

.legend { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 10px; color: var(--text-mute); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 9px; height: 9px; border-radius: var(--radius-sm); }

/* ============================================================
   TABLES
   ============================================================ */

table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th {
    background: color-mix(in srgb, var(--trace) 6%, var(--card));
    color: var(--text-mute);
    text-align: left;
    padding: 10px 14px;
    font-size: 10.5px;
    letter-spacing: 0.3px;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
td.mono { font-family: var(--mono); font-size: 10.5px; color: var(--text-mute); }

/* ============================================================
   CARDS — defects, programmes, side panels, generic component blocks
   ============================================================ */

.defect-card {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.defect-card:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--trace) 35%, var(--line)); }
.defect-card .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.defect-card .asset { font-size: 12px; font-weight: 600; }
.defect-card .meta { font-size: 10.5px; color: var(--text-mute); margin-top: 4px; }

.side-block { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.side-block .lbl { font-size: 9.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-mute); margin-bottom: 8px; font-weight: 600; }
.side-block .big { font-family: var(--font); font-weight: 700; font-size: 16.5px; margin-bottom: 4px; }
.side-block .note { font-size: 11px; color: var(--text-mute); }

.prog-card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 10px; box-shadow: var(--shadow-sm); }
.prog-card .name { font-size: 13px; font-weight: 600; }
.prog-card .ref { font-family: var(--mono); font-size: 10px; color: var(--text-mute); margin-top: 2px; }
.prog-card .meta { display: flex; gap: 20px; margin-top: 10px; font-size: 11px; color: var(--text-mute); }
.prog-card .meta b { color: var(--text); font-weight: 500; }
.prog-card .eng { text-align: right; font-size: 11px; color: var(--text-mute); }
.prog-card .eng .who { color: var(--text); font-size: 12px; margin-bottom: 2px; }

.comp-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.comp-block .comp-label { font-size: 10px; color: var(--text-mute); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ============================================================
   RANKED LISTS / BAR COMPARISONS (Insights)
   ============================================================ */

.rank-block { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.rank-block > .title, .sitebar-block > .title, .trend-block > .title { font-size: 13.5px; font-weight: 700; margin-bottom: 12px; }
.rankrow { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.rankrow:last-child { border-bottom: none; }
.rankrow .n { font-family: var(--mono); color: var(--text-mute); width: 20px; flex-shrink: 0; }
.rankrow .name { flex: 0 0 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rankrow .bar { flex: 1; height: 7px; background: color-mix(in srgb, var(--line) 70%, transparent); margin: 0 10px; border-radius: var(--radius-sm); overflow: hidden; }
.rankrow .bar .fill { height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--data) 70%, white), var(--data)); border-radius: var(--radius-sm); }
.rankrow .count { font-family: var(--mono); font-size: 11px; flex-shrink: 0; }

.sitebar-block { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 26px; box-shadow: var(--shadow-sm); }
.siterow { display: grid; grid-template-columns: 100px 1fr 36px; align-items: center; gap: 12px; padding: 7px 0; }
.siterow .sname { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barwrap { background: color-mix(in srgb, var(--line) 70%, transparent); height: 16px; border-radius: var(--radius-sm); overflow: hidden; display: flex; }
.barwrap .seg { height: 100%; }
.siterow .total { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--text-mute); }

.trend-block { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-lg); padding: 18px 20px 14px; margin-bottom: 28px; box-shadow: var(--shadow-sm); }
.trend-bars { display: flex; align-items: flex-end; gap: 14px; height: 110px; margin-bottom: 8px; }
.tbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.tbar .col { width: 100%; background: var(--data); opacity: 0.85; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tbar .lbl { font-size: 9.5px; color: var(--text-mute); margin-top: 6px; }
.tbar .val { font-family: var(--mono); font-size: 9.5px; margin-bottom: 4px; }
/* line-chart variant: render as SVG polyline/path + <circle> points using
   var(--trace); see design reference. Not expressible as CSS-only. */

.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }

/* ============================================================
   DAILY WORK — inbox + week grid
   ============================================================ */

.inbox { border: 1px dashed var(--steel-light); background: color-mix(in srgb, var(--trace) 4%, var(--card)); padding: 14px 16px; margin-bottom: 24px; border-radius: var(--radius-lg); }
.inbox .lbl { font-size: 10px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-mute); margin-bottom: 10px; }
.inbox-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.inbox-row:last-child { border-bottom: none; }
.inbox-row .hint { font-size: 10px; color: var(--steel-light); }

.week { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.daycol { background: var(--paper); min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.daycol .head { background: var(--card); padding: 8px 10px; font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-mute); border-bottom: 1px solid var(--line); font-weight: 600; }
.daycol .head b { color: var(--text); font-weight: 700; }
.card { background: var(--card); margin: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); font-size: 11px; transition: box-shadow 150ms ease, border-color 150ms ease; }
.card:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--trace) 30%, var(--line)); }
.card .type { font-size: 9px; color: var(--trace); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 3px; font-weight: 600; }
.card .site { font-size: 9.5px; color: var(--text-mute); margin-top: 3px; }
.card.done { opacity: 0.5; text-decoration: line-through; }

/* dashboard alert strip + day-grouped task list */
.alert { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: var(--radius-md); margin-bottom: 8px; font-size: 12px; }
.alert.overdue { background: color-mix(in srgb, var(--action) 14%, transparent); color: var(--action); border-left: 3px solid var(--action); }
.alert.project { background: color-mix(in srgb, var(--watch) 14%, transparent); color: var(--watch); border-left: 3px solid var(--watch); }
.alert.issue { background: color-mix(in srgb, var(--monitor) 16%, transparent); color: var(--monitor); border-left: 3px solid var(--monitor); cursor: pointer; }
.alert .tag { font-family: var(--mono); font-size: 10px; opacity: 0.75; }

/* ============================================================
   FORMS / BUTTONS / BADGES
   ============================================================ */

.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters span { font-size: 11.5px; font-weight: 500; padding: 6px 14px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; color: var(--text-mute); cursor: pointer; }
.filters span.active { background: var(--tint); color: var(--trace); border-color: color-mix(in srgb, var(--trace) 40%, var(--line)); font-weight: 600; }
.week-hdr { font-size: 10px; color: var(--text-mute); letter-spacing: 0.6px; text-transform: uppercase; margin: 20px 0 8px; }

.btn { display: inline-block; padding: 8px 18px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-family: inherit; transition: background 150ms ease, box-shadow 150ms ease; }
.btn-primary { background: var(--trace); color: var(--on-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--trace) 85%, black); box-shadow: var(--shadow-md); }
.btn-accent { background: var(--trace); color: var(--on-primary); }
.btn-accent:hover { background: color-mix(in srgb, var(--trace) 85%, black); box-shadow: var(--shadow-md); }
.btn-outline { background: var(--card); border: 1px solid var(--line); color: var(--text); }
.btn-outline:hover { background: var(--hover); }
.btn-add { padding: 7px 16px; border-radius: 999px; background: var(--trace); color: var(--on-primary); font-size: 11.5px; font-weight: 600; }

.badge, .pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 10px; font-weight: 600; }
/* severity-mapped badges — use these instead of ad-hoc colors */
.badge-sat { color: color-mix(in srgb, var(--sat) 68%, var(--text)); background: color-mix(in srgb, var(--sat) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--sat) 45%, var(--card)); }
.badge-nodata { color: color-mix(in srgb, var(--nodata) 68%, var(--text)); background: color-mix(in srgb, var(--nodata) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--nodata) 45%, var(--card)); }
.badge-incons { color: color-mix(in srgb, var(--incons) 68%, var(--text)); background: color-mix(in srgb, var(--incons) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--incons) 45%, var(--card)); }
.badge-watch { color: color-mix(in srgb, var(--watch) 68%, var(--text)); background: color-mix(in srgb, var(--watch) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--watch) 45%, var(--card)); }
.badge-monitor { color: color-mix(in srgb, var(--monitor) 68%, var(--text)); background: color-mix(in srgb, var(--monitor) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--monitor) 45%, var(--card)); }
.badge-action { color: color-mix(in srgb, var(--action) 68%, var(--text)); background: color-mix(in srgb, var(--action) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--action) 45%, var(--card)); }
.badge-urgent { color: color-mix(in srgb, var(--urgent) 68%, var(--text)); background: color-mix(in srgb, var(--urgent) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--urgent) 45%, var(--card)); }
.badge-overdue { color: color-mix(in srgb, var(--overdue) 68%, var(--text)); background: color-mix(in srgb, var(--overdue) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--overdue) 45%, var(--card)); }
.badge-bias { color: color-mix(in srgb, var(--bias) 68%, var(--text)); background: color-mix(in srgb, var(--bias) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--bias) 45%, var(--card)); }

.note {
    font-size: 10.5px;
    color: var(--text-mute);
    margin-bottom: 16px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--watch) 12%, transparent);
    border-left: 3px solid var(--watch);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* title-block variant used inside component demos (design system page) */
.tb { padding-left: 0; }
.tb .eyebrow { font-size: 9.5px; letter-spacing: 1px; color: var(--text-mute); margin-bottom: 3px; }
.tb h3 { font-size: 17px; font-weight: 600; }

/* ============================================================
   ADMIN SPLIT LAYOUT — list + detail form, shared by every admin
   CRUD page (Sites, Programmes, Machines, ...). One definition here,
   not reinvented per page.
   ============================================================ */

.admin-split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }

.list-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.list-panel-header { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 10px; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.list-panel-header .count { font-size: 10.5px; font-weight: 500; color: var(--text-mute); }
.list-search { width: 100%; padding: 8px 12px; border: none; border-bottom: 1px solid var(--line); background: var(--card); color: var(--text); font-family: inherit; font-size: 11.5px; outline: none; }
.list-items { max-height: 560px; overflow-y: auto; }
.list-item { padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; transition: background 120ms ease; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--hover); }
.list-item.active { background: var(--tint); box-shadow: inset 3px 0 0 var(--trace); }
.list-item .list-item-name { font-weight: 600; }
.list-item .list-item-sub { font-size: 10.5px; color: var(--text-mute); margin-top: 2px; }
.list-item.inactive { opacity: 0.5; }

.detail-panel { min-height: 200px; }
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.form-section-title { font-size: 12px; font-weight: 600; color: var(--text-mute); margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-mute); margin-bottom: 5px; }
.form-field input, .form-field select, .form-field textarea {
    width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--card); color: var(--text); font-family: inherit; font-size: 12px; outline: none;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--trace); box-shadow: 0 0 0 3px color-mix(in srgb, var(--trace) 18%, transparent); }
.form-field textarea { resize: vertical; min-height: 60px; }

.status-bar { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.status-bar .ref { font-size: 13px; font-weight: 700; }
.status-bar .actions { display: flex; gap: 8px; }

.empty-state { text-align: center; color: var(--text-mute); font-size: 12px; padding: 60px 20px; }

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
a:focus-visible, .btn:focus-visible, .nav a:focus-visible, input:focus-visible {
    outline: 2px solid var(--trace);
    outline-offset: 2px;
}

/* ============================================================
   MOBILE (<=768px) — the app previously had zero responsive
   handling at all (no media queries, no viewport meta tag on any
   page but login). Sidebar becomes a slide-over drawer instead of
   a fixed 184px column; list+detail and two-column layouts stack
   instead of squeezing side by side. Bespoke chart/grid layouts
   (Insights' site bars, Site Access's condition tracker, Daily
   Work's week grid) are left as horizontally-scrollable rather
   than redesigned — good enough to use, not yet a native-feeling
   mobile layout.
   ============================================================ */
.hamburger { display: none; }
.nav-scrim { display: none; }

@media (max-width: 768px) {
    .hamburger { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-right: 4px; background: none; border: none; color: var(--text); cursor: pointer; font-size: 18px; }
    .appbar .search { display: none; }
    .appbar .brand img { height: 26px; }

    .shell-body { grid-template-columns: 1fr; }
    /* .main is a 1fr grid item — its default min-width is 'auto', which
       means "at least as wide as my widest child's min-content." A page
       with a wide unwrapped table (radar-v2-dashboard.html's site
       summary, in particular) was using that to drag the WHOLE shell —
       appbar included — wider than the viewport; .shell's own
       overflow:hidden then silently clipped the excess instead of
       showing a scrollbar, cutting off the theme toggle/avatar on the
       right and the table's own last column or two. #siteTableWrap's
       overflow-x:auto (and .week's own overflow-x above) can only ever
       scroll their own oversized content instead of inflating their
       ancestors once this column is actually capped to the viewport. */
    .main { min-width: 0; }
    .panel {
        position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 400;
        transform: translateX(-100%); transition: transform 200ms ease; box-shadow: var(--shadow-md);
        overflow-y: auto;
    }
    .panel.open { transform: translateX(0); }
    .nav-scrim.open { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(20,30,50,0.4); z-index: 390; }

    .main { padding: 16px; }
    .titleblock { flex-wrap: wrap; gap: 10px; align-items: flex-start; }

    .admin-split { grid-template-columns: 1fr; }
    .twocol { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }

    .week { grid-template-columns: repeat(5, minmax(200px, 1fr)); overflow-x: auto; padding-bottom: 8px; }
    .planner-kpis { grid-template-columns: repeat(2, 1fr); }
    .week-grid { grid-template-columns: 1fr; }

    /* Shell-flat pages (Insights, Site Access) — already single-column
       main, just needs the same padding/kpi treatment. */
    .shell-flat { max-width: 100%; }

    /* Below 16px, iOS Safari force-zooms the whole page on focus and
       doesn't zoom back out on blur — every form field and the sidebar
       search box on every admin page was small enough to trigger this.
       Desktop keeps its tighter density; only the mobile layout bumps
       these to the 16px floor. */
    .form-field input, .form-field select, .form-field textarea { font-size: 16px; }
    .list-search { font-size: 16px; }
}

/* ── Brand motion ──────────────────────────────────────────────
   .rl   a loading line: the RADAR sweep turning beside the words. Put it on any element whose text is "Loading…".
   .live a small pulse mark: an instrument channel that reported inside the last 48 hours.
   Both stand still for visitors who ask for reduced motion (the loader falls back to the still mark). */
.rl { display: inline-flex; align-items: center; gap: 10px; }
.rl::before { content: ''; width: 22px; height: 22px; flex: none; background: url(brand/radar-mark-sweep-light.svg) center / contain no-repeat; }
:root[data-theme="dark"] .rl::before { background-image: url(brand/radar-mark-sweep-dark.svg); }
.live { display: inline-block; position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #1C9E8E); margin: 0 4px 0 2px; flex: none; vertical-align: middle; }
.live::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent, #1C9E8E); animation: live-ping 2.4s ease-out infinite; opacity: 0; }
@keyframes live-ping { 0% { transform: scale(1); opacity: .8; } 70%, 100% { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .rl::before { background-image: url(brand/radar-mark-small-light.svg); }
    :root[data-theme="dark"] .rl::before { background-image: url(brand/radar-mark-small-dark.svg); }
    .live::after { animation: none; }
}
