:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1c1d21;
  --muted: #6b6f7b;
  --border: #e2e3e8;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --good: #1a7f4b;
  --good-bg: #e3f5eb;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #b42318;
  --bad-bg: #fde7e5;
  --neutral-bg: #eceef2;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1b1c21;
    --text: #e6e7ea;
    --muted: #9195a1;
    --border: #2c2e35;
    --accent: #6d8dff;
    --accent-text: #0b0c0f;
    --good: #5fd39a;
    --good-bg: #133324;
    --warn: #f2c063;
    --warn-bg: #3a2c0c;
    --bad: #ff8a80;
    --bad-bg: #3d1614;
    --neutral-bg: #2a2c33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 2rem 0 0.75rem; }

.masthead {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

nav {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
  padding: 0.4rem 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

nav a:hover {
  color: var(--text);
  text-decoration: none;
}

nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.actions { display: flex; gap: 0.5rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.card .badge { align-self: flex-start; }

.label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

td { overflow-wrap: anywhere; }

th, td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { text-align: right; white-space: nowrap; }

.mono, code, .code { font-family: var(--mono); font-size: 0.88em; }
.muted { color: var(--muted); }
.empty { padding: 1rem 0; }

.host {
  display: inline-block;
  margin: 0 0.35rem 0.2rem 0;
  font-family: var(--mono);
  font-size: 0.88em;
}

.attr { font-size: 0.85em; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--neutral-bg);
  white-space: nowrap;
}

.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.error, .warning, .notice {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  margin: 0.75rem 0;
}

.error { background: var(--bad-bg); color: var(--bad); white-space: pre-wrap; }
.warning { background: var(--warn-bg); color: var(--warn); }
.notice { background: var(--good-bg); color: var(--good); }
.error-text { color: var(--bad); }

.events { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.events li { padding: 0.25rem 0; }

button, .button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-block;
}

button:hover, .button:hover { text-decoration: none; border-color: var(--muted); }
button:disabled { opacity: 0.6; cursor: default; }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0.2rem 0.3rem;
}

.link.danger { color: var(--bad); }

.segmented { gap: 0; }
.segmented button { border-radius: 0; }
.segmented button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.segmented button:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: 0; }
.segmented button.active { background: var(--neutral-bg); font-weight: 600; }

.editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 760px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
}

label small { font-weight: 400; color: var(--muted); }

label.checkbox {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
}

input, select, textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

input[type="checkbox"] { width: auto; }
textarea.code { line-height: 1.45; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-actions { display: flex; gap: 0.5rem; }

.login {
  max-width: 380px;
  margin: 12vh auto;
}

.login h1 { margin-bottom: 1.5rem; }
.login form { display: flex; flex-direction: column; gap: 1rem; }

@media (max-width: 640px) {
  main { padding: 1rem; }
  .masthead { padding: 1rem 1rem 0; }
  nav { gap: 1rem; }
  th, td { padding: 0.5rem; }
}
