/* 客流工作台 —— 深浅两套主题，手机自适应 */

:root[data-theme="dark"] {
  --bg: #0d1119;
  --bg2: #131926;
  --card: #161d2c;
  --card2: #1b2333;
  --line: #232c3e;
  --text: #e9eef8;
  --muted: #8b97b0;
  --dim: #66718a;
  --accent: #4a8cff;
  --accent2: #7c5cff;
  --up: #f2544b;      /* 涨：红 */
  --down: #2fbf71;    /* 跌：绿 */
  --bgA: rgba(13, 17, 25, .9);
  --accentSoft: rgba(74, 140, 255, .14);
  --accentLine: rgba(74, 140, 255, .3);
  --accentGlow: rgba(74, 140, 255, .26);
  --upSoft: rgba(242, 84, 75, .13);
  --upLine: rgba(242, 84, 75, .3);
  --downGlow: rgba(47, 191, 113, .55);
  --shadow: 0 2px 14px rgba(0, 0, 0, .35);
  --scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f5fa;
  --bg2: #e8edf6;
  --card: #ffffff;
  --card2: #f7f9fd;
  --line: #e2e8f2;
  --text: #16202f;
  --muted: #5d6b85;
  --dim: #8c99b0;
  --accent: #2569e8;
  --accent2: #6a48e0;
  --up: #e8362c;
  --down: #12a05c;
  --bgA: rgba(242, 245, 250, .92);
  --accentSoft: rgba(37, 105, 232, .1);
  --accentLine: rgba(37, 105, 232, .26);
  --accentGlow: rgba(37, 105, 232, .18);
  --upSoft: rgba(232, 54, 44, .1);
  --upLine: rgba(232, 54, 44, .26);
  --downGlow: rgba(18, 160, 92, .45);
  --shadow: 0 2px 12px rgba(20, 35, 70, .08);
  --scheme: light;
}

* { box-sizing: border-box; }

/* 这条不能删！
   HTML 的 hidden 属性靠浏览器默认样式表（[hidden]{display:none}）生效，
   而作者样式表里的 display:flex / inline-flex 会把它盖掉 —— 优先级更高。
   少了这一条，登录遮罩、公网提醒条、退出按钮会从页面一打开就显示出来，
   表现就是：手机上只看到一个空的弹窗糊在最上层，数据其实已经取到了，但被盖住看不见。
   （.date-week 也是 display:inline-flex，同理。） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bgA);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .3px;
  white-space: nowrap;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--down);
  box-shadow: 0 0 0 0 var(--downGlow);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

.topmeta { flex: 1; min-width: 120px; }

.upd {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.topact {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(.96); }
.btn.icon { padding: 7px 10px; font-size: 15px; line-height: 1; }
.btn.danger:hover { border-color: var(--up); color: var(--up); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }

.datepick {
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color-scheme: var(--scheme);
}

/* 日期旁边的「星期N」，跟着日期一起变 */
.date-week {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  background: var(--accentSoft);
  color: var(--accent);
  border: 1px solid var(--accentLine);
}

/* ---------------- 状态区 ---------------- */

.state {
  display: flex;
  justify-content: center;
  padding: 90px 20px;
}

.state-inner { text-align: center; }

.spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 16px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.state p { color: var(--muted); font-size: 14px; margin: 0; }
.state.error .spinner { display: none; }
.state.error p { color: var(--up); }
.state.error::before {
  content: "⚠";
  display: block;
  font-size: 34px;
  margin-bottom: 12px;
  opacity: .8;
}

/* ---------------- 主体 ---------------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 18px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-row {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

/* 大数字卡 */
.hero {
  padding: 22px 22px 20px;
  background: linear-gradient(145deg, var(--card) 0%, var(--card2) 100%);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accentGlow) 0%, transparent 70%);
}

.hero-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .5px;
}

.hero-num {
  font-size: clamp(46px, 9vw, 68px);
  font-weight: 700;
  line-height: 1.05;
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  position: relative;
}

.hero-sub { font-size: 13px; color: var(--muted); }

.hero-tags { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--accentSoft);
  color: var(--accent);
  border: 1px solid var(--accentLine);
}

.tag.warn {
  background: var(--upSoft);
  color: var(--up);
  border-color: var(--upLine);
}

/* 兜底状态（同期的数据取不到时）——弱化，不抢眼 */
.tag.dim {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

/* 同期全天：整页最该被看见的一个数 */
.tag.big {
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 13px;
}

/* 对比卡 */
.cmp-wrap {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
  overflow: hidden;
}

.cmp {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--card);
}

.cmp + .cmp { border-top: 1px solid var(--line); }

.cmp-label {
  font-size: 13px;
  color: var(--muted);
  width: 68px;
  flex-shrink: 0;
}

.cmp-num {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cmp-pct {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 74px;
  text-align: right;
}

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* 卡片头 */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: .3px;
}

.head-meta { font-size: 12.5px; color: var(--muted); }

section.card { margin-bottom: 14px; }

/* 分段切换 */
.seg {
  display: inline-flex;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: .15s;
}

.seg-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

/* 图表 */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

.chart-empty {
  padding: 46px 10px;
  text-align: center;
  color: var(--dim);
  font-size: 13.5px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
}

.lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.lg i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.note {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.7;
}

.foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.8;
}

.foot p { margin: 0; }

/* 页脚那句长提醒：默认折成一枚居中的小胶囊，点一下才展开。
   原来是一整句平铺，手机上会折成两三行、居中之后参差不齐。 */
.foot-more { display: inline-block; }

.foot-more summary {
  display: inline-block;
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card2);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
  list-style: none;                    /* 去掉浏览器默认的三角 */
  -webkit-tap-highlight-color: transparent;
}

.foot-more summary::-webkit-details-marker { display: none; }

.foot-more summary::after { content: " ▾"; }
.foot-more[open] summary::after { content: " ▴"; }

.foot-more summary:hover {
  color: var(--muted);
  border-color: var(--muted);
}

.foot-more > p {
  max-width: 22em;
  margin: 10px auto 0;
  padding: 8px 12px;
  background: var(--card2);
  border-left: 2px solid var(--accentLine);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.7;
  text-align: left;                    /* 长句左对齐，折行才整齐 */
}

/* 备案号：按工信部要求悬挂在页面最底部，可点击跳转备案系统。
   跟「数据来源」是同级的独立一行，别塞进 details 里 —— 折叠起来就不算"悬挂"了。 */
.beian {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: .2px;
}

.beian a {
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}

.beian a:hover,
.beian a:focus-visible {
  color: var(--muted);
  border-bottom-color: var(--muted);
}

/* ---------------- 遮罩 ---------------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 10, 18, .72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mask-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.mask-box.wide { max-width: 440px; }

.mask-box h2 { margin: 0 0 8px; font-size: 17px; font-weight: 620; }
.dim { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 0 0 16px; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.input:focus { border-color: var(--accent); }

.mask-err {
  min-height: 20px;
  color: var(--up);
  font-size: 12.5px;
  margin: 10px 0 0;
}

.mask-box .btn.primary { width: 100%; margin-top: 6px; }
.mask-box .btn { margin-top: 6px; }

/* 公网暴露提醒：能上网访问但没设访问口令时，挂在顶栏下面。
   这是全页面唯一一处会提醒这件事的地方（原来在「手机扫码」面板里，2026-09-15 扫码面板删掉后挪过来），别删。 */
.warnbar {
  padding: 10px 20px;
  background: var(--upSoft);
  border-bottom: 1px solid var(--upLine);
  color: var(--up);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------------- 手机端 ---------------- */

@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 15.5px; }
  .topmeta { order: 3; width: 100%; }
  .topact { margin-left: auto; }
  .topact .btn { padding: 6px 10px; font-size: 12.5px; }
  .datepick { padding: 5px 8px; font-size: 12.5px; }
  .date-week { padding: 5px 8px; font-size: 12.5px; }
  .warnbar { padding: 9px 14px; font-size: 12.5px; }

  main { padding: 14px 12px 30px; }

  .hero-row { grid-template-columns: 1fr; gap: 12px; }

  .card { padding: 15px; border-radius: 12px; }
  .hero { padding: 18px; }
  .hero-num { font-size: clamp(42px, 13vw, 60px); }

  .cmp { padding: 12px 14px; gap: 10px; }
  .cmp-label { width: 60px; font-size: 12.5px; }
  .cmp-num { font-size: 19px; }
  .cmp-pct { font-size: 14px; min-width: 66px; }

  .chart svg { min-height: 190px; }
}

@media (max-width: 380px) {
  .seg-btn { padding: 6px 9px; font-size: 12px; }
}

/* 打印/导出：展开全部图表 */
@media print {
  .topbar, .foot, .seg { display: none; }
  body { background: #fff; }
}
