:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #5f6b7a;
  --line: #dde2e8;
  --accent: #2f6fdb;
  --bad: #c2412d;
  --ok: #1f8a4c;
  --code-bg: #f0f2f5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --panel: #1a1f27;
    --text: #e4e8ee;
    --muted: #97a1ae;
    --line: #2c333e;
    --accent: #6c9cf0;
    --bad: #ef7a63;
    --ok: #5cc98a;
    --code-bg: #232a34;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 8px;
}

h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 15px; }
.sub, .hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.header-links { display: flex; gap: 10px; align-items: center; }

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.badge.on { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--bad); border-color: var(--bad); }

main { padding: 8px 24px 32px; display: grid; gap: 16px; }

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel-head { display: flex; justify-content: space-between; align-items: center; }

.row, .actions, .inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { margin-bottom: 12px; }
.field > label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }

button, .button-link {
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
button.bad { background: transparent; color: var(--bad); border-color: var(--bad); }
button.quiet { background: transparent; color: var(--muted); border-color: var(--line); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=number], input[type=text] {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
input[type=number] { width: 90px; }
input[type=text] { width: 100%; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented label { padding: 6px 12px; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--accent); color: #fff; }
.segmented input { position: absolute; opacity: 0; }
.check { display: inline-flex; gap: 4px; align-items: center; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
code { background: var(--code-bg); padding: 3px 8px; border-radius: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.status-ok { color: var(--ok); }
td.status-bad { color: var(--bad); }
td a { color: var(--accent); }
tbody { display: block; max-height: 280px; overflow-y: auto; }
thead, tbody tr { display: table; width: 100%; table-layout: fixed; }
th:nth-child(1), td:nth-child(1) { width: 90px; }
th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { width: 70px; }
th:nth-child(5), td:nth-child(5) { width: 110px; }
td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

pre {
  margin: 12px 0 0;
  padding: 12px;
  background: var(--code-bg);
  border-radius: 6px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  max-width: 420px;
}
dialog::backdrop { background: rgb(0 0 0 / .4); }

@media (max-width: 600px) {
  header, main { padding-left: 16px; padding-right: 16px; }
}
