/* ===========================================================
   门店经营看板 · 移动优先样式
   设计目标：3 秒内看清「区域今天好不好、哪家店有问题」
   =========================================================== */

:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --ink: #17130f;
  --ink-2: #6e635a;
  --ink-3: #a79c91;
  --line: #ece5dd;
  --line-soft: #f4eee7;

  --brand: #b45309;
  --brand-ink: #8a3f06;
  --brand-tint: #fdf1e4;

  --up: #d92d20;      /* 涨 = 红 */
  --down: #067a55;    /* 跌 = 绿 */
  --warn: #b54708;
  --warn-tint: #fff6ea;

  --hero-1: #241a12;
  --hero-2: #3a2717;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow: 0 1px 2px rgba(23, 19, 15, .04), 0 10px 30px -18px rgba(23, 19, 15, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 14px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.region {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-tint);
  border-radius: 6px;
  letter-spacing: 0;
}

.datebar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  color: var(--ink);
  font-size: 12.5px;
}

.refresh {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: transform .15s ease, background .15s;
}
.refresh:active { transform: scale(.94); background: var(--line-soft); }
.refresh svg { width: 17px; height: 17px; }
.refresh.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 首屏核心卡 ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 20px 20px 16px;
  color: #fdf8f2;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(226, 150, 74, .34) 0%, rgba(226, 150, 74, 0) 55%),
    linear-gradient(160deg, var(--hero-2) 0%, var(--hero-1) 62%);
  box-shadow: 0 14px 34px -20px rgba(36, 26, 18, .8);
}

.hero-label {
  font-size: 12.5px;
  color: rgba(253, 248, 242, .62);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-value {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  letter-spacing: -.02em;
}
.hero-value .cur { font-size: 17px; font-weight: 600; opacity: .72; }
.hero-value .val { font-size: 38px; font-weight: 760; line-height: 1.05; }
.hero-value .dec { font-size: 19px; font-weight: 700; opacity: .82; }

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

.delta {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .1);
  color: rgba(253, 248, 242, .92);
}
.delta b { font-size: 14px; font-weight: 750; }
.delta .k { color: rgba(253, 248, 242, .55); font-weight: 500; }
.hero .delta.up b { color: #ff8f7f; }
.hero .delta.down b { color: #55d6a7; }
.hero .delta.flat b { color: rgba(253, 248, 242, .8); }

/* 迷你走势 */
.spark { margin: 14px -4px 0; }
.spark svg { display: block; width: 100%; height: 54px; overflow: visible; }

/* 目标进度 */
.goal {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.goal-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(253, 248, 242, .58);
  margin-bottom: 7px;
}
.goal-top b { color: #fdf8f2; font-weight: 650; }
.goal-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f0b06a, #e08a3c);
}

/* ---------- KPI 网格 ---------- */
.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 13px 11px;
  box-shadow: var(--shadow);
}
.kpi-k {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-v {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -.015em;
  display: flex;
  align-items: baseline;
  gap: 0;
}
.kpi-v small { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-left: 1px; }
.kpi-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.chip-up { color: var(--up); font-weight: 650; }
.chip-down { color: var(--down); font-weight: 650; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 16px 14px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-note { font-size: 11.5px; color: var(--ink-3); }
.card-title .tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-tint);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------- 8 天走势 ---------- */
.trend {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 132px;
  padding-top: 18px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  height: 100%;
  cursor: pointer;
}
.trend-bar-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.trend-bar {
  width: 100%;
  border-radius: 6px 6px 3px 3px;
  background: #eadfd2;
  min-height: 4px;
  transition: background .18s ease, transform .18s ease;
  position: relative;
}
.trend-col.is-active .trend-bar { background: linear-gradient(180deg, #d98a3a, #b45309); }
.trend-col:active .trend-bar { transform: scaleY(.98); }
.trend-x { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.trend-col.is-active .trend-x { color: var(--brand-ink); font-weight: 700; }

.trend-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.trend-readout .big { font-size: 19px; font-weight: 720; letter-spacing: -.01em; }
.trend-readout .small { font-size: 12px; color: var(--ink-3); }

/* ---------- 品类结构 ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 66px 1fr 96px; align-items: center; gap: 10px; }
.bar-name { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #eab171, #c9762b);
  transform-origin: left;
  animation: grow .6s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes grow { from { transform: scaleX(0); } }
.bar-val { text-align: right; font-size: 12.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.bar-val em { font-style: normal; font-size: 11px; color: var(--ink-3); font-weight: 500; margin-left: 6px; }

/* ---------- 时段 ---------- */
.periods { display: flex; align-items: flex-end; gap: 8px; height: 118px; }
.period { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.period-bar {
  width: 100%;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #f0c796, #d4904a);
  min-height: 4px;
  animation: growY .6s cubic-bezier(.2, .8, .2, 1) both;
  transform-origin: bottom;
}
.period.is-peak .period-bar { background: linear-gradient(180deg, #d98a3a, #a44b06); }
@keyframes growY { from { transform: scaleY(0); } }
.period-l { font-size: 10.5px; color: var(--ink-3); }
.period-p { font-size: 10.5px; font-weight: 650; color: var(--ink-2); }

/* ---------- 门店排行 ---------- */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--line-soft);
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.seg {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-family: inherit;
  cursor: pointer;
  transition: background .16s, color .16s, box-shadow .16s;
}
.seg.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(23, 19, 15, .1);
}

.stores { display: flex; flex-direction: column; }
.store {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.store:last-child { border-bottom: 0; }

.rank {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rank.top { color: var(--brand); }

.store-main { min-width: 0; }
.store-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.store-flag {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 650;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--warn-tint);
  color: var(--warn);
}
.store-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.store-bar { height: 4px; background: var(--line-soft); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.store-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: #dfa163;
  animation: grow .55s cubic-bezier(.2, .8, .2, 1) both;
}

.store-val { text-align: right; }
.store-amount { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.store-delta { font-size: 11.5px; font-weight: 650; margin-top: 2px; }

.more {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.more:active { background: var(--line-soft); }

/* ---------- 重点关注 ---------- */
.insights { display: flex; flex-direction: column; gap: 8px; }
.insight {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  background: var(--warn-tint);
  border: 1px solid #f6e3c8;
}
.insight.good { background: #eefaf3; border-color: #d3efe2; }
.insight-ico {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: #fff; color: var(--warn);
  font-size: 11px; font-weight: 800;
  border: 1px solid #f3ddbe;
}
.insight.good .insight-ico { color: var(--down); border-color: #cdeadd; }
.insight-t { font-size: 12.5px; font-weight: 650; line-height: 1.4; }
.insight-d { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }

/* ---------- 页脚 ---------- */
.foot {
  margin-top: 18px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.7;
}

/* ---------- 骨架 ---------- */
.boot {
  padding: 40vh 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ---------- 桌面 / 平板 ---------- */
@media (min-width: 900px) {
  .app {
    max-width: 1020px;
    padding: 8px 24px 40px;
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "left right";
    gap: 0 20px;
    align-items: start;
  }
  .topbar { grid-area: top; padding: 20px 0 16px; }
  .col-left { grid-area: left; position: sticky; top: 16px; }
  .col-right { grid-area: right; }
  .hero-value .val { font-size: 44px; }
  .card { margin-top: 14px; }
  .col-right > .card:first-child { margin-top: 12px; }
  .trend { height: 160px; }
}

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

/* ---------- 异常提示（未登录 / 无权限 / 取数失败） ---------- */
.notice {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 32px 72px;
  text-align: center;
}
.notice-mark {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand);
  margin-bottom: 18px;
}
.notice-mark svg { width: 26px; height: 26px; }
.notice-title {
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -.01em;
  color: var(--ink);
  margin-bottom: 8px;
}
.notice-sub {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2);
  max-width: 300px;
}

/* ---------- 区域切换 ---------- */
.region-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.rs {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1;
  padding: 7px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.rs:active { transform: scale(.97); }
.rs.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}
.rs-tag {
  font-size: 11px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 99px;
  background: var(--brand-tint);
  color: var(--brand-ink);
  letter-spacing: .02em;
}

.foot-demo { color: var(--brand); }

/* ---------- 提示页附加信息 ---------- */
.notice-meta {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
  word-break: break-all;
  max-width: 300px;
}
.notice-btn {
  margin-top: 18px;
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}

/* ---------- 诊断面板 ---------- */
.diag-mask {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(23, 19, 15, .5);
  display: flex;
  align-items: flex-end;
  animation: fadeIn .18s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.diag {
  width: 100%;
  max-height: 82vh;
  overflow: auto;
  background: #1b1510;
  color: #f6efe7;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.diag-head button {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: transparent;
  color: #f6efe7;
}
.diag pre {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  color: #d8cbbd;
}
.diag-foot {
  margin-top: 12px;
  font-size: 10.5px;
  color: #8c7f72;
  word-break: break-all;
}
