:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #f9fafb;
    --line: #e4e7ec;
    --text: #1d2433;
    --muted: #667085;
    --accent: #2f6fed;
    --accent-soft: #e8efff;
    --ok: #12805c;
    --ok-soft: #e3f5ee;
    --bad: #c4320a;
    --bad-soft: #fdeee8;
    --warn: #a15c07;
    --warn-soft: #fdf3e1;
    --minor: #5b5fc7;
    --minor-soft: #eeeefb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1218;
        --panel: #171b23;
        --panel-2: #1c212b;
        --line: #2a303c;
        --text: #e6e9ef;
        --muted: #98a2b3;
        --accent: #6e9bff;
        --accent-soft: #1d2a47;
        --ok: #4cc79a;
        --ok-soft: #13302a;
        --bad: #ff8a65;
        --bad-soft: #3a1f17;
        --warn: #f0b252;
        --warn-soft: #36290f;
        --minor: #a3a6ff;
        --minor-soft: #25264a;
        --shadow: none;
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.table-wrap { overflow-x: auto; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0; }

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.nav { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a { color: var(--text); padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; }
.nav nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-foot { margin-top: auto; padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; }
.nav-foot .conn { display: flex; align-items: center; gap: 8px; }
.user-box { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); font-size: 13px; }
body.logged-out .nav { display: none; }
body.logged-out .shell { grid-template-columns: 1fr; }
body.logged-out main { max-width: none; display: grid; place-items: center; min-height: 100vh; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login .brand { padding: 0 0 6px; }
.login label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.login input { max-width: none; }
.login .err { color: var(--bad); min-height: 1em; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }

main { padding: 24px 28px 60px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 18px 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--panel-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.minor { background: var(--minor-soft); color: var(--minor); }
.pill.idle { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill.run { background: var(--accent-soft); color: var(--accent); }

.verdict { display: flex; gap: 14px; align-items: center; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; font-weight: 600; font-size: 15px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict .meta { margin-left: auto; font-weight: 400; font-size: 13px; color: var(--muted); }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 9px 14px; margin-bottom: 12px; }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.finding { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; background: var(--panel); display: grid; grid-template-columns: 1fr auto; gap: 14px; }
.finding .title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.finding .desc { margin-top: 6px; color: var(--text); }
.finding .tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.finding pre { white-space: pre-wrap; background: var(--panel-2); padding: 8px 10px; border-radius: 6px; max-height: 200px; overflow: auto; margin: 8px 0 0; }
.thumbs { display: flex; gap: 8px; }
.thumb { width: 92px; height: 200px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: var(--panel-2); }
.new-tag { color: var(--bad); font-size: 12px; font-weight: 600; }

.timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 16px 18px; }
.tl-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.tl-item img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; object-position: top; display: block; cursor: zoom-in; }
.tl-item .cap { padding: 6px 8px; font-size: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); font: inherit; cursor: pointer; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { padding: 3px 10px; font-size: 12px; }

form .row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
form .row:last-of-type { border-bottom: 0; }
form label.l { color: var(--muted); padding-top: 7px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea { width: 100%; max-width: 520px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
textarea { min-height: 70px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.log { background: #0d1117; color: #c9d1d9; border-radius: var(--radius); padding: 12px 14px; height: 520px; overflow: auto; white-space: pre-wrap; margin: 0; font-size: 12.5px; line-height: 1.6; }
.log .l-ok { color: #56d364; }
.log .l-bad { color: #ff7b72; }
.log .l-warn { color: #e3b341; }
.log .l-step { color: #8b949e; }
.log .l-head { color: #79c0ff; }

#lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.82); display: grid; place-items: center; z-index: 10; cursor: zoom-out; }
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
#toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 8px; z-index: 11; max-width: 420px; }

.diffcell.better { color: var(--ok); }
.diffcell.worse { color: var(--bad); }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
    .nav nav { flex-direction: row; flex-wrap: wrap; }
    .brand { padding: 0 8px 0 0; }
    .nav-foot { margin: 0 0 0 auto; }
    main { padding: 16px; }
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-2 { grid-template-columns: 1fr; }
    form .row { grid-template-columns: 1fr; gap: 4px; }
    .finding { grid-template-columns: 1fr; }
    .table-wrap { overflow-x: auto; }
}
