:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #111827;
  --accent: #16a34a;
  --warm: #f97316;
  --danger: #dc2626;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(17,24,39,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.topbar, .admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #111827;
  color: #fff;
  padding: 12px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: #9ca3af; font-size: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #16a34a, #f97316);
  display: grid; place-items: center; font-weight: 800;
}
.top-nav { display: none; gap: 8px; }
.top-nav a, .sidenav a {
  padding: 8px 12px; border-radius: 999px; color: #d1d5db;
}
.top-nav a.active, .sidenav a.active { background: #1f2937; color: #fff; }
.page { width: min(1100px, calc(100% - 28px)); margin: 18px auto 88px; }
.hero, .card, .auth-card, .quote-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero {
  padding: 28px 24px;
  background: linear-gradient(160deg, #111827 0%, #1f2937 55%, #14532d 100%);
  color: #fff;
  margin-bottom: 16px;
}
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 5vw, 40px); }
.hero p { margin: 0; color: #d1d5db; }
.layout { display: grid; gap: 16px; }
.card { padding: 18px; }
.grid-2, .grid-3 { display: grid; gap: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; padding: 12px 18px; font: inherit; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; font-weight: 700; }
.btn-dark { background: var(--brand); color: #fff; width: 100%; font-weight: 700; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.muted { color: var(--muted); }
.ok { color: #15803d; }
.err { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #fff; cursor: pointer;
}
.chip.active { background: #111827; color: #fff; border-color: #111827; }
.quote-box { padding: 16px; margin: 12px 0; display: none; }
.quote-box.show { display: block; }
.price { font-size: 32px; font-weight: 800; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--line);
}
.timeline li.done::before { background: var(--accent); }
.pin {
  font-size: 28px; letter-spacing: 8px; font-weight: 800; background: #f3f4f6;
  border-radius: 12px; padding: 10px; text-align: center;
}
.order-list { display: grid; gap: 12px; }
.order-item {
  background: #fff; border-radius: 16px; padding: 14px; box-shadow: var(--shadow);
}
.badge {
  display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; background: #e5e7eb;
}
.badge.pending { background: #fef3c7; }
.badge.accepted { background: #dbeafe; }
.badge.picked { background: #ffedd5; }
.badge.delivered { background: #dcfce7; }
.badge.cancelled { background: #fee2e2; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  /* 項目數量會變（加了「地址」就變 4 個），用 auto-fit 讓它自己平分，不要寫死欄數 */
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: #fff; border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.badge { white-space: nowrap; }
.chip { margin: 0 6px 8px 0; white-space: nowrap; vertical-align: top; }
.bottom-nav a { text-align: center; padding: 10px; color: var(--muted); font-weight: 600; }
.bottom-nav a.active { color: var(--accent); }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); padding: 24px; }
.auth-card h1 { margin-top: 0; }
.map-fake {
  height: 180px; border-radius: 16px; background:
    radial-gradient(circle at 30% 40%, #bbf7d0, transparent 28%),
    radial-gradient(circle at 72% 62%, #fed7aa, transparent 24%),
    linear-gradient(135deg, #e5e7eb, #f8fafc);
  position: relative; overflow: hidden; margin-bottom: 12px;
}
/* Google 地址自動完成元件預設跟隨系統深色模式，本站是亮色設計，
   在深色模式的瀏覽器下會變成黑底黑框，與其他輸入框不一致 → 強制亮色並對齊本站樣式 */
gmp-place-autocomplete {
  display: block;
  width: 100%;
  color-scheme: light;
  border-radius: 12px;
  --gmp-mat-color-surface: #ffffff;
  --gmp-mat-color-on-surface: #111827;
  --gmp-mat-color-on-surface-variant: var(--muted);
  --gmp-mat-color-outline: var(--line);
}
.map-live {
  height: 180px; border-radius: 16px; overflow: hidden; margin-bottom: 12px;
}
/* 地圖磚載入期間：地圖照常佔位但透明（必須有尺寸才會載入圖磚），
   改讓示意圖絕對定位疊在上面，載好再把示意圖移除。
   絕對定位放在純裝飾的示意圖上，地圖本身永遠是正常的區塊元素，不會爆版。 */
#map-wrap { position: relative; }
.map-live.loading { opacity: 0; }
#map-wrap.loading .map-fake {
  position: absolute; left: 0; top: 0; right: 0; bottom: 12px; margin: 0;
}
.pin-a, .pin-b {
  position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff;
}
.pin-a { left: 28%; top: 36%; background: #16a34a; }
.pin-b { left: 70%; top: 58%; background: #f97316; }
.route {
  position: absolute; left: 30%; top: 42%; width: 42%; height: 2px;
  background: #111827; transform: rotate(18deg);
}
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: #fff; padding: 16px; border-radius: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 16px; overflow: hidden; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.admin-body { display: grid; min-height: 100vh; }
.sidenav { display: none; background: #111827; color: #fff; padding: 18px 12px; }
.admin-main { padding: 18px; }
.flash { background: #ecfdf5; color: #166534; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; }

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .layout { grid-template-columns: 1.2fr .8fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .page { margin-bottom: 32px; }
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
  .map-fake, .map-live { height: 260px; }
}
@media (min-width: 1024px) {
  .admin-body { grid-template-columns: 240px 1fr; }
  .sidenav { display: flex; flex-direction: column; gap: 6px; }
  .sidenav .brand { margin-bottom: 16px; color: #fff; }
}
/* 手機／平板的後台：選單與表格都不該被擠壓成直排 */
@media (max-width: 1023px) {
  .sidenav { align-items: center; }
  .sidenav .brand { flex: 0 0 auto; margin-bottom: 0; }
  .sidenav a { white-space: nowrap; }
  /* 欄位多的表格在窄螢幕改成整塊可橫向捲動，而不是把每個字擠成一行 */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table th, table td { white-space: nowrap; }
}
@media (max-width: 1023px) {
  .sidenav {
    display: flex; flex-direction: row; overflow-x: auto; gap: 8px;
    padding: 10px; position: sticky; top: 0;
  }
  .admin-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}
