:root {
  --bg: #f4f7f4;
  --panel: #ffffff;
  --ink: #1c2520;
  --muted: #64716a;
  --line: #e1e8e2;
  --line-strong: #cfd9d1;
  --accent: #12885b;
  --accent-strong: #0c6b46;
  --accent-soft: #e4f4ea;
  --accent-ink: #0b5c3c;
  --critical: #b3261e;
  --critical-soft: #fbe9e7;
  --high: #c05a1c;
  --high-soft: #fdf0e3;
  --medium: #9a7200;
  --medium-soft: #fbf4dd;
  --low: #37699b;
  --low-soft: #e9f1f9;
  --info: #64716a;
  --info-soft: #f0f4f1;
  --shadow: 0 16px 36px rgba(20, 40, 28, 0.08);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #121714;
  --panel: #1a211c;
  --ink: #e7efe9;
  --muted: #96a69b;
  --line: #2a342d;
  --line-strong: #3a463e;
  --accent: #3ecf8e;
  --accent-strong: #2bb37a;
  --accent-soft: #1d3428;
  --accent-ink: #8be7bb;
  --critical: #ff8f85;
  --critical-soft: #3a2320;
  --high: #ffb27a;
  --high-soft: #362a1e;
  --medium: #f0cf6b;
  --medium-soft: #332d18;
  --low: #8fc7f5;
  --low-soft: #1e2b36;
  --info: #96a69b;
  --info-soft: #222b25;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14.5px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.92em; background: var(--info-soft); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- 通用控件 ---------- */
input[type="text"], input[type="password"], input:not([type]), #target, #token-name {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:not([type]):focus, input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button { cursor: pointer; border: none; background: transparent; }

.primary {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s;
}
.primary:hover { background: var(--accent-strong); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.6; cursor: default; }
.primary.wide { width: 100%; }
.primary.small { padding: 7px 13px; font-size: 13px; border-radius: 9px; }

.ghost {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 12px;
  padding: 11px 16px;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.ghost.small { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.ghost.danger:hover { border-color: var(--critical); color: var(--critical); }

.form-error { color: var(--critical); font-size: 13px; margin: 10px 0 0; }
.muted.small { font-size: 12.5px; color: var(--muted); }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(18, 136, 91, 0.14), transparent 60%),
    radial-gradient(720px 420px at 96% 106%, rgba(18, 136, 91, 0.1), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand b { display: block; font-size: 16px; letter-spacing: -0.01em; }
.login-brand small { color: var(--muted); font-size: 12px; }
.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 12px;
  flex: none;
}
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-card > .muted { margin-bottom: 22px; font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.login-card .primary.wide { margin-top: 6px; }
.login-foot { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; }
.theme-float {
  position: fixed; right: 18px; top: 18px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; }
.brand-text b { display: block; font-size: 14.5px; line-height: 1.2; letter-spacing: -0.01em; }
.brand-text small { display: block; color: var(--muted); font-size: 11px; }
.nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13.5px;
}
.nav-btn:hover { color: var(--ink); background: var(--info-soft); }
.nav-btn.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user { font-size: 13px; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px 60px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 1px 0 rgba(20, 40, 28, 0.03);
}
.form-panel { position: sticky; top: 78px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { font-size: 16px; letter-spacing: -0.01em; }
.content-panel { min-height: 340px; }

.field-label { display: block; font-size: 12.5px; color: var(--muted); margin: 16px 0 7px; }
.field-label:first-of-type { margin-top: 0; }

.depth-list { display: grid; gap: 8px; }
.depth {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.depth:hover { border-color: var(--line-strong); }
.depth.selected { border-color: var(--accent); background: var(--accent-soft); }
.depth input { margin-top: 3px; accent-color: var(--accent); }
.depth-body b { display: block; font-size: 13.5px; }
.depth-body small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 2px; }

.consent {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 16px 0 4px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.consent input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.form-panel .primary.wide { margin-top: 12px; }
.hint {
  margin-top: 18px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--info-soft);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.hint b { display: block; color: var(--ink); font-size: 12.5px; margin-bottom: 4px; }

/* ---------- 扫描列表 ---------- */
.scan-list { display: grid; gap: 10px; }
.scan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: left;
  background: var(--panel);
  transition: border-color 0.15s, transform 0.1s;
}
.scan-row:hover { border-color: var(--accent); }
.scan-row:active { transform: scale(0.997); }
.scan-main { min-width: 0; }
.scan-target { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.counts-inline { color: var(--muted); }
.scan-right { display: flex; align-items: center; gap: 10px; flex: none; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--muted);
  font-size: 11.5px;
}
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.status-queued { background: var(--info-soft); color: var(--muted); }
.status-running { background: var(--accent-soft); color: var(--accent-ink); }
.status-running::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: 1px;
  animation: pulse 1.2s infinite;
}
.status-done { background: var(--accent-soft); color: var(--accent-ink); }
.status-failed { background: var(--critical-soft); color: var(--critical); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.score-badge {
  min-width: 58px;
  text-align: center;
  border-radius: 11px;
  padding: 6px 9px;
  background: var(--info-soft);
  color: var(--muted);
  line-height: 1.1;
}
.score-badge b { font-size: 17px; }
.score-badge small { font-size: 10px; margin-left: 1px; }
.score-badge.ghosted { font-size: 15px; color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); padding: 8px 9px; }
.score-badge.risk-critical { background: var(--critical-soft); color: var(--critical); }
.score-badge.risk-high { background: var(--high-soft); color: var(--high); }
.score-badge.risk-medium { background: var(--medium-soft); color: var(--medium); }
.score-badge.risk-low { background: var(--low-soft); color: var(--low); }
.score-badge.risk-safe { background: var(--accent-soft); color: var(--accent-ink); }

.empty-state { padding: 44px 18px; text-align: center; color: var(--muted); }
.empty-state b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

/* ---------- 详情 ---------- */
.detail-head { margin-bottom: 18px; }
.back { margin-bottom: 12px; }
.detail-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.detail-title h2 { font-size: 21px; letter-spacing: -0.02em; }
.target-link { font-size: 12.5px; color: var(--muted); text-decoration: none; word-break: break-all; }
.target-link:hover { color: var(--accent); text-decoration: underline; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.risk-pill { padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.risk-pill.risk-critical { background: var(--critical-soft); color: var(--critical); }
.risk-pill.risk-high { background: var(--high-soft); color: var(--high); }
.risk-pill.risk-medium { background: var(--medium-soft); color: var(--medium); }
.risk-pill.risk-low { background: var(--low-soft); color: var(--low); }
.risk-pill.risk-safe { background: var(--accent-soft); color: var(--accent-ink); }

.progress-card {
  background: var(--info-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.progress-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.progress-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }
.progress-card .muted { margin-top: 8px; }

.error-card {
  border: 1px solid var(--critical);
  background: var(--critical-soft);
  color: var(--critical);
  border-radius: 13px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.error-card b { display: block; margin-bottom: 4px; }
.error-card p { font-size: 13px; word-break: break-word; }

.count-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 4px 0 16px; }
.count-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--panel);
}
.count-card b { display: block; font-size: 21px; line-height: 1.2; }
.count-card span { font-size: 11.5px; color: var(--muted); }
.count-card.critical b { color: var(--critical); }
.count-card.high b { color: var(--high); }
.count-card.medium b { color: var(--medium); }
.count-card.low b { color: var(--low); }
.count-card.info b { color: var(--muted); }

.report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 22px; }
.link-btn { text-decoration: none; display: inline-block; }

.findings { display: grid; gap: 20px; }
.finding-group { display: grid; gap: 9px; }
.group-title {
  font-size: 13px;
  letter-spacing: 0.02em;
  padding-left: 10px;
  border-left: 3px solid var(--info);
  color: var(--ink);
  margin: 0;
}
.group-title span { color: var(--muted); font-weight: 400; }
.group-title.sev-critical { border-color: var(--critical); }
.group-title.sev-high { border-color: var(--high); }
.group-title.sev-medium { border-color: var(--medium); }
.group-title.sev-low { border-color: var(--low); }

.finding {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.finding summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.finding summary::-webkit-details-marker { display: none; }
.finding summary:hover { background: var(--info-soft); }
.finding-title { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.finding-cat { color: var(--muted); font-size: 11.5px; flex: none; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.sev-dot.critical { background: var(--critical); }
.sev-dot.high { background: var(--high); }
.sev-dot.medium { background: var(--medium); }
.sev-dot.low { background: var(--low); }
.finding-body { padding: 2px 14px 15px; border-top: 1px solid var(--line); }
.finding-body .desc { font-size: 13px; color: var(--ink); margin: 12px 0 0; }
.evidence {
  margin: 12px 0 0;
  background: var(--info-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow: auto;
  color: var(--ink);
}
.fix {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px;
}
.fix b { display: block; font-size: 11px; letter-spacing: 0.06em; margin-bottom: 3px; }
.finding-url { margin: 10px 0 0; font-size: 12px; word-break: break-all; }

/* ---------- Token ---------- */
.inline-form { display: flex; gap: 9px; margin: 14px 0 18px; }
.inline-form input { flex: 1; }
.token-created {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 14px 15px;
  margin-bottom: 18px;
  display: grid;
  gap: 9px;
}
.token-plain {
  display: block;
  background: var(--panel);
  border: 1px dashed var(--accent);
  border-radius: 9px;
  padding: 10px 12px;
  word-break: break-all;
  font-size: 12.5px;
}
.token-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.token-list { display: grid; gap: 9px; }
.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.token-main { display: grid; gap: 3px; min-width: 0; }
.token-main b { font-size: 13.5px; }
.token-main code { justify-self: start; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 50;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .count-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand-text small { display: none; }
  .top-actions { margin-left: 0; }
  .layout { padding: 16px 14px 48px; }
  .count-cards { grid-template-columns: repeat(2, 1fr); }
  .scan-row { align-items: flex-start; }
  .scan-right { flex-direction: column; align-items: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
