:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14171c; --muted: #5f6b7a; --line: #e3e7ec; --soft: #eef1f5;
  --brand: #d5202c; --brand-ink: #ffffff; --accent: #1f5fbf; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --s1: #1f5fbf; --s2: #7aa7e6; --s3: #d5202c; --s4: #f0959b;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --panel: #161a21; --ink: #e8ebf0; --muted: #98a3b3; --line: #252b35; --soft: #1c222b;
    --accent: #6ea8ff; --s1: #5b9bf5; --s2: #2f5d9e; --s3: #ef5963; --s4: #8f3038;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.noscript { padding: 40px; text-align: center; }
.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- sign-in */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate .wordmark { font-size: 17px; }
.gate-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; }
.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; margin-bottom: 22px; white-space: nowrap; }
.wordmark img { width: 28px; height: 28px; }
.wordmark span { color: var(--muted); font-weight: 500; }
.gate-foot { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }
.qr { display: block; margin: 8px auto 12px; border-radius: 8px; background: #fff; padding: 6px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.codes code { background: var(--soft); border-radius: 6px; padding: 8px; text-align: center; font-size: 13px; }

/* ---- forms */
label { display: block; font-size: 13px; font-weight: 550; margin: 14px 0 6px; }
input, select { width: 100%; font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
button { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid transparent; padding: 10px 16px; cursor: pointer; background: var(--ink); color: var(--panel); }
button:hover { opacity: .92; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand); color: var(--brand-ink); width: 100%; margin-top: 18px; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.small { padding: 6px 10px; font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin-top: 12px; min-height: 20px; }
.notice { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 8px; padding: 12px 14px; font-size: 14px; margin: 12px 0; }
.notice.warn { background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }

/* ---- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .wordmark { margin: 0 8px 22px; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--soft); text-decoration: none; }
.nav a.on { background: var(--soft); font-weight: 650; }
.side-foot { margin-top: auto; font-size: 13px; padding: 0 8px; }
.side-foot .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.filters { display: flex; gap: 8px; align-items: center; }
.filters select { width: auto; padding: 8px 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 8px 12px; font-weight: 550; }
.seg button.on { background: var(--soft); color: var(--ink); }

.viewing { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: 1.6fr 1fr; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; margin-top: 2px; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.meter { width: 100%; height: 8px; margin-top: 10px; display: block; }
.meter .track { fill: var(--soft); }
.meter .fill { fill: var(--ok); }
.meter .fill.warn { fill: var(--warn); }
.meter .fill.bad { fill: var(--bad); }

.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .s1 { fill: var(--s1); } .chart .s2 { fill: var(--s2); } .chart .s3 { fill: var(--s3); } .chart .s4 { fill: var(--s4); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .s1 { background: var(--s1); } .legend .s2 { background: var(--s2); } .legend .s3 { background: var(--s3); } .legend .s4 { background: var(--s4); }
.empty { color: var(--muted); text-align: center; padding: 36px 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.ok { color: var(--ok); } .tag.warn { color: var(--warn); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.keyline { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.keyline:last-child { border-bottom: 0; }
.keyline .what { font-weight: 600; }
.reveal { background: var(--soft); border-radius: 8px; padding: 12px; margin: 12px 0; word-break: break-all; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 14, 20, .55); }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; padding: 12px; }
  .side .wordmark { margin: 0 8px 0 0; } .nav { display: flex; gap: 4px; } .side-foot { margin: 0 0 0 auto; white-space: nowrap; }
  .main { padding: 20px 16px 48px; } .kpis { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr; }
}
