:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --ink: #16222e;
  --muted: #5b6b7a;
  --line: #d9e0e6;
  --accent: #1b5fd6;
  --on-accent: #fff;
  --up: #17784b;
  --down: #b4361f;
  --warn: #9a6700;
  --sans: "Public Sans", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #16212c;
    --ink: #e6edf3;
    --muted: #93a4b3;
    --line: #27364a;
    --accent: #6aa3ff;
    --on-accent: #0f1720;
    --up: #4cc38a;
    --down: #ff8a70;
    --warn: #e3b341;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  align-items: center;
  padding: .85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar .brand { font-weight: 600; margin-right: auto; color: var(--ink); text-decoration: none; }
.bar form { margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

main { max-width: 56rem; margin: 0 auto; padding: 2.25rem 1.25rem 4rem; }
h1 { font: 500 2.1rem/1.2 var(--serif); margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 2.5rem 0 .75rem; }
p { max-width: 42rem; }
.muted { color: var(--muted); }
.lead { font: 500 1.5rem/1.5 var(--serif); max-width: 40rem; margin: .25rem 0 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .875rem; }
.n { text-align: right !important; font-variant-numeric: tabular-nums; }
.up, .ok { color: var(--up); }
.down, .bad { color: var(--down); }
.warn { color: var(--warn); }

.btn {
  display: inline-block;
  padding: .6rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 .95rem var(--sans);
  cursor: pointer;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: wait; }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: transparent; border: 1px solid var(--down); color: var(--down); }

form.stack { display: grid; gap: .9rem; max-width: 26rem; }
label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  width: 100%;
}
textarea { font-family: monospace; font-size: .85rem; min-height: 5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.note { padding: .7rem .9rem; border-left: 3px solid var(--accent); background: var(--surface); max-width: 42rem; }
.note.err { border-color: var(--down); }

/* Hub Grid Layout */
.hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.hub-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}
.hub-head { display: flex; align-items: center; gap: .75rem; }
.hub-head h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.tile {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--accent);
  font-weight: 700;
  font-size: .85rem;
  flex: none;
}
.pill {
  margin-left: auto;
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 99px;
  text-transform: uppercase;
}
.pill.ok { background: rgba(23, 120, 75, 0.15); color: var(--up); }
.pill.off { background: var(--line); color: var(--muted); }
.pill.err { background: rgba(180, 54, 31, 0.15); color: var(--down); }

.mono { font: .82rem/1.45 ui-monospace, Menlo, Consolas, monospace; word-break: break-word; }
.hub-foot {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: .75rem;
}
.acts { display: flex; gap: .4rem; align-items: center; }
.acts form { margin: 0; }

/* Modals */
dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(32rem, calc(100% - 2rem));
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-top: 0; }
dialog form.stack { max-width: none; }
.row { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }