/* SERMON dashboard. Colours are role tokens; dark mode swaps them in one place. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #96948d;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #96948d;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; margin: 28px 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink-2); }
p { margin: 0 0 10px; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 8px 22px; flex-wrap: wrap; min-height: 54px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: 0.04em; }
.brand img { width: 24px; height: 24px; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a {
  padding: 7px 11px; border-radius: 7px; color: var(--ink-2); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); }
.topbar-right { display: flex; gap: 6px; align-items: center; }
main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.page-head .sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; color: var(--ink-2); margin-bottom: 10px; }
.back:hover { color: var(--ink); }
.lead { color: var(--ink-2); max-width: 70ch; }

/* ---- buttons & forms ---- */
.btn {
  font: inherit; font-weight: 550; cursor: pointer;
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--critical); border-color: transparent; color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 550; margin-bottom: 4px; }
label.field > small { display: block; color: var(--muted); margin-top: 3px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select {
  font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }
.form-error { color: var(--critical); font-weight: 550; margin: 4px 0 0; }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

/* ---- cards & tiles ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.tile .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
a.server { display: block; transition: border-color 0.12s; }
a.server:hover { border-color: var(--axis); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title { font-size: 16px; font-weight: 650; margin-top: 8px; overflow-wrap: anywhere; }
.card-sub { color: var(--muted); font-size: 12.5px; min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--grid);
  color: var(--ink-2); font-size: 12.5px;
}
.card-note { color: var(--ink-2); margin: 14px 0 4px; min-height: 66px; }
.server.dim .meters { opacity: 0.45; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 550; white-space: nowrap;
}

/* Status never relies on colour alone: the dot always sits beside a label. */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status.up i { background: var(--good); }
.status.down i { background: var(--critical); }
.status.warn i { background: var(--warning); border-radius: 2px; }
.status.pending i { background: transparent; border: 2px solid var(--muted); }

/* ---- meters ---- */
.meters { display: grid; gap: 8px; margin-top: 12px; }
.meter-row { display: grid; grid-template-columns: 58px 1fr 44px; align-items: center; gap: 10px; font-size: 12.5px; }
.meter-row .k { color: var(--ink-2); }
.meter-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
/* The track is a lighter step of the fill's own colour, so severity reads across the whole bar. */
.meter { --fill: var(--accent); height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--fill) 18%, transparent); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--fill); min-width: 2px; }
.meter.warn { --fill: var(--warning); }
.meter.crit { --fill: var(--critical); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
/* Minimum widths keep text readable on phones: the table scrolls sideways instead of wrapping letter by letter. */
td.wrap { overflow-wrap: anywhere; min-width: 130px; }
td.msg { min-width: 240px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.selected td { background: var(--surface-2); }
.card.flush { padding: 4px 4px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 24px; }
.kv div { min-width: 0; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 1px 0 0; overflow-wrap: anywhere; }
dl { margin: 0; }
.empty { text-align: center; padding: 44px 20px; color: var(--ink-2); }
.empty h2 { margin: 0 0 6px; font-size: 17px; }
.empty .btn { margin-top: 12px; }

/* ---- charts ---- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 26px 0 10px; }
.toolbar h2 { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-weight: 550; padding: 5px 12px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-2); color: var(--ink); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 860px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.chart-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-head .now { font-size: 18px; font-weight: 650; }
.legend { display: flex; gap: 12px; margin-left: auto; color: var(--ink-2); font-size: 12.5px; }
.legend i, .tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart { position: relative; height: 190px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.1; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .nodata { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tip {
  position: absolute; top: 6px; pointer-events: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14); padding: 7px 10px; font-size: 12.5px;
}
.tip b { display: block; margin-bottom: 3px; font-weight: 600; }
.tip div { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tip div span:last-child { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; }

/* ---- events ---- */
.level { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.level i { font-style: normal; width: 16px; text-align: center; color: var(--muted); }
.level.down i { color: var(--critical); }
.level.up i, .level.ok i { color: var(--good); }
.level.warn i, .level.reboot i { color: var(--warning); }

/* ---- install command ---- */
.cmd {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 8px 0 12px;
}
.cmd code { flex: 1; overflow-wrap: anywhere; white-space: pre-wrap; padding-top: 3px; }
details { margin-top: 10px; color: var(--ink-2); }
details summary { cursor: pointer; font-weight: 550; color: var(--ink); }
details a, .link { color: var(--accent); text-decoration: underline; }
.callout { border-left: 3px solid var(--warning); background: var(--surface-2); padding: 9px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; }

/* ---- dialogs, toasts, auth ---- */
dialog.dlg {
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog.dlg::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.dlg form { padding: 20px; }
dialog.dlg h2 { margin: 0 0 14px; font-size: 17px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: var(--page); padding: 9px 14px; border-radius: 8px;
  font-weight: 550; max-width: min(420px, calc(100vw - 32px)); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.toast.err { background: var(--critical); color: #fff; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(380px, 100%); padding: 26px; }
.auth .brand { font-size: 18px; margin-bottom: 16px; }
.auth .btn { width: 100%; margin-top: 4px; padding: 9px; }

@media (max-width: 600px) {
  .topbar-in { padding: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  main { padding: 16px 16px 50px; }
}
