:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #85847e;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #008300;
  --warn: #b77a00;
  --bad: #d03b3a;
  --series-1: #2a78d6; /* hit */
  --series-2: #eb6834; /* miss */
  --series-3: #1baf7a; /* bypass */
  --grid: #e8e7e2;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8d8c84;
    --accent: #3987e5; --good: #2fae2f; --warn: #e0a42a; --bad: #e66767;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2a2a28;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8d8c84;
  --accent: #3987e5; --good: #2fae2f; --warn: #e0a42a; --bad: #e66767;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2a2a28;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

header.top {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--series-2), var(--series-1)); }
nav a { color: var(--text-2); margin-right: 16px; font-weight: 500; }
nav a.active { color: var(--text); }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }
.tile .label { color: var(--text-2); font-size: 12px; }
.tile .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--text-3); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 28px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--good); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }
.badge.plain::before { display: none; }
.act-cache { color: var(--series-1); } .act-bypass { color: var(--text-2); }
.act-redirect { color: var(--warn); } .act-block { color: var(--bad); }

form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.f small { font-weight: 400; color: var(--text-3); }
input[type=text], input[type=number], input[type=password], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); padding: 5px 12px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .d-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
dialog .d-body { padding: 20px; max-height: 70vh; overflow: auto; }
dialog .d-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 50;
  opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; white-space: pre-line;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); color: #fff; }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; }
.chart .axis text { fill: var(--text-3); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .xhair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  min-width: 150px; display: none; z-index: 3;
}
.tip .t { color: var(--text-2); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.tip .r i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.empty { text-align: center; color: var(--text-3); padding: 32px 0; }
.rule-off td { opacity: .45; }
.pattern { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 340px; }
.err-box { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
