:root {
  color-scheme: light;
  --page: #e8edf4;
  --surface: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #dfe5ee;
  --axis: #c3c2b7;
  --border: rgba(15, 39, 71, 0.14);
  --wash: rgba(29, 78, 150, 0.07);
  --accent: #1d6fdc;
  --navy: #0f2747; --navy-2: #1b3a66;
  --shadow: 0 1px 2px rgba(15, 39, 71, 0.08), 0 4px 14px rgba(15, 39, 71, 0.06);
  --accent-ink: #ffffff;
  --neg: #e34948;
  --mid: #f0efec;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up-good: #006300;
  /* sequential blue: low recedes towards the surface */
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5;
  --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --seq-ink-flip: 4; /* from this step on, cell text is white */
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --accent: #3987e5;
    --neg: #e66767;
    --mid: #383835;
    --up-good: #0ca30c;
    --seq-1: #0d366b; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5;
    --seq-5: #6da7ec; --seq-6: #9ec5f4; --seq-7: #cde2fb;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 4px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.error { color: var(--critical); min-height: 1.5em; margin: 0; }
a { color: inherit; }

.btn {
  font: inherit; font-weight: 550; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis);
  border-radius: 8px; padding: 8px 10px; max-width: 100%;
}

/* login */
#galaxy { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; background: #03040a; }
#galaxy[hidden] { display: none; }
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; position: relative; z-index: 1; }
body.galaxy-on .login-card {
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  /* slightly see-through, so on a short screen the galaxy still glows behind the card */
  background: color-mix(in srgb, var(--surface) 84%, transparent); backdrop-filter: blur(6px);
}
/* The sign-in form itself is mostly glass: the stars show through, and its colours no longer follow the
   light or dark theme because what is behind it is always dark. */
body.galaxy-on #login .login-card {
  --ink: #f4f5f7; --ink-2: #d3d6dd; --muted: #b6bac3; --border: rgba(255, 255, 255, 0.18); --critical: #ff9a9a;
  color: var(--ink); background: rgba(8, 10, 18, 0.32); border-color: var(--border); backdrop-filter: none;
}
body.galaxy-on #login .login-card input {
  background: rgba(255, 255, 255, 0.07); color: var(--ink); border-color: rgba(255, 255, 255, 0.24);
}
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: grid; gap: 14px;
}
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }

/* shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100%; }
.shell.with-chat { grid-template-columns: 220px minmax(0, 1fr) 380px; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column;
  gap: 18px; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { font-weight: 700; font-size: 16px; padding: 0 8px; }
#nav { display: grid; gap: 2px; }
#nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); }
#nav a:hover { background: var(--wash); }
#nav a[aria-current="page"] { background: var(--wash); color: var(--ink); font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.view { padding: 28px 32px 64px; min-width: 0; outline: none; max-width: 1280px; }
.view.loading { opacity: 0.55; transition: opacity 0.15s; }
.lede { color: var(--ink-2); max-width: 70ch; margin-bottom: 20px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 18px; }
.filters label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px;
  min-width: 0;
}
.card > .sub { color: var(--ink-2); font-size: 13px; margin: 0 0 12px; }
.section { margin-top: 20px; }

/* figures */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile.click { cursor: pointer; }
.tile.click:hover, .tile.click:focus-visible { border-color: var(--accent); outline: none; }
.tile .more { font-size: 12px; color: var(--accent); margin-top: 8px; }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 650; line-height: 1.2; margin-top: 2px; }
.tile .note { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.hero .value { font-size: 52px; line-height: 1.05; }
.delta { font-weight: 600; }
.delta.good { color: var(--up-good); }
.delta.bad { color: var(--critical); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:hover { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--wash); }
td .sub { display: block; font-size: 12px; color: var(--ink-2); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.badge .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.badge .ico { font-size: 12px; width: 12px; text-align: center; font-weight: 700; }
.s-good .ico { color: var(--good); } .s-warning .ico { color: var(--warning); }
.s-serious .ico { color: var(--serious); } .s-critical .ico { color: var(--critical); }
.s-neutral .ico { color: var(--muted); }

/* heat grid */
.heat { border-collapse: separate; border-spacing: 2px; }
.heat th, .heat td { border: 0; padding: 0; }
.heat th { padding: 4px 8px; }
.heat td.cell {
  text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; height: 28px; min-width: 62px;
  border-radius: 4px; cursor: default;
}
.heat td.cell:hover, .heat td.cell:focus { outline: 2px solid var(--ink); outline-offset: -2px; }
.heat td.name { padding-right: 12px; white-space: nowrap; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.line { height: 2px; width: 16px; border-radius: 0; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.val { fill: var(--ink); font-weight: 600; }
.chart text.lab { fill: var(--ink-2); }
details.tbl { margin-top: 8px; font-size: 13px; }
details.tbl summary { cursor: pointer; color: var(--ink-2); }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--page);
  padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; max-width: 280px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.tip strong { font-size: 13px; display: block; }
.tip .k { opacity: 0.75; }

.notice { border-left: 3px solid var(--axis); padding: 8px 12px; background: var(--wash); border-radius: 0 8px 8px 0;
  font-size: 14px; margin: 0 0 12px; }
.notice.warn { border-left-color: var(--warning); }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li { margin-bottom: 4px; }

.slider { display: flex; align-items: center; gap: 12px; }
.slider input[type=range] { padding: 0; width: 220px; accent-color: var(--accent); }
.slider output { font-weight: 650; font-size: 18px; min-width: 3ch; }

.map-grid { display: grid; grid-template-columns: minmax(160px, 240px) minmax(0, 1fr); gap: 8px 12px; align-items: center; margin: 12px 0; }
.drop { border: 1px dashed var(--axis); border-radius: 10px; padding: 16px; display: grid; gap: 10px; }

/* drawer + chat */
.drawer-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface);
  z-index: 31; padding: 24px; overflow-y: auto; border-left: 1px solid var(--border);
}
.chat {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--surface);
}
.chat header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.msg { padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msg.user { background: var(--accent); color: var(--accent-ink); justify-self: end; max-width: 88%; }
.msg.bot { background: var(--wash); justify-self: start; max-width: 96%; }
.msg.err { background: transparent; border: 1px solid var(--critical); }
.msg .tools { display: block; margin-top: 6px; font-size: 11px; color: var(--ink-2); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat-suggest button { font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--ink-2); text-align: left; }
.chat-suggest button:hover { background: var(--wash); color: var(--ink); }
.chat-form { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; resize: none; }

@media (max-width: 1100px) {
  .shell.with-chat { grid-template-columns: 220px minmax(0, 1fr); }
  .chat { position: fixed; right: 0; top: 0; width: min(400px, 100%); z-index: 20; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15); }
}
@media (max-width: 760px) {
  .shell, .shell.with-chat { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: column; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; gap: 10px; }
  #nav { display: flex; overflow-x: auto; gap: 4px; }
  #nav a { white-space: nowrap; }
  .side-foot { margin-top: 0; display: flex; }
  .view { padding: 20px 16px 48px; }
  .hero .value { font-size: 44px; }
  .map-grid { grid-template-columns: 1fr; }
}

/* sequential steps for the heat grid and its legend; ink flips where the fill gets dark */
.q1 { background: var(--seq-1); } .q2 { background: var(--seq-2); } .q3 { background: var(--seq-3); }
.q4 { background: var(--seq-4); } .q5 { background: var(--seq-5); } .q6 { background: var(--seq-6); }
.q7 { background: var(--seq-7); }
.q1, .q2, .q3, .q4 { color: #0b0b0b; } .q5, .q6, .q7 { color: #ffffff; }
@media (prefers-color-scheme: dark) {
  .q1, .q2, .q3 { color: #ffffff; } .q4, .q5, .q6, .q7 { color: #0b0b0b; }
}

/* keep the name column readable when a wide table scrolls sideways on a phone */
.table-wrap td:first-child, .table-wrap th:first-child { min-width: 190px; }
.heat td:first-child, .heat th:first-child { min-width: 0; }

/* first sign-in authenticator wizard */
.wizard { width: min(480px, 100%); }
.wizard-head { display: flex; justify-content: space-between; }
.wizard-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.wizard-bar i { height: 4px; border-radius: 2px; background: var(--grid); }
.wizard-bar i.on { background: var(--accent); }
.wizard p { margin: 0; }
.wizard-stores { display: flex; flex-wrap: wrap; gap: 8px; }
.wizard-stores a { text-decoration: none; }
.wizard-choice { display: grid; gap: 6px; margin: 10px 0; }
.wizard-choice label { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.wizard-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.wizard-qr { justify-self: center; border-radius: 8px; background: #fff; }
.wizard-key { user-select: all; overflow-wrap: anywhere; font-size: 14px; }
.wizard-code { font-size: 22px; letter-spacing: 0.12em; text-align: center; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }

/* management report table: month columns scroll, the label column stays */
.mgmt { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.mgmt th, .mgmt td { padding: 3px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.mgmt thead th { position: sticky; top: 0; background: var(--surface); text-align: right; font-weight: 600; z-index: 2; }
.mgmt td.label, .mgmt th.label { position: sticky; left: 0; background: var(--surface); text-align: left; min-width: 330px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.mgmt thead th.label { z-index: 3; }
.mgmt td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mgmt td.total, .mgmt th.total { border-left: 1px solid var(--axis); font-weight: 600; }
.mgmt tr.section td { background: var(--wash); font-weight: 650; }
.mgmt tr.group td { font-weight: 600; }
.mgmt tr.subtotal td, .mgmt tr.total-row td { font-weight: 650; background: var(--wash); }
.mgmt tr.total-row td { border-top: 1px solid var(--axis); }
.mgmt td.neg { color: var(--critical); }
.mgmt td.zero { color: var(--muted); }
.mgmt .lvl1 { padding-left: 22px !important; } .mgmt .lvl2 { padding-left: 34px !important; } .mgmt .lvl3 { padding-left: 46px !important; }
.mgmt .note { color: var(--muted); font-size: 12px; margin-left: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 16px; }


/* a stronger look: coloured page, white cards, navy menu and title band (colour and depth only, no new files) */
:root { --navy: #0f2747; --navy-2: #1b3a66; --shadow: 0 1px 2px rgba(15, 39, 71, 0.08), 0 4px 14px rgba(15, 39, 71, 0.06); }
@media (prefers-color-scheme: dark) {
  :root { --navy: #0a1a33; --navy-2: #14305a; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --surface: #1b1f27; --page: #0e1117;
    --border: rgba(255, 255, 255, 0.12); --grid: #2a303a; }
}
.card { box-shadow: var(--shadow); }
.side { background: var(--navy); border-right: 0; color: #fff; }
.side .brand { color: #fff; }
#nav a { color: rgba(255, 255, 255, 0.74); border-left: 3px solid transparent; border-radius: 6px; }
#nav a:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
#nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: #fff; border-left-color: #5aa2ff; }
.side-foot .muted { color: rgba(255, 255, 255, 0.7); }
.side-foot .btn:not(.primary) { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.side-foot .btn:not(.primary):hover { background: rgba(255, 255, 255, 0.16); }

/* title band: the page title (and the line under it) on navy across the top of the page */
.view > h1 { background: var(--navy); color: #fff; margin: -28px -32px 20px; padding: 22px 32px 20px; }
.view > h1:has(+ .lede) { margin-bottom: 0; padding-bottom: 4px; }
.view > h1 + .lede { background: var(--navy); color: rgba(255, 255, 255, 0.8); max-width: none; margin: 0 -32px 20px; padding: 0 32px 18px; }
@media (max-width: 760px) {
  .view > h1 { margin: -20px -16px 16px; padding: 16px; }
  .view > h1:has(+ .lede) { margin-bottom: 0; padding-bottom: 4px; }
  .view > h1 + .lede { margin: 0 -16px 16px; padding: 0 16px 14px; }
}

/* tiles carry a coloured edge: blue by default, green or red where the tile shows a good or bad change */
.tile { border-left: 4px solid var(--accent); }
.tile:has(.delta.good) { border-left-color: var(--good); }
.tile:has(.delta.bad) { border-left-color: var(--critical); }
.tile.hero { border-left-color: var(--navy-2); }

/* tables: tinted header row, striped rows */
th { background: var(--wash); color: var(--ink); }
table:not(.heat):not(.mgmt) tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--wash) 55%, transparent); }
.mgmt thead th { background: color-mix(in srgb, var(--surface) 88%, var(--accent)); }
.btn.primary { box-shadow: 0 1px 2px rgba(15, 39, 71, 0.25); }
@media (max-width: 760px) {
  .mgmt td.label, .mgmt th.label { min-width: 150px; max-width: 170px; white-space: normal; font-size: 12px; }
  .mgmt th, .mgmt td { padding: 3px 7px; }
}

/* clickable tiles: lift and glow on hover (transform and shadow only, so nothing is re-laid out), hint appears */
.tile.click { transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.tile.click:hover, .tile.click:focus-visible { transform: translateY(-3px); border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(29, 78, 150, 0.22); }
.tile.click:active { transform: translateY(-1px); }
.tile .more { opacity: 0; transition: opacity 0.15s ease; }
.tile.click:hover .more, .tile.click:focus-visible .more { opacity: 1; }
@media (hover: none) { .tile .more { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tile.click, .tile .more { transition: none; } .tile.click:hover { transform: none; } }
.drawer .card + .card, .drawer .kpis + .card { margin-top: 16px; }

/* a card the page has just scrolled to */
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: var(--shadow); } }
.card.flash { animation: flash 1.2s ease-out; }
@media (prefers-reduced-motion: reduce) { .card.flash { animation: none; } }

/* the extra scrollbar above a wide table */
.xbar { overflow-x: auto; overflow-y: hidden; height: 14px; margin-bottom: 2px; }
.xbar > div { height: 1px; }

/* download progress toast */
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 60; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: min(92vw, 440px);
  padding: 14px 18px; border-radius: 14px; background: var(--navy); color: #fff; box-shadow: 0 12px 32px rgba(10, 26, 51, 0.35);
  overflow: hidden; opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ico { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.toast.work .toast-ico { border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #5aa2ff; animation: spin 0.8s linear infinite; }
.toast.ok .toast-ico { background: #1fa971; }
.toast.bad .toast-ico { background: #d03b3b; }
.toast-text { display: grid; gap: 2px; min-width: 0; }
.toast-text strong { font-weight: 650; }
.toast-sub { font-size: 12.5px; color: rgba(255, 255, 255, 0.75); overflow-wrap: anywhere; }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 40%; background: linear-gradient(90deg, transparent, #5aa2ff, transparent); animation: sweep 1.3s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
.btn.busy { opacity: 0.65; pointer-events: none; }
.btn.busy::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -1px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .toast, .toast-bar, .toast.work .toast-ico, .btn.busy::after { animation-duration: 3s; transition: none; } }

/* cost method choice and the in-system cost editor */
.choices { display: grid; gap: 8px; margin: 12px 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.choice input { margin-top: 4px; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.cost-in { width: 110px; text-align: right; }

.note-in { width: 100%; min-width: 160px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: inherit; font: inherit; }
