/* ====== 配色主題 ====== */
/* 啟用某個主題：取消該區塊的註解，並註解掉其他主題 */

/* --- 主題 1：深邃藍夜（目前啟用） --- */
/* :root {
  --bg:        #0a1e3c;
  --surface:   rgba(10,30,60,0.95);
  --surface2:  rgba(20,50,90,0.9);
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.04);
  --accent:    #3d7eff;
  --accent2:   #00c2a8;
  --warn:      #f5a623;
  --text:      #e1e9f8;
  --text-dim:  #7aa0c4;
  --text-mute: #3d5c8a;
  --header-h:  48px;
  --panel-w:   300px;
  --radius:    10px;
  --fs-logo:    15px;
  --fs-icon:    28px;
  --fs-body:    12.5px;
  --fs-item:    12px;
  --fs-panel:   14px;
  --fs-small:   14px;
  --fs-caption: 14px;
  --fs-check:   9px;
} */

/* --- 主題 2：淺色辦公 --- */
:root {
  --bg:        #f0f2f5;
  --surface:   rgba(255,255,255,0.97);
  --surface2:  rgba(241,243,247,0.95);
  --border:    rgba(0,0,0,0.10);
  --border2:   rgba(0,0,0,0.05);
  --accent:    #2563eb;
  --accent2:   #0d9488;
  --warn:      #d97706;
  --text:      #1e293b;
  --text-dim:  #64748b;
  --text-mute: #94a3b8;
  --header-h:  48px;
  --panel-w:   300px;
  --radius:    10px;
  --fs-logo:    15px;
  --fs-icon:    28px;
  --fs-body:    12.5px;
  --fs-item:    12px;
  --fs-panel:   16px;
  --fs-small:   14px;
  --fs-caption: 14px;
  --fs-check:   9px;
}

/* --- 主題 3：暗綠物流 --- */
/* :root {
  --bg:        #0c1a14;
  --surface:   rgba(14,30,22,0.95);
  --surface2:  rgba(22,45,34,0.9);
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.04);
  --accent:    #10b981;
  --accent2:   #06b6d4;
  --warn:      #f59e0b;
  --text:      #e2f0e8;
  --text-dim:  #7daa94;
  --text-mute: #3a5c4a;
  --header-h:  48px;
  --panel-w:   300px;
  --radius:    10px;
  --fs-logo:    15px;
  --fs-icon:    28px;
  --fs-body:    12.5px;
  --fs-item:    12px;
  --fs-panel:   14px;
  --fs-small:   14px;
  --fs-caption: 14px;
  --fs-check:   9px;
} */

/* --- 主題 4：暖橘科技 --- */
/* :root {
  --bg:        #171011;
  --surface:   rgba(28,18,16,0.95);
  --surface2:  rgba(42,28,24,0.9);
  --border:    rgba(255,255,255,0.09);
  --border2:   rgba(255,255,255,0.05);
  --accent:    #f97316;
  --accent2:   #ec4899;
  --warn:      #eab308;
  --text:      #fde8d8;
  --text-dim:  #b8917a;
  --text-mute: #5c3d2e;
  --header-h:  48px;
  --panel-w:   300px;
  --radius:    10px;
  --fs-logo:    15px;
  --fs-icon:    28px;
  --fs-body:    12.5px;
  --fs-item:    12px;
  --fs-panel:   14px;
  --fs-small:   14px;
  --fs-caption: 14px;
  --fs-check:   9px;
} */

/* --- 主題 5：紫霧夜幕 --- */
/* :root {
  --bg:        #110d1a;
  --surface:   rgba(22,16,36,0.95);
  --surface2:  rgba(34,26,54,0.9);
  --border:    rgba(255,255,255,0.09);
  --border2:   rgba(255,255,255,0.05);
  --accent:    #8b5cf6;
  --accent2:   #d946ef;
  --warn:      #f5a623;
  --text:      #ede5fc;
  --text-dim:  #9b8ab8;
  --text-mute: #4a3d63;
  --header-h:  48px;
  --panel-w:   300px;
  --radius:    10px;
  --fs-logo:    15px;
  --fs-icon:    28px;
  --fs-body:    12.5px;
  --fs-item:    12px;
  --fs-panel:   14px;
  --fs-small:   14px;
  --fs-caption: 14px;
  --fs-check:   9px;
} */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 200;
  backdrop-filter: blur(12px);
}
.logo-img {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}
.logo {
  font-size: var(--fs-logo);
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo span { color: var(--accent); }

/* nav 靠右推到登出按鈕左邊 */
.header-spacer { flex: 1; }
nav { display: flex; gap: 2px; }
nav a {
  padding: 5px 13px;
  border-radius: 6px;
  font-size: var(--fs-body);
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
nav a.active { background: var(--accent); color: #fff; }

.btn-logout {
  padding: 5px 13px;
  border-radius: 6px;
  font-size: var(--fs-body);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-logout:hover { border-color: #e5534b; color: #e5534b; }

/* ── MAP (全版) ── */
.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.map-bg {
  width: 100%; height: 100%;
}

/* ── LOADING OVERLAY ── */
#loadingOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  gap: 12px;
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .05em;
}

/* ── FLOATING PANEL BASE ── */
.float-panel {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══ LEFT PANEL：集配資訊儀表板 ══ */
.panel-dashboard {
  left: 14px;
  top: 14px;
  bottom: 48px;
  width: var(--panel-w);
  max-height: calc(100% - 28px);
}

.panel-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: default;
}
.panel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  flex-shrink: 0;
}
.panel-dot.warn { background: var(--warn); }
.panel-name {
  font-size: var(--fs-panel);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text);
  flex: 1;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.panel-content::-webkit-scrollbar { width: 3px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Search */
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: var(--fs-body);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.search-wrap input::placeholder { color: var(--text-mute); }
.search-wrap input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-mute); font-size: var(--fs-icon); pointer-events: none; }

/* Toggle switches */
.toggle-row {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
}
.toggle-label { flex: 1; font-size: var(--fs-body); color: var(--text-dim); }
.toggle {
  width: 34px; height: 18px;
  background: var(--text-mute);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: left .2s;
}
.toggle.on::after { left: 19px; }

/* 配區列表 section */
.section-hd {
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-mute);
  text-transform: uppercase;
  padding: 2px 0;
}
.zone-actions {
  display: flex; gap: 4px;
}
.zone-btn {
  flex: 1;
  padding: 4px 0;
  border-radius: 5px;
  font-size: var(--fs-small);
  font-family: inherit;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.zone-btn:hover { border-color: var(--accent); color: var(--accent); }

.zone-list {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  /* scroll 向下延伸到底 */
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
}
.zone-list::-webkit-scrollbar { width: 3px; }
.zone-list::-webkit-scrollbar-track { background: transparent; }
.zone-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.zone-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
  transition: background .1s;
  font-size: var(--fs-item);
}
.zone-item:last-child { border-bottom: none; }
.zone-item:hover { background: rgba(61,126,255,.07); }
.z-check {
  width: 13px; height: 13px;
  border-radius: 3px;
  border: 1.5px solid var(--text-mute);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.zone-item.on .z-check { background: var(--accent); border-color: var(--accent); }
.zone-item.on .z-check::after { content: '✓'; font-size: var(--fs-check); color: #fff; }
.z-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.z-name { flex: 1; color: var(--text); }
.z-meta { font-size: var(--fs-caption); color: var(--text-mute); font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }

/* 可展開父項目 */
.zone-parent { position: relative; }
.z-expand-arrow {
  font-size: 9px; color: var(--text-mute);
  transition: transform .15s;
  margin-left: 4px;
}
.zone-parent.expanded .z-expand-arrow { transform: rotate(90deg); }
.z-sub-count {
  font-size: 10px; color: var(--text-mute);
  background: var(--border);
  border-radius: 8px;
  padding: 0 5px;
  margin-left: 2px;
}

/* 子項目容器 */
.zone-sub-body { padding-left: 18px; }
.zone-sub-body.hidden { display: none; }

/* 子項目 */
.zone-sub-item {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
  transition: background .1s;
  font-size: var(--fs-item);
}
.zone-sub-item:last-child { border-bottom: none; }
.zone-sub-item:hover { background: rgba(61,126,255,.07); }
.zone-sub-item .z-check { margin-top: 2px; }
.zone-sub-item.on .z-check { background: var(--accent); border-color: var(--accent); }
.zone-sub-item.on .z-check::after { content: '✓'; font-size: var(--fs-check); color: #fff; }
.z-sub-info { flex: 1; min-width: 0; }
.z-sub-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.z-sub-addr { font-size: 11px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* 空狀態 */
.zone-empty {
  padding: 20px 10px;
  text-align: center;
  color: var(--text-mute);
  font-size: var(--fs-body);
}

/* 群組標題（分類 + 子分類） */
.zone-group-hd {
  padding: 8px 10px 4px;
  font-size: var(--fs-caption);
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border2);
  background: rgba(0,0,0,.02);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.zone-group-hd .group-arrow {
  font-size: 10px;
  transition: transform .2s;
  color: var(--text-mute);
}
.zone-group-hd.collapsed .group-arrow {
  transform: rotate(-90deg);
}
.zone-group-body.hidden {
  display: none;
}

/* ══ RIGHT PANEL：集配區種類顯示控制 ══ */
.panel-filter {
  right: 50px;
  top: 10px;
  width: 298px;
  /* 可收合 */
  max-height: calc(100% - 28px);
  transition: max-height .3s cubic-bezier(.4,0,.2,1);
}
.panel-filter.collapsed {
  max-height: 42px; /* 只顯示 titlebar */
}

.panel-filter .panel-titlebar {
  cursor: pointer;
  user-select: none;
}
.collapse-btn {
  font-size: var(--fs-item);
  color: var(--text-mute);
  transition: transform .3s;
  flex-shrink: 0;
}
.panel-filter.collapsed .collapse-btn { transform: rotate(180deg); }

.filter-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-scroll::-webkit-scrollbar { width: 3px; }
.filter-scroll::-webkit-scrollbar-track { background: transparent; }
.filter-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* filter group */
.fg {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  overflow: hidden;
}
.fg-hd {
  padding: 7px 11px;
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--text-mute);
  text-transform: uppercase;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
}
.fg-check-all {
  margin-left: auto;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--text-mute);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.fg-check-all.on {
  background: var(--accent);
  border-color: var(--accent);
}
.fg-check-all.on::after {
  content: '\2713';
  font-size: 9px;
  color: #fff;
}
.fr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--border2);
}
.fr:last-child { border-bottom: none; }
.fr-name { flex: 1; font-size: var(--fs-body); color: var(--text); }
.chip-pair { display: flex; gap: 3px; }
.chip {
  padding: 2px 9px;
  border-radius: 4px;
  font-size: var(--fs-small);
  border: 1.5px solid var(--border);
  color: var(--text-mute);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  background: transparent;
  white-space: nowrap;
}
.chip:hover { border-color: var(--text-dim); color: var(--text-dim); }
.chip.r { border-color: var(--accent);  color: var(--accent);  background: rgba(61,126,255,.12); }
.chip.s { border-color: var(--accent2); color: var(--accent2); background: rgba(0,194,168,.12); }

/* station checkbox */
.sc-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
  transition: background .1s;
}
.sc-row:last-child { border-bottom: none; }
.sc-row:hover { background: rgba(255,255,255,.03); }
.sc-box {
  width: 13px; height: 13px;
  border-radius: 3px;
  border: 1.5px solid var(--text-mute);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.sc-row.on .sc-box { background: var(--warn); border-color: var(--warn); }
.sc-row.on .sc-box::after { content: '✓'; font-size: var(--fs-check); color: #fff; }
.sc-label { font-size: var(--fs-body); color: var(--text); }

/* footer */
.filter-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn { flex: 1; padding: 8px 0; border-radius: 7px; font-size: var(--fs-body); font-family: inherit; font-weight: 500; cursor: pointer; border: none; transition: all .15s; }
.btn-p { background: var(--accent); color: #fff; }
.btn-p:hover:not(:disabled) { background: #2d6fe8; }
.btn-p:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-g { background: rgba(255,255,255,.05); color: var(--text-dim); border: 1px solid var(--border); }
.btn-g:hover { border-color: var(--text-dim); color: var(--text); }

/* Color dots */
.c1{background:#3d7eff} .c2{background:#00c2a8} .c3{background:#36d399}
.c4{background:#f5a623} .c5{background:#a855f7} .c6{background:#e5534b}
.c7{background:#f472b6} .c8{background:#38bdf8}
