:root {
  --blue: #1a73e8;
  --blue-dark: #174ea6;
  --orange: #e8710a;
  --ink: #202124;
  --ink-2: #5f6368;
  --ink-3: #80868b;
  --border: #dadce0;
  --bg: #f8f9fa;
  --card: #ffffff;
  --hover: #f8f9fa;
  --good: #188038;
  --bad: #d93025;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Roboto, 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- 登录墙 ---------- */
#login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 48px 56px; text-align: center; box-shadow: 0 1px 3px rgba(60,64,67,.08);
}
.login-logo { font-size: 40px; margin-bottom: 12px; }
.login-card h1 { font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.login-sub { color: var(--ink-3); font-size: 13px; margin-bottom: 28px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.topbar-title { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.badge {
  font-size: 11px; color: var(--blue-dark); background: #e8f0fe;
  padding: 2px 8px; border-radius: 10px; font-weight: 500;
}
.topbar-user { display: flex; align-items: center; gap: 14px; color: var(--ink-2); }
.link-muted { color: var(--ink-3); text-decoration: none; font-size: 13px; }
.link-muted:hover { color: var(--blue); }

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

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}

/* ---------- 工具栏 ---------- */
.toolbar { padding: 14px 18px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toolbar-label { color: var(--ink-2); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--ink-2);
  border-radius: 16px; padding: 5px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: background .15s;
}
.chip:hover { background: var(--hover); }
.chip.active { background: #e8f0fe; border-color: #e8f0fe; color: var(--blue-dark); font-weight: 500; }
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range input[type="date"] {
  border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px;
  font-family: inherit; font-size: 13px; color: var(--ink);
}
.range-sep { color: var(--ink-3); }
.btn-primary {
  display: inline-block; background: var(--blue); color: #fff; border: none;
  border-radius: 4px; padding: 8px 20px; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn-primary:hover { background: var(--blue-dark); }

/* ---------- 得分卡 ---------- */
.scorecards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.scorecard {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 18px;
}
.scorecard .sc-label { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.scorecard .sc-value { font-size: 26px; font-weight: 500; letter-spacing: -.3px; }
.scorecard .sc-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.scorecard.accent { border-top: 3px solid var(--orange); }

/* ---------- 表格 ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 150px); }
table { width: 100%; border-collapse: collapse; min-width: 1150px; }
thead th {
  font-size: 12px; font-weight: 500; color: var(--ink-2); text-align: right;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--card); z-index: 10;
  height: 38px;
}
thead th:first-child { text-align: left; }
thead th .arrow { font-size: 10px; margin-left: 2px; color: var(--blue); }
tbody td {
  padding: 10px 12px; text-align: right; border-bottom: 1px solid #f1f3f4;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
tbody td:first-child { text-align: left; }
tbody tr.data-row { cursor: pointer; }
tbody tr.data-row:hover { background: var(--hover); }
tr.total-row td {
  font-weight: 700; border-bottom: 1px solid var(--border); background: #fafbfc;
  padding: 10px 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
  position: sticky; top: 38px; z-index: 10;
}
tr.total-row td:first-child { text-align: left; }
.camp-name { font-weight: 400; color: var(--ink); max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.acct-tag {
  display: inline-block; font-size: 11px; color: var(--ink-2); background: #f1f3f4;
  border-radius: 4px; padding: 1px 6px; margin-right: 6px;
}
.muted { color: var(--ink-3); }
.gap-col { background: #fff8f1; }
tr.total-row .gap-col { background: #fdf0e3; }
.na { color: var(--ink-3); }

/* ---------- 展开详情 ---------- */
tr.detail-row td { background: #fafbfc; padding: 16px 20px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.chart-title { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.legend { display: flex; gap: 14px; margin-bottom: 6px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-svg { width: 100%; height: 150px; display: block; }
.chart-svg text { font-family: inherit; font-size: 10px; fill: var(--ink-3); }
.gridline { stroke: #f1f3f4; stroke-width: 1; }
.axisline { stroke: var(--border); stroke-width: 1; }

/* ---------- 图表悬浮提示 ---------- */
.chart-tooltip {
  position: fixed; z-index: 50; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 2px 8px rgba(60,64,67,.18);
  padding: 8px 12px; font-size: 12px; pointer-events: none; min-width: 140px;
}
.chart-tooltip .tt-date { color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chart-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip .tt-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink); }

.empty-state { padding: 60px 0; text-align: center; color: var(--ink-3); }
.footnote { color: var(--ink-3); font-size: 12px; line-height: 1.7; margin: 14px 4px 40px; }
