/* ============================================================
   style.css — 全局樣式設計系統
   POS 管理系統 | Apple / iOS 高級灰色風格
   
   設計規範：
   - 色系：iOS 系統灰階搭配藍色強調色
   - 字體：SF Pro Display / Helvetica Neue（Apple 原生字體堆疊）
   - 無任何 emoji，圖示全部使用 SVG
   - 字體大，觸控友善，適配手機直式與桌面
   - 所有動畫使用 ease-in-out，符合 iOS 流暢感
   ============================================================ */


/* ============================================================
   1. CSS 自訂屬性（設計 Token）
   所有顏色、間距、字體皆由此統一管理
   ============================================================ */
:root {
  /* --- 主要背景色系（iOS 分層灰） --- */
  --color-bg-primary:        #F2F2F7;   /* iOS 主背景灰 */
  --color-bg-secondary:      #FFFFFF;   /* 卡片/表格背景 */
  --color-bg-tertiary:       #E5E5EA;   /* 輸入框/分隔背景 */
  --color-bg-grouped:        #EFEFF4;   /* 分組區塊背景 */
  --color-bg-elevated:       #FFFFFF;   /* 浮起元件（Modal、卡片） */
  --color-bg-overlay:        rgba(0, 0, 0, 0.45); /* 遮罩層 */

  /* --- 文字色系 --- */
  --color-text-primary:      #1C1C1E;   /* 主要文字 */
  --color-text-secondary:    #636366;   /* 次要文字 */
  --color-text-tertiary:     #8E8E93;   /* 說明文字/佔位符 */
  --color-text-quaternary:   #AEAEB2;   /* 禁用文字 */
  --color-text-inverse:      #FFFFFF;   /* 深色背景上的文字 */

  /* --- 強調色（iOS 藍） --- */
  --color-accent:            #007AFF;   /* 主要強調藍 */
  --color-accent-hover:      #0066D6;   /* 懸停狀態藍 */
  --color-accent-pressed:    #0051A8;   /* 按下狀態藍 */
  --color-accent-subtle:     rgba(0, 122, 255, 0.12); /* 淡藍背景 */

  /* --- 系統狀態色 --- */
  --color-success:           #34C759;   /* 庫存充足 / 成功 */
  --color-success-bg:        rgba(52, 199, 89, 0.12);
  --color-warning:           #FF9F0A;   /* 低庫存 / 警告 */
  --color-warning-bg:        rgba(255, 159, 10, 0.12);
  --color-danger:            #FF3B30;   /* 缺貨 / 危險 */
  --color-danger-bg:         rgba(255, 59, 48, 0.12);
  --color-info:              #5AC8FA;   /* 資訊提示 */

  /* --- 分隔線與邊框 --- */
  --color-border:            #C6C6C8;   /* 標準邊框 */
  --color-border-light:      #E5E5EA;   /* 輕量邊框 */
  --color-border-focus:      #007AFF;   /* 聚焦邊框 */
  --color-separator:         rgba(60, 60, 67, 0.18); /* iOS 分隔線 */

  /* --- 陰影（iOS 風格多層陰影） --- */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:    0 12px 32px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.07);
  --shadow-xl:    0 24px 56px rgba(0,0,0,0.14), 0 8px 20px rgba(0,0,0,0.09);

  /* --- 字體堆疊（Apple 原生優先） --- */
  --font-primary: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                  'Helvetica Neue', 'Arial', sans-serif;
  --font-mono:    'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;

  /* --- 字體大小（觸控友善，整體放大） --- */
  --text-xs:     13px;
  --text-sm:     15px;
  --text-base:   17px;   /* iOS 標準正文大小 */
  --text-lg:     19px;
  --text-xl:     22px;
  --text-2xl:    26px;
  --text-3xl:    32px;
  --text-4xl:    40px;
  --text-hero:   56px;

  /* --- 行高 --- */
  --leading-tight:  1.2;
  --leading-normal: 1.5;
  --leading-relaxed:1.75;

  /* --- 字重 --- */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* --- 圓角（iOS 風格大圓角） --- */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* --- 間距系統 --- */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-7:   28px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;
  --space-16:  64px;

  /* --- 動畫時長 --- */
  --duration-fast:   150ms;
  --duration-base:   250ms;
  --duration-slow:   400ms;
  --duration-slower: 600ms;
  --easing-ios:      cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --easing-spring:   cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* --- 版面高度 --- */
  --header-height:   60px;
  --nav-height:      56px;
  --safe-bottom:     env(safe-area-inset-bottom, 0px); /* iPhone 底部安全區 */
}


/* ============================================================
   2. CSS Reset 與基礎設定
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* 消除手機點擊藍框 */
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%; /* 防止手機自動調整字體大小 */
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
  min-height: 100dvh; /* 動態視窗高度（iOS Safari 兼容） */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;  /* macOS 字體平滑 */
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  font-family: var(--font-primary);
  cursor: pointer;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

input, textarea, select {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  border: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

a {
  text-decoration: none;
  color: var(--color-accent);
}

ul, ol {
  list-style: none;
}


/* ============================================================
   3. 視圖切換系統
   所有畫面（.view）預設隱藏，由 ui.js 控制顯示
   ============================================================ */
.view {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--easing-ios);
}

/* 畫面顯示中（由 ui.js 加入 .view--active 類） */
.view--active {
  display: flex;
  flex-direction: column;
}

/* 淡入完成（由 ui.js 在 display 後下一幀加入 .view--visible） */
.view--visible {
  opacity: 1;
}


/* ============================================================
   4. 登入頁面（#view-login）
   ============================================================ */
#view-login {
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-primary);
  padding: var(--space-6);
  min-height: 100vh;
  min-height: 100dvh;
}

/* 登入卡片容器 */
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-2xl);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* 登入頁 Logo / 標題區 */
.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--color-text-primary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo svg {
  width: 40px;
  height: 40px;
  fill: var(--color-text-inverse);
}

.login-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-regular);
}

/* 語言選擇器（登入頁頂部） */
.login-lang-selector {
  display: flex;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  gap: var(--space-1);
}

.login-lang-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  transition: all var(--duration-fast) var(--easing-ios);
  text-align: center;
}

.login-lang-btn:hover {
  background: rgba(0,0,0,0.05);
}

.login-lang-btn.active {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

/* 表單區域 */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 輸入框群組 */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-tertiary);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--easing-ios),
              background var(--duration-fast) var(--easing-ios);
}

.form-input::placeholder {
  color: var(--color-text-quaternary);
}

.form-input:focus {
  background: var(--color-bg-secondary);
  border-color: var(--color-border-focus);
}

.form-input.error {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* 錯誤訊息 */
.form-error {
  font-size: var(--text-sm);
  color: var(--color-danger);
  font-weight: var(--weight-medium);
  display: none;
}

.form-error.visible {
  display: block;
}


/* ============================================================
   5. 按鈕系統
   ============================================================ */

/* 主要按鈕（藍色填充） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  transition: all var(--duration-fast) var(--easing-ios);
  white-space: nowrap;
  user-select: none;
}

.btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* 主要藍色按鈕 */
.btn--primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.30);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.38);
  transform: translateY(-1px);
}

.btn--primary:active {
  background: var(--color-accent-pressed);
  box-shadow: none;
  transform: translateY(0);
}

/* 次要按鈕（灰色邊框） */
.btn--secondary {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-text-secondary);
}

.btn--secondary:active {
  background: var(--color-bg-grouped);
}

/* 危險按鈕（紅色） */
.btn--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1.5px solid rgba(255, 59, 48, 0.25);
}

.btn--danger:hover {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: var(--color-danger);
}

/* 幽靈按鈕（透明） */
.btn--ghost {
  background: transparent;
  color: var(--color-accent);
}

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

/* 按鈕大小變體 */
.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn--sm svg {
  width: 16px;
  height: 16px;
}

.btn--lg {
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-xl);
  border-radius: var(--radius-lg);
}

.btn--lg svg {
  width: 24px;
  height: 24px;
}

/* 全寬按鈕 */
.btn--full {
  width: 100%;
}

/* 禁用狀態 */
.btn:disabled,
.btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 載入中狀態（旋轉動畫） */
.btn--loading {
  pointer-events: none;
  position: relative;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}


/* ============================================================
   6. 歡迎畫面（#view-welcome）
   登入後全螢幕顯示，然後淡出進入首頁
   ============================================================ */
#view-welcome {
  align-items: center;
  justify-content: center;
  background: var(--color-text-primary);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.welcome-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.welcome-logo {
  width: 96px;
  height: 96px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: welcome-logo-in 0.6s var(--easing-spring) both;
}

.welcome-logo svg {
  width: 52px;
  height: 52px;
  fill: var(--color-text-inverse);
}

.welcome-text {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-inverse);
  letter-spacing: -0.5px;
  animation: welcome-text-in 0.6s var(--easing-ios) 0.2s both;
}

.welcome-sub {
  font-size: var(--text-lg);
  color: rgba(255,255,255,0.55);
  animation: welcome-text-in 0.6s var(--easing-ios) 0.35s both;
}

@keyframes welcome-logo-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes welcome-text-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
   7. 主應用殼（登入後的整體版面）
   ============================================================ */

/* 主容器（Header + 內容） */
#view-main {
  flex-direction: column;
  background: var(--color-bg-primary);
}

/* 頂部 Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242, 242, 247, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-separator);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
}

.app-header__title {
  flex: 1;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.3px;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Header 圖示按鈕 */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-text-secondary);
  transition: background var(--duration-fast) var(--easing-ios);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.icon-btn:active {
  background: var(--color-border);
}

/* 底部分頁導航（手機版） */
.app-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-separator);
  display: flex;
  padding-bottom: var(--safe-bottom);
}

.tab-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-2) var(--space-2) var(--space-3);
  min-height: var(--nav-height);
  cursor: pointer;
  color: var(--color-text-tertiary);
  transition: color var(--duration-fast) var(--easing-ios);
}

.tab-bar__item svg {
  width: 26px;
  height: 26px;
  transition: transform var(--duration-fast) var(--easing-spring);
}

.tab-bar__item span {
  font-size: 11px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.2px;
}

.tab-bar__item.active {
  color: var(--color-accent);
}

.tab-bar__item.active svg {
  transform: scale(1.05);
}

/* 桌面版側邊導航（寬度 >= 768px 時顯示） */
.app-sidebar {
  display: none; /* 手機預設隱藏，桌面由 media query 顯示 */
  width: 240px;
  min-height: 100%;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border-light);
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  gap: var(--space-2);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-ios);
}

.sidebar__item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar__item:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.sidebar__item.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

/* 主內容區域 */
.app-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 每個模組的內容捲動區域 */
.module-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-5));
  /* 底部留出 tab bar 空間 */
}


/* ============================================================
   8. 倉庫管理模組（#module-inventory）
   ============================================================ */

/* 模組頂部工具列 */
.module-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.module-toolbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.module-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* 搜尋輸入框 */
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.search-input-wrap svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) + 18px + var(--space-2));
  background: var(--color-bg-elevated);
  border: 1.5px solid var(--color-border-light);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast);
}

.search-input:focus {
  border-color: var(--color-border-focus);
  background: var(--color-bg-secondary);
}

/* 分類篩選標籤列 */
.category-filter {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-bottom: var(--space-4);
}

.category-filter::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  background: var(--color-bg-elevated);
  border: 1.5px solid var(--color-border-light);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-ios);
  white-space: nowrap;
}

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

.category-chip.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
}

/* 倉庫表格容器 */
.inventory-table-wrap {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* 表格 */
.inventory-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px; /* 強制橫向捲動，保持欄位完整 */
}

.inventory-table thead {
  background: var(--color-bg-grouped);
  border-bottom: 1px solid var(--color-border-light);
}

.inventory-table th {
  padding: var(--space-4) var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.inventory-table tbody tr {
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--duration-fast);
}

.inventory-table tbody tr:last-child {
  border-bottom: none;
}

.inventory-table tbody tr:hover {
  background: var(--color-bg-grouped);
}

.inventory-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  vertical-align: middle;
}

/* 商品圖片縮圖 */
.product-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: transform var(--duration-fast);
}

.product-thumb:hover {
  transform: scale(1.06);
}

/* 商品圖片上傳按鈕（未有圖片時） */
.product-thumb-upload {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
  border: 1.5px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  color: var(--color-text-quaternary);
}

.product-thumb-upload:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.product-thumb-upload svg {
  width: 20px;
  height: 20px;
}

/* 行內輸入框（表格內） */
.table-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  min-width: 80px;
  transition: all var(--duration-fast);
}

.table-input:hover {
  border-color: var(--color-border);
  background: var(--color-bg-tertiary);
}

.table-input:focus {
  border-color: var(--color-border-focus);
  background: var(--color-bg-secondary);
}

/* 庫存狀態標籤 */
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.stock-badge--ok {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.stock-badge--low {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.stock-badge--out {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* 表格操作按鈕 */
.table-action-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-text-tertiary);
  transition: all var(--duration-fast);
}

.table-action-btn svg {
  width: 18px;
  height: 18px;
}

.table-action-btn:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* 新增行按鈕（表格底部） */
.add-row-btn {
  width: 100%;
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: transparent;
  border-top: 1px solid var(--color-border-light);
  color: var(--color-accent);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast);
}

.add-row-btn svg {
  width: 20px;
  height: 20px;
}

.add-row-btn:hover {
  background: var(--color-accent-subtle);
}


/* ============================================================
   9. POS 販售模式模組（#module-pos）
   ============================================================ */

/* POS 整體布局（商品區 + 購物車區） */
.pos-layout {
  display: flex;
  gap: var(--space-5);
  height: calc(100vh - var(--header-height) - var(--nav-height) - var(--safe-bottom));
  overflow: hidden;
}

/* 商品網格區域 */
.pos-products {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-products__scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-1) var(--space-1);
}

/* 商品網格：手機 2欄，桌面 4欄 */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

/* 商品卡片 */
.pos-card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1.5px solid var(--color-border-light);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-ios);
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.pos-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.pos-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

/* 缺貨卡片 */
.pos-card--out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* 缺貨標示貼片 */
.pos-card__out-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  background: var(--color-danger);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
}

/* 商品圖片 */
.pos-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--color-bg-tertiary);
}

/* 商品圖片佔位（無圖片時） */
.pos-card__image-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-quaternary);
}

.pos-card__image-placeholder svg {
  width: 40px;
  height: 40px;
}

/* 商品資訊區 */
.pos-card__info {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pos-card__name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
  /* 超過兩行截斷 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-card__price {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
}

.pos-card__stock {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* 購物車區域（桌面版右欄，手機版底部 Sheet） */
.pos-cart {
  width: 340px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.pos-cart__header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pos-cart__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.pos-cart__count {
  background: var(--color-accent);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 購物車商品列表 */
.pos-cart__items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cart-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cart-item__name {
  flex: 1;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 數量控制器 */
.qty-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  padding: 2px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.qty-btn:hover {
  background: var(--color-accent);
  color: white;
}

.qty-value {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  min-width: 20px;
  text-align: center;
}

.cart-item__price {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  flex-shrink: 0;
  min-width: 70px;
  text-align: right;
}

/* 購物車底部：合計 + 操作 */
.pos-cart__footer {
  padding: var(--space-5);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 付款方式選擇 */
.payment-method {
  display: flex;
  gap: var(--space-2);
}

.payment-chip {
  flex: 1;
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1.5px solid var(--color-border-light);
  color: var(--color-text-secondary);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast);
}

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

.payment-chip.active {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

/* 合計金額列 */
.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.cart-total__label {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
}

.cart-total__amount {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
}

/* 購物車操作按鈕組 */
.cart-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 手機版 POS 購物車 Sheet（底部滑入） */
.pos-cart-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 200;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--easing-ios);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.pos-cart-sheet.open {
  transform: translateY(0);
}

.pos-cart-sheet__handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto;
  flex-shrink: 0;
}

/* 手機版 POS 購物車觸發按鈕 */
.pos-cart-trigger {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4));
  right: var(--space-5);
  z-index: 150;
  width: 60px;
  height: 60px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  color: white;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--easing-spring);
}

.pos-cart-trigger:active {
  transform: scale(0.92);
}

.pos-cart-trigger svg {
  width: 28px;
  height: 28px;
}

.pos-cart-trigger__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-bg-primary);
}


/* ============================================================
   10. 後台資訊模組（#module-dashboard）
   ============================================================ */

/* 統計卡片網格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-card__sub {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* 時間範圍切換器 */
.time-range-tabs {
  display: flex;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  margin-bottom: var(--space-5);
  width: fit-content;
}

.time-range-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-ios);
  white-space: nowrap;
}

.time-range-tab:hover {
  color: var(--color-text-primary);
}

.time-range-tab.active {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

/* 圖表容器 */
.chart-card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
}

.chart-card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

/* 訂單列表 */
.orders-section {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.orders-section__header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.orders-section__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* 訂單列項 */
.order-item {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.order-item:last-child {
  border-bottom: none;
}

.order-item:hover {
  background: var(--color-bg-grouped);
}

.order-item__date {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.order-item__info {
  flex: 1;
  min-width: 0;
}

.order-item__id {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

.order-item__items-count {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.order-item__amount {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* 付款方式標籤（後台訂單中） */
.payment-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}


/* ============================================================
   11. Modal 通用樣式（收據、設定等）
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--color-bg-overlay);
  display: flex;
  align-items: flex-end;   /* 手機版：從底部滑入 */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--easing-ios);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  width: 100%;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(30px);
  transition: transform var(--duration-slow) var(--easing-ios);
  box-shadow: var(--shadow-xl);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal__handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-1);
  flex-shrink: 0;
}

.modal__header {
  padding: var(--space-3) var(--space-6) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.modal__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--duration-fast);
}

.modal__close:hover {
  background: var(--color-border);
}

.modal__close svg {
  width: 16px;
  height: 16px;
}

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
}

.modal__footer {
  padding: var(--space-4) var(--space-6) calc(var(--space-4) + var(--safe-bottom));
  border-top: 1px solid var(--color-border-light);
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* 桌面版 Modal（置中顯示） */
@media (min-width: 768px) {
  .modal-overlay {
    align-items: center;
  }

  .modal {
    border-radius: var(--radius-2xl);
    max-width: 560px;
    max-height: 85vh;
    transform: translateY(20px) scale(0.97);
  }

  .modal-overlay.open .modal {
    transform: translateY(0) scale(1);
  }

  .modal__handle {
    display: none;
  }
}


/* ============================================================
   12. 收據樣式（在 Modal 內顯示）
   ============================================================ */
.receipt {
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  font-size: var(--text-base);
}

.receipt__header {
  text-align: center;
  padding-bottom: var(--space-5);
  border-bottom: 1px dashed var(--color-border);
  margin-bottom: var(--space-5);
}

.receipt__shop-name {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.3px;
}

.receipt__order-id {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}

.receipt__meta {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

.receipt__items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.receipt__item {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.receipt__item-name {
  flex: 1;
  font-weight: var(--weight-medium);
}

.receipt__item-qty {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.receipt__item-price {
  font-weight: var(--weight-semibold);
  text-align: right;
  min-width: 80px;
  flex-shrink: 0;
}

.receipt__divider {
  border: none;
  border-top: 1px dashed var(--color-border);
  margin: var(--space-4) 0;
}

.receipt__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.receipt__total-label {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.receipt__total-amount {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.5px;
}

.receipt__payment {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
}


/* ============================================================
   13. 設定面板（語言 / 貨幣）
   ============================================================ */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
}

.settings-section__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 var(--space-1) var(--space-2);
}

.settings-row {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-md);
  gap: var(--space-3);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.settings-row:hover {
  background: var(--color-bg-grouped);
}

.settings-row__label {
  flex: 1;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.settings-row__value {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

.settings-row svg.chevron {
  width: 18px;
  height: 18px;
  color: var(--color-text-quaternary);
  flex-shrink: 0;
}


/* ============================================================
   14. 通用工具類別
   ============================================================ */

/* 載入中 Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

.spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner--lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 全頁載入遮罩 */
.full-page-loader {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
}

.full-page-loader__text {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

/* Toast 通知 */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - var(--space-10));
  max-width: 400px;
}

.toast {
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--duration-base) var(--easing-spring) both;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toast--success { background: var(--color-success); }
.toast--warning { background: var(--color-warning); }
.toast--error   { background: var(--color-danger); }

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

.toast.removing {
  animation: toast-out var(--duration-base) var(--easing-ios) forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* 空狀態顯示 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--color-text-quaternary);
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
}

.empty-state__sub {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
  max-width: 280px;
  line-height: var(--leading-relaxed);
}

/* 分隔線 */
.divider {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-5) 0;
}

/* 隱藏元素 */
.hidden {
  display: none !important;
}

/* 文字截斷 */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ============================================================
   15. 響應式斷點
   手機優先，桌面版覆蓋
   ============================================================ */

/* 平板 / 桌面（>= 768px） */
@media (min-width: 768px) {

  /* 桌面：隱藏底部 Tab Bar，改用側邊欄 */
  .app-tab-bar {
    display: none;
  }

  .app-sidebar {
    display: flex;
  }

  /* 桌面：內容不需留底部 Tab Bar 空間 */
  .module-scroll {
    padding-bottom: var(--space-8);
  }

  /* 桌面：POS 網格 4 欄 */
  .pos-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* 桌面：不顯示購物車浮動按鈕 */
  .pos-cart-trigger {
    display: none;
  }

  /* 桌面：不顯示手機底部購物車 Sheet */
  .pos-cart-sheet {
    display: none;
  }

  /* 桌面：統計卡片 4 欄 */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 大桌面（>= 1280px） */
@media (min-width: 1280px) {
  .pos-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* 小螢幕（< 375px，舊款 iPhone SE 等） */
@media (max-width: 374px) {
  :root {
    --text-base: 16px;
    --text-lg:   18px;
  }

  .pos-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
}


/* ============================================================
   16. 列印樣式（收據列印用）
   ============================================================ */
@media print {
  /* 列印時只顯示收據內容，其他全部隱藏 */
  body > *:not(#print-area) {
    display: none !important;
  }

  #print-area {
    display: block !important;
  }

  .receipt {
    background: white;
    padding: 0;
    font-size: 13px;
  }

  /* 避免分頁時截斷收據 */
  .receipt__items {
    page-break-inside: avoid;
  }
}
