/* 米樂家營運戰情室 — Warm operations dashboard */

:root {
  /* Warm palette */
  --bg: #FAF6EE;
  --bg-paper: #FFFFFF;
  --bg-dark: #261810;
  --warm-1: #F5E8D0;
  --warm-2: #EAD9B5;
  --warm-3: #D4B57C;
  --brand: #D97A3B;
  --brand-dark: #B85F26;
  --gold: #C9A961;
  --ink: #261810;
  --ink-soft: #6E5A48;
  --ink-mute: #A89580;
  --line: #E4D8C2;
  --good: #6B8E4E;
  --good-soft: #E8EEDA;
  --alert: #C44A36;
  --alert-soft: #F8DDD5;
  --warn: #D89A2C;
  --warn-soft: #F7E9C8;
  --info: #4F6F84;
  --info-soft: #DDE6EC;

  /* Type scale (1920×1080) */
  --type-hero: 156px;
  --type-display: 110px;
  --type-title: 60px;
  --type-section: 44px;
  --type-subtitle: 36px;
  --type-body: 30px;
  --type-data: 26px;
  --type-small: 24px;

  /* Spacing */
  --pad-x: 72px;
  --pad-top: 56px;
  --pad-bottom: 56px;
  --gap-title: 32px;
  --gap-item: 20px;
  --gap-tight: 12px;

  --radius: 18px;
  --radius-sm: 10px;
  --radius-lg: 28px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, sans-serif;
  font-feature-settings: "tnum", "ss01";
  -webkit-font-smoothing: antialiased;
}

deck-stage { background: var(--bg); }
deck-stage section {
  background: var(--bg);
  font-family: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Common slide head bar ===== */
.slide-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 36px;
  padding: 28px var(--pad-x);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.slide-head .brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: "Noto Serif TC", serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.slide-head .brand-mark .logo-img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  display: block;
}
.slide-head .brand-mark .label {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.slide-head .brand-mark .label .zh {
  font-family: "Noto Serif TC", serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.slide-head .brand-mark .label .en {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-top: 2px;
}
section.dark-slide .slide-head .brand-mark .logo-img { filter: brightness(1.05); }
section.dark-slide .slide-head .brand-mark .label .zh { color: var(--warm-1); }
section.dark-slide .slide-head .brand-mark .label .en { color: rgba(245,232,208,.5); }
.slide-head .section-name {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.slide-head .meta {
  font-size: 22px;
  color: var(--ink-soft);
  display: flex;
  gap: 18px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.slide-head .live-pip {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(107,142,78,0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* slide body */
.slide-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 40px var(--pad-x) 48px;
  gap: 24px;
  min-height: 0;
}
.slide-title {
  font-family: "Noto Serif TC", serif;
  font-size: var(--type-title);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.1;
  color: var(--ink);
}
.slide-title .sub {
  display: inline-block;
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 500;
  font-size: var(--type-subtitle);
  color: var(--ink-soft);
  margin-left: 24px;
  letter-spacing: 0.06em;
}

/* ===== Reusable card ===== */
.card {
  background: var(--bg-paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card .card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.card .card-title {
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 700;
  font-size: 30px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.card .card-sub {
  font-size: 22px;
  color: var(--ink-soft);
}

/* ===== KPI tile ===== */
.kpi {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.kpi.dark {
  background: var(--bg-dark);
  color: var(--warm-1);
  border-color: transparent;
}
.kpi.brand { background: var(--brand); color: #fff; border-color: transparent; }
.kpi.gold { background: var(--gold); color: var(--ink); border-color: transparent; }
.kpi .label {
  font-size: 24px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  font-weight: 500;
}
.kpi.dark .label, .kpi.brand .label { color: rgba(255,255,255,0.85); }
.kpi.gold .label { color: rgba(38,24,16,0.78); }
.kpi .value {
  font-family: "Noto Serif TC", serif;
  font-size: var(--type-display);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .value .unit {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 32px;
  font-weight: 600;
  margin-left: 8px;
  opacity: 0.7;
}
.kpi .delta {
  font-size: 24px;
  margin-top: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--alert); }
.kpi.dark .delta.up { color: #A8C77F; }
.kpi.dark .delta.down { color: #EE9783; }

/* ===== Progress bar ===== */
.bar {
  height: 14px;
  background: var(--warm-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar > .fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}
.bar.thin { height: 10px; }
.bar.tall { height: 18px; }
.bar > .fill.gold { background: var(--gold); }
.bar > .fill.good { background: var(--good); }
.bar > .fill.alert { background: var(--alert); }
.bar > .fill.warn { background: var(--warn); }

/* ===== Table ===== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-data);
  font-variant-numeric: tabular-nums;
}
.tbl th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
  font-size: 22px;
  letter-spacing: 0.04em;
}
.tbl td {
  padding: 16px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.tbl.compact th { padding: 7px 12px; font-size: 20px; }
.tbl.compact td { padding: 6px 12px; font-size: 21px; line-height: 1.25; }
.tbl.compact td.num { font-size: 22px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.num { text-align: right; font-weight: 600; }
.tbl td.muted { color: var(--ink-soft); }

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 600;
  background: var(--warm-1);
  color: var(--ink);
  letter-spacing: 0.04em;
}
.badge.alert { background: var(--alert-soft); color: var(--alert); }
.badge.warn { background: var(--warn-soft); color: #8C6610; }
.badge.good { background: var(--good-soft); color: #4D6B33; }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: rgba(217,122,59,0.16); color: var(--brand-dark); }
.badge.dark { background: var(--bg-dark); color: var(--warm-1); }

/* ===== Rank pill ===== */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--warm-1);
  color: var(--ink);
  font-family: "Noto Serif TC", serif;
  font-weight: 800;
  font-size: 32px;
  flex-shrink: 0;
}
.rank.r1 { background: var(--gold); color: var(--ink); }
.rank.r2 { background: var(--warm-3); color: var(--ink); }
.rank.r3 { background: var(--brand); color: #fff; }

/* ===== Watermark ===== */
.watermark {
  position: absolute;
  right: var(--pad-x);
  bottom: 24px;
  font-size: 18px;
  color: var(--ink-mute);
  font-family: "Inter", "Noto Sans TC", sans-serif;
  letter-spacing: 0.12em;
  pointer-events: none;
}

/* ===== Sample data marker ===== */
.sample-tag {
  font-size: 18px;
  color: var(--ink-mute);
  font-family: "Inter", "Noto Sans TC", sans-serif;
  letter-spacing: 0.06em;
}

/* ===== Auto-rotate progress bar (top of viewport) ===== */
#rotate-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0%;
  background: var(--brand);
  z-index: 9999;
  transition: width 100ms linear;
  pointer-events: none;
}
#rotate-progress.paused { background: var(--ink-mute); }

/* ===== Fullscreen button ===== */
#fs-btn {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 9998;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(38,24,16,.72);
  color: var(--warm-1);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 200ms, background 200ms;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
#fs-btn:hover { opacity: 1; background: rgba(38,24,16,.92); }
:fullscreen #fs-btn { opacity: 0.2; }
:fullscreen #fs-btn:hover { opacity: 1; }

/* ===== Data import status badge (on dashboard slides) ===== */
.data-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.data-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.data-status-sample {
  background: var(--warm-1);
  color: var(--ink-soft);
}
.data-status-sample .dot {
  background: var(--ink-mute);
}
.data-status-live {
  background: var(--good-soft);
  color: #3F5D2A;
}
.data-status-live .dot {
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(107,142,78,.25);
}
.data-status-live .meta {
  opacity: 0.75;
  font-weight: 500;
  font-size: 16px;
}
section.dark-slide .data-status-sample {
  background: rgba(255,255,255,.08);
  color: rgba(245,232,208,.7);
}
section.dark-slide .data-status-sample .dot {
  background: rgba(245,232,208,.4);
}

/* KPI live indicator: shows green dot when number is from imported data */
[data-kpi-live]::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--good);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: super;
  box-shadow: 0 0 0 2px rgba(107,142,78,.25);
}
section.dark-slide [data-kpi-live]::after {
  background: #A8C77F;
  box-shadow: 0 0 0 2px rgba(168,199,127,.3);
}

/* AI summary banner */
[data-import-summary] {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(217,122,59,.1) 0%, rgba(217,122,59,.02) 100%);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  font-size: 19px;
  color: var(--ink);
  line-height: 1.5;
}
[data-import-summary] .summary-icon {
  font-size: 22px;
}
[data-import-summary] .summary-text b {
  color: var(--brand-dark);
  margin-right: 4px;
}

#import-btn {
  position: fixed;
  left: 70px;
  bottom: 14px;
  z-index: 9998;
  height: 46px;
  padding: 0 16px 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(217,122,59,.35);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: "Noto Sans TC", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(217,122,59,.32);
  transition: all 180ms;
}
#import-btn:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(217,122,59,.45);
}
#import-btn .lbl { line-height: 1; }
:fullscreen #import-btn { opacity: 0.35; }
:fullscreen #import-btn:hover { opacity: 1; }

/* Fullscreen hint toast */
#fs-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  background: rgba(38,24,16,.96);
  color: var(--warm-1);
  padding: 28px 36px;
  border-radius: 14px;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  max-width: 480px;
  cursor: pointer;
  animation: fsHintIn 0.3s ease-out;
}
@keyframes fsHintIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== Tweaks panel ===== */
.tweaks-row { display: flex; align-items: center; gap: 12px; }

/* ===== Utility ===== */
.row { display: flex; gap: 24px; }
.col { display: flex; flex-direction: column; gap: 16px; }
.grow { flex: 1; min-width: 0; min-height: 0; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; justify-content: space-between; align-items: center; }
.mono { font-family: "JetBrains Mono", "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.tab-num { font-variant-numeric: tabular-nums; }

.dot-good { color: var(--good); }
.dot-alert { color: var(--alert); }
.dot-warn { color: var(--warn); }

.section-strip {
  background: var(--bg-dark);
  color: var(--warm-1);
  padding: 16px 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.up::before { content: "▲ "; color: var(--alert); }
.down::before { content: "▼ "; color: var(--good); }
/* (For 漲跌, in 食材業漲價 = bad for buyers, so use red for up) */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  background: var(--warm-1);
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
}
.chip.solid { background: var(--bg-dark); color: var(--warm-1); }

/* Slides with dark backgrounds */
section.dark-slide { background: var(--bg-dark); color: var(--warm-1); }
section.dark-slide .slide-head { border-bottom-color: rgba(245,232,208,0.15); }
section.dark-slide .slide-head .brand-mark,
section.dark-slide .slide-head .section-name { color: var(--warm-1); }
section.dark-slide .slide-head .meta { color: rgba(245,232,208,0.7); }
section.dark-slide .slide-title { color: var(--warm-1); }
section.dark-slide .slide-title .sub { color: rgba(245,232,208,0.7); }
section.dark-slide .card { background: rgba(255,255,255,0.04); border-color: rgba(245,232,208,0.12); color: var(--warm-1); }
section.dark-slide .card .card-title { color: var(--warm-1); }
section.dark-slide .card .card-sub { color: rgba(245,232,208,0.65); }
section.dark-slide .tbl th { color: rgba(245,232,208,0.6); border-color: rgba(245,232,208,0.18); }
section.dark-slide .tbl td { color: var(--warm-1); border-color: rgba(245,232,208,0.1); }
section.dark-slide .watermark { color: rgba(245,232,208,0.4); }
