/* NxGen Status - one stylesheet for the login page and the dashboard.
   Colour roles follow the data-viz reference palette: status colours are
   reserved for state and always travel with an icon and a word. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-track: #cde2fb;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --critical: #d03b3b;
  --critical-ink: #b02a2a;
  --good-wash: rgba(12, 163, 12, 0.08);
  --warning-wash: rgba(250, 178, 25, 0.14);
  --critical-wash: rgba(208, 59, 59, 0.09);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #98968f;
    --hairline: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-track: #184f95;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --critical-ink: #ef6b6b;
    --good-wash: rgba(12, 163, 12, 0.14);
    --warning-wash: rgba(250, 178, 25, 0.13);
    --critical-wash: rgba(208, 59, 59, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #98968f;
  --hairline: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-track: #184f95;
  --good-ink: #0ca30c;
  --warning-ink: #fab219;
  --critical-ink: #ef6b6b;
  --good-wash: rgba(12, 163, 12, 0.14);
  --warning-wash: rgba(250, 178, 25, 0.13);
  --critical-wash: rgba(208, 59, 59, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; overflow-x: hidden; }

a { color: var(--accent); }

button {
  font: inherit;
  color: inherit;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ------------------------------------------------------------------ */
/*  Top bar                                                            */
/* ------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 16px;
  min-width: 0;
}

.brand-mark { width: 26px; height: 26px; flex: none; }

.topbar-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.updated { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spinning svg { animation: none; } }

/* ------------------------------------------------------------------ */
/*  Layout                                                             */
/* ------------------------------------------------------------------ */
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.section-title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 28px 0 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.banner {
  display: none;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warning-wash);
  color: var(--ink);
  font-size: 14px;
}
.banner.show { display: flex; gap: 8px; align-items: flex-start; }

/* ------------------------------------------------------------------ */
/*  Status glyphs - never colour alone: icon + word                    */
/* ------------------------------------------------------------------ */
.glyph { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -4px; }
.glyph.good { color: var(--good); }
.glyph.warning { color: var(--warning); }
.glyph.critical { color: var(--critical); }
.glyph.muted { color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 7px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pill .glyph { width: 15px; height: 15px; vertical-align: 0; }
.pill.good { background: var(--good-wash); color: var(--good-ink); }
.pill.warning { background: var(--warning-wash); color: var(--warning-ink); }
.pill.critical { background: var(--critical-wash); color: var(--critical-ink); }
.pill.muted { background: var(--surface-2); color: var(--ink-2); }

/* ------------------------------------------------------------------ */
/*  Hero                                                               */
/* ------------------------------------------------------------------ */
.hero {
  padding: 22px 22px 20px;
  display: grid;
  gap: 18px;
}

.hero-head { display: flex; gap: 14px; align-items: flex-start; }

.hero-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
}
.hero-icon .glyph { width: 26px; height: 26px; vertical-align: 0; }
.hero-icon.good { background: var(--good-wash); }
.hero-icon.warning { background: var(--warning-wash); }
.hero-icon.critical { background: var(--critical-wash); }

.hero h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.hero p { margin: 4px 0 0; color: var(--ink-2); }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--hairline);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.tile { background: var(--surface); padding: 12px 14px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--muted); }
.tile-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-value small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tile-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ */
/*  Problems                                                           */
/* ------------------------------------------------------------------ */
.problems { padding: 4px 0; }
.problem {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--hairline);
}
.problem:first-child { border-top: 0; }
.problem .glyph { margin-top: 1px; }
.problem-where { font-size: 13px; color: var(--muted); }
.problem-where strong { color: var(--ink-2); font-weight: 600; }
.problem-text { grid-column: 2; }

/* ------------------------------------------------------------------ */
/*  Machine cards                                                      */
/* ------------------------------------------------------------------ */
.machines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

.machine { overflow: hidden; }
.machine.is-stale .machine-body { opacity: 0.6; }

.machine-head {
  padding: 16px 18px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--hairline);
}
.machine-title { min-width: 0; flex: 1; }
.machine-title h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.machine-sub { font-size: 13px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.machine-body { padding: 14px 18px 6px; display: grid; gap: 14px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.runs { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.run-dot {
  width: 18px; height: 18px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.run-dot.good { background: var(--good-wash); color: var(--good-ink); }
.run-dot.critical { background: var(--critical-wash); color: var(--critical-ink); }
.run-dot svg { width: 11px; height: 11px; }
.runs-caption { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* Meter: severity on the fill, the track is a lighter step of the same ramp */
.meters { display: grid; gap: 10px; }
.meter-row { display: grid; gap: 5px; }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.meter-label span:first-child { font-weight: 600; }
.meter-label span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--accent-track);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}
.meter.warning { background: var(--warning-wash); }
.meter.warning > i { background: var(--warning); }
.meter.critical { background: var(--critical-wash); }
.meter.critical > i { background: var(--critical); }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Collapsible detail sections */
details.more {
  border-top: 1px solid var(--hairline);
  margin: 0 -18px;
}
details.more:first-of-type { margin-top: 4px; }
details.more > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary .chev { width: 16px; height: 16px; color: var(--muted); transition: transform 0.15s; flex: none; }
details.more[open] > summary .chev { transform: rotate(90deg); }
details.more > summary .count { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
details.more > summary:hover { background: var(--surface-2); }
.more-body { padding: 0 18px 14px; overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.grid th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
table.grid td {
  padding: 7px 8px 7px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td .glyph { width: 15px; height: 15px; vertical-align: -3px; margin-right: 4px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.tight { margin-bottom: 4px; }
.list { margin: 0; padding-left: 18px; }
.wrap { overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--ink-2);
}

.footer {
  margin-top: 36px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/*  Login                                                              */
/* ------------------------------------------------------------------ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 24px;
}
.login .brand { font-size: 18px; margin-bottom: 4px; }
.login p { color: var(--ink-2); margin: 0 0 20px; font-size: 14px; }
.login label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.login input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--axis);
  background: var(--page);
  color: var(--ink);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn {
  margin-top: 14px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--page);
  font-weight: 650;
  cursor: pointer;
}
.btn:hover { opacity: 0.9; }
.login-error {
  display: none;
  margin-bottom: 14px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--critical-wash);
  color: var(--critical-ink);
  font-size: 14px;
}
.login-error.show { display: block; }

/* ------------------------------------------------------------------ */
/*  Small screens                                                      */
/* ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 18px 16px 16px; }
  .hero h1 { font-size: 21px; }
  .machines { grid-template-columns: minmax(0, 1fr); }
  .problem { padding: 12px 16px; }
  .machine-head, .machine-body { padding-left: 16px; padding-right: 16px; }
  details.more { margin: 0 -16px; }
  details.more > summary, .more-body { padding-left: 16px; padding-right: 16px; }
  .kv { grid-template-columns: 96px 1fr; }
  .updated-long { display: none; }
}

/* ------------------------------------------------------------------ */
/*  Alerts line, expiry card, clients                                  */
/* ------------------------------------------------------------------ */
.alerts-line { margin: 0; color: var(--ink-2); }
.alerts-line .glyph { width: 15px; height: 15px; vertical-align: -3px; margin-right: 2px; }
.alerts-line code, .empty code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.expiry { padding: 6px 18px 10px; overflow-x: auto; }
.crit-text { color: var(--critical-ink); }

/* ------------------------------------------------------------------ */
/*  Charts                                                             */
/* ------------------------------------------------------------------ */
:root {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; }
}
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; }

.trends { display: grid; gap: 18px; }
.chart { display: grid; gap: 8px; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chart-title { margin: 0; font-size: 14px; font-weight: 650; }
.link-btn {
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.link-btn:hover { background: var(--surface-2); color: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.swatch.s1 { background: var(--s1); } .swatch.s2 { background: var(--s2); }
.swatch.s3 { background: var(--s3); } .swatch.s4 { background: var(--s4); }
.swatch.fail { background: var(--critical); }

.chart-plot { position: relative; touch-action: pan-y; }
.chart-svg { display: block; overflow: visible; }
.grid-line { stroke: var(--hairline); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.end-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.s1, .dot.s1 { stroke: var(--s1); } .line.s2, .dot.s2 { stroke: var(--s2); }
.line.s3, .dot.s3 { stroke: var(--s3); } .line.s4, .dot.s4 { stroke: var(--s4); }
.dot { fill: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.hit, .bar-hit { fill: transparent; cursor: crosshair; }
.bar.s1 { fill: var(--s1); } .bar.fail { fill: var(--critical); }

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--ring);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: nowrap;
}
.tip-head { font-weight: 650; margin-bottom: 2px; }
.table-scroll { max-height: 320px; overflow: auto; }

@media (forced-colors: active) {
  .meter > i { background: CanvasText; }
  .pill, .run-dot { border: 1px solid CanvasText; }
}
