/* ---------------------------------------------------------------
   00337700 dashboard
   Colour tokens are the validated data-viz reference palette:
   status colours are fixed (never themed), meters use one blue ramp.
   --------------------------------------------------------------- */

:root {
  color-scheme: light;
  --plane:        #f9f9f7;
  --surface:      #fcfcfb;
  --surface-2:    #f4f3ef;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --muted:        #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --border:       rgba(11, 11, 11, 0.10);
  --border-strong:rgba(11, 11, 11, 0.16);
  --accent:       #2a78d6;
  --accent-soft:  #cde2fb;
  --shadow:       0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);

  /* status palette — fixed, identical in both modes */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;

  --radius:  14px;
  --radius-s: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:        #0d0d0d;
    --surface:      #1a1a19;
    --surface-2:    #212120;
    --ink:          #ffffff;
    --ink-2:        #c3c2b7;
    --muted:        #898781;
    --grid:         #2c2c2a;
    --axis:         #383835;
    --border:       rgba(255, 255, 255, 0.10);
    --border-strong:rgba(255, 255, 255, 0.16);
    --accent:       #3987e5;
    --accent-soft:  #184f95;
    --shadow:       0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:        #0d0d0d;
  --surface:      #1a1a19;
  --surface-2:    #212120;
  --ink:          #ffffff;
  --ink-2:        #c3c2b7;
  --muted:        #898781;
  --grid:         #2c2c2a;
  --axis:         #383835;
  --border:       rgba(255, 255, 255, 0.10);
  --border-strong:rgba(255, 255, 255, 0.16);
  --accent:       #3987e5;
  --accent-soft:  #184f95;
  --shadow:       0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

/* ------------------------------------------------------------- sign in */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.gate-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate-card h1 {
  margin: 14px 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.gate-card p.sub {
  margin: 0 0 22px;
  color: var(--ink-2);
  font-size: 13px;
}

/* --------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--plane);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--axis); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  padding: 11px 14px;
}

.btn-primary:hover { filter: brightness(1.06); }

.notice {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.notice::before { flex: none; }
.notice.error   { border-color: color-mix(in oklab, var(--critical) 45%, var(--border)); }
.notice.error::before   { content: "✕"; color: var(--critical); }
.notice.success { border-color: color-mix(in oklab, var(--good) 45%, var(--border)); }
.notice.success::before { content: "✓"; color: var(--good); }
.notice.warning { border-color: color-mix(in oklab, var(--warning) 55%, var(--border)); }
.notice.warning::before { content: "!"; color: var(--warning); font-weight: 700; }

/* -------------------------------------------------------------- shell */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 64px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grid);
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-dot {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand .sub {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

/* --------------------------------------------------------- status pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.pill[data-tone="good"]::before     { background: var(--good); }
.pill[data-tone="warning"]::before  { background: var(--warning); }
.pill[data-tone="serious"]::before  { background: var(--serious); }
.pill[data-tone="critical"]::before { background: var(--critical); }
.pill[data-tone="accent"]::before   { background: var(--accent); }

.pill[data-tone="good"]     { border-color: color-mix(in oklab, var(--good) 40%, var(--border)); }
.pill[data-tone="warning"]  { border-color: color-mix(in oklab, var(--warning) 50%, var(--border)); }
.pill[data-tone="serious"]  { border-color: color-mix(in oklab, var(--serious) 50%, var(--border)); }
.pill[data-tone="critical"] { border-color: color-mix(in oklab, var(--critical) 45%, var(--border)); }

/* ------------------------------------------------------- service cards */

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}

.card-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.card-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-title .tagline { font-size: 12.5px; color: var(--ink-2); }

.card-title .endpoint {
  font-size: 11.5px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-all;
}

.card-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.latency {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------- lead + tiles */

.lead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.lead-label {
  width: 100%;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}

.lead-value {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lead-caption {
  font-size: 12.5px;
  color: var(--muted);
  flex: 1 1 220px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--grid);
  border: 1px solid var(--grid);
  border-radius: var(--radius-s);
  overflow: hidden;
}

.tile { background: var(--surface); padding: 14px 16px; }

.tile-label {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.tile-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tile-value .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}

.tile-value .dot[data-tone="good"]     { background: var(--good); }
.tile-value .dot[data-tone="warning"]  { background: var(--warning); }
.tile-value .dot[data-tone="serious"]  { background: var(--serious); }
.tile-value .dot[data-tone="critical"] { background: var(--critical); }

.tile-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- section */

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.section-note { font-size: 12px; color: var(--muted); flex: 1 1 240px; }

/* -------------------------------------------------------------- meters */

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

.meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.meter-label { font-size: 13px; font-weight: 500; }

.meter-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.track {
  height: 10px;
  border-radius: 5px;
  background: color-mix(in oklab, var(--fill, var(--accent)) 16%, var(--surface-2));
  overflow: hidden;
}

.track-fill {
  height: 100%;
  background: var(--fill, var(--accent));
  border-radius: 5px 2px 2px 5px;
  min-width: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter[data-tone="good"],     .track[data-tone="good"]     { --fill: var(--accent); }
.meter[data-tone="neutral"],  .track[data-tone="neutral"]  { --fill: var(--muted); }
.meter[data-tone="warning"],  .track[data-tone="warning"]  { --fill: var(--warning); }
.meter[data-tone="serious"],  .track[data-tone="serious"]  { --fill: var(--serious); }
.meter[data-tone="critical"], .track[data-tone="critical"] { --fill: var(--critical); }

.meter-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meter-caption {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--ink-2);
}

/* --------------------------------------------------------------- facts */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 22px;
}

.fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--grid);
}

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

.fact-value {
  font-size: 12.5px;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fact-value[data-tone="good"]     { color: var(--good); }
.fact-value[data-tone="warning"]  { color: color-mix(in oklab, var(--warning) 80%, var(--ink)); }
.fact-value[data-tone="serious"]  { color: var(--serious); }
.fact-value[data-tone="critical"] { color: var(--critical); }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--grid); border-radius: var(--radius-s); }

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

thead th {
  text-align: left;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--grid);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

td.right, th.right { text-align: right; }

.cell-primary { font-weight: 500; font-variant-numeric: tabular-nums; }
.cell-secondary { font-size: 11px; color: var(--muted); margin-top: 1px; }

.cell-meter {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: flex-end;
}

.cell-meter .track { width: 74px; height: 7px; border-radius: 4px; flex: none; }
.cell-meter .num { font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------------------------------------------------------------- misc */

details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-2);
  user-select: none;
}

details pre {
  margin: 12px 0 0;
  padding: 14px;
  background: var(--plane);
  border: 1px solid var(--grid);
  border-radius: var(--radius-s);
  overflow: auto;
  max-height: 380px;
  font-size: 11.5px;
  line-height: 1.5;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.state-block {
  padding: 26px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  max-width: 460px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.panel p.sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.skeleton {
  height: 160px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border: 1px solid var(--border);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 640px) {
  .shell { padding: 16px 14px 48px; }
  .lead-value { font-size: 28px; }
}

/* ------------------------------------------------------- compact cards */

.ccard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px 13px;
  display: grid;
  gap: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.ccard:hover,
.ccard:focus-visible {
  border-color: var(--axis);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(11, 11, 11, 0.06), 0 14px 34px rgba(11, 11, 11, 0.07);
}

.ccard:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent); }
.ccard:hover .ccard-more,
.ccard:focus-visible .ccard-more { color: var(--accent); }

.ccard[data-state="offline"],
.ccard[data-state="unauthorised"] { border-left: 3px solid var(--critical); }
.ccard[data-state="degraded"]     { border-left: 3px solid var(--warning); }

.ccard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ccard-id { min-width: 0; }

.ccard-id h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ccard-host {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ccard-status {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

/* lead figure — the one number the card is about */
.ccard-lead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.ccard-value {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.ccard-lead-label { font-size: 11.5px; color: var(--ink-2); }

.ccard-meter .track { height: 7px; border-radius: 4px; }

.ccard-meter-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* four micro stats, hairline-separated */
.ccard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--grid);
  border-radius: var(--radius-s);
  overflow: hidden;
}

.cstat {
  background: var(--surface);
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cstat b {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cstat span {
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* per-account headroom, one small vertical bar each */
.strip { display: flex; align-items: flex-end; gap: 12px; justify-content: space-between; }

.strip-label {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 12px;
  flex: none;
}

.strip-bars { display: flex; align-items: flex-end; gap: 5px; flex: 1 1 auto; justify-content: flex-end; }

.sbar {
  flex: 0 1 34px;
  min-width: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: help;
}

.sbar-track {
  width: 100%;
  height: 24px;
  border-radius: 3px;
  background: color-mix(in oklab, var(--fill, var(--accent)) 16%, var(--surface-2));
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.sbar-fill {
  width: 100%;
  background: var(--fill, var(--accent));
  border-radius: 3px 3px 2px 2px;
  min-height: 2px;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sbar[data-tone="good"]     { --fill: var(--accent); }
.sbar[data-tone="neutral"]  { --fill: var(--muted); }
.sbar[data-tone="warning"]  { --fill: var(--warning); }
.sbar[data-tone="serious"]  { --fill: var(--serious); }
.sbar[data-tone="critical"] { --fill: var(--critical); }

.sbar-key {
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ccard-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 11px;
  border-top: 1px solid var(--grid);
}

.chip {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.chip[data-tone="good"]     { color: var(--good);     border-color: color-mix(in oklab, var(--good) 35%, var(--border)); }
.chip[data-tone="warning"]  { color: color-mix(in oklab, var(--warning) 80%, var(--ink)); border-color: color-mix(in oklab, var(--warning) 45%, var(--border)); }
.chip[data-tone="serious"]  { color: var(--serious);  border-color: color-mix(in oklab, var(--serious) 45%, var(--border)); }
.chip[data-tone="critical"] { color: var(--critical); border-color: color-mix(in oklab, var(--critical) 40%, var(--border)); }

.ccard-more {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s;
  white-space: nowrap;
}

.ccard-fallback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 2px;
}

.ccard-fallback p { margin: 0; font-size: 12.5px; color: var(--ink-2); }

/* ------------------------------------------------------- detail dialog */

.detail {
  width: min(1000px, calc(100vw - 40px));
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.detail::backdrop { background: rgba(11, 11, 11, 0.45); backdrop-filter: blur(2px); }

.detail[open] {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--grid);
  background: var(--surface);
}

.detail-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}

/* never let a block with overflow:hidden (the tile row) collapse when the
   dialog runs out of height — it scrolls instead */
.detail-body > * { flex: 0 0 auto; }

.detail-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--grid);
  background: var(--surface-2);
}

.icon-btn { padding: 6px 10px; font-size: 13px; line-height: 1; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .ccard-value { font-size: 24px; }
  .detail { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; border: none; }
  .detail-body { padding: 16px; gap: 18px; }
}

