:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #dde3ea;
  --brand: #1f4e79;
  --brand-2: #2e75b6;
  --ok: #1e7b4a;
  --warn: #9a6400;
  --bad: #b3261e;
  --chip: #eef3f8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --panel: #171e27; --text: #e6ebf1; --muted: #93a0ae; --line: #2a3441;
    --brand: #8fb8e0; --brand-2: #5b9bd5; --chip: #1f2a37;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --panel: #171e27; --text: #e6ebf1; --muted: #93a0ae; --line: #2a3441;
  --brand: #8fb8e0; --brand-2: #5b9bd5; --chip: #1f2a37;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
.app-root { max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }
h1 { font-size: 22px; margin: 0; color: var(--brand); }
h2 { font-size: 18px; margin: 0 0 10px; color: var(--brand); }
h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.stat { font-size: 26px; font-weight: 600; color: var(--brand); }
.stat-label { color: var(--muted); font-size: 13px; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 500; }
nav a.active, nav a:hover { color: var(--brand); background: var(--chip); }
.disclaimer { background: var(--chip); border-left: 4px solid var(--brand-2); padding: 10px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); }

label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }
.field-inline input, .field-inline select { width: auto; min-width: 160px; }
button, .btn { border: 1px solid var(--brand-2); background: var(--brand-2); color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: transparent; color: var(--brand-2); }
button.danger { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small-btn { padding: 4px 9px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--chip); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--chip); color: var(--text); white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fff3d6; color: var(--warn); }
.badge.bad { background: #fde7e5; color: var(--bad); }
.badge.info { background: var(--chip); color: var(--brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.ok { background: #1d3a2a; } :root:not([data-theme="light"]) .badge.warn { background: #3d3118; } :root:not([data-theme="light"]) .badge.bad { background: #3f1f1d; } }
.score { font-weight: 700; font-size: 16px; }
.score.hi { color: var(--ok); } .score.mid { color: var(--warn); } .score.lo { color: var(--muted); }

.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; gap: 8px; align-items: center; margin: 5px 0; font-size: 13px; }
.bar { height: 10px; background: var(--brand-2); border-radius: 4px; }
.bar-track { background: var(--chip); border-radius: 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tabs button { background: transparent; color: var(--muted); border-color: var(--line); }
.tabs button.on { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12px; max-height: 320px; overflow: auto; background: var(--chip); padding: 8px; border-radius: 8px; }
.log .error { color: var(--bad); } .log .warn { color: var(--warn); } .log .success { color: var(--ok); }
.msg { padding: 8px 12px; border-radius: 8px; margin: 8px 0; background: var(--chip); }
.msg.err { background: #fde7e5; color: var(--bad); }
.msg.ok { background: #e3f4ea; color: var(--ok); }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; z-index: 20; overflow: auto; }
.modal { background: var(--panel); color: var(--text); width: min(900px, 100%); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.login { max-width: 360px; margin: 10vh auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); padding: 3px 9px; border-radius: 999px; font-size: 13px; }

@media (max-width: 640px) {
  .app-root { padding: 0 16px 40px; }
  .kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 3px 0; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
}
