:root {
  --bg: #0e1116;
  --bg-2: #131722;
  --panel: #171b24;
  --panel-2: #1d222d;
  --border: #272e3a;
  --border-2: #333c4a;
  --text: #e7ebf3;
  --muted: #8b95a7;
  --faint: #5d6678;
  --accent: #4f8cff;
  --accent-2: #6ea8ff;
  --green: #34d399;
  --amber: #f5b14c;
  --red: #f06a6a;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #845cff);
  box-shadow: 0 6px 20px rgba(79, 140, 255, 0.35);
  flex: none;
}
.brand-text h1 { margin: 0; font-size: 22px; letter-spacing: 1px; font-weight: 700; }
.brand-text p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; letter-spacing: .5px; }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.demo-banner {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  background: rgba(245, 177, 76, 0.08);
  border: 1px solid rgba(245, 177, 76, 0.25);
  padding: 7px 12px; border-radius: 999px;
}
.demo-banner .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }

.actor-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.actor-pick select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 9px;
  padding: 8px 12px; font-size: 13px; cursor: pointer; outline: none;
}
.actor-pick select:focus { border-color: var(--accent); }

/* ---------------- 布局 ---------------- */
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 188px; flex: none;
  padding: 22px 14px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.nav-item {
  text-align: left;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 11px;
  padding: 12px 16px; font-size: 14.5px; cursor: pointer;
  transition: all .15s ease;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(79,140,255,.18), rgba(132,92,255,.12));
  color: #fff; border-color: rgba(79,140,255,.4);
  font-weight: 600;
}
.view { flex: 1; padding: 26px 34px; overflow: auto; }

/* ---------------- 通用 ---------------- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 18px; }
.section-title h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.section-title .sub { color: var(--muted); font-size: 13px; }

.btn {
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 9px 16px; font-size: 13.5px; cursor: pointer;
  transition: all .15s ease; font-weight: 500;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #845cff); border: none; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { border-color: rgba(240,106,106,.5); color: var(--red); }
.btn-danger:hover { background: rgba(240,106,106,.12); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }

/* 统计卡 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: 1px; }
.kpi .value.sm { font-size: 22px; }
.kpi .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; letter-spacing: .4px; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 12.5px; }

/* 标签 */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.draft { background: rgba(139,149,167,.15); color: var(--muted); }
.tag.in_review { background: rgba(245,177,76,.15); color: var(--amber); }
.tag.active { background: rgba(52,211,153,.15); color: var(--green); }
.tag.archived { background: rgba(110,168,255,.12); color: var(--accent-2); }
.tag.terminated { background: rgba(240,106,106,.15); color: var(--red); }
.tag.high { background: rgba(240,106,106,.18); color: var(--red); }
.tag.medium { background: rgba(245,177,76,.18); color: var(--amber); }
.tag.low { background: rgba(52,211,153,.15); color: var(--green); }
.tag.pending { background: rgba(139,149,167,.15); color: var(--muted); }
.tag.paid { background: rgba(52,211,153,.15); color: var(--green); }
.tag.overdue { background: rgba(240,106,106,.18); color: var(--red); }
.tag.pass { background: rgba(52,211,153,.15); color: var(--green); }
.tag.conditional { background: rgba(245,177,76,.18); color: var(--amber); }
.tag.reject { background: rgba(240,106,106,.18); color: var(--red); }

.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* 筛选 */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filters .field { display: flex; flex-direction: column; gap: 5px; }
.filters label { font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 9px;
  padding: 9px 12px; font-size: 13.5px; outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

/* 空态 */
.empty { text-align: center; color: var(--faint); padding: 50px 0; font-size: 14px; }

/* 弹层 */
.modal-root { position: fixed; inset: 0; background: rgba(6,8,12,.66); display: grid; place-items: center; z-index: 50; padding: 24px; }
.modal-root.hidden { display: none; }
.modal {
  width: min(720px, 96vw); max-height: 92vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 18px; padding: 26px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.modal .row .col { display: flex; flex-direction: column; gap: 6px; }
.modal .row .col.full { grid-column: 1 / -1; }
.modal label { font-size: 12.5px; color: var(--muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* 详情 tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { background: transparent; border: none; color: var(--muted); padding: 10px 16px; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
.tab.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 22px; border-left: 2px solid var(--border-2); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 14px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.timeline .t-action { font-weight: 600; }
.timeline .t-meta { color: var(--faint); font-size: 12px; }
.timeline .t-note { color: var(--muted); font-size: 13px; margin-top: 2px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 12px 22px; border-radius: 12px; z-index: 80; box-shadow: var(--shadow);
  font-size: 13.5px;
}
.toast.hidden { display: none; }
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(240,106,106,.5); }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.up { color: #cf1322; font-weight: 600; }
.down { color: #389e0d; font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- 集成总线 ---------------- */
.int-summary {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
  font-size: 13.5px;
}
.int-summary.ok { border-color: rgba(52,211,153,.35); }
.int-summary.off { border-color: rgba(240,106,106,.4); }
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.int-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.int-head { display: flex; align-items: center; gap: 10px; }
.int-name { font-weight: 700; font-size: 15px; }
.int-role { color: var(--faint); font-size: 12px; margin-top: 8px; }
.int-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; line-height: 1.6; min-height: 40px; }
.int-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.int-dot.ok { background: var(--green); color: var(--green); }
.int-dot.info { background: var(--accent); color: var(--accent); }
.int-dot.wait { background: var(--amber); color: var(--amber); }
.int-dot.off { background: var(--red); color: var(--red); }
.int-badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; margin-left: auto; }
.int-badge.ok { background: rgba(52,211,153,.15); color: var(--green); }
.int-badge.info { background: rgba(79,140,255,.15); color: var(--accent-2); }
.int-badge.wait { background: rgba(245,177,76,.15); color: var(--amber); }
.int-badge.off { background: rgba(240,106,106,.15); color: var(--red); }
.value.ok { color: var(--green); }
.value.info { color: var(--accent-2); }
.value.wait { color: var(--amber); }
.value.off { color: var(--red); }

/* ---------------- 统计分析 ---------------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }
.hbar-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.hbar-name { width: 220px; min-width: 220px; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.hbar-track { flex: 1; height: 18px; background: var(--bg-2); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 5px; min-width: 2px; }
.hbar-val { width: 110px; min-width: 110px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cols { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 8px 4px 0; }
.col-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.col-amt { font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.col-bar { width: 100%; max-width: 56px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.col-cnt { font-size: 11px; color: var(--faint); margin-top: 4px; }
.col-year { font-size: 12px; color: var(--text); margin-top: 6px; }
/* 历史趋势：无数据年份（灰色空柱）+ 高峰年高亮（与原「历史看板原型」一致） */
.col-item.col-zero .col-bar { background: var(--border-2); opacity: .5; }
.col-item.col-zero .col-year { color: var(--faint); }
.col-item.col-peak .col-bar { background: linear-gradient(180deg, #ffd27a, var(--amber)); box-shadow: 0 0 14px rgba(245,177,76,.45); }
.legend { margin-top: 10px; font-size: 11.5px; color: var(--faint); }
.note { font-size: 12.5px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }

/* 台账看板：小红书式留白居中容器 */
.dash { max-width: 1120px; margin: 0 auto; }

/* 抖音 Top20 风格：带排名数字的横向条形排行 */
.rbar { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.rbar-rank { width: 26px; min-width: 26px; text-align: center; font-weight: 800; font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rbar-rank.top { color: #ffd27a; }
.rbar-name { width: 200px; min-width: 200px; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbar-track { flex: 1; height: 20px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.rbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; min-width: 2px; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.rbar-fill.top { background: linear-gradient(90deg, #ffb347, var(--amber)); box-shadow: 0 0 10px rgba(245,177,76,.35); }
.rbar-val { width: 130px; min-width: 130px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
