/* The design system every surface shares.
 *
 * One stylesheet rather than one per page, because the five surfaces are
 * one product seen by five people and a tenant portal that looks like a
 * different company from the operator console is a tell.
 *
 * Instrument panel, not dashboard: a fixed summary band above stacked
 * panels, each panel a plain table of one thing. Nothing is a card unless
 * it is a node or a job. No gradients, no shadows that imply depth nothing
 * has, no colour that is not carrying information.
 */

:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --sunk: #eaeef0;
  --line: #d5dde0;
  --line-soft: #e4eaec;
  --ink: #121a1d;
  --ink-dim: #5a6b70;
  --ink-faint: #82959b;
  --accent: #0f6d8c;
  --accent-soft: #e0eef3;
  --ok: #1a6b4a;
  --ok-soft: #dff0e7;
  --warn: #8a5a0c;
  --warn-soft: #f9ecd6;
  --crit: #983024;
  --crit-soft: #fae4e0;
  --bar: #0f6d8c;
  --bar-track: #dde5e8;

  --display: "Chivo", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --gutter: 16px;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1214;
    --panel: #121b1e;
    --sunk: #0e1619;
    --line: #223035;
    --line-soft: #1a262a;
    --ink: #e3ebed;
    --ink-dim: #93a6ac;
    --ink-faint: #6d8187;
    --accent: #4bb8d8;
    --accent-soft: #10292f;
    --ok: #59b98c;
    --ok-soft: #10251c;
    --warn: #d8a654;
    --warn-soft: #2a2213;
    --crit: #e08878;
    --crit-soft: #2c1815;
    --bar: #4bb8d8;
    --bar-track: #1d2a2e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1214;
  --panel: #121b1e;
  --sunk: #0e1619;
  --line: #223035;
  --line-soft: #1a262a;
  --ink: #e3ebed;
  --ink-dim: #93a6ac;
  --ink-faint: #6d8187;
  --accent: #4bb8d8;
  --accent-soft: #10292f;
  --ok: #59b98c;
  --ok-soft: #10251c;
  --warn: #d8a654;
  --warn-soft: #2a2213;
  --crit: #e08878;
  --crit-soft: #2c1815;
  --bar: #4bb8d8;
  --bar-track: #1d2a2e;
}

* { box-sizing: border-box; }

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

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

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 64px;
}

/* --- masthead ------------------------------------------------------ */

.mast {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.mast-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: baseline;
}

.mast h1 {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.mast .sub {
  color: var(--ink-dim);
  font-size: 13px;
}

.mast nav {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mast nav a {
  font-size: 12.5px;
  text-decoration: none;
  color: var(--ink-dim);
  padding: 4px 9px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.mast nav a:hover { background: var(--sunk); color: var(--ink); }

.mast nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--line-soft);
}

/* --- provenance ---------------------------------------------------- */

/* Every surface says where its numbers came from, at the top, before
   anything else. A page of recorded data that does not say so is a
   mock-up pretending to be a product. */
.prov {
  margin: 14px 0 0;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 12.5px;
  color: var(--ink-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

.prov strong { color: var(--ink); font-weight: 600; }
.prov .spacer { margin-left: auto; }

.switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.switch button {
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  border: 0;
  background: var(--panel);
  color: var(--ink-dim);
  cursor: pointer;
}

.switch button + button { border-left: 1px solid var(--line); }
.switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }

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

.band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px;
  margin: 14px 0 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat { background: var(--panel); padding: 11px 13px; }

.stat .k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat .v {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat .n { font-size: 11.5px; color: var(--ink-dim); margin-top: 1px; }
.stat.is-ok .v { color: var(--ok); }
.stat.is-warn .v { color: var(--warn); }
.stat.is-crit .v { color: var(--crit); }

/* --- panels -------------------------------------------------------- */

.panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.panel > h2 {
  margin: 0;
  padding: 10px 13px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line-soft);
  background: var(--sunk);
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.panel > h2 .hint {
  margin-left: auto;
  font-family: var(--body);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-faint);
}

.panel .body { padding: 13px; }

/* --- tables -------------------------------------------------------- */

.tablewrap { overflow-x: auto; }

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

th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

td {
  padding: 8px 13px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

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

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
}

.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.mute { background: var(--sunk); color: var(--ink-dim); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* --- bars ---------------------------------------------------------- */

.bar { height: 7px; border-radius: 4px; background: var(--bar-track); overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; background: var(--bar); }
.bar.is-full > span { background: var(--crit); }

/* --- notes and empties --------------------------------------------- */

.note {
  font-size: 12.5px;
  color: var(--ink-dim);
  padding: 11px 13px;
  background: var(--sunk);
  border-top: 1px solid var(--line-soft);
}

.empty { padding: 20px 13px; color: var(--ink-faint); font-size: 13.5px; text-align: center; }

.gap {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
  padding: 10px 13px;
  font-size: 12.5px;
  border-radius: var(--radius);
  margin-top: 14px;
}

.gap strong { font-weight: 600; }

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

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin-bottom: 4px; }

.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
}

.field .help { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.field.bad input, .field.bad select { border-color: var(--crit); }
.field .err { font-size: 11.5px; color: var(--crit); margin-top: 3px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 13px; }

button.go {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.go[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- foot ---------------------------------------------------------- */

.foot {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
}

.foot p { margin: 0 0 6px; }

@media (max-width: 640px) {
  .row2 { grid-template-columns: 1fr; }
  .mast nav { margin-left: 0; width: 100%; }
  .stat .v { font-size: 22px; }
}
