:root {
  /* status / brand accents */
  --primary: #4285f4;
  --primary-dark: #3367d6;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --error: #c62828;
  --error-bg: #ffebee;
  --warn: #f57c00;
  --warn-bg: #fff8e1;
  --warn-tint: #fff8e6;
  --info: #1565c0;
  --info-bg: #e3f2fd;

  /* structural — light defaults */
  --bg: #f7f8fa;
  --surface: #ffffff;       /* cards, topbar, table headers, dropdowns, inputs, slider knob */
  --surface-2: #fafafa;     /* client hover, log container */
  --surface-hover: #f3f6fc; /* table row hover */
  --border: #e0e0e0;
  --border-soft: #eee;      /* table cell borders, combo dividers */
  --text: #1f2937;
  --muted: #6b7280;

  /* brand blue (active nav, subtab, slider-on, sortable hover, login button) */
  --brand: #020381;
  --brand-hover: #01026a;
  --on-brand: #ffffff;
  --brand-tint: rgba(2, 3, 129, 0.06);
  --brand-tint-strong: rgba(2, 3, 129, 0.18);

  --shadow: rgba(8, 23, 52, 0.12);
  --shadow-strong: rgba(0, 0, 0, 0.12);

  /* buttons / logout / status dots */
  --btn-disabled: #c2c2c2;
  --btn-secondary-bg: #f1f1f1;
  --btn-secondary-hover: #e6e6e6;
  --logout-bg: #fde8e8;
  --logout-text: #b3261e;
  --logout-hover: #fbd5d5;
  --dot-green: #22c55e;
  --dot-red: #ef4444;
  --dot-gray: #cbd5e1;

  /* badge / status-select triples (good / warn / bad / neutral / blue) */
  --b-good-bg: #e6f7ef; --b-good-fg: #1b7a4b; --b-good-bd: #bfe6d2;
  --b-warn-bg: #fff4e0; --b-warn-fg: #9a6700; --b-warn-bd: #f0d9a8;
  --b-bad-bg: #fde8e8;  --b-bad-fg: #b3261e;  --b-bad-bd: #f3c0c0;
  --b-neu-bg: #eceff1;  --b-neu-fg: #5b6770;  --b-neu-bd: #d4dadd;
  --b-blue-bg: #e7f0ff; --b-blue-fg: #1a56c4; --b-blue-bd: #c5d8fb;
  /* donut slot colours — categorical, fixed order (see .pie-c* rules) */
  --pie-1: #2a78d6; --pie-2: #eb6834; --pie-3: #1baf7a; --pie-4: #eda100;
  --pie-5: #e87ba4; --pie-6: #008300; --pie-other: #8a93a3;
}

/* ====================================================================
   DARK THEME TOKENS
   Two selector blocks share the SAME values — KEEP IN SYNC.
   1) auto mode (no explicit choice) following an OS that prefers dark
   2) explicit [data-theme="dark"] (wins regardless of OS)
   Explicit light needs no block: [data-theme="light"] sets the attribute,
   so the auto selectors below stop matching and :root light defaults apply.
   ==================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  :root[data-theme="auto"] {
    --primary: #5a9bff;
    --primary-dark: #4886f0;
    --success: #7fd99a; --success-bg: #13301c;
    --error: #ff8d85;   --error-bg: #3a1f22;
    --warn: #e0b35a;    --warn-bg: #332813; --warn-tint: #332813;
    --info: #7fb2ff;    --info-bg: #16273f;

    --bg: #0f1419;
    --surface: #1a1f29;
    --surface-2: #222834;
    --surface-hover: #232b3a;
    --border: #2e3643;
    --border-soft: #262d39;
    --text: #e6e9ef;
    --muted: #9aa4b2;

    --brand: #5b6cff;
    --brand-hover: #4656e0;
    --on-brand: #ffffff;
    --brand-tint: rgba(91, 108, 255, 0.15);
    --brand-tint-strong: rgba(91, 108, 255, 0.30);

    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-strong: rgba(0, 0, 0, 0.6);

    --btn-disabled: #3a4250;
    --btn-secondary-bg: #2a313d;
    --btn-secondary-hover: #333c4a;
    --logout-bg: #3a1f22; --logout-text: #ff8d85; --logout-hover: #4a2429;
    --dot-gray: #4a5563;

    --b-good-bg: #13301c; --b-good-fg: #6fd89a; --b-good-bd: #1f5235;
    --b-warn-bg: #332813; --b-warn-fg: #e0b35a; --b-warn-bd: #5a4720;
    --b-bad-bg: #3a1f22;  --b-bad-fg: #ff8d85;  --b-bad-bd: #5a2c2f;
    --b-neu-bg: #262d39;  --b-neu-fg: #9aa4b2;  --b-neu-bd: #3a4250;
    --b-blue-bg: #16273f; --b-blue-fg: #7fb2ff; --b-blue-bd: #274468;
    /* donut slots, re-stepped for the dark surface — not a flip of the light set */
    --pie-1: #3987e5; --pie-2: #d95926; --pie-3: #199e70; --pie-4: #c98500;
    --pie-5: #d55181; --pie-6: #008300; --pie-other: #7b8595;
  }
}
:root[data-theme="dark"] {
  /* KEEP IN SYNC with the @media block above */
  --primary: #5a9bff;
  --primary-dark: #4886f0;
  --success: #7fd99a; --success-bg: #13301c;
  --error: #ff8d85;   --error-bg: #3a1f22;
  --warn: #e0b35a;    --warn-bg: #332813; --warn-tint: #332813;
  --info: #7fb2ff;    --info-bg: #16273f;

  --bg: #0f1419;
  --surface: #1a1f29;
  --surface-2: #222834;
  --surface-hover: #232b3a;
  --border: #2e3643;
  --border-soft: #262d39;
  --text: #e6e9ef;
  --muted: #9aa4b2;

  --brand: #5b6cff;
  --brand-hover: #4656e0;
  --on-brand: #ffffff;
  --brand-tint: rgba(91, 108, 255, 0.15);
  --brand-tint-strong: rgba(91, 108, 255, 0.30);

  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-strong: rgba(0, 0, 0, 0.6);

  --btn-disabled: #3a4250;
  --btn-secondary-bg: #2a313d;
  --btn-secondary-hover: #333c4a;
  --logout-bg: #3a1f22; --logout-text: #ff8d85; --logout-hover: #4a2429;
  --dot-gray: #4a5563;

  --b-good-bg: #13301c; --b-good-fg: #6fd89a; --b-good-bd: #1f5235;
  --b-warn-bg: #332813; --b-warn-fg: #e0b35a; --b-warn-bd: #5a4720;
  --b-bad-bg: #3a1f22;  --b-bad-fg: #ff8d85;  --b-bad-bd: #5a2c2f;
  --b-neu-bg: #262d39;  --b-neu-fg: #9aa4b2;  --b-neu-bd: #3a4250;
  --b-blue-bg: #16273f; --b-blue-fg: #7fb2ff; --b-blue-bd: #274468;
  /* donut slots, re-stepped for the dark surface — not a flip of the light set */
  --pie-1: #3987e5; --pie-2: #d95926; --pie-3: #199e70; --pie-4: #c98500;
  --pie-5: #d55181; --pie-6: #008300; --pie-other: #7b8595;
}

* { box-sizing: border-box; }

body {
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* Headlines in Montserrat (Futura PT Heavy equivalent); body stays Work Sans */
h1, h2, h3, .section-title, .kpi-label {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
.section-title { font-weight: 800; }

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  position: sticky;
  top: 0;
  z-index: 100;
}
/* "Performance Tracker" in Montserrat ExtraBold (Futura PT Heavy equivalent) */
header.topbar h1 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .01em; }
header.topbar h1 .brand-logo { height: 26px; width: auto; display: block; }
header.topbar nav { display: flex; gap: 4px; }
header.topbar .navitem { display: flex; }
header.topbar .navlink {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
}
header.topbar .navlink:hover { background: var(--bg); color: var(--text); }
header.topbar .navlink.active, header.topbar .navlink.active:hover { background: var(--brand); color: var(--on-brand); }
/* Hover sub-menu — a full-width single row of pills, mirroring the sub-tab bar.
   Only the CURRENT page's selected nav item shows one, and only once its
   sub-tab row has scrolled out of view (body.subbar-hidden, set in userbar.js).
   Hovering the other (non-selected) top items never opens a menu. The flyout is
   anchored to the sticky header (the .navitem is static), so it spans the full
   header width just like the real sub-tab bar. */
header.topbar .navmenu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  /* Centered bar, wider than the content column; pills bounded by this width
     (the row font-fit shrinks them only if they'd overflow it). */
  width: min(1640px, calc(100vw - 24px));
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 8px 18px var(--shadow);
  padding: 12px 20px;
  display: none;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  z-index: 200;
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
header.topbar .navmenu.open { display: flex; }
header.topbar .navmenu a {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: inherit;
  font-weight: 500;
  white-space: nowrap;
}
header.topbar .navmenu a:hover { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
header.topbar .spacer { flex: 1; }
header.topbar #userEmail { margin-right: 12px; }

main { max-width: 1200px; margin: 24px auto; padding: 0 20px; }

/* sub-tabs (Settings page: Import / Clients) */
.subtabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: nowrap; font-size: 14px; }
.subtab {
  flex: 0 0 auto; white-space: nowrap;
  padding: 8px 14px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; cursor: pointer; font-size: inherit; font-weight: 500; color: var(--muted);
}
.subtab:hover { background: var(--bg); }
.subtab.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

/* Buyer targets entry */
.bt-in.bt-warn { border-color: var(--warn); background: var(--warn-tint); }
.bt-row-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bt-row-status.saved { color: var(--success); font-weight: 600; }
/* Full-bleed pages (e.g. the schedule table) use the whole viewport width,
   keeping a small responsive gutter on either side. */
main.wide { max-width: none; padding: 0 clamp(12px, 2vw, 28px); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 15px; }

.btn {
  padding: 9px 16px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--btn-disabled); cursor: not-allowed; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--text); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-logout { background: var(--logout-bg); color: var(--logout-text); }
.btn-logout:hover { background: var(--logout-hover); }

label { display: block; margin: 8px 0 4px; font-weight: 500; }
/* Matches every text-entry input rather than an allow-list of type values, so
   a field like type="email" can't silently fall back to browser defaults (a
   different height and square corners next to the selects). Checkboxes,
   radios and buttons are excluded — they carry their own sizing. */
select,
input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]) {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: var(--surface); color: var(--text);
}
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin-right: 16px; }
.radio-row input { width: auto; }

/* Import client picker: 3-per-row grid of small checkbox boxes */
.client-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px; margin: 8px 0;
}
.client-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer;
}
.client-item:hover { background: var(--surface-2); }
.client-item input { width: auto; flex: 0 0 auto; }
.ci-info { display: flex; flex-direction: column; min-width: 0; }
.ci-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-item .meta { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-item .err { color: var(--error); font-size: 12px; }

.select-controls { display: flex; gap: 8px; margin-bottom: 8px; }

.status { margin-top: 12px; padding: 10px 12px; border-radius: 6px; display: none; }
.status.show { display: block; }
.status.info { background: var(--info-bg); color: var(--info); }
.status.success { background: var(--success-bg); color: var(--success); }
.status.error { background: var(--error-bg); color: var(--error); }
.status.warning { background: var(--warn-bg); color: var(--warn); }

.log-container {
  max-height: 360px; overflow-y: auto; margin-top: 12px; padding: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.log-entry { padding: 2px 0; border-bottom: 1px solid var(--border-soft); }
.log-entry:last-child { border-bottom: none; }
.log-entry.error { color: var(--error); }
.log-entry.success { color: var(--success); }
.log-entry.warning { color: var(--warn); }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 1s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* searchable dropdown (combobox) + selected chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--info-bg); color: var(--info);
  border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; font-weight: 600;
}
.chip-x { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.combo { position: relative; }
.combo-options {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  max-height: 300px; overflow-y: auto; margin-top: 4px;
  box-shadow: 0 8px 24px var(--shadow-strong);
}
.combo-option { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.combo-option:last-child { border-bottom: none; }
.combo-option:hover { background: var(--bg); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { min-width: 150px; }
.filters .field label { margin-top: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
table.data th { position: sticky; top: 0; background: var(--surface); border-bottom: 2px solid var(--border); }
.table-scroll { max-height: 600px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.muted { color: var(--muted); }

/* Row actions in a data table: small outlined buttons instead of bare links,
   so the hit target is a real control rather than a few pixels of text. */
.row-actions { display: flex; gap: 6px; }
.btn-row {
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1.6;
  cursor: pointer; white-space: nowrap;
}
.btn-row:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-row-danger { color: var(--error); }
.btn-row-danger:hover { background: var(--error-bg); border-color: var(--error); }
.row-count { color: var(--muted); margin: 8px 0; }

.login-wrap { max-width: 460px; margin: 12vh auto; }
.login-wrap .card { padding: 40px; }
.login-wrap .btn-primary { background: var(--brand); text-decoration: none; padding: 12px 16px; font-size: 15px; }
.login-wrap .btn-primary:hover { background: var(--brand-hover); }

/* ---- Dashboard ---- */
.dash-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.dash-controls .field { min-width: 130px; }
.dash-controls label { margin: 0 0 4px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.kpi .kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--text); }
.kpi .kpi-sub { font-size: 13px; margin-top: 4px; color: var(--muted); }

/* Notched radial gauge (% to Annual Target). Colours come from the theme vars,
   so light/dark are handled by the same rules. */
.kpi-gauge { display: flex; flex-direction: column; }
.kpi-gauge .gauge { display: block; width: 100%; max-width: 178px; height: auto; margin: 2px auto 0; }
.gauge-notch { stroke-width: 5; stroke-linecap: round; stroke: url(#gaugeTrackRamp); }
.gauge-notch.is-lit { stroke: url(#gaugeFillRamp); }
.gauge-value { text-anchor: middle; font-size: 30px; font-weight: 700; fill: currentColor; color: var(--text); }
/* Sized to clear the inner radius: any wider and the caption runs into the notches. */
.gauge-caption { text-anchor: middle; font-size: 12px; font-weight: 600; fill: currentColor; color: var(--muted); }

/* The gauge makes its tile taller than its plain-number neighbours; centring
   their values keeps the row from reading as three half-empty boxes. */
.kpi-vcenter { display: flex; flex-direction: column; }
.kpi-vcenter .kpi-value { margin-top: auto; margin-bottom: auto; padding: 6px 0; }

/* Notches fade in on a stagger; gauge.js sets --gauge-fade and the per-notch
   animation-delay so the whole sweep lands on its total duration. */
@media (prefers-reduced-motion: no-preference) {
  .gauge-notch.is-lit { animation: gauge-notch-in var(--gauge-fade, 280ms) ease-out both; }
  @keyframes gauge-notch-in { from { opacity: 0; } to { opacity: 1; } }
}

/* ===== Donut chart (Media Type Summary) =========================== */
/* Categorical slot colours, fixed order, never cycled — a 7th media type
   folds into .pie-other rather than getting a generated hue. Both columns
   validated for their own surface (lightness band, chroma floor, CVD and
   normal-vision separation on adjacent pairs). Three light-mode slots sit
   under 3:1 on white, which is why every value is labelled in the legend and
   the full table sits directly below. */
.pie-c0 { --slot: var(--pie-1); }
.pie-c1 { --slot: var(--pie-2); }
.pie-c2 { --slot: var(--pie-3); }
.pie-c3 { --slot: var(--pie-4); }
.pie-c4 { --slot: var(--pie-5); }
.pie-c5 { --slot: var(--pie-6); }
.pie-other { --slot: var(--pie-other); }

.pie-figure { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; padding: 18px; }
.pie { width: 100%; max-width: 230px; height: auto; flex: 0 0 auto; }
/* The 2px surface stroke is the gap between neighbouring slices. */
.pie-slice { fill: var(--slot); stroke: var(--surface); stroke-width: 2; transition: opacity .12s; }
.pie-figure:hover .pie-slice { opacity: .55; }
.pie-figure .pie-slice:hover { opacity: 1; }
.pie-total { text-anchor: middle; font-size: 21px; font-weight: 700; fill: var(--text); }
.pie-total-label { text-anchor: middle; font-size: 12px; font-weight: 600; fill: var(--muted);
                   text-transform: uppercase; letter-spacing: .04em; }

.pie-legend { flex: 1 1 240px; min-width: 240px; }
.pie-legend-row { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center;
                  gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border-soft); }
.pie-legend-row:last-child { border-bottom: 0; }
.pie-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--slot); }
.pie-legend-label { color: var(--text); font-weight: 600; }
.pie-legend-value { color: var(--text); font-variant-numeric: tabular-nums; }
.pie-legend-pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 46px;
                  text-align: right; }
.pie-empty { padding: 24px 18px; }

.quarters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.quarter { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; text-align: center; }
.quarter .q-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.quarter .q-value { font-size: 18px; font-weight: 700; margin-top: 4px; }

.delta-pos { color: var(--success); font-weight: 600; }
.delta-neg { color: var(--error); font-weight: 600; }
.delta-warn { color: var(--warn); font-weight: 600; }

/* signal + status badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.badge-growing { background: var(--b-good-bg); color: var(--b-good-fg); }
.badge-declining { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.badge-flat { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.badge-new { background: var(--b-blue-bg); color: var(--b-blue-fg); }
.badge-churned { background: var(--b-neu-bg); color: var(--b-neu-fg); }
.badge-annual { background: var(--b-good-bg); color: var(--b-good-fg); }
.badge-test { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.badge-renewal { background: var(--b-blue-bg); color: var(--b-blue-fg); }
.badge-canceled { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.badge-paused { background: var(--b-neu-bg); color: var(--b-neu-fg); }
.badge-ontrack { background: var(--b-good-bg); color: var(--b-good-fg); }
.badge-atrisk { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.badge-behind { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.badge-notarget { background: var(--b-neu-bg); color: var(--b-neu-fg); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* editable brand status dropdown (super_admin) / read-only badge (everyone else) */
select.bs-status { width: auto; min-width: 110px; padding: 5px 8px; font-size: 13px; }
.bs-status-ro { display: inline-block; padding: 5px 10px; font-size: 13px; border-radius: 4px; border: 1px solid transparent; }
.bs-status.st-annual,    .bs-status-ro.st-annual    { background: var(--b-good-bg); color: var(--b-good-fg); border-color: var(--b-good-bd); font-weight: 600; }
.bs-status.st-test,      .bs-status-ro.st-test      { background: var(--b-warn-bg); color: var(--b-warn-fg); border-color: var(--b-warn-bd); font-weight: 600; }
.bs-status.st-renewal,   .bs-status-ro.st-renewal   { background: var(--b-blue-bg); color: var(--b-blue-fg); border-color: var(--b-blue-bd); font-weight: 600; }
.bs-status.st-cancelled, .bs-status-ro.st-cancelled { background: var(--b-bad-bg); color: var(--b-bad-fg); border-color: var(--b-bad-bd); font-weight: 600; }
.bs-status.st-paused,    .bs-status-ro.st-paused    { background: var(--b-neu-bg); color: var(--b-neu-fg); border-color: var(--b-neu-bd); font-weight: 600; }
select.bs-status.saved-flash { box-shadow: 0 0 0 2px rgba(34,197,94,.35); }
select.bs-status.save-error  { box-shadow: 0 0 0 2px rgba(239,68,68,.35); }

/* row hover highlight across all data tables (skip virtualized spacer rows) */
table.data tbody tr:not([data-spacer]):hover { background: var(--surface-hover); }
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 10px; }

/* shared-with-service-account status dots */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--dot-gray); vertical-align: middle; }
.dot-green { background: var(--dot-green); }
.dot-red { background: var(--dot-red); }
.dot-gray { background: var(--dot-gray); }
.legend { color: var(--muted); font-size: 12px; margin: 8px 0; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.legend .item { display: inline-flex; gap: 6px; align-items: center; }

/* Changelog (Settings) */
.changelog { list-style: none; margin: 12px 0 0; padding: 0; }
.changelog-item { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.changelog-item:first-child { border-top: none; }
.changelog-when { flex: 0 0 130px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.changelog-title { font-weight: 600; font-size: 14px; }
.changelog-summary { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.45; }

/* Sortable table headers (Schedule) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--brand-tint); }
th.sortable::after { content: "\2195"; opacity: 0.25; margin-left: 4px; font-size: 11px; }
th.sortable.sort-asc::after { content: "\2191"; opacity: 0.9; }
th.sortable.sort-desc::after { content: "\2193"; opacity: 0.9; }

/* Resizable table columns (Schedule) */
.data th { position: relative; }
.col-resizer { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; user-select: none; touch-action: none; }
.col-resizer:hover { background: var(--brand-tint-strong); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* Network & Show Summary — two tables side by side */
.ns-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; }

/* Q2-vs-Q1 NEW flag (Network Summary) */
.delta-new { color: var(--b-blue-fg); font-weight: 600; }

/* Collapsible section header (Account Health) */
.section-toggle { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
.section-toggle .caret { font-size: 12px; color: var(--muted); width: 12px; display: inline-block; }
.section-toggle:hover .caret { color: var(--text); }

/* Slider toggles (Monthly Summary graph/table visibility) */
.switch-row { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--dot-gray); border-radius: 999px; transition: background .2s; }
.switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--surface); border-radius: 50%; transition: transform .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* Deactivated brands in Settings → Clients (both the Ticker and Active
   toggle cells stay full-opacity so they are still obviously clickable). */
#cl-tbody tr.inactive-row td { opacity: .45; }
#cl-tbody tr.inactive-row td:has(.switch) { opacity: 1; }

/* Theme toggle (segmented System / Light / Dark control in the top bar) */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 2px; margin-right: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface);
}
.theme-toggle button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px;
}
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.on { background: var(--brand); color: var(--on-brand); }

/* Inline text button (e.g. expandable error count in the import log) */
.link-btn {
  border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: underline;
}
.err-list { margin: 4px 0; padding-left: 18px; white-space: normal; }
.err-list li { padding: 2px 0; }

/* ---- Brand ticker bar (Dashboard) ---------------------------------------- */
.ticker-bar {
  overflow: hidden;
  /* Always black, both themes — so the item colors below are fixed rather
     than theme vars (light mode's --text would vanish on black). */
  background: #000;
  color: #e6e6e6;
  border-bottom: 1px solid var(--border);
  /* Stock-ticker look: JetBrainsMono Nerd Font where installed locally; the
     Google-served JetBrains Mono fallback is glyph-identical for everything
     the ticker renders, so all users see the same thing. */
  font-family: 'JetBrainsMono Nerd Font', 'JetBrainsMono NF', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  line-height: 1;
  padding: 7px 0;
  white-space: nowrap;
}
.ticker-track {
  display: inline-flex;
  animation: ticker-scroll var(--ticker-duration, 60s) linear infinite;
}
.ticker-bar:hover .ticker-track { animation-play-state: paused; }
.ticker-half { display: inline-flex; }
.ticker-item { padding: 0 18px; cursor: default; }
.ticker-symbol { font-weight: 700; color: #fff; }
.ticker-flat { color: #9a9a9a; }
.ticker-bar .delta-pos { color: #4ade80; }
.ticker-bar .delta-neg { color: #f87171; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}
