/* Server Monitor — "enamel rack panel".
   Light cool-grey enamel with a dark log well set into it; graphite in dark mode.
   Colour is reserved for state: healthy, warning, fault. Mono is used only for
   identifiers (container names, images, ports, keys) and log text. */

@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-hyperlegible-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(fonts/jetbrains-mono-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --enamel: #E8ECEE;       /* page */
  --panel: #F7F8F9;        /* raised surfaces */
  --sunk: #DDE3E7;         /* insets, table head, tracks */
  --rule: #C7CFD6;
  --ink: #18212B;
  --ink-2: #4A5763;        /* secondary text, still AA on enamel */
  --ok: #1E7A55;   --ok-bg: #D9EDE3;
  --warn: #A2650A; --warn-bg: #F4E6CC;
  --fault: #B42318; --fault-bg: #F6D9D5;
  --link: #1D5FBF;
  --well: #141A21; --well-ink: #D5DDE5; --well-dim: #7D8A97; --well-err: #FF9C8F;
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r-panel: 10px; --r-ctl: 7px; --r-tag: 4px;
  --side: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --enamel: #1C2126; --panel: #242A30; --sunk: #2C333A; --rule: #3A434C;
    --ink: #E4E8EC; --ink-2: #A3AEB9;
    --ok: #5CC395; --ok-bg: #1F3A2F;
    --warn: #E5AE52; --warn-bg: #3D3220;
    --fault: #F2786C; --fault-bg: #452622;
    --link: #8AB4FF;
    --well: #11161B;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--enamel); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--link); text-underline-offset: 2px; }
a:not(:hover) { text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; color: var(--ink-2); }
p { margin: .4rem 0; max-width: 72ch; }
code, .mono { font-family: var(--mono); font-size: .86em; }
small, .small { font-size: .85rem; }
.muted { color: var(--ink-2); }
.ok-text { color: var(--ok); font-weight: 700; }
.crit-text { color: var(--fault); }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------- shell: sidebar + content ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--rule); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: var(--ink); display: grid; gap: .1rem; }
.brand b { font-size: 1.05rem; }
.brand span { font-family: var(--mono); font-size: .8rem; color: var(--ink-2); overflow-wrap: anywhere; }
.navgroup { display: grid; gap: 2px; }
.navgroup h3 { padding: 0 .6rem .3rem; font-size: .8rem; }
.navgroup a { color: var(--ink); padding: .42rem .6rem; border-radius: var(--r-ctl); display: flex; justify-content: space-between; align-items: center; }
.navgroup a:hover { background: var(--sunk); text-decoration: none; }
.navgroup a[aria-current] { background: var(--ink); color: var(--panel); font-weight: 700; }
.navgroup .count { font-size: .78rem; font-weight: 700; min-width: 1.4rem; text-align: center; border-radius: var(--r-tag); padding: 0 .3rem; background: var(--fault); color: #fff; }
.who { margin-top: auto; border-top: 1px solid var(--rule); padding-top: 1rem; display: grid; gap: .5rem; font-size: .9rem; }
.who a { color: var(--ink); }
.who form { margin: 0; }
.unlock { font-size: .8rem; color: var(--ok); }
main { padding: 1.75rem 2.25rem 3rem; max-width: 1240px; width: 100%; min-width: 0; /* let wide tables scroll instead of widening the page */ }
main.narrow { max-width: 460px; margin: 0 auto; padding-top: 12vh; }
main.narrow:has(.auth.wide) { max-width: 620px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--rule); }
  .brand { flex: 1 1 auto; }
  .navgroup { display: flex; flex-wrap: nowrap; overflow-x: auto; width: 100%; order: 3; gap: 4px; }
  .navgroup a { flex: none; }
  .navgroup + .navgroup { order: 4; }
  .navgroup h3 { display: none; }
  .who { margin: 0; border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .75rem; order: 2; }
  .unlock { display: none; }
  main { padding: 1.25rem 1rem 2.5rem; }
  .headline { font-size: 1.7rem; }
  .strip { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ---------- sections ---------- */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; overflow-x: auto; }
.card.center { text-align: center; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.auth h1 { margin-bottom: .75rem; }

.flash, .error { padding: .7rem 1rem; border-radius: var(--r-ctl); margin-bottom: 1rem; border-left: 4px solid; }
.flash { background: var(--ok-bg); border-color: var(--ok); }
.error { background: var(--fault-bg); border-color: var(--fault); }

/* ---------- overview hero: status sentence + service strip ---------- */
.hero { margin: .25rem 0 1.5rem; }
.hero .host { font-family: var(--mono); color: var(--ink-2); font-size: .9rem; }
.headline { font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; margin: .2rem 0 1rem; max-width: 30ch; }
.headline.ok { color: var(--ink); }
.headline.warn { color: var(--warn); }
.headline.fault { color: var(--fault); }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; padding: 4px; background: var(--sunk); border-radius: var(--r-panel); }
.cell { display: grid; gap: .1rem; padding: .55rem .7rem .6rem; border-radius: 6px; background: var(--panel); color: var(--ink); border-top: 4px solid var(--ok); min-width: 0; }
.cell:hover { text-decoration: none; outline: 1px solid var(--rule); }
.cell b { font-family: var(--mono); font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell span { font-size: .8rem; color: var(--ink-2); }
.cell.pending { border-top-color: var(--warn); }
.cell.fault { border-top-color: var(--fault); background: var(--fault-bg); }
.cell.paused { border-top-color: var(--rule); opacity: .7; }
.strip-empty { padding: .9rem 1rem; color: var(--ink-2); }

/* ---------- gauges ---------- */
/* Gauges share one panel; each wraps as a flexible column so no empty cell is left over. */
.tiles { display: flex; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-panel); overflow: hidden; margin-bottom: 1.5rem; }
.tile { flex: 1 1 170px; padding: .8rem 1rem; display: grid; gap: .3rem; align-content: start; box-shadow: -1px 0 0 var(--rule), 0 -1px 0 var(--rule); }
.big { font-size: 1.55rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.big .muted { font-size: 1rem; font-weight: 400; }
.bar { width: 100%; height: 5px; display: block; border-radius: 3px; overflow: hidden; }
.bar .track { fill: var(--sunk); }
.bar .fill.ok { fill: var(--ok); }
.bar .fill.warn { fill: var(--warn); }
.bar .fill.crit { fill: var(--fault); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-size: .82rem; color: var(--ink-2); font-weight: 700; background: var(--sunk); border-bottom: 0; white-space: nowrap; }
td[title] { white-space: nowrap; }
thead th:first-child { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
thead th:last-child { border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
tbody tr:last-child td { border-bottom: 0; }
td.w40 { width: 28%; vertical-align: middle; }
td a strong, .ident { font-family: var(--mono); font-weight: 600; font-size: .9rem; }
tr.crit-row td:first-child { box-shadow: inset 4px 0 0 var(--fault); }

/* ---------- tags (state) ---------- */
.pill { display: inline-block; padding: .05rem .45rem; border-radius: var(--r-tag); font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--sunk); color: var(--ink-2); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--fault-bg); color: var(--fault); }
.pill.muted { background: var(--sunk); color: var(--ink-2); font-weight: 400; }

/* ---------- facts, graphs ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem 1.5rem; margin: .5rem 0 1rem; }
.facts dt { color: var(--ink-2); font-size: .82rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.sparks, .sysgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
figure { margin: 0; display: grid; gap: .35rem; }
figcaption { color: var(--ink-2); font-size: .85rem; }
.spark { width: 100%; height: 52px; background: var(--sunk); border-radius: 6px; }
.spark polyline { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-empty { fill: var(--ink-2); font-size: 11px; }

/* ---------- controls ---------- */
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.actions form, form.inline { display: inline-flex; gap: .5rem; align-items: end; margin: 0 .5rem .5rem 0; flex-wrap: wrap; }
button, .button { font: inherit; font-weight: 700; font-size: .92rem; padding: .45rem .9rem; border-radius: var(--r-ctl); border: 1px solid var(--rule); background: var(--panel); color: var(--ink); cursor: pointer; display: inline-block; line-height: 1.3; }
button:hover, .button:hover { border-color: var(--ink-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .button.primary { background: var(--ink); border-color: var(--ink); color: var(--panel); }
button.primary:hover { background: var(--link); border-color: var(--link); }
button.danger { color: var(--fault); border-color: var(--fault); background: transparent; }
button.danger:hover { background: var(--fault-bg); }
button.link { background: none; border: 0; padding: 0; color: var(--link); font-weight: 400; }
button.link.danger { color: var(--fault); }
button[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }

form label { display: grid; gap: .25rem; color: var(--ink-2); font-size: .85rem; font-weight: 700; }
form label.check { display: flex; gap: .55rem; align-items: center; color: var(--ink); font-weight: 400; font-size: .92rem; }
input, select { font: inherit; padding: .45rem .6rem; border-radius: var(--r-ctl); border: 1px solid var(--rule); background: var(--panel); color: var(--ink); min-width: 0; }
input:focus, select:focus { border-color: var(--link); outline: 2px solid color-mix(in srgb, var(--link) 30%, transparent); outline-offset: 0; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }
.auth form { display: grid; gap: .9rem; margin: .75rem 0 1rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem 1.25rem; align-items: end; }
.grid-form .full, fieldset.full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: .75rem 1rem; }
legend { padding: 0 .4rem; font-weight: 700; }
.grants td { border: 0; padding: .25rem .4rem; }
.grants td:first-child input { width: 100%; font-family: var(--mono); font-size: .88rem; }

/* ---------- sign-in, enrolment ---------- */
.enrol { display: flex; gap: 1.25rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.enrol img { background: #fff; padding: 8px; border-radius: var(--r-ctl); border: 1px solid var(--rule); image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 1rem; letter-spacing: .04em; padding: .5rem .7rem; background: var(--sunk); border-radius: var(--r-ctl); display: inline-block; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: .4rem 2rem; padding: 0; list-style: none; font-size: 1.05rem; }
.codes code { font-size: 1rem; }

/* ---------- logs: the dark well ---------- */
.logbar { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; margin-bottom: .75rem; }
.logs { background: var(--well); color: var(--well-ink); font: 12.5px/1.55 var(--mono); border-radius: var(--r-ctl); padding: .6rem .8rem; height: 64vh; overflow: auto; box-shadow: inset 0 1px 3px rgba(0,0,0,.35); }
.logs .ln { white-space: pre; display: flex; gap: .8rem; }
.logs.wrap .ln { white-space: pre-wrap; overflow-wrap: anywhere; }
.logs .ln time { color: var(--well-dim); flex: none; user-select: none; }
.logs .ln.err span { color: var(--well-err); }
.logs .ln.note { color: var(--well-dim); font-style: italic; font-family: var(--sans); }
.logs:focus-visible { outline: 2px solid var(--link); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; display: none; animation: spin .8s linear infinite; align-self: center; }
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------- authenticator pop-up ---------- */
dialog#stepup-dialog { border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 1.25rem 1.4rem; background: var(--panel); color: var(--ink); width: min(420px, calc(100vw - 2rem)); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog#stepup-dialog::backdrop { background: rgba(20, 26, 33, .55); }
#stepup-form { display: grid; gap: .8rem; }
#stepup-form h2 { margin: 0; }
#stepup-form p { margin: 0; }
#stepup-code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .25em; text-align: center; }
#stepup-form .actions { justify-content: flex-end; }
