/* ===== 全域 ===== */
:root {
  --gh-bg: #eef2f9;
  --gh-bg-soft: #f7f9fc;
  --gh-surface: #ffffff;
  --gh-border: #dee5ef;
  --gh-border-strong: #c8d1de;
  --gh-text: #1f2937;
  --gh-text-muted: #6b7280;
  --gh-primary: #2563eb;
  --gh-primary-strong: #1d4ed8;
  --gh-primary-soft: #e8f0fe;
  --gh-accent: #7c3aed;
  --gh-accent-soft: #f1ecff;
  --gh-success: #16a34a;
  --gh-success-soft: #dcfce7;
  --gh-warning: #f59e0b;
  --gh-warning-soft: #fff4d6;
  --gh-danger: #dc2626;
  --gh-danger-soft: #fee2e2;
  --gh-info: #0891b2;
  --gh-info-soft: #cffafe;
  --gh-shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
  --gh-shadow-md: 0 6px 18px rgba(15,23,42,.1);
  --gh-shadow-lg: 0 12px 28px rgba(15,23,42,.12);
  --gh-brand-gradient: linear-gradient(120deg, #1e3a8a 0%, #2563eb 45%, #7c3aed 100%);
  /* 品牌獨立色：琥珀／日落，象徵配送、活力、即時 */
  --gh-brand: #f97316;
  --gh-brand-2: #fbbf24;
  --gh-brand-gradient-logo: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
  --gh-brand-glow: 0 4px 14px rgba(249, 115, 22, .42);
}
html, body {
  background:
    radial-gradient(1100px 520px at -10% -20%, rgba(124,58,237,.08), transparent 60%),
    radial-gradient(900px 480px at 110% -10%, rgba(37,99,235,.08), transparent 55%),
    var(--gh-bg);
  background-attachment: fixed;
  color: var(--gh-text);
  -webkit-font-smoothing: antialiased;
  font-family: "Microsoft JhengHei UI", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main.container-fluid {
  max-width: 1600px;
  padding-top: 16px;
  position: relative;
  z-index: auto;
}
.app-main {
  clear: both;
}
a { text-decoration: none; color: var(--gh-primary); }
a:hover { color: var(--gh-primary-strong); }

/* ===== 導覽列 ===== */
.navbar.bg-dark {
  background: var(--gh-brand-gradient) !important;
  box-shadow: 0 2px 14px rgba(30, 58, 138, .25);
  padding-top: .4rem;
  padding-bottom: .4rem;
  position: relative;
  z-index: 1040;
  overflow: visible;
}
.navbar .container-fluid,
.navbar .navbar-collapse,
.navbar .navbar-nav,
.navbar .nav-item.dropdown {
  overflow: visible;
}
/* === 品牌 chip：把「購好康派車系統」獨立出來 === */
.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .85rem .3rem .65rem;
  margin-right: .9rem;
  border-radius: 12px;
  background: var(--gh-brand-gradient-logo);
  color: #fff !important;
  font-weight: 900;
  letter-spacing: 1.5px;
  font-size: 1.05rem;
  text-shadow: 0 1px 0 rgba(120, 50, 0, .25);
  box-shadow:
    var(--gh-brand-glow),
    inset 0 1px 0 rgba(255, 255, 255, .35),
    inset 0 -1px 0 rgba(120, 50, 0, .25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.navbar-brand:hover {
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow:
    0 6px 18px rgba(249, 115, 22, .55),
    inset 0 1px 0 rgba(255, 255, 255, .4),
    inset 0 -1px 0 rgba(120, 50, 0, .25);
}
/* logo 標記：白色圓底 + 深色圓點，模擬車輪 / 出貨點 */
.navbar-brand::before {
  content: '';
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ea580c 0 4px, transparent 5px),
    #ffffff;
  box-shadow:
    inset 0 0 0 2px #ea580c,
    0 1px 2px rgba(0, 0, 0, .2);
}
.navbar .nav-link { font-size: .92rem; padding: .35rem .8rem; border-radius: 8px; transition: background .15s ease, color .15s ease; }
.navbar .nav-link:hover { background: rgba(255,255,255,.12); }
.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] {
  background: rgba(255,255,255,.22);
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.6);
}
.navbar .dropdown-menu { border-radius: 8px; box-shadow: var(--gh-shadow-md); border: 1px solid var(--gh-border); padding: .35rem; z-index: 1060; }
.navbar .dropdown-menu .dropdown-item { border-radius: 6px; font-size: .92rem; padding: .4rem .7rem; }
.navbar .dropdown-menu .dropdown-item:active { background: var(--gh-primary); }
.navbar-search { min-width: 200px; }
.navbar-search .form-control { background: rgba(255,255,255,.12); border: 0; color: #fff; }
.navbar-search .form-control::placeholder { color: rgba(255,255,255,.65); }
.navbar-search .form-control:focus { background: rgba(255,255,255,.22); color: #fff; box-shadow: none; }
.user-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  color: rgba(255,255,255,.92);
  background: rgba(255,255,255,.08);
  padding: .2rem .55rem; border-radius: 999px; font-size: .82rem;
}
.user-chip .role-tag { color: rgba(255,255,255,.7); font-size: .72rem; }

/* ===== 標題 / 卡片 ===== */
.page-header .page-title {
  font-weight: 800;
  letter-spacing: .3px;
  background: linear-gradient(90deg, #1e3a8a, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card {
  border: 1px solid var(--gh-border);
  border-radius: 12px;
  box-shadow: var(--gh-shadow);
  background: var(--gh-surface);
  overflow: hidden;
}
.card-header {
  background: linear-gradient(180deg, #f7f9fc 0%, #f0f4fa 100%);
  border-bottom: 1px solid var(--gh-border);
  font-weight: 600;
  letter-spacing: .2px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  position: relative;
}
.card-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gh-brand-gradient);
  border-top-left-radius: 12px;
}

/* ===== KPI 卡片 ===== */
.stat-card {
  display: block;
  color: inherit;
  border-left: 4px solid transparent;
  transition: box-shadow .18s ease, transform .18s ease;
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}
a.stat-card:hover { box-shadow: var(--gh-shadow-md); transform: translateY(-2px); }
.stat-card .stat-label { font-size: .82rem; font-weight: 500; }
.stat-card .stat-value {
  font-size: 1.95rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.5px;
  color: var(--gh-text);
}
.stat-card .stat-icon {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gh-primary-soft); color: var(--gh-primary);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 4px 10px rgba(37,99,235,.12);
}
.stat-card-primary { border-left-color: var(--gh-primary); }
.stat-card-primary .stat-icon { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: var(--gh-primary-strong); }
.stat-card-primary .stat-value { color: var(--gh-primary-strong); }
.stat-card-success { border-left-color: var(--gh-success); }
.stat-card-success .stat-icon { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #15803d; }
.stat-card-success .stat-value { color: #15803d; }
.stat-card-info { border-left-color: var(--gh-info); }
.stat-card-info .stat-icon { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #0e7490; }
.stat-card-info .stat-value { color: #0e7490; }
.stat-card-warning { border-left-color: var(--gh-warning); }
.stat-card-warning .stat-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #b45309; }
.stat-card-warning .stat-value { color: #b45309; }
.stat-card-danger {
  border-left-color: var(--gh-danger);
  background: linear-gradient(180deg, #fff5f5 0%, #ffeaea 100%);
}
.stat-card-danger .stat-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); color: var(--gh-danger); }
.stat-card-danger .stat-value { color: var(--gh-danger); }
.stat-card-default { border-left-color: var(--gh-border-strong); }
.stat-card-default .stat-icon { background: linear-gradient(135deg, #eef2f7, #e2e8f0); color: #475569; }

/* ===== 表格 ===== */
.table { vertical-align: middle; margin-bottom: 0; }
.table thead th {
  background: linear-gradient(180deg, #eef2fb 0%, #e6ecf6 100%);
  border-bottom: 1px solid var(--gh-border) !important;
  color: #334155;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .4px;
  white-space: nowrap;
  text-transform: none;
}
.table tbody td { font-size: .9rem; border-color: #eef2f8; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fafbfd; }
.table-hover tbody tr { transition: background .12s ease; }
.table-hover tbody tr:hover > * { background: linear-gradient(90deg, #eef4ff 0%, #f4ecff 100%); }
.table.table-sticky thead th { position: sticky; top: 0; z-index: 5; }
.table .text-muted { color: var(--gh-text-muted) !important; }
/* 強調的金額 / 數字欄 */
.table td.fw-medium { color: #111827; font-weight: 600; }

/* 長文字省略，hover 顯示完整 */
.cell-ellipsis {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}
.cell-address { color: var(--gh-text-muted); font-size: .82rem; }

/* ===== 按鈕 ===== */
.btn {
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { font-size: .82rem; padding: .3rem .65rem; border-radius: 7px; }
.action-btn { min-width: 56px; }
.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.btn-success {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  border-color: #16a34a;
  box-shadow: 0 2px 6px rgba(22,163,74,.22);
}
.btn-success:hover, .btn-success:focus {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  border-color: #15803d;
  box-shadow: 0 4px 12px rgba(22,163,74,.32);
}
.btn-warning {
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  border-color: #f59e0b;
  color: #422006;
  box-shadow: 0 2px 6px rgba(245,158,11,.25);
}
.btn-warning:hover, .btn-warning:focus { background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%); border-color: #d97706; color: #422006; }
.btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  border-color: #dc2626;
  box-shadow: 0 2px 6px rgba(220,38,38,.25);
}
.btn-danger:hover, .btn-danger:focus {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  border-color: #b91c1c;
  box-shadow: 0 4px 12px rgba(220,38,38,.35);
}
.btn-outline-primary { color: var(--gh-primary); border-color: var(--gh-primary); }
.btn-outline-primary:hover { background: var(--gh-primary); border-color: var(--gh-primary); color: #fff; }
.btn-outline-info { color: var(--gh-info); border-color: var(--gh-info); }
.btn-outline-info:hover { background: var(--gh-info); border-color: var(--gh-info); color: #fff; }
.btn-outline-success { color: var(--gh-success); border-color: var(--gh-success); }
.btn-outline-success:hover { background: var(--gh-success); border-color: var(--gh-success); color: #fff; }
.btn-outline-warning { color: #b45309; border-color: #f59e0b; }
.btn-outline-warning:hover { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-outline-danger { color: var(--gh-danger); border-color: var(--gh-danger); }
.btn-outline-danger:hover { background: var(--gh-danger); border-color: var(--gh-danger); color: #fff; }

/* 表格內動作群組整齊間距 */
td .btn + .btn,
td .btn + form,
td form + .btn,
td form + form { margin-left: 4px; }

/* ===== 徽章 ===== */
.badge {
  font-weight: 700;
  letter-spacing: .4px;
  padding: .38em .7em;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.badge.status-badge { font-size: .76rem; }
.badge.badge-sm { padding: .2em .55em; font-size: .72rem; }
.badge.bg-primary   { background: linear-gradient(135deg, #3b82f6, #2563eb) !important; }
.badge.bg-success   { background: linear-gradient(135deg, #22c55e, #16a34a) !important; }
.badge.bg-info      { background: linear-gradient(135deg, #22d3ee, #0891b2) !important; color: #fff !important; }
.badge.bg-warning   { background: linear-gradient(135deg, #fcd34d, #f59e0b) !important; color: #422006 !important; }
.badge.bg-danger    { background: linear-gradient(135deg, #f87171, #dc2626) !important; }
.badge.bg-secondary { background: linear-gradient(135deg, #94a3b8, #64748b) !important; }
.badge.bg-dark      { background: linear-gradient(135deg, #475569, #1e293b) !important; }

/* ===== 表單 ===== */
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: .3rem; }
.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--gh-border-strong);
  font-size: .92rem;
  background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--gh-primary);
  box-shadow: 0 0 0 .22rem rgba(37, 99, 235, .18);
}
.form-check-input:checked {
  background-color: var(--gh-primary);
  border-color: var(--gh-primary);
}
.form-switch .form-check-input:checked {
  background-color: var(--gh-success);
  border-color: var(--gh-success);
}
.toolbar .input-group .input-group-text {
  border-color: var(--gh-border-strong);
  color: var(--gh-primary);
  background: #fff;
}
.toolbar .input-group:focus-within .input-group-text { color: var(--gh-primary-strong); }

/* ===== 既有：拖拉模板 ===== */
.paste-box { min-height: 140px; font-family: Consolas, "Microsoft JhengHei UI", monospace; }
.paste-box-lg { min-height: 220px; font-family: Consolas, "Microsoft JhengHei UI", monospace; }

.status-button-group,
.status-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.status-pill {
  border: 1px solid currentColor;
  border-radius: 999px;
  background: #fff;
  padding: 3px 12px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, opacity .15s ease, transform .1s ease;
}
.status-pill:hover:not(:disabled):not(.active) { background: rgba(0,0,0,.03); }
.status-pill:disabled { cursor: default; opacity: .75; }
.status-pill-mini { padding: 1px 8px; font-size: 12px; vertical-align: middle; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.status-上班 { color: #198754; }
.status-休息 { color: #b58100; }
.status-停用 { color: #dc3545; }
.status-上班.active,
.btn-check:checked + .status-上班 { background: #198754; border-color: #198754; color: #fff; }
.status-休息.active,
.btn-check:checked + .status-休息 { background: #ffc107; border-color: #ffc107; color: #212529; }
.status-停用.active,
.btn-check:checked + .status-停用 { background: #dc3545; border-color: #dc3545; color: #fff; }

.progress-badge { font-weight: 600; }
.progress-尚未派車 { background: #6c757d; }
.product-drag-handle {
  cursor: grab;
  user-select: none;
  text-align: center;
}
.progress-部分派車 { background: #ffc107; color: #212529; }
.progress-已派車 { background: #0d6efd; }
.progress-配送中 { background: #0dcaf0; color: #212529; }
.progress-已完成 { background: #198754; }
.progress-無需配送 { background: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; }

.hash-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Consolas, monospace;
  font-size: .82rem;
}

.drag-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, #ffffff 0%, #f4f7ff 100%);
  border-color: #c7d2fe;
}
.drag-toolbar .card-body { background: transparent; }
.drag-board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  height: calc(100vh - 200px);
  padding-bottom: 8px;
  scroll-behavior: smooth;
  position: relative;
  align-items: stretch;
  scrollbar-gutter: stable;
}
.drag-column {
  min-width: 240px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gh-border);
  border-radius: 8px;
  background: #fff;
}
.unassigned-column {
  min-width: 250px;
  max-width: 250px;
  position: sticky;
  left: 0;
  z-index: 12;
  box-shadow: 8px 0 18px rgba(15, 23, 42, .08);
  align-self: stretch;
}
.unassigned-column .drag-column-header { background: linear-gradient(135deg, #dbeafe, #ede9fe); }
.drag-column-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gh-border);
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-radius: 8px 8px 0 0;
}
.driver-column .drag-column-header { background: linear-gradient(135deg, #ecfdf5, #f0fdfa); }
.driver-column.border-warning .drag-column-header { background: linear-gradient(135deg, #fef3c7, #fff7ed); }
.drag-column-header .driver-title { font-size: 12.5px; line-height: 1.4; }
.drag-list {
  overflow-y: auto;
  min-height: 100px;
  flex: 1;
  padding: 6px;
  background: #fbfcfd;
}
.store-list { border: 0; }
.drag-source-tabs .nav-link {
  font-size: 12px;
  padding: 4px 6px;
}
.drag-source-content {
  display: flex;
  flex: 1;
  min-height: 0;
}
.drag-source-pane {
  width: 100%;
  min-height: 0;
}
.drag-source-pane.active {
  display: flex !important;
  flex-direction: column;
}
.store-group-card {
  border: 1px solid #c7d2fe;
  border-radius: 7px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  padding: 7px 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(37,99,235,.08);
}
.store-group-card:hover {
  border-color: #818cf8;
  background: #eef2ff;
}
.store-group-card:active { cursor: grabbing; }
.store-group-name {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.store-group-badge { font-size: 10px; }
.group-preview {
  margin-top: 2px;
}
.store-group-hint {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  color: #4338ca;
  font-size: 11px;
  font-weight: 600;
}
.store-card {
  display: flex;
  gap: 6px;
  border: 1px solid #e1e6ed;
  border-radius: 6px;
  background: #fff;
  padding: 5px 7px;
  margin-bottom: 5px;
  font-size: 12.5px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.store-card:hover { border-color: #b8c4d6; }
.store-card:active { cursor: grabbing; }
.store-card.is-selected-for-assign {
  border-color: #f97316;
  background: #fff7ed;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, .18), 0 6px 18px rgba(249, 115, 22, .16);
}
.store-card.is-selected-for-assign .store-assign-btn {
  color: #fff;
  border-color: #f97316;
  background: #f97316;
}
.store-card .drag-order {
  width: 22px;
  flex: 0 0 22px;
  color: var(--gh-text-muted);
  font-size: 11px;
  line-height: 1.4;
}
.store-card-main { min-width: 0; flex: 1; }
.store-assign-btn {
  align-self: flex-start;
  flex: 0 0 auto;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.35;
}
.store-card .store-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.store-route-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin: 2px 0;
}
.store-route-badge {
  font-size: 10px;
  font-weight: 500;
  color: #1d4ed8 !important;
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
}
.store-card .store-meta {
  color: var(--gh-text-muted);
  font-size: 11.5px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-assign-menu {
  position: fixed;
  width: 260px;
  z-index: 1080;
  padding: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .18);
}
.driver-column:has(.driver-list:hover),
.driver-column:hover {
  border-color: #93c5fd;
}
.driver-list {
  transition: background .15s ease, box-shadow .15s ease;
}
.driver-list:hover {
  background: #f0f9ff;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}
.driver-column.is-route-filtered {
  display: none !important;
}
.group-store-row {
  cursor: grab;
}
.group-store-row:active {
  cursor: grabbing;
}
.group-order-cell {
  white-space: nowrap;
}
.group-sort-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 4px;
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  color: var(--gh-text-muted);
  background: #fff;
  cursor: grab;
}
.group-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}
.group-builder .card {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  height: calc(100vh - 260px);
}
.group-store-list {
  flex: 1 1 auto;
  min-height: 360px;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  padding-bottom: 72px;
  background: #fbfcfd;
}
.group-store-list-target {
  background: #f8fbff;
  border: 1px dashed #bfdbfe;
  border-radius: 0 0 8px 8px;
}
.group-store-card {
  display: flex;
  gap: 7px;
  border: 1px solid #e1e6ed;
  border-radius: 7px;
  background: #fff;
  padding: 6px 8px;
  margin-bottom: 6px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.group-store-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}
.group-store-card:active {
  cursor: grabbing;
}
.group-store-list .sortable-ghost,
.group-store-list .drag-ghost {
  opacity: .45;
  background: #dbeafe;
}
.group-store-list .sortable-chosen,
.group-store-list .drag-chosen {
  border-color: #2563eb;
}
.group-empty-hint {
  pointer-events: none;
  padding: 8px;
}
.group-store-order {
  flex: 0 0 28px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.group-store-main {
  min-width: 0;
  flex: 1;
}
.group-store-actions {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}
.group-store-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-store-meta {
  color: var(--gh-text-muted);
  font-size: 11.5px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-xs {
  --bs-btn-padding-y: .05rem;
  --bs-btn-padding-x: .35rem;
  --bs-btn-font-size: .72rem;
}
.drag-column.is-collapsed { min-width: 240px; height: auto; }
.drag-column.is-collapsed .drag-list { display: none; }
.drag-ghost { background: #e7f1ff; opacity: .65; }
.drag-chosen { background: #f8fbff; }

.adjust-action-col { min-width: 560px; }
.adjustment-inline-form { min-width: 540px; }
.adjustment-inline-form .qty-input { width: 80px; }
.adjustment-inline-form .reason-input { width: 140px; }

.driver-mobile-page { max-width: 760px; margin: 0 auto; }
.driver-task-card,
.driver-stop-card { border-radius: 8px; }
.driver-stop-card .btn,
.driver-task-card .btn { min-height: 46px; }
.driver-stop-done { opacity: .62; }

/* ===== 列印頁（保持白底黑字 A4） ===== */
.print-body {
  background: #fff !important;
  color: #000;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  font-size: 14px;
  padding: 24px;
}
.print-button { padding: 8px 14px; margin-bottom: 16px; }
.print-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  margin-bottom: 12px;
}
.print-footer {
  border-top: 1px solid #333;
  font-size: 12px;
  margin-top: 16px;
  padding-top: 8px;
}
.print-store {
  border-top: 1px solid #333;
  padding: 12px 0;
  page-break-inside: avoid;
}
.print-store h2 { font-size: 18px; margin: 0 0 6px; }
.print-products-title { margin-top: 8px; font-weight: 700; }
.print-products { margin: 4px 0 10px 20px; padding: 0; }
.print-sign { margin-top: 8px; }
.driver-section { page-break-after: always; }
.driver-section.last { page-break-after: auto; }
@media print {
  .print-button { display: none; }
  .print-body { padding: 0; }
  .single-driver-print { padding-bottom: 28px; }
  .single-driver-print .print-footer {
    position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  }
}

@page driver-matrix-page {
  size: A4 landscape;
  margin: 10mm;
}
.driver-matrix-print {
  page: driver-matrix-page;
  font-size: 12px;
}
.driver-matrix-summary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.driver-matrix-print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.driver-matrix-print-table th,
.driver-matrix-print-table td {
  border: 1px solid #333;
  padding: 4px 5px;
  vertical-align: middle;
}
.driver-matrix-print-table th {
  background: #eee;
  font-weight: 700;
  text-align: center;
}
.driver-matrix-item-col {
  min-width: 150px;
  text-align: left;
}
.driver-matrix-store-col {
  min-width: 52px;
  max-width: 78px;
  word-break: keep-all;
}
.driver-matrix-total-col {
  min-width: 54px;
  font-weight: 700;
}
.driver-matrix-note-col {
  min-width: 160px;
  text-align: left;
}
.small-muted {
  color: #555;
  font-size: 11px;
}

/* ===== 警示卡 ===== */
.alert {
  border-radius: 10px;
  border: 1px solid transparent;
}
.alert-success { background: linear-gradient(180deg, #ecfdf5, #d1fae5); border-color: #a7f3d0; color: #065f46; }
.alert-info    { background: linear-gradient(180deg, #ecfeff, #cffafe); border-color: #a5f3fc; color: #155e75; }
.alert-warning { background: linear-gradient(180deg, #fffbeb, #fef3c7); border-color: #fde68a; color: #854d0e; }
.alert-danger  { background: linear-gradient(180deg, #fef2f2, #fee2e2); border-color: #fecaca; color: #991b1b; }
.alert-primary { background: linear-gradient(180deg, #eff6ff, #dbeafe); border-color: #bfdbfe; color: #1e40af; }
.alert-soft-warning {
  background: linear-gradient(180deg, #fff8e1, #ffedb0);
  color: #854d0e;
  border: 1px solid #fde68a;
  border-radius: 10px;
}
.alert-soft-danger {
  background: linear-gradient(180deg, #fff5f5, #fee2e2);
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
}

/* ===== 搜尋分區 ===== */
.search-section .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-empty { color: var(--gh-text-muted); padding: 1rem; }

/* ===== RWD ===== */
@media (max-width: 991.98px) {
  main.container-fluid { padding-left: 12px; padding-right: 12px; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .page-header .page-title { font-size: 1.25rem; }
  .navbar-search { min-width: 100%; margin-bottom: .5rem; }
  .table tbody td { font-size: .85rem; }
  .cell-ellipsis { max-width: 160px; }
}
@media (max-width: 575.98px) {
  .stat-card .card-body { padding: .75rem; }
  .stat-card .stat-icon { width: 32px; height: 32px; flex-basis: 32px; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .table { font-size: .85rem; }
  .action-btn { min-width: 0; padding: .25rem .5rem; font-size: .78rem; }
  .toolbar .row > .col-12 { width: 100%; }
}

/* ===== 我的快捷列 ===== */
.shortcut-bar {
  position: relative;
  top: auto;
  z-index: 1;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--gh-border);
  box-shadow: 0 2px 8px rgba(15,23,42,.05);
  backdrop-filter: blur(8px);
  margin-bottom: 16px;
}
.shortcut-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  min-width: 0;
  scrollbar-width: thin;
}
.shortcut-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--gh-border);
  border-radius: 999px;
  color: var(--gh-text);
  background: #fff;
  font-size: .85rem;
  line-height: 1;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s ease;
}
.shortcut-pill:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}
.shortcut-pill.active {
  border-color: #2563eb;
  color: #fff;
  background: #2563eb;
  box-shadow: 0 4px 10px rgba(37,99,235,.22);
}
.shortcut-icon { font-size: .8rem; }
.pin-button {
  border: 1px solid var(--gh-border);
  border-radius: 999px;
  background: #fff;
  color: var(--gh-text);
  white-space: nowrap;
}
.pin-button:hover,
.pin-button.is-pinned {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}
@media (max-width: 991.98px) {
  .shortcut-bar {
    position: relative;
    top: auto;
    z-index: 1;
  }
  .shortcut-pill { font-size: .8rem; padding: 6px 10px; }
}

/* ===== 配送量矩陣調整表 ===== */
.matrix-page-header {
  margin-top: 16px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}
.matrix-page-title-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.matrix-header-copy {
  min-width: 260px;
  flex: 1 1 360px;
}
.matrix-header-actions {
  display: flex;
  flex: 1 1 320px;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.matrix-header-actions .btn {
  white-space: nowrap;
}
.matrix-route-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.matrix-route-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--gh-border);
  border-radius: 999px;
  background: #fff;
  color: var(--gh-text);
  font-size: .86rem;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s ease;
}
.matrix-route-pill:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}
.matrix-route-pill.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 10px rgba(37,99,235,.18);
}
.matrix-route-pill span {
  font-size: .74rem;
  opacity: .8;
}
.matrix-selection-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--gh-border);
  border-bottom: 1px solid var(--gh-border);
  background: #fff7ed;
}
.matrix-global-selection-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #fdba74;
  border-radius: 999px;
  color: #9a3412;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}
.matrix-table-wrap {
  max-height: calc(100vh - 250px);
  overflow: auto;
  position: relative;
}
.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 960px;
}
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 var(--gh-border);
}
.matrix-sticky-col {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 300px;
  min-width: 300px;
  max-width: 340px;
  background: #fff;
  box-shadow: 1px 0 0 var(--gh-border);
  white-space: normal;
  overflow: visible;
  vertical-align: top;
}
.matrix-table thead .matrix-sticky-col {
  z-index: 5;
  background: #f8fafc;
}
.matrix-store-th {
  min-width: 116px;
  max-width: 136px;
  white-space: nowrap;
}
.matrix-qty-td {
  width: 116px;
  min-width: 116px;
  padding: 4px !important;
  vertical-align: top;
  overflow: visible !important;
}
.matrix-cell-input {
  width: 74px;
  min-width: 74px;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}
.matrix-cell-changed {
  border-width: 2px;
  font-weight: 700;
}
.matrix-cell-increase,
.matrix-cell-new {
  background: #ecfdf5;
  border-color: #34d399;
  color: #065f46;
}
.matrix-cell-decrease {
  background: #fff1f2;
  border-color: #fb7185;
  color: #9f1239;
}
.matrix-cell-zero {
  background: #f1f5f9;
  color: #64748b;
}
.matrix-row-new-product .matrix-sticky-col,
.matrix-row-new-product td {
  background: #eff6ff;
}
.matrix-row-new-product .matrix-sticky-col {
  box-shadow: 1px 0 0 #bfdbfe;
}
.matrix-total-cell,
.matrix-row-total {
  color: #b91c1c;
}
.matrix-note-th {
  min-width: 220px;
}
.matrix-note-input {
  min-width: 210px;
}
.matrix-product-name-wrap {
  line-height: 1.25;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
  margin-bottom: 2px;
}
.matrix-product-rule-trigger {
  color: inherit;
  text-decoration: none;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}
.matrix-product-rule-trigger:hover {
  color: #2563eb;
  text-decoration: underline;
}
.matrix-box-control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  min-width: 210px;
  overflow: visible;
}
.matrix-box-button {
  --bs-btn-padding-y: .14rem;
  --bs-btn-padding-x: .45rem;
  --bs-btn-font-size: .76rem;
  line-height: 1.2;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.matrix-box-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 3px;
  font-size: .72rem;
  color: #1d4ed8 !important;
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
}
.matrix-box-empty-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 3px;
  font-size: .72rem;
  color: #64748b !important;
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}
.matrix-product-cell {
  min-width: 280px;
  max-width: 330px;
  white-space: normal;
  overflow: visible;
  line-height: 1.3;
}
.matrix-product-name {
  display: block;
  font-weight: 700;
  color: inherit;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}
.matrix-unit-text {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}
.matrix-product-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  align-items: center;
  overflow: visible;
}
.box-round-btn {
  display: inline-flex !important;
  visibility: visible !important;
  align-items: center;
  font-size: 12px;
  padding: 2px 8px;
  line-height: 1.25;
  white-space: nowrap;
}
.product-rule-badge,
.product-rule-missing {
  display: inline-flex !important;
  visibility: visible !important;
  align-items: center;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.25;
  white-space: nowrap;
}
.product-rule-badge {
  background: #dcfce7 !important;
  color: #166534 !important;
}
.product-rule-missing {
  background: #fef3c7 !important;
  color: #92400e !important;
}
.matrix-row-box-toolbar {
  gap: 3px;
  margin-top: 5px;
}
.matrix-row-box-toolbar .btn {
  --bs-btn-padding-y: .1rem;
  --bs-btn-padding-x: .35rem;
  --bs-btn-font-size: .7rem;
  line-height: 1.2;
}
.matrix-row-selection-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff7ed;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
}
.matrix-qty-cell,
.matrix-cell-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 106px;
  min-height: 88px;
  padding: 5px 4px;
  border-radius: 7px;
  overflow: visible !important;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.matrix-qty-cell:focus-within,
.matrix-qty-cell:hover,
.matrix-cell-editor:focus-within,
.matrix-cell-editor:hover {
  border-color: #fed7aa;
  background: #fffaf0;
}
.matrix-cell-selected {
  background: #ffedd5 !important;
  border: 2px solid #f97316 !important;
  box-shadow: 0 0 0 2px rgba(249,115,22,.15);
}
.matrix-cell-selected.matrix-cell-box-mode {
  background: #fed7aa !important;
  border: 2px solid #ea580c !important;
  box-shadow: 0 0 0 2px rgba(234,88,12,.2);
}
.matrix-cell-select-hint {
  display: block;
  color: #9a3412;
  background: #fff7ed;
  border: 1px dashed #fdba74;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.15;
  padding: 2px 7px;
  user-select: none;
  white-space: nowrap;
  cursor: pointer;
}
.matrix-box-mode-wrap,
.matrix-box-mode-label,
.matrix-box-mode-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  user-select: none;
  white-space: nowrap;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible !important;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid #fdba74;
  border-radius: 999px;
  background: #fff7ed;
  cursor: pointer;
}
.matrix-box-mode-checkbox,
.matrix-box-mode-toggle .form-check-input {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 14px !important;
  height: 14px !important;
  margin: 0;
  accent-color: #f97316;
  flex: 0 0 auto;
}
.matrix-box-mode-text {
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  color: #92400e;
}
.matrix-box-mode-checked {
  display: none;
}
.matrix-box-mode-checkbox:checked + .matrix-box-mode-text .matrix-box-mode-unchecked {
  display: none;
}
.matrix-box-mode-checkbox:checked + .matrix-box-mode-text .matrix-box-mode-checked {
  display: inline;
}
.matrix-box-mode-checkbox:disabled {
  opacity: .55 !important;
  cursor: not-allowed;
}
.matrix-cell-box-mode {
  background: #fff7ed !important;
  border-color: #fb923c !important;
  box-shadow: inset 0 0 0 1px #fed7aa;
}
.matrix-cell-box-mode .matrix-cell-input {
  border-color: #fb923c;
  background: #fff;
  color: #9a3412;
  font-weight: 700;
}
.matrix-cell-box-summary {
  color: #9a3412;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
}
.matrix-cell-box-summary small {
  display: block;
  color: #92400e;
  font-size: 10.5px;
}
.matrix-box-original-note {
  display: block;
  font-size: 11px;
  color: #92400e;
  margin-top: 2px;
}
@media (max-width: 768px) {
  .matrix-page-header {
    margin-top: 12px;
  }
  .matrix-header-actions {
    justify-content: flex-start;
  }
  .matrix-header-actions .btn {
    flex: 1 1 auto;
  }
  .matrix-table-wrap {
    max-height: calc(100vh - 210px);
  }
  .matrix-sticky-col {
    width: 240px;
    min-width: 240px;
    max-width: 280px;
  }
}
