/* 销售时段看板 —— 样式。
 *
 * 视觉方向「运营销售看板」：暖米白底、深墨色字、一个青绿强调色；
 * 三个时段各一个类别色（白天琥珀 / 傍晚玫红 / 夜间靛蓝），其他 6–9 点用暖灰压低。
 * 时段配色已用 dataviz 校验器验过（暖底 #fbf9f4，全两两对比）：
 *   色弱最差 ΔE 12.5（≥8 达标），正常视觉最差 ΔE 23.6（≥15 达标）。
 *   琥珀对底色对比 2.55:1 < 3:1 —— 按规则配了可见数字标签和明细表。
 * 只做浅色。
 */

:root {
  color-scheme: light;

  --canvas: #f4f0e6;
  --canvas-2: #ece6d8;
  --surface: #fbf9f4;
  --surface-hover: #f6f2e9;
  --ink: #1a1915;
  --ink-2: #4f4b43;
  --muted: #6f6a60;
  --faint: #9a9488;
  --hair: #e3ddd0;
  --hair-2: #d6cfbf;
  --grid: #ebe5d8;
  --axis: #c9c1b0;

  --accent: #0d6e5f;
  --accent-hover: #0a5c4f;
  --accent-soft: #dcece6;
  --accent-ring: rgba(13, 110, 95, 0.28);

  --slot-day: #cf9300;
  --slot-evening: #cc4278;
  --slot-night: #2e4cb3;
  --slot-other: #aaa497;
  --slot-day-soft: #f3e3bd;
  --slot-evening-soft: #f2d5e1;
  --slot-night-soft: #d9e0f4;
  --slot-other-soft: #e6e1d6;
  /* 深色底（顶栏、登录页头图、悬停提示）上用的同一组时段色，提亮一档 */
  --slot-day-on-dark: #cf9300;
  --slot-evening-on-dark: #e0659a;
  --slot-night-on-dark: #6f88e0;
  --slot-other-on-dark: #57534a;

  --good: #17803d;
  --good-soft: #e3f1e6;
  --bad: #b42318;
  --bad-soft: #f8e4e1;

  --topbar: #1a1915;
  --topbar-ink: #f4f0e6;
  --topbar-muted: #b3ad9f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(26, 25, 21, 0.04), 0 8px 24px -16px rgba(26, 25, 21, 0.18);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 50;
  background: var(--ink);
  color: var(--topbar-ink);
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
}
.skip:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-left: 32px;
  padding-right: 32px;
}

/* ══ 顶栏 ══════════════════════════════════════════════════════════════ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar);
  color: var(--topbar-ink);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--topbar-ink);
  text-decoration: none;
  flex: none;
}
.brand-mark { width: 30px; height: 30px; display: block; }
.ring-day { stroke: var(--slot-day-on-dark); }
.ring-evening { stroke: var(--slot-evening-on-dark); }
.ring-night { stroke: var(--slot-night-on-dark); }
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: 0.02em; }

.fresh {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--topbar-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 0;
}
.fresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--topbar-muted);
  flex: none;
}
.fresh-dot.ok { background: #3ec28f; box-shadow: 0 0 0 3px rgba(62, 194, 143, 0.18); }
.fresh-dot.stale { background: #e8b23a; box-shadow: 0 0 0 3px rgba(232, 178, 58, 0.18); }
.fresh-dot.old { background: #ef7b6c; box-shadow: 0 0 0 3px rgba(239, 123, 108, 0.18); }
.fresh-sep { opacity: 0.5; }

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  white-space: nowrap;
}
.who-name { color: var(--topbar-ink); font-weight: 550; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
  border: 1px solid rgba(244, 240, 230, 0.28);
  color: var(--topbar-muted);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11.5px;
  line-height: 20px;
}
.role-badge:empty { display: none; }
.role-badge.is-admin { border-color: rgba(94, 196, 168, 0.55); color: #8fd9c3; }
.logout-form { display: inline; margin: 0; }
.toplink {
  color: var(--topbar-ink);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.2;
}
.toplink:hover { background: rgba(244, 240, 230, 0.1); }
.toplink-btn { background: transparent; border: 1px solid rgba(244, 240, 230, 0.22); cursor: pointer; }
.toplink-btn:hover { border-color: rgba(244, 240, 230, 0.4); }
.toplink[aria-current="page"] { background: rgba(244, 240, 230, 0.12); }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  overflow: hidden;
  visibility: hidden;
}
.progress::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -30%;
  width: 30%;
  background: #3ec28f;
}
body.is-loading .progress { visibility: visible; }
body.is-loading .progress::after { animation: slide 1.1s ease-in-out infinite; }
@keyframes slide {
  from { left: -30%; }
  to { left: 100%; }
}

/* ══ 时间范围 ══════════════════════════════════════════════════════════ */

.main { padding-top: 28px; padding-bottom: 24px; }

.controls { display: grid; gap: 14px; }

.preset-rail {
  margin: 0 -4px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.preset-rail::-webkit-scrollbar { display: none; }

.presets {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--canvas-2);
  border-radius: 12px;
  white-space: nowrap;
}
.presets button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.presets button:hover { background: rgba(255, 255, 255, 0.55); color: var(--ink); }
.presets button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--topbar-ink);
  font-weight: 600;
}
.live-tag {
  font-size: 10.5px;
  line-height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.presets button[aria-pressed="true"] .live-tag { background: var(--accent); color: #fff; }

.custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.date-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.date-field input {
  border: 1px solid var(--hair-2);
  background: var(--surface);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-height: 36px;
}
.date-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.custom-hint { color: var(--muted); font-size: 12.5px; }
.custom-hint.is-error { color: var(--bad); font-weight: 550; }

.range-line { display: grid; gap: 4px; padding-top: 6px; }
.range-title {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.range-dash { color: var(--faint); font-weight: 400; }
.range-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 13.5px; }
.range-compare { position: relative; }
.range-compare:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 0;
  border-top: 2px solid var(--ink-2);
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -2px;
}
.range-note {
  margin-top: 6px;
  color: #7a5200;
  background: #fbefd2;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  justify-self: start;
}

.alert {
  margin-top: 18px;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid #efc5bf;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 550;
}

/* ══ 区块 ══════════════════════════════════════════════════════════════ */

.content { transition: opacity 0.2s; }
body.is-loading .content:not(.is-empty) { opacity: 0.55; pointer-events: none; }
.content.is-empty .sec { visibility: hidden; }

.sec {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--hair-2);
}
.sec-hero { margin-top: 26px; border-top: 0; padding-top: 0; }

.sec-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  margin-bottom: 18px;
}
.sec-head-tools { grid-template-columns: auto 1fr auto; }
.kicker {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  padding-top: 5px;
  border-top: 2px solid var(--accent);
  line-height: 1;
  margin-top: 6px;
}
.sec-head h2 { font-size: 21px; line-height: 1.3; font-weight: 700; letter-spacing: 0.01em; }
.sec-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.sec-sub strong { color: var(--ink-2); font-weight: 600; }

.panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── 切换按钮（单数 / 销售额） ── */

.toggle {
  display: inline-flex;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  padding: 3px;
  background: var(--surface);
  align-self: center;
}
.toggle button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.toggle button:hover { color: var(--ink); background: var(--surface-hover); }
.toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  line-height: 1.3;
  white-space: nowrap;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--hair-2); align-self: center; }
.btn-outline:hover { border-color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--hair-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #951d14; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; font-weight: 550; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon { width: 16px; height: 16px; flex: none; }

/* ══ 01 时段卡片 ═══════════════════════════════════════════════════════ */

.slot-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.slot-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.slot-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: var(--slot-color);
}
.sc-day { --slot-color: var(--slot-day); --slot-soft: var(--slot-day-soft); }
.sc-evening { --slot-color: var(--slot-evening); --slot-soft: var(--slot-evening-soft); }
.sc-night { --slot-color: var(--slot-night); --slot-soft: var(--slot-night-soft); }

.sc-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.sc-name { font-size: 19px; font-weight: 700; }
.sc-span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sc-tag {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--canvas-2);
  border-radius: 999px;
  padding: 2px 9px;
}

.sc-label { color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.sc-value {
  display: block;
  font-size: 38px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sc-value .cents { font-size: 22px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.sc-delta, .sc-sub-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.sc-prev { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.sc-sub {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}
.sc-sub-r { margin-top: 0; padding-bottom: 4px; }
.sc-value-2 { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.sc-value-2 .unit { font-size: 14px; color: var(--muted); font-weight: 500; }

.sc-share { display: grid; gap: 10px; }
.share-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.share-val { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--slot-soft);
  overflow: hidden;
}
.meter-fill { height: 100%; background: var(--slot-color); border-radius: 999px; min-width: 2px; }
.meter-fill.is-zero { display: none; }
.meter-day { --slot-color: var(--slot-day); --slot-soft: var(--slot-day-soft); }
.meter-evening { --slot-color: var(--slot-evening); --slot-soft: var(--slot-evening-soft); }
.meter-night { --slot-color: var(--slot-night); --slot-soft: var(--slot-night-soft); }

.sc-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}
.stat { min-width: 0; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-val { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.stat-num { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-val .delta { font-size: 11.5px; }
.stat-sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* 变化标记 */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border-radius: 6px;
  line-height: 1.5;
}
.delta-arrow { font-size: 0.78em; }
.delta.is-good { color: var(--good); }
.delta.is-bad { color: var(--bad); }
.delta.is-flat, .delta.is-na { color: var(--muted); font-weight: 500; }
.sc-delta .delta, .sc-sub-r .delta, .tot-item .delta {
  padding: 1px 7px;
}
.sc-delta .delta.is-good, .sc-sub-r .delta.is-good, .tot-item .delta.is-good { background: var(--good-soft); }
.sc-delta .delta.is-bad, .sc-sub-r .delta.is-bad, .tot-item .delta.is-bad { background: var(--bad-soft); }

/* 合计条 */
.totals {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--canvas-2);
}
.tot-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; }
.tot-title { font-weight: 700; font-size: 13.5px; }
.tot-list { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.tot-item { display: flex; align-items: baseline; gap: 6px; }
.tot-item dt { color: var(--muted); font-size: 12.5px; }
.tot-item dd { display: inline-flex; align-items: center; gap: 6px; }
.tot-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.tot-item .delta { font-size: 11.5px; padding: 0 5px; }
.tot-other { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: 12.5px; }
.tot-other-head { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tot-other-note { color: var(--faint); }
.tot-other-val { font-variant-numeric: tabular-nums; }

/* 色块 */
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
  vertical-align: baseline;
}
.swatch-lg { width: 12px; height: 12px; }
.sw-day { background: var(--slot-day); }
.sw-evening { background: var(--slot-evening); }
.sw-night { background: var(--slot-night); }
.sw-other { background: var(--slot-other); }

/* ══ 02 对比 ═══════════════════════════════════════════════════════════ */

.insights {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  max-width: 900px;
}
.insight { display: flex; align-items: baseline; gap: 10px; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.insight strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.insight .swatch { position: relative; top: 0; }
.insight-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; border: 2px solid var(--ink-2); }

.compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
}

.fig { padding: 18px 20px 16px; min-width: 0; }
.fig-head { display: grid; gap: 2px; margin-bottom: 12px; }
.fig-title { font-weight: 700; font-size: 14.5px; }
.fig-sub { color: var(--muted); font-size: 12.5px; }
.fig-foot { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-name { font-weight: 600; }
.legend-span { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-item.is-muted .legend-name { color: var(--muted); font-weight: 500; }

.chart { position: relative; min-width: 0; }
.chart-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.chart-scroll.is-scrolling { padding-bottom: 6px; }
.viz { display: block; overflow: visible; }

.pace-key { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.pace-key-item { display: inline-flex; align-items: center; gap: 6px; }
.pace-key-bar { width: 16px; height: 8px; border-radius: 2px; background: var(--ink-2); }
.pace-key-tick { width: 2px; height: 14px; background: var(--ink); }

.table-panel { margin-top: 16px; padding: 4px 0; overflow: hidden; }
.scroll-hint { display: none; color: var(--faint); font-size: 12px; padding: 8px 14px 0; }

/* ══ SVG 图元 ══════════════════════════════════════════════════════════ */

.f-day { fill: var(--slot-day); }
.f-evening { fill: var(--slot-evening); }
.f-night { fill: var(--slot-night); }
.f-other { fill: var(--slot-other); }
.fs-day { fill: var(--slot-day-soft); }
.fs-evening { fill: var(--slot-evening-soft); }
.fs-night { fill: var(--slot-night-soft); }
.fs-other { fill: var(--slot-other-soft); }

.viz text { font-family: var(--font); }
.t-label { font-size: 12.5px; fill: var(--ink-2); font-weight: 600; }
.t-title { font-size: 12.5px; fill: var(--ink); font-weight: 700; }
.t-value { font-size: 12.5px; fill: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.t-tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.t-faint { font-size: 10.5px; fill: var(--faint); }
.t-strong { fill: var(--ink-2); font-weight: 650; }
.t-muted { fill: var(--muted) !important; font-weight: 500; }
.t-band { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; }
.t-small { font-size: 11px; }
.t-peak { font-size: 11px; fill: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.t-soft { fill: var(--ink-2); font-weight: 550; }
.t-in { font-size: 11.5px; fill: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; pointer-events: none; }
.t-in.t-on-dark, .t-cell.t-on-dark { fill: #fff; }
.t-cell { font-size: 10.5px; fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.t-row { font-size: 11px; }
.t-empty { font-size: 13px; fill: var(--muted); font-weight: 550; }
.t-empty.t-small { font-size: 11.5px; }
.seg-empty { fill: var(--canvas-2); }

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.sep-line { stroke: var(--hair-2); stroke-width: 1; }
.avg-line { stroke: var(--ink); stroke-width: 1.5; opacity: 0.55; pointer-events: none; }
.prev-tick { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; pointer-events: none; }

.hit { fill: transparent; cursor: default; outline: none; }
.hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.bar, .seg, .cell, .col path, .col rect.bar { transition: opacity 0.12s; }
.is-dimming .bar:not(.is-hot),
.is-dimming .seg:not(.is-hot) { opacity: 0.4; }
.is-dimming .col:not(.is-hot) .bar { opacity: 0.4; }
.is-dimming .col.is-hot .bar { opacity: 1; }
.cell.is-hot { stroke: var(--ink); stroke-width: 1.5; }
.cell.is-future { stroke: var(--hair-2); stroke-width: 1; }
.col.is-today .bar { opacity: 0.55; }

/* 热力图图例 */
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.heat-zero { display: inline-flex; align-items: center; gap: 6px; }
.heat-zero-sw { width: 14px; height: 10px; border-radius: 3px; background: #ece6d8; border: 1px solid var(--hair-2); }
.heat-scale { display: block; overflow: visible; }

/* ══ 表格 ══════════════════════════════════════════════════════════════ */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.data-table th,
.data-table td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid var(--hair);
}
.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--surface);
  position: sticky;
  top: 0;
}
.data-table .l { text-align: left; }
.data-table tbody th { font-weight: 600; color: var(--ink); }
.data-table tbody th .swatch,
.data-table td .swatch,
.data-table thead th .swatch { margin-right: 7px; }
.data-table .td-sub { color: var(--muted); font-weight: 400; font-size: 12px; }
.data-table tr.is-muted th, .data-table tr.is-muted td { color: var(--muted); }
.data-table tr.is-subtotal th, .data-table tr.is-subtotal td { background: var(--canvas); font-weight: 650; color: var(--ink-2); }
.data-table tr.is-total th, .data-table tr.is-total td { font-weight: 700; color: var(--ink); border-top: 1px solid var(--ink-2); border-bottom: 0; }
.data-table tr.is-weekend th { color: var(--ink); }
.data-table tbody tr:hover th, .data-table tbody tr:hover td { background: var(--surface-hover); }
.data-table th.grp { text-align: center; color: var(--ink-2); border-bottom: 1px solid var(--hair-2); }
.data-table .td-total { font-weight: 650; }
.data-table td .delta { font-size: 12px; }
.compare-table td:nth-child(3), .compare-table td:nth-child(5) { padding-left: 4px; text-align: left; }

.details { margin-top: 12px; overflow: hidden; }
.details summary {
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 650;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.details summary::-webkit-details-marker { display: none; }
.details summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin-right: 4px;
}
.details[open] summary::before { transform: rotate(45deg); }
.details[open] summary { border-bottom: 1px solid var(--hair); }
.summary-sub { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.details .table-scroll { max-height: 640px; overflow-y: auto; }

/* ══ 悬停提示 ══════════════════════════════════════════════════════════ */

.tip {
  position: fixed;
  z-index: 60;
  left: 0;
  top: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--topbar-ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  min-width: 160px;
  max-width: 280px;
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.45);
}
.tip[hidden] { display: none; }
.tip-title { font-weight: 650; color: var(--topbar-muted); font-size: 12px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; background: transparent; }
.tip-key.k-day { background: var(--slot-day-on-dark); }
.tip-key.k-evening { background: var(--slot-evening-on-dark); }
.tip-key.k-night { background: var(--slot-night-on-dark); }
.tip-key.k-other { background: var(--slot-other); }
.tip-val { font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.tip-lbl { color: var(--topbar-muted); margin-left: auto; padding-left: 12px; }

/* ══ 页脚 ══════════════════════════════════════════════════════════════ */

.foot {
  margin-top: 40px;
  padding-top: 22px;
  padding-bottom: 48px;
  background: linear-gradient(var(--hair-2), var(--hair-2)) top center / calc(100% - 64px) 1px no-repeat;
  color: var(--muted);
  font-size: 12.5px;
}
.foot-title { font-size: 12.5px; color: var(--ink-2); font-weight: 700; margin-bottom: 6px; }
.foot-list { display: grid; gap: 3px; max-width: 880px; }
.foot-list li { padding-left: 14px; position: relative; }
.foot-list li::before { content: ""; position: absolute; left: 2px; top: 0.72em; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.foot strong { color: var(--ink-2); font-weight: 600; }

/* ══ 登录 / 首次设置 ═══════════════════════════════════════════════════ */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(26, 25, 21, 0.04), 0 24px 48px -28px rgba(26, 25, 21, 0.35);
  overflow: hidden;
}
.auth-hero {
  background: var(--topbar);
  color: var(--topbar-ink);
  padding: 26px 28px 0;
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .brand-mark { width: 34px; height: 34px; }
.auth-title { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
.auth-tagline { color: var(--topbar-muted); font-size: 13px; margin-top: 10px; }
.auth-bars { display: block; width: 100%; height: 64px; margin-top: 16px; }
.auth-bars .b-day { fill: var(--slot-day-on-dark); }
.auth-bars .b-evening { fill: var(--slot-evening-on-dark); }
.auth-bars .b-night { fill: var(--slot-night-on-dark); }
.auth-bars .b-other { fill: var(--slot-other-on-dark); }
.auth-main { padding: 26px 28px 24px; }
.auth-heading { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-form { display: grid; gap: 6px; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 8px; }
.auth-form label .opt { color: var(--faint); font-weight: 400; }
.field {
  width: 100%;
  border: 1px solid var(--hair-2);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  min-height: 44px;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field[readonly] { background: var(--canvas); color: var(--ink-2); }
.field-hint { color: var(--faint); font-size: 12px; }
.auth-err { color: var(--bad); background: var(--bad-soft); border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 550; margin-top: 10px; }
.auth-err:empty { display: none; }
.auth-ok { color: var(--accent); background: var(--accent-soft); border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 550; margin-top: 10px; }
.auth-ok:empty { display: none; }
.auth-form .btn { margin-top: 16px; padding: 11px 16px; font-size: 15px; }
.btn-block { width: 100%; }
.auth-foot { color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* 首次设置页：三种模式 */
.mode-setup .only-reset,
.mode-setup .only-invalid,
.mode-reset .only-setup,
.mode-reset .only-invalid,
.mode-invalid .only-setup,
.mode-invalid .only-reset,
.mode-invalid .only-form { display: none !important; }
.reset-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--canvas);
  font-weight: 650;
}
.reset-user .muted { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ══ 账号管理页 ════════════════════════════════════════════════════════ */

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.admin-panel { padding: 20px 22px; }
.admin-panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.admin-panel .panel-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.form-grid { display: grid; gap: 4px; }
.form-grid label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 10px; }
.form-grid label:first-child { margin-top: 0; }
.input-row { display: flex; gap: 8px; }
.input-row .field { flex: 1; min-width: 0; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
.role-opt {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  font-weight: 400 !important;
  margin-top: 0 !important;
}
.role-opt input { position: absolute; left: 12px; top: 13px; accent-color: var(--accent); margin: 0; }
.role-opt strong { font-size: 13.5px; color: var(--ink); }
.role-opt span { font-size: 12px; color: var(--muted); }
.role-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #f6fbf9; }
.form-msg { font-size: 13px; margin-top: 10px; border-radius: 9px; padding: 8px 12px; }
.form-msg:empty { display: none; }
.form-msg.is-ok { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.form-msg.is-err { background: var(--bad-soft); color: var(--bad); font-weight: 550; }
.pw-reveal {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  background: #f6fbf9;
  font-size: 13px;
  color: var(--ink-2);
}
.pw-reveal code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; color: var(--ink); font-weight: 700; word-break: break-all; }

.user-table td, .user-table th { vertical-align: middle; }
.user-table .acts { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-viewer { background: var(--canvas-2); color: var(--ink-2); }
.badge-off { background: var(--bad-soft); color: var(--bad); }
.badge-on { background: var(--good-soft); color: var(--good); }
.badge-me { background: var(--ink); color: var(--topbar-ink); margin-left: 6px; font-size: 11px; }
.user-table tr.is-disabled th, .user-table tr.is-disabled td:not(:last-child) { color: var(--faint); }
.user-cell { display: grid; gap: 1px; text-align: left; }
.user-cell .u-name { font-weight: 650; color: var(--ink); }
.user-cell .u-id { color: var(--muted); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.audit-list { display: grid; }
.audit-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 4px 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
  align-items: baseline;
}
.audit-item:last-child { border-bottom: 0; }
.audit-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.audit-what { color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.audit-what strong { color: var(--ink); font-weight: 650; }
.audit-ip { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.audit-item.is-warn .audit-what strong { color: var(--bad); }
.empty { color: var(--muted); padding: 16px 0; font-size: 13px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 720px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 10px; }
.back-link:hover { color: var(--ink); }

.denied { text-align: center; padding: 48px 20px; }
.denied h2 { font-size: 18px; margin-bottom: 6px; }
.denied p { color: var(--muted); margin-bottom: 18px; }

dialog.dlg {
  border: 0;
  padding: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 30px 60px -20px rgba(26, 25, 21, 0.45);
}
dialog.dlg::backdrop { background: rgba(26, 25, 21, 0.42); }
.dlg-body { padding: 22px 22px 8px; }
.dlg-body h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.dlg-body p { color: var(--ink-2); font-size: 13.5px; }
.dlg-body .form-grid { margin-top: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* ══ 窄屏 ══════════════════════════════════════════════════════════════ */

@media (max-width: 1080px) {
  .slot-cards { grid-template-columns: 1fr; }
  .slot-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
  .sc-head { grid-column: 1 / -1; }
  .sc-main { grid-column: 1; }
  .sc-sub { grid-column: 1; }
  .sc-share { grid-column: 2; grid-row: 2; align-self: center; }
  .sc-stats { grid-column: 2; grid-row: 3; }
  .compare-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .admin-grid { grid-template-columns: 1fr; }
  .fresh .fresh-sep, .fresh #freshOrder { display: none; }
}

@media (max-width: 680px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .foot { background-size: calc(100% - 32px) 1px; }
  .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding-top: 10px; padding-bottom: 8px; min-height: 0; }
  .brand-name { font-size: 15px; }
  .fresh { order: 3; width: 100%; font-size: 12px; }
  .fresh .fresh-sep, .fresh #freshOrder { display: inline; }
  .who { gap: 6px; }
  .who-name { max-width: 6em; }
  .role-badge { display: none; }
  /* 只看数据的账号顶栏没有「账号管理」，地方够，角色照样显示 */
  .who:has(#adminLink.hidden) .role-badge:not(:empty) { display: inline-block; }
  .range-meta { flex-direction: column; gap: 2px; }
  .range-compare:not(:empty)::before { display: none; }
  .toplink { padding: 5px 8px; }
  .main { padding-top: 18px; }
  .range-title { font-size: 22px; }
  .sec { margin-top: 34px; }
  .sec-head-tools { grid-template-columns: auto 1fr; }
  .sec-head-tools > .toggle, .sec-head-tools > .btn { grid-column: 1 / -1; justify-self: start; margin-top: 8px; }
  .sec-head h2 { font-size: 19px; }
  .slot-card { display: flex; padding: 18px 16px 16px; gap: 14px; }
  .sc-share { align-self: stretch; }
  .preset-rail { overflow: visible; margin: 0; padding: 0; }
  .presets { display: flex; flex-wrap: wrap; white-space: normal; }
  .presets button { padding: 7px 11px; }
  .scroll-hint { display: block; }
  .sc-value { font-size: 32px; }
  .sc-stats { gap: 8px; }
  .stat-num { font-size: 15px; }
  .totals { padding: 14px 16px; }
  .fig { padding: 16px 14px 14px; }
  .insight { font-size: 14px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .auth-hero, .auth-main { padding-left: 22px; padding-right: 22px; }
  .audit-item { grid-template-columns: 1fr auto; }
  .audit-what { grid-column: 1 / -1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  .swatch, .meter-fill, .tip-key { forced-color-adjust: none; }
}

/* ══ 账号管理页：补充 ══════════════════════════════════════════════════ */

.page-admin .main { padding-bottom: 64px; }
.flash { margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; font-weight: 550; font-size: 13.5px; }
.flash.is-ok { background: var(--accent-soft); color: var(--accent); }
.flash.is-err { background: var(--bad-soft); color: var(--bad); }
.page-admin > .main > .pw-reveal { margin: 0 0 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pw-reveal.hidden { display: none; }
.pw-tail { flex: 1 1 auto; color: var(--muted); font-size: 12.5px; }
.pw-close { margin-left: auto; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.admin-users { min-width: 0; }
.admin-users .table-scroll { margin: 0 -22px; }
.admin-users .data-table th:first-child, .admin-users .data-table td:first-child { padding-left: 22px; }
.admin-users .data-table th:last-child, .admin-users .data-table td:last-child { padding-right: 22px; }
.admin-users { margin-bottom: 20px; }
.admin-audit { min-width: 0; }
.btn-del { color: var(--bad); }
.btn-del:hover:not(:disabled) { background: var(--bad-soft); border-color: #efc5bf; color: var(--bad); }
.audit-actor { color: var(--ink); font-weight: 600; }
.audit-target { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.audit-detail { color: var(--muted); }
.form-grid .opt, .auth-form .opt { color: var(--faint); font-weight: 400; font-size: 12px; }

/* ══ 登录 / 设置页：补充 ══════════════════════════════════════════════ */

.auth-hero-slim { padding-bottom: 20px; }
.auth-step { color: var(--topbar-muted); font-size: 12.5px; margin-top: 12px; letter-spacing: 0.04em; }

/* 服务器内置的提示页（链接失效、没有权限） */
.message-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.message-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 18px;
  box-shadow: 0 24px 48px -28px rgba(26, 25, 21, 0.35);
  padding: 30px 28px 24px;
  position: relative;
  overflow: hidden;
}
.message-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--slot-day) 0 37.5%, var(--slot-evening) 37.5% 50%, var(--slot-night) 50% 87.5%, var(--slot-other) 87.5% 100%);
}
.message-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.message-card p { color: var(--ink-2); font-size: 14px; }
.message-card p + p { margin-top: 20px; }
.message-card .btn { background: var(--accent); color: #fff; }
.message-card .btn:hover { background: var(--accent-hover); }

/* 产出倍数条 */
.yield { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--hair); }
.yield-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 10px; }
.yield-title { font-weight: 700; font-size: 13px; }
.yield-sub { color: var(--muted); font-size: 12px; }
.yield-items { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.yield-item { background: var(--canvas); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.yield-top { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.yield-val { font-size: 20px; font-weight: 700; margin-top: 2px; }
.yield-item.is-muted .yield-val, .yield-item.is-muted .yield-top { color: var(--muted); }

/* 今天进行中：还没开始的时段 */
.slot-card.is-pending { background: var(--canvas); box-shadow: none; border-style: dashed; border-color: var(--hair-2); }
.slot-card.is-pending::before { opacity: 0.35; }
.sc-pending { flex: 1; display: grid; align-content: center; justify-items: start; gap: 4px; color: var(--muted); font-size: 13px; padding: 12px 0; min-height: 120px; }
.sc-pending strong { color: var(--ink-2); font-size: 16px; }
.sc-tag-live { background: var(--accent-soft); color: var(--accent); }
.sc-tag + .sc-tag { margin-left: 0; }
.chart-empty { display: grid; gap: 4px; padding: 28px 4px; color: var(--muted); font-size: 13px; }
.chart-empty strong { color: var(--ink-2); font-size: 15px; }
.form-grid .btn-block { margin-top: 16px; }
.admin-users { padding-bottom: 8px; }
.user-table tbody tr:last-child th, .user-table tbody tr:last-child td { border-bottom: 0; }

/* 账号表：手机上改成一张张卡片，操作按钮不用横向滑动 */
@media (max-width: 680px) {
  .admin-users .table-scroll { margin: 0 -22px; overflow: visible; }
  .user-table, .user-table tbody { display: block; width: 100%; }
  .user-table thead { display: none; }
  .user-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--hair);
  }
  .user-table tbody tr:last-child { border-bottom: 0; }
  .user-table th, .user-table td { display: block; border: 0 !important; padding: 0 !important; text-align: left; white-space: normal; background: none !important; }
  .user-table tbody th { flex: 1 1 100%; }
  .user-table .td-last, .user-table .td-created { flex: 1 1 100%; color: var(--muted); font-size: 12.5px; }
  .user-table .td-last::before, .user-table .td-created::before { content: attr(data-label) "："; color: var(--faint); }
  .user-table .td-acts { flex: 1 1 100%; margin-top: 4px; }
  .user-table .acts { flex-wrap: wrap; justify-content: flex-start; }
}
