/* ================================================================
   冠興管理系統 V4.0 - 商務毛玻璃風格主題
   設計理念：沉穩商務藍 + 透明毛玻璃 + 統一組件規範
   ================================================================ */

/* ===================== CSS Variables ===================== */
:root {
  /* 主色調 - 沉穩商務藍 */
  --primary: #1a3a5c;
  --primary-light: #2a5a8c;
  --primary-lighter: #4a8bc2;
  --primary-dark: #0f2440;
  --primary-gradient: linear-gradient(135deg, #1a3a5c, #2a5a8c);

  /* 輔助色 */
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #2563eb;

  /* 狀態色 - 柔和版本 */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);

  /* 玻璃態效果 */
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-bg-strong: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --glass-blur: blur(20px);
  --glass-saturate: saturate(180%);

  /* 側邊欄 - 輕量玻璃（匹配內容區域配色） */
  --sidebar-bg: rgba(255, 255, 255, 0.88);
  --sidebar-glass-border: rgba(226, 232, 240, 0.6);
  --sidebar-text: #64748b;
  --sidebar-text-hover: #1e293b;
  --sidebar-active-bg: rgba(59, 130, 246, 0.08);
  --sidebar-active-border: #3b82f6;

  /* 背景 */
  --bg-body: #eef1f5;
  --bg-card: var(--glass-bg-strong);
  --bg-filter: rgba(247, 248, 250, 0.8);

  /* 文字 */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  /* 邊框 */
  --border-color: rgba(226, 232, 240, 0.8);
  --border-light: rgba(226, 232, 240, 0.4);

  /* 圓角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* 陰影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.12);

  /* 過渡 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.35s ease;

  /* 字體 */
  --font-family: 'Inter', 'Segoe UI', 'Microsoft YaHei', -apple-system, sans-serif;
}

/* ===================== Base ===================== */
body {
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================== Glassmorphism Utilities ===================== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.glass-card {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  -webkit-backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}

.glass-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

/* ===================== Layout ===================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-body);
}

/* ===================== Sidebar ===================== */
.sidebar {
  width: 210px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
  color: var(--text-primary);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width var(--transition-slow), transform var(--transition-slow);
  border-right: 1px solid var(--border-color);
  box-shadow: 2px 0 24px rgba(0, 0, 0, 0.04);
}

.sidebar.collapsed {
  width: 64px;
}

/* ===== Sidebar Header ===== */
.sidebar-header {
  padding: 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 68px;
  transition: padding var(--transition-slow);
}

.sidebar-header .logo-mark {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(26, 58, 92, 0.3);
  flex-shrink: 0;
}

.sidebar-header .brand-text {
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar.collapsed .sidebar-header .brand-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-header .brand-text h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.sidebar-header .brand-text .subtitle {
  font-size: 10px;
  color: var(--text-light);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

/* ===== Navigation Menu ===== */
.nav-menu {
  padding: 6px 0;
}

/* ===== Group Title (Parent Menu) ===== */
.nav-group-title {
  padding: 12px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}

.nav-group-title .group-icon {
  font-size: 16px;
  width: 22px;
  min-width: 22px;
  text-align: center;
  color: var(--accent);
  transition: color var(--transition-fast);
}

.nav-group-title .group-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-slow);
}

.nav-group-title .collapse-arrow {
  font-size: 12px;
  color: var(--text-light);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.nav-group-title .collapse-arrow.rotated {
  transform: rotate(90deg);
}

.nav-group-title:hover {
  color: var(--accent);
}

.nav-group-title:hover .group-icon {
  color: var(--accent-light);
}

/* Collapsed state - group title */
.sidebar.collapsed .nav-group-title {
  padding: 14px 0;
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-group-title .group-text,
.sidebar.collapsed .nav-group-title .collapse-arrow {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-group-title .group-icon {
  font-size: 20px;
  width: auto;
  margin: 0;
}

/* ===== Nav Item (Child Menu) ===== */
.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 16px 8px 38px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  gap: 10px;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.06);
  color: var(--accent);
}

.nav-item.active {
  background: var(--info-bg);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 15px;
  width: 22px;
  min-width: 22px;
  text-align: center;
  opacity: 0.65;
  transition: opacity var(--transition-fast);
}

.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.nav-item .nav-text {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-slow);
}

/* Collapsed state - nav item */
.sidebar.collapsed .nav-item {
  padding: 10px 0;
  justify-content: center;
  margin: 2px 4px;
  gap: 0;
}

.sidebar.collapsed .nav-item .nav-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-item .nav-icon {
  font-size: 18px;
  width: auto;
  min-width: 0;
  margin: 0;
  opacity: 0.8;
}

.sidebar.collapsed .nav-item:hover .nav-icon {
  opacity: 1;
}

/* ===== Nav Children Container ===== */
.nav-children {
  display: none;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-children.open {
  display: block;
}

/* Collapsed state - hide all children */
.sidebar.collapsed .nav-children {
  display: none !important;
}

/* ===== Floating menu for collapsed sidebar ===== */
.sidebar-float-menu {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.06);
  padding: 6px 0;
  animation: floatMenuIn 0.15s ease;
  position: fixed;
  pointer-events: auto;
}

/* 左側小三角（連接感） */
.sidebar-float-menu::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 14px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid #ffffff;
  filter: drop-shadow(-2px 0 2px rgba(0, 0, 0, 0.05));
}

@keyframes floatMenuIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

.sidebar-float-menu .nav-item {
  padding: 9px 16px;
  margin: 1px 4px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 13.5px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-float-menu .nav-item:hover {
  background: rgba(59, 130, 246, 0.08);
  color: #3b82f6;
}

.sidebar-float-menu .nav-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  font-weight: 600;
}

.sidebar-float-menu .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  opacity: 0.65;
}

/* ===== Sidebar Scrollbar ===== */
.sidebar::-webkit-scrollbar {
  width: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.15);
  border-radius: 2px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.3);
}
.main-area {
  flex: 1;
  margin-left: 210px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-area {
  margin-left: 64px;
}

/* ===================== Top Header ===================== */
.top-header {
  height: 56px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-light);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toggle-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toggle-btn:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--text-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span {
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.user-info:hover {
  background: rgba(59, 130, 246, 0.06);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(26, 58, 92, 0.3);
}

.user-name {
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 500;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===================== Content Area ===================== */
.content-area {
  flex: 1;
  padding: 24px;
}

/* ===================== Page Card (Unified Glass Card) ===================== */
.page-card {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  -webkit-backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
}

.page-card:hover {
  box-shadow: var(--shadow-lg);
}

/* ★ 2026-08-12：當 .container 同時是 .page-card 時，去掉 .container 的 padding，
   避免標題區左右出現白邊（如 /shift/employees、/purchase/summary-new 等） */
.container.page-card {
  padding: 0;
}

.page-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.04), rgba(26, 58, 92, 0.04));
}

.page-card-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.page-card-header h3 i {
  color: var(--accent);
}

.page-card-body {
  padding: 20px 24px;
}

/* ===================== Filter Bar ===================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--bg-filter);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

/* ===================== Form Controls ===================== */
.form-input,
.form-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: all var(--transition-fast);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
  font-family: var(--font-family);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  background: #fff;
}

.form-input::placeholder {
  color: var(--text-light);
}

.input-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.form-row {
  margin-bottom: 18px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-row label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-row .form-select,
.form-row .form-input {
  width: 100%;
}

select.form-input {
  appearance: auto;
  cursor: pointer;
}

/* ===================== Buttons (Unified) ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-family);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* 彈窗底部按鈕：PC 顯示全名，手機端切換為簡寫 */
.btn-label-full { display: inline; }
.btn-label-sm { display: none; }

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(26, 58, 92, 0.35);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}

.btn-accent:hover {
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff;
}

.btn-info {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: #fff;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.04);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-white {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(4px);
}

.btn-white:hover {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

/* ===================== Table ===================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  background: rgba(247, 248, 250, 0.8);
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: center;
  border-bottom: 1.5px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* 大屏：表頭顯示完整標題；小屏下由 ≤768px 媒體查詢切換為 .th-short */
.th-full { display: inline; }
.th-short { display: none; }

/* 內容單元格：長字段在大屏也允許省略（可選，用於單號等） */
.cell-ellipsis {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  text-align: center;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table.compact thead th {
  padding: 8px 12px;
  font-size: 11.5px;
  text-align: center;
}

.data-table.compact tbody td {
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}

.data-table tfoot td {
  padding: 10px 16px;
  background: rgba(247, 248, 250, 0.5);
  font-weight: 600;
  border-top: 1.5px solid var(--border-color);
  text-align: center;
}

/* ===================== Status Tags ===================== */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.status-tag.status-on,
.status-1 {
  background: var(--success-bg);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.2);
}

.status-tag.status-off,
.status-0 {
  background: var(--warning-bg);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.2);
}

.status--1 {
  background: var(--danger-bg);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.2);
}

.status-2 {
  background: var(--info-bg);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.2);
}

.status-3 {
  background: var(--success-bg);
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.2);
}

/* ===================== Role / Source Tags ===================== */
.role-tag,
.source-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.15);
  background: var(--info-bg);
  color: var(--accent-dark);
}

.source-0 {
  background: var(--success-bg);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.2);
}

.source-1 {
  background: var(--info-bg);
  color: var(--accent-dark);
  border-color: rgba(59, 130, 246, 0.2);
}

.source-2 {
  background: var(--warning-bg);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.2);
}

.source-3 {
  background: var(--danger-bg);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.2);
}

.source-4 {
  background: rgba(139, 92, 246, 0.1);
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.2);
}

.source-5 {
  background: rgba(20, 184, 166, 0.1);
  color: #0d9488;
  border-color: rgba(20, 184, 166, 0.2);
}

/* ===================== Pagination ===================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}

.pagination .total {
  color: var(--text-light);
  font-size: 13px;
  margin-right: 12px;
}

/* ===================== Loading ===================== */
/* 用 body 选择器提高优先级，覆盖页面内 <style> 中的同名规则 */
body .loading-spinner {
  display: block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(59, 130, 246, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
/* td 内加载圈也居中（覆盖有些页面 td 默认左对齐的情况） */
body .data-table td .loading-spinner,
body .data-table th .loading-spinner,
body table td .loading-spinner {
  display: block;
  margin: 0 auto;
}
/* 表格内加载中通用容器——spinner 和文字垂直居中、整体水平居中 */
.loading-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
/* 全局修正：表格内 colspan td 加载中或空状态时让内容垂直居中、整体居中 */
body .data-table td.text-center .loading-spinner,
body table td.text-center .loading-spinner {
  display: block;
  margin: 0 auto 10px;
}
/* 只针对包含 loading-spinner 的 td 用 flex */
.data-table td.text-center:has(> .loading-spinner),
table td.text-center:has(> .loading-spinner) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* colspan td 始終保持 table-cell，讓 colspan 寬度算法正常計算撐滿整行 */
html body .data-table td[colspan],
html body table td[colspan] {
  display: table-cell !important;
}
.loading-cell .loading-text {
  font-size: 13px;
  color: var(--text-light, #94a3b8);
}

/* ===================== 統一空狀態 / 加載中樣式（全局标杆） ===================== */
.no-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light, #94a3b8);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  min-height: 220px;
}
.no-data .icon,
.no-data .empty-icon {
  font-size: 48px;
  opacity: 0.4;
  line-height: 1;
}
.no-data .loading-spinner { margin: 0; }
.no-data .loading-text { font-size: 14px; color: var(--text-light, #94a3b8); }

/* 表格內 td 使用 no-data / empty-state 時的兼容 */
.data-table td.no-data,
.data-table td.empty-state,
table td.no-data,
table td.empty-state {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  padding: 40px 20px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  border: none;
  min-height: auto;
}

.loading-spinner.blue {
  border-color: rgba(59, 130, 246, 0.12);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================== Link ===================== */
.link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ===================== Modal (Glass Style) ===================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-nested {
  z-index: 200;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-box {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 850px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

.modal-lg {
  max-width: 1200px;
}

/* ★ 2026-08-12：Element Plus el-dialog 統一毛玻璃 + 圓角，與自定義 .modal-box 一致 */
.el-dialog {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  border-radius: 18px !important;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12) !important;
  overflow: hidden !important;
  /* ★ 2026-08-12：限制最大高度，內容過長時 body 內部滾動 */
  max-height: 88vh !important;
  margin: 5vh auto !important;
  display: flex !important;
  flex-direction: column !important;
}
.el-dialog__header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.04), rgba(26, 58, 92, 0.04)) !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
  margin: 0 !important;
  padding: 14px 20px !important;
  flex: 0 0 auto !important;
}
.el-dialog__title {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #1e293b !important;
}
.el-dialog__body {
  padding: 16px 20px !important;
  /* ★ 2026-08-12：body 撐滿剩餘高度並內部滾動 */
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  max-height: none !important;
}
.el-dialog__footer {
  padding: 12px 20px !important;
  border-top: 1px solid rgba(226, 232, 240, 0.8) !important;
  flex: 0 0 auto !important;
}
.el-dialog__headerbtn { top: 14px !important; right: 16px !important; }
.el-dialog__headerbtn .el-dialog__close { color: #64748b !important; font-size: 16px !important; }

.modal-sm {
  max-width: 460px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3,
.modal-header h4 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.modal-header h3 i,
.modal-header h4 i {
  color: var(--accent);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
/* 彈窗內有下拉選項打開時，解除 modal-body 的 overflow 限制，避免下拉被裁切 */
@supports selector(:has(*)) {
  .modal-body:has(.dropdown-list) { overflow: visible; }
}
/* 舊瀏覽器不支援 :has()（舊 Android WebView/微信等）：
   下拉打開時由頁面 JS 為 modal-body 加 dd-open class，同樣解除裁切 */
.modal-body.dd-open { overflow: visible; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(247, 248, 250, 0.5);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ===================== View Info Grid ===================== */
.view-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-filter);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.view-info-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-label {
  font-size: 13px;
  color: var(--text-light);
}

.view-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.view-value.sn {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.view-footer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 16px;
  padding: 12px 18px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.1);
  border-radius: var(--radius-md);
}

/* ===================== Stats Cards ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  color: #fff;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -30%;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.stat-icon {
  font-size: 34px;
  opacity: 0.85;
}

.stat-info label {
  display: block;
  font-size: 12.5px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.stat-num {
  display: block;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ===================== Section Title ===================== */
.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ===================== Shortcut Grid ===================== */
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 16px;
}

.shortcut-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: left;
}

.shortcut-item:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.3);
  border-color: transparent;
}

.shortcut-item i {
  font-size: 24px;
  flex-shrink: 0;
}

.shortcut-item span {
  font-size: 14px;
  font-weight: 500;
}

/* ===================== Badge ===================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-dark);
  font-weight: 500;
}

/* ===================== Readonly Field ===================== */
.readonly-field {
  padding: 8px 12px;
  background: rgba(247, 248, 250, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  min-height: 20px;
}

/* ===================== Checkbox ===================== */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.filter-bar .checkbox-label {
  align-self: center;
  margin-bottom: 1px;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ===================== Sync Hint ===================== */
.sync-hint {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #b45309;
  line-height: 1.5;
}

/* ===================== Search Select ===================== */
.search-select {
  position: relative;
  min-width: 0;
}
.search-select > input.form-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 0;
  max-width: 100%;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: rgba(59, 130, 246, 0.06);
}

/* ===================== Bill Switch ===================== */
.bill-switch {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--danger-bg);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.bill-switch.bill-on {
  background: var(--success-bg);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.2);
}

.bill-switch:hover {
  opacity: 0.8;
}

/* ===================== Quantity Diff ===================== */
/* ★ 2026-10-02：採購/調撥數量 ≠ 實際數量 的統一樣式（半透明紅底 + 紅字）
   全站唯一來源，查看 / 審核 / 修改 / 詳情頁共用；請勿於各頁 <style> 內重複定義 */
.qty-diff {
  background: rgba(220, 38, 38, 0.12);
  color: #cf1322;
  font-weight: 600;
}
/* 唯讀顯示（查看 / 詳情頁）的文字外形 */
span.qty-diff {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
}
/* 可編輯的實際數量輸入框（審核 / 修改）— 與上列同一視覺 */
input.qty-diff,
.form-input.qty-diff,
.form-input.qty-diff:focus {
  background: rgba(220, 38, 38, 0.12);
  color: #cf1322;
  border-color: rgba(220, 38, 38, 0.4);
  font-weight: 600;
}
.form-input.qty-diff:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.qty-diff-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

.diff-positive {
  background: var(--success-bg);
  color: #047857;
}

.diff-negative {
  background: var(--danger-bg);
  color: #b91c1c;
}

.diff-zero {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-secondary);
}

/* ===================== Stock Tip ===================== */
.stock-tip {
  position: relative;
}

.stock-tip:hover::after {
  content: '當前庫存：' attr(data-stock) ' 件';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: var(--primary-dark);
  color: #fff;
  font-size: 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* ===================== Highlight ===================== */
.highlight {
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
}

/* ===================== Footer ===================== */
.footer {
  padding: 16px 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 12.5px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) var(--glass-blur);
  border-top: 1px solid var(--border-light);
}

/* ===================== Scrollbar ===================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.35);
}

/* ===================== Text Utilities ===================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* ===================== ===================== */
/*  補充通用樣式（從各頁面提取的重複模式）    */
/* ===================== ===================== */

/* ===== Detail Section (詳情頁通用) ===== */
.detail-section {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-filter);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-item label { font-size: 13px; color: var(--text-secondary); }
.detail-item span { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* ===== Action Cell (表格操作列) ===== */
.action-cell {
  /* td 必須保持 table-cell，避免撐大操作列 */
  white-space: nowrap;
  text-align: center;
}
.action-cell .action-btns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

/* 覆盖：空数据行不应用 flex 布局，保持居中 */
.data-table .empty-state,
.data-table td.empty-state:last-child {
  display: table-cell;
}
/* colspan td (載入中/空狀態) 不套用 last-child 的 flex，保持 table-cell 撐滿整行 */
.data-table td[colspan],
.data-table td[colspan]:last-child {
  display: table-cell;
}

/* ===== Row States ===== */
.row-dirty { background: #fffde7; }
.row-edited { background: #fff8e1; }

/* ===== Toolbar (頁面頂部操作欄) ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ===== Type Tags ===== */
.type-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.type-user { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.type-admin { background: rgba(239, 68, 68, 0.1); color: #b91c1c; }

/* ===== Shop Cell (匯總表門店列) ===== */
.shop-cell {
  background: rgba(16, 185, 129, 0.08);
  font-weight: 600;
  color: #047857;
  vertical-align: middle;
}

/* ===== Container Pattern (goods/admin 等使用) ===== */
.container {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  -webkit-backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  padding: 20px 24px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.page-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-header h3 i { color: var(--accent); }

/* ===== LayUI 卡片覆蓋 ===== */
.layui-card {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  -webkit-backdrop-filter: var(--glass-saturate) calc(var(--glass-blur) * 0.6);
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-md) !important;
}
.layui-card-header {
  border-bottom: 1px solid var(--border-color) !important;
  background: rgba(247, 248, 250, 0.5) !important;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

/* ===== Form Section ===== */
.form-section { margin-bottom: 24px; }

/* ===== Animations ===== */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.2s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* ===================== Responsive ===================== */
/* 中屏適配 - 平板（769~1024px）：64px 圖標折疊版 */
@media screen and (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 64px;
  }
  .sidebar .sidebar-header .brand-text,
  .sidebar .nav-group-title .group-text,
  .sidebar .nav-group-title .collapse-arrow,
  .sidebar .nav-item .nav-text {
    display: none;
  }
  .sidebar .nav-group-title {
    padding: 14px 0;
    justify-content: center;
  }
  .sidebar .nav-group-title .group-icon {
    font-size: 20px;
    margin: 0;
  }
  .sidebar .nav-item {
    padding: 10px 0;
    justify-content: center;
    margin: 2px 4px;
  }
  .sidebar .nav-item .nav-icon {
    font-size: 18px;
    margin: 0;
    opacity: 0.8;
  }
  .sidebar .nav-children {
    display: none !important;
  }
  /* 平板下浮動菜單可用（hover 展開） */
  .sidebar:not(.collapsed) .nav-children { display: none !important; }

  /* 平板下點擊漢堡展開：恢復 240px 完整版 */
  .sidebar.collapsed {
    width: 240px;
  }
  .sidebar.collapsed .sidebar-header .brand-text,
  .sidebar.collapsed .nav-group-title .group-text,
  .sidebar.collapsed .nav-group-title .collapse-arrow,
  .sidebar.collapsed .nav-item .nav-text {
    display: revert;
  }
  .sidebar.collapsed .nav-group-title {
    padding: 12px 14px;
    justify-content: space-between;
  }
  .sidebar.collapsed .nav-item {
    padding: 10px 14px;
    justify-content: flex-start;
    margin: 2px 8px;
  }
  .sidebar.collapsed .nav-item .nav-icon {
    margin-right: 10px;
    font-size: 16px;
  }

  .main-area {
    margin-left: 64px;
  }
  /* 平板展開時主內容讓出 210px（與桌面側欄寬度一致） */
  .sidebar.collapsed ~ .main-area {
    margin-left: 210px;
  }
  .toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* 浮動菜單容器：與桌面折疊版一致 */
  .sidebar-float-menu {
    position: fixed;
    left: 60px;
    top: auto;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    min-width: 160px;
    padding: 6px;
    display: none;
  }
  .sidebar-float-menu .nav-item {
    padding: 8px 12px;
    margin: 2px 0;
    justify-content: flex-start;
  }
  .sidebar-float-menu .nav-item .nav-text {
    display: inline;
  }
}

/* 小屏適配 - 平板通用（≤1024px）：網格 */
@media screen and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .shortcut-grid { grid-template-columns: repeat(4, 1fr); }
  .view-info-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 手機適配（≤768px）：抽屜式側邊欄 */
@media screen and (max-width: 768px) {
  /* 阻斷整體橫向滾動，確保頁面內容全部夾在視口內（含 481~768px 平板/手機大屏區間，原只在 ≤480 處理） */
  html, body { overflow-x: hidden; max-width: 100%; }
  .app-layout, .main-area, .content-area { max-width: 100%; overflow-x: hidden; }
  /* 側邊欄隱藏後，主內容區收回左邊距，佔滿整個視口（!important 蓋過 .sidebar.collapsed ~ .main-area 的 64px） */
  .main-area {
    margin-left: 0 !important;
  }
  /* 側邊欄預設完全隱藏、不佔空間（避免擠壓主內容） */
  .sidebar {
    transform: translateX(-100%);
    /* 2026-08-18：小屏手機抽屜寬度與 PC 大屏一致 (210px) */
    width: 210px;
    min-width: 210px;
    max-width: 210px;
    z-index: 200;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.12);
  }
  /* 點擊漢堡按鈕後：抽屜展開 */
  .sidebar.open {
    transform: translateX(0);
  }
  /* 抽屜打開時顯示完整內容（恢復文字） */
  .sidebar.open .sidebar-header .brand-text,
  .sidebar.open .nav-group-title .group-text,
  .sidebar.open .nav-group-title .collapse-arrow,
  .sidebar.open .nav-item .nav-text {
    display: revert;
  }
  .sidebar.open .nav-group-title {
    padding: 12px 14px;
    justify-content: space-between;
  }
  .sidebar.open .nav-item {
    padding: 10px 14px;
    justify-content: flex-start;
    margin: 2px 8px;
  }
  .sidebar.open .nav-children.open {
    display: block !important;
  }

  /* 遮罩層：點擊關閉抽屜 */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 36, 64, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }
  .sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  /* 主內容區不再被 sidebar 擠壓 */
  .main-area {
    margin-left: 0;
  }

  /* 頂部漢堡按鈕在小屏突出顯示 */
  .toggle-btn {
    font-size: 22px;
    padding: 8px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
  }

  /* 頂部頭部收緊間距 */
  .top-header {
    padding: 0 12px;
  }
  .header-left { gap: 10px; }
  /* ★ 2026-08-12：頂部區域夠大，顯示用戶名全稱 */
  .header-right .user-name { display: inline !important; }

  .content-area {
    padding: 6px;
  }

  .page-card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
  }

  .page-card-header h3 {
    font-size: 15px;
  }

  .page-card-header .btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .page-card-body {
    padding: 14px 2px;
  }

  /* 篩選欄改回橫向流動（讓 label 與 input 同行），必要時自然換行 */
  .filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 14px;
  }
  .filter-bar > label {
    font-size: 13px;
    margin-bottom: 0;
  }
  .filter-bar input[type="date"],
  .filter-bar input[type="text"],
  .filter-bar select,
  .filter-bar .form-select {
    min-width: 0;
    flex: 0 1 auto;
    padding: 7px 10px;
    font-size: 13px;
  }
  /* 小屏下覆蓋頁面內聯 style="width:140px/160px" 的日期與搜索框 */
  .filter-bar input[type="date"] {
    width: 110px !important;
    max-width: 110px !important;
  }
  .filter-bar input[type="text"] {
    width: 110px !important;
    max-width: 110px !important;
  }
  .filter-bar select.form-select,
  .filter-bar select {
    width: auto !important;
    max-width: 140px !important;
  }
  .filter-bar .form-input[type="text"]:not([placeholder]) { width: 110px !important; }
  .filter-bar .layui-input-inline {
    width: auto !important;
    max-width: 100%;
  }
  .filter-bar .layui-input-inline input[type="date"] {
    width: 110px !important;
    max-width: 110px !important;
  }
  .filter-bar .layui-input-inline input[type="text"] {
    width: 110px !important;
    max-width: 110px !important;
  }
  .filter-bar .form-input { min-width: 0; flex: 0 1 auto; }
  /* 按鈕組在小屏允許換行到下一行 */
  .filter-actions {
    margin-left: auto;
    flex-wrap: wrap;
  }
  .filter-actions .btn { padding: 6px 12px; font-size: 13px; }

  .filter-group {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .filter-group label {
    margin-bottom: 0;
    font-size: 13px;
  }
  .filter-group input,
  .filter-group select { min-width: 100px; flex: 0 1 auto; }

  /* 小屏隱藏冗餘標籤工具類（需要時在頁面對應 label 上加 class="hide-label-sm"） */
  .hide-label-sm { display: none !important; }

  /* 表頭自適應：小屏切換為簡寫 */
  .th-full { display: none; }
  .th-short { display: inline; }

  /* 彈窗底部按鈕：手機端顯示簡寫並縮小 */
  .btn-label-full { display: none !important; }
  .btn-label-sm { display: inline !important; }
  .modal-footer .btn { padding: 5px 10px; font-size: 12px; }

  /* 小屏：長內容省略（單號/長字段） */
  .cell-ellipsis {
    display: inline-block;
    max-width: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }
  .data-table td { word-break: break-word; }

  /* ================================================================
     小屏統一表格自適應策略（三級降級）：
     1. 優先級：col-* class 精確分配列寬（auto 佈局下為建議值）
     2. 兜底級：.table-wrapper 啓用 overflow-x:auto 橫向滾動
     3. 終極級：≤480px 可選 .table-cards 卡片模式（需頁面顯式添加 class）
     ================================================================ */

  /* --- 第 0 層：全局基礎收緊 --- */
  .data-table thead th,
  .data-table tbody td {
    padding: 6px 4px;
    font-size: 12px;
  }
  .data-table td .btn { padding: 3px 6px; font-size: 11px; }

  /* 表頭雙文本切換 */
  .th-full { display: none; }
  .th-short { display: inline; }

  /* 隱藏非重要列 */
  .data-table .hide-sm,
  .layui-table .hide-sm,
  .summary-table .hide-sm,
  .table-wrapper .hide-sm { display: none !important; }

  /* --- 第 1 層：auto 佈局，隱藏列真正不佔位 --- */
  .data-table {
    table-layout: auto;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
  }

  /* 隱藏列：auto 佈局下 display:none 完全不佔位 */
  .data-table .hide-sm,
  .data-table th.hide-sm,
  .data-table td.hide-sm {
    display: none !important;
    width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }

  /* auto 佈局：內容列用 width:1px 收縮到最小，操作列自然撐滿剩餘 */
  .data-table .col-index  { width: 1px; min-width: 36px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .data-table .col-source { width: 1px; min-width: 48px; max-width: 60px; text-align: center; padding: 4px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .data-table .col-bill   { width: 1px; min-width: 48px; max-width: 60px; text-align: center; padding: 4px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .data-table .col-qty    { width: 1px; min-width: 52px; max-width: 64px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .data-table .col-unit   { width: 1px; min-width: 44px; max-width: 56px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .data-table .col-spec   { width: 1px; min-width: 52px; max-width: 64px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .data-table .col-price  { width: 1px; min-width: 60px; max-width: 76px; text-align: right; padding: 4px 2px; white-space: nowrap; }
  .data-table .col-amount { width: 1px; min-width: 64px; max-width: 80px; text-align: right; padding: 4px 2px; white-space: nowrap; }

  /* 店鋪/供應商（採購列）：收縮到內容寬 */
  .data-table .col-shop,
  .data-table .col-supplier {
    width: 1px;
    min-width: 44px;
    max-width: 64px;
    text-align: center;
    padding: 4px 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .data-table .col-shop .cell-ellipsis,
  .data-table .col-supplier .cell-ellipsis {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* 狀態列：固定寬度收縮 */
  .data-table .col-status { width: 1px; min-width: 64px; max-width: 120px; text-align: center; padding: 4px 2px; white-space: nowrap; }
  .data-table .col-status .status-tag,
  .data-table td .status-tag {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    padding: 3px 7px;
    font-size: 11px;
  }

  /* 單號列：小屏隱藏，不佔任何空間 */
  .data-table .col-sn { display: none !important; width: 0 !important; min-width: 0 !important; padding: 0 !important; border: none !important; }

  /* 名稱列：剩餘空間自動撐開 */
  .data-table .col-name,
  .data-table td.col-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .data-table .col-name .cell-ellipsis,
  .data-table td .cell-ellipsis {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* --- 操作列：auto 下不設寬，自然撐滿剩餘；按鈕 flex 居中、絕不換行 --- */
  .data-table thead th.col-action {
    padding: 4px 2px;
    text-align: center;
    white-space: nowrap;
  }
  .data-table tbody td.col-action {
    padding: 4px 2px !important;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    overflow: visible;
    /* 核心：flex 居中 */
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }
  .data-table .col-action .btn {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 3px 6px;
    font-size: 11px;
    margin: 0;
    white-space: nowrap;
  }

  /* --- 第 2 層：小屏禁止橫向滾動（auto 已自適配，不需要滾） --- */
  .table-wrapper {
    overflow-x: hidden;
    max-width: 100%;
  }
  .data-table {
    max-width: 100%;
    min-width: 0;
    /* 保持 auto 佈局（第 1 層已設），不覆蓋為 fixed */
  }

  /* transfer/list 小屏：auto 佈局，內容列收縮、操作列撐滿剩餘 */
  .transfer-table.data-table {
    table-layout: auto;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
  }
  .transfer-table.data-table .hide-sm { display: none !important; width: 0 !important; min-width: 0 !important; padding: 0 !important; border: none !important; overflow: hidden !important; }
  .transfer-table.data-table .col-index  { width: 6%; min-width: 28px; text-align: center; white-space: nowrap; padding: 4px 2px; }
  .transfer-table.data-table .col-shop   { width: 6%; min-width: 32px; text-align: center; padding: 4px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .transfer-table.data-table .col-status { width: 30%; min-width: 48px; max-width: 80px; text-align: center; padding: 4px 2px; white-space: nowrap; }
  /* 操作列：不設寬度，auto 下自然佔滿剩餘全部空間 */
  .transfer-table.data-table .col-action { width: auto; }

  /* --- 第 3 層：超小屏 (≤440px) 額外隱藏單號列 --- */
  @media (max-width: 440px) {
    .data-table thead th.col-sn,
    .data-table tbody td.col-sn { display: none !important; }
  }

  /* 狀態徽章全局收緊 */
  .status-tag {
    padding: 3px 7px;
    font-size: 11px;
  }

  /* 標題區收緊（全量頁面統一） */
  .page-card { margin-bottom: 8px !important; }
  .page-card-header {
    padding: 8px 12px !important;
    margin-bottom: 4px !important;
    border-bottom: 1px solid rgba(226,232,240,0.4) !important;
  }
  .page-card-header h3,
  .page-card-header .page-title {
    font-size: 14px !important;
    margin: 0 !important;
    line-height: 1.3 !important;
  }
  .page-card-header i,
  .page-card-header .el-icon { font-size: 14px !important; }

  /* 篩選條與分頁緊湊 */
  .filter-bar {
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid rgba(226,232,240,0.4);
  }
  .filter-group { flex-wrap: wrap; gap: 6px; }
  .filter-group label.hide-label-sm { display: none !important; }
  .filter-group input,
  .filter-group select { min-width: 100px; height: 28px; }
  .filter-group input[type="date"] {
    width: 130px !important;
    min-width: 0 !important;
    max-width: 140px;
    padding: 5px 8px;
    font-size: 12.5px;
  }
  .filter-group input[type="text"] {
    width: 110px !important;
    min-width: 0 !important;
  }
  .filter-group select {
    min-width: 90px;
    padding: 5px 8px;
    font-size: 12.5px;
  }
  .filter-bar .btn { padding: 5px 12px; font-size: 12.5px; }
  .pagination { flex-wrap: wrap; gap: 4px; padding: 8px 0; font-size: 12px; }
  .pagination .btn { padding: 3px 8px; font-size: 12px; }

  /* ================================================================
     彈窗內表格統一自適應（768px）
     ================================================================ */

  /* 彈窗表格基礎：auto 佈局（與主列表一致，隱藏列不佔位） */
  .modal-box .data-table {
    table-layout: auto;
    width: 100%;
    min-width: 0;
  }

  /* 彈窗內列寬：內容列收縮，操作列撐滿 */
  .modal-box .data-table .col-index  { width: 1px; min-width: 32px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .modal-box .data-table .col-source { width: 1px; min-width: 48px; max-width: 64px; text-align: center; padding: 4px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-box .data-table .col-bill   { width: 1px; min-width: 48px; max-width: 64px; text-align: center; padding: 4px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-box .data-table .col-qty    { width: 1px; min-width: 52px; max-width: 70px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .modal-box .data-table .col-unit   { width: 1px; min-width: 44px; max-width: 56px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .modal-box .data-table .col-spec   { width: 1px; min-width: 52px; max-width: 64px; text-align: center; padding: 4px 1px; white-space: nowrap; }
  .modal-box .data-table .col-price  { width: 1px; max-width: 70px; min-width: 56px; text-align: right; padding: 4px 2px; white-space: nowrap; }
  .modal-box .data-table .col-amount { width: 1px; max-width: 76px; min-width: 60px; text-align: right; padding: 4px 2px; white-space: nowrap; }
  .modal-box .data-table .col-supplier { width: 1px; max-width: 72px; min-width: 50px; text-align: center; padding: 4px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 彈窗名稱列：剩餘空間自動撐開 */
  .modal-box .data-table .col-name,
  .modal-box .data-table td.col-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .modal-box .data-table .col-name .cell-ellipsis,
  .modal-box .data-table td .cell-ellipsis {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* 彈窗操作列：auto 下不設寬，flex 居中、不換行 */
  .modal-box .data-table thead th.col-action {
    padding: 4px 2px;
    text-align: center;
    white-space: nowrap;
  }
  .modal-box .data-table tbody td.col-action {
    padding: 4px 2px;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }
  .modal-box .data-table .col-action .btn {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 3px 5px;
    font-size: 11px;
    margin: 0;
    white-space: nowrap;
  }

  /* 彈窗內標籤類元素 */
  .modal-box .bill-switch,
  .modal-box .source-tag {
    display: inline-block;
    white-space: nowrap;
    padding: 1px 3px;
    font-size: 10px;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
  }

  /* 彈窗表格通用 padding */
  .modal-box .data-table thead th,
  .modal-box .data-table tbody td {
    padding: 6px 3px;
    font-size: 12px;
  }
  .modal-box .data-table.compact thead th,
  .modal-box .data-table.compact tbody td {
    padding: 5px 3px;
    font-size: 11.5px;
  }

  /* 彈窗內數量輸入框（採購數量 1-3 位數，48px 足夠） */
  .modal-box .data-table input[type="number"].input-sm,
  .modal-box .data-table .form-input.input-sm {
    width: 48px;
    min-width: 42px;
    max-width: 100%;
    padding: 3px 2px;
    font-size: 12px;
  }

  /* 彈窗表頭簡寫 */
  .modal-box .th-full { display: none; }
  .modal-box .th-short { display: inline; }

  /* 彈窗訂單信息區 */
  .modal-box .view-info-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .modal-box .view-info-item { padding: 6px 8px; gap: 4px; flex-wrap: nowrap; }
  .modal-box .view-label { font-size: 12px; flex: 0 0 auto; }
  .modal-box .view-value { font-size: 13px; }
  .modal-box .view-value.sn { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

  /* 彈窗狀態徽章 */
  .modal-box .status-tag {
    padding: 3px 7px;
    font-size: 11px;
  }

  /* --- 彈窗：modal-body 禁止橫向滾動，由 table-scroll-wrapper 單獨處理 --- */
  .modal-box .modal-body {
    overflow-x: hidden;
  }

  /* 詳情頁（layui 遺留） */
  .layui-table .th-full { display: none; }
  .layui-table .th-short { display: inline; }
  .detail-section .detail-grid { grid-template-columns: 1fr; gap: 8px; }
  .detail-section .detail-item { padding: 6px 10px; }
  .detail-section .detail-item label { font-size: 11px; }
  .detail-section .detail-item span { font-size: 13px; }
  .detail-section .sn-badge { font-size: 12px; max-width: 100%; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
  .detail-section .layui-table { width: 100% !important; min-width: 0 !important; }
  .detail-section .layui-table input[type="number"] { width: 40px !important; min-width: 40px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 6px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-num {
    font-size: 24px;
  }

  .shortcut-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .shortcut-item {
    padding: 16px 12px;
  }

  .view-info-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    gap: 10px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .container {
    padding: 14px 16px;
  }
  /* ★ 2026-08-12：小屏下 .container.page-card 去掉 padding，標題鋪滿無白邊 */
  .container.page-card {
    padding: 0 !important;
  }

  .page-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .page-header h3,
  .page-header h1 {
    font-size: 15px;
  }

  .page-header .btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* 彈窗在小屏統一自適應：貼合視口、內容可滾動、表單單列 */
@media screen and (max-width: 768px) {
  .modal-box,
  .modal-box.modal-lg,
  .modal-box.modal-sm,
  .modal-lg,
  .modal-sm {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px) !important;
    min-width: 0 !important;
    max-height: 90vh !important;
    margin: 16px auto !important;
    border-radius: 14px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  /* 添加貨品等小彈窗在窄屏直接自適應，去掉固定 min-width 撐破 */
  .modal.modal-edit,
  .modal-box.modal-edit {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    min-width: 0 !important;
  }
  .modal-body { max-height: calc(90vh - 130px); overflow-y: auto; }
  /* 表單兩欄在小屏折成單欄
     ★ !important 必需：檔案後方（.frow 基礎定義區）有同特異性的
       grid-template-columns: 1fr 1fr，靠後聲明會蓋掉本媒體查詢規則 */
  .frow { grid-template-columns: 1fr !important; gap: 10px; }
  .frow .fitem { gap: 8px; }
  .frow .fitem > label { flex: 0 0 60px !important; font-size: 12.5px; }
  .frow .fitem > .form-input,
  .frow .fitem > .form-select,
  .frow .fitem > input,
  .frow .fitem > select,
  .frow .fitem > .search-select,
  .frow .fitem > .ss-wrap {
    flex: 1; min-width: 0; width: 100%;
  }
  .frow .fitem--auto { width: 100% !important; }
  .frow .fitem--auto > .form-input,
  .frow .fitem--auto > .form-select,
  .frow .fitem--auto > input,
  .frow .fitem--auto > select,
  .frow .fitem--auto > .search-select,
  .frow .fitem--auto > .ss-wrap { flex: 1 !important; width: 100% !important; min-width: 0; }
  .modal-edit .modal-body { padding: 16px; }
  /* 自定義提示層/對話框在小屏適配 */
  .dialog-box { width: calc(100vw - 32px) !important; max-width: calc(100vw - 32px) !important; }
  .toast-wrap { left: 12px !important; right: 12px !important; }
  .toast-item { width: auto !important; max-width: none !important; }
}

/* 超小屏：表格仍用 fixed 百分比佈局，禁止橫向滾動 */
@media screen and (max-width: 480px) {
  /* 阻斷整體橫向滾動，確保頁面內容全部夾在視口內 */
  html, body { overflow-x: hidden; max-width: 100%; }
  .app-layout, .main-area, .content-area { max-width: 100%; overflow-x: hidden; }
  /* 表格容器禁止滾動 */
  .table-wrapper { overflow-x: hidden; max-width: 100%; }
  .table-wrapper > table,
  .table-wrapper .data-table { max-width: 100%; min-width: 0; }
  /* 超小屏時仍保留 hide-sm 隱藏效果 */
  .table-wrapper .data-table .hide-sm { display: none !important; }
  /* review 詳情頁明細表也禁止溢出 */
  .detail-section { overflow-x: hidden; }
}

/* layui 彈窗/提示層在小屏統一適配（部分頁面用 layui 原生彈窗） */
@media screen and (max-width: 768px) {
  .layui-layer { max-width: calc(100vw - 24px) !important; }
  .layui-layer-page .layui-layer-content { overflow-x: hidden; }
  .layui-table { width: 100% !important; }
  .layui-table[style*="min-width"] { min-width: 0 !important; }
  /* 詳情頁 detail-grid 在窄屏單列 */
  .detail-grid { grid-template-columns: 1fr; }
  /* 操作按鈕組在小屏縱向排列不撐破 */
  .action-btns { flex-direction: column; align-items: stretch; }
  .action-btns .btn { margin: 3px 0; width: 100%; }
  /* 篩選欄/操作列在小屏換行 */
  .filter-bar, .toolbar, .page-header { flex-wrap: wrap; }
  .filter-bar .fitem, .toolbar .fitem { flex: 1 1 auto; min-width: 0; }
}

/* ===== 共用表單/彈窗補充（由各列表頁原本的本地 <style> 統一收攏至此，確保風格一致） ===== */
.btn-blue { background: linear-gradient(135deg, #1a3a5c, #2a5a8c); color: #fff; }
.btn-blue:hover { opacity: .92; }

.search-bar { margin-bottom: 16px; padding: 16px; background: rgba(247,248,250,0.8); border: 1px solid rgba(226,232,240,0.4); border-radius: 8px; }
.search-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; color: #64748b; font-weight: 500; }

.required { color: #ef4444; margin-left: 2px; }

/* 兩欄行內表單：標籤與值同一行，每行兩欄（新增/編輯彈窗共用）
   寬度自適應兩欄內容，固定視口邊距 max-width 限定，min-width 保證窄屏可讀 */
.modal.modal-edit, .modal-box.modal-edit {
  width: 560px;
  max-width: calc(100vw - 32px);
  min-width: 440px;
}
.modal-edit .modal-body { padding: 22px 24px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.frow:last-child { margin-bottom: 0; }
.frow .fitem { min-width: 0; display: flex; align-items: center; gap: 10px; }
.frow .fitem:only-child { grid-column: 1 / -1; }
/* 隱藏 input（v-model 佔位）在 flex 容器內需強制 0 寬，避免撐大兄弟控件 */
.frow .fitem > input[type="hidden"] {
  width: 0; min-width: 0; max-width: 0; padding: 0; margin: 0;
  border: 0; flex: 0 0 0; overflow: hidden; visibility: hidden;
}
.frow .fitem > label {
  flex: 0 0 64px;
  text-align: right;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
}
.frow .fitem > label .required { color: #ef4444; margin-left: 2px; }
.frow .fitem > .form-input,
.frow .fitem > .form-select,
.frow .fitem > input,
.frow .fitem > select,
.frow .fitem > .search-select,
.frow .fitem > .ss-wrap {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 38px;
  box-sizing: border-box;
}
/* search-select/ss-wrap 內部的 input 同樣需要 border-box 防止撐出容器 */
.frow .search-select > input,
.frow .ss-wrap > input { width: 100%; min-width: 0; box-sizing: border-box; }
/* 单行局部控制項（如數量）：不撐滿彈窗，寬度與兩欄控件一致 */
.frow .fitem--auto { width: max-content; }
.frow .fitem--auto > .form-input,
.frow .fitem--auto > .form-select,
.frow .fitem--auto > input,
.frow .fitem--auto > select,
.frow .fitem--auto > .search-select,
.frow .fitem--auto > .ss-wrap { flex: 0 0 150px; width: 150px; }

/* 超小屏適配 */
@media screen and (max-width: 480px) {
  /* ★ 2026-08-12：統計卡片保持 2x2 雙排，PC 端不受影響（原 .stats-grid 在 ≤480 是 1fr，會讓 4 張卡片變成 1 列單排） */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; padding: 0 !important; }
  .stat-card { padding: 12px 10px !important; gap: 10px !important; }
  .stat-icon { font-size: 24px !important; }
  .stat-info label { font-size: 11.5px !important; }
  .stat-num { font-size: 20px !important; }
  .shortcut-grid { grid-template-columns: repeat(2, 1fr); }
  .top-header { padding: 0 8px; gap: 6px; }
  .header-left .breadcrumb { display: none; }
  /* ★ 2026-08-12：頂部區域夠大，顯示用戶名全稱（不隱藏） */
  .user-name { display: inline !important; font-size: 12.5px; }
  .user-info { padding: 0 4px; }
  .user-info .user-avatar { width: 26px; height: 26px; font-size: 12px; }
  .btn-logout { font-size: 12px; padding: 4px 8px; }
  /* 阻斷祖先容器的橫向溢出 */
  html, body { overflow-x: hidden; max-width: 100%; }
  .app-layout, .main-area, .content-area { max-width: 100%; overflow-x: hidden; }
}

/* ===================== 報表模組專用 ===================== */
.report-wrap { padding: 4px 10px; }

/* 篩選工具列 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
  background: var(--glass-bg, rgba(255,255,255,0.6));
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 2px 10px rgba(15,36,64,0.04);
}
.filter-bar .fitem { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.filter-bar .fitem > label { font-size: 12.5px; color: var(--text-secondary, #64748b); font-weight: 500; }
.filter-bar .fitem .form-input,
.filter-bar .fitem .el-input__inner { width: 100%; }
.filter-bar .filter-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ===================== Report Module ===================== */
/* 報表區域內容容器 */
.report-content {
  position: relative;
  min-height: 360px;
}
/* 載入狀態：垂直水平居中 */
.report-content .loading-state,
.loading-state.report-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary, #64748b);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
  z-index: 5;
}
.report-content .loading-state .loading-spinner {
  margin: 0 auto;
}
/* 報表篩選列：label 與 控件 同行 */
.filter-bar.filter-bar-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 12px;
}
.filter-bar.filter-bar-inline .fitem {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: auto;
}
.filter-bar.filter-bar-inline .fitem > label {
  flex: 0 0 auto;
  font-size: 13px;
  color: #1e293b;
  font-weight: 600;
  white-space: nowrap;
}
.filter-bar.filter-bar-inline .fitem > .form-input,
.filter-bar.filter-bar-inline .fitem > .form-select,
.filter-bar.filter-bar-inline .fitem > input[type="date"] {
  flex: 0 0 150px;
  width: 150px;
  min-width: 0;
  height: 36px;
  line-height: 34px;
  padding: 0 10px;
  box-sizing: border-box;
  border-radius: 6px;
  background-color: #fff;
  border: 1px solid #cbd5e1;
}
.filter-bar.filter-bar-inline .fitem > input[type="date"] {
  /* 讓原生日曆控件與 select 高度視覺一致 */
  appearance: none;
  -webkit-appearance: none;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  color: #1e293b;
}
.filter-bar.filter-bar-inline .fitem > input[type="date"]::-webkit-calendar-picker-indicator {
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0.85;
}
.filter-bar.filter-bar-inline .fitem > input[type="date"]::-webkit-datetime-edit { padding: 0; }
.filter-bar.filter-bar-inline .fitem > .form-select { flex: 0 0 160px; width: 160px; }
.filter-bar.filter-bar-inline .filter-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-bar.filter-bar-inline .date-input-wrap {
  flex: 0 0 150px;
  width: 150px;
  display: flex;
  align-items: center;
  position: relative;
}
.filter-bar.filter-bar-inline .date-input-wrap input[type="date"] {
  width: 100%;
  height: 36px;
}
.filter-bar.filter-bar-inline .date-input-wrap > span {
  display: none;
}

/* 圖表卡片 */
.chart-box {
  background: #fff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(15,36,64,0.04);
  margin-bottom: 22px;
}
.chart-box .chart-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.chart-box .chart-title::before {
  content: '';
  width: 4px; height: 16px;
  background: var(--accent, #3b82f6);
  border-radius: 2px;
}
.chart-box .chart-canvas-wrap { position: relative; height: 320px; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media screen and (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

/* KPI 小標註 */
.stat-sub { display: block; font-size: 12px; opacity: 0.75; margin-top: 4px; line-height: 1.4; }

/* 報表表格與 KPI 卡之間分隔 */
.report-section { margin-top: 8px; }

/* 調撥/財務利潤正負色 */
.profit-pos { color: var(--success, #10b981); font-weight: 600; }
.profit-neg { color: var(--danger, #ef4444); font-weight: 600; }

/* ===== 排班系統專用樣式（限定在 .shift-page / .app-dialog-content，避免污染後台全域樣式） ===== */
/* 排班日曆表格：保持寬幅橫向滾動，單元格可直接點擊編輯 */
.shift-page .shift-table{border-collapse:collapse;width:100%;background:#fff;border-radius:8px;overflow:hidden;}
.shift-page .shift-table th,.shift-page .shift-table td{border:1px solid #e7ebf0;padding:8px 6px;text-align:center;font-size:13px;}
.shift-page .shift-table th{background:#f3f6fb;}
.shift-page .emp-col{white-space:nowrap;text-align:left;min-width:90px;}
.shift-page .c-work{background:#eaf4ff;}
.shift-page .c-leave{background:#fff3e6;color:#c9760f;}
.shift-page .shift-cell{min-height:64px;border:1px solid #eee;padding:4px;}
.shift-page .shift-tag{display:inline-block;margin:1px;padding:1px 4px;border-radius:4px;font-size:12px;}
.shift-page .shift-tag.work{background:#eaf4ff;}
.shift-page .shift-tag.leave{background:#fff3e6;color:#c9760f;}
.shift-page .shift-weekhead,.shift-page .shift-grid{display:grid;}
.shift-page .shift-weekhead{grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:4px;}
.shift-page .shift-weekhead span{text-align:center;font-weight:600;}
.shift-page .shift-grid{grid-template-columns:repeat(7,1fr);gap:4px;}
.shift-page .shift-cell.empty{visibility:hidden;}
.shift-page .shift-date{font-weight:600;}
.shift-page .shift-names{margin-top:2px;}
.shift-page .shift-loading{padding:24px;text-align:center;color:#999;}
/* 彈層表單橫排：日曆/指派彈窗內統一標籤在左，控件在右 */
.app-dialog-content .form-row{display:flex;align-items:center;gap:8px;margin-bottom:10px;}
.app-dialog-content .form-row label{width:72px;text-align:right;color:#555;white-space:nowrap;}
.app-dialog-content .form-row input,.app-dialog-content .form-row select{flex:1;padding:8px 10px;border:1px solid #d4dce6;border-radius:6px;font-size:14px;}


