:root {
  color-scheme: light;
  --surface-0: #f4f3f0; --surface-1: #fcfcfb; --border: #e3e2dd; --grid: #ecebe7;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #7a7973;
  --accent: #2a78d6; --hover: #f0efec; --critical: #d03b3b; --warning: #b37800; --ok: #2e8540;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2c; --grid: #262624;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --accent: #3987e5; --hover: #242422; --warning: #fab219; --ok: #4caf50;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2c; --grid: #262624;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5; --hover: #242422; --warning: #fab219; --ok: #4caf50;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.topbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-1); }
.topbar .brand { font-weight: 600; color: inherit; text-decoration: none; margin-right: auto; }
.topbar a { text-decoration: none; }
.topbar form { margin: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
main.narrow { max-width: 420px; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 16px; margin: 24px 0 10px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px; }
.card h2 { font-size: 16px; margin: 0; }
.card h2 a { color: inherit; text-decoration: none; }
.sub { color: var(--text-secondary); font-size: 13px; }
.muted { color: var(--text-muted); font-size: 12px; }
.big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > div { background: var(--warning); }
.meter.crit > div { background: var(--critical); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card .row { margin-top: auto; }
.row a.open { flex: 1; text-align: center; }
a.open, button, .button {
  font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
a.open, button.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
button.danger { border-color: var(--critical); color: var(--critical); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:hover, a.open:hover, .button:hover { background: var(--hover); }
button.link:hover { background: none; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
.fail, .error { color: var(--critical); }
.fail { font-weight: 600; }
.ok { color: var(--ok); }
.state { min-height: 1.2em; overflow-wrap: anywhere; }
.notice { background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; overflow-wrap: anywhere; }
.notice.warn { border-left-color: var(--warning); }
.notice.err { border-left-color: var(--critical); }
form.stack { display: flex; flex-direction: column; gap: 12px; }
form.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
form.stack label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; font-size: 14px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; width: 100%;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; min-height: 120px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.table-wrap { overflow-x: auto; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.validation-summary-valid { display: none; }
.field-validation-error, .validation-summary-errors { color: var(--critical); font-size: 13px; font-weight: normal; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin: 0; }
