/* ================================================================
   小鎮飲料戰 Little Town — 樣式
   ----------------------------------------------------------------
   設計原則：
   1. 可投影 —— 帶領人控台的字級刻意放大，後排也看得到
   2. 手機可用 —— 學員可能用手機提交，760px 以下全部改單欄
   3. 五組各有代表色 —— 色碼與 web_server.py 的 TEAM_PRESETS 對齊
   4. 零外部資源 —— 不引入任何字型 CDN，只用系統既有的中文字型
   ================================================================ */

:root {
  color-scheme: light;

  /* 基本色調：溫暖的紙感，長時間盯著不刺眼 */
  --ink: #23211c;
  --ink-soft: #6a6559;
  --ink-faint: #97917f;
  --paper: #f4f1ea;
  --paper-deep: #e8e3d6;
  --card: #fdfcf8;
  --line: #d8d1c0;
  --line-soft: #e8e2d4;

  /* 語意色 */
  --profit: #2f7355;      /* 賺錢：綠 */
  --loss: #b8412f;        /* 虧錢：紅 */
  --warn: #a3691a;        /* 警告：琥珀 */
  --accent: #1f6f7a;      /* 主要動作 */
  --accent-dark: #14525b;

  /* 五組代表色（與伺服器 TEAM_PRESETS 一致） */
  --t1: #b8703a;
  --t2: #4a7c4e;
  --t3: #7b5aa6;
  --t4: #c0453c;
  --t5: #2f7d92;

  --radius: 10px;
  --shadow: 0 10px 30px rgba(53, 46, 31, 0.09);
  --shadow-lift: 0 16px 44px rgba(53, 46, 31, 0.16);

  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC",
    system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

p {
  margin: 0 0 12px;
  line-height: 1.75;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--ink-soft);
}

.faint {
  color: var(--ink-faint);
}

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

/* ---------------------------------------------------------------- 通用元件 */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

.wrap-wide {
  max-width: 1500px;
}

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

.card + .card {
  margin-top: 18px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2 {
  font-size: 1.18rem;
}

.card-head .hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.btn {
  padding: 11px 20px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(31, 111, 122, 0.09);
  color: var(--accent-dark);
}

.btn-quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-soft);
}

.btn-quiet:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--paper-deep);
  color: var(--ink);
}

.btn-danger {
  border-color: var(--loss);
  background: transparent;
  color: var(--loss);
}

.btn-danger:hover:not(:disabled) {
  background: var(--loss);
  color: #fff;
}

.btn-big {
  padding: 16px 34px;
  border-radius: 10px;
  font-size: 1.1rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-ok {
  background: rgba(47, 115, 85, 0.14);
  color: var(--profit);
}

.pill-wait {
  background: rgba(163, 105, 26, 0.15);
  color: var(--warn);
}

.pill-bad {
  background: rgba(184, 65, 47, 0.13);
  color: var(--loss);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 122, 0.14);
  outline: none;
}

input.invalid,
textarea.invalid {
  border-color: var(--loss);
  background: #fdf6f5;
}

textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.7;
}

.field {
  margin-bottom: 18px;
}

.field-note {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.field-note.over {
  color: var(--loss);
  font-weight: 600;
}

.error-text {
  margin-top: 6px;
  color: var(--loss);
  font-size: 0.83rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------- 提示訊息 */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  max-width: min(440px, calc(100vw - 40px));
  padding: 14px 20px;
  border-left: 5px solid var(--profit);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-lift);
  font-weight: 600;
  line-height: 1.6;
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-left-color: var(--loss);
}

.toast.warn {
  border-left-color: var(--warn);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.banner {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  background: #fdf6e8;
  line-height: 1.7;
}

.banner-bad {
  border-left-color: var(--loss);
  background: #fdf1ef;
}

.banner ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.banner li {
  margin-bottom: 4px;
}

/* ---------------------------------------------------------------- 入口頁 */

.lobby {
  min-height: 100vh;
  padding: clamp(28px, 6vw, 76px) 20px 60px;
}

.lobby-inner {
  max-width: 1040px;
  margin: 0 auto;
}

.lobby-hero {
  margin-bottom: 40px;
  text-align: center;
}

.lobby-hero h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5.4vw, 3.3rem);
  letter-spacing: 0.04em;
}

.lobby-hero .sub {
  max-width: 660px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: clamp(0.98rem, 2vw, 1.12rem);
  line-height: 1.85;
}

.lobby-mark {
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.team-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 16px 22px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--team-color, var(--accent));
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: center;
  transition: transform 0.14s, box-shadow 0.14s;
}

.team-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.team-card .badge {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 50%;
  background: var(--team-soft, var(--paper-deep));
  color: var(--team-color, var(--ink));
  font-size: 1.24rem;
  font-weight: 800;
}

.team-card .name {
  margin-bottom: 4px;
  font-size: 1.04rem;
  font-weight: 700;
}

.lobby-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 26px;
  border-top: 1px solid var(--line-soft);
}

/* ---------------------------------------------------------------- 頂欄 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 234, 0.96);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 13px 20px;
}

.topbar-wide .topbar-inner {
  max-width: 1500px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
}

.topbar .brand .dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--team-color, var(--accent));
}

.topbar .spacer {
  flex: 1;
}

.day-chip {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-weight: 700;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 分頁 */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
  padding-bottom: 2px;
  border-bottom: 2px solid var(--line);
  scrollbar-width: thin;
}

.tab {
  padding: 11px 20px;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  border-bottom-color: var(--team-color, var(--accent));
  color: var(--ink);
}

.tab .count {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 0.74rem;
}

/* ---------------------------------------------------------------- 數字看板 */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 14px;
}

.stat {
  padding: 15px 17px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--paper);
}

.stat .label {
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 600;
}

.stat .value {
  font-size: 1.52rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat .delta {
  margin-top: 3px;
  font-size: 0.79rem;
  font-weight: 600;
}

.value.up, .delta.up { color: var(--profit); }
.value.down, .delta.down { color: var(--loss); }

/* ---------------------------------------------------------------- 菜單編輯器 */

.menu-item {
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--team-color, var(--accent));
  border-radius: 9px;
  background: var(--paper);
}

.menu-item-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.menu-item-head .idx {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--team-color, var(--accent));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.menu-item-head input[type="text"] {
  flex: 1;
  min-width: 120px;
}

.btn-remove {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.84rem;
}

.btn-remove:hover {
  border-color: var(--loss);
  background: var(--loss);
  color: #fff;
}

.component-group {
  margin-bottom: 12px;
}

.component-group .group-label {
  margin-bottom: 7px;
  color: var(--ink-faint);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.87rem;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}

.chip:hover {
  border-color: var(--team-color, var(--accent));
}

.chip input {
  display: none;
}

.chip .cost {
  color: var(--ink-faint);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.chip.on {
  border-color: var(--team-color, var(--accent));
  background: var(--team-soft, #e6f0f1);
  font-weight: 600;
}

.chip.on .cost {
  color: var(--ink-soft);
}

.item-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.item-controls label {
  margin-bottom: 4px;
  font-size: 0.78rem;
}

/* 即時毛利面板：菜單編輯器的重點，數字要一眼看到 */
.margin-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line-soft);
}

.margin-panel .cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.margin-panel .cell .k {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
}

.margin-panel .cell .v {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.margin-panel.below-cost {
  border-color: var(--loss);
  background: #fdf1ef;
}

.margin-bar {
  flex: 1;
  min-width: 130px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-deep);
}

.margin-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--profit);
  transition: width 0.2s;
}

.margin-bar.thin span {
  background: var(--warn);
}

.margin-bar.negative span {
  background: var(--loss);
}

.menu-empty {
  padding: 34px 20px;
  border: 2px dashed var(--line);
  border-radius: 9px;
  color: var(--ink-soft);
  text-align: center;
}

.menu-total {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 9px;
  background: var(--paper-deep);
  font-weight: 600;
}

/* ---------------------------------------------------------------- 表格 */

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

table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.data th,
table.data td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

table.data th {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

table.data tbody tr:hover {
  background: var(--paper);
}

table.data td.name {
  font-weight: 600;
}

.dot-team {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: baseline;
}

/* ---------------------------------------------------------------- 顧客評論 */

.comments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 12px;
}

.comment {
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--ink-faint);
  border-radius: 8px;
  background: var(--paper);
}

.comment.good { border-left-color: var(--profit); }
.comment.bad { border-left-color: var(--loss); }

.comment .who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.comment .who strong {
  color: var(--ink);
}

.comment .text {
  line-height: 1.75;
}

/* ---------------------------------------------------------------- SVG 走勢圖 */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 16px;
}

.chart {
  padding: 15px 17px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--paper);
}

.chart .chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.87rem;
  font-weight: 700;
}

.chart .chart-title .now {
  font-size: 1.06rem;
  font-variant-numeric: tabular-nums;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------- 輪廓包（Markdown） */

.markdown {
  max-width: 780px;
  line-height: 1.85;
}

.markdown h1 { margin: 0 0 18px; font-size: 1.5rem; }
.markdown h2 { margin: 30px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft); font-size: 1.18rem; }
.markdown h3 { margin: 22px 0 9px; font-size: 1.02rem; }
.markdown ul, .markdown ol { margin: 0 0 14px; padding-left: 22px; }
.markdown li { margin-bottom: 6px; }
.markdown code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--paper-deep);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.markdown blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--paper);
}
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown table {
  width: 100%;
  margin-bottom: 16px;
  border-collapse: collapse;
}
.markdown th, .markdown td {
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  text-align: left;
}
.markdown th { background: var(--paper-deep); font-weight: 700; }
.markdown strong { font-weight: 700; }
.markdown hr { margin: 26px 0; border: none; border-top: 1px solid var(--line); }

/* ================================================================
   帶領人控台 —— 會被投影到大螢幕，字級整體放大一級
   ================================================================ */

.facilitator {
  font-size: 1.06rem;
}

.facilitator .card-head h2 {
  font-size: 1.34rem;
}

.facilitator table.data th {
  font-size: 0.9rem;
}

.facilitator table.data td {
  padding: 14px 15px;
  font-size: 1.08rem;
}

.fac-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: start;
}

/* ── 提交狀態一覽 */

.submit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 14px;
}

.submit-card {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--team-color, var(--accent));
  border-radius: 9px;
  background: var(--paper);
}

.submit-card.done {
  background: rgba(47, 115, 85, 0.07);
}

.submit-card .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.submit-card .shop {
  font-size: 1.04rem;
  font-weight: 700;
}

.submit-card .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.84rem;
}

.submit-card .fact {
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  color: var(--ink-soft);
}

.submit-card .fact.miss {
  border-color: rgba(184, 65, 47, 0.4);
  color: var(--loss);
}

/* ── 執行控制與進度條 */

.run-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

.progress {
  flex: 1;
  min-width: 210px;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-deep);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--profit));
  transition: width 0.4s ease;
}

.progress-text {
  margin-top: 8px;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.progress-fill.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.62; }
}

/* ── 排行榜 */

.rank-num {
  display: inline-grid;
  width: 27px;
  height: 27px;
  margin-right: 10px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-deep);
  font-size: 0.86rem;
  font-weight: 700;
  vertical-align: middle;
}

.rank-num.gold { background: #e8c96a; color: #4a3a10; }
.rank-num.silver { background: #d3d3ce; color: #43423d; }
.rank-num.bronze { background: #d9ab86; color: #4d3320; }

/* ── 市佔長條 */

.share-rows {
  display: grid;
  gap: 11px;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr minmax(58px, auto);
  align-items: center;
  gap: 12px;
}

.share-row .who {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-track {
  height: 22px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--paper-deep);
}

.share-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.share-row .pct {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── 全鎮日誌 */

.log {
  max-height: 460px;
  overflow-y: auto;
  padding-right: 6px;
}

.log-line {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.96rem;
  line-height: 1.65;
}

.log-line:last-child {
  border-bottom: none;
}

.log-line .clock {
  flex: 0 0 60px;
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.log-line .body {
  flex: 1;
}

.log-line.kind-result { background: rgba(47, 115, 85, 0.05); }
.log-line.kind-system { color: var(--ink-soft); font-style: italic; }
.log-line.kind-run { font-weight: 600; }

/* ── 後端狀態燈 */

.backend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  font-size: 0.86rem;
}

.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.led.on { background: var(--profit); box-shadow: 0 0 0 3px rgba(47, 115, 85, 0.18); }
.led.fallback { background: var(--warn); box-shadow: 0 0 0 3px rgba(163, 105, 26, 0.18); }
.led.off { background: var(--loss); box-shadow: 0 0 0 3px rgba(184, 65, 47, 0.18); }

/* ── 密碼頁 */

.gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.gate-card {
  width: min(430px, 100%);
  padding: 34px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-lift);
}

.gate-card h2 {
  margin-bottom: 10px;
  font-size: 1.32rem;
}

/* ================================================================
   響應式 —— 學員可能用手機提交
   ================================================================ */

@media (max-width: 1080px) {
  .fac-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  :root {
    font-size: 15px;
  }

  .wrap {
    padding: 0 13px 56px;
  }

  .card {
    padding: 17px 15px;
  }

  .topbar-inner {
    padding: 10px 13px;
    gap: 9px;
  }

  .topbar .brand {
    font-size: 0.95rem;
  }

  /* 手機上分頁改成可橫向捲動的窄按鈕 */
  .tab {
    padding: 12px 15px;
    font-size: 0.9rem;
  }

  /* iOS Safari 在欄位字級小於 16px 時會自動放大整頁，打完字畫面就跑掉了。
     學員多半用手機提交，這裡強制 16px 把自動縮放關掉。 */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px;
    padding: 12px 12px;
  }

  /* 觸控目標：手指比滑鼠粗，按鈕與勾選晶片都拉到約 44px 高 */
  .btn {
    padding: 13px 20px;
  }

  .btn-remove {
    padding: 10px 14px;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 10px;
  }

  .stat .value {
    font-size: 1.3rem;
  }

  .item-controls {
    grid-template-columns: 1fr 1fr;
  }

  .menu-item {
    padding: 14px 13px;
  }

  .chip {
    padding: 11px 14px;
    font-size: 0.9rem;
  }

  .margin-panel {
    gap: 13px;
  }

  .margin-panel .cell .v {
    font-size: 1.1rem;
  }

  .comments {
    grid-template-columns: 1fr;
  }

  .charts {
    grid-template-columns: 1fr;
  }

  .btn-big {
    width: 100%;
    padding: 15px 22px;
  }

  .toast {
    right: 13px;
    left: 13px;
    bottom: 13px;
    max-width: none;
  }

  .facilitator {
    font-size: 1rem;
  }

  .share-row {
    grid-template-columns: minmax(74px, auto) 1fr minmax(48px, auto);
    gap: 9px;
  }

  .log-line .clock {
    flex-basis: 50px;
  }
}

/* 投影模式：帶領人按下「投影模式」後整體再放大 */
body.project-mode .facilitator {
  font-size: 1.26rem;
}

body.project-mode .facilitator .stat .value {
  font-size: 2rem;
}

body.project-mode .facilitator table.data td {
  padding: 17px 16px;
  font-size: 1.24rem;
}

body.project-mode .facilitator .log-line {
  font-size: 1.14rem;
}

body.project-mode .facilitator .card-head h2 {
  font-size: 1.6rem;
}

@media print {
  .topbar, .tabs, .btn, .btn-row, .toast {
    display: none !important;
  }
  .card {
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* ================================================================
   顧客回饋區塊（fb_ 軌道）
   全部 class 以 .fb- 開頭，不會撞到既有樣式。
   沿用 styles.css 既有的 CSS 變數（--ink / --paper / --profit⋯），
   不新增變數、不引入字型與外部資源。
   ================================================================ */

.fb-feedback {
  margin-top: 26px;
}

.fb-h3 {
  margin: 26px 0 4px;
  font-size: 1rem;
}

.fb-feedback > .fb-h3:first-child {
  margin-top: 0;
}

.fb-lede {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.6;
}

.fb-icon {
  flex: none;
}

/* ---------------------------------------------------------------- 建議卡 */

.fb-advice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 12px;
}

.fb-advice-card {
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--ink-faint);
  border-radius: 8px;
  background: var(--card);
}

.fb-advice-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}

.fb-advice-label {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.fb-count {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.fb-advice-text {
  margin: 0;
  line-height: 1.75;
  font-size: 0.94rem;
}

/* 要改的：暖琥珀。是建議不是錯誤，所以不用紅色 */
.fb-a-fix {
  border-left-color: var(--warn);
  background: #fdf7ec;
}
.fb-a-fix .fb-icon,
.fb-a-fix .fb-advice-label { color: var(--warn); }

/* 別動的：綠 */
.fb-a-keep {
  border-left-color: var(--profit);
  background: #f0f7f3;
}
.fb-a-keep .fb-icon,
.fb-a-keep .fb-advice-label { color: var(--profit); }

/* 貼文吹過頭：最重要的一條。整排寬 + 較深底色 + 左邊粗框 */
.fb-a-over {
  grid-column: 1 / -1;
  border: 1px solid rgba(184, 65, 47, 0.32);
  border-left: 6px solid var(--loss);
  background: #fdefec;
  box-shadow: var(--shadow);
}
.fb-a-over .fb-icon,
.fb-a-over .fb-advice-label { color: var(--loss); }
.fb-a-over .fb-advice-label { font-size: 0.98rem; }
.fb-a-over .fb-advice-text { font-size: 1rem; }
.fb-a-over .fb-count {
  background: rgba(184, 65, 47, 0.13);
  color: var(--loss);
}

/* 今天沒賣出去：中性灰，不搶戲 */
.fb-a-nodata {
  border-left-color: var(--line);
  background: var(--paper);
}
.fb-a-nodata .fb-icon,
.fb-a-nodata .fb-advice-label { color: var(--ink-soft); }
.fb-a-nodata .fb-advice-text { color: var(--ink-soft); }

/* ------------------------------------------------------ 滿意度分佈條 */

.fb-spread {
  padding: 4px 2px 0;
}

.fb-track {
  position: relative;
  height: 74px;
  margin-bottom: 6px;
  border-radius: 8px;
  /* 三段底色：< 0.45 偏紅、0.45–0.75 中性、≥ 0.75 偏綠 */
  background: linear-gradient(
    to right,
    rgba(184, 65, 47, 0.11) 0%,
    rgba(184, 65, 47, 0.11) 45%,
    rgba(163, 105, 26, 0.09) 45%,
    rgba(163, 105, 26, 0.09) 75%,
    rgba(47, 115, 85, 0.13) 75%,
    rgba(47, 115, 85, 0.13) 100%
  );
}

/* 0.45 與 0.75 兩條門檻線 */
.fb-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed rgba(35, 33, 28, 0.34);
}

.fb-line-bad { border-left-color: rgba(184, 65, 47, 0.6); }
.fb-line-good { border-left-color: rgba(47, 115, 85, 0.6); }

/* 每位顧客一個點，往上堆避免重疊 */
.fb-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
}

.fb-dot {
  position: absolute;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 1px 3px rgba(53, 46, 31, 0.28);
}

.fb-dot.bad { background: var(--loss); }
.fb-dot.mid { background: var(--warn); }
.fb-dot.good { background: var(--profit); }

/* 全店平均：從上方指下來的小三角 */
.fb-avg {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.fb-avg-tip {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--ink);
}

.fb-avg-text {
  display: block;
  margin-top: 1px;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

/* 刻度：0 / 0.45 / 0.75 / 1 */
.fb-scale {
  position: relative;
  height: 32px;
  margin-bottom: 10px;
}

.fb-tick {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}

.fb-tick:first-child { transform: translateX(0); text-align: left; }
.fb-tick-end { transform: translateX(-100%); text-align: right; }

.fb-tick b {
  display: block;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.fb-tick i {
  display: block;
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-style: normal;
}

/* 三段人數 */
.fb-zones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fb-zone {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.fb-zone b { font-weight: 700; }
.fb-zone.bad { background: rgba(184, 65, 47, 0.13); color: var(--loss); }
.fb-zone.mid { background: rgba(163, 105, 26, 0.15); color: var(--warn); }
.fb-zone.good { background: rgba(47, 115, 85, 0.14); color: var(--profit); }

/* ---------------------------------------------------------------- 評語卡 */

.fb-comments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 12px;
}

.fb-comment {
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--ink-faint);
  border-radius: 8px;
  background: var(--paper);
}

/* verdict 決定整則的邊框色調 */
.fb-v-good { border-left-color: var(--profit); }
.fb-v-mixed { border-left-color: var(--warn); }
.fb-v-bad { border-left-color: var(--loss); }
.fb-v-over {
  border-left-color: var(--loss);
  border-left-width: 6px;
  background: #fdf3f1;
}

.fb-comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.fb-who {
  color: var(--ink);
  font-size: 0.92rem;
}

.fb-bought { color: var(--ink-faint); }

.fb-verdict {
  margin-left: auto;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.fb-verdict b {
  margin-left: 4px;
  color: var(--ink);
}

.fb-v-good .fb-verdict,
.fb-v-good .fb-verdict b { color: var(--profit); }
.fb-v-bad .fb-verdict,
.fb-v-bad .fb-verdict b { color: var(--loss); }
.fb-v-over .fb-verdict,
.fb-v-over .fb-verdict b { color: var(--loss); }

.fb-said {
  margin: 0 0 11px;
  line-height: 1.75;
}

/* 診斷：強項 / 弱項兩行 */
.fb-diag {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
}

.fb-diag-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fb-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.fb-tag.strong { background: rgba(47, 115, 85, 0.15); color: var(--profit); }
.fb-tag.weak { background: rgba(163, 105, 26, 0.17); color: var(--warn); }

.fb-diag-name {
  flex: none;
  min-width: 3.6em;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.fb-bar {
  flex: 1 1 auto;
  min-width: 40px;
  height: 7px;
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
}

.fb-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.fb-bar-fill.strong { background: var(--profit); }
.fb-bar-fill.weak { background: var(--warn); }

.fb-diag-num {
  flex: none;
  width: 2.6em;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.fb-lever {
  margin: 9px 0 0;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--ink-soft);
}

.fb-lever-key {
  margin-right: 5px;
  font-weight: 700;
  color: var(--warn);
}

/* expect_gap > 0 的特別標記 */
.fb-gap {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(184, 65, 47, 0.09);
  color: var(--loss);
  font-size: 0.82rem;
  line-height: 1.6;
}

.fb-gap .fb-icon { margin-top: 2px; }

.fb-has-gap { box-shadow: inset 0 0 0 1px rgba(184, 65, 47, 0.18); }

/* ---------------------------------------------------------------- 手機 */

@media (max-width: 760px) {
  /* 單欄，卡片不要被擠成窄條 */
  .fb-advice,
  .fb-comments {
    grid-template-columns: 1fr;
  }

  .fb-track { height: 66px; }

  /* 0.45 與 0.75 的刻度標籤在窄螢幕會互相疊到，字再縮一點 */
  .fb-tick b { font-size: 0.7rem; }
  .fb-tick i { font-size: 0.63rem; }

  /* 滿意度數字換行到下一行，名字才不會被擠掉 */
  .fb-verdict {
    margin-left: 0;
    flex-basis: 100%;
  }

  .fb-diag-name { min-width: 3.2em; font-size: 0.78rem; }
}

/* 列印／匯出時把底色留住（帶領人會印出來檢討） */
@media print {
  .fb-advice-card,
  .fb-comment,
  .fb-track {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
