/* ═══ 可重用元件（照 freetaxi 車隊端的長相；數值出處見 研究\freetaxi-UI風格規格.md 第 3 節）═══ */

/* ── 按鈕（照 tcm-btn）── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ft-touch); padding: 0 18px;
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-lg);
  background: transparent; color: var(--ft-text-muted);
  font: inherit; font-size: var(--ft-fs-13); font-weight: 600; white-space: nowrap; cursor: pointer;
  text-decoration: none;
  transition: background var(--ft-t-fast) var(--ft-ease), color var(--ft-t-fast) var(--ft-ease),
              border-color var(--ft-t-fast) var(--ft-ease), transform 90ms var(--ft-ease);
}
.btn:hover:not(:disabled) { background: var(--ft-hover); color: var(--ft-text); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { border-color: transparent; background: var(--ft-primary); color: var(--ft-on-primary); }
.btn--primary:hover:not(:disabled) { background: var(--ft-primary); color: var(--ft-on-primary); filter: brightness(1.08); }
.btn--danger { border-color: transparent; background: var(--ft-danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--ft-danger); color: #fff; filter: brightness(1.08); }
.btn--danger-outline { border-color: var(--ft-danger-outline); color: var(--ft-danger); font-weight: 700; }
.btn--danger-outline:hover:not(:disabled) { border-color: var(--ft-danger); background: var(--ft-danger-soft); color: var(--ft-danger); }
.btn--sm { min-height: var(--ft-btn-sm); padding: 0 12px; font-size: var(--ft-fs-sm); border-radius: 10px; }
.btn--icon { padding: 0; width: var(--ft-touch); }
.btn--sm.btn--icon { width: var(--ft-btn-sm); }
.btn--link { border: 0; padding: 0 4px; min-height: 0; color: var(--ft-primary-text); font-weight: 600; background: none; }
.btn--link:hover:not(:disabled) { background: none; color: var(--ft-primary-text); text-decoration: underline; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: ft-spin .6s linear infinite;
}
.btn-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
@media (pointer: coarse) { .btn--sm { min-height: var(--ft-touch); } .btn--sm.btn--icon { width: var(--ft-touch); } }

/* ── 卡片 ── */
.card {
  background: var(--ft-surface); color: var(--ft-text);
  border: 1px solid var(--ft-border); border-radius: var(--ft-card-radius);
  padding: var(--ft-sp-4); box-shadow: var(--ft-shadow-card);
}
.card__head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.card__title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.card__sub { margin: 3px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ft-text-muted); }
.card__head .btn-row, .card__head .card__aside { margin-left: auto; }
.card__aside { font-size: var(--ft-fs-sm); color: var(--ft-text-muted); white-space: nowrap; }
.card__aside a { display: inline-flex; align-items: center; gap: 2px; }

/* 設定區塊卡（freetaxi 車隊設定：標題條淡底＋左側 4px 主色條＋圓形編號）*/
.section-card {
  background: var(--ft-surface); border: 1px solid var(--ft-border-strong);
  border-radius: var(--ft-section-radius); box-shadow: var(--ft-shadow-card); overflow: hidden;
}
.section-card__head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--ft-primary-soft);
  border-bottom: 1px solid var(--ft-border); box-shadow: inset 4px 0 0 var(--ft-primary);
}
.section-card__no {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ft-primary); color: var(--ft-on-primary); font-size: 13px; font-weight: 800;
}
.section-card__title { font-size: 16px; font-weight: 800; letter-spacing: .02em; }
.section-card__note { margin-left: auto; font-size: 12px; color: var(--ft-text-muted); }
.section-card__body { padding: 0 14px; }
.section-card__intro { padding: 12px 0 4px; }

/* 設定列：一列一件事，左說明、右控制 */
.setting-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--ft-border);
}
.section-card__body > .setting-row:first-child, .section-card__intro + .setting-row { border-top: 0; }
.setting-row__text { min-width: 0; flex: 1 1 auto; }
.setting-row__name { display: block; font-size: 14px; font-weight: 700; }
.setting-row__desc { max-width: 52ch; margin-top: 2px; font-size: 12.5px; line-height: 1.55; color: var(--ft-text-muted); }
.setting-row__control { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.setting-row__sub { font-size: 12px; color: var(--ft-text-muted); text-align: right; }
.setting-row--block { flex-direction: column; align-items: stretch; }
.setting-row--block .setting-row__control { align-items: stretch; }
.setting-row.is-disabled .setting-row__name,
.setting-row.is-disabled .setting-row__desc { opacity: .55; }
.setting-row.is-changed .setting-row__name::after {
  content: "已改"; margin-left: 8px; padding: 0 6px; border-radius: var(--ft-r-xs);
  font-size: 11px; font-weight: 700; vertical-align: 1px;
  color: var(--ft-primary-text); background: var(--ft-primary-soft);
}

/* ── 表單欄位 ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field__label { font-size: var(--ft-fs-13); font-weight: 700; }
.field__hint  { max-width: 66ch; font-size: var(--ft-fs-sm); line-height: 1.6; color: var(--ft-text-muted); }
.field__error { display: flex; gap: 6px; align-items: flex-start; font-size: var(--ft-fs-sm); line-height: 1.5; color: var(--ft-danger); font-weight: 600; }
.field__error .icon { margin-top: 1px; }
.field__warn { font-size: var(--ft-fs-sm); line-height: 1.5; color: var(--ft-warning); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: var(--ft-touch); padding: 10px 14px;
  border: 1px solid var(--ft-input-border); border-radius: var(--ft-r-lg);
  background: var(--ft-input-bg); color: var(--ft-text);
  font: inherit; font-size: var(--ft-fs-base);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 120px; line-height: 1.55; resize: vertical; font-family: var(--ft-font); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ft-text-muted) 50%), linear-gradient(135deg, var(--ft-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--ft-surface); color: var(--ft-text); }
.input::placeholder, .textarea::placeholder { color: var(--ft-text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: rgba(var(--ft-accent-rgb), .6);
  box-shadow: 0 0 0 3px rgba(var(--ft-accent-rgb), .15);
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: .55; cursor: not-allowed; }
.is-error .input, .is-error .select, .is-error .textarea, .input.is-error { border-color: var(--ft-danger); }
.is-error .input:focus, .input.is-error:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ft-danger) 20%, transparent); }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select--inline { width: auto; min-width: 140px; min-height: 40px; }

/* 數字＋單位 */
.num-input { position: relative; display: inline-flex; align-items: center; width: 132px; }
.num-input .input { padding-right: 40px; }
.num-input__unit {
  position: absolute; right: 12px; pointer-events: none;
  font-size: 13px; color: var(--ft-text-muted);
}
.num-input--wide { width: 160px; }

/* 搜尋框 */
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; color: var(--ft-text-muted); pointer-events: none; }
.search .input { padding-left: 38px; }

/* ── 開關（點擊範圍 52×44，看起來 46×26）── */
.switch { position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: not-allowed; }
.switch__label { font-size: 13px; font-weight: 600; color: var(--ft-text-muted); min-width: 1.2em; text-align: right; }
.switch__track {
  position: relative; width: 46px; height: 26px; border-radius: 999px; pointer-events: none; flex: none;
  background: var(--ft-switch-off); border: 1px solid var(--ft-border);
  transition: background .18s ease, border-color .18s ease;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); transition: transform .18s ease;
}
.switch input:checked ~ .switch__track { background: var(--ft-switch-on); border-color: transparent; }
.switch input:checked ~ .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--ft-accent); outline-offset: 2px; }
.switch input:disabled ~ .switch__track, .switch input:disabled ~ .switch__label { opacity: .5; }

/* ── 選項（radio 一組）── */
.choice-group { display: flex; flex-direction: column; gap: 8px; }
.choice-group--row { flex-direction: row; flex-wrap: wrap; }
.choice {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  min-height: var(--ft-touch); padding: 10px 12px;
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-lg);
  cursor: pointer; transition: background var(--ft-t-fast) var(--ft-ease), border-color var(--ft-t-fast) var(--ft-ease);
}
.choice:hover { background: var(--ft-hover); }
.choice input { margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--ft-primary); flex: none; cursor: pointer; }
.choice__text { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.choice__desc { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--ft-text-muted); }
.choice:has(input:checked) { border-color: var(--ft-primary); background: var(--ft-primary-soft); box-shadow: inset 0 0 0 1px var(--ft-primary); }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* 勾選鈕（人員設定用：整顆是熱區）*/
.check-chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--ft-touch); padding: 0 12px;
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-lg);
  font-size: 13px; font-weight: 600; color: var(--ft-text-muted); cursor: pointer; user-select: none;
  transition: background var(--ft-t-fast) var(--ft-ease), border-color var(--ft-t-fast) var(--ft-ease), color var(--ft-t-fast) var(--ft-ease);
}
.check-chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--ft-primary); cursor: pointer; }
.check-chip:hover { background: var(--ft-hover); color: var(--ft-text); }
.check-chip:has(input:checked) { border-color: var(--ft-primary); color: var(--ft-text); background: var(--ft-primary-soft); }
.check-chip:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.check-chip:has(input:focus-visible) { outline: 2px solid var(--ft-accent); outline-offset: 2px; }

/* 分段切換（頂欄的主色／主題／視角）*/
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08);
}
.seg__btn {
  min-height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ft-chrome-muted); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.seg__btn:hover { color: var(--ft-chrome-fg); }
.seg__btn[aria-pressed="true"] { background: #eef4f8; color: #0a1317; }   /* freetaxi 車隊快切 chip：選中＝淺色 chip 深字 */
.seg__label { font-size: 11px; color: var(--ft-chrome-muted); margin-right: 2px; align-self: center; padding-left: 6px; }
.seg__dot { width: 9px; height: 9px; border-radius: 50%; }
.seg__dot--teal { background: #00c896; }
.seg__dot--blue { background: #3b8fe0; }
@media (pointer: coarse) { .seg__btn { min-height: 38px; } }

/* 篩選 chip（報表風：方角，選中加內框，不只靠顏色）*/
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-xs); background: transparent;
  color: var(--ft-text-muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--ft-text); background: var(--ft-hover); }
.chip[aria-pressed="true"] { color: var(--ft-text); border-color: var(--ft-primary); box-shadow: inset 0 0 0 1px var(--ft-primary); background: var(--ft-primary-soft); }
.chip__count { font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--ft-hover); font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .chip { min-height: 40px; } }

/* 分頁籤（頁面內）*/
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ft-border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  position: relative; min-height: var(--ft-touch); padding: 0 14px; border: 0; background: none;
  color: var(--ft-text-muted); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ft-text); }
.tab[aria-selected="true"] { color: var(--ft-text); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ft-primary);
}

/* ── 狀態膠囊 ── */
.pill {
  --pill-c: var(--st-searching);
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 2px 9px; border-radius: var(--ft-r-pill);
  font-size: 11.5px; font-weight: 700; line-height: 1.5; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--pill-c) 32%, transparent);
  background: color-mix(in srgb, var(--pill-c) 14%, transparent);
  color: var(--pill-c);
}
[data-theme="light"] .pill { color: color-mix(in srgb, var(--pill-c) 45%, var(--ft-text)); }
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill--square { padding: 1px 6px; border-radius: var(--ft-r-xs); font-weight: 600; }
.pill--faded { opacity: .78; background: color-mix(in srgb, var(--pill-c) 9%, transparent); }
.st-new        { --pill-c: var(--st-new); border-style: dashed; }
.st-searching  { --pill-c: var(--st-searching); }
.st-selecting  { --pill-c: var(--st-selecting); }
.st-scheduled  { --pill-c: var(--st-scheduled); }
.st-accepted   { --pill-c: var(--st-accepted); }
.st-arrived    { --pill-c: var(--st-arrived); }
.st-boarded    { --pill-c: var(--st-boarded); }
.st-dropped    { --pill-c: var(--st-dropped); }
.st-cancelled  { --pill-c: var(--st-cancelled); }
.st-nocar      { --pill-c: var(--st-nocar); }
.st-fallback   { --pill-c: var(--st-fallback); }
.pill--ok      { --pill-c: #22c55e; }
.pill--bad     { --pill-c: #ef4444; }
.pill--warn    { --pill-c: #f0c14a; }
.pill--info    { --pill-c: #5aa9ff; }
.pill--off     { --pill-c: #8a93a6; }
.pill--primary { --pill-c: var(--ft-primary); }
.st-selecting .pill__dot, .pill--live .pill__dot { animation: ft-blink 1.2s ease-in-out infinite; }

/* 身分膠囊 */
.role { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; border: 1px solid; }
.role--admin { color: var(--role-admin-fg); background: var(--role-admin-bg); border-color: var(--role-admin-bd); }
.role--fleet { color: var(--role-fleet-fg); background: var(--role-fleet-bg); border-color: var(--role-fleet-bd); }
[data-theme="light"] .page .role--admin { color: #6d28d9; }
[data-theme="light"] .page .role--fleet { color: #92400e; }

/* 小標籤（代入欄位、群代號…）*/
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: var(--ft-r-xs);
  font-size: 11.5px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--ft-hover); color: var(--ft-text-2); border: 1px solid var(--ft-border);
}
.tag--mono { font-family: var(--ft-font-mono); font-weight: 500; }
.tag--primary { color: var(--ft-primary-text); background: var(--ft-primary-soft); border-color: transparent; }
.tag--warn { color: var(--ft-warning); background: color-mix(in srgb, var(--ft-warning) 14%, transparent); border-color: transparent; }
.tag--btn { cursor: pointer; min-height: 30px; padding: 0 9px; }
.tag--btn:hover { border-color: var(--ft-primary); color: var(--ft-text); }
@media (pointer: coarse) { .tag--btn { min-height: 38px; } }

/* ── 表格（照訂單報表 ERP 方正風）── */
.table-wrap {
  overflow-x: auto; overflow-y: hidden;
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-sm);
  background: var(--ft-surface);
}
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--ft-fs-13); line-height: 1.45; color: var(--ft-text);
}
.table--fixed { table-layout: fixed; }
.table thead th {
  height: 40px; padding: 0 12px; text-align: left; vertical-align: middle;
  font-size: var(--ft-fs-sm); font-weight: 600; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ft-table-head-fg); background: var(--ft-table-head);
}
.table tbody td { padding: 9px 12px; vertical-align: middle; border-bottom: 1px solid var(--ft-border); }
.table tbody tr:last-child > td { border-bottom: 0; }
.table tbody tr:hover > td { background: var(--ft-row-hover); }
.table tbody tr.is-clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table__id { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ft-primary-text); font-family: var(--ft-font-mono); }
.table__sub { display: block; font-size: 12px; color: var(--ft-text-muted); }
.table__empty { padding: 28px 12px !important; text-align: center; color: var(--ft-text-muted); }
.table__actions { white-space: nowrap; text-align: right; }
.table .clamp1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 清單列（群組、成員：桌機與手機同一套，會自動換行）── */
.list { border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-sm); background: var(--ft-surface); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--ft-border);
}
.list-row:first-child { border-top: 0; }
.list-row__main { flex: 1 1 220px; min-width: 0; display: flex; align-items: center; gap: 12px; }
.list-row__title { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.list-row__meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 2px; font-size: 12px; color: var(--ft-text-muted); }
.list-row__side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.list-row.is-changed { box-shadow: inset 3px 0 0 var(--ft-primary); }
.list-row.is-muted .list-row__title { color: var(--ft-text-muted); }

/* 頭像（名字第一個字）*/
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: var(--ft-text);
  background: color-mix(in srgb, var(--av, #8a93a6) 26%, var(--ft-surface-2));
  border: 1px solid color-mix(in srgb, var(--av, #8a93a6) 40%, transparent);
}
.avatar--bot { --av: #5aa9ff; }
.avatar--oa { --av: #22c55e; }
.avatar--a0 { --av: #f0c14a; } .avatar--a1 { --av: #b18cff; } .avatar--a2 { --av: #5aa9ff; }
.avatar--a3 { --av: #ff9f43; } .avatar--a4 { --av: #00c896; } .avatar--a5 { --av: #e879f9; }
.avatar .icon { width: 18px; height: 18px; }

/* ── 提示框 ── */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--ft-r-sm);
  background: color-mix(in srgb, var(--ft-primary) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--ft-primary);
  font-size: 13px; line-height: 1.6; color: var(--ft-text-2);
}
.callout > .icon { margin-top: 2px; color: var(--ft-primary-text); }
.callout b, .callout strong { color: var(--ft-text); }
.callout--info { background: color-mix(in srgb, var(--ft-info) 10%, transparent); box-shadow: inset 3px 0 0 var(--ft-info); }
.callout--info > .icon { color: var(--ft-info-text); }
.callout--warn { background: color-mix(in srgb, var(--ft-warning) 10%, transparent); box-shadow: inset 3px 0 0 var(--ft-warning); }
.callout--warn > .icon { color: var(--ft-warning); }
.callout--danger { background: color-mix(in srgb, var(--ft-danger) 10%, transparent); box-shadow: inset 3px 0 0 var(--ft-danger); }
.callout--danger > .icon { color: var(--ft-danger); }
.callout p + p { margin-top: 4px; }
.terms { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.terms dt { font-weight: 800; color: var(--ft-text); white-space: nowrap; }
.terms dd { margin: 0; }

/* ── 統計 ── */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  padding: 12px 14px; border-radius: var(--ft-r-sm); border: 1px solid var(--ft-border-strong); background: var(--ft-surface);
}
.stat__label { font-size: 12px; color: var(--ft-text-muted); display: flex; align-items: center; gap: 6px; }
.stat__value { margin-top: 2px; font-size: 26px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat__note { font-size: 12px; color: var(--ft-text-muted); }
.stat__bar { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--ft-primary)); }

/* ── 空狀態 ── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 28px 16px; border: 1px dashed var(--ft-border-strong); border-radius: var(--ft-r-sm);
  color: var(--ft-text-muted); font-size: 13px;
}
.empty .icon { width: 28px; height: 28px; opacity: .6; }
.empty__title { font-size: 14px; font-weight: 600; color: var(--ft-text); }

/* ── 載入中 ── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--ft-border); border-top-color: var(--ft-primary);
  animation: ft-spin .6s linear infinite;
}
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--ft-text-muted); }

/* ── 下拉選單 ── */
.menu {
  position: absolute; z-index: calc(var(--ft-z-topbar) + 10); min-width: 220px; padding: 6px;
  background: var(--ft-surface); color: var(--ft-text);
  border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-lg); box-shadow: var(--ft-shadow-pop);
  animation: ft-pop-in var(--ft-t) var(--ft-ease);
}
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px;
  border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; color: var(--ft-text);
}
.menu__item:hover { background: var(--ft-hover); }
.menu__item[aria-current="true"] { background: var(--ft-primary-soft); }
.menu__item-sub { display: block; font-size: 12px; color: var(--ft-text-muted); }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--ft-border); }
.menu__label { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 700; color: var(--ft-text-muted); letter-spacing: .04em; }

/* ── 彈窗（統一彈窗殼 tcm）── */
.modal-host { position: fixed; inset: 0; z-index: var(--ft-z-modal); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-host--confirm { z-index: var(--ft-z-confirm); }
.modal-host::before { content: ""; position: absolute; inset: 0; background: var(--ft-scrim); animation: ft-fade-in var(--ft-t) ease; }
.modal {
  position: relative; display: flex; flex-direction: column;
  width: min(var(--ft-modal-w), 100%); max-height: 85vh;
  background: var(--ft-surface); color: var(--ft-text);
  border: 1px solid var(--ft-border-strong); border-radius: 16px; box-shadow: var(--ft-shadow-modal);
  animation: ft-modal-in .18s ease;
}
.modal--wide { width: min(600px, 100%); }
.modal__head {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--ft-border); flex: none;
}
.modal__title { flex: 1; font-size: 15px; font-weight: 700; }
.modal__close {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--ft-text-muted);
  display: grid; place-items: center; cursor: pointer;
}
.modal__close:hover { background: var(--ft-hover); color: var(--ft-text); }
.modal__body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; font-size: 14px; line-height: 1.6; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--ft-border); flex: none; }
.modal.is-shake { animation: ft-shake .28s ease; }
.modal__grab { display: none; }

/* 側邊面板（訂單詳情）*/
.modal-host--side { justify-content: flex-end; padding: 0; }
.modal--side {
  width: min(560px, 100%); height: 100%; max-height: none; border-radius: 0; border-width: 0 0 0 1px;
  animation: ft-side-in var(--ft-t-slow) var(--ft-ease);
}

@media (max-width: 560px) {
  .modal-host, .modal-host--side { align-items: flex-end; padding: 0; }
  .modal, .modal--wide, .modal--side {
    width: 100%; max-height: 92vh; height: auto; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: ft-sheet-in var(--ft-t-slow) var(--ft-ease);
  }
  .modal--side { height: 92vh; }
  .modal__grab { display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--ft-border-strong); margin: 8px auto 0; flex: none; }
  .modal__foot .btn { flex: 1 1 0; }
}

/* ── Toast（直掛 body、最上層、預設畫面正中央）── */
.toast-host {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: var(--ft-z-toast);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  min-width: 220px; max-width: 420px; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  background: var(--ft-surface); color: var(--ft-text); border: 1px solid var(--ft-border-strong); box-shadow: var(--ft-shadow-pop);
  font-size: 14px; line-height: 1.5; animation: ft-toast-in .18s ease;
}
.toast.is-leaving { animation: ft-toast-out .18s ease forwards; }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ft-toast-success); }
.toast--info .toast__dot { background: var(--ft-toast-info); }
.toast--warn .toast__dot { background: var(--ft-toast-warn); }
.toast--error .toast__dot { background: var(--ft-toast-error); }

/* ── 定義清單（詳情用）── */
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--ft-text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ── 時間軸 ── */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline__item { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 0 0 14px; }
.timeline__item::before {
  content: ""; position: absolute; left: 61px; top: 16px; bottom: -2px; width: 1px; background: var(--ft-border-strong);
}
.timeline__item:last-child::before { display: none; }
.timeline__time { font-size: 12px; color: var(--ft-text-muted); font-variant-numeric: tabular-nums; padding-top: 1px; text-align: right; }
.timeline__body { position: relative; padding-left: 18px; min-width: 0; }
.timeline__body::before {
  content: ""; position: absolute; left: -3.5px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--tl-c, var(--ft-text-faint)); box-shadow: 0 0 0 3px var(--ft-surface);
}
.timeline__title { font-size: 13.5px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.timeline__meta { font-size: 12px; color: var(--ft-text-muted); margin-top: 1px; overflow-wrap: anywhere; }
.timeline__item.is-status .timeline__body::before { width: 11px; height: 11px; left: -4.5px; top: 4px; }

/* ── LINE 訊息預覽泡泡 ── */
.bubble-wrap { display: flex; flex-direction: column; gap: 4px; }
.bubble-who { font-size: 11.5px; color: var(--ft-text-muted); display: flex; gap: 6px; align-items: center; }
.bubble {
  align-self: flex-start; max-width: 100%;
  padding: 10px 12px; border-radius: 4px 16px 16px 16px;
  background: var(--ft-surface-2); border: 1px solid var(--ft-border);
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble--empty { color: var(--ft-text-faint); font-style: italic; }
.bubble mark { background: none; color: var(--ft-primary-text); font-weight: 700; }

/* ── 動畫（只動 opacity／transform）── */
@keyframes ft-spin { to { transform: rotate(360deg); } }
@keyframes ft-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ft-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ft-modal-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ft-side-in { from { opacity: .4; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes ft-sheet-in { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes ft-pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes ft-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes ft-toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes ft-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
