/* ========================================
   楱庡＋閰嶉€佺郴绲� - Design System
   ======================================== */

:root {
  /* Core Colors */
  --bg-primary: #0a0a14;
  --bg-secondary: #111125;
  --bg-card: #181835;
  --bg-card-hover: #1e1e42;
  --bg-surface: #1a1a38;
  --bg-input: #12122a;
  --border-color: rgba(255,255,255,0.06);
  --border-active: rgba(255,255,255,0.12);

  /* Status Colors */
  --green: #00e676;
  --green-bg: rgba(0,230,118,0.12);
  --green-border: rgba(0,230,118,0.3);
  --orange: #ff9100;
  --orange-bg: rgba(255,145,0,0.12);
  --orange-border: rgba(255,145,0,0.3);
  --red: #ff1744;
  --red-bg: rgba(255,23,68,0.12);
  --red-border: rgba(255,23,68,0.4);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-muted: #555577;

  /* Accent */
  --accent: #7c6aff;
  --accent-bg: rgba(124,106,255,0.12);

  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --touch-min: 48px;
  --header-h: 60px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', 'Noto Sans TC', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: var(--text-primary); }
a { color: inherit; text-decoration: none; }

/* ========== HEADER ========== */
#app-header, 
.bottom-nav {
  max-width: 1000px !important; /* 🌟 設定統一的最大寬度 */
  width: 100% !important;
  margin: 0 auto !important;   /* 🌟 畫面水平置中 */
  left: 0 !important;
  right: 0 !important;
  box-sizing: border-box !important;
}

#app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, rgba(16,16,40,0.95), rgba(10,10,20,0.98));
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-h);
  display: flex !important;
  justify-content: space-between !important; /* 🌟 強制將左右兩塊推向邊緣 */
  align-items: center !important;
  padding: 0 16px !important; /* 🌟 這裡的 16px 是內容距離 1000px 邊界線的距離 */
}

@media (max-width: 600px) {
  #app-header {
    padding: 0 12px !important;
  }
}

.header-content {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; width: 100%;
}
.header-left {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 0 !important;
}
.header-icon { font-size: 28px; color: var(--accent); }
.header-left h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.header-right {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 0 !important;
}
.header-badge {
  background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700;
  min-width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 13px; padding: 0 7px;
}
.header-btn {
  width: var(--touch-min); height: var(--touch-min);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 0.2s var(--ease);
}
.header-btn:active { background: rgba(255,255,255,0.08); }
.header-btn .material-icons-round { font-size: 24px; color: var(--text-secondary); }

/* ========== SECTIONS ========== */
.app-section {
  max-width: 600px; margin: 12px auto;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer; user-select: none;
  -webkit-user-select: none;
  transition: background 0.2s var(--ease);
}
.section-header:active { background: rgba(255,255,255,0.03); }
.section-title-group { display: flex; align-items: center; gap: 10px; }
.section-icon { font-size: 22px; color: var(--accent); }
.section-title-group h2 { font-size: 16px; font-weight: 700; }
.section-count {
  background: var(--accent-bg); color: var(--accent);
  font-size: 12px; font-weight: 700;
  min-width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; padding: 0 6px;
}
.section-count.outstanding-count { background: var(--red-bg); color: var(--red); }
.section-actions { display: flex; align-items: center; gap: 4px; }
.btn-add {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(124,106,255,0.3);
}
.btn-add:active { transform: scale(0.9); }
.btn-add .material-icons-round { font-size: 24px; color: #fff; }
.chevron {
  font-size: 24px; color: var(--text-secondary);
  transition: transform 0.3s var(--ease);
}
.btn-section-action {
  height: 32px;
  padding: 0 8px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 600;
  transition: all 0.2s;
}
.btn-section-action:active { background: rgba(255,255,255,0.1); transform: scale(0.9); }
.btn-section-action .material-icons-round { font-size: 18px; }
.btn-section-action.btn-clear { color: var(--red); }
.btn-section-action.btn-clear:active { background: var(--red-bg); }
.section-body {
  max-height: 5000px;
  overflow: hidden;
  transition: max-height 0.4s var(--ease), opacity 0.3s;
  opacity: 1;
}
.section-body.collapsed { max-height: 0; opacity: 0; }
.cards-container { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }

/* ========== BATCH GROUPS ========== */
.batch-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.batch-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; user-select: none;
  background: rgba(124,106,255,0.06);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}
.batch-group-header:active { background: rgba(124,106,255,0.12); }
.batch-group-left { display: flex; align-items: center; gap: 10px; }
.batch-group-id {
  font-size: 14px; font-weight: 800; color: var(--accent);
  background: var(--accent-bg); padding: 3px 10px;
  border-radius: 6px; letter-spacing: 0.5px;
}
.batch-group-count {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.batch-group-body {
  display: flex; flex-direction: column; gap: 0;
  max-height: 5000px; overflow: hidden;
  transition: max-height 0.4s var(--ease), opacity 0.3s;
  opacity: 1;
}
.batch-group-body.collapsed { max-height: 0; opacity: 0; }
.batch-group-body .delivery-card {
  border-radius: 0; border-left: none; border-right: none;
  border-bottom: 1px solid var(--border-color);
  animation: none;
}
.batch-group-body .delivery-card:last-child { border-bottom: none; }

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 30px 16px; gap: 10px;
}
.empty-state .material-icons-round { font-size: 48px; color: var(--text-muted); }
.empty-state p { color: var(--text-muted); font-size: 14px; }
.btn-empty-add {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent-bg); color: var(--accent);
  padding: 10px 20px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  margin-top: 6px;
  transition: background 0.2s;
}
.btn-empty-add:active { background: rgba(124,106,255,0.2); }

/* ========== DELIVERY CARD ========== */
.delivery-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
  position: relative;
}
.delivery-card.dragging {
  opacity: 0.5; transform: scale(0.97);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.delivery-card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.delivery-card.shortage-card { border-color: var(--red-border); border-width: 2px; }
.delivery-card.outstanding-done { border-color: var(--green-border); border-width: 2px; }

/* Card Top Bar */
.card-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 4px 10px;
}
.card-topbar-left { display: flex; align-items: center; gap: 6px; }
.drag-handle {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; border-radius: var(--radius-sm);
  transition: background 0.15s;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; background: rgba(255,255,255,0.06); }
.drag-handle .material-icons-round { font-size: 22px; color: var(--text-muted); }
.card-order {
  font-size: 18px; font-weight: 800;
  color: var(--accent); min-width: 24px; text-align: center;
}
.card-batch {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px; border-radius: 4px; margin-left: 4px;
}
.card-topbar-right { display: flex; gap: 4px; }
.btn-card-action {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.btn-card-action:active { background: rgba(255,255,255,0.08); }
.btn-card-action .material-icons-round { font-size: 22px; }
.btn-delete .material-icons-round { color: var(--red); }
.btn-complete .material-icons-round { color: var(--green); }

/* Card Info */
.card-info { padding: 4px 14px 10px; }
.card-name { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.card-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; min-height: 36px;
}
.card-row .material-icons-round { font-size: 18px; color: var(--text-muted); flex-shrink: 0; }
.card-phone {
  color: var(--green); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 0;
}
.card-phone:active { opacity: 0.7; }
.card-address-group {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
}
.card-address {
  font-size: 13px; color: var(--text-secondary);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 4px 0; cursor: pointer;
}
.card-address:active { color: var(--text-primary); }
.btn-nav, .btn-copy-addr {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); flex-shrink: 0;
  transition: background 0.15s;
}
.btn-nav { background: var(--accent-bg); }
.btn-nav .material-icons-round { font-size: 20px; color: var(--accent); }
.btn-nav:active { background: rgba(124,106,255,0.25); }
.btn-copy-addr .material-icons-round { font-size: 18px; color: var(--text-muted); }
.btn-copy-addr:active { background: rgba(255,255,255,0.06); }

/* Card Notes */
.card-notes-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; cursor: pointer;
  border-top: 1px solid var(--border-color);
  min-height: 40px;
  transition: background 0.15s;
}
.card-notes-row:active { background: rgba(255,255,255,0.03); }
.card-notes-row .material-icons-round { font-size: 18px; color: var(--orange); flex-shrink: 0; }
.card-notes-text {
  font-size: 13px; color: var(--orange);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-notes-text.empty { color: var(--text-muted); font-style: italic; }

/* Card Items */
.card-items {
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border-color);
}
.card-items-title {
  font-size: 12px; color: var(--text-muted); font-weight: 600;
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.card-items-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.item-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: all 0.2s;
  min-height: 32px;
}
.item-tag:active { transform: scale(0.95); }
.item-tag.delivered {
  text-decoration: line-through;
  color: var(--text-muted);
  background: var(--green-bg);
}
.item-tag .item-shortage {
  color: var(--red); font-weight: 800; font-size: 12px; margin-left: 2px;
}

/* Card Complete Button */
.card-complete-bar {
  padding: 8px 14px 12px;
}
.btn-card-complete {
  width: 100%; height: 48px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--green), #00c853);
  border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700; color: #000;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(0,230,118,0.2);
}
.btn-card-complete:active { transform: scale(0.97); }
.btn-card-complete .material-icons-round { font-size: 22px; }

/* Outstanding done badge */
.outstanding-done-badge {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 14px; font-weight: 700;
  border-top: 1px solid var(--green-border);
}

/* ========== INVENTORY GRID ========== */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px; padding: 0 12px 12px;
}
.inv-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex; align-items: center;
  justify-content: center;
  gap: 6px; cursor: pointer; user-select: none;
  transition: all 0.2s var(--ease);
  position: relative;
  min-width: 0;
}
.inv-item:active { transform: scale(0.96); }
.inv-item.pending { border-color: rgba(255,145,0,0.15); background: rgba(255,145,0,0.04); }
.inv-item.confirmed { border-color: var(--green); background: var(--green-bg); }
.inv-item.shortage { border-color: var(--red); background: var(--red-bg); }

.inv-item-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.inv-item-qty {
  font-size: 13px; font-weight: 800; color: var(--accent);
}
.inv-status-icon {
  font-size: 15px;
}
.inv-item.pending .inv-status-icon { color: var(--text-muted); }
.inv-item.confirmed .inv-status-icon { color: var(--green); }
.inv-item.shortage .inv-status-icon { color: var(--red); }

.inv-shortage-num {
  font-size: 10px; font-weight: 800; color: var(--red);
  margin-left: 2px;
}

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 500px;
  max-height: 90dvh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease);
}
.modal-overlay.active .modal-container { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: var(--touch-min); height: var(--touch-min);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.modal-close:active { background: rgba(255,255,255,0.08); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; gap: 10px; padding: 12px 16px 24px;
  border-top: 1px solid var(--border-color);
}
.btn-modal-cancel {
  flex: 1; height: var(--touch-min);
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  transition: background 0.15s;
}
.btn-modal-cancel:active { background: rgba(255,255,255,0.1); }
.btn-modal-confirm {
  flex: 1; height: var(--touch-min);
  background: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; color: #fff;
  transition: transform 0.15s;
}
.btn-modal-confirm:active { transform: scale(0.97); }
.btn-modal-confirm.btn-danger { background: var(--red); }

/* Form Elements */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-group input, .form-group textarea, .modal-body textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text-primary);
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus, .form-group textarea:focus, .modal-body textarea:focus {
  border-color: var(--accent);
}
.modal-hint {
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: 14px; text-align: center;
}
.modal-hint span { color: var(--accent); font-weight: 700; }
.confirm-msg { font-size: 15px; color: var(--text-secondary); text-align: center; padding: 8px 0; }

/* Items Editor */
.items-editor { display: flex; flex-direction: column; gap: 8px; }
.item-edit-row {
  display: flex; align-items: center; gap: 8px;
}
.item-edit-row input[type="text"] {
  flex: 1; background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 15px;
  color: var(--text-primary); outline: none;
}
.item-edit-row input[type="text"]:focus { border-color: var(--accent); }
.item-edit-row input[type="number"] {
  width: 60px; background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 8px; font-size: 15px;
  color: var(--text-primary); text-align: center; outline: none;
}
.item-edit-row input[type="number"]:focus { border-color: var(--accent); }
.btn-remove-item {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.btn-remove-item .material-icons-round { font-size: 22px; color: var(--red); }
.btn-remove-item:active { background: var(--red-bg); }
.btn-add-item {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border-active);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: border-color 0.2s, color 0.2s;
}
.btn-add-item:active { border-color: var(--accent); color: var(--accent); }
.btn-add-item .material-icons-round { font-size: 20px; }

/* Quantity Control */
.quantity-control {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.qty-btn {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  transition: background 0.15s, transform 0.1s;
}
.qty-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.14); }
.qty-btn .material-icons-round { font-size: 28px; }
.qty-minus .material-icons-round { color: var(--red); }
.qty-plus .material-icons-round { color: var(--green); }
.quantity-control input[type="number"] {
  width: 80px; text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 8px; font-size: 28px; font-weight: 800;
  color: var(--text-primary); outline: none;
  -moz-appearance: textfield;
}
.quantity-control input[type="number"]::-webkit-inner-spin-button,
.quantity-control input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}

/* ========== TOAST ========== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; z-index: 300;
  transition: opacity 0.3s, transform 0.3s var(--ease);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: all; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.delivery-card { animation: fadeIn 0.3s var(--ease) both; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ========== MAP ========== */
#map-container {
  height: 280px; width: 100%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  z-index: 1;
}
.map-legend {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.legend-main { display: flex; gap: 16px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.legend-dot.hq { background: var(--red); box-shadow: 0 0 8px var(--red); }
.legend-dot.stop { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

.map-info {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--accent);
}
.map-info .material-icons-round { font-size: 16px; }

/* ========== IMPORT ========== */
.import-area { padding: 12px; }
.import-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.btn-import-photo {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, #ff9100, #ff6d00);
  color: #000; font-size: 14px; font-weight: 700;
  padding: 12px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: transform 0.15s;
}
.btn-import-photo:active { transform: scale(0.97); }
.btn-import-parse {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700;
  padding: 12px 8px; border-radius: var(--radius-sm);
  transition: transform 0.15s;
}
.btn-import-parse:active { transform: scale(0.97); }
.btn-import-clear {
  width: 48px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm); transition: background 0.15s;
}
.btn-import-clear:active { background: var(--red-bg); }
.btn-import-clear .material-icons-round { color: var(--red); font-size: 22px; }
#import-textarea {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 14px;
  color: var(--text-primary); resize: vertical;
  outline: none; font-family: inherit;
  line-height: 1.6;
}
#import-textarea:focus { border-color: var(--accent); }
.ocr-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-top: 8px;
  background: var(--orange-bg);
  border: 1px solid var(--orange-border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--orange);
}
.ocr-status.done { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.ocr-status.error { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.import-preview { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.preview-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.preview-card .preview-batch {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-bg); padding: 2px 8px;
  border-radius: 4px; align-self: flex-start;
}
.preview-card .preview-name { font-size: 16px; font-weight: 700; }
.preview-card .preview-detail { font-size: 13px; color: var(--text-secondary); }
.preview-card .preview-items { font-size: 13px; color: var(--orange); }
.preview-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-preview-confirm {
  flex: 1; height: 48px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--green); color: #000;
  font-size: 15px; font-weight: 700;
  border-radius: var(--radius-sm);
  transition: transform 0.15s;
}
.btn-preview-confirm:active { transform: scale(0.97); }
.btn-preview-discard {
  width: 48px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
}
.btn-preview-discard .material-icons-round { color: var(--red); }

/* Leaflet overrides */
.leaflet-container { background: #f2f2f2 !important; }
.leaflet-control-zoom a {
  background: white !important; color: #333 !important;
  border-color: rgba(0,0,0,0.15) !important;
}
.leaflet-control-attribution { display: none !important; }
.marker-number {
  background: var(--accent); color: #fff;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(124,106,255,0.4);
  border: 2px solid #fff;
}
.marker-hq {
  background: var(--red); color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  box-shadow: 0 2px 12px rgba(255,23,68,0.5);
  border: 2px solid #fff;
}

@keyframes spin { to { transform: rotate(360deg); } }
.ocr-spinner {
  width: 16px; height: 16px; border: 2px solid transparent;
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block;
}


.btn-map-center {
  background: white;
  border: 1px solid rgba(0,0,0,0.1);
  width: 34px; height: 34px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  margin: 10px;
  transition: all 0.2s;
  color: var(--accent);
}
.btn-map-center:hover { background: #f4f4f4; transform: scale(1.05); }
.btn-map-center:active { transform: scale(0.95); }
.btn-map-center .material-icons-round { font-size: 20px; }
.custom-div-icon { background: none; border: none; }

/* Swipe Button Slider */
.swipe-btn-container {
  position: relative;
  width: 220px;
  height: 44px;
  background: rgba(0,0,0,0.2);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 3px;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.1);
  margin: 10px auto 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.swipe-btn-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.swipe-btn-text {
  position: absolute;
  width: 100%;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  z-index: 0;
  letter-spacing: 0.5px;
  pointer-events: none;
}
.swipe-btn-handle {
  position: relative;
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  cursor: grab;
  color: #000;
  transition: box-shadow 0.2s;
}
.swipe-btn-handle:active {
  cursor: grabbing;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.swipe-btn-handle .material-icons-round {
  font-size: 20px;
}

/* ========== 額外庫存專用樣式 ========== */
/* 移除額外庫存的特殊樣式，與配送庫存保持一致 */

.quantity-control-mini {
  display: flex; align-items: center; background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  height: 42px; overflow: hidden;
}
.quantity-control-mini:focus-within { border-color: var(--accent); }
.qty-btn-mini {
  width: 34px; height: 100%; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); transition: background 0.15s;
}
.qty-btn-mini:active { background: rgba(255,255,255,0.15); }
.qty-btn-mini .material-icons-round { font-size: 18px; color: var(--text-secondary); }
.quantity-control-mini input[type="number"] {
  width: 44px; text-align: center; border: none; background: transparent;
  font-size: 16px; font-weight: 700; color: var(--text-primary); padding: 0; outline: none;
  -moz-appearance: textfield;
}
.quantity-control-mini input[type="number"]::-webkit-inner-spin-button,
.quantity-control-mini input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}

.btn-header-text {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  background: rgba(124, 106, 255, 0.15);
  color: var(--accent); font-size: 14px; font-weight: 700;
  transition: all 0.2s var(--ease);
  border: 1px solid rgba(124, 106, 255, 0.3);
}
.btn-header-text:active { transform: scale(0.95); background: rgba(124, 106, 255, 0.25); }
.btn-header-text .material-icons-round { font-size: 18px; }

/* ========== Google 登入按鈕專用 ========== */
.auth-divider {
  display: flex; align-items: center; text-align: center; 
  color: var(--text-muted); font-size: 12px; margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; border-bottom: 1px solid var(--border-color);
}
.auth-divider span { padding: 0 10px; }

.btn-google-login {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: var(--touch-min);
  background: #ffffff; color: #3c4043;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700;
  transition: transform 0.15s, background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.btn-google-login:active { transform: scale(0.97); background: #f1f3f4; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px; /* 控制後台鈕與登入鈕的距離 */
}

/* 讓後台鈕在滑鼠滑過時有橘色高亮感 */
#btn-admin-panel:active {
  background: rgba(255, 145, 0, 0.2) !important;
  transform: scale(0.95);
}

/* 返回配送按鈕 - 顯目風格 */
#btn-back-to-app {
  background: rgba(255, 145, 0, 0.2) !important;
  color: #ff9100 !important;
  border: 2px solid #ff9100 !important;
  box-shadow: 0 0 12px rgba(255, 145, 0, 0.4) !important;
  font-weight: 800 !important;
}
#btn-back-to-app:active {
  background: rgba(255, 145, 0, 0.35) !important;
  transform: scale(0.95);
}

/* ========== 獨立後台頁面專用 (ADMIN VIEW) ========== */
.admin-header {
  position: sticky; top: 0; z-index: 101;
  background: linear-gradient(135deg, rgba(16,16,40,0.95), rgba(10,10,20,0.98));
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 16px;
}

.view-section {
  animation: viewFadeIn 0.3s var(--ease) forwards;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 後台分頁與排版 ========== */
.admin-tabs {
  display: flex; border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary); padding: 0 16px;
}
.admin-tab-btn {
  flex: 1; padding: 14px 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-secondary); font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.admin-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tab-btn:active { background: rgba(255,255,255,0.05); }

.admin-view-content { padding: 20px 0; animation: viewFadeIn 0.3s forwards; }

.admin-split-layout {
  display: flex; flex-direction: column; gap: 15px;
}
@media (min-width: 600px) {
  .admin-split-layout { flex-direction: row; align-items: flex-start; }
  .admin-sidebar { width: 220px; flex-shrink: 0; }
  .admin-main-panel { flex: 1; min-width: 0; }
}

.admin-sidebar h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; padding-left: 5px; }
.admin-user-list {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); overflow: hidden;
}
.admin-user-item {
  padding: 12px 15px; border-bottom: 1px solid var(--border-color);
  font-size: 14px; color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background 0.2s;
}
.admin-user-item:last-child { border-bottom: none; }
.admin-user-item:hover, .admin-user-item.active { background: rgba(124,106,255,0.1); color: var(--accent); font-weight: 700; }

.admin-record-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 15px;
}
/* 調整後台紀錄顯示區域為長條捲軸模式 */
.admin-scroll-list {
  /* 🌟 將高度從 250px 提高到螢幕高度的 75%，實現「長度加長」 */
  max-height: 75vh; 
  overflow-y: auto; 
  padding-right: 10px; 
  display: flex; 
  flex-direction: column; 
  gap: 12px;
  
  /* 🌟 優化捲軸顯示，讓使用者更清楚「可以滑動」 */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

/* 針對 Chrome/Safari 的捲軸美化 */
.admin-scroll-list::-webkit-scrollbar {
  width: 6px;
}
.admin-scroll-list::-webkit-scrollbar-track {
  background: transparent;
}
.admin-scroll-list::-webkit-scrollbar-thumb {
  background-color: var(--border-active);
  border-radius: 20px;
}

.admin-mini-card {
  background: var(--bg-input); padding: 10px; border-radius: 6px; border: 1px solid var(--border-active);
  font-size: 13px;
}
.admin-mini-card strong { font-size: 14px; display: block; margin-bottom: 4px; }

/* 🌟 滑動按鈕內的提示文字樣式 */
.swipe-btn-instruction {
  position: absolute;
  width: 100%;
  text-align: center;
  left: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 0;
  letter-spacing: 1px;
}

/* 🌟 移動按鈕樣式微調 */
.btn-move-up .material-icons-round {
  color: var(--text-secondary);
  font-size: 24px;
}
.btn-move-up:active {
  background: rgba(255,255,255,0.1);
  transform: scale(1.2);
}

.btn-move-down {
  width: 36px;
  height: 28px; /* 稍微扁一點，方便疊在導航紐上方 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-move-down .material-icons-round {
  font-size: 22px;
}
.btn-move-down:active {
  background: rgba(255,255,255,0.06);
}

/* 讓卡片右上角的按鈕區塊稍微寬一點 */
.card-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 迷你標籤互動效果 */
.mini-tab {
  transition: all 0.2s var(--ease);
  user-select: none;
}
.mini-tab:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.05);
}

/* 🌟 卡片主佈局：資訊與側邊按鈕分開 */
.card-main-layout {
  display: flex;
  padding: 4px 14px 10px;
  gap: 12px;
}
.card-info { flex: 1; min-width: 0; }

/* 🌟 側邊垂直動作欄 */
.side-action-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

/* 🌟 修改：稍微縮小移動按鈕的高度，以容納四顆按鈕 */
.btn-side-move {
  width: 44px;
  height: 30px; /* 原本是 38px，改扁一點讓它們排起來更緊湊 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  color: var(--text-secondary);
}

.btn-side-move .material-icons-round {
  font-size: 34px; /* 稍微縮小圖示，原本 36px */
}

.btn-side-move:active {
  background: var(--accent-bg);
  color: var(--accent);
}

/* 🌟 備註區域與對齊邏輯 */
.card-notes-section {
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
}
.notes-header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--orange);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.notes-header-btn .material-icons-round { font-size: 18px; }

.notes-content-display {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 0; /* 🌟 直接對齊標題的第一個字/圖示 */
  white-space: pre-wrap;
  word-break: break-all;
}
.notes-content-display.has-text {
  color: var(--text-primary);
  background: rgba(255, 145, 0, 0.05);
  border-radius: 4px;
  padding: 4px 0;
}

/* 🌟 備註彈窗中的刪除按鈕樣式 */
.btn-notes-clear-action {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--red-bg);
  color: var(--red);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--red-border);
  transition: all 0.2s;
  cursor: pointer;
}

.btn-notes-clear-action:active {
  transform: scale(0.95);
  background: rgba(255, 23, 68, 0.25);
}

.btn-notes-clear-action .material-icons-round {
  font-size: 16px;
}

/* 🌟 地址與複製按鈕的緊湊排列樣式 */
.card-address-inline-wrapper {
  max-width: 100%;
}

.card-address {
  /* 確保地址在長度過長時仍有省略號，但短的時候會讓按鈕緊跟在後 */
  display: inline-block;
  vertical-align: middle;
}

.btn-copy-addr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s;
  cursor: pointer;
}

.btn-copy-addr:active {
  opacity: 1;
  transform: scale(1.1);
}

/* 確保右上角按鈕區塊維持同一行（插單標籤在刪除鈕左邊） */
.card-topbar-right {
  min-width: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}


/* 🌟 針對手機版導航列的自動縮小排版 */
@media (max-width: 600px) {
  /* 1. 縮小右側按鈕群之間的間隔 */
  .header-right {
    gap: 4px !important; 
  }

  /* 2. 縮小按鈕內的文字大小與內邊距 */
  .btn-header-text {
    font-size: 11px !important; 
    padding: 4px 6px !important;
    gap: 2px !important; /* 圖示與文字的間距 */
  }

  /* 3. 同步微調圖示大小，讓比例維持協調 */
  .btn-header-text .material-icons-round {
    font-size: 15px !important;
  }

  /* 4. 微調左側標題與使用者名稱，確保絕對能維持在同一行 */
  .header-left h1 {
    font-size: 16px !important;
  }
  #display-user-name {
    font-size: 11px !important;
  }
}

/* 1. 確保導覽列死死鎖在最底部，絕對不會跑去上面 */
.bottom-nav {
  position: fixed !important;
  bottom: 0 !important; /* 🌟 關鍵：強制設定在底部 */
  top: auto !important;   /* 🌟 關鍵：防止繼承到 top: 0 */
  
  height: 65px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  pointer-events: all !important;
  cursor: pointer;
  
  /* 設定極高層級，但確保不與 Modal 衝突 */
  z-index: 20000 !important; 
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);

  border-left: 1px solid var(--border-color); /* 在寬螢幕時增加左右邊框提升質感 */
  border-right: 1px solid var(--border-color);
}

@media (max-width: 600px) {
  .bottom-nav {
    border-left: none;
    border-right: none;
  }
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  height: 100%;
  transition: all 0.2s ease;
}

.nav-item.active { color: var(--accent); }
.nav-item.active[data-target="page-planning"] { color: var(--orange); } /* 🌟 規劃為橘色 */

/* 🌟 插單按鈕啟動色改為與配送中一致 */
.nav-item.active[data-target="page-emergency"] { 
  color: var(--accent);
}

.nav-item.has-alert[data-target="page-emergency"] {
  color: #ffeb3b;
  animation: emergencyNavBlink 0.9s ease-in-out infinite;
}

.nav-item.has-alert[data-target="page-emergency"] .material-icons-round,
.nav-item.has-alert[data-target="page-emergency"] span:last-child {
  animation: emergencyIconPulse 0.9s ease-in-out infinite;
}

/* 確保圖示在選中時有微幅上跳動畫 */
.nav-item.active .material-icons-round {
  transform: translateY(-2px);
  transition: transform 0.2s ease;
}
.nav-item.active[data-target="page-records"] { color: var(--green); }
.nav-item.active[data-target="page-outstanding"] { color: var(--red); }

.nav-item .material-icons-round { font-size: 24px; transition: transform 0.2s; }
.nav-item span { font-size: 11px; font-weight: 700; }

.nav-item.active .material-icons-round { transform: translateY(-2px); }

@keyframes emergencyNavBlink {
  0%, 100% { background: transparent; }
  50% { background: rgba(255, 235, 59, 0.14); }
}

@keyframes emergencyIconPulse {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.35; transform: translateY(-1px); }
}

/* 2. 修正分頁顯示，避免內容重疊 */
.nav-page {
  display: none; /* 預設全部隱藏 */
  width: 100%;
}

.nav-page.active {
  display: block; /* 只有啟用的分頁才顯示 */
}


/* 4. 墊高底部空間：防止最後一筆訂單被底部導覽列蓋住 */
#app-main {
  padding-bottom: 80px !important;
}

/* 🌟 地圖定位按鈕樣式 */
.map-control-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000; /* 確保在 Leaflet 圖層之上 */
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: 8px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  background: var(--bg-card-hover);
  color: var(--orange);
}

.map-control-btn:active {
  transform: scale(0.9);
}

.map-control-btn .material-icons-round {
  font-size: 24px;
}

/* ====================================================
   🌟 修正彈出框、提示框與輸入框被底部導航列擋住的問題
   ==================================================== */

/* 1. 提升所有彈出視窗 (Modal) 的層級，並往上推移 */
.modal-overlay {
  z-index: 10000 !important; /* 確保絕對在最上層，蓋過導航列 */
  padding-bottom: 75px !important; /* 將視窗視覺中心往上移，避開 65px 的底部導航列 */
}

/* 2. 提升提示訊息 (Toast) 的層級與高度 */
#toast, .toast, .toast-message {
  z-index: 15000 !important;
  bottom: 85px !important; /* 將原本在最底部的提示框，安全地移到導航列的上方 */
}

/* 🌟 統一的按鈕樣式 (顏色由 JS 行內樣式決定) */
.btn-toggle-delete {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-delete:hover {
  background: currentColor !important;
  color: white !important;
}

/* 🌟 全新的停用帳號樣式 (無濾鏡干擾版) */
.admin-user-item.driver-disabled {
  opacity: 0.6;
  background: rgba(0, 0, 0, 0.25) !important;
}

/* 加上刪除線，並讓名字變暗 */
.admin-user-item.driver-disabled .user-main-info div:first-child {
  text-decoration: line-through;
  color: #888 !important;
}

/* 確保按鈕本身不會跟著變透明，維持亮綠色/亮紅色 */
.admin-user-item.driver-disabled .btn-toggle-delete {
  opacity: 1 !important;
}/* 3. 解決手機「虛擬鍵盤」彈出時，導航列推上來擋住畫面的問題 */
@media screen and (max-height: 600px) {
  /* 當螢幕高度縮小 (代表手機鍵盤彈出時)，自動隱藏底部導航列 */
  .bottom-nav {
    display: none !important;
  }
  
  /* 釋放底部預留空間 */
  body {
    padding-bottom: 0 !important;
  }
  
  /* 鍵盤彈出時，彈出框恢復正常置中，不需要再往上推 */
  .modal-overlay {
    padding-bottom: 0 !important; 
  }
}







/* 🌟 更新後台儀表板：單欄式排版 */
.admin-dashboard {
  display: block !important; /* 移除 flex 佈局 */
  height: auto !important;
  overflow: visible !important;
}

.admin-sidebar {
  display: none !important; /* 徹底移除側邊欄 */
}

.admin-main {
  width: 100% !important;
  padding: 0 !important;
}

/* 讓司機名單在帳號管理分頁中看起來更像列表 */
.admin-user-item {
  background: var(--bg-card);
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  padding: 15px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-user-item:hover {
  border-color: var(--orange-border);
  background: var(--bg-card-hover);
}

.admin-record-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
}

.admin-record-item .row-top {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--accent);
  font-size: 14px;
}

.admin-record-item .row-address {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.4;
}



/* 🌟 權限選擇下拉選單樣式 */
.role-select-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.role-select-box:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.role-select-box option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* 🌟 司機選擇佔位符樣式 */
.admin-select-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  margin-top: 10px;
}

.btn-select-driver-trigger {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(124, 106, 255, 0.2);
}

.btn-select-driver-trigger:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
}

.btn-select-driver-trigger .material-icons-round {
  font-size: 20px;
}

/* 正在檢視狀態列 */
.admin-active-driver-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid var(--accent-bg);
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.viewing-label { font-size: 14px; color: var(--text-secondary); }
.viewing-label strong { color: var(--accent); font-size: 15px; }

.btn-back-picker {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center; gap: 6px; cursor: pointer;
}

/* 選擇司機按鈕區 */
.admin-select-placeholder {
  width: 100%; height: 180px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border-color); border-radius: 12px;
}

.btn-select-driver-trigger {
  background: var(--bg-card); border: 1px solid var(--accent);
  color: var(--accent); padding: 12px 24px; border-radius: 50px;
  font-weight: 700; display: flex; align-items: center; gap: 8px;
}

/* 彈窗遮罩修正 (避免擋住登入鈕) */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex !important; }

/* 🌟 後台上方分頁標籤：圖示與文字完美上下置中 */
.admin-mini-tabs .mini-tab {
  display: flex !important;
  align-items: center !important;     /* 垂直置中 */
  justify-content: center !important; /* 水平置中 */
  gap: 6px !important;                /* 圖示與文字之間留一點空隙 */
  white-space: nowrap !important;     /* 確保文字不會被擠到下一行 */
  padding-bottom: 8px !important;     /* 微調底部留白，讓底線更好看 */
}

/* 確保圖示本身不會有預設的行高干擾 */
.admin-mini-tabs .mini-tab .material-icons-round {
  margin: 0 !important;
  line-height: 1 !important;
  display: block !important;
}

/* 🌟 手機版後台分頁：2 行式且垂直對齊優化 */
@media screen and (max-width: 600px) {
  .admin-mini-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
    padding: 0 10px !important;
    gap: 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
  }

  .admin-mini-tabs .mini-tab {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important; /* 🌟 靠左對齊 */
    padding: 12px 0 !important;
    font-size: 13px !important;
    border-bottom: 2px solid transparent !important;
    box-sizing: border-box;
    gap: 6px !important;
    
    /* 🌟 核心修改：所有標籤統一佔比 1/3 (33.33%) */
    flex: 0 0 33.33% !important; 
  }

  /* 確保第 4, 5, 6 個選項會跑到第二行並產生上邊框 */
  #tab-btn-emg-record, 
  #tab-btn-location, 
  #tab-btn-emergency {
    border-top: 1px solid var(--border-color);
    margin-top: -1px;
    background: rgba(255, 255, 255, 0.02);
  }
  
  /* 插單紀錄選中時的黃色底線與文字 */
  #tab-btn-emg-record.active { 
    border-bottom-color: #ffeb3b !important; 
    opacity: 1 !important; 
    color: #ffeb3b !important; 
  }

  /* 狀態顏色 (維持不變) */
  #tab-btn-accounts.active { border-bottom-color: var(--orange) !important; opacity: 1 !important; }
  #tab-btn-records.active { border-bottom-color: var(--green) !important; opacity: 1 !important; }
  #tab-btn-outstanding.active { border-bottom-color: var(--red) !important; opacity: 1 !important; }
  #tab-btn-location.active { border-bottom-color: var(--accent) !important; opacity: 1 !important; }
  #tab-btn-emergency.active { border-bottom-color: var(--orange) !important; opacity: 1 !important; }
}

/* 電腦版：保持 5 個一排並置中對齊 */
@media screen and (min-width: 601px) {
  .admin-mini-tabs .mini-tab {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
}

/* 🌟 底部導航：插單選中顏色 */
.nav-item.active[data-target="page-emergency"] { 
  color: #ffeb3b !important; 
}

/* 🌟 卡片上的黃色插單標籤 */
.tag-emergency-label {
  color: #ffeb3b;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255, 235, 59, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 2px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid rgba(255, 235, 59, 0.3);
  order: 1;
}

/* 🌟 紀錄區與欠單區的黃色插單文字 */
.text-emergency-inline {
  color: #ffeb3b !important;
  font-weight: 800;
  margin-right: 5px;
}

/* 後台插單表單背景 */
.admin-emergency-form-box {
  background: var(--bg-card);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border-active);
  margin-top: 15px;
}
