:root {
  color-scheme: dark;
  --bg: #0c0c0c;
  --surface: #161616;
  --surface-2: #1c1c1c;
  --surface-3: #222222;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.55);
  --subtle: rgba(255, 255, 255, 0.32);
  --accent: #fa9d3b;
  --accent-2: #ffc46b;
  --green: #07c160;
  --green-2: #12d87a;
  --red: #fa5151;
  --blue: #10aeff;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.30);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -10%, rgba(250, 157, 59, .12), transparent 34rem),
    radial-gradient(circle at 82% 8%, rgba(7, 193, 96, .07), transparent 28rem),
    var(--bg);
}

button,
a { -webkit-tap-highlight-color: transparent; }

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-shell { width: min(460px, 100%); }
.login-card {
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #111;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.login-card h1,
.topbar h1,
.panel h2,
.live-card h2,
.mini-card h3 {
  margin: 0;
  letter-spacing: -0.02em;
}
.login-card h1 { margin-top: 18px; font-size: clamp(30px, 7vw, 44px); line-height: 1.12; }
.login-copy { color: var(--muted); line-height: 1.7; font-size: 15px; }
.login-status {
  margin: 22px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-2);
}
.login-status.ok { border-color: rgba(7, 193, 96, .26); color: var(--green-2); background: rgba(7, 193, 96, .08); }
.login-status.warn { border-color: rgba(250, 157, 59, .3); color: var(--accent); background: rgba(250, 157, 59, .09); }

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease;
}
.primary-button { width: 100%; color: #111; background: var(--accent); }
.primary-button:hover { opacity: .9; }
.ghost-button { color: var(--text); background: rgba(255,255,255,.06); border-color: var(--line); }
.ghost-button:hover { background: rgba(255,255,255,.1); border-color: var(--line-strong); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 4vw, 54px);
  background: rgba(12, 12, 12, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: clamp(22px, 3.2vw, 32px); line-height: 1.18; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-pill {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255,255,255,.04);
}

.dashboard-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px clamp(16px, 3.2vw, 44px) 48px;
}
.eyebrow,
.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.status-strip,
.hero-grid,
.split-grid { display: grid; gap: 14px; }
.status-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.status-strip > div,
.panel,
.live-card,
.mini-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.status-strip > div { padding: 14px 16px; }
.status-strip strong { display: block; margin-top: 7px; font-size: 20px; line-height: 1.2; }
#collector-status { color: var(--accent); }

.hero-grid { grid-template-columns: 1fr; margin-bottom: 14px; }
.live-card,
.mini-card,
.panel { padding: 20px; }
.live-card {
  position: relative;
  overflow: hidden;
  min-height: 226px;
  background:
    linear-gradient(115deg, rgba(250, 157, 59, .09), transparent 48%),
    repeating-radial-gradient(ellipse at 72% 22%, rgba(250,157,59,.16) 0 1px, transparent 1px 42px),
    var(--surface);
}
.live-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(22,22,22,.88) 0%, rgba(22,22,22,.62) 58%, rgba(22,22,22,.2) 100%);
}
.live-card > * { position: relative; z-index: 1; }
.card-header,
.panel-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.live-card h2 { margin-top: 6px; font-size: clamp(24px, 3.2vw, 36px); line-height: 1.15; }
.mini-card h3 { margin-top: 10px; font-size: 24px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid rgba(250, 157, 59, .28);
  color: var(--accent);
  background: rgba(250, 157, 59, .1);
  font-weight: 700;
  white-space: nowrap;
  font-size: 13px;
}
.muted-badge { color: var(--muted); border-color: var(--line); background: rgba(255,255,255,.05); }
.warn-badge { color: var(--accent); border-color: rgba(250, 157, 59, .28); background: rgba(250, 157, 59, .1); }

.metric-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.metric {
  min-width: 0;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
}
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong {
  display: block;
  min-width: 0;
  margin-top: 6px;
  font-size: clamp(18px, 2.2vw, 24px);
  letter-spacing: -0.02em;
  line-height: 1.16;
  font-variant-numeric: tabular-nums;
}
.metric-money strong { color: var(--accent); }
.live-card .metric-money strong { font-size: clamp(24px, 3.4vw, 34px); }

.panel { margin-bottom: 16px; }
.panel h2 { font-size: 20px; }
.chart-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  margin-top: 16px;
  background: rgba(255,255,255,.025);
}
.chart { width: 100%; height: 260px; margin-top: 14px; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; }
.chart .grid { stroke: rgba(255,255,255,.08); }
.chart .gmv { fill: none; stroke: var(--accent); stroke-width: 3; }
.chart .online { fill: none; stroke: var(--green); stroke-width: 3; }
.chart .dot-gmv { fill: var(--accent); }
.chart .dot-online { fill: var(--green); }

.split-grid { grid-template-columns: minmax(0, 1.22fr) minmax(320px, .78fr); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; font-weight: 650; }
td { color: var(--text); }
.empty-cell { color: var(--muted); text-align: center; padding: 28px 12px; }

.session-link { color: var(--text); font-weight: 700; text-decoration: none; border-bottom: 1px solid transparent; }
.session-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.session-detail { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.03); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.detail-meta span { padding: 6px 10px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,.045); font-size: 12px; }
.detail-section-title { margin-top: 18px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.product-list { display: grid; gap: 10px; margin-top: 14px; }
.compact-list { max-height: 460px; overflow: auto; padding-right: 2px; }
.product-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) minmax(86px, max-content); gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.product-rank { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: rgba(250,157,59,.12); font-weight: 800; font-style: italic; }
.product-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.product-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.product-gmv { text-align: right; font-weight: 750; color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.parsed-sections { display: grid; gap: 16px; margin-top: 18px; }
.parsed-section-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.03); }
.parsed-section-card h3 { margin: 6px 0 0; color: var(--muted); font-size: 15px; font-weight: 500; }
.parsed-subtitle { margin: 16px 0 10px; color: var(--text); font-size: 14px; font-weight: 700; }
.parsed-metric small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.parsed-note { color: var(--muted); font-size: 12px; }
.parsed-table { margin-top: 14px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.distribution-card { padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.distribution-card h4 { margin: 0 0 12px; font-size: 14px; }
.bar-row { display: grid; gap: 5px; margin: 10px 0; }
.bar-row-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar-row-head strong { color: var(--text); }
.bar-track { height: 7px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar-row em { color: var(--muted); font-size: 12px; font-style: normal; }
.raw-debug,
.raw-sections,
.raw-section { display: none; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: 360px; padding: 12px 14px; border-radius: 12px; color: var(--text); border: 1px solid var(--line); background: var(--surface-2); box-shadow: var(--shadow); }

@media (max-width: 980px) {
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid, .split-grid { grid-template-columns: 1fr; }
  .metric-grid, .detail-grid, .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  .status-strip, .metric-grid, .detail-grid, .profile-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px; }
  .live-card, .mini-card, .panel { padding: 16px; }
  .live-card .metric-money strong { font-size: clamp(22px, 8vw, 30px); }
}
