:root {
  --paper: #f2f4f7; --panel: #ffffff; --ink: #172131; --muted: #5b6778; --line: #d7dde6;
  --rail: #172131; --rail-ink: #c9d2df; --accent: #0e7c86; --accent-ink: #ffffff;
  --up: #1e8e4e; --down: #c8372d; --stopped: #8a93a0; --pending: #b7791f;
  --add: #e3f4e8; --del: #fbe7e5;
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #11161f; --panel: #19202b; --ink: #e4e9f0; --muted: #98a3b3; --line: #2c3645;
    --rail: #0b0f15; --accent: #3fb2bb; --accent-ink: #0b0f15; --add: #16321f; --del: #3a1d1b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 var(--sans); color: var(--ink); background: var(--paper); display: flex; min-height: 100vh; }
body.bare { display: block; }
a { color: var(--accent); }
.mono, pre, code { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); font-weight: normal; }
.bad { color: var(--down); }
.right { text-align: right; }
.wrap { word-break: break-all; }
h1 { font-size: 22px; margin: 0 0 8px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 32px 0 10px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 6px; }
small { font-size: 13px; }

/* 左侧导航 */
.rail { width: 188px; flex: none; background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column;
  padding: 18px 10px; gap: 2px; position: sticky; top: 0; height: 100vh; }
.rail a, .rail .link { color: var(--rail-ink); text-decoration: none; padding: 7px 10px; border-radius: 6px; font: inherit;
  text-align: left; background: none; border: 0; cursor: pointer; width: 100%; }
.rail a:hover, .rail .link:hover { background: rgba(255,255,255,.07); }
.rail a[aria-current] { background: rgba(255,255,255,.12); color: #fff; }
.rail .brand { color: #fff; font-weight: 700; font-size: 17px; margin-bottom: 14px; }
.rail-sep { height: 1px; background: rgba(255,255,255,.12); margin: 10px 6px; }
.rail-grow { flex: 1; }
main { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1240px; }

/* 通用 */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.stack label, .row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.choice { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
button, .button { font: inherit; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); }
button.small { padding: 2px 10px; font-size: 13px; }
button.big { padding: 11px 22px; font-size: 16px; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { white-space: nowrap; font-size: 12px; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--paper) 60%, var(--panel)); }
tr:last-child td { border-bottom: 0; }
table.dense td, table.dense th { padding: 5px 10px; font-size: 14px; }
.row-bad td { background: color-mix(in srgb, var(--down) 7%, var(--panel)); }
.scroll { overflow-x: auto; }
.empty { color: var(--muted); padding: 18px 12px; }
.tag { display: inline-block; font-size: 12px; padding: 0 7px; margin: 1px 3px 1px 0; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--ink); }
.badge { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; vertical-align: middle; white-space: nowrap; }
.st-up.badge { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.st-down.badge, .cs-failed { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.st-stopped.badge, .cs-draft { background: color-mix(in srgb, var(--stopped) 20%, transparent); color: var(--muted); }
.st-pending.badge, .cs-partial { background: color-mix(in srgb, var(--pending) 18%, transparent); color: var(--pending); }
.cs-applied { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }

.flash { padding: 9px 14px; border-radius: 6px; margin-bottom: 14px; border-left: 4px solid var(--accent); background: var(--panel); }
.flash.error { border-color: var(--down); } .flash.warn { border-color: var(--pending); } .flash.ok { border-color: var(--up); }
p.error, .error { color: var(--down); }
.warn { color: var(--pending); }
pre.cmd { background: var(--rail); color: #e4e9f0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
pre.note { white-space: pre-wrap; margin: 4px 0 0; font-family: var(--sans); font-size: 13px; color: var(--muted); }

/* 总览数字 */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.figures div { background: var(--panel); padding: 14px 16px; display: flex; flex-direction: column; }
.figures b { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.figures span { color: var(--muted); font-size: 13px; }
.figures .bad b { color: var(--down); }

/* 服务器墙：页面上唯一的"重"元素 */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line);
  border-left: 6px solid var(--stopped); border-radius: 6px; padding: 10px 12px; color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--muted); }
.tile.st-up { border-left-color: var(--up); }
.tile.st-down { border-left-color: var(--down); background: color-mix(in srgb, var(--down) 6%, var(--panel)); }
.tile.st-pending { border-left-color: var(--pending); }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile-sub { font-size: 12px; color: var(--muted); }
.meters { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.meters label { display: grid; grid-template-columns: 34px 1fr 38px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
meter { width: 100%; height: 7px; }

/* 其它 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.bulkbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 10px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; position: sticky; top: 0; z-index: 2; }
.bulkbar span { font-size: 13px; color: var(--muted); min-width: 64px; }
dl.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; }
.diff { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; }
.rrset ul { list-style: none; margin: 4px 0 8px; padding: 0; }
.rrset li { padding: 1px 8px; white-space: pre-wrap; word-break: break-all; }
.rrset li.add { background: var(--add); }
.rrset li.del { background: var(--del); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--down) 60%, transparent); }
.gate { max-width: 420px; margin: 16vh auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 14px; }
.gate label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.narrow { max-width: 560px; }
[hidden] { display: none !important; }

/* ---------- 列表与徽章 ---------- */
table a { text-decoration: none; }
table a:hover { text-decoration: underline; }
a.strong { font-weight: 560; color: var(--ink); }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }
tbody tr.selected td { background: color-mix(in srgb, var(--accent) 13%, var(--panel)); }
th.check, td.check { width: 34px; padding-right: 0; }
.nowrap { white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
.pv { display: inline-block; font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 4px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--muted); line-height: 20px; }
.pv-cloudflare { color: #d9680f; border-color: color-mix(in srgb, #f38020 35%, transparent); }
.pv-route53 { color: #7a5bd0; border-color: color-mix(in srgb, #7a5bd0 45%, transparent); }
@media (prefers-color-scheme: dark) { .pv-cloudflare { color: #f7a35c; } .pv-route53 { color: #b19cf0; } }
.exp { font-variant-numeric: tabular-nums; }
.exp-warn { color: var(--pending); font-weight: 600; }
.exp-bad { color: var(--down); font-weight: 600; }
.rtype { display: inline-block; min-width: 46px; font: 600 12px var(--mono); color: var(--accent); }
a.tag { text-decoration: none; }
a.tag:hover { background: color-mix(in srgb, var(--accent) 24%, var(--panel)); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chips a { padding: 4px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  text-decoration: none; font-size: 13px; }
.chips a b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.chips a:hover { border-color: var(--muted); }
.chips a[aria-current] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.chips a.chip-bad b { color: var(--down); }
.filters input[type=search] { min-width: 240px; flex: 1 1 240px; max-width: 360px; }
.filters .clear { font-size: 13px; }
.bulkbar { justify-content: space-between; }
.bulk-actions, .bulk-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bulk-tags { padding-left: 8px; border-left: 1px solid var(--line); }
.bulkbar.has-selection { border-color: var(--accent); }
.bulkbar.has-selection [data-selected-count] { color: var(--ink); font-weight: 600; }

/* ---------- 详情页 ---------- */
.crumb { margin: 0; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.row.tight { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.card, .panel, .notice { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.card { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-label { font-size: 12px; color: var(--muted); }
.card-value { font-size: 17px; }
.card-foot { font-size: 13px; color: var(--muted); }
.notice { border-left: 4px solid var(--pending); margin-top: 14px; }
.panel.stack { max-width: 760px; }
.stack > button, .stack > div > button { align-self: flex-start; }
.stack label small { font-size: 12px; }
.figures b.money { font-size: 20px; line-height: 1.5; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .rail a, .rail .link { width: auto; white-space: nowrap; }
  .rail .brand { margin: 0 8px 0 0; }
  .rail-sep, .rail-grow { display: none; }
  .rail form { flex: none; }
  main { padding: 18px 14px 40px; }
  dl.facts { grid-template-columns: 1fr; }
  .bulk-tags { border-left: 0; padding-left: 0; }
  .filters input[type=search] { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
