/* ============================================================
   小慧發財團購店 - 後台管理系統
   設計主題：團購 / 網購電商後台風格 (Sidebar Admin Dashboard)
   本檔為跨裝置共用的基礎樣式（配色、元件外觀），
   尺寸與版面配置分別交由 desktop.css / mobile.css 依斷點處理。
   ============================================================ */

:root {
  /* 品牌主色：團購搶購紅 */
  --primary: #e3402d;
  --primary-dark: #c22f1f;
  --primary-light: #fdece9;

  /* 輔助色：促銷金 */
  --accent: #ffb100;
  --accent-dark: #e69900;

  /* 側邊欄配色 */
  --sidebar-bg: #1c2333;
  --sidebar-bg-light: #2a3247;
  --sidebar-text: #aab1c5;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-alt: #f7f8fb;
  --ink: #1f2430;
  --muted: #6b7280;
  --border: #e4e7ed;

  /* 狀態色 */
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #2563eb;

  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --sidebar-width: 260px;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

form {
  margin: 0;
}

h1,
h2,
h3 {
  margin: 0 0 4px;
}

/* ---------- 導覽列 / 側邊欄（基礎，尺寸由斷點檔決定） ---------- */
.top-nav {
  position: relative;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.top-nav-inner {
  position: relative;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--sidebar-text-active);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  flex-shrink: 0;
}

.menu-mobile-toggle {
  display: none;
  border: none;
  cursor: pointer;
}

.menu-list {
  position: relative;
}

.menu-groups,
.menu-group-items {
  padding: 0;
  margin: 0;
  list-style: none;
}

.menu-group {
  list-style: none;
}

.menu-group-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--sidebar-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.menu-group-toggle::after {
  content: "\276F";
  font-size: 0.7em;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.menu-group.open > .menu-group-toggle::after {
  transform: rotate(90deg);
}

.menu-group-toggle:hover,
.menu-group.open > .menu-group-toggle {
  background: var(--sidebar-bg-light);
  color: var(--sidebar-text-active);
}

.menu-group-items {
  display: none;
}

.menu-group.open > .menu-group-items {
  display: block;
}

.menu-item {
  display: block;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.menu-item:hover {
  background: var(--sidebar-bg-light);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}

/* ---------- 版面容器 ---------- */
.page-shell {
  max-width: 1240px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h1,
.page-header h2 {
  font-weight: 800;
  color: var(--ink);
}

.page-header .page-desc {
  margin: 4px 0 0;
  color: var(--muted);
}

/* ---------- 卡片 / 面板 ---------- */
.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel + .panel {
  margin-top: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-badge {
  display: inline-flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent-dark));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.login-card,
.wide {
  max-width: 880px;
  margin: 0 auto;
}

/* ---------- 表單元件 ---------- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field-group label {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.92rem;
}

.input-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227, 64, 45, 0.14);
}

.filter-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

/* ---------- 按鈕 ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(227, 64, 45, 0.24);
}

.button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button.secondary {
  background: var(--surface);
  color: var(--primary-dark);
  border-color: rgba(227, 64, 45, 0.3);
}

/* ---------- 訊息 / 提示 ---------- */
.message {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 600;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--primary-light);
  border: 1px solid rgba(227, 64, 45, 0.16);
  border-left: 4px solid var(--primary);
}

.intro-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.intro-text {
  color: var(--muted);
}

/* ---------- 徽章（訂單狀態等） ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--muted);
}

.badge.success { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.badge.warning { background: rgba(245, 158, 11, 0.14); color: var(--warning); }
.badge.danger { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.badge.info { background: rgba(37, 99, 235, 0.12); color: var(--info); }

/* ---------- 表格 ---------- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.table th {
  background: var(--sidebar-bg);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
  font-weight: 700;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.table tbody tr:nth-child(even) {
  background: var(--surface-alt);
}

.table tbody tr:hover {
  background: var(--primary-light);
}

/* ---------- Excel / SharePoint 風格即時編輯表格 ---------- */
.excel-table {
  table-layout: fixed;
  font-size: 0.88rem;
}

.excel-table td {
  padding: 5px 6px;
  vertical-align: middle;
}

.excel-table .input-field {
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.88rem;
}

.excel-table .input-field:hover {
  border-color: var(--border);
}

.excel-table .input-field:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227, 64, 45, 0.14);
}

/* 下拉選單（廠商名稱等）：預設就要看得出是可點選的選單框，而不是等 hover 才有邊框 */
.excel-table select.input-field {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 19px) center,
    calc(100% - 14px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

.excel-table select.input-field:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.excel-table select.input-field:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(227, 64, 45, 0.14);
}

/* 下拉展開後的選項清單樣式（主流瀏覽器如 Chrome/Edge/Firefox 支援度較好，其餘瀏覽器會自動退回預設樣式） */
.excel-table select.input-field option {
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}

.excel-table select.input-field option:hover,
.excel-table select.input-field option:checked,
.excel-table select.input-field option:focus {
  background: var(--primary);
  color: #fff;
}

.excel-table .col-id {
  width: 80px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.form-change-status {
  min-height: 22px;
  margin: 0 0 14px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.form-change-status.is-visible {
  visibility: visible;
  opacity: 1;
}

.form-change-status.is-saved {
  color: var(--success);
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.28);
}

.form-change-status.is-error {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.excel-table .vender-row-new .vender-id-cell {
  color: var(--primary-dark);
  font-style: italic;
}

.excel-table .col-actions {
  width: 90px;
  text-align: center;
}

.instock-table-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 10px;
}

.instock-bulk-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.instock-bulk-delete-btn:hover {
  background: var(--danger);
  color: #fff;
}

.instock-bulk-delete-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.excel-table .instock-select-cell {
  text-align: center;
}

.excel-table .instock-row-select {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.excel-table .instock-row-select.is-hidden {
  visibility: hidden;
}

.excel-table .btn-delete-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.excel-table .btn-delete-row:hover {
  background: var(--danger);
  color: #fff;
}

.excel-table .btn-delete-row:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.excel-table .btn-delete-row.is-hidden {
  visibility: hidden;
}

.excel-table .col-actions {
  width: 86px;
  white-space: nowrap;
  text-align: center;
}

.excel-table .btn-action-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 6px 12px;
  min-width: 58px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(227, 64, 45, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.excel-table .btn-action-row:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 10px 22px rgba(227, 64, 45, 0.24);
}

.excel-table .btn-add-row {
  background: linear-gradient(135deg, #16a34a, #0f8a3f);
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.2);
}

.excel-table .btn-add-row:hover {
  box-shadow: 0 10px 22px rgba(22, 163, 74, 0.28);
}

.excel-table .col-actions .btn-delete-row,
.excel-table .col-actions .btn-action-row {
  vertical-align: middle;
}

.excel-table .col-actions .btn-action-row + .btn-delete-row {
  margin-left: 6px;
}

/* ---------- InStock 欄寬優化 ---------- */
.excel-table .instock-col-vender {
  width: 17%;
}

.excel-table .instock-col-goods {
  width: 24%;
}

.excel-table .instock-col-select {
  width: 5%;
  text-align: center;
}

.excel-table .instock-col-money {
  width: 9%;
}

.excel-table .instock-col-margin {
  width: 8%;
}

.excel-table .instock-col-qty {
  width: 6%;
}

.excel-table .instock-col-date {
  width: 14%;
}

.excel-table .instock-row .input-field,
.excel-table .instock-row .instock-margin {
  display: block;
  width: 100%;
  min-width: 0;
}

.excel-table .instock-row .instock-goods-select {
  min-width: 0;
}

.excel-table .instock-row .instock-vender-select {
  min-width: 0;
}

.excel-table .instock-row .instock-cost-input,
.excel-table .instock-row .instock-price-input,
.excel-table .instock-row .instock-qty-input {
  min-width: 0;
}

.excel-table .instock-row .instock-qty-input {
  max-width: 72px;
}

.excel-table .instock-row .instock-buy-date-input,
.excel-table .instock-row .instock-arrival-date-input {
  min-width: 0;
}

.excel-table .instock-row .instock-margin {
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  padding-right: 6px;
}

.instock-editing-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
}

.instock-editing-label {
  font-weight: 700;
  color: var(--ink);
}

#instockCurrentGoodsName {
  color: var(--primary-dark);
  font-weight: 800;
}

/* ---------- TodaySell 欄寬優化 ---------- */
.todaysell-filter {
  margin-bottom: 12px;
}

.todaysell-filter .field-group {
  margin-bottom: 0;
  max-width: 260px;
}

.excel-table .todaysell-col-goods {
  min-width: 280px;
}

.excel-table .todaysell-col-qty {
  min-width: 130px;
}

.excel-table .todaysell-col-remain {
  min-width: 120px;
}

.excel-table .todaysell-row .todaysell-sid-select {
  min-width: 260px;
}

.excel-table .todaysell-row .todaysell-qty-input {
  min-width: 110px;
}

.excel-table .todaysell-row .todaysell-remain {
  display: inline-block;
  min-width: 80px;
  text-align: right;
  font-weight: 700;
  color: var(--ink);
}

.excel-table .todaysell-row .todaysell-remain.is-negative {
  color: var(--danger);
}

.todaysell-table-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.todaysell-bulk-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(220, 38, 38, 0.24);
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(220, 38, 38, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.todaysell-bulk-delete-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 12px 26px rgba(220, 38, 38, 0.24);
}

.todaysell-bulk-delete-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  box-shadow: none;
}

.excel-table .todaysell-col-select {
  width: 54px;
  text-align: center;
}

.excel-table .todaysell-select-cell {
  text-align: center;
  vertical-align: middle;
}

.excel-table .todaysell-row-select {
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--primary);
}

.excel-table .todaysell-row-select.is-hidden {
  visibility: hidden;
}

.excel-table .todaysell-row .btn-save-row,
.excel-table .todaysell-row .btn-add-row {
  min-width: 64px;
}

.excel-table .todaysell-row-new .btn-save-row {
  display: none;
}

.excel-table .todaysell-row:not(.todaysell-row-new) .btn-add-row {
  display: none;
}

/* ---------- Dashboard ---------- */
.dashboard-filter-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.dashboard-date-field {
  margin-bottom: 0;
  width: min(100%, 240px);
  max-width: 240px;
  min-width: 0;
}

.dashboard-date-field .input-field {
  width: 100%;
  max-width: 100%;
  min-width: 220px;
  box-sizing: border-box;
}

.dashboard-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
  grid-auto-rows: minmax(0, auto);
  margin-bottom: 20px;
}

.dashboard-metric-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.dashboard-metric-card-clickable {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.dashboard-metric-card-clickable:hover,
.dashboard-metric-card-clickable:focus,
.dashboard-metric-card-clickable[aria-expanded="true"] {
  transform: translateY(-1px);
  border-color: rgba(227, 64, 45, 0.45);
  box-shadow: 0 10px 24px rgba(227, 64, 45, 0.12);
}

.dashboard-metric-card-clickable:focus {
  outline: none;
}

.dashboard-metric-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
}

.dashboard-metric-value {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  line-height: 1.15;
  font-weight: 800;
  color: var(--primary-dark);
  overflow-wrap: anywhere;
}

.dashboard-metric-note {
  font-size: 0.86rem;
  color: var(--muted);
}

@media (min-width: 769px) {
  .dashboard-metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.dashboard-chart-card {
  padding: 20px;
}

@media (max-width: 768px) {
  .todaysell-table-actions {
    justify-content: stretch;
  }

  .todaysell-bulk-delete-btn {
    width: 100%;
  }

  .excel-table .todaysell-col-select {
    width: 44px;
  }

  .excel-table .todaysell-row-select {
    width: 17px;
    height: 17px;
  }

  .excel-table .col-actions {
    width: 72px;
  }

  .excel-table .todaysell-row .btn-save-row,
  .excel-table .todaysell-row .btn-add-row {
    min-width: 54px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

.dashboard-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(12, 18, 33, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.dashboard-detail-overlay[hidden] {
  display: none !important;
}

.dashboard-detail-modal {
  width: min(1200px, calc(100vw - 44px));
  max-height: calc(100vh - 44px);
  display: flex;
  overflow: visible;
}

.dashboard-detail-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
  width: 100%;
  min-height: 0;
  max-height: calc(100vh - 88px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.dashboard-detail-panel[hidden] {
  display: none !important;
}

.dashboard-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-detail-header h3 {
  margin: 0;
  font-size: 1.02rem;
}

.dashboard-detail-close {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.dashboard-detail-close:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.dashboard-detail-empty {
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.dashboard-detail-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 10px;
  max-width: 100%;
  overflow: auto;
}

.dashboard-detail-table th,
.dashboard-detail-table td {
  white-space: nowrap;
}

.dashboard-detail-total {
  margin-top: auto;
  padding-top: 6px;
  padding-bottom: 4px;
  text-align: right;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.dashboard-detail-total strong {
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.dashboard-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-chart-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dashboard-trend-select {
  min-width: 210px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.dashboard-chart-header h2 {
  margin: 0;
  font-size: 1.06rem;
}

.dashboard-chart-sub {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.dashboard-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 280px;
}

@media (max-width: 768px) {
  .dashboard-filter-row {
    margin-bottom: 14px;
  }

  .todaysell-filter,
  .instock-editing-hint,
  .todaysell-table-actions,
  .instock-table-actions {
    margin-left: -4px;
    margin-right: -4px;
  }

  .todaysell-filter .field-group,
  .dashboard-date-field,
  .instock-editing-hint,
  .todaysell-table-actions,
  .instock-table-actions {
    width: 100%;
  }

  .todaysell-filter .field-group {
    max-width: none;
  }

  .instock-editing-hint {
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: flex-start;
    padding: 10px 12px;
  }

  .instock-editing-hint strong {
    min-width: 0;
    word-break: break-word;
  }

  .dashboard-date-field {
    max-width: none;
    width: 100%;
    min-width: 0;
  }

  .dashboard-date-field .input-field {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .dashboard-chart-controls {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-trend-select {
    min-width: 0;
    width: 100%;
  }

  .dashboard-detail-panel {
    padding: 14px;
    max-height: calc(100vh - 54px);
  }

  .dashboard-detail-overlay {
    padding: 13px;
  }

  .dashboard-detail-modal {
    width: calc(100vw - 26px);
    max-height: calc(100vh - 26px);

  .excel-table .todaysell-col-select,
  .excel-table .instock-col-select {
    width: 40px;
  }

  .excel-table .todaysell-col-goods {
    min-width: 180px;
  }

  .excel-table .todaysell-col-qty {
    min-width: 86px;
  }

  .excel-table .todaysell-col-remain {
    min-width: 76px;
  }

  .excel-table .todaysell-row .todaysell-sid-select {
    min-width: 170px;
  }

  .excel-table .todaysell-row .todaysell-qty-input {
    min-width: 84px;
  }

  .excel-table .todaysell-row .todaysell-remain {
    min-width: 68px;
  }

  .excel-table .todaysell-row .btn-save-row,
  .excel-table .todaysell-row .btn-add-row {
    min-width: 52px;
    padding: 5px 9px;
    font-size: 0.74rem;
  }

  .excel-table .instock-col-vender {
    min-width: 130px;
  }

  .excel-table .instock-col-goods {
    min-width: 150px;
  }

  .excel-table .instock-col-money {
    min-width: 74px;
  }

  .excel-table .instock-col-margin {
    min-width: 70px;
  }

  .excel-table .instock-col-qty {
    min-width: 62px;
  }

  .excel-table .instock-col-date {
    min-width: 120px;
  }

  .excel-table .instock-row .input-field,
  .excel-table .instock-row .instock-margin,
  .excel-table .todaysell-row .input-field,
  .excel-table .todaysell-row .todaysell-remain {
    font-size: 0.88rem;
  }

  .excel-table .instock-row .btn-action-row,
  .excel-table .todaysell-row .btn-action-row {
    min-width: 52px;
    padding-left: 9px;
    padding-right: 9px;
    font-size: 0.74rem;
  }

  .excel-table .instock-row-select,
  .excel-table .todaysell-row-select {
    width: 16px;
    height: 16px;
  }

  .todaysell-bulk-delete-btn,
  .instock-bulk-delete-btn {
    width: 100%;
  }

  .instock-table-actions {
    margin-bottom: 12px;
  }

  .instock-editing-hint {
    font-size: 0.9rem;
  }
  }

  .dashboard-detail-header {
    flex-wrap: wrap;
  }

  .dashboard-detail-header h3 {
    font-size: 0.98rem;
  }

  .dashboard-detail-total {
    text-align: left;
  }
}

/* ---------- Booking Query ---------- */
.booking-query-page .table-pager td {
  text-align: center;
  padding: 12px;
  background: var(--surface);
}

.booking-query-page .table-pager a,
.booking-query-page .table-pager span {
  display: inline-block;
  min-width: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 2px;
  font-size: 0.85rem;
}

.booking-query-page .table-pager span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.booking-query-page .table-pager a {
  color: var(--ink);
  background: var(--surface);
}

.booking-query-page .table-pager a:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.booking-query-summary {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
}

.booking-query-summary-label {
  color: var(--muted);
  font-weight: 700;
}

.booking-query-summary-value {
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 1.08rem;
}

@media (max-width: 768px) {
  .booking-query-page .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .booking-query-page .booking-query-grid {
    min-width: 1020px;
    table-layout: auto;
  }

  .booking-query-page .booking-query-grid thead {
    display: table-header-group;
  }

  .booking-query-page .booking-query-grid,
  .booking-query-page .booking-query-grid th,
  .booking-query-page .booking-query-grid td {
    width: auto;
  }

  .booking-query-page .booking-query-grid tbody {
    display: table-row-group;
  }

  .booking-query-page .booking-query-grid tr {
    display: table-row;
  }

  .booking-query-page .booking-query-grid th,
  .booking-query-page .booking-query-grid td {
    display: table-cell;
  }

  .booking-query-page .booking-query-grid td {
    white-space: nowrap;
    word-break: normal;
  }

  .booking-query-page .booking-query-grid .table-pager td::before {
    content: none;
  }

  .booking-query-summary {
    justify-content: flex-start;
  }
}

/* ---------- 讀取遮罩 ---------- */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 30, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-card {
  background: var(--surface);
  padding: 22px 28px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 700;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(227, 64, 45, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 列印樣式 ---------- */
@media print {
  .top-nav,
  .menu-mobile-toggle,
  .loading-mask,
  .button,
  .filter-actions {
    display: none !important;
  }

  .page-shell {
    margin: 0 !important;
    max-width: none !important;
    padding: 0 !important;
  }

  .card,
  .panel {
    box-shadow: none !important;
    border: none !important;
  }
}
