:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1b1f24; --muted: #667085; --border: #e3e6ea;
  --accent: #2563eb; --good: #15803d; --good-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --muted-bg: #eef0f3; --row-bad: #fff5f5;
  --ok-bar: #22c55e; --ko-bar: #ef4444;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #171b21; --text: #e6e8eb; --muted: #98a2b3; --border: #2a3039;
    --accent: #60a5fa; --good: #4ade80; --good-bg: #12301f; --warn: #fbbf24; --warn-bg: #3a2c0b;
    --bad: #f87171; --bad-bg: #3b1515; --muted-bg: #222831; --row-bad: #2a1717;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 12.5px; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; gap: 24px; height: 52px; }
.brand { font-weight: 700; color: var(--text); }
.main-nav { display: flex; gap: 16px; }
.main-nav a { color: var(--muted); }
.user { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.domain-nav { display: flex; gap: 6px; padding-bottom: 10px; overflow-x: auto; }
.domain-nav a { padding: 3px 10px; border-radius: 999px; background: var(--muted-bg); color: var(--text); font-size: 13px; white-space: nowrap; }
.domain-nav a.active { background: var(--accent); color: #fff; }

main { padding-top: 20px; padding-bottom: 40px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 4px 12px; color: var(--muted); font-size: 13px; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.on { background: var(--accent); color: #fff; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.notice { display: block; background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.grid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } .grid { grid-template-columns: 1fr; } }

.domain-card { display: block; color: var(--text); margin: 0; transition: border-color .15s; }
.domain-card:hover { text-decoration: none; border-color: var(--accent); }
.dc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dc-head h2 { margin: 0; }
.dc-foot { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.kpis div, .tile { display: flex; flex-direction: column; }
.k { color: var(--muted); font-size: 12px; }
.v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.spark-box { position: relative; height: 48px; margin-top: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .v { font-size: 22px; }
.tile .s { color: var(--muted); font-size: 12px; }
.chart-box { position: relative; height: 260px; }

.rate.good { color: var(--good); } .rate.warn { color: var(--warn); } .rate.bad { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--muted-bg); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--muted-bg); }
.bar .ok { background: var(--ok-bar); } .bar .ko { background: var(--ko-bar); }
.barcell { white-space: nowrap; }
.barcell .bar { display: inline-flex; width: 70px; vertical-align: middle; margin-right: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-bad td { background: var(--row-bad); }
tbody tr:last-child td { border-bottom: 0; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.good { color: var(--good); border-color: var(--good); }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters select, .filters input { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 5px 10px; font: inherit; }
.pager { display: flex; gap: 16px; justify-content: center; padding-top: 12px; color: var(--muted); }

dl.meta { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }
.wrap-code { white-space: pre-wrap; word-break: break-word; }
pre.sample { white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 500px; overflow: auto; background: var(--muted-bg); padding: 12px; border-radius: 8px; margin: 0; }
.empty { max-width: 640px; }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 24px; }
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  dl.meta { grid-template-columns: 1fr; }
  .main-nav { gap: 10px; }
  .top-inner { gap: 12px; }
  .user { display: none; }
}

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.login-card h1 { font-size: 20px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-card input { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 8px 12px; }
