:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #6b7380;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #dcf5e3;
  --off: #8a919c;
  --off-bg: #eceef1;
  --danger: #c62828;
  --code-bg: #f0f2f5;
  --row-hover: #f7f9fc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2028;
    --border: #2c333d;
    --text: #e4e7ec;
    --muted: #9099a6;
    --accent: #4c8dff;
    --ok: #4ac26b;
    --ok-bg: #173523;
    --off: #8a919c;
    --off-bg: #262c35;
    --danger: #ff6b6b;
    --code-bg: #232933;
    --row-hover: #212731;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  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; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; margin: 12px 0 4px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { fill: var(--accent); stroke: var(--accent); stroke-width: 1.6; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 4px 0 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.back { display: inline-block; margin-bottom: 8px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.table-card { padding: 16px 0 4px; }
.table-wrap { overflow-x: auto; }
.table-card h2 { padding: 0 18px; }
.count { color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 18px; border-top: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--row-hover); }
.num { text-align: right; }
td.mono, code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.empty { padding: 4px 18px 14px; color: var(--muted); margin: 0; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--off-bg); color: var(--off); }

.btn {
  font: inherit; border: 1px solid transparent; border-radius: 7px; padding: 7px 14px;
  cursor: pointer; background: transparent; color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: var(--border); }
.btn.ghost:hover { background: var(--row-hover); }
.btn.danger-ghost { border-color: var(--border); color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.inline-form { max-width: 520px; }
.error { color: var(--danger); margin: 0 0 12px; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.card-head.padded { padding: 0 18px 10px; }
.table-card .card-head h2 { padding: 0; }
.card-head input[type=search] { width: 260px; max-width: 100%; margin: 0; padding: 6px 10px; }
.switch { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; font-weight: 500; }
.switch input { width: 36px; height: 20px; margin: 0; appearance: none; border-radius: 999px; background: var(--off-bg); border: 1px solid var(--border); position: relative; cursor: pointer; padding: 0; display: inline-block; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { left: 18px; background: #fff; }
label.inline { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }
.scan-history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.scan-history li { padding: 3px 0; color: var(--muted); }
.scan-history li b { color: var(--text); font-weight: 500; }
.small-note { font-size: 12px; }
.agent-error { color: var(--danger); font-size: 12px; white-space: normal; max-width: 420px; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--code-bg); color: var(--muted); margin-left: 6px; }
.keybox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.keybox code { background: var(--code-bg); padding: 7px 10px; border-radius: 6px; font-size: 14px; letter-spacing: .02em; }
.keybox code.wrap { font-size: 12px; word-break: break-all; letter-spacing: 0; flex: 1 1 300px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; padding: 28px; }
.login h1 { margin-bottom: 2px; }
.login p.muted { margin: 0 0 20px; }
.login .btn { width: 100%; margin-top: 4px; }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  th, td { padding: 8px 12px; }
}

.file-btn { position: relative; overflow: hidden; display: inline-block; margin: 0; font-weight: 400; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; padding: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.tile-num { font-size: 22px; font-weight: 600; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile.accent .tile-num { color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex-wrap: wrap; }
.tab { font: inherit; background: none; border: none; border-bottom: 2px solid transparent; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
#compare-card th, #compare-card td { padding-left: 10px; padding-right: 10px; }
.warn { color: #b26a00; }
@media (prefers-color-scheme: dark) { .warn { color: #e3a33b; } }
