:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #f9fafb; --text: #1c2026; --muted: #626b76; --line: #e3e7ec; --line-2: #eef1f4;
  --delta: #1f97a6; --delta-soft: #e3f3f5; --echo: #b9821f; --echo-soft: #fbf1dc; --ok: #2e8b62; --ok-soft: #e3f3ea; --bad: #c2453f; --bad-soft: #fbe6e4; --warn: #b26b16; --warn-soft: #fbeedb;
  --radius: 6px; --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif; --mono: "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --shadow: 0 1px 2px rgba(20, 24, 30, .06);
}
:root[data-theme="dark"] {
  --bg: #14171c; --panel: #1b1f26; --panel-2: #20252d; --text: #e7eaee; --muted: #98a1ab; --line: #2b323b; --line-2: #242a32;
  --delta: #4fc0cd; --delta-soft: #1a3339; --echo: #d9a03a; --echo-soft: #3a2f16; --ok: #4fbf8a; --ok-soft: #173327; --bad: #e0716b; --bad-soft: #3a1f1d; --warn: #d9973f; --warn-soft: #3a2b16;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow-x: hidden; }
body { font: 13px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--delta); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

.gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.gate-card { width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px 22px 18px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.gate-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.gate-card label { font-size: 12px; color: var(--muted); }
.gate-card input { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius); padding: 8px 10px; outline: none; }
.gate-card input:focus { border-color: var(--delta); box-shadow: 0 0 0 3px var(--delta-soft); }

.app { display: grid; grid-template-columns: 212px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 16px 16px 12px; font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--delta); box-shadow: 0 0 0 3px var(--delta-soft); display: inline-block; }
.nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 2px; }
.nav a { padding: 7px 10px; border-radius: var(--radius); color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--delta-soft); color: var(--delta); font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--line-2); display: grid; gap: 8px; }
.side-actions { display: flex; gap: 6px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.crumbs { font-weight: 600; font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.view { padding: 18px 20px 40px; display: grid; gap: 16px; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--delta); border-color: var(--delta); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.grid-2 > *, .grid-3 > *, .view > * { min-width: 0; }
.kpi { min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-weight: 600; }
.panel-head .muted { font-weight: 400; }
.panel-body { padding: 10px 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1280px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; background: var(--panel-2); position: sticky; top: 0; }
.tbl tr.row { cursor: pointer; }
.tbl tr.row:hover td { background: var(--panel-2); }
.tbl td.title { min-width: 300px; max-width: 640px; }
.tbl td.nowrap, .tbl th.nowrap { white-space: nowrap; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl-wrap { overflow: auto; max-height: 72vh; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; line-height: 1.6; border: 1px solid transparent; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.cat-审计 { background: var(--delta-soft); color: var(--delta); }
.badge.cat-绩效评价 { background: var(--delta-soft); color: var(--delta); }
.badge.cat-评估 { background: var(--echo-soft); color: var(--echo); }
.badge.cat-法律 { background: var(--echo-soft); color: var(--echo); }
.badge.stage-公告, .badge.stage-意向 { background: var(--ok-soft); color: var(--ok); }
.badge.stage-结果 { background: var(--panel-2); color: var(--text); }
.badge.stage-合同, .badge.stage-验收, .badge.stage-其他 { color: var(--muted); }
.badge.stage-更正 { background: var(--warn-soft); color: var(--warn); }
.badge.stage-终止 { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.echo { background: var(--echo-soft); color: var(--echo); }
.badge.delta { background: var(--delta-soft); color: var(--delta); }
.rel { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.rel i { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.rel i b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--delta); }
.rel.low i b { background: var(--line); }

.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 72px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; }
.bar i { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; display: block; }
.bar i b { display: block; height: 100%; background: var(--delta); }
.bar.echo i b { background: var(--echo); }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.filters select, .filters input { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius); padding: 5px 8px; outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--delta); }
.filters input[type="search"] { min-width: 220px; }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line-2); }

.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-mask { position: absolute; inset: 0; background: rgba(10, 12, 16, .35); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 96vw); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.drawer-body { padding: 14px 16px; overflow: auto; display: grid; gap: 12px; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
pre.msg { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; white-space: pre-wrap; word-break: break-all; font-family: var(--font); font-size: 12.5px; margin: 0; }
.group-title { font-weight: 600; margin: 6px 0 4px; display: flex; align-items: center; gap: 8px; }
.targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.target { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); font-size: 12.5px; }
.target .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.form { display: grid; gap: 12px; max-width: 640px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.form input, .form textarea { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius); padding: 6px 8px; outline: none; color: var(--text); }
.form textarea { min-height: 70px; font-family: var(--mono); font-size: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: var(--radius); font-size: 12.5px; z-index: 30; max-width: 80vw; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 10px 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 4px 8px 8px; }
  .side-foot { margin-left: auto; border-top: 0; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
  .view { padding: 12px; }
  .tbl td.title { max-width: none; min-width: 240px; }
}

.clients { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 1000px) { .clients { grid-template-columns: 1fr; } }
.client-card { padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); cursor: pointer; display: grid; gap: 4px; }
.client-card.active { border-color: var(--delta); background: var(--delta-soft); }
.client-card .counts { display: flex; gap: 6px; flex-wrap: wrap; }
.verdict-cell { white-space: nowrap; }
.score { color: var(--muted); font-size: 11px; margin-left: 4px; font-variant-numeric: tabular-nums; }
details.profile summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 8px 14px; }
details.profile .form { padding: 0 14px 14px; max-width: none; }
.match-basis { color: var(--muted); font-size: 11.5px; }
