/* SparkHub dashboard. Plain CSS, light and dark. */
:root {
  --bg: #f4f5f3; --surface: #ffffff; --fg: #1b1f1d; --muted: #5f6862; --rule: #d9ddd8;
  --accent: #22594a; --accent-fg: #ffffff; --ok: #1f6b3a; --ok-bg: #e5f2e8; --warn: #7a5200; --warn-bg: #fbf1dc;
  --err: #9b1c1c; --err-bg: #fbe7e7; --load: #8a5a00;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --surface: #181c1a; --fg: #e3e8e4; --muted: #96a19a; --rule: #2a312d;
    --accent: #7cc3ab; --accent-fg: #0d1512; --ok: #8fd6a4; --ok-bg: #16281c; --warn: #f0c56b; --warn-bg: #2b2414;
    --err: #f39a9a; --err-bg: #2e1717; --load: #f0c56b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--sans); }
main { max-width: 1240px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
code, pre { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
small { font-size: 12px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--fg); }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a[aria-current] { color: var(--fg); font-weight: 600; }
.top nav a:hover { color: var(--accent); }
.modebadge { font: 12px var(--mono); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--rule); }
.logout { margin: 0; }

button, .button { font: inherit; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--err); color: #fff; }
button.small { padding: 3px 9px; font-size: 13px; }
button.link { background: none; color: var(--muted); padding: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 5px; padding: 5px 8px; }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.auth { max-width: 380px; margin: 9vh auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 24px; }
.auth.wide { max-width: 520px; }
.auth form { display: grid; gap: 12px; }
.auth label { display: grid; gap: 4px; }
.qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 6px; }
.secret { word-break: break-all; user-select: all; }
.codes { columns: 2; font-size: 16px; }

.ok, .warn, .error { border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.ok { background: var(--ok-bg); color: var(--ok); }
.warn { background: var(--warn-bg); color: var(--warn); }
.error { background: var(--err-bg); color: var(--err); }
.error-text { color: var(--err); }
.sub.error { padding: 0; background: none; }
.ok p, .warn p, .error p { margin: 4px 0; }

.live { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; }
.tile.big { grid-column: span 2; }
.tile.wide { margin: 12px 0; }
.tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.tile .sub { font-size: 13px; color: var(--muted); }
.state-ready .value { color: var(--ok); }
.state-loading .value, .state-draining .value, .state-stopping .value { color: var(--load); }
.state-failed .value { color: var(--err); }
.modebadge.state-ready { color: var(--ok); } .modebadge.state-failed { color: var(--err); }
.modebadge.state-loading, .modebadge.state-draining, .modebadge.state-stopping { color: var(--load); }
.progress { height: 6px; background: var(--rule); border-radius: 3px; margin: 8px 0 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--load); }
.progress span.w0 { width: 0%; }
.progress span.w5 { width: 5%; }
.progress span.w10 { width: 10%; }
.progress span.w15 { width: 15%; }
.progress span.w20 { width: 20%; }
.progress span.w25 { width: 25%; }
.progress span.w30 { width: 30%; }
.progress span.w35 { width: 35%; }
.progress span.w40 { width: 40%; }
.progress span.w45 { width: 45%; }
.progress span.w50 { width: 50%; }
.progress span.w55 { width: 55%; }
.progress span.w60 { width: 60%; }
.progress span.w65 { width: 65%; }
.progress span.w70 { width: 70%; }
.progress span.w75 { width: 75%; }
.progress span.w80 { width: 80%; }
.progress span.w85 { width: 85%; }
.progress span.w90 { width: 90%; }
.progress span.w95 { width: 95%; }
.progress span.w100 { width: 100%; }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 12px; }
.charts figure { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 10px; }
.charts figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.chart { min-height: 170px; }
.uplot, .u-legend { color: var(--fg); }

.modecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; margin: 12px 0; }
.modecard, .panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; margin: 0 0 12px; }
.modecard.current { border-color: var(--accent); }
.modecard h2, .panel h2 { margin-top: 0; }
.pill { font-size: 11px; background: var(--accent); color: var(--accent-fg); padding: 1px 7px; border-radius: 8px; vertical-align: middle; }
.row { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 2px 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.row small { grid-column: 1 / -1; }
.row.changed span { font-weight: 650; color: var(--warn); }

table { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.dense td { padding: 3px 8px; font-size: 13px; white-space: nowrap; }
tr.dim td { color: var(--muted); }
tr.warnrow td { background: var(--warn-bg); }
.trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll { overflow-x: auto; }
pre.logs { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px; overflow: auto; max-height: 75vh; white-space: pre-wrap; word-break: break-all; }

.report { max-width: 980px; }
.report table { display: block; overflow-x: auto; }
.report code { background: var(--surface); padding: 1px 4px; border-radius: 3px; }

@media (max-width: 640px) {
  .tile.big { grid-column: span 1; }
  .top nav { order: 3; flex-basis: 100%; }
}
.steps li { margin: 10px 0; max-width: 90ch; }
.steps pre { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px; overflow-x: auto; }
.auth label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
