:root {
  --ink: #14304A;
  --ink-2: #1E4A6B;
  --accent: #E8542F;
  --accent-soft: #FDEDE8;
  --bg: #F6F8FA;
  --card: #FFFFFF;
  --line: #E3E9EF;
  --line-2: #EFF3F7;
  --muted: #5B6472;
  --muted-2: #8A94A3;
  --up: #1B7F5A;
  --down: #D64530;
  --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 216px; flex: 0 0 216px;
  background: var(--ink);
  color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.4; }
.brand p { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 6px; letter-spacing: 0.06em; }

.nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; font-size: 13.5px; color: rgba(255,255,255,0.62);
  cursor: pointer; border-left: 2px solid transparent; transition: all .12s;
  user-select: none;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.04); }
.nav-item.active { color: #fff; border-left-color: var(--accent); background: rgba(255,255,255,0.06); font-weight: 600; }
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; }

.side-foot {
  padding: 14px 20px; font-size: 11px; color: rgba(255,255,255,0.35);
  border-top: 1px solid rgba(255,255,255,0.08); line-height: 1.6;
}

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: 0 0 60px;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.crumb { font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.crumb-sub { font-size: 12px; color: var(--muted-2); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
select, input[type=text], input[type=date], input[type=password] {
  font-family: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px;
  background: #fff; outline: none;
}
select:focus, input:focus { border-color: var(--ink-2); }

.btn {
  font-family: inherit; font-size: 13px; padding: 7px 14px; border-radius: 4px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.content { padding: 24px 28px 48px; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.card-note { font-size: 11.5px; color: var(--muted-2); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 15px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; width: 3px; height: 100%; background: var(--line); }
.kpi.hl::after { background: var(--accent); }
.kpi-label { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--muted-2); }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted-2); }

/* ---------- 图表 ---------- */
.chart-wrap { width: 100%; overflow: visible; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 74px; align-items: center; gap: 10px; padding: 5px 0; }
.bar-name { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 18px; background: var(--line-2); border-radius: 3px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--ink); border-radius: 3px 0 0 3px; transition: width .35s ease; }
.bar-fill.accent { background: var(--accent); }
.bar-val { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.bar-val .sub { color: var(--muted-2); font-weight: 400; font-size: 11px; margin-left: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; max-height: 620px; border: 1px solid var(--line-2); border-radius: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: #F9FBFD;
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  font-size: 11.5px; letter-spacing: 0.02em;
}
thead th.num, tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th .arrow { font-size: 9px; margin-left: 3px; opacity: .55; }
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
tbody tr:hover { background: #FAFCFE; }
tbody tr:last-child td { border-bottom: none; }
.t-sub { color: var(--muted-2); font-size: 11.5px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 11px;
  font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
}
.tag.system { background: #E6F2EC; color: #146B4A; }
.tag.band { background: #FFF1E8; color: #A8451F; }
.tag.marker { background: #EEF1F5; color: #5B6472; }
.tag.ghost { background: var(--line-2); color: var(--muted); }
.tag.acc { background: var(--accent-soft); color: #B03A1A; }

/* ---------- 空态 / 提示 ---------- */
.empty { padding: 56px 20px; text-align: center; color: var(--muted-2); font-size: 13px; line-height: 1.9; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; font-weight: 700; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: #FFF8F4; border: 1px solid #F6D9CB; border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 4px; font-size: 12.5px; color: #7A3A24; line-height: 1.65;
  margin-bottom: 14px;
}
.banner.info { background: #F3F7FB; border-color: #D3E0EC; border-left-color: var(--ink-2); color: #2A4A66; }

/* ---------- 上传 ---------- */
.drop {
  border: 1.5px dashed #C9D4DF; border-radius: 6px; padding: 30px; text-align: center;
  cursor: pointer; transition: all .15s; background: #FBFCFE;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #FFF9F6; }
.drop b { display: block; font-size: 14px; margin-bottom: 6px; }
.drop span { font-size: 12px; color: var(--muted-2); }

.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

.log { margin-top: 12px; font-size: 12.5px; line-height: 1.8; }
.log .ok { color: var(--up); }
.log .err { color: var(--down); }
.log .warn { color: #A8451F; }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.form-row label { font-size: 12.5px; color: var(--muted); min-width: 62px; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--line-2); border-radius: 3px; padding: 3px 9px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.pill .x { cursor: pointer; color: var(--muted-2); font-weight: 700; }
.pill .x:hover { color: var(--down); }

.loading { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
