/* SchoolPulse AI · Elizabeth Gabriel International Academy
   Layout: fixed navy sidebar with a scrolling work area. Summary first (controls, KPI grid,
   alerts and insights), then paired chart panels per area, then report and automation. */

:root {
  --bg: #F2F5F7;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --line: #E0E6EC;
  --line-strong: #C9D3DC;
  --ink: #13212E;
  --muted: #566778;
  --faint: #7F8E9C;

  --navy: #0F2A44;
  --navy-2: #173A5C;
  --side-ink: #D3DEE9;
  --side-muted: #8EA5BB;

  --teal: #11918A;
  --teal-strong: #0B746E;
  --teal-soft: #DDF2EF;
  --on-teal: #FFFFFF;
  --gold: #B3862B;
  --gold-soft: #F5ECD7;

  --ok: #1C8655;
  --ok-soft: #DFF2E7;
  --warn: #A9690F;
  --warn-soft: #FBEED6;
  --crit: #C03838;
  --crit-soft: #FAE2E2;
  --info: #3A6C9C;
  --info-soft: #E2ECF6;

  --grid: #E6EBF0;
  --scrim: rgba(8, 20, 32, .5);
  --shadow: 0 1px 2px rgba(15, 42, 68, .06), 0 10px 28px -14px rgba(15, 42, 68, .22);

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --gutter: clamp(16px, 3vw, 36px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09141F; --surface: #0F1E2D; --surface-2: #0C1925; --line: #1B3044; --line-strong: #28435B;
    --ink: #E4EBF2; --muted: #9CACBC; --faint: #718597;
    --navy: #06111D; --navy-2: #102740; --side-ink: #D3DEE9; --side-muted: #7E96AD;
    --teal: #2FC1B5; --teal-strong: #5DD6CB; --teal-soft: #0D3233; --on-teal: #04201E;
    --gold: #DAB767; --gold-soft: #2B2412;
    --ok: #4CC08A; --ok-soft: #0F2F1F; --warn: #E6AA4C; --warn-soft: #32250D; --crit: #EF6E6E; --crit-soft: #381A1C;
    --info: #80B1DE; --info-soft: #12293F; --grid: #192D40; --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 30px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09141F; --surface: #0F1E2D; --surface-2: #0C1925; --line: #1B3044; --line-strong: #28435B;
  --ink: #E4EBF2; --muted: #9CACBC; --faint: #718597;
  --navy: #06111D; --navy-2: #102740; --side-ink: #D3DEE9; --side-muted: #7E96AD;
  --teal: #2FC1B5; --teal-strong: #5DD6CB; --teal-soft: #0D3233; --on-teal: #04201E;
  --gold: #DAB767; --gold-soft: #2B2412;
  --ok: #4CC08A; --ok-soft: #0F2F1F; --warn: #E6AA4C; --warn-soft: #32250D; --crit: #EF6E6E; --crit-soft: #381A1C;
  --info: #80B1DE; --info-soft: #12293F; --grid: #192D40; --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 30px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }

.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  background: var(--navy); color: var(--side-ink);
  padding-block: 24px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: 20px;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.crest { width: 46px; height: 46px; }
.crest-shield { fill: var(--navy-2); stroke: #D4AE5C; stroke-width: 1.6; }
.crest-inner { fill: none; stroke: #D4AE5C; stroke-width: .8; opacity: .55; }
.crest-text { fill: #E3C27A; font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.brand-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-school { font-family: var(--font-display); font-size: 15.5px; line-height: 1.2; color: #FFFFFF; font-weight: 500; }
.brand-app { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #E3C27A; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--side-muted); padding: 14px 12px 6px;
}
.nav-label:first-child { padding-top: 0; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--side-ink); text-decoration: none; font-weight: 500; font-size: 14.5px;
  transition: background .2s, color .2s;
}
.nav-link svg { opacity: .75; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #FFFFFF; }
.nav-link.is-active { background: rgba(47, 193, 181, .16); color: #FFFFFF; }
.nav-link.is-active svg { color: #5DD6CB; opacity: 1; }

.sidebar-foot {
  margin-top: auto; font-size: 12.5px; line-height: 1.5; color: var(--side-muted);
  border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.foot-strong { color: #E3C27A; font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }

.shell { min-width: 0; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 14px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; line-height: 1.15; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.icon-btn.menu-btn { display: none; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.pill-demo { background: var(--gold-soft); color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.pill-demo::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.pill-auto { background: var(--surface); color: var(--muted); border: 1px solid var(--line-strong); }
.pill-auto.is-set { color: var(--teal-strong); border-color: color-mix(in srgb, var(--teal) 45%, transparent); background: var(--teal-soft); }

/* ---------- Content ---------- */
.content {
  display: flex; flex-direction: column; gap: 44px;
  padding-block: 28px 32px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  max-width: 1480px; width: 100%;
}
.section { display: flex; flex-direction: column; gap: 18px; }
.section-head { display: flex; flex-direction: column; gap: 4px; }
.section-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.55rem; }
.section-head p { color: var(--muted); max-width: 68ch; }

.intro { display: flex; flex-direction: column; gap: 6px; }
.greeting { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.8rem, 1.2rem + 1.8vw, 2.5rem); line-height: 1.1; letter-spacing: -.01em; }
.lede { color: var(--muted); max-width: 64ch; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions a.btn { text-decoration: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer;
  transition: transform .15s ease, border-color .2s, background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--teal); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn svg { color: var(--teal-strong); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.btn-primary svg { color: var(--on-teal); }
.btn-primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); }
.btn-report { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.btn-report svg { color: var(--gold); }
.btn-report:hover { border-color: var(--gold); }
.btn-ghost { margin-left: auto; background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost svg { color: var(--muted); }
.btn-ghost:hover { border-color: var(--line-strong); box-shadow: none; }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #FFFFFF; }
.btn-danger:hover { border-color: var(--crit); filter: brightness(1.05); }
.btn-sm { padding: 8px 12px; font-size: 13.5px; }
.btn[aria-busy="true"] { pointer-events: none; opacity: .75; }
.btn[aria-busy="true"] svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--teal-soft); color: var(--teal-strong);
}
.kpi-icon.gold { background: var(--gold-soft); color: var(--gold); }
.kpi-value {
  font-family: var(--font-display); font-weight: 600; font-size: 2.05rem; line-height: 1.05;
  letter-spacing: -.015em; font-variant-numeric: tabular-nums lining-nums;
}
.kpi-desc { font-size: 13px; color: var(--muted); }
.kpi-foot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; gap: 8px; min-height: 26px; }
.kpi.flash { animation: flash 1.1s ease; }
@keyframes flash {
  0% { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
  100% { border-color: var(--line); box-shadow: none; }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-crit { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.chip-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip-gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }

.meter { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--teal); border-radius: inherit; transition: width .6s ease; }
.meter-label { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Panels ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; }
.chart-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; line-height: 1.25; }
.panel-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel-head > svg, .panel-head > span[data-icon] { color: var(--faint); }
.count {
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: 999px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.count.has-alerts { background: var(--crit-soft); color: var(--crit); border-color: transparent; }

.chart-box { position: relative; height: 270px; min-width: 0; }
.chart-box-tall { height: 300px; }
.chart-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 10px; padding: 16px; }

/* Alerts */
.alerts, .insights, .activity, .subjects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alert {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
}
.alert.warn { border-left-color: var(--warn); }
.alert.crit { border-left-color: var(--crit); }
.alert.ok { border-left-color: var(--ok); }
.alert-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.alert.warn .alert-icon { background: var(--warn-soft); color: var(--warn); }
.alert.crit .alert-icon { background: var(--crit-soft); color: var(--crit); }
.alert.ok .alert-icon { background: var(--ok-soft); color: var(--ok); }
.alert-title { font-weight: 600; font-size: 14.5px; }
.alert-detail { font-size: 13.5px; color: var(--muted); }
.alert-area { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding-top: 3px; }

.insights li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: baseline; font-size: 14.5px; }
.insights li::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--gold); transform: translateY(-2px) rotate(45deg); }
.insights strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.text-link { margin-top: auto; font-weight: 600; font-size: 14px; color: var(--teal-strong); text-decoration: none; align-self: flex-start; }
.text-link:hover { text-decoration: underline; }

/* Glance + funnel */
.glance { display: flex; flex-direction: column; gap: 18px; }
.glance-row { display: flex; flex-direction: column; gap: 8px; }
.glance-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.glance-line strong { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.stack > span { transition: width .6s ease; }
.stack .s-present { background: var(--teal); }
.stack .s-absent { background: var(--gold); opacity: .8; }
.key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel-step { display: flex; flex-direction: column; gap: 6px; }
.funnel-top { display: flex; justify-content: space-between; font-size: 14px; }
.funnel-top strong { font-variant-numeric: tabular-nums; }
.bar { height: 30px; border-radius: 8px; background: var(--teal-soft); position: relative; overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--teal); border-radius: 8px; transition: width .6s ease; }
.bar.gold > span { background: var(--gold); }
.funnel-note { font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

.subjects li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.subjects li:last-child { border-bottom: 0; }
.subjects .score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Enquiries ---------- */
.enq-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.enq-actions a.btn { text-decoration: none; }
.enq-status { font-size: 13px; color: var(--muted); }
.enq-status.err { color: var(--crit); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.enq-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 620px; }
.enq-table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.enq-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.enq-table tr:last-child td { border-bottom: 0; }
.enq-table td:first-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.enq-table td.student { font-weight: 600; }
.enq-table tr.is-new td { animation: rowIn 2.4s ease; }
@keyframes rowIn { 0% { background: var(--teal-soft); } 100% { background: transparent; } }
.enq-empty td { text-align: center; color: var(--muted); padding: 20px; }

/* ---------- Report ---------- */
.report { gap: 22px; }
.report-empty { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; padding: 8px 0; }
.report-empty .badge-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.report-empty h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.report-empty p { color: var(--muted); max-width: 62ch; }
.report-empty .btn { margin-top: 12px; }

.report-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.report-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.report-title h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1.15; }
.report-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.report-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.report-note { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; }
.highlights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.highlight { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.highlight span { font-size: 12px; font-weight: 600; color: var(--muted); }
.highlight strong { display: block; font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.report-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; }
.report-section { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.report-section.wide { grid-column: 1 / -1; }
.report-section h4 { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-strong); }
.report-section p { max-width: 70ch; }
.report-section ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; max-width: 75ch; }
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.skeleton span { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Automation ---------- */
.legend-mini { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-local { background: var(--info-soft); color: var(--info); }
.status-success { background: var(--ok-soft); color: var(--ok); }
.status-failed { background: var(--crit-soft); color: var(--crit); }
.status-off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.status-pending { background: var(--gold-soft); color: var(--gold); }

.activity { max-height: 430px; overflow-y: auto; gap: 0; }
.activity li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); align-items: start; }
.activity li:last-child { border-bottom: 0; }
.activity time { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.activity .a-title { font-weight: 600; font-size: 14px; }
.activity .a-detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.settings { display: flex; flex-direction: column; gap: 8px; }
.settings label { font-size: 13px; font-weight: 600; }
.settings input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface-2); font-size: 14px; min-width: 0;
}
.settings input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.settings input + label { margin-top: 6px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-msg { font-size: 13px; min-height: 1.2em; color: var(--muted); }
.form-msg.err { color: var(--crit); }
.form-msg.ok { color: var(--ok); }
.help { font-size: 12.5px; color: var(--muted); }
.mini-head { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }
.thresholds { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-size: 14px; }
.thresholds dt { color: var(--muted); }
.thresholds dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.limits { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 16px 20px; }
.limits h4 { font-size: 14px; margin-bottom: 6px; }
.limits ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; }

.footer { font-size: 12.5px; color: var(--faint); border-top: 1px solid var(--line); padding-top: 18px; }

/* ---------- Modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; max-width: 440px; width: 100%; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; animation: rise .2s ease; }
.modal-card h3 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.modal-card p { color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
@keyframes rise { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }

.toasts {
  position: fixed; z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  left: max(16px, env(safe-area-inset-left, 0px)); pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 380px; background: var(--ink); color: var(--bg);
  padding: 11px 14px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  animation: rise .2s ease;
}

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(288px, 86vw); z-index: 50;
    transform: translateX(-102%); transition: transform .25s ease;
    padding-top: max(24px, env(safe-area-inset-top, 0px));
  }
  .sidebar.open { transform: none; }
  .icon-btn.menu-btn { display: grid; }
  .split, .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .report-body { grid-template-columns: minmax(0, 1fr); }
  .limits ul { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar-title h1 { font-size: 1.2rem; }
  .topbar-meta { margin-left: 0; width: 100%; }
  .date { width: 100%; }
  .btn-ghost { margin-left: 0; }
  .actions .btn { flex: 1 1 calc(50% - 10px); }
  .kpi-value { font-size: 1.7rem; }
  .chart-box { height: 240px; }
  .report-empty { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .kpi-grid, .highlights { grid-template-columns: minmax(0, 1fr); }
  .actions .btn { flex-basis: 100%; }
  .activity li { grid-template-columns: minmax(0, 1fr) auto; }
  .activity time { grid-column: 1 / -1; }
}

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

/* ---------- Print: report only ---------- */
@media print {
  body { background: #FFFFFF; color: #000000; }
  body::before, .sidebar, .topbar, .scrim, .toasts, .modal, .footer, .section:not(#report), #report .section-head, .report-tools { display: none !important; }
  .app { display: block; }
  .content { padding: 0; gap: 0; }
  .panel { border: 0; padding: 0; }
  .report-body { grid-template-columns: 1fr; }
}
