:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #12141a;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #4f46e5;
  --accent-2: #0ea5a4;
  --green: #059669;
  --amber: #b45309;
  --red: #dc2626;
  --nav: #101322;
  --nav-2: #171b2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 18, 26, 0.04), 0 8px 24px rgba(16, 18, 26, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.shell { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar { width: 236px; flex: 0 0 236px; background: var(--nav); color: #e7e9f3; display: flex; flex-direction: column; padding: 22px 14px 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 22px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #6d6afc, #22c3b7); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; letter-spacing: .5px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: #8b91ab; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: transparent; color: #aeb4ca; padding: 10px 11px; border-radius: 9px; text-align: left; font-size: 13.5px; }
.nav-item:hover { background: var(--nav-2); color: #fff; }
.nav-item.active { background: #232849; color: #fff; font-weight: 600; }
.nav-k { font-size: 11px; color: #7c83a0; background: rgba(255,255,255,.06); border-radius: 6px; padding: 1px 6px; }
.nav-item.active .nav-k { color: #c7c9ff; background: rgba(109,106,252,.18); }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #cfd3e3; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.dot.ok { background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.12); }
.tiny { color: #7c83a0; font-size: 11px; margin-top: 6px; }

/* main */
.main { flex: 1; min-width: 0; padding: 26px 34px 60px; max-width: 1480px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
h1 { font-size: 25px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.top-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 13px; font-size: 13px; font-weight: 500; transition: .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c9ccd6; transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.file-btn { position: relative; overflow: hidden; }
.link { border: 0; background: transparent; color: var(--accent); font-size: 12.5px; padding: 0; }
.icon-btn { border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--muted); padding: 2px 8px; border-radius: 8px; }
.icon-btn:hover { background: #f1f2f5; color: var(--ink); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 18px 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.card-head.wrap { flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 25px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .delta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi .value.green { color: var(--green); }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 74px 1fr 38px; align-items: center; gap: 9px; font-size: 12.5px; }
.funnel-label { color: var(--muted); }
.funnel-track { height: 9px; background: #f0f1f5; border-radius: 99px; overflow: hidden; }
.funnel-fill { height: 100%; background: linear-gradient(90deg, #6d6afc, #22c3b7); border-radius: 99px; min-width: 3px; transition: width .4s; }
.funnel-num { text-align: right; font-variant-numeric: tabular-nums; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 11px; align-items: flex-start; padding: 11px 2px; border-bottom: 1px solid #f0f1f4; min-width: 0; }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.score { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 750; font-size: 13px; background: #eef2ff; color: #4338ca; }
.score.a { background: #e7f8f1; color: #047857; }
.score.b { background: #fff7e6; color: #b45309; }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; border-radius: 999px; padding: 2px 7px; background: #f3f4f6; color: #4b5563; white-space: nowrap; }
.badge.a { background: #e7f8f1; color: #047857; }
.badge.b { background: #fff7e6; color: #b45309; }
.badge.source { background: #eef2ff; color: #4338ca; }
.badge.stage { background: #f1f5f9; color: #334155; }

/* next actions */
.next-list { margin: 0; padding-left: 20px; color: #252936; }
.next-list li { padding: 7px 0; border-bottom: 1px dashed #eef0f3; }
.next-list li:last-child { border-bottom: 0; }

/* table */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
.table { width: 100%; border-collapse: collapse; min-width: 780px; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #f0f1f4; font-size: 12.8px; vertical-align: middle; }
.table th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #fafbff; }
.company-cell { font-weight: 600; }
.company-cell small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 10px; outline: none; color: var(--ink); }
.input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(79,70,229,.08); }
.small-select { min-width: 110px; }
.form { display: grid; gap: 11px; }
.form label { display: grid; gap: 5px; font-size: 12.5px; color: #374151; }
.form .check { display: flex; align-items: center; gap: 8px; }
.notice { background: #f8f9fb; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 12.5px; color: #4b5563; }
.notice.small { font-size: 11.5px; }
code { background: #eef0f4; border-radius: 5px; padding: 1px 5px; font-size: 11.5px; }

/* drafts */
.drafts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.draft { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #fff; }
.draft-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.draft-body { white-space: pre-wrap; font-size: 12.8px; color: #2b2f3a; background: #fafbfc; border: 1px solid #f0f1f4; border-radius: 9px; padding: 10px 11px; max-height: 220px; overflow: auto; }
.draft-actions { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.draft-actions .btn { padding: 6px 9px; font-size: 12px; }

/* pipeline */
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.pipe-col { background: #fafbfc; border: 1px solid var(--line); border-radius: 11px; padding: 10px; min-height: 160px; }
.pipe-col h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; display: flex; justify-content: space-between; }
.pipe-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px; margin-bottom: 8px; font-size: 12.3px; cursor: pointer; }
.pipe-card:hover { border-color: #c7c9ff; box-shadow: 0 3px 10px rgba(79,70,229,.08); }
.pipe-card b { display: block; font-size: 12.5px; }
.pipe-card span { color: var(--muted); font-size: 11.5px; }

/* audits */
.audits { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.audit { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.audit .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.audit .big { font-size: 20px; font-weight: 750; color: var(--green); }
.audit .muted { color: var(--muted); font-size: 12px; }
.audit .bar { height: 8px; background: #f0f1f5; border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.audit .bar > i { display: block; height: 100%; background: linear-gradient(90deg, #22c3b7, #4f46e5); border-radius: 99px; }

/* content */
.report-box { white-space: pre-wrap; background: #0f1220; color: #dbe1ff; border-radius: 11px; padding: 16px; font: 12.2px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 620px; overflow: auto; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,18,32,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 94vw); background: #fff; z-index: 50; box-shadow: -20px 0 50px rgba(15,18,32,.15); display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 16px 20px 28px; overflow: auto; }
.drawer-body .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 14px; }
.drawer-body .detail-grid label { font-size: 11.5px; color: var(--muted); display: block; }
.drawer-body .detail-grid div { font-size: 13px; margin-top: 2px; word-break: break-all; }
.drawer-body textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 9px; padding: 9px; resize: vertical; }
.drawer-body .section { margin-top: 16px; }
.drawer-body .section h3 { font-size: 12.5px; color: var(--muted); margin: 0 0 7px; text-transform: uppercase; letter-spacing: .04em; }
.drawer-body .score-reasons { display: flex; flex-wrap: wrap; gap: 5px; }
.drawer-body .reason { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,32,.38); z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 96vw); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(15,18,32,.25); }
.modal .drawer-head { padding: 16px 18px 12px; }
.modal #modal-body { padding: 14px 18px 20px; }
.modal textarea { width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.modal .form { margin-top: 8px; }

/* toast */
.toast { position: fixed; right: 22px; bottom: 22px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; z-index: 80; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
.toast.err { background: #991b1b; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
  .drafts, .audits { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px 50px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; justify-content: center; }
}
