/* =========================================================================
   12321 monitoring console
   Light-first tokens; dark values are re-stepped for the dark surface rather
   than flipped, and are declared under both the OS media query and the
   explicit [data-theme] scope so the toggle wins in either direction.
   ========================================================================= */

:root {
  color-scheme: light;

  /* surfaces & ink */
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-raised: #f2f2ee;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --hairline: rgba(11, 11, 11, .10);
  --hairline-strong: rgba(11, 11, 11, .18);
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  /* categorical series — validated (see README) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s1-wash: rgba(42, 120, 214, .10);

  /* sequential blue ramp, light -> dark */
  --seq-100: #cde2fb;
  --seq-200: #9ec5f4;
  --seq-300: #6da7ec;
  --seq-400: #3987e5;
  --seq-500: #256abf;
  --seq-600: #184f95;
  --seq-700: #0d366b;

  /* status — fixed, never themed */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 6px 18px -12px rgba(11, 11, 11, .22);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #232322;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --hairline: rgba(255, 255, 255, .10);
    --hairline-strong: rgba(255, 255, 255, .18);
    --grid: #2c2c2a;
    --axis: #383835;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s1-wash: rgba(57, 135, 229, .12);
    --good-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px -12px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-raised: #232322;
  --ink-1: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --hairline: rgba(255, 255, 255, .10);
  --hairline-strong: rgba(255, 255, 255, .18);
  --grid: #2c2c2a;
  --axis: #383835;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s1-wash: rgba(57, 135, 229, .12);
  --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px -12px rgba(0, 0, 0, .8);
}

/* ---------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -.01em;
}

p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--s1);
  outline-offset: 2px;
  border-radius: 4px;
}

/*
 * The `hidden` attribute only gets `display: none` from the UA stylesheet, so
 * any class that sets `display` silently outranks it and the element stays on
 * screen forever. Every element this app toggles with `hidden` also carries
 * such a class, so the attribute needs to win outright.
 */
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--s1);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 600;
}

.brand-text small {
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-inline-start: auto;
}

.topbar__meta {
  display: flex;
  gap: 16px;
  color: var(--ink-3);
  font-size: 12px;
}

.topbar__meta b {
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* status pill: colour is backed by a dot shape + text, never colour alone */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-raised);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}

.pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}

.pill[data-state="ok"] .pill__dot {
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent);
}

.pill[data-state="warn"] .pill__dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent);
}

.pill[data-state="down"] .pill__dot {
  background: var(--critical);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--critical) 22%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .pill[data-state="ok"] .pill__dot {
    animation: pulse 2.6s ease-in-out infinite;
  }
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent);
  }

  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 8%, transparent);
  }
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-1);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}

.btn:hover {
  background: var(--surface-raised);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn--quiet {
  border-color: transparent;
  color: var(--ink-2);
}

.btn--sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn--icon {
  padding: 6px;
}

.btn--primary {
  background: var(--s1);
  border-color: var(--s1);
  color: #fff;
}

.btn--primary:hover {
  background: color-mix(in srgb, var(--s1) 88%, #000);
}

.btn--block {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
}

.btn.is-busy {
  pointer-events: none;
  opacity: .6;
}

.icon {
  width: 14px;
  height: 14px;
  flex: none;
}

.icon--moon {
  display: none;
}

:root[data-theme="dark"] .icon--sun {
  display: none;
}

:root[data-theme="dark"] .icon--moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .icon--sun {
    display: none;
  }

  :root:where(:not([data-theme="light"])) .icon--moon {
    display: block;
  }
}

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 12px 24px 0;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  font-size: 13px;
}

.banner strong {
  font-weight: 600;
}

.banner--warn {
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
}

.banner--error {
  background: color-mix(in srgb, var(--critical) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--critical) 40%, transparent);
}

.banner span {
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- layout */

main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card__head h2 {
  font-size: 14px;
}

.card__head h3 {
  font-size: 13px;
}

.card__sub {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
  max-width: 62ch;
}

.card__head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- summary */

.summary {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 1.6fr);
  gap: 16px;
}

.card--hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero__figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

/* Proportional figures: tabular-nums makes a display-size number look loose. */
.hero__value {
  font-size: clamp(40px, 5.2vw, 60px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
}

.hero__unit {
  color: var(--ink-3);
  font-size: 15px;
}

.hero__delta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.delta {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.delta[data-dir="up"] {
  color: var(--critical);
}

.delta[data-dir="down"] {
  color: var(--good-text);
}

.delta::before {
  font-size: 11px;
  content: "→";
}

.delta[data-dir="up"]::before {
  content: "▲";
}

.delta[data-dir="down"]::before {
  content: "▼";
}

.hero__spark {
  height: 68px;
  margin: 0 -4px;
}

.hero__facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.hero__facts div {
  min-width: 0;
}

.hero__facts dt {
  color: var(--ink-3);
  font-size: 11px;
  margin-bottom: 2px;
}

.hero__facts dd {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero__facts i {
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card--tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.card--tile h3 {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

.tile__value {
  font-size: 27px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.tile__note {
  color: var(--ink-3);
  font-size: 11.5px;
}

/* ---------------------------------------------------------------- filters */

.filters {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.filters__group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filters__group--end {
  margin-inline-start: auto;
}

.filters__group--range {
  gap: 6px;
  padding-inline-start: 20px;
  border-inline-start: 1px solid var(--hairline);
}

.filters__dash {
  color: var(--ink-3);
}

.filters__hint {
  color: var(--ink-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.input--sm {
  padding: 3px 7px;
  font-size: 12px;
}

.filters__label {
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.segmented button {
  padding: 4px 11px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--ink-1);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink-1);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .10);
}

.segmented--sm button {
  padding: 3px 9px;
  font-size: 12px;
}

.input {
  padding: 5px 9px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-2);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--axis);
  transition: background .15s ease;
  flex: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}

.switch input:checked+.switch__track {
  background: var(--s1);
}

.switch input:checked+.switch__track::after {
  transform: translateX(14px);
}

.switch input:focus-visible+.switch__track {
  outline: 2px solid var(--s1);
  outline-offset: 2px;
}

.switch__text b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- charts */

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.span-12 {
  grid-column: span 12;
}

.span-7 {
  grid-column: span 7;
}

.span-5 {
  grid-column: span 5;
}

.card--chart {
  display: flex;
  flex-direction: column;
}

/* Height includes the x-axis band so the card never grows a nested scrollbar. */
.chart {
  width: 100%;
  height: 260px;
}

.chart--tall {
  height: 320px;
}

.card--chart.is-loading .chart {
  opacity: .45;
  transition: opacity .2s ease;
}

.card--chart.is-empty .chart {
  display: none;
}

.state {
  display: grid;
  place-items: center;
  height: 200px;
  color: var(--ink-3);
  font-size: 13px;
}

.card--chart.is-empty .state[data-state="empty"] {
  display: grid;
}

/* ---------------------------------------------------------------- table */

.card--table {
  padding-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-3);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--surface-raised);
}

.table .num,
.table td.num {
  text-align: right;
}

.table__placeholder td {
  padding: 22px;
  text-align: center;
  color: var(--ink-3);
}

.table-more {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--hairline-strong);
  color: var(--ink-2);
}

.badge--reset {
  border-color: color-mix(in srgb, var(--warning) 55%, transparent);
  background: color-mix(in srgb, var(--warning) 16%, transparent);
}

/* ---------------------------------------------------------------- footer */

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 18px 24px 32px;
  color: var(--ink-3);
  font-size: 11.5px;
  border-top: 1px solid var(--hairline);
}

.footer__sep {
  opacity: .5;
}

/* ---------------------------------------------------------------- login */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(60rem 40rem at 50% -10%, var(--s1-wash), transparent 70%),
    var(--page);
}

.login {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.login__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.login__brand h1 {
  font-size: 19px;
}

.login__brand p {
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  color: var(--ink-2);
}

.field .input {
  padding: 9px 11px;
  font-size: 14px;
}

.login__error {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--critical) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent);
  font-size: 12.5px;
}

.login__foot {
  text-align: center;
  color: var(--ink-3);
  font-size: 11px;
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .summary {
    grid-template-columns: 1fr;
  }

  .span-7,
  .span-5 {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {

  main,
  .topbar {
    padding-inline: 14px;
  }

  .banner {
    margin-inline: 14px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar__status {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
  }

  .card {
    padding: 15px 14px;
  }

  .chart,
  .chart--tall {
    height: 240px;
  }

  .hero__facts {
    grid-template-columns: 1fr 1fr;
  }

  .brand-text small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/*
 * The projection's uncertainty band. It sits under the headline number rather
 * than beside it: the point estimate is what gets read at a glance, the range
 * is what stops it being mistaken for a certainty.
 */
.fact__range {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
