/* ==========================================================================
   SoftMAX ERP — Tactile Soft UI design tokens（唯一真實來源）
   規格來源：markdown/SoftMAX_ERP_KimiK3_Prompt_PasteReady.txt
   規則：所有樣式只能引用變數，不得再寫死色碼。
   ========================================================================== */

:root {
  /* 顏色 */
  --bg: #EFEBE3;            /* 頁面底色（暖白紙感） */
  --surface: #F4F1EA;       /* 卡片／鍵帽表層 */
  --surface-2: #F7F4EE;     /* 更亮的表層、hover 態 */
  --sunken: #E8E2D7;        /* 凹槽、圖示井、進度條底 */
  --hairline: #DCD5C6;      /* 極細分隔線（1px，僅必要處） */
  --ink: #1F1C17;           /* 主文字（暖黑，禁用純黑） */
  --ink-2: #555047;         /* 次要文字 */
  --muted: #7A746A;         /* 說明文字、英文小標 */
  --accent: #2B54D6;        /* 品牌藍：指示燈、選中文字、主要按鈕 */
  --accent-ink: #1E3FA8;    /* 藍色按鈕 hover */
  --accent-soft: #E4E9FB;   /* 藍色淡底（圖示磚、標籤） */
  --success: #1C7A54;
  --success-soft: #E1EFE7;
  --danger: #B23A32;
  --danger-soft: #F7E4E1;
  --warning: #A26A16;
  --warning-soft: #F5EAD7;

  /* 陰影與高度（總共只准 3 層；光源一致：左上亮、右下暗） */
  --shadow-raise: -6px -6px 14px rgba(255, 255, 255, .95), 8px 10px 24px rgba(160, 148, 128, .30);
  --shadow-raise-sm: -3px -3px 8px rgba(255, 255, 255, .90), 4px 5px 12px rgba(160, 148, 128, .26);
  --shadow-press: inset 3px 3px 7px rgba(160, 148, 128, .45), inset -3px -3px 7px rgba(255, 255, 255, .95);
  --shadow-press-sm: inset 2px 2px 5px rgba(160, 148, 128, .40), inset -2px -2px 5px rgba(255, 255, 255, .90);

  /* 圓角 */
  --radius-card: 22px;
  --radius-key: 16px;
  --radius-field: 12px;
  --radius-brick: 14px;     /* 圖示磚（10–14px 範圍取大者，配合 44px 磚） */
  --radius-iconwell: 10px;

  /* 動效 */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-press: 120ms;
  --dur-hover: 180ms;
}

/* --------------------------------------------------------------------------
   基底
   -------------------------------------------------------------------------- */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 英文小標（10.5px / 600 / uppercase / .16em / muted） */
.eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   KPI 統計卡（Batch 1 樣板：暖白浮雕卡＋彩色小圖示磚＋大字數字＋底部細線索）
   -------------------------------------------------------------------------- */
.kpi-card {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-raise);
  color: inherit;
  text-decoration: none;
  transition: box-shadow var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}
.kpi-card:hover {
  background: var(--surface-2);
  color: inherit;
}
.kpi-card:active {
  box-shadow: var(--shadow-press);
  transform: translateY(1px) scale(.995);
  transition-duration: var(--dur-press);
}

/* 44×44 圖示磚：微凹，像嵌進去的按鈕；顏色只出現在這裡 */
.kpi-brick {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-brick);
  box-shadow: var(--shadow-press-sm);
}
.kpi-brick svg { width: 20px; height: 20px; }
.kpi-brick--accent  { background: var(--accent-soft);  color: var(--accent); }
.kpi-brick--success { background: var(--success-soft); color: var(--success); }
.kpi-brick--danger  { background: var(--danger-soft);  color: var(--danger); }
.kpi-brick--warning { background: var(--warning-soft); color: var(--warning); }

.kpi-label {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.kpi-value {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--muted);
}
.kpi-foot .kpi-action {
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

/* 互動元件的 focus-visible 規範（2px accent 外框 + 2px offset） */
.kpi-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 尊重 prefers-reduced-motion：關閉位移與過場，只保留顏色變化 */
@media (prefers-reduced-motion: reduce) {
  .kpi-card {
    transition: background-color var(--dur-hover) var(--ease);
  }
  .kpi-card:active {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   App Shell：側邊欄（Tactile 三定律）
   ① 選單項 = 新擬物鍵帽（浮起）
   ② 按下時外陰影轉內陰影
   ③ 當前項保持按下＋右側藍色 LED＋藍字
   -------------------------------------------------------------------------- */
.app-sidebar {
  position: sticky;
  top: 0;
  width: 264px;
  min-width: 264px;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--hairline);
  padding: 20px 16px;
  gap: 4px;
}

/* 品牌區 */
.brand-block {
  padding: 6px 8px 18px;
}
.brand-wordmark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.2;
}
.brand-wordmark .brand-erp {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .28em;
  color: var(--muted);
  vertical-align: 2px;
  margin-left: 2px;
}

/* 導航清單 */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 鍵帽（定律①：浮起） */
.nav-key {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-key);
  background: var(--surface);
  box-shadow: var(--shadow-raise-sm);
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  transition: box-shadow var(--dur-press) var(--ease),
              background-color var(--dur-hover) var(--ease),
              color var(--dur-hover) var(--ease),
              transform var(--dur-press) var(--ease);
}
.nav-key:hover {
  background: var(--surface-2);
  color: var(--ink);
}
/* 定律②：按下瞬間陷進去 */
.nav-key:active {
  box-shadow: var(--shadow-press);
  transform: translateY(1px) scale(.995);
}
/* 定律③：當前項保持按下＋藍字＋右側 LED */
.nav-key[aria-current="page"],
.nav-key[aria-current="page"]:hover {
  background: var(--surface);
  box-shadow: var(--shadow-press);
  color: var(--accent);
  font-weight: 600;
}
.nav-key:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Icon 井：32×32 微凹小方槽 */
.nav-key .icon-well {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-iconwell);
  background: var(--surface-2);
  box-shadow: var(--shadow-press-sm);
  color: var(--muted);
  transition: color var(--dur-hover) var(--ease);
}
.nav-key .icon-well svg { width: 18px; height: 18px; }
.nav-key:hover .icon-well { color: var(--ink-2); }
.nav-key[aria-current="page"] .icon-well { color: var(--accent); }

.nav-key .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* LED：6px 藍點＋3px accent-soft 光暈；非當前項隱藏 */
.nav-key .nav-led {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 999px;
  opacity: 0;
  transition: opacity var(--dur-hover) var(--ease);
}
.nav-key[aria-current="page"] .nav-led {
  opacity: 1;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 底部帳號區 */
.account-block {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--sunken);
  box-shadow: var(--shadow-press-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.account-meta {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-role {
  font-size: 12px;
  color: var(--muted);
}

/* Ghost 按鈕（登出；完整按鈕體系在 Batch 3） */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.btn-ghost svg { width: 15px; height: 15px; }
.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 內容區 */
.app-main {
  padding: 28px 40px 40px;
  max-width: 1440px;
}

/* 尊重 prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .nav-key {
    transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
  }
  .nav-key:active { transform: none; }
  .nav-key .nav-led,
  .nav-key .icon-well,
  .btn-ghost {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Batch 3 — 基礎元件：以 token 重映射 Bootstrap 類別
   既有模板不需改 class 即自動 inherit 新語言（同 shadcn 變數重映射思路）
   -------------------------------------------------------------------------- */

/* ===== 按鈕（鍵帽語言） ===== */
.btn {
  --bs-btn-padding-x: 16px;
  --bs-btn-padding-y: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 0;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-raise-sm);
  transition: box-shadow var(--dur-press) var(--ease),
              background-color var(--dur-hover) var(--ease),
              color var(--dur-hover) var(--ease),
              transform var(--dur-press) var(--ease);
}
.btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.btn:active, .btn.active, .btn:first-child:active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-press);
  transform: translateY(1px) scale(.995);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-raise-sm);
}
.btn:disabled, .btn.disabled {
  opacity: .55;
  box-shadow: none;
}
.btn-sm {
  --bs-btn-padding-x: 12px;
  min-height: 34px;
  border-radius: var(--radius-field);
  font-size: 12.5px;
}

/* Primary：品牌藍底、暖白字 */
.btn-primary {
  background: var(--accent);
  color: #FDFBF7;
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--accent-ink);
  color: #FDFBF7;
}
.btn-primary:active, .btn-primary:first-child:active {
  background: var(--accent-ink);
  color: #FDFBF7;
  box-shadow: var(--shadow-press);
}

/* Danger：淡紅底紅字 */
.btn-danger, .btn-outline-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover, .btn-outline-danger:hover,
.btn-danger:active, .btn-outline-danger:active {
  background: var(--danger);
  color: #FDFBF7;
}

/* Success / Warning / Info / Secondary：語意淡底＋主色字 */
.btn-success, .btn-outline-success {
  background: var(--success-soft);
  color: var(--success);
}
.btn-success:hover, .btn-outline-success:hover,
.btn-success:active, .btn-outline-success:active {
  background: var(--success);
  color: #FDFBF7;
}
.btn-warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.btn-warning:hover, .btn-warning:active {
  background: var(--warning);
  color: #FDFBF7;
}
.btn-info {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-info:hover, .btn-info:active {
  background: var(--accent);
  color: #FDFBF7;
}
.btn-secondary, .btn-outline-secondary, .btn-outline-primary, .btn-outline-dark, .btn-dark {
  background: var(--surface);
  color: var(--ink-2);
}
.btn-secondary:hover, .btn-outline-secondary:hover, .btn-outline-primary:hover, .btn-outline-dark:hover, .btn-dark:hover,
.btn-secondary:active, .btn-outline-secondary:active, .btn-outline-primary:active, .btn-outline-dark:active, .btn-dark:active {
  background: var(--surface-2);
  color: var(--ink);
}

/* btn-close（alert / modal 用） */
.btn-close {
  filter: grayscale(1) opacity(.6);
  box-shadow: none;
}
.btn-close:hover { filter: grayscale(1) opacity(1); }

/* ===== 表單控制項（凹槽語言） ===== */
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.form-control, .form-select {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-field);
  background-color: var(--surface-2);
  box-shadow: var(--shadow-press-sm);
  color: var(--ink);
  font-size: 14px;
  transition: box-shadow var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}
textarea.form-control { min-height: auto; }
.form-control::placeholder { color: var(--muted); }
.form-control:focus, .form-select:focus {
  background-color: var(--surface-2);
  border: 0;
  box-shadow: var(--shadow-press-sm),
              inset 0 0 0 1.5px var(--accent),
              0 0 0 3px var(--accent-soft);
  color: var(--ink);
  outline: none;
}
.form-control:disabled, .form-select:disabled,
.form-control[readonly] {
  background-color: var(--sunken);
  color: var(--muted);
  box-shadow: none;
  opacity: 1;
}
.form-control.is-invalid, .form-select.is-invalid {
  box-shadow: var(--shadow-press-sm), inset 0 0 0 1.5px var(--danger);
}
.invalid-feedback { color: var(--danger); font-size: 12px; }
.form-text { color: var(--muted); font-size: 12px; }
.form-check-input {
  background-color: var(--surface-2);
  border-color: var(--hairline);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-group-text {
  background: var(--sunken);
  border: 0;
  color: var(--muted);
  border-radius: var(--radius-field);
}

/* ===== 卡片（L1 浮起容器） ===== */
.card {
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
  color: var(--ink);
}
.card-body { padding: 22px; }
.card-title { font-size: 17px; font-weight: 600; color: var(--ink); }
.card-header, .card-footer {
  background: transparent;
  border-color: var(--hairline);
  padding: 14px 22px;
}

/* ===== 資料表（內容平鋪 L0） ===== */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--hairline);
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-hover-color: var(--ink);
  --bs-table-striped-bg: transparent;
  --bs-table-active-bg: var(--surface-2);
  color: var(--ink);
  margin-bottom: 0;
}
.table > thead > tr > th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
  padding: 10px 12px;
  white-space: nowrap;
}
.table > tbody > tr > td {
  height: 52px;
  vertical-align: middle;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table a { color: var(--accent); text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* ===== 狀態標籤（Badge / Pill） ===== */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
}
.badge.bg-success { background: var(--success-soft) !important; color: var(--success); }
.badge.bg-danger  { background: var(--danger-soft)  !important; color: var(--danger); }
.badge.bg-warning { background: var(--warning-soft) !important; color: var(--warning); }
.badge.bg-info    { background: var(--accent-soft)  !important; color: var(--accent); }
.badge.bg-primary { background: var(--accent-soft)  !important; color: var(--accent); }
.badge.bg-secondary { background: var(--sunken)     !important; color: var(--muted); }
.badge.bg-dark    { background: var(--sunken)       !important; color: var(--ink-2); }
.badge.bg-light   { background: var(--surface-2)    !important; color: var(--ink-2); }

/* ===== 提示列（Toast 式：淡底＋左側 3px 語意色條） ===== */
.alert {
  position: relative;
  border: 0;
  border-radius: var(--radius-key);
  background: var(--surface-2);
  box-shadow: var(--shadow-raise-sm);
  color: var(--ink-2);
  font-size: 13px;
  padding: 14px 18px 14px 21px;
}
.alert::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--muted);
}
.alert-success::before { background: var(--success); }
.alert-success { color: var(--success); }
.alert-warning::before { background: var(--warning); }
.alert-warning { color: var(--warning); }
.alert-danger::before { background: var(--danger); }
.alert-danger { color: var(--danger); }
.alert-info::before { background: var(--accent); }
.alert-info { color: var(--accent); }
.alert .btn { box-shadow: var(--shadow-raise-sm); }
.alert strong { color: inherit; }

/* ===== 對話框（Dialog） ===== */
.modal-content {
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-raise);
  color: var(--ink);
}
.modal-backdrop {
  --bs-backdrop-bg: #1F1C17;
  --bs-backdrop-opacity: .35;
  backdrop-filter: blur(2px);
}
.modal-header { border-bottom: 1px solid var(--hairline); padding: 18px 24px; }
.modal-title { font-size: 18px; font-weight: 600; color: var(--ink); }
.modal-body { padding: 20px 24px; }
.modal-footer { border-top: 1px solid var(--hairline); padding: 14px 24px; }

/* ===== 下拉面板 ===== */
.dropdown-menu {
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow-raise);
  padding: 6px;
}
.dropdown-item {
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface);
  color: var(--ink);
}

/* ===== 分頁 ===== */
.pagination { gap: 6px; }
.page-link {
  border: 0;
  border-radius: var(--radius-field) !important;
  background: var(--surface);
  box-shadow: var(--shadow-raise-sm);
  color: var(--ink-2);
  min-width: 36px;
  text-align: center;
}
.page-link:hover { background: var(--surface-2); color: var(--ink); }
.page-item.active .page-link {
  background: var(--accent);
  color: #FDFBF7;
  box-shadow: var(--shadow-press-sm);
}
.page-item.disabled .page-link {
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
}

/* ===== 空狀態（EmptyState） ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 24px;
  border: 1.5px dashed var(--hairline);
  border-radius: 18px;
  text-align: center;
}
.empty-state .empty-icon {
  color: var(--muted);
  opacity: .8;
  margin-bottom: 6px;
}
.empty-state .empty-icon svg { width: 40px; height: 40px; }
.empty-state .empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}
.empty-state .empty-desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 380px;
}
.empty-state .empty-action { margin-top: 10px; }

/* ===== 骨架載入（skeleton） ===== */
.skeleton {
  border-radius: 8px;
  background: var(--sunken);
  animation: skeleton-pulse 1.6s var(--ease) infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* ===== 全站 focus-visible 補強（連結） ===== */
a:focus-visible, .page-link:focus-visible, .dropdown-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== 尊重 prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
  .btn, .form-control, .form-select, .btn-ghost {
    transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
  }
  .btn:active, .btn.active, .btn:first-child:active { transform: none; }
  .skeleton { animation: none; opacity: .7; }
}

/* --------------------------------------------------------------------------
   Batch 4 — 儀表板：頁首、分段控制器、最近訂單清單
   -------------------------------------------------------------------------- */

/* 頁首 */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.page-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 分段控制器（鍵帽式：外層 sunken 凹槽，選中項 surface 浮起） */
.seg-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-key);
  background: var(--sunken);
  box-shadow: var(--shadow-press-sm);
}
.seg-control .seg-item {
  border: 0;
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  height: 32px;
  padding: 0 14px;
  white-space: nowrap;
  transition: box-shadow var(--dur-press) var(--ease),
              background-color var(--dur-hover) var(--ease),
              color var(--dur-hover) var(--ease);
}
.seg-control .seg-item:hover { color: var(--ink); }
.seg-control .seg-item[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: var(--shadow-raise-sm);
  color: var(--accent);
  font-weight: 600;
}
.seg-control .seg-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 最近訂單清單（清單式，非表格） */
.mini-list {
  display: flex;
  flex-direction: column;
}
.mini-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-field);
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: inherit;
  transition: background-color var(--dur-hover) var(--ease);
}
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--surface-2); }
.mini-row .mini-main { flex: 1; min-width: 0; line-height: 1.4; }
.mini-row .mini-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-row .mini-sub {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-row .mini-amount {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}
a.mini-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* 圖表區空狀態包裝 */
.chart-empty { padding: 24px 0 8px; }

@media (prefers-reduced-motion: reduce) {
  .seg-control .seg-item, .mini-row {
    transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
  }
}

/* --------------------------------------------------------------------------
   Batch 5 — 列表頁：表格卡與區塊標題
   -------------------------------------------------------------------------- */
.table-card { border-radius: 18px; }
.table-card .card-body { padding: 10px 16px 14px; }
.table-card .table > tbody > tr:last-child > td { border-bottom: 0; }
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 24px 0 12px;
}
.empty-state--in-table {
  border: 0;
  padding: 32px 16px;
}

/* --------------------------------------------------------------------------
   Batch 6 — 全域驗收：表格列語意色重映射＋響應式側欄
   -------------------------------------------------------------------------- */

/* 表格列語意色（低庫存/停用/快到期）：淡底訊號，不用高飽和色 */
.table > tbody > tr.table-warning > td {
  --bs-table-bg: var(--warning-soft);
  --bs-table-hover-bg: var(--warning-soft);
  background: var(--warning-soft);
}
.table > tbody > tr.table-secondary > td {
  --bs-table-bg: var(--sunken);
  --bs-table-hover-bg: var(--sunken);
  background: var(--sunken);
  color: var(--muted);
}

/* ===== 響應式：< 992px 側欄改為抽屜 ===== */
.nav-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1050;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-key);
  background: var(--surface);
  box-shadow: var(--shadow-raise-sm);
  color: var(--ink-2);
  place-items: center;
  transition: box-shadow var(--dur-press) var(--ease), transform var(--dur-press) var(--ease);
}
.nav-toggle:active { box-shadow: var(--shadow-press); transform: translateY(1px); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-toggle svg { width: 20px; height: 20px; }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(31, 28, 23, .35);
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1045;
    transform: translateX(-105%);
    transition: transform var(--dur-hover) var(--ease);
    box-shadow: none;
  }
  body.nav-open .app-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-raise);
  }
  .nav-toggle { display: grid; }
  body.nav-open .nav-backdrop { display: block; }
  .app-main { padding: 72px 20px 32px; }
}
@media (min-width: 992px) and (max-width: 1279.98px) {
  .app-main { padding: 28px 28px 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar, .nav-toggle { transition: none; }
}

/* --------------------------------------------------------------------------
   Dashboard 圖表卡：圓餅圖圖例＋水平長條（分類營收）
   色票為圖表專用語意延伸，仍集中於 token。
   -------------------------------------------------------------------------- */
:root {
  --chart-1: #2B54D6;  /* accent 藍 */
  --chart-2: #1C7A54;  /* success 綠 */
  --chart-3: #A26A16;  /* warning 琥珀 */
  --chart-4: #B23A32;  /* danger 紅 */
  --chart-5: #6C5CE7;  /* 補色紫 */
  --chart-6: #0E7C86;  /* 補色青 */
  --chart-7: #7A746A;  /* muted 灰 */
}

/* 圓餅圖區：左圖右圖例 */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-canvas {
  position: relative;
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  margin: 0 auto;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}
.donut-center .donut-total {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.donut-center .donut-total-label {
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.donut-legend {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.legend-row .legend-label { flex: 1; }
.legend-row .legend-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* 水平長條（分類營收 TOP5）：sunken 凹槽軌＋浮起填充 */
.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hbar-row .hbar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.hbar-row .hbar-name {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-row .hbar-amount {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}
.hbar-row .hbar-pct {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.hbar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--sunken);
  box-shadow: var(--shadow-press-sm);
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 600ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .hbar-fill { transition: none; }
}
