:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e6e8ef;
  --brand: #4f46e5;
  --brand-soft: #eef0ff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(20, 24, 40, .08), 0 6px 18px rgba(20, 24, 40, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
}
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 6px; }
.tab {
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600;
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--brand-soft); color: var(--brand); }

main { padding: 24px; max-width: 1180px; margin: 0 auto; }

/* KPI 卡片 */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 500; }

/* 图表 */
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.chart-card.wide { grid-column: span 2; }

/* 表格 */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toolbar h2 { margin: 0; font-size: 18px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--red); border-color: #f3c2c2; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #fafbff; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.green { background: #e7f6ec; color: var(--green); }
.tag.red { background: #fdeaea; color: var(--red); }
.tag.amber { background: #fdf2e2; color: var(--amber); }
.tag.gray { background: #eef0f4; color: var(--muted); }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20,24,40,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { background: #fff; width: 460px; max-width: 92vw; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-head button { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
#modal-form { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#modal-form .full { grid-column: span 2; }
#modal-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
#modal-form input, #modal-form select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--ink); }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); text-align: right; }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }
.toast.hidden { display: none; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
}
