:root {
  --bg: #f4f7fb;
  --paper: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #e1e7ef;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1ff;
  --ok: #15805f;
  --warn: #b76e00;
  --danger: #d13b4c;
  --sidebar: #101828;
  --sidebar-ink: #f8fafc;
  --sidebar-muted: #98a2b3;
  --code: #f1f4f8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 4px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 12px 28px rgba(16, 24, 40, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: "IBM Plex Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }
code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  background: var(--code);
  padding: 2px 6px;
  border-radius: 5px;
}

.shell { min-height: 100vh; }
nav.side {
  position: sticky;
  top: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 12px clamp(18px, 3vw, 48px);
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 70px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.1);
  z-index: 100;
}
nav.side .side-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
nav.side .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  padding: 0;
  color: var(--sidebar-ink);
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: linear-gradient(145deg, #60a5fa, #2563eb);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.38);
  font-size: 16px;
  font-weight: 600;
}
nav.side .meta { display: flex; align-items: center; gap: 7px; color: var(--sidebar-muted); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #32d583; box-shadow: 0 0 0 3px rgba(50, 213, 131, 0.12); }
.nav-links { display: flex; align-items: center; gap: 4px; min-width: 0; }
nav.side a {
  display: block;
  color: var(--sidebar-muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
nav.side a:hover { color: var(--sidebar-ink); background: rgba(255, 255, 255, 0.055); transform: translateY(-1px); }
nav.side .brand:hover { background: transparent; transform: none; }
nav.side a.active { color: #fff; background: rgba(37, 99, 235, 0.23); box-shadow: inset 0 -2px #60a5fa; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.guard-version { color: var(--sidebar-muted); font-family: "IBM Plex Mono", monospace; font-size: 13px; }
nav.side form { flex: 0 0 auto; margin: 0; padding: 0; }
nav.side form button { width: auto; margin: 0; }

main { width: 100%; min-width: 0; margin: 0 auto; padding: 44px clamp(24px, 4vw, 64px) 72px; max-width: 1920px; }
h1 {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin: 0 0 10px;
}
.lede { color: var(--muted); margin: 0 0 30px; font-size: 16px; }
h2 { margin: 30px 0 14px; font-size: 20px; letter-spacing: -0.02em; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
a.stat { display: block; color: inherit; text-decoration: none; }
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.dash .card { margin-bottom: 0; }
.dash .card h2 { display: flex; align-items: center; justify-content: space-between; }
.dash .lede { margin-bottom: 12px; }
.dash .empty { margin: 0; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #cbd5e1; }
.stat b { display: block; font-size: 30px; line-height: 1.25; letter-spacing: -0.03em; }
.stat span { color: var(--muted); font-size: 13px; }

table.data { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); font-size: 14px; }
table.data th, table.data td {
  text-align: left;
  vertical-align: top;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
table.data tr:last-child td { border-bottom: 0; }
table.data th { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); background: #f8fafc; }
table.data tbody tr { transition: background 140ms ease; }
table.data tbody tr:not(.row-panel):not(.file-panel):hover { background: #f8fbff; }
.empty { color: var(--muted); padding: 28px; background: var(--paper); border: 1px dashed #cbd5e1; border-radius: var(--radius); font-size: 15px; text-align: center; }

.flash {
  background: #fff1f3;
  border: 1px solid #fecdd3;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
}
.note {
  background: var(--accent-soft);
  border: 1px solid #cfe0ff;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 18px; margin: 0 0 14px; }

label { display: block; font-size: 15px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  max-width: 480px;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:focus, select:focus, textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11); }
textarea { max-width: 100%; min-height: 120px; resize: vertical; font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 10px; }
.muted { color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 960px; }
.site-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  max-width: 100%;
  align-items: end;
}
.site-form input, .site-form select { max-width: 100%; }
.radios {
  border: 0;
  margin: 12px 0 0;
  padding: 0;
}
.radios legend { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.radios label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 0 0;
  font-size: 16px;
}
.radios input { width: auto; margin: 0; }

button.path-toggle {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(209, 59, 76, 0.45);
  text-underline-offset: 3px;
}
button.path-toggle:hover,
button.path-toggle:active {
  background: none;
  border: 0;
  color: #b4233f;
  box-shadow: none;
  transform: none;
}
button.path-toggle[aria-expanded="true"] { color: #b4233f; font-weight: 600; }

button, .btn {
  font: inherit;
  font-size: 16px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 15px;
  cursor: pointer;
  margin-top: 14px;
  font-weight: 500;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18); }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.ghost:hover, .btn.ghost:hover { background: #f8fafc; border-color: #cbd5e1; box-shadow: none; }
nav.side button.ghost { color: var(--sidebar-muted); border-color: rgba(255,255,255,.12); }
nav.side button.ghost:hover { color: #fff; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.2); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #b4233f; border-color: #b4233f; box-shadow: 0 4px 12px rgba(209,59,76,.18); }
.actions { white-space: nowrap; }
.actions form, .actions a.btn { display: inline-block; margin: 0 6px 0 0; vertical-align: top; }
.actions button, .actions a.btn {
  margin-top: 0;
  font-size: 14px;
  padding: 6px 10px;
  text-decoration: none;
}
.card a.btn { margin-left: 8px; }
.checks { margin: 0; padding-left: 20px; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--danger); }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-box {
  width: min(480px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 32px 32px 36px;
}
.auth-box h1 { font-size: 36px; }
.auth-box .lede { font-size: 20px; line-height: 1.55; }
.auth-box label { font-size: 16px; }
.auth-box input { font-size: 18px; padding: 10px 12px; }
.auth-box button { font-size: 18px; padding: 10px 16px; }
.qr { width: 180px; height: 180px; background: #fff; padding: 8px; margin: 12px 0; }
.qr svg { width: 100%; height: 100%; }
.secret { word-break: break-all; font-size: 15px; }

.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
}
.badge.php { background: #e4eef4; color: #1e4d6b; }
.badge.node { background: #dceee3; color: var(--ok); }
.badge.python { background: #eee4f4; color: #5a2d7a; }
.badge.both { background: var(--accent-soft); }

a.webroot { color: inherit; }
a.webroot code { color: var(--accent); }
a.badge { text-decoration: none; }
table.data tr.site-row.picked td { background: var(--accent-soft); }
table.data tr.picked td { background: var(--accent-soft); }
table.data tr.row-panel td {
  background: #f8fafc;
  padding: 16px 14px 20px;
  border-bottom: 2px solid var(--accent);
  max-width: 0;
}
table.data.inner { margin-top: 8px; }
table.data tr.file-panel td {
  background: #fff;
  padding: 10px 12px 14px;
  border-bottom: 2px solid var(--accent);
}
table.data tr.file-panel .flash { margin-bottom: 0; }
table.data tr.file-panel pre.review { margin: 0; }
.excerpt { color: var(--muted); font-size: 13px; margin-top: 4px; }
table.data th.check, table.data td.check { width: 28px; text-align: center; }
#batch-review { margin: 0 0 10px; }
#batch-review button { margin-top: 0; }
#scan-panel h2 { margin-top: 0; }
#scan-panel h3 { margin: 22px 0 10px; font-size: 18px; }
#scan-panel form button { margin-top: 0; }
#scan-panel .lede, #log-panel .lede { margin-bottom: 12px; }
#log-panel h2 { margin-top: 0; }
#log-panel h3 { margin: 16px 0 8px; font-size: 18px; }
.log-actions form, .log-actions a.btn { display: inline-block; margin: 0 8px 10px 0; vertical-align: top; }
.log-actions button, .log-actions a.btn { margin-top: 0; text-decoration: none; }
.log-stats { margin: 12px 0 16px; grid-template-columns: repeat(6, 1fr); }
.log-stats a.stat { color: inherit; text-decoration: none; cursor: pointer; }
.log-stats a.stat:hover, .log-stats a.stat.picked { border-color: var(--accent); background: var(--accent-soft); }
.outcome {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}
.outcome.opened, .outcome.error { background: #f6e0dc; color: var(--danger); }
.outcome.denied { background: #f6ebd0; color: var(--accent); }
.outcome.missing { background: #dceee3; color: var(--ok); }
.outcome.unknown, .outcome.other { background: var(--code); color: var(--muted); }
pre.log-lines {
  max-height: 420px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  background: var(--code);
  padding: 10px 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}
.actions .when { color: var(--muted); font-size: 13px; vertical-align: middle; }
pre.review {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--code);
  padding: 12px 14px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: auto;
}

.tabs {
  display: flex;
  gap: 0;
  margin: 18px 0 16px;
  border-bottom: 1px solid var(--line);
}
.tabs a {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active, .tabs a:hover { color: var(--ink); border-bottom-color: var(--accent); }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 15px;
}
.pager a, .pager span {
  display: inline-block;
  min-width: 2em;
  text-align: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  border-radius: 7px;
}
.pager a:hover { border-color: var(--accent); }
.pager span.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pager span.off { color: var(--muted); background: transparent; }
button.toggle {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.toggle.on {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

@media (max-width: 800px) {
  nav.side { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px 10px; }
  nav.side .side-head { min-width: 0; }
  nav.side .meta { display: none; }
  .nav-links { order: 3; width: 100%; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  nav.side a { flex: 0 0 auto; padding: 8px 11px; }
  nav.side a:hover { transform: none; }
  nav.side a.active { box-shadow: inset 0 -2px #60a5fa; }
  .nav-end { margin-left: auto; }
  nav.side form button { width: auto; }
  .stats, .row, .dash, .site-form { grid-template-columns: 1fr 1fr; }
  main { padding: 28px 16px 52px; }
}

@media (max-width: 520px) {
  .stats, .row, .dash, .site-form { grid-template-columns: 1fr; }
  .stat { padding: 16px 18px; }
  .card { padding: 18px 16px; }
  .auth { padding: 16px; }
  .auth-box { padding: 24px 20px 28px; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
}
