:root {
  --bg: #0a0c0f;
  --surface: #111418;
  --surface2: #181c22;
  --border: #232832;
  --green: #4ade80;
  --orange: #f59e0b;
  --blue: #60a5fa;
  --red: #f87171;
  --text: #e5e7eb;
  --text2: #94a3b8;
  --gray: #64748b;
  --radius: 6px;
  --mono: "DM Mono", ui-monospace, monospace;
  --sans: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans);
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: env(safe-area-inset-top);
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 12px; position: relative; z-index: 1000; }
.search { display: flex; gap: 6px; }
.search input {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 10px; font-size: 16px; /* 16px 防 iOS 自動放大 */
}
.search input:focus { outline: none; border-color: var(--blue); }
.icon-btn {
  width: 40px; flex: none; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 17px;
}
.icon-btn:active { background: var(--border); }
.icon-btn.text-btn { width: auto; padding: 0 10px; font-size: 14px; }
.dropdown {
  position: absolute; left: 12px; right: 12px; top: 54px; margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); max-height: 50vh; overflow: auto;
}
.dropdown li { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.dropdown li:last-child { border-bottom: 0; }
.dropdown li small { display: block; color: var(--text2); font-size: 12px; }
.dropdown li.msg { color: var(--text2); }

.bar { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.bar::-webkit-scrollbar { display: none; }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg button { background: transparent; border: 0; padding: 5px 9px; color: var(--text2); font-size: 13px; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface2); color: var(--text); }

main { flex: 1; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.list { position: absolute; inset: 0; overflow-y: auto; background: var(--bg); padding: 4px 0 70px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.row .badge {
  flex: none; min-width: 46px; text-align: center; font: 500 14px var(--mono); padding: 4px 6px;
  border-radius: var(--radius); background: var(--surface2);
}
.row .main { flex: 1; min-width: 0; }
.row .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--text2); font-size: 12px; }
.row .sub .num, .num { font-family: var(--mono); }
.row .go, .pop .go {
  flex: none; background: transparent; border: 1px solid var(--blue); color: var(--blue);
  border-radius: var(--radius); padding: 5px 10px; font-size: 13px; text-decoration: none;
}
.list .empty { padding: 30px 16px; color: var(--text2); text-align: center; }

.c-green { color: var(--green); } .c-blue { color: var(--blue); } .c-orange { color: var(--orange); }
.c-red { color: var(--red); } .c-gray { color: var(--gray); }

.fab {
  position: absolute; right: 12px; bottom: 16px; z-index: 900; width: 44px; height: 44px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 20px;
}
.fab.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status {
  background: var(--surface); border-top: 1px solid var(--border); padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--text2);
}
#status { color: var(--text); }
#status .warn { color: var(--orange); }
#status .err { color: var(--red); }
.note { margin-top: 2px; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; background: var(--surface);
  border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); max-height: 70vh; overflow: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.fav-form { display: flex; gap: 6px; }
.fav-form input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 10px; font-size: 16px; }
.fav-form button { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }
.fav-list { list-style: none; margin: 10px 0 0; padding: 0; }
.fav-list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.fav-list li .name { flex: 1; }
.fav-list li button { background: transparent; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; font-size: 13px; }
.fav-list .empty { color: var(--text2); }

/* 地圖標記 */
.pin-curb { width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--green); }
.pin-lot {
  font: 500 12px var(--mono); color: var(--bg); background: var(--blue); border-radius: var(--radius);
  padding: 2px 5px; white-space: nowrap; border: 1px solid var(--bg); text-align: center; transform: translate(-50%, -50%);
  display: inline-block; position: absolute; left: 0; top: 0;
}
.pin-lot.full { background: var(--red); }
.pin-lot.low { background: var(--orange); }
.pin-lot.nodata { background: var(--surface2); color: var(--text2); border-color: var(--gray); }
.pin-center { width: 18px; height: 18px; border-radius: 50%; background: var(--text); border: 4px solid var(--blue); }
.leaflet-container { font: 13px var(--sans); background: var(--bg); }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); border-radius: var(--radius); }
.leaflet-popup-content { margin: 10px 12px; }
.pop .t { font-weight: 600; margin-bottom: 2px; }
.pop .s { color: var(--text2); margin-bottom: 8px; }
.pop .go { display: inline-block; }
.leaflet-control-attribution { background: rgba(10, 12, 15, 0.7) !important; color: var(--text2) !important; }
.leaflet-control-attribution a { color: var(--text2) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(74, 222, 128, 0.25) !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--green) !important; color: var(--bg); font: 500 12px var(--mono);
}
