/* ==========================================================================
   overview.css — Overview 頁面樣式
   規格：reference/assets/overview-Dv_rHoPk.css + index--oEMGL0U.css（原值照抄）、
   docs/design-tokens.md §3（overview 版面）§6（component notes）。
   所有顏色/字級/間距/圓角經 styles/tokens.css variables；字面尺寸（thumb、ring 等）
   係原版 component literal，唔係 token。
   注意：原版 CSS 零 transition — hover/狀態變色係即時跳變，唔好加 transition。
   ========================================================================== */

/* ==========================================================================
   共用 primitives（原版放喺主 bundle，呢頁先用；inventory agent 需要時可共用）
   ========================================================================== */
.card__head {
  display: flex; align-items: center; gap: 12px;
  min-height: 34px; margin-bottom: 16px;
  flex-wrap: wrap; row-gap: 10px;
}
.card__head > div:first-child { flex: 1; min-width: 0; }
.card__sub { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--muted); }

.card--flush { padding: 0; overflow: hidden; }
.card--ink { background: var(--ink-card); color: var(--on-ink); border-color: transparent; }
.card--ink .card__sub, .card--ink .muted { color: var(--ink-dim); }

.tnum { font-variant-numeric: tabular-nums; }

/* delta（升 / 跌指示） */
.delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: var(--fs-xs); font-weight: 700;
}
.delta--up { color: var(--good); }
.delta--down { color: var(--bad); }
.kpi[data-tile] .delta--up { color: color-mix(in srgb, var(--good) 80%, var(--on-tile)); }

/* swatch / stars */
.swatch { background: var(--c, var(--muted)); border-radius: 3px; width: 10px; height: 10px; flex: none; }
.stars { display: inline-flex; gap: 1px; color: var(--amber-fill); }
.stars svg { fill: currentColor; width: 13px; height: 13px; }

/* thumb：placeholder 瓷磚（原版係產品照，呢度用 tokens gradient） */
.thumb {
  display: block; overflow: hidden; flex: none;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--grad-thumb);
}
.thumb--sm { width: 34px; height: 34px; border-radius: 10px; }

/* seg（segmented control）：底 --well / ink 版 --ink-card；
   thumb 面 --surface（ink 版 --side-pill），位置由 JS clip-path FLIP（§5.2） */
.seg {
  position: relative; display: inline-flex; flex: none; width: max-content;
  padding: 4px; background: var(--well); border-radius: 22px;
}
.seg__thumb {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--surface);
  box-shadow: 0 1px 2px #00000014, 0 4px 12px -6px #00000040;
  clip-path: inset(0 100% 0 0);
}
[data-theme="dark"] .seg__thumb { background: var(--raised); }
.seg button {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border: 0; background: none; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
  white-space: nowrap; border-radius: 18px;
}
.seg button[aria-pressed="true"] { color: var(--text); }
.seg--ink { background: var(--ink-card); }
.seg--ink .seg__thumb { background: var(--side-pill); }
.seg--ink button { color: var(--ink-dim); }
.seg--ink button[aria-pressed="true"] { color: var(--on-side-pill); }

/* chart（SVG 折線 / 面積圖共用；hover tooltip 見下面 §chart hover） */
.chart { position: relative; width: 100%; user-select: none; touch-action: pan-y; }
.chart svg { overflow: visible; }
.chart__grid { stroke: var(--line); stroke-width: 1px; }
.chart__tick { fill: var(--muted); font-size: var(--fs-2xs); font-weight: 600; font-family: var(--font); }
/* hover cursor + tip（design-tokens.md §5.6c，原版 charts chunk + CSS 原值照抄；
   出現／消失即時，冇動畫） */
.chart__hover line { stroke: var(--line-2); stroke-dasharray: 3 4; }
.chart__hover circle { stroke: var(--surface); stroke-width: 2.5px; }
.chart__tip {
  pointer-events: none; z-index: 2;
  background: var(--text); color: var(--bg);
  font-size: var(--fs-sm); white-space: nowrap;
  box-shadow: var(--shadow-pop); border-radius: 12px;
  gap: 2px; padding: 8px 12px;
  display: grid; position: absolute; top: -6px;
  transform: translate(-50%, -100%);
}
.chart__tip small { opacity: .7; font-size: var(--fs-2xs); font-weight: 600; }
.chart__tip span { align-items: center; gap: 6px; display: flex; }
.chart__tip i { border-radius: 50%; width: 8px; height: 8px; }
.chart__tip b { font-weight: 700; }

/* ring（courier pickup 圓環進度） */
.ring { position: relative; flex: none; }
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }

/* live 點（§5.8：原版冇 pulse 動畫） */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 600; color: var(--good); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* stackbar + legend
   2026-10-30 量度修正（見 build-log）：原版 PNG（1920w 原圖逐像素）條 bar 段與段之間
   係直邊相接 + 一條 3px 幼縫（同原 bundle gap:3px 一致），圓角只出現喺成條 bar 兩端
   （~4px）。之前一段一個 border-radius:4px 會令接縫中段出現 8–11px「沙漏」空隙，
   就係驗收見到嘅「明顯空隙」。所以圓角改為只落 first / last 段嘅外端。 */
.stackbar { display: flex; gap: 3px; width: 100%; }
.stackbar i { display: block; height: 100%; min-width: 4px; transform-origin: 0 50%; }
.stackbar i:first-child { border-radius: 4px 0 0 4px; }
.stackbar i:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--c); }

/* switch（44×26，on = --primary；§5.8 狀態即時跳變，thumb 無過渡） */
.switch {
  position: relative; flex: none; width: 44px; height: 26px;
  padding: 0; border: 0; background: var(--line-2); border-radius: 13px;
  cursor: pointer;
}
.switch i {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px #00000040;
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] i { transform: translate(18px, 0); }
[data-theme="dark"] .switch[aria-checked="true"] i { background: var(--on-primary); }

/* avatar 尺寸（原版 --size 26 / 40） */
.avatar--sm { width: 26px; height: 26px; font-size: 9px; }
.tt__stack .avatar { width: 40px; height: 40px; font-size: 14px; }

/* meter：支援 --c 分類色（原版 .meter i background var(--c, --primary)） */
.meter > i { background: var(--c, var(--primary)); }

/* 小圓鈕（shelf arrows / 卡 head 外連）：34px + 16px icon */
.ibtn--sm { width: 34px; height: 34px; }
.ibtn--sm .ico { width: 16px; height: 16px; }

/* Pack orders 徽章（原版 overview chunk 覆寫） */
.btn__count {
  display: grid; place-items: center;
  min-width: 22px; height: 20px; padding: 0 6px;
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  border-radius: 10px;
  font-size: var(--fs-2xs); font-weight: 700;
}

/* ==========================================================================
   版面 grid：12 欄 + named areas（照原版，含全部斷點）
   ========================================================================== */
.ov__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-areas:
    "k k k k k k k k k k k k"
    "h h h h h h h h s s s s"
    "r r r r r r r r l l l l"
    "t t t t t f f f f m m m";
  gap: var(--gap);
}
.ov__kpis { grid-area: k; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.ov__hero { grid-area: h; min-width: 0; }
.ov__side { grid-area: s; display: grid; gap: var(--gap); align-content: start; min-width: 0; }
.ov__rev { grid-area: r; min-width: 0; }
.ov__low { grid-area: l; min-width: 0; }
.ov__today { grid-area: t; min-width: 0; }
.ov__feed { grid-area: f; min-width: 0; }
.ov__team { grid-area: m; min-width: 0; }
.ov__grid > div > .card { height: 100%; }
.ov__side > .card { height: auto; }

/* ==========================================================================
   KPI 瓷磚補充（sparkline 定位 + foot 排版）
   ========================================================================== */
.kpi__label { display: flex; align-items: center; gap: 8px; }
.kpi__foot { display: flex; align-items: center; gap: 8px; }
.kpi__spark { position: absolute; bottom: 16px; right: 16px; }

/* ==========================================================================
   The shelf（大卡）
   ========================================================================== */
.shelf { display: flex; flex-direction: column; }
.shelf__head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px 20px;
  padding: 18px 20px 16px;
}
.shelf__seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.shelf__seg::-webkit-scrollbar { display: none; }
.shelf__body {
  flex: 1;
  display: grid; grid-template-columns: minmax(240px, 40%) minmax(0, 1fr);
  gap: 22px; padding: 0 20px 20px;
}
.shelf__stage {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 520px; border-radius: 18px;
  background: var(--surface-2);
}
/* placeholder「照片」：tokens 色混合嘅 gradient（原版係產品照，唔搬素材） */
.shelf__img {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.shelf__img.ph-0 {
  background:
    radial-gradient(120% 90% at 70% 30%, color-mix(in srgb, var(--c-serums) 30%, var(--surface-2)) 0%, transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--side) 55%, var(--surface-2)) 0%, color-mix(in srgb, var(--side) 25%, var(--surface-2)) 48%, color-mix(in srgb, var(--side-pill) 55%, var(--surface-2)) 100%);
}
.shelf__img.ph-1 {
  background:
    radial-gradient(120% 90% at 30% 25%, color-mix(in srgb, var(--c-oils) 35%, var(--surface-2)) 0%, transparent 60%),
    linear-gradient(200deg, color-mix(in srgb, var(--side) 50%, var(--surface-2)) 0%, color-mix(in srgb, var(--c-oils) 22%, var(--surface-2)) 55%, color-mix(in srgb, var(--tile-apricot) 70%, var(--surface-2)) 100%);
}
.shelf__img.ph-2 {
  background:
    radial-gradient(120% 90% at 65% 70%, color-mix(in srgb, var(--c-balms) 35%, var(--surface-2)) 0%, transparent 60%),
    linear-gradient(145deg, color-mix(in srgb, var(--side) 45%, var(--surface-2)) 0%, color-mix(in srgb, var(--c-balms) 20%, var(--surface-2)) 52%, color-mix(in srgb, var(--tile-clay) 70%, var(--surface-2)) 100%);
}
/* 產品切換：新圖 slide-in（§5.6 shelf 圖 B：y 14 / scale 1.1 / 0 → 0/1/1，0.85s power4.out）；
   舊圖同步下沉消失（§5.6 shelf 圖 B 舊圖：yPercent −6 / scale .94 / opacity 0，0.5s power2.in） */
@keyframes shelf-img-in {
  from { opacity: 0; transform: translateY(14px) scale(1.1); }
  to { opacity: 1; transform: none; }
}
.shelf__img.is-swap { animation: shelf-img-in .85s var(--ease-power4-out) both; }
@keyframes shelf-img-out {
  to { opacity: 0; transform: translateY(-6px) scale(.94); }
}
.shelf__img--out { animation: shelf-img-out .5s var(--ease-power2-in) forwards; }
.shelf__tag {
  position: absolute; top: 14px; left: 14px; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: var(--ink-card); color: var(--on-ink);
  border-radius: 16px; font-size: var(--fs-sm); font-weight: 600;
}
.shelf__arrows { position: absolute; bottom: 14px; right: 14px; z-index: 3; display: flex; gap: 8px; }
.shelf__arrows .ibtn { background: var(--surface); }

.shelf__info { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.shelf__title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.shelf__name { margin: 0; font-size: var(--fs-4xl); font-weight: 600; line-height: 1.1; letter-spacing: -.025em; }
/* 逐字結構（own-enter 用；同 .head__title 樣式）：
   .word 做遮罩（overflow hidden），.ch 係逐字 span，own-enter 時逐字升起＋6deg 轉正 */
.shelf__name .word {
  display: inline-block; overflow: hidden;
  padding-bottom: .14em; margin-bottom: -.14em;
  vertical-align: top;
}
.shelf__name .ch { display: inline-block; will-change: transform; }
.shelf__meta { margin: 6px 0 0; font-size: var(--fs-sm); }
.shelf__price { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }

.shelf__facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.shelf__facts > div {
  display: grid; align-content: start; gap: 4px; min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
}
.shelf__facts small { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.shelf__facts b { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.01em; }
.shelf__facts .meter { margin-top: 4px; }
.shelf__facts > div > span:not(.meter) { font-size: var(--fs-xs); }
.shelf__chart { margin: 0 -4px; }

.shelf__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.shelf__row button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 12px 6px 6px;
  background: none; border: 1px solid var(--line); border-radius: 14px;
  font-size: var(--fs-sm); text-align: left; cursor: pointer;
}
.shelf__row button:hover { background: var(--surface-2); }
.shelf__row button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.shelf__row button[aria-pressed="true"] .muted { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.shelf__rowname { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }

.shelf__foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.shelf__feature { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-md); font-weight: 600; cursor: pointer; }

/* ==========================================================================
   Shelf own-enter 進場編排（design-tokens.md §5.6a；由 anim.js own-enter 分支 +
   scripts/views/overview.js shelfOwnEnter 掛 class + inline delay）
   ========================================================================== */
@keyframes enter-own {          /* 容器閃入：opacity 0 / y40 / scale .98 → 1，1s power3.out，delay .2s（anim.js set） */
  from { opacity: 0; transform: translateY(40px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.is-enter-own { animation: enter-own 1s var(--ease-power3-out) both; }

@keyframes own-char {           /* 產品名逐字：yPercent 115 / rotate 6deg → 0（遮罩升起＋轉正） */
  from { transform: translateY(115%) rotate(6deg); }
  to { transform: none; }
}
.is-own-char { animation: own-char .85s var(--ease-power4-out) both; }

@keyframes own-so {             /* facts / rows / foot / tag / arrows：opacity 0 + 位移 → 1/0 */
  from { opacity: 0; transform: translate(var(--so-x, 0px), var(--so-y, 12px)); }
  to { opacity: 1; transform: none; }
}
.is-own-so { animation: own-so .55s var(--ease-power3-out) both; }
/* collection 切換 rows 由右飛入：--so-x:18px --so-y:0px（overview.js set inline） */

/* ==========================================================================
   Next courier pickup（card--ink）
   ========================================================================== */
.pickup .live { color: var(--side-pill); }
.pickup__body { display: flex; align-items: center; gap: 22px; }
.pickup__ring { font-size: var(--fs-3xl); font-weight: 600; line-height: 1; }
.pickup .ring__label small { font-size: var(--fs-2xs); }
.pickup__count { display: grid; gap: 2px; }
.pickup__count b { font-size: var(--fs-display); font-weight: 600; line-height: 1.05; letter-spacing: -.025em; }
.pickup__actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.pickup__btn { background: var(--side-pill); color: var(--on-side-pill); border-color: transparent; }
.pickup__btn:hover { background: color-mix(in srgb, var(--side-pill) 88%, #fff); }
.pickup__link { color: var(--side-pill); display: inline-flex; align-items: center; gap: 5px; }

/* ==========================================================================
   In the lab（cure）
   ========================================================================== */
.cure__list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.cure__row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 76px;
  align-items: center; gap: 12px;
  margin: 0 -8px; padding: 8px; border-radius: 12px;
}
.cure__row:hover { background: var(--surface-2); }
.cure__text { display: grid; min-width: 0; }
.cure__text b { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.cure__text small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ==========================================================================
   Revenue
   ========================================================================== */
.revenue__figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin: -4px 0 14px; }
.revenue__figure > b { font-size: var(--fs-display); font-weight: 600; line-height: 1; letter-spacing: -.025em; }
.revenue__figure .muted { font-size: var(--fs-sm); }
.revenue__split { display: grid; gap: 10px; margin-top: 18px; }
.revenue__split .legend b { color: var(--text); font-weight: 600; }

/* ==========================================================================
   Running low
   ========================================================================== */
.low__list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.low__row { display: flex; align-items: center; gap: 12px; }
.low__text { flex: 1; display: grid; gap: 3px; min-width: 0; }
.low__text b { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.low__text .meter { margin-top: 3px; }

/* ==========================================================================
   Today's orders
   ========================================================================== */
.today__list { display: grid; margin: 0 -10px; padding: 0; list-style: none; }
.today__row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto 84px;
  align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 12px;
}
.today__row:hover { background: var(--surface-2); }
.today__who { display: grid; min-width: 0; }
.today__who b { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.today__who small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.today__sum { font-weight: 600; text-align: right; }

/* ==========================================================================
   Studio feed
   ========================================================================== */
.feed__list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.feed__row { display: flex; align-items: flex-start; gap: 10px; }
.feed__row p { margin: 0; font-size: var(--fs-md); line-height: 1.4; }
.feed__row b { font-weight: 600; }
.feed__row small { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.feed__row small .ico { width: 13px; height: 13px; }

/* ==========================================================================
   In today（team-today）
   ========================================================================== */
.tt__stack { margin-bottom: 16px; }
.tt__more { margin-left: -9px; background: var(--well); color: var(--text); font-size: var(--fs-xs); box-shadow: 0 0 0 2px var(--surface); }
.tt__places { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tt__places li {
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2); border-radius: 12px;
  font-size: var(--fs-md); font-weight: 600;
}
.tt__away { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: var(--fs-sm); }

/* ==========================================================================
   Responsive（照原版斷點）
   ========================================================================== */
@media (max-width: 1279px) {
  .ov__grid {
    grid-template-areas:
      "k k k k k k k k k k k k"
      "h h h h h h h h h h h h"
      "s s s s s s s s s s s s"
      "r r r r r r r l l l l l"
      "t t t t t t f f f f f f"
      "m m m m m m m m m m m m";
  }
  .ov__side { grid-template-columns: 1fr 1fr; }
  .tt__places { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 1100px) {
  .ov__kpis, .shelf__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 999px) {
  .ov__grid {
    grid-template-areas:
      "k k k k k k k k k k k k"
      "h h h h h h h h h h h h"
      "s s s s s s s s s s s s"
      "r r r r r r r r r r r r"
      "l l l l l l l l l l l l"
      "t t t t t t t t t t t t"
      "f f f f f f m m m m m m";
  }
  .shelf__stage { min-height: 460px; }
}

@media (max-width: 760px) {
  .ov__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "k" "h" "s" "r" "l" "t" "f" "m";
  }
  .ov__side { grid-template-columns: minmax(0, 1fr); }
  .shelf__head { padding: 16px 16px 12px; }
  .shelf__body { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 0 12px 14px; }
  .shelf__stage { aspect-ratio: 4 / 3.4; min-height: 0; }
  .shelf__name { font-size: var(--fs-3xl); }
  .shelf__price { font-size: var(--fs-xl); }
  .shelf__list { grid-template-columns: minmax(0, 1fr); }
  .pickup__count b { font-size: var(--fs-4xl); }
  .today__row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .today__row .pill { display: none; }
  .revenue__figure > b { font-size: var(--fs-4xl); }
}

@media (max-width: 420px) {
  .ov__kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__spark { display: none; }
}

/* ==========================================================================
   Reduced motion：切換 / 入場 animation 停用（meter 進場由 main.css 一併處理）
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .shelf__img.is-swap, .shelf__img--out,
  .is-enter-own, .is-own-char, .is-own-so { animation: none; }
}

/* 觸控裝置（原版 @media pointer:coarse 有關部分） */
@media (pointer: coarse) {
  .btn--sm { min-height: 40px; }
  .ibtn--sm { width: 44px; height: 44px; }
  .seg button { height: 40px; }
}
