:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --border: #e7e5e4;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #ea580c;
  --accent-soft: #fff1e6;
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info-soft: #e0f2fe;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 2px 8px rgba(28, 25, 23, .05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100f;
    --surface: #1c1917;
    --surface-2: #231f1d;
    --border: #35302c;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --accent: #fb923c;
    --accent-soft: #3a2314;
    --good: #4ade80;
    --good-soft: #14321f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0d;
    --bad: #f87171;
    --bad-soft: #3d1717;
    --info-soft: #0f2a3a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #12100f; --surface: #1c1917; --surface-2: #231f1d; --border: #35302c; --text: #f5f5f4; --muted: #a8a29e;
  --accent: #fb923c; --accent-soft: #3a2314; --good: #4ade80; --good-soft: #14321f; --warn: #fbbf24; --warn-soft: #3a2c0d;
  --bad: #f87171; --bad-soft: #3d1717; --info-soft: #0f2a3a; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 1em; }
.hint.err { color: var(--bad); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; position: relative; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.dot-badge { position: absolute; top: 0; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 6px; z-index: 30; }
.usermenu .menu a, .usermenu .menu button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; border-radius: 7px; cursor: pointer; text-decoration: none; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.menu-head b { display: block; color: var(--text); font-size: 14px; }
.field-s { display: block; font-size: 12px; color: var(--muted); margin-top: 10px; }
.users-table td, .users-table th { white-space: nowrap; }
.users-table td.wrap { white-space: normal; min-width: 120px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.add-user { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 8px; align-items: end; }
.add-user label { font-size: 12px; color: var(--muted); }
.add-user select { width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
@media (max-width: 900px) { .add-user { grid-template-columns: 1fr 1fr; } }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok i { background: var(--good); }
.pill.bad i { background: var(--bad); }

.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; padding: 18px 20px 40px; max-width: 1440px; margin: 0 auto; }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.main { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

.drop {
  display: block; border: 1.5px dashed var(--border); border-radius: 10px; padding: 14px; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; color: var(--muted); text-align: center; }
.drop-empty b { color: var(--text); font-weight: 600; }
.drop-empty span { font-size: 12px; }
.drop.has .drop-empty { display: none; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: 13px; line-height: 20px; padding: 0;
}
.thumb.add { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; background: transparent; border: 1px dashed var(--border); }

.more { margin: 12px 0 0; }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.more label { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input, textarea {
  width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { width: 100%; margin-top: 14px; background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12px; font-weight: 500; }

.list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; }
.item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 7px; border-radius: 9px; cursor: pointer; text-decoration: none; color: inherit; border: 1px solid transparent;
}
.item:hover { background: var(--surface-2); }
.item.active { background: var(--accent-soft); border-color: var(--accent); }
.item img { width: 44px; height: 44px; border-radius: 7px; object-fit: cover; background: var(--border); }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12px; color: var(--muted); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.run { background: var(--info-soft); color: var(--text); border-color: transparent; }

.placeholder { text-align: center; padding: 90px 20px; color: var(--muted); }
.placeholder h3 { color: var(--text); font-size: 18px; margin: 14px 0 6px; }
.placeholder p { max-width: 520px; margin: 0 auto; }

/* 进度 */
.progress-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.step { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.step b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.step.running { border-color: var(--accent); background: var(--accent-soft); }
.step.done b::after { content: " ✓"; color: var(--good); }
.step.failed { border-color: var(--bad); background: var(--bad-soft); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { padding: 10px 14px; border-radius: 10px; margin: 12px 0; font-size: 13px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.logs { font: 12px/1.7 ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; max-height: 320px; overflow: auto; }
.logs div { white-space: pre-wrap; word-break: break-word; }
.logs span { color: var(--muted); margin-right: 8px; }

/* 报告 */
.report { display: flex; flex-direction: column; gap: 16px; }
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.score { position: relative; width: 112px; height: 112px; }
.score svg { transform: rotate(-90deg); }
.score .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score .num b { font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.score .num span { font-size: 11px; color: var(--muted); }
.verdict { display: inline-block; font-size: 18px; font-weight: 800; padding: 3px 14px; border-radius: 8px; margin-bottom: 6px; }
.verdict.good { background: var(--good-soft); color: var(--good); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.one-line { font-size: 15px; font-weight: 600; margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 8px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dims { display: flex; flex-direction: column; gap: 9px; }
.dim { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 2.2em; gap: 10px; align-items: center; font-size: 13px; }
.dim .bar { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.dim .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.dim .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.dim-c { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -6px; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.stat span { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.match { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; }
.match img { width: 64px; height: 64px; border-radius: 7px; object-fit: cover; background: var(--border); }
.match .t { font-size: 12px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.match .s { font-size: 12px; color: var(--muted); }
.match .r { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.sim { font-weight: 700; color: var(--accent); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
td img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--border); display: block; }
td .tt { max-width: 420px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.shots figure { margin: 0; }
.shots img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.shots figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }

.details { display: flex; flex-direction: column; gap: 12px; }
.detail { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.detail-head { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: center; }
.detail-head img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--border); }
.detail-head .t { font-weight: 600; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

ul.clean { margin: 0; padding-left: 18px; }
ul.clean li { margin: 3px 0; }
.lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.md { font-size: 13.5px; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; font-size: 15px; }
.md h1 { font-size: 17px; }
.md table { margin: 8px 0; }
.md p { margin: 8px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
details.full > summary { cursor: pointer; font-weight: 600; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.login { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.login-box { width: 100%; max-width: 360px; }
.login-box input { margin: 12px 0 0; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lb-close { position: absolute; top: 12px; right: 16px; background: none; border: 0; color: #fff; font-size: 32px; cursor: pointer; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 32px; }
  .grid2, .lists { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .list { max-height: none; }
  body.viewing .side { display: none; }
  body:not(.viewing) .main { display: none; }
  .topbar { padding: 10px 16px; }
}
