:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e8eb;
  --line-strong: #d8dbe0;
  --text: #1f2329;
  --muted: #8a919c;
  --faint: #b6bcc5;
  --up: #e4393c;
  --down: #00a870;
  --accent: #2f6feb;
  --accent-soft: #eaf1fe;
  --amber: #e8930c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
button { font: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; letter-spacing: .2px; }
.brand-sm h1 { font-size: 15px; white-space: nowrap; }
.brand-mark {
  width: 10px; height: 18px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filters { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: #f0f2f4; border-radius: 8px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 11px; border-radius: 6px; font-size: 13px; white-space: nowrap;
}
.seg button.active { background: var(--card); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }
.seg-sm button { padding: 3px 9px; font-size: 12px; }

.dd { position: relative; }
.dd summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 6px 26px 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); font-size: 13px; color: var(--muted);
  position: relative; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.dd summary::-webkit-details-marker { display: none; }
.dd summary::after {
  content: ""; position: absolute; right: 10px; top: 12px;
  width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg);
}
.dd[open] summary { border-color: var(--accent); color: var(--text); }
.dd-body {
  position: absolute; top: 38px; left: 0; z-index: 40;
  min-width: 200px; max-height: 320px; overflow: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}
.dd-body label {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.dd-body label:hover { background: #f5f6f8; }
.dd-body input { accent-color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.stamp { font-size: 12px; color: var(--faint); white-space: nowrap; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 5px 10px; border-radius: 8px; font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- 布局 ---------- */

.wrap { max-width: 1560px; margin: 0 auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.72fr 1fr; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; }
.hint { font-size: 12px; color: var(--faint); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ---------- KPI ---------- */

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 10px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value {
  font-size: 28px; font-weight: 600; letter-spacing: -.5px;
  margin: 6px 0 2px; font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--faint); }
.delta { font-weight: 500; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--faint); }
.kpi-spark { height: 26px; margin: 2px -4px -2px; }

/* ---------- 图表 ---------- */

.chart { width: 100%; height: 246px; position: relative; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart-empty, .empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 13px; height: 100%; min-height: 80px;
}

.chart-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: rgba(31, 35, 41, .94); color: #fff; font-size: 12px;
  padding: 8px 10px; border-radius: 8px; line-height: 1.6; white-space: nowrap;
  transform: translate(-50%, -120%);
}
.chart-tip b { font-weight: 600; }

/* ---------- 登录时段 ---------- */

.login-window { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.lw-item { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.lw-item span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.lw-item strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lw-item em { font-size: 11px; color: var(--faint); font-style: normal; }
.lw-timeline { position: relative; height: 34px; margin-top: 4px; }
.lw-track { position: absolute; left: 0; right: 0; top: 15px; height: 4px; background: #eef0f3; border-radius: 2px; }
.lw-span { position: absolute; top: 15px; height: 4px; background: var(--accent); border-radius: 2px; }
.lw-tick { position: absolute; top: 8px; width: 2px; height: 18px; background: var(--text); border-radius: 1px; }
.lw-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ---------- 表格 ---------- */

.table-wrap { overflow: auto; max-height: 320px; }
.table-tall { max-height: 460px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  position: sticky; top: 0; z-index: 1; background: var(--card);
  text-align: right; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td {
  padding: 9px 10px; border-bottom: 1px solid #f2f3f5;
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tbl tbody tr:hover { background: #fafbfc; }
.tbl .num-strong { font-weight: 500; }
.tbl .sub { color: var(--faint); font-size: 12px; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; background: #f0f2f4; color: var(--muted); margin-left: 6px;
}
.badge.warn { background: #fdecec; color: var(--up); }
.badge.ok { background: #e8f7f0; color: var(--down); }
.share-bar { position: relative; height: 6px; background: #f0f2f4; border-radius: 3px; min-width: 60px; overflow: hidden; }
.share-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }

/* ---------- 环形图 / 条形 ---------- */

.donut-wrap { display: flex; align-items: center; gap: 16px; min-height: 190px; }
.donut-wrap svg { width: 168px; height: 168px; flex: 0 0 auto; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.donut-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.donut-legend span { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.bar-list { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 84px; align-items: center; gap: 12px; }
.bar-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: #f0f2f4; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */

.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #eef3fc 0%, var(--bg) 60%);
}
.login-card {
  width: 348px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 28px 22px; box-shadow: 0 12px 40px rgba(16, 24, 40, .08);
}
.login-card .brand { margin-bottom: 22px; }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--faint); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 9px 11px; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary {
  width: 100%; margin-top: 6px; padding: 10px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
}
.btn-primary:hover { background: #2560d4; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.form-error { color: var(--up); font-size: 12px; margin: 0 0 8px; }
.login-foot { margin: 18px 0 0; text-align: center; font-size: 11px; color: var(--faint); }

/* ---------- 响应式 ---------- */

@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .topbar { height: auto; padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
  .filters { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .wrap { padding: 12px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .bar-row { grid-template-columns: 78px 1fr 70px; }
  .login-window { grid-template-columns: 1fr; }
}

/* ---------- 活跃时段明细 ---------- */

.lw-days { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.lw-day { display: grid; grid-template-columns: 52px 1fr auto; font-size: 12px; color: var(--muted); }
.lw-day span:nth-child(2) { font-variant-numeric: tabular-nums; }

.empty { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 13px; padding: 28px 0; }

.share-cell { display: flex; align-items: center; gap: 8px; }
.share-cell .share-bar { flex: 1; }
.share-cell em { font-style: normal; font-size: 11px; color: var(--muted); width: 40px; text-align: right; }
