:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #8a93a6;
  --line: #e7eaf2;
  --brand: #2f6bff;
  --brand-d: #1d4ed8;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(20,30,60,.08), 0 6px 20px rgba(20,30,60,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
a { cursor: pointer; }

/* ---------- 登录 ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#1d4ed8,#2f6bff 60%,#5b8bff); }
.login-card { width: 380px; background: var(--panel); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-brand { text-align: center; margin-bottom: 22px; }
.brand-logo { width: 54px; height: 54px; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 800; font-size: 22px; display: grid; place-items: center; margin: 0 auto 12px; }
.login-brand h1 { font-size: 20px; margin: 0; }
.login-brand p { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-card button { width: 100%; margin-top: 18px; padding: 11px; border: none; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px; }
.login-card button:hover { background: var(--brand-d); }
.login-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0; position: relative; }
.login-divider span { background: var(--panel); padding: 0 10px; }
.login-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); z-index: -1; }
.wecom-btn { background: #07c160 !important; }
.wecom-btn:hover { background: #06ad56 !important; }
.login-error { color: var(--bad); font-size: 12.5px; margin-top: 12px; min-height: 16px; }

/* ---------- 布局 ---------- */
.app-view { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 18px 12px; }
.sidebar-brand { font-weight: 800; font-size: 18px; color: #fff; padding: 6px 10px 18px; letter-spacing: 1px; }
.nav-item { display: block; padding: 11px 12px; border-radius: 9px; color: #cbd5e1; margin-bottom: 4px; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.sidebar-user { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.sidebar-user #user-name { color: #fff; font-weight: 600; }
.logout-btn { margin-top: 8px; width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.2); color: #cbd5e1; border-radius: 8px; padding: 7px; }
.logout-btn:hover { background: rgba(255,255,255,.08); color:#fff; }
.main { flex: 1; padding: 26px 30px; overflow: auto; }

/* ---------- 卡片/网格 ---------- */
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4,1fr); }
.cards-3 { grid-template-columns: repeat(3,1fr); }
.cards-2 { grid-template-columns: repeat(2,1fr); }
@media (max-width: 1100px) { .cards-4,.cards-3 { grid-template-columns: repeat(2,1fr); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.good { background: #dcfce7; color: var(--good); }
.chip.warn { background: #fef3c7; color: var(--warn); }
.chip.bad { background: #fee2e2; color: var(--bad); }
.chip.info { background: #dbeafe; color: var(--brand-d); }

/* ---------- 表单/按钮 ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; min-width: 150px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); }
.btn { background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px; }
.btn:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; background: #fafbfe; position: sticky; top: 0; }
tbody tr:hover { background: #f7f9ff; }
.section { margin-top: 22px; }
.section h3 { margin: 0 0 10px; font-size: 15px; }

/* ---------- 图表 ---------- */
.chart-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.chart-wrap h3 { margin: 0 0 8px; font-size: 14px; }
.chart-svg { width: 100%; height: 240px; display: block; }
.chart-svg text { fill: var(--muted); font-size: 10px; }
.chart-svg .axis { stroke: var(--line); }
.bar-rect { fill: var(--brand); transition: opacity .15s; cursor: pointer; }
.bar-rect:hover { opacity: .8; }
.line-path { fill: none; stroke: var(--brand); stroke-width: 2; }
.line-dot { fill: var(--brand); cursor: pointer; }
.drill { margin-top: 10px; font-size: 12.5px; color: var(--ink); min-height: 18px; }
.drill b { color: var(--brand-d); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.toast { position: fixed; bottom: 22px; right: 22px; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
