/* ==========================================================================
   i-School Consult - application stylesheet
   Layers: 1 fonts + tokens, 2 base + Bootstrap bridge, 3 shell, 4 components,
   5 data display (KPIs, charts, health checks), 6 page-specific, 7 Choices.js.
   Every colour comes from a token. A school's primary colour arrives as
   --brand-purple (+ --brand-ink / --brand-glow / --on-brand, computed server-side
   so they are always readable) and the whole interface derives from it.
   Light and dark themes: <html data-theme="light|dark"> (set by theme.js; falls
   back to the OS setting).
   ========================================================================== */

/* ---------- 1. Fonts + tokens ---------- */
@font-face {
  font-family: "Inter Variable";
  font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* School brand (overridden per school by TenantBranding.ThemeCss) */
  --brand-purple: #5b2a86;
  --brand-purple-dark: #401d5e;
  --brand-purple-darker: #2e1543;
  --brand-ink: #5b2a86;
  --brand-glow: #a36dd1;
  --on-brand: #ffffff;

  /* Surfaces + text (light) */
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f0f0ed;
  --line: #e7e6e1;
  --line-strong: #d3d2cb;
  --text: #171716;
  --text-2: #4f4e49;
  --text-3: #6b6a64;

  /* Accent (derived from the school colour) */
  --accent: var(--brand-purple);
  --on-accent: var(--on-brand);
  --accent-ink: var(--brand-ink);
  --accent-hover: color-mix(in srgb, var(--accent) 86%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --accent-softer: color-mix(in srgb, var(--accent) 5%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 28%, var(--surface));
  --focus-ring: color-mix(in srgb, var(--accent) 32%, transparent);

  /* Status: fixed hues (dataviz palette) with text-safe inks */
  --good: #0ca30c;   --good-ink: #0b6b0b;
  --warn: #fab219;   --warn-ink: #885200;
  --serious: #ec835a; --serious-ink: #a43e0e;
  --crit: #d03b3b;   --crit-ink: #b42828;
  --good-bg: color-mix(in srgb, var(--good) 13%, var(--surface));
  --warn-bg: color-mix(in srgb, var(--warn) 20%, var(--surface));
  --serious-bg: color-mix(in srgb, var(--serious) 17%, var(--surface));
  --crit-bg: color-mix(in srgb, var(--crit) 12%, var(--surface));

  /* Chart series (fixed order, validated; dark steps below) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --chart-grid: #e7e6e1; --chart-axis: #c3c2b7; --chart-text: #4f4e49; --chart-muted: #6b6a64;

  /* Legacy aliases used by older views */
  --status-good: var(--good); --status-good-bg: var(--good-bg);
  --status-warning: var(--warn); --status-warning-bg: var(--warn-bg);
  --status-serious: var(--serious); --status-serious-bg: var(--serious-bg);
  --status-critical: var(--crit); --status-critical-bg: var(--crit-bg);
  --ok-green: var(--good-ink); --ok-bg: var(--good-bg);
  --review-amber: var(--warn-ink); --review-bg: var(--warn-bg);
  --investigate-red: var(--crit-ink); --investigate-bg: var(--crit-bg);

  /* Shape + depth */
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 18, 14, .05);
  --shadow: 0 1px 2px rgba(20, 18, 14, .04), 0 4px 16px rgba(20, 18, 14, .05);
  --shadow-lg: 0 12px 40px rgba(20, 18, 14, .16);

  --sidebar-w: 264px;
  color-scheme: light;
}

/* Dark theme: explicit choice, or the OS setting when no choice was made. */
:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --surface: #1a1a19;
  --surface-2: #20201e;
  --surface-3: #2a2a27;
  --line: #2f2f2b;
  --line-strong: #43433e;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9d9c93;

  --accent: var(--brand-glow);
  --on-accent: #0e0e0d;
  --accent-ink: var(--brand-glow);
  --accent-hover: color-mix(in srgb, var(--accent) 88%, #fff);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
  --accent-softer: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 38%, var(--surface));

  --good-ink: #5fd25f; --warn-ink: #f5b83d; --serious-ink: #f2976f; --crit-ink: #f07a7a;
  --good-bg: color-mix(in srgb, var(--good) 22%, var(--surface));
  --warn-bg: color-mix(in srgb, var(--warn) 20%, var(--surface));
  --serious-bg: color-mix(in srgb, var(--serious) 20%, var(--surface));
  --crit-bg: color-mix(in srgb, var(--crit) 24%, var(--surface));

  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --chart-grid: #2f2f2b; --chart-axis: #43433e; --chart-text: #c3c2b7; --chart-muted: #9d9c93;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0d;
    --surface: #1a1a19;
    --surface-2: #20201e;
    --surface-3: #2a2a27;
    --line: #2f2f2b;
    --line-strong: #43433e;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9d9c93;

    --accent: var(--brand-glow);
    --on-accent: #0e0e0d;
    --accent-ink: var(--brand-glow);
    --accent-hover: color-mix(in srgb, var(--accent) 88%, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
    --accent-softer: color-mix(in srgb, var(--accent) 9%, var(--surface));
    --accent-line: color-mix(in srgb, var(--accent) 38%, var(--surface));

    --good-ink: #5fd25f; --warn-ink: #f5b83d; --serious-ink: #f2976f; --crit-ink: #f07a7a;
    --good-bg: color-mix(in srgb, var(--good) 22%, var(--surface));
    --warn-bg: color-mix(in srgb, var(--warn) 20%, var(--surface));
    --serious-bg: color-mix(in srgb, var(--serious) 20%, var(--surface));
    --crit-bg: color-mix(in srgb, var(--crit) 24%, var(--surface));

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --chart-grid: #2f2f2b; --chart-axis: #43433e; --chart-text: #c3c2b7; --chart-muted: #9d9c93;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- 2. Base + Bootstrap bridge ---------- */
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  --bs-body-font-family: "Inter Variable", system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--text);
  --bs-body-color-rgb: 23, 23, 22;
  --bs-body-bg: var(--bg);
  --bs-secondary-color: var(--text-3);
  --bs-emphasis-color: var(--text);
  --bs-border-color: var(--line);
  --bs-border-color-translucent: var(--line);
  --bs-link-color: var(--accent-ink);
  --bs-link-hover-color: var(--accent-hover);
  --bs-link-color-rgb: 91, 42, 134;
  --bs-heading-color: var(--text);
  --bs-border-radius: 10px;
  --bs-border-radius-sm: 8px;
  --bs-border-radius-lg: 14px;
  --bs-tertiary-bg: var(--surface-3);
  --bs-secondary-bg: var(--surface-3);
  --bs-form-control-bg: var(--surface);
  font-family: var(--bs-body-font-family);
  font-feature-settings: "cv11", "ss03";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root[data-theme="dark"] body { --bs-body-color-rgb: 240, 239, 236; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--text); letter-spacing: -.015em; font-weight: 650; }
h1, .h1 { font-size: 1.7rem; letter-spacing: -.025em; font-weight: 700; }
h1.h3 { font-size: 1.55rem; letter-spacing: -.022em; font-weight: 700; }
h2.h5 { font-size: 1.05rem; font-weight: 650; }
.text-muted { color: var(--text-3) !important; }
.small, small { font-size: .84rem; }
a { color: var(--accent-ink); text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }
hr { border-color: var(--line); opacity: 1; }
.num, .metric-value, .stat-value, td.text-end, th.text-end { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Buttons */
.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: 10px;
  --bs-btn-padding-x: .95rem;
  --bs-btn-padding-y: .48rem;
  --bs-btn-font-size: .9rem;
  letter-spacing: -.005em;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease, transform .06s ease;
}
.btn:active { transform: translateY(.5px); }
.btn-sm { --bs-btn-padding-x: .7rem; --bs-btn-padding-y: .32rem; --bs-btn-font-size: .83rem; --bs-btn-border-radius: 8px; }
.btn-lg { --bs-btn-padding-x: 1.25rem; --bs-btn-padding-y: .7rem; --bs-btn-font-size: 1rem; --bs-btn-border-radius: 12px; }

.btn-brand, .btn-primary {
  --bs-btn-color: var(--on-accent);
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--on-accent);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-color: var(--on-accent);
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
  --bs-btn-disabled-color: var(--on-accent);
  --bs-btn-disabled-bg: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
  --bs-btn-focus-shadow-rgb: 0, 0, 0;
  box-shadow: var(--shadow-sm);
}
.btn-brand:focus-visible, .btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--focus-ring); }

.btn-outline-secondary, .btn-outline-brand, .btn-light {
  --bs-btn-color: var(--text);
  --bs-btn-bg: var(--surface);
  --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-color: var(--text);
  --bs-btn-hover-bg: var(--surface-3);
  --bs-btn-hover-border-color: var(--line-strong);
  --bs-btn-active-color: var(--text);
  --bs-btn-active-bg: var(--surface-3);
  --bs-btn-active-border-color: var(--line-strong);
  --bs-btn-disabled-color: var(--text-3);
  --bs-btn-disabled-bg: var(--surface-2);
  --bs-btn-disabled-border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-outline-brand { --bs-btn-color: var(--accent-ink); --bs-btn-border-color: var(--accent-line); --bs-btn-hover-color: var(--accent-ink); --bs-btn-hover-bg: var(--accent-soft); --bs-btn-hover-border-color: var(--accent); }
.btn-outline-danger {
  --bs-btn-color: var(--crit-ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: color-mix(in srgb, var(--crit) 45%, var(--line));
  --bs-btn-hover-color: var(--crit-ink); --bs-btn-hover-bg: var(--crit-bg); --bs-btn-hover-border-color: var(--crit);
  --bs-btn-active-color: var(--crit-ink); --bs-btn-active-bg: var(--crit-bg); --bs-btn-active-border-color: var(--crit);
  box-shadow: var(--shadow-sm);
}
.btn-danger { --bs-btn-bg: var(--crit); --bs-btn-border-color: var(--crit); --bs-btn-hover-bg: color-mix(in srgb, var(--crit) 86%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--crit) 86%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--crit) 80%, #000); --bs-btn-active-border-color: color-mix(in srgb, var(--crit) 80%, #000); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-link { --bs-btn-color: var(--accent-ink); --bs-btn-hover-color: var(--accent-hover); --bs-btn-font-weight: 600; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn-check:checked + .btn-outline-secondary, .btn-outline-secondary.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.btn-close { opacity: .55; }
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* Forms */
.form-label { font-weight: 600; font-size: .84rem; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select {
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: .52rem .8rem;
  font-size: .94rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.form-control-sm, .form-select-sm { border-radius: 8px; padding: .3rem .6rem; font-size: .86rem; }
.form-control::placeholder { color: var(--text-3); opacity: .8; }
.form-control:focus, .form-select:focus { background-color: var(--surface); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface-3); color: var(--text-2); opacity: 1; }
.form-control-plaintext { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.form-text { color: var(--text-3); font-size: .8rem; }
.form-check-input { border-color: var(--line-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.form-switch .form-check-input:checked { background-color: var(--accent); }
.input-group-text { background: var(--surface-3); border-color: var(--line-strong); color: var(--text-2); }
.invalid-feedback, .text-danger, .field-validation-error { color: var(--crit-ink) !important; }
.is-invalid, .input-validation-error { border-color: var(--crit) !important; }
:root[data-theme="dark"] .form-select { --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23c3c2b7' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }

/* Alerts: quiet tinted banners */
.alert {
  --bs-alert-border-radius: 12px;
  --bs-alert-padding-x: 1rem;
  --bs-alert-padding-y: .8rem;
  border-width: 1px; border-style: solid; font-size: .92rem;
  box-shadow: var(--shadow-sm);
}
.alert-success { background: var(--good-bg); color: var(--text); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); border-left: 4px solid var(--good); }
.alert-warning { background: var(--warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); border-left: 4px solid var(--warn); }
.alert-danger { background: var(--crit-bg); color: var(--text); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); border-left: 4px solid var(--crit); }
.alert-info { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); border-left: 4px solid var(--accent); }
.alert-light { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.alert .alert-link, .alert a { color: var(--accent-ink); font-weight: 600; }

/* Cards */
.card {
  --bs-card-bg: var(--surface);
  --bs-card-border-color: var(--line);
  --bs-card-border-radius: var(--radius);
  --bs-card-inner-border-radius: calc(var(--radius) - 1px);
  --bs-card-cap-bg: var(--surface);
  --bs-card-color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); color: var(--text); font-weight: 650; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--line); }
.control-card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.control-card.card { overflow: visible; }

/* Card titles: replaces the old solid coloured bars */
.section-header, .section-subheader {
  background: var(--surface);
  color: var(--text);
  padding: .85rem 1.15rem;
  font-weight: 650;
  font-size: .98rem;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; gap: .55rem;
}
.section-header::before {
  content: ""; width: 4px; height: 1.05em; border-radius: 3px; background: var(--accent); flex-shrink: 0;
}
.section-subheader { font-size: .9rem; color: var(--text-2); background: var(--surface-2); }

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  --bs-table-striped-bg: var(--surface-2);
  --bs-table-hover-bg: var(--accent-softer);
  --bs-table-hover-color: var(--text);
  margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .72rem 1rem; background-color: var(--bs-table-bg); }
.table-sm > :not(caption) > * > * { padding: .5rem .85rem; }
.table thead th {
  font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom-width: 0; }
.table tfoot td, .table tfoot th { background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.table-hover > tbody > tr:hover > * { background-color: var(--accent-softer); }
.table td, .table th { vertical-align: middle; }
.table-responsive { border-radius: inherit; }
.table-light, .table-light > th, .table-light > td { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text); }
.bg-light, .text-bg-light { background-color: var(--surface-3) !important; color: var(--text) !important; }
.border { border-color: var(--line) !important; }
.border-top, .border-bottom { border-color: var(--line) !important; }

/* Badges + status pills */
.badge {
  --bs-badge-padding-x: .6em; --bs-badge-padding-y: .34em; --bs-badge-font-weight: 600; --bs-badge-border-radius: 999px; --bs-badge-font-size: .74rem;
  letter-spacing: .01em;
}
.badge.status-ok { background: var(--good-bg); color: var(--good-ink); }
.badge.status-review { background: var(--warn-bg); color: var(--warn-ink); }
.badge.status-investigate { background: var(--crit-bg); color: var(--crit-ink); }
.badge.bg-secondary { background: var(--surface-3) !important; color: var(--text-2) !important; }
.badge.bg-success { background: var(--good-bg) !important; color: var(--good-ink) !important; }
.badge.bg-danger { background: var(--crit) !important; color: #fff !important; }
.badge.bg-warning { background: var(--warn-bg) !important; color: var(--warn-ink) !important; }
.badge.bg-info { background: var(--accent-soft) !important; color: var(--accent-ink) !important; }
.role-badge { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.status-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .32rem .8rem .32rem .65rem; border-radius: 999px;
  font-weight: 650; font-size: .82rem; letter-spacing: .02em; text-transform: uppercase;
}
.status-pill.reconciled { background: var(--good-bg); color: var(--good-ink); }
.status-pill.attention { background: var(--crit-bg); color: var(--crit-ink); }
.status-dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.green { background-color: var(--good); }
.status-dot.red { background-color: var(--crit); }

/* Tabs: underline style */
.nav-pills.control-tabs, .control-tabs {
  display: flex; flex-wrap: nowrap !important; gap: .15rem !important; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--line); margin-bottom: 1.1rem !important; padding: 0 .15rem;
}
.control-tabs .nav-item { flex: 0 0 auto; }
.control-tabs .nav-link {
  color: var(--text-2); font-weight: 600; font-size: .9rem; background: transparent;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: .75rem .95rem; margin-bottom: -1px; white-space: nowrap;
  transition: color .14s ease, border-color .14s ease, background-color .14s ease;
}
.control-tabs .nav-link:hover { color: var(--text); background: var(--surface-3); border-radius: 8px 8px 0 0; }
.control-tabs .nav-link.active { color: var(--accent-ink); background: transparent; border-bottom-color: var(--accent); }
.nav-tabs { --bs-nav-tabs-border-color: var(--line); --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--surface); --bs-nav-tabs-link-active-color: var(--accent-ink); --bs-nav-link-color: var(--text-2); --bs-nav-link-hover-color: var(--text); }

/* Modals, dropdowns */
.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-weight: 650; }
.modal-backdrop { --bs-backdrop-opacity: .5; }
.dropdown-menu {
  --bs-dropdown-bg: var(--surface); --bs-dropdown-color: var(--text); --bs-dropdown-border-color: var(--line);
  --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: var(--surface-3); --bs-dropdown-link-hover-color: var(--text);
  --bs-dropdown-link-active-bg: var(--accent-soft); --bs-dropdown-link-active-color: var(--accent-ink); --bs-dropdown-divider-bg: var(--line);
  --bs-dropdown-border-radius: 12px; --bs-dropdown-padding-y: .4rem; --bs-dropdown-item-padding-x: .9rem;
  box-shadow: var(--shadow-lg); font-size: .9rem;
}
.dropdown-item { border-radius: 8px; margin: 0 .35rem; width: calc(100% - .7rem); padding: .5rem .65rem; font-weight: 500; }

/* Pagination */
.pagination {
  --bs-pagination-color: var(--text-2); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--line);
  --bs-pagination-hover-color: var(--accent-ink); --bs-pagination-hover-bg: var(--accent-soft); --bs-pagination-hover-border-color: var(--accent-line);
  --bs-pagination-focus-color: var(--accent-ink); --bs-pagination-focus-bg: var(--accent-soft); --bs-pagination-focus-box-shadow: 0 0 0 3px var(--focus-ring);
  --bs-pagination-active-color: var(--on-accent); --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent);
  --bs-pagination-disabled-color: var(--text-3); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-disabled-border-color: var(--line);
  --bs-pagination-border-radius: 8px; gap: .25rem;
}
.pagination .page-link { border-radius: 8px !important; font-weight: 600; font-size: .86rem; }
@media (max-width: 575.98px) { .pagination { --bs-pagination-padding-x: .55rem; --bs-pagination-padding-y: .35rem; --bs-pagination-font-size: .88rem; } }

/* ---------- 3. Application shell ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

.app-sidebar {
  --bs-offcanvas-width: var(--sidebar-w);
  --bs-offcanvas-bg: var(--surface);
  --bs-offcanvas-color: var(--text);
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); color: var(--text);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; }
}

.app-sidebar-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 1.05rem 1.1rem .95rem; flex-shrink: 0;
}
.app-sidebar-brand {
  color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .7rem; line-height: 1.2; min-width: 0;
}
.app-sidebar-brand:hover { color: var(--text); }
.app-sidebar-logo {
  height: 40px; width: 40px; object-fit: contain; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 3px; flex-shrink: 0;
}
.app-sidebar-brand-text { font-weight: 700; font-size: .98rem; letter-spacing: -.015em; }
.app-sidebar .btn-close { filter: none; }
:root[data-theme="dark"] .app-sidebar .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

.app-sidebar-body { display: flex; flex-direction: column; flex: 1 1 auto; padding: .35rem .75rem 1rem; }
.app-sidebar-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .12rem; flex: 1 1 auto; }

.app-nav-section {
  padding: 1.15rem .7rem .4rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3);
}
.app-nav-section:first-child { padding-top: .5rem; }
.app-nav-section[role="button"] {
  display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none;
  padding-top: .6rem; padding-bottom: .5rem; border-radius: 8px;
}
.app-nav-section[role="button"]:hover { color: var(--text-2); background: var(--surface-3); }
.app-nav-section[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-nav-chevron { display: inline-flex; transition: transform .15s ease; transform: rotate(-90deg); }
.app-nav-section.is-open .app-nav-chevron, .app-sidebar-nav.is-filtering .app-nav-chevron { transform: none; }
.app-sidebar-nav .nav-collapsed, .app-sidebar-nav .nav-filtered-out { display: none; }
.app-nav-search { padding: .35rem .1rem .25rem; }
.app-nav-search-input {
  width: 100%; padding: .45rem .7rem; font-size: .88rem; color: var(--text); background: var(--surface-3);
  border: 1px solid var(--line); border-radius: 10px;
}
.app-nav-search-input:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }

.app-nav-link {
  position: relative; display: flex; align-items: center; gap: .7rem;
  padding: .56rem .7rem; border-radius: 10px; color: var(--text-2); text-decoration: none;
  font-weight: 550; font-size: .91rem; letter-spacing: -.005em;
  transition: background-color .12s ease, color .12s ease;
}
.app-nav-icon { display: inline-flex; flex-shrink: 0; color: var(--text-3); transition: color .12s ease; }
.app-nav-link:hover { background: var(--surface-3); color: var(--text); }
.app-nav-link:hover .app-nav-icon { color: var(--text-2); }
.app-nav-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.app-nav-link.active .app-nav-icon { color: var(--accent-ink); }
.app-nav-link.active::before {
  content: ""; position: absolute; left: -.75rem; top: 22%; bottom: 22%; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent);
}

.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.app-content { flex: 1 0 auto; padding: 0 1.75rem 1.5rem; width: 100%; max-width: 1440px; margin-inline: auto; }
@media (max-width: 575.98px) { .app-content { padding: 0 1rem 1.25rem; } }

.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1.75rem; min-height: 60px;
}
@media (max-width: 575.98px) { .app-topbar { padding: .55rem 1rem; } }
.app-topbar-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.app-topbar-title { font-weight: 650; font-size: 1rem; letter-spacing: -.012em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar-right { display: flex; align-items: center; gap: .55rem; }
.app-topbar-date { color: var(--text-3); font-size: .84rem; margin-right: .35rem; }
.app-topbar-divider { display: none; }
.app-topbar-toggle, .icon-btn {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); box-shadow: var(--shadow-sm);
  transition: background-color .12s ease, color .12s ease; padding: 0;
}
.app-topbar-toggle:hover, .icon-btn:hover { background: var(--surface-3); color: var(--text); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.app-topbar-user { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: .6rem; padding: .25rem .65rem .25rem .3rem; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); box-shadow: var(--shadow-sm); text-align: left;
}
.user-menu-btn:hover { background: var(--surface-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; letter-spacing: .02em; flex-shrink: 0;
}
.user-menu-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-topbar-user-name { font-weight: 650; font-size: .84rem; color: var(--text); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: .72rem; color: var(--text-3); font-weight: 550; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-btn .chev { color: var(--text-3); flex-shrink: 0; }
.user-menu .dropdown-menu { min-width: 250px; margin-top: .5rem !important; }
.user-menu-head { padding: .6rem 1rem .5rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.user-menu-head .n { font-weight: 650; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.user-menu-head .e { font-size: .8rem; color: var(--text-3); overflow-wrap: anywhere; }

footer.footer {
  background: transparent; border-top: 1px solid var(--line); padding: .85rem 1.75rem; font-size: .8rem; flex-shrink: 0;
  display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 1.5rem; row-gap: .15rem; color: var(--text-3);
}
.app-main footer.footer { position: static; width: auto; white-space: normal; line-height: 1.5; }
footer.footer .footer-powered { white-space: nowrap; }
footer.footer .footer-powered strong { color: var(--text-2); font-weight: 650; }

/* Page header pattern */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 1.25rem; }
.page-header h1 { margin: 0; }
.page-header .page-sub { color: var(--text-3); margin: .2rem 0 0; font-size: .92rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); }

/* Flash messages auto-dismiss */
.flash { animation: flash-in .25s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .3s ease, transform .3s ease; }

/* Empty states */
.empty-state { text-align: center; padding: 2.75rem 1.5rem; color: var(--text-3); }
.empty-state .empty-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; margin-bottom: .9rem; }
.empty-state h3 { font-size: 1.05rem; color: var(--text); margin-bottom: .3rem; }

/* ---------- 4. Sign-in ---------- */
.auth-body { background: var(--bg); min-height: 100vh; }
/* Compact centred card: used by the platform-admin sign-in */
.login-body { background: linear-gradient(135deg, var(--brand-purple-darker), var(--brand-purple)); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); color: var(--text); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); margin: 1rem; }
.login-brand { text-align: center; }
.login-logo { display: inline-block; height: 84px; width: 84px; object-fit: contain; margin-bottom: .75rem; }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; color: #fff; padding: 3rem 3.25rem; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(1200px 600px at 0% 0%, color-mix(in srgb, var(--brand-purple) 100%, #fff 0%) 0%, transparent 60%),
    linear-gradient(155deg, var(--brand-purple) 0%, var(--brand-purple-dark) 55%, var(--brand-purple-darker) 100%);
}
.auth-brand::before {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .14);
}
.auth-brand::before { width: 520px; height: 520px; right: -200px; bottom: -180px; box-shadow: 0 0 0 70px rgba(255,255,255,.04), 0 0 0 140px rgba(255,255,255,.03); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand-top { display: flex; align-items: center; gap: .85rem; }
.auth-brand-logo { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 15px; padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.auth-brand-name { font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em; opacity: .95; }
.auth-brand h2 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.12; letter-spacing: -.035em; font-weight: 750; max-width: 15ch; margin: 0 0 1rem; }
.auth-brand p { color: rgba(255,255,255,.82); font-size: 1.02rem; max-width: 40ch; margin: 0; line-height: 1.55; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .65rem; color: rgba(255,255,255,.9); font-size: .94rem; }
.auth-points li { display: flex; gap: .65rem; align-items: center; }
.auth-points svg { flex-shrink: 0; opacity: .9; }
.auth-foot { font-size: .8rem; color: rgba(255,255,255,.7); }
.auth-foot strong { color: #fff; font-weight: 650; }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--bg); position: relative; }
.auth-form-wrap { width: 100%; max-width: 392px; }
.auth-mobile-brand { display: none; align-items: center; gap: .7rem; margin-bottom: 1.75rem; }
.auth-mobile-brand img { margin: 0; width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 3px; }
.auth-form-wrap h1 { font-size: 1.65rem; letter-spacing: -.03em; margin: 0 0 .3rem; }
.auth-form-wrap .lead-sub { color: var(--text-3); margin-bottom: 1.6rem; }
.auth-theme { position: absolute; top: 1.1rem; right: 1.1rem; }
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 2.9rem; }
.pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--text-3); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.auth-note { color: var(--text-3); font-size: .84rem; margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
@media (max-width: 899.98px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-form-side { align-items: flex-start; padding-top: 4rem; }
}
.login-powered { text-align: center; margin: 1.5rem 0 0; font-size: .78rem; color: var(--text-3); }
.login-powered strong { color: var(--text-2); font-weight: 650; }
.login-body .login-powered { color: rgba(255,255,255,.8); }
.login-body .login-powered strong { color: #fff; }

/* ---------- 5. Data display ---------- */
.metric-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .62rem 0; border-bottom: 1px solid var(--line); }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text-2); font-size: .91rem; }
.metric-value { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* KPI tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.stat-tile, .kpi {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.05rem 1.2rem 1rem; display: flex; flex-direction: column; min-width: 0;
}
.stat-tile .stat-label, .kpi .kpi-label {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 650; display: flex; align-items: center; gap: .5rem;
}
.kpi .kpi-ico { width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); flex-shrink: 0; }
.stat-tile .stat-value, .kpi .kpi-value {
  font-size: 1.7rem; font-weight: 720; letter-spacing: -.03em; color: var(--text); margin-top: .5rem; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi .kpi-value .cur { font-size: .8rem; font-weight: 600; color: var(--text-3); letter-spacing: 0; margin-right: .2rem; }
.stat-tile .stat-sub, .kpi .kpi-sub { font-size: .8rem; color: var(--text-3); margin-top: .35rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.kpi .spark { margin-top: .75rem; height: 36px; width: 100%; display: block; overflow: visible; }
.stat-delta, .delta { display: inline-flex; align-items: center; gap: .2rem; font-weight: 650; font-size: .78rem; padding: .12rem .45rem; border-radius: 999px; }
.stat-delta.up, .delta.up { color: var(--good-ink); background: var(--good-bg); }
.stat-delta.down, .delta.down { color: var(--crit-ink); background: var(--crit-bg); }
.stat-delta.flat, .delta.flat { color: var(--text-3); background: var(--surface-3); }

/* Chart cards */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem 1.2rem; height: 100%; display: flex; flex-direction: column; }
.chart-card .chart-title { font-weight: 650; font-size: .98rem; letter-spacing: -.01em; color: var(--text); margin-bottom: .1rem; }
.chart-card .chart-subtitle { font-size: .82rem; color: var(--text-3); margin-bottom: .8rem; }
.chart-card canvas { max-width: 100%; }
.chart-fill { position: relative; flex: 1 1 auto; min-height: 280px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.chart-scroll-area { max-height: 420px; overflow-y: auto; overflow-x: hidden; }
.chart-legend-list { list-style: none; padding: 0; margin: .7rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .82rem; }
.chart-legend-list li { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-2); }
.chart-legend-swatch { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.chart-table-toggle { font-size: .8rem; color: var(--text-3); margin-top: .75rem; }
.chart-table-toggle summary { cursor: pointer; font-weight: 600; width: max-content; }
.chart-table-toggle summary:hover { color: var(--text); }
.chart-table-toggle table { margin-top: .5rem; font-size: .82rem; }

/* Horizontal bar lists (revenue by channel / point) */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; align-items: baseline; }
.bar-row .bar-name { font-size: .88rem; color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-val { font-size: .86rem; color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-row .bar-val small { color: var(--text-3); font-weight: 500; margin-left: .35rem; }
.bar-track { grid-column: 1 / -1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--series-1); min-width: 2px; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.stack-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.stack-seg { height: 100%; min-width: 3px; transition: opacity .12s ease; }
.stack-seg:first-child { border-radius: 999px 0 0 999px; } .stack-seg:last-child { border-radius: 0 999px 999px 0; }
.stack-bar:hover .stack-seg:not(:hover) { opacity: .45; }

/* Health checks */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.check-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.check-ico { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.check-item.ok .check-ico { background: var(--good-bg); color: var(--good-ink); }
.check-item.review .check-ico { background: var(--warn-bg); color: var(--warn-ink); }
.check-item.bad .check-ico { background: var(--crit-bg); color: var(--crit-ink); }
.check-item .check-label { font-weight: 600; font-size: .9rem; flex: 1 1 auto; min-width: 0; }
.check-item .check-detail { font-size: .78rem; color: var(--text-3); display: block; font-weight: 450; }
.check-item .check-state { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.check-item.ok .check-state { color: var(--good-ink); } .check-item.review .check-state { color: var(--warn-ink); } .check-item.bad .check-state { color: var(--crit-ink); }

/* Workflow stepper (daily control status) */
.stepper { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; row-gap: .5rem; }
.step { display: flex; align-items: center; gap: .55rem; font-size: .84rem; font-weight: 600; color: var(--text-3); }
.step .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; background: var(--surface); }
.step.done { color: var(--text-2); } .step.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.step.now { color: var(--accent-ink); } .step.now .dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--focus-ring); }
.step-line { width: 34px; height: 2px; background: var(--line-strong); margin: 0 .6rem; border-radius: 2px; }
.step-line.done { background: var(--good); }
@media (max-width: 575.98px) { .step-line { width: 14px; margin: 0 .3rem; } .step .lbl { display: none; } .step.now .lbl { display: inline; } }

/* Hero (today's control) */
.today-card { border-radius: var(--radius-lg); overflow: hidden; }
.today-card .card-header { background: linear-gradient(120deg, var(--brand-purple), var(--brand-purple-dark)); color: #fff; padding: 1rem 1.4rem; border: 0; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.hero-card .hero-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.15rem 1.4rem; border-bottom: 1px solid var(--line); background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%); }
.hero-card .hero-body { padding: 1.2rem 1.4rem 1.3rem; }

/* Date range filter pills */
.filter-pills { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.filter-pills .btn { border-radius: 999px; font-size: .82rem; padding: .3rem .85rem; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.seg a, .seg button { border: 0; background: transparent; color: var(--text-2); font-weight: 600; font-size: .82rem; padding: .32rem .8rem; border-radius: 8px; text-decoration: none; }
.seg a:hover, .seg button:hover { color: var(--text); }
.seg a.active, .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- 6. Page-specific ---------- */
.balance-sheet-table td.net-positive { color: var(--good-ink); font-weight: 700; }
.balance-sheet-table td.net-negative { color: var(--crit-ink); font-weight: 700; }
.balance-sheet-table tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.balance-sheet-point-row { cursor: pointer; }
.balance-sheet-point-row:hover { background-color: var(--accent-softer); }
.balance-sheet-chevron { display: inline-block; transition: transform .15s ease; width: 1em; }
.balance-sheet-point-row[aria-expanded="true"] .balance-sheet-chevron { transform: rotate(90deg); }
.balance-sheet-breakdown { background-color: var(--surface-2); }
.balance-sheet-breakdown table { background: transparent; }

.insight-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .95rem 1.15rem; display: flex; align-items: flex-start; gap: .8rem; }
.insight-icon { width: 2.2rem; height: 2.2rem; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; flex-shrink: 0; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.book-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.book-card:hover, .book-card:focus-visible { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--accent-line); color: inherit; }
.book-cover { aspect-ratio: 3 / 4; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder { width: 100%; height: 100%; padding: .75rem; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 650; font-size: .9rem; color: var(--on-brand); background: linear-gradient(145deg, var(--brand-purple), var(--brand-purple-darker)); }
.book-card-body { padding: .75rem .85rem .85rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.book-title { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta { font-size: .8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card-footer { margin-top: auto; padding-top: .5rem; display: flex; justify-content: space-between; align-items: center; gap: .4rem; font-size: .8rem; }

.doc-project-header { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.doc-project-name { font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.doc-table thead th { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.doc-file-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cash count grid */
.cash-grid { display: grid; gap: .5rem; }
.cash-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 118px; align-items: center; gap: .75rem; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .14s ease, background-color .14s ease; }
.cash-row.has-qty { border-color: var(--accent-line); background: var(--accent-softer); }
.cash-denom { font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: .25rem; }
.cash-denom small { color: var(--text-3); font-weight: 550; font-size: .72rem; }
.qty-stepper { display: inline-flex; align-items: center; justify-self: start; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.qty-stepper button { width: 38px; height: 38px; border: 0; background: transparent; color: var(--text-2); font-size: 1.15rem; line-height: 1; font-weight: 600; }
.qty-stepper button:hover { background: var(--surface-3); color: var(--text); }
.qty-stepper input { width: 62px; height: 38px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; background: transparent; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { outline: none; background: var(--accent-soft); }
.cash-amount { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cash-row.has-qty .cash-amount { color: var(--text); }
.cash-total { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); margin-top: .75rem; }
.cash-total .t-label { font-weight: 650; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-ink); }
.cash-total .t-value { font-size: 1.45rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) { .cash-row { grid-template-columns: 70px minmax(0, 1fr) 92px; gap: .5rem; padding: .5rem .55rem; } .qty-stepper button { width: 34px; } .qty-stepper input { width: 48px; } }

.platform-logo { height: 56px; width: 56px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.table-sm td, .table-sm th { vertical-align: middle; }

/* ---------- 7. Choices.js dropdowns (match the form controls) ---------- */
.choices { margin-bottom: 0; font-size: .94rem; }
.choices__inner {
  background-color: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; min-height: calc(1.5em + 1.04rem + 2px);
  padding: .4rem 2.25rem .4rem .8rem; font-size: inherit; line-height: 1.5; display: flex; align-items: center; box-shadow: var(--shadow-sm); color: var(--text);
}
.choices[data-type*="select-one"] .choices__inner { padding-bottom: .4rem; }
.choices__list--single { padding: 0; width: 100%; }
.choices__list--single .choices__item { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.choices[data-type*="select-one"]::after { border-color: var(--text-3) transparent transparent; right: 1rem; }
.choices[data-type*="select-one"].is-open::after { border-color: transparent transparent var(--text-3); }
.choices.is-focused .choices__inner, .choices.is-open .choices__inner { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.choices.is-open .choices__inner { border-radius: 10px 10px 0 0; }
.choices.is-open.is-flipped .choices__inner { border-radius: 0 0 10px 10px; }
.choices.is-disabled .choices__inner { background-color: var(--surface-3); }
.choices__list--dropdown, .choices__list[aria-expanded] {
  background: var(--surface); border-color: var(--accent); min-width: 100%; width: max-content; max-width: min(360px, 90vw); z-index: 1050; font-size: .92rem; color: var(--text);
  box-shadow: var(--shadow-lg); border-radius: 0 0 10px 10px;
}
.choices__list--dropdown .choices__item { padding: .5rem .8rem; white-space: normal; }
.choices__list--dropdown .choices__item--selectable.is-highlighted, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted { background-color: var(--accent-soft); color: var(--text); }
.choices__list--dropdown .choices__item--selectable[data-select-text]::after { display: none; }
.choices__list--dropdown .choices__input, .choices__list[aria-expanded] .choices__input { background: var(--surface); color: var(--text); border-bottom: 1px solid var(--line); padding: .55rem .8rem; font-size: .9rem; }
.choices__list--dropdown .choices__list { max-height: 260px; }
.choices__item--choice.is-selected { font-weight: 650; }
.choices__placeholder { color: var(--text-3); opacity: 1; }
.choices-sm { font-size: .86rem; }
.choices-sm .choices__inner { min-height: calc(1.5em + .6rem + 2px); padding: .25rem 2rem .25rem .55rem; border-radius: 8px; }
.choices-sm[data-type*="select-one"]::after { right: .75rem; }
.choices-sm .choices__list--dropdown .choices__item { padding: .38rem .65rem; }
.table-responsive.choices-open { overflow: visible; }
.modal .choices__list--dropdown { z-index: 1060; }

/* Scrollbars */
* { scrollbar-color: var(--line-strong) transparent; }
.validation-summary-valid { display: none; }

.breadcrumb { --bs-breadcrumb-divider: "/"; margin: 0; }
.breadcrumb a { text-decoration: none; font-weight: 550; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-item.active { color: var(--text-3); }

@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .kpi, .stat-tile { padding: .85rem .9rem .8rem; }
  .kpi .kpi-value, .stat-tile .stat-value { font-size: 1.3rem; }
  .kpi .kpi-label { font-size: .68rem; letter-spacing: .06em; }
  .kpi .spark { height: 28px; }
  .page-header { margin: 1.1rem 0 1rem; }
  h1, h1.h3 { font-size: 1.45rem; }
  .hero-card .hero-top, .hero-card .hero-body { padding-left: 1rem; padding-right: 1rem; }
}

/* Date-range filter bar: presets on the left, custom range on the right, wrapping cleanly */
.filter-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem 1rem; padding: .6rem .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.range-form { display: flex; align-items: center; gap: .4rem; flex-wrap: nowrap; }
.range-form .form-control { width: 9.5rem; min-width: 0; }
@media (max-width: 575.98px) { .range-form { width: 100%; flex-wrap: wrap; } .range-form .form-control { flex: 1 1 8rem; } .filter-pills { overflow-x: auto; flex-wrap: nowrap; width: 100%; padding-bottom: .15rem; } .filter-pills .btn { white-space: nowrap; } }

/* ==========================================================================
   Platform console (admin.* host): same system, its own indigo identity
   ========================================================================== */
.platform-mark {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--brand-purple), var(--brand-purple-dark)); color: var(--on-brand);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-purple) 32%, transparent);
}
.platform-mark-lg { width: 52px; height: 52px; border-radius: 15px; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); color: #fff; }
.env-tag {
  align-items: center; gap: .4rem; font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; padding: .22rem .65rem;
}
.state-pill {
  display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .65rem .2rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.state-pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.state-pill.ok { background: var(--good-bg); color: var(--good-ink); }
.state-pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.state-pill.bad { background: var(--crit-bg); color: var(--crit-ink); }
.state-pill.off { background: var(--surface-3); color: var(--text-2); }

.school-cell { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.school-logo {
  width: 42px; height: 42px; flex-shrink: 0; object-fit: contain; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 3px;
}
.school-cell .school-name { font-weight: 650; color: var(--text); text-decoration: none; display: block; line-height: 1.25; }
.school-cell .school-name:hover { color: var(--accent-ink); }
.school-cell .school-code { font-size: .78rem; color: var(--text-3); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.module-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.module-chip { font-size: .72rem; font-weight: 600; padding: .14rem .55rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.addr-link { color: var(--text-2); text-decoration: none; font-size: .86rem; white-space: nowrap; }
.addr-link:hover { color: var(--accent-ink); text-decoration: underline; }

.detail-hero { display: flex; align-items: center; gap: 1.1rem; min-width: 0; }
.detail-hero .school-logo { width: 64px; height: 64px; border-radius: 16px; padding: 5px; }
.detail-hero h1 { margin: 0; }
.detail-hero .meta { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; color: var(--text-3); font-size: .88rem; }

/* Usage meter: a thin track with a fill; turns amber at 80% and red at 95% (also stated in the text beside it). */
.usage-meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 320px; }
.usage-meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); min-width: 2px; }
.usage-meter.warn > span { background: var(--warn); }
.usage-meter.crit > span { background: var(--crit); }

.detail-list { margin: 0; display: grid; grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr); }
.detail-list dt, .detail-list dd { padding: .6rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.detail-list dt { color: var(--text-3); font-weight: 550; font-size: .84rem; }
.detail-list dd { color: var(--text); font-size: .9rem; overflow-wrap: anywhere; }
.detail-list dt:nth-last-of-type(1), .detail-list dd:last-of-type { border-bottom: 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: .4rem; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

.health-row { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: .9rem; }
.health-row + .health-row { margin-top: .5rem; }
.health-row .h-ico { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--good-bg); color: var(--good-ink); }
.health-row.warn .h-ico { background: var(--warn-bg); color: var(--warn-ink); }
.health-row.bad .h-ico { background: var(--crit-bg); color: var(--crit-ink); }
.health-row .h-state { margin-left: auto; font-size: .8rem; font-weight: 650; color: var(--text-2); text-align: right; }

.secret-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: .04em; user-select: all;
  background: var(--surface-3); border: 1px dashed var(--line-strong); border-radius: 10px; padding: .35rem .7rem; display: inline-block;
}
.card-foot-form { padding: .9rem 1.15rem 1rem; background: var(--surface-2); border-top: 1px solid var(--line); }
.page-actions form { margin: 0; }
@media (max-width: 575.98px) {
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { padding-bottom: 0; border-bottom: 0; }
  .detail-hero { align-items: flex-start; }
  .detail-hero .school-logo { width: 52px; height: 52px; }
}
.module-pick { display: flex; flex-wrap: wrap; gap: .6rem; }
.module-pick-item { position: relative; }
.module-pick-item .form-check-input { position: absolute; top: .75rem; left: .8rem; margin: 0; }
.module-pick-label {
  display: block; cursor: pointer; padding: .65rem 1rem .65rem 2.4rem; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); font-weight: 600; font-size: .9rem; color: var(--text-2); transition: border-color .12s, background .12s, color .12s;
}
.module-pick-item .form-check-input:checked + .module-pick-label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.module-pick-item .form-check-input:focus-visible + .module-pick-label { box-shadow: 0 0 0 3px var(--focus-ring); }
.filter-bar .form-select, .filter-bar .form-control { min-width: 0; }
.min-w-0 { min-width: 0; }
.audit-filter { display: grid; grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr) auto; align-items: center; gap: .6rem; justify-content: stretch; }
@media (max-width: 767.98px) { .audit-filter { grid-template-columns: 1fr; } }

/* Confirmation dialog (site.js: data-confirm) */
.fch-confirm { overflow: hidden; }
.fch-confirm-body { display: flex; gap: 1rem; padding: 1.5rem 1.5rem 1.15rem; align-items: flex-start; }
.fch-confirm-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); }
.fch-confirm-icon.tone-danger { background: var(--crit-bg); color: var(--crit-ink); }
.fch-confirm-icon.tone-warn { background: var(--warn-bg); color: var(--warn-ink); }
.fch-confirm-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; margin: .1rem 0 .35rem; }
.fch-confirm-text { margin: 0; color: var(--text-2); font-size: .94rem; line-height: 1.5; overflow-wrap: anywhere; }
.fch-confirm-actions { display: flex; justify-content: flex-end; gap: .55rem; padding: .9rem 1.25rem; background: var(--surface-2); border-top: 1px solid var(--line); }
@media (max-width: 575.98px) { .fch-confirm-actions { flex-direction: column-reverse; } .fch-confirm-actions .btn { width: 100%; } }

/* Pill tabs (Setup > Custom Fields: Student / Guardian / Staff) follow the school's brand colour. */
.nav-pills .nav-link { color: var(--accent-ink); border-radius: 999px; }
.nav-pills .nav-link:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background: var(--accent); color: var(--on-accent); }

/* Financial statements (Accounting) */
.statement-table th { font-weight: 600; font-size: .85rem; }
.statement-table td { font-size: .92rem; }
.statement-table .st-num { font-variant-numeric: tabular-nums; }
.statement-table .st-heading td { font-weight: 600; background: var(--bs-tertiary-bg, #f6f7f9); }
.statement-table .st-subtotal td { border-top: 1px solid var(--bs-border-color, #dee2e6); font-weight: 500; }
.statement-table .st-total td { font-weight: 700; border-top: 1px solid var(--bs-emphasis-color, #000); }
.statement-table .st-col-head { min-width: 7.5rem; }
.statement-tabs .nav-link { padding: .35rem .85rem; }
@media (max-width: 575.98px) { .statement-table td, .statement-table th { font-size: .82rem; } .statement-table .st-col-head { min-width: 6rem; } }

/* Letters: the editor and the on-screen paper */
.letter-editor { min-height: 18rem; max-height: 36rem; overflow: auto; background: var(--surface); line-height: 1.55; }
.letter-editor:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.letter-editor p, .letter-editor div { margin: 0 0 .7rem; }
.letter-paper { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.5rem; line-height: 1.55; }
.letter-paper p, .letter-paper div { margin: 0 0 .7rem; }
.letter-paper ul, .letter-paper ol { padding-left: 1.5rem; }
.letter-paper .letter-sheet { padding: 0; }
.letter-paper .letter-head { display: flex; align-items: center; gap: .75rem; border-bottom: 2px solid var(--accent); padding-bottom: .5rem; margin-bottom: 1rem; }
.letter-paper .letter-logo { max-width: 100px; max-height: 48px; object-fit: contain; }
.letter-paper .letter-school { font-weight: 700; color: var(--accent); }

/* Report centre */
.rc-card { transition: box-shadow .15s, border-color .15s; }
.rc-card:hover { border-color: var(--brand, #5b2a86); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.rc-checks { max-height: 16rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; }
.rc-checkgroup + .rc-checkgroup { margin-top: .4rem; }
.rc-table th { white-space: nowrap; font-size: .8rem; }
.rc-table .rc-subtotal td { border-top: 1px solid var(--line); }
.rc-table .rc-total td { border-top: 2px solid var(--line); background: rgba(127,127,127,.08); }
.rc-bar { display: inline-block; width: 3.5rem; height: .45rem; background: rgba(127,127,127,.2); border-radius: 3px; vertical-align: middle; margin-right: .35rem; overflow: hidden; }
.rc-bar > span { display: block; height: 100%; background: var(--brand, #5b2a86); }
.rc-details > summary { list-style: none; cursor: pointer; display: inline-block; }
.rc-details > summary::-webkit-details-marker { display: none; }
.rc-details > summary::before { content: "\25B8\00a0"; }
.rc-details[open] > summary::before { content: "\25BE\00a0"; }
