:root {
  color-scheme: dark;
  --bg: #0d0e16; --bg-2: #12131c; --surface: #171825; --surface-2: #1e1f30; --line: rgba(255,255,255,.08);
  --ink: #E7E8F0; --ink-2: #b4b7c9; --muted: #8B8FA3; --faint: #5c6078;
  --brand: #FE2C55; --brand-2: #14A8A3; --violet: #8B7BFF;
  --good: #2F9E50; --warn: #C27A12; --bad: #FE2C55;
  --shadow: 0 8px 28px rgba(0,0,0,.35); --r: 14px;
  --mono: "SF Mono", ui-monospace, "DIN Alternate", monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8; --bg-2: #eef0f4; --surface: #ffffff; --surface-2: #f7f8fb; --line: rgba(20,22,40,.1);
  --ink: #1c1e2b; --ink-2: #3c4054; --muted: #6b7088; --faint: #9aa0b4;
  --shadow: 0 6px 20px rgba(20,22,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; display: flex; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(127,127,150,.35); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

/* 侧栏 */
#side { width: 220px; flex: none; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #ff7a59); display: grid; place-items: center; font-weight: 800; color: #fff; letter-spacing: -1px; }
.brand b { font-size: 15px; display: block; }
.brand small { color: var(--muted); font-size: 11px; }
#search { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; margin-bottom: 12px; outline: none; }
#search:focus { border-color: var(--violet); }
#nav { overflow: auto; display: flex; flex-direction: column; gap: 2px; }
#nav button { display: flex; gap: 9px; align-items: center; text-align: left; background: none; border: 0; border-radius: 9px; padding: 8px 10px; color: var(--ink-2); }
#nav button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
#nav button.on { background: linear-gradient(90deg, rgba(254,44,85,.18), transparent); color: var(--ink); font-weight: 600; }
#nav button:hover:not(.on) { background: var(--surface); }
.side-foot { margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }

/* 主区 */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#top { min-height: 58px; flex: none; flex-wrap: nowrap; padding-top: 10px !important; padding-bottom: 10px !important; display: flex; align-items: center; gap: 14px; padding: 0 20px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
#daterange, #filters { display: none !important; }
#daterange { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#daterange input, .flt select, .field input, .field select, .field textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; outline: none; }
#daterange input:focus, .flt select:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--violet); }
#filters { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; overflow-x: auto; min-width: 0; flex: 1; scrollbar-width: none; }
#filters::-webkit-scrollbar { display: none; }
.btn { white-space: nowrap; }
.flt { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; }
.flt select { max-width: 120px; }
.top-right { flex: none; margin-left: auto; display: flex; align-items: center; gap: 10px; }
.admin-name { color: var(--muted); font-size: 12px; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.badge.ok { background: rgba(47,158,80,.18); color: #5dca7e; }
.badge.warn { background: rgba(194,122,18,.18); color: #e2a84a; }
:root[data-theme="light"] .badge.ok { color: #1d7a3a; }
:root[data-theme="light"] .badge.warn { color: #8a5a09; }
#syncInfo { color: var(--muted); font-size: 12px; }
#errInfo { color: var(--warn); font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 9px; padding: 7px 14px; font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn.busy { opacity: .6; pointer-events: none; }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.iconbtn { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; width: 32px; height: 32px; display: grid; place-items: center; }
.iconbtn svg { width: 15px; height: 15px; stroke: var(--ink-2); fill: none; stroke-width: 1.8; }

#view { flex: 1; overflow: auto; padding: 18px 20px 28px; }
#sheetTabs { display: none; flex: none; align-items: center; gap: 7px; min-height: 54px; overflow-x: auto; padding: 7px 20px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg-2) 78%, transparent); scrollbar-width: thin; }
.sheet-label { flex: none; margin-right: 3px; color: var(--muted); font-size: 11px; }
.sheet-tab { display: flex; flex: none; align-items: center; gap: 9px; max-width: 240px; padding: 7px 10px; color: var(--ink-2); background: transparent; border: 1px solid transparent; border-radius: 8px; white-space: nowrap; }
.sheet-tab span { overflow: hidden; text-overflow: ellipsis; }
.sheet-tab small { color: var(--muted); font-size: 10px; }
.sheet-tab:hover { background: var(--surface); }
.sheet-tab.on { color: var(--ink); background: rgba(254,44,85,.10); border-color: rgba(254,44,85,.2); box-shadow: inset 0 -2px var(--brand); }
.sheet-tab.on small { color: #f27b91; }
.connection-empty { min-height: 60vh; display: grid; grid-template-columns: 56px minmax(0,540px); align-content: center; justify-content: center; gap: 22px; }
.connection-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--brand), #aa1d42); font-weight: 800; font-size: 19px; box-shadow: 0 12px 30px rgba(254,44,85,.2); }
.connection-empty .eyebrow { color: var(--brand-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.connection-empty h2 { margin: 6px 0 8px; font-size: clamp(20px, 3vw, 28px); line-height: 1.3; }
.connection-empty p { margin: 0 0 18px; max-width: 520px; color: var(--muted); }
.page-title { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 14px; }
.page-title h2 { margin: 0; font-size: 18px; }
.page-title span { color: var(--muted); font-size: 12px; }

/* 卡片与网格 */
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; background: radial-gradient(circle, rgba(254,44,85,.16), transparent 70%); }
.k-label { color: var(--muted); font-size: 12px; }
.k-value { font: 600 26px/1.25 var(--mono); letter-spacing: -0.5px; margin: 4px 0; }
.k-sub { font-size: 12px; color: var(--faint); display: flex; gap: 6px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 0; gap: 8px; }
.card h3 { margin: 0; font-size: 13.5px; font-weight: 650; }
.card h3 .sub { color: var(--muted); font-weight: 400; margin-left: 6px; }
.card .body { padding: 10px 14px 14px; flex: 1; min-height: 0; }
.chart { width: 100%; height: 280px; }
.chart.lg { height: 460px; } .chart.xl { height: 620px; } .chart.sm { height: 210px; }
.cols-2 { grid-template-columns: 1fr 1fr; } .cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.cols-13 { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); } .cols-31 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
.grid > * { min-width: 0; }
@media (max-width: 1100px) { .cols-2, .cols-3, .cols-13, .cols-31 { grid-template-columns: 1fr; } #side { width: 64px; } .brand div, #search, #nav button span, .side-foot { display: none; } #nav button { justify-content: center; } }

/* 表格 */
.tbl-wrap { overflow: auto; max-height: 460px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.tbl th { position: sticky; top: 0; background: var(--surface-2); text-align: right; padding: 7px 8px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl td { text-align: right; padding: 6px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
table.tbl tr:hover td { background: rgba(139,123,255,.06); }
table.tbl td.pos { color: var(--good); } table.tbl td.neg { color: var(--bad); }
.column-preview { max-width: 600px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.bar-cell { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.bar-cell i { height: 6px; border-radius: 4px; background: var(--brand-2); display: inline-block; }

/* 其他 */
.tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 9px; padding: 3px; }
.tabs button { background: none; border: 0; border-radius: 7px; padding: 4px 10px; color: var(--muted); font-size: 12px; }
.tabs button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.note { background: rgba(139,123,255,.08); border: 1px solid rgba(139,123,255,.25); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 12px; }
.note b { color: var(--violet); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); margin-right: 4px; }
.insight { border-left: 3px solid var(--brand); padding: 8px 12px; margin-bottom: 8px; background: var(--surface-2); border-radius: 0 10px 10px 0; }
.insight .lv { font-size: 11px; font-weight: 700; }
.lv.good { color: var(--good); } .lv.warn { color: var(--warn); } .lv.bad { color: var(--bad); }
.form { display: grid; gap: 10px; max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field textarea { min-height: 64px; resize: vertical; }
.row-actions { display: flex; gap: 8px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 8px 18px; border-radius: 99px; opacity: 0; transition: .25s; pointer-events: none; font-weight: 600; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.map-tip { position: absolute; pointer-events: none; }
.legend-inline { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); }
.legend-inline b { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 4px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
a.link { color: var(--violet); cursor: pointer; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* 地图大屏氛围 */
.map-card { background: radial-gradient(ellipse at 50% 40%, rgba(139,123,255,.16), transparent 65%), radial-gradient(ellipse at 70% 80%, rgba(254,44,85,.10), transparent 60%), var(--surface); }
.hero-num { font: 700 30px/1.1 var(--mono); letter-spacing: -.5px; background: linear-gradient(90deg, #fff, #c9c2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="light"] .hero-num { background: linear-gradient(90deg, #1c1e2b, #5a4ad1); -webkit-background-clip: text; background-clip: text; }

/* 波后云连锁经营台：以抖音红作点睛，保留低亮度数据底色与足够的阅读对比 */
:root {
  --bg: #0b0c12; --bg-2: #101117; --surface: #15161e; --surface-2: #1c1d27;
  --line: rgba(235,238,255,.075); --brand: #fe2c55; --brand-2: #25f4ee;
  --r: 12px; --shadow: 0 14px 38px rgba(0,0,0,.22);
}
#side { background: linear-gradient(180deg, #101117 0%, #0e0f15 100%); }
#nav button { transition: background .18s ease, color .18s ease, transform .18s ease; }
#nav button.on { background: linear-gradient(90deg, rgba(254,44,85,.17), rgba(254,44,85,.045)); box-shadow: inset 2px 0 var(--brand); }
.card { box-shadow: 0 1px 0 rgba(255,255,255,.018); transition: border-color .18s ease, transform .18s ease; }
.card:hover { border-color: rgba(254,44,85,.2); }
.kpi { background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, white), var(--surface)); }
.kpi::after { background: radial-gradient(circle, rgba(254,44,85,.13), transparent 70%); }
.overview-map-card { height:100%; min-width:0; }
.overview-map-card > .card { height:100%; min-height:480px; }
.overview-map-card > .card > .body { display:flex; flex:1; flex-direction:column; min-height:0; }
.overview-map { flex:1 1 auto; height:auto; min-height:380px; }
#ovMapNote { flex:none; color:var(--ink-2); font-size:13px; line-height:1.65; margin-top:12px; padding:7px 1px 5px; }
.ov-controls { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:0 0 14px; padding:12px 14px; background:linear-gradient(100deg,rgba(254,44,85,.09),rgba(37,244,238,.035)); border:1px solid var(--line); border-radius:12px; }
.ov-controls > div:first-child { display:grid; gap:2px; }
.ov-controls b { font-size:12px; }
.ov-controls small { color:var(--muted); font-size:10px; }
.range-pills { display:flex; gap:6px; flex-wrap:wrap; }
.range-pill { padding:6px 11px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--ink-2); font-size:12px; white-space:nowrap; }
.range-pill:hover { border-color:rgba(254,44,85,.45); color:var(--ink); }
.range-pill.on { color:#fff; border-color:var(--brand); background:var(--brand); box-shadow:0 5px 14px rgba(254,44,85,.18); }
.map-hint { color: var(--muted); font-size: 11px; }
.sync-note { display: grid; gap: 2px; padding: 9px 11px; background: rgba(37,244,238,.055); border: 1px solid rgba(37,244,238,.16); border-radius: 9px; color: var(--ink-2); font-size: 12px; }
.sync-note b { color: var(--brand-2); font-size: 11px; }
.coverage-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.coverage-grid > div { display: flex; align-items: baseline; justify-content: space-between; padding: 12px; background: var(--surface-2); border-radius: 9px; }
.coverage-grid b { font: 600 18px var(--mono); color: var(--brand-2); }
.coverage-grid span,.muted-note { color: var(--muted); font-size: 11px; }
.muted-note { margin: 8px 0 0; }
.table-tools { align-items: center; margin-bottom: 10px; }
.table-tools input,.select-control { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.table-tools input { min-width: 210px; }
.table-tools select,.select-control { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.page-title .select-control { margin-left: auto; }
.source-meta { display: flex; gap: 18px; align-items: center; margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.source-meta span:first-child { color: var(--ink); font-weight: 650; }
.connection-state { display: grid; gap: 10px; color: var(--muted); font-size: 12px; }
.connection-state b { color: var(--ink); font-size: 16px; }
.log-list > div { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.log-list time { color: var(--muted); white-space: nowrap; }
.review-copy { margin-top: 6px; white-space: pre-wrap; color: var(--ink-2); font-size: 12px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
@media (max-width: 1100px) {
  body { overflow: auto; }
  #side { width: 64px; min-height: 100vh; position: sticky; top: 0; }
  #main { min-height: 100vh; }
  #top { flex-wrap: wrap; gap: 8px; }
  #daterange { flex: 1 0 100%; }
  #filters { order: 3; flex: 1 0 100%; }
  .top-right { margin-left: auto; }
}
@media (max-width: 680px) {
  #side { width: 54px; padding: 12px 7px; }
  .brand { padding: 2px 2px 12px; }
  .logo { width: 34px; height: 34px; }
  #view { padding: 14px 12px 24px; }
  #sheetTabs { padding-left: 12px; padding-right: 12px; }
  .connection-empty { grid-template-columns: 1fr; gap: 16px; align-content: center; }
  #top { padding-left: 12px; padding-right: 12px; }
  #daterange, #filters { display: none !important; }
  .page-title { flex-wrap: wrap; }
  .page-title span { flex-basis: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .k-value { font-size: 20px; }
  .overview-map-card > .card { min-height:420px; }
  .overview-map { min-height:340px; }
  #ovMapNote { font-size:12px; }
  .ov-controls { align-items:flex-start; flex-direction:column; }
  .chart.xl { height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
