/* ===== 餐車 POS 系統樣式 ===== */
/* 設計風格：工業黑金 — 適合餐車環境的高對比大字體 UI */

:root {
  --bg-base: #0f0f0f;
  --bg-panel: #1a1a1a;
  --bg-card: #222222;
  --bg-hover: #2a2a2a;
  --bg-active: #333333;

  --accent: #f5a623;
  --accent-dark: #d4891a;
  --accent-light: #ffc15e;
  --success: #4caf50;
  --danger: #e53935;
  --danger-dark: #c62828;
  --info: #2196f3;

  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;

  --border: #333;
  --border-accent: #f5a623;

  --shadow: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.4);

  --radius: 10px;
  --radius-sm: 6px;

  --font-body: 'Noto Sans TC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #111;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.shop-icon { font-size: 22px; }
.shop-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid #333;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 700;
}
.nav-icon { font-size: 16px; }

.topbar-right { min-width: 80px; text-align: right; }
.clock {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

/* ===== PAGES ===== */
.page {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
}
.page.active { display: flex; }

.page-inner {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

/* ===== POS LAYOUT ===== */
.pos-layout {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 0;
}

/* LEFT: Product Panel */
.product-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--border);
  overflow: hidden;
}

.category-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cat-btn {
  flex: 1;
  padding: 10px 8px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.cat-btn:hover { border-color: var(--accent); color: var(--accent); }
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
}

.product-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-content: start;
}

.product-grid::-webkit-scrollbar { width: 6px; }
.product-grid::-webkit-scrollbar-track { background: var(--bg-base); }
.product-grid::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* Product Card — with image support */
.product-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Image area — fixed 4:3 aspect ratio */
.product-card-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #1a1a1a;
  flex-shrink: 0;
  position: relative;
}

.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

/* Placeholder when no image */
.product-card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: linear-gradient(135deg, #1e1e1e 0%, #252525 100%);
}

.product-card-img-placeholder-icon {
  font-size: 28px;
  opacity: 0.5;
  line-height: 1;
}

.product-card-img-placeholder-cat {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.8;
}

/* Text content below image */
.product-card-body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.product-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.15s;
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.product-card:hover .product-card-img { transform: scale(1.05); }
.product-card:hover::after { transform: scaleX(1); }
.product-card:active { transform: scale(0.97); }

.product-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.product-card-price {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
}

.product-card-cat {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-base);
  padding: 2px 8px;
  border-radius: 20px;
}

/* Flash animation when added */
@keyframes flashGreen {
  0% { border-color: var(--success); box-shadow: 0 0 12px var(--success); }
  100% { border-color: var(--border); box-shadow: none; }
}
.product-card.added {
  animation: flashGreen 0.4s ease-out;
}

.loading-card {
  grid-column: 1/-1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ===== IMAGE UPLOAD UI ===== */
.img-upload-area {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
  background: var(--bg-base);
}
.img-upload-area:hover { border-color: var(--accent); }

.img-preview-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
}

.img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.img-placeholder-icon { font-size: 32px; }

.img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Drag-over state */
.img-upload-area.drag-over {
  border-color: var(--accent);
  background: #1a1200;
}

/* Thumbnail in product table */
.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-base);
  border: 1px solid var(--border);
  display: block;
}

.product-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
}

/* RIGHT: Cart Panel */
.cart-panel {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  overflow: hidden;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cart-title {
  font-size: 16px;
  font-weight: 700;
}

.btn-clear {
  background: transparent;
  border: 1px solid #444;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Cart Items */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.cart-items::-webkit-scrollbar { width: 4px; }
.cart-items::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-muted);
  gap: 8px;
}
.cart-empty-icon { font-size: 32px; }

/* Cart Item Row */
.cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid #2a2a2a;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.cart-item-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); color: #111; }

.qty-num {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  font-size: 15px;
}

.cart-item-price {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
  font-size: 14px;
}

.cart-item-del {
  background: transparent;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  transition: color 0.15s;
}
.cart-item-del:hover { color: var(--danger); }

/* Customer Quick Input */
.customer-quick {
  display: flex;
  gap: 6px;
  padding: 8px 10px 0;
  flex-shrink: 0;
}
.customer-quick input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}
.customer-quick input:focus { border-color: var(--accent); }

.note-area { padding: 6px 10px 0; flex-shrink: 0; }
.note-area input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}
.note-area input:focus { border-color: var(--accent); }

/* Total Area */
.cart-total-area {
  padding: 10px 14px 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.total-row.grand {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
  padding-top: 8px;
  border-top: 1px solid #444;
  margin-top: 4px;
}
.total-row.grand span:last-child {
  color: var(--accent);
  font-family: var(--font-mono);
}

/* Payment Methods */
.payment-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  flex-shrink: 0;
}

.pay-btn {
  padding: 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pay-btn:hover { border-color: var(--accent); color: var(--accent); }
.pay-btn.active {
  background: #1a1200;
  border-color: var(--accent);
  color: var(--accent);
}

/* Checkout Button */
.btn-checkout {
  margin: 8px 10px 12px;
  padding: 18px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #111;
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-checkout:hover { background: var(--accent-light); transform: scale(1.02); }
.btn-checkout:active { transform: scale(0.98); }
.btn-checkout:disabled { background: #444; color: #666; cursor: not-allowed; transform: none; }

/* ===== ORDERS PAGE ===== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 900; }

.toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-right input[type="date"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}
.stat-card-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Table */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #1f1f1f;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #252525;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

.order-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

.payment-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.pay-cash { background: #1a3a1a; color: #4caf50; }
.pay-linepay { background: #0a2a0a; color: #4caf50; }
.pay-card { background: #0a1a3a; color: #64b5f6; }
.pay-transfer { background: #1a1a3a; color: #9575cd; }

/* ===== SETTINGS PAGE ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.settings-card.full { grid-column: 1 / -1; }
.settings-card h3 { margin-bottom: 16px; font-size: 15px; color: var(--accent); }
.settings-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
.settings-card input, .settings-card select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.settings-card input:focus, .settings-card select:focus { border-color: var(--accent); }

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: #1a1a00;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* API Docs */
.api-docs { display: flex; flex-direction: column; gap: 8px; }
.api-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 45px;
  text-align: center;
}
.method.get { background: #0a2a0a; color: #4caf50; }
.method.post { background: #1a1a00; color: var(--accent); }
.api-row code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 200px;
}

/* ===== PRODUCTS PAGE ===== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-on { background: #0a2a0a; color: #4caf50; }
.status-off { background: #2a0a0a; color: var(--danger); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid #444;
  border-radius: var(--radius);
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.modal-body input, .modal-body select, .modal-body textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
}
.modal-body input:focus, .modal-body select:focus { border-color: var(--accent); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 10px !important; font-size: 15px !important; color: var(--text-primary) !important; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* Receipt Modal */
.receipt-modal { max-width: 380px; }
.receipt-header {
  text-align: center;
  padding: 24px 20px 16px;
  border-bottom: 2px dashed #333;
}
.receipt-logo { font-size: 36px; margin-bottom: 8px; }
.receipt-header h2 { font-size: 20px; font-weight: 900; }
.receipt-order-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
}
.receipt-time { font-size: 12px; color: var(--text-muted); }

.receipt-body {
  padding: 16px 20px;
  border-bottom: 2px dashed #333;
}
.receipt-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid #2a2a2a;
}
.receipt-item:last-child { border-bottom: none; }
.receipt-item-name { flex: 1; }
.receipt-item-qty { color: var(--text-muted); font-size: 12px; margin-left: 8px; }
.receipt-item-price { font-family: var(--font-mono); color: var(--accent); }

.receipt-total { padding: 12px 20px; }
.receipt-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.receipt-total-row.grand {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
}
.receipt-total-row.grand span:last-child {
  color: var(--accent);
  font-family: var(--font-mono);
}

.receipt-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 20px;
  border-top: 2px dashed #333;
}

.receipt-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #111;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: #555; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon.danger:hover { background: #2a0a0a; border-color: var(--danger); color: var(--danger); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease-out;
  max-width: 280px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}
.toast.hiding { animation: toastOut 0.3s ease-in forwards; }

/* ===== PRINT ===== */
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    position: fixed;
    left: 0; top: 0;
    width: 80mm;
    font-family: monospace;
    font-size: 12px;
    color: #000;
    background: #fff;
  }
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* Tablet Responsive */
@media (max-width: 768px) {
  .cart-panel { width: 280px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .nav-btn span:last-child { display: none; }
  .nav-btn { padding: 8px 12px; }
}

/* ===== 現金找零面板 ===== */
.cash-change-panel {
  margin: 6px 10px 0;
  background: #1a1200;
  border: 1px solid #3a2800;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  flex-shrink: 0;
}

.cash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.cash-label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 32px;
  flex-shrink: 0;
}

.cash-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}

.cash-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  outline: none;
  text-align: right;
  max-width: 160px;
}
.cash-input:focus { border-color: var(--accent); }

.change-row { border-top: 1px dashed #3a2800; margin-top: 4px; padding-top: 8px; }
.change-val { color: var(--success) !important; font-size: 20px !important; }

.cash-warn {
  font-size: 12px;
  color: var(--danger);
  margin: 4px 0 0;
  text-align: center;
}

/* ===== 訂單狀態標籤 ===== */
.order-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.status-completed { background: #0a2a0a; color: #4caf50; }
.status-modified  { background: #1a1a00; color: var(--accent); }
.status-void      { background: #2a0a0a; color: var(--danger); }

/* ===== 訂單編輯 — 商品列表 ===== */
.edit-items-list {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.edit-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #252525;
}
.edit-item-row:last-child { border-bottom: none; }
.edit-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.edit-item-price { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); min-width: 50px; text-align: right; }
.edit-item-subtotal { font-family: var(--font-mono); font-weight: 700; color: var(--accent); min-width: 55px; text-align: right; font-size: 14px; }

/* ===== 金額差額橫幅 ===== */
.amount-diff-banner {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin: 8px 0;
}
.diff-surcharge { background: #1a0a00; color: var(--accent); border: 1px solid #5a2800; }
.diff-refund    { background: #0a1a0a; color: var(--success); border: 1px solid #1a4a1a; }

/* ===== 訂單操作按鈕組 ===== */
.order-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.btn-icon.edit-btn:hover  { background: #1a1200; border-color: var(--accent); color: var(--accent); }
.btn-icon.void-btn:hover  { background: #2a0a0a; border-color: var(--danger); color: var(--danger); }
.btn-icon.print-btn:hover { background: #0a1a2a; border-color: var(--info); color: var(--info); }

/* ===== 訂單修改紀錄 ===== */
.order-log-section {
  border-top: 2px dashed #333;
  padding: 12px 20px;
}
.order-log-section h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.log-item {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
}
.log-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.log-action-modify { color: var(--accent); font-weight: 700; }
.log-action-void   { color: var(--danger);  font-weight: 700; }
.log-time { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.log-reason { color: var(--text-secondary); }
.log-diff { font-size: 12px; margin-top: 4px; color: var(--text-muted); }

/* ===== 訂單日期快速選擇 ===== */
.date-shortcuts {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.shortcut-btn {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.shortcut-btn:hover { border-color: var(--accent); color: var(--accent); }
.shortcut-btn.active { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; }

#customDateRange input[type="date"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

/* ===== 庫存管理 ===== */
.inv-stock-ok    { color: var(--success); font-weight: 700; font-family: var(--font-mono); }
.inv-stock-low   { color: var(--accent);  font-weight: 700; font-family: var(--font-mono); }
.inv-stock-empty { color: var(--danger);  font-weight: 700; font-family: var(--font-mono); }

.low-stock-banner {
  background: #1a0a00;
  border: 1px solid #5a2800;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.low-stock-banner h4 { color: var(--accent); font-size: 13px; margin-bottom: 8px; }
.low-stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.low-stock-item .inv-stock-low { font-size: 14px; }

/* 商品卡庫存徽章 */
.product-card-stock {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #0a2a0a;
  color: #4caf50;
  font-family: var(--font-mono);
}
.product-card-stock.low  { background: #1a1200; color: var(--accent); }
.product-card-stock.zero { background: #2a0a0a; color: var(--danger); }

/* 已售完遮罩 */
.product-card.sold-out {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
.product-card.sold-out::after {
  content: '已售完';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--danger);
  pointer-events: auto;
}

/* 庫存預覽 */
.inv-preview {
  background: #0a1a00;
  border: 1px solid #1a4a1a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--success);
  margin-top: 8px;
}

/* ===== 分類管理 ===== */
.cat-icon-big { font-size: 24px; line-height: 1; }

/* ===== 點餐模式切換 ===== */
.order-mode-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-base);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.mode-btn {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -2px;
}

.mode-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.mode-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(245,166,35,0.06);
}

/* ===== 模式欄位 ===== */
.mode-fields {
  padding: 8px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.mode-fields input, .mode-fields select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  width: 100%;
}
.mode-fields input:focus, .mode-fields select:focus { border-color: var(--accent); }

.mode-fields-row {
  display: flex;
  gap: 6px;
}
.mode-fields-row input { flex: 1; }

/* 外送平台選擇器 */
.delivery-platform-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.platform-chip {
  padding: 7px 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.platform-chip:hover { border-color: var(--accent); color: var(--accent); }
.platform-chip.selected {
  background: #1a1200;
  border-color: var(--accent);
  color: var(--accent);
}

/* 外送金額計算 */
.delivery-calc {
  background: #0d1a0d;
  border: 1px solid #1a4a1a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 4px;
}
.delivery-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
  color: var(--text-secondary);
  gap: 6px;
}
.dc-rate { color: var(--accent); font-family: var(--font-mono); font-size: 11px; }
.dc-commission { color: var(--danger); font-family: var(--font-mono); font-weight: 700; margin-left: auto; }
.dc-income { color: var(--success) !important; font-weight: 700 !important; border-top: 1px solid #1a4a1a; padding-top: 6px !important; margin-top: 4px; }
.dc-income span:last-child { font-family: var(--font-mono); font-size: 16px; }

/* ===== 訂單分頁 ===== */
.order-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.order-tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.order-tab-btn:hover { color: var(--text-primary); }
.order-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.order-tab-panel { display: block; }

/* 訂單模式徽章 */
.mode-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.mode-dine_in  { background: #0a2a1a; color: #4caf50; }
.mode-takeout  { background: #1a1a00; color: var(--accent); }
.mode-delivery { background: #1a0a2a; color: #ce93d8; }

/* 訂單狀態徽章 */
.ostatus-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.ostatus-pending    { background: #1a1200; color: #ffb74d; }
.ostatus-preparing  { background: #0a1a2a; color: #64b5f6; }
.ostatus-delivering { background: #1a0a2a; color: #ce93d8; }
.ostatus-completed  { background: #0a2a0a; color: #4caf50; }
.ostatus-cancelled  { background: #2a0a0a; color: #e53935; }

/* 外送統計平台卡 */
.platform-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.platform-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid #ce93d8;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.platform-stat-card h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.platform-stat-card .psc-revenue { font-size: 20px; font-weight: 900; color: var(--accent); font-family: var(--font-mono); }
.platform-stat-card .psc-detail { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ===== 訂單資訊展開/隱藏 ===== */
.order-info-section {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.order-info-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-base);
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}
.order-info-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.toggle-arrow {
  font-size: 11px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.toggle-arrow.collapsed { transform: rotate(-90deg); }

#orderInfoFields { overflow: hidden; transition: max-height 0.25s ease; }
#orderInfoFields.collapsed { max-height: 0 !important; }

/* ===== 金額計算區：把外送 calc 移到 total-area 裡 ===== */
.cart-total-area .delivery-calc {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px dashed #2a3a20;
  border-bottom: 1px dashed #2a3a20;
  padding: 6px 0;
}

/* ===== 付款方式警告 ===== */
.payment-warn {
  font-size: 12px;
  color: var(--accent);
  text-align: center;
  padding: 6px 10px;
  background: #1a1200;
  border-radius: var(--radius-sm);
  margin: 0 10px 4px;
}

/* ===== 設定頁分頁 ===== */
.settings-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}
.settings-tab-btn {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
}
.settings-tab-btn:hover { color: var(--text-primary); }
.settings-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-tab-panel { display: block; }

/* ===== 付款方式管理表格 ===== */
.pm-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.pm-toggle input { opacity: 0; width: 0; height: 0; }
.pm-toggle-slider {
  position: absolute;
  inset: 0;
  background: #333;
  border-radius: 22px;
  transition: background 0.2s;
  cursor: pointer;
}
.pm-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.pm-toggle input:checked + .pm-toggle-slider { background: var(--accent); }
.pm-toggle input:checked + .pm-toggle-slider::before { transform: translateX(18px); }

.pm-checkbox {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== 金流卡片 ===== */
.gateway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.gateway-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gateway-card.active-gw { border-color: var(--accent); }

.gateway-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gateway-card-header h4 { font-size: 15px; font-weight: 700; }

.gateway-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}
.gw-on  { background: #0a2a0a; color: #4caf50; }
.gw-off { background: #2a2a2a; color: var(--text-muted); }

.gateway-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.gateway-card input, .gateway-card select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}
.gateway-card input:focus { border-color: var(--accent); }

.gateway-mode-toggle {
  display: flex;
  gap: 6px;
}
.mode-chip {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.mode-chip.selected { border-color: var(--accent); color: var(--accent); background: #1a1200; }

.gateway-card-actions {
  display: flex;
  gap: 8px;
}

/* ===== 外送狀態按鈕 ===== */
.delivery-status-btn {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.ds-preparing  { background: #0a1a2a; color: #64b5f6; border-color: #1a3a5a; }
.ds-completed  { background: #0a2a0a; color: #4caf50; border-color: #1a4a1a; }
.ds-cancelled  { background: #2a0a0a; color: #e53935; border-color: #5a1a1a; }
.ds-preparing:hover  { background: #1a2a3a; }
.ds-completed:hover  { background: #1a3a1a; }
.ds-cancelled:hover  { background: #3a1a1a; }

/* 多模式價格 label 內的 input */
.modal-body label input[type="number"] { width: 100%; }

/* ===== 外送狀態下拉選單 ===== */
.delivery-status-select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.delivery-status-select:focus { border-color: var(--accent); }
.ds-preparing  { border-color: #1a3a5a; color: #64b5f6; background: #0a1a2a; }
.ds-completed  { border-color: #1a3a1a; color: #4caf50; background: #0a1a0a; }
.ds-cancelled  { border-color: #3a1a1a; color: #e53935; background: #1a0a0a; }

/* ===== 外送價格標籤 ===== */
.delivery-price-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: #1a0a2a;
  color: #ce93d8;
  margin-right: 3px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}
