:root {
  --bg: #0f1720;
  --card: #1b2530;
  --line: #2c3a49;
  --text: #e8eef4;
  --muted: #93a2b3;
  --safe: #22c55e;
  --short: #94a3b8;
  --risk: #ef4444;
  --accent: #3b82f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
#map { position: absolute; inset: 0; background: #0b1016; }

#panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 340px; z-index: 1000;
  background: var(--bg); color: var(--text); overflow-y: auto;
  padding: 16px; box-shadow: 2px 0 16px rgba(0,0,0,.4);
}
header h1 { margin: 0; font-size: 20px; }
header .sub { margin: 2px 0 14px; color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none; }

.mode-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab { flex: 1; padding: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.scores { display: flex; gap: 10px; }
.score { flex: 1; text-align: center; border-radius: 10px; padding: 10px 6px; }
.score.safe { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); }
.score.short { background: rgba(148,163,184,.1); border: 1px solid rgba(148,163,184,.3); }
.score .label { display: block; font-size: 11px; color: var(--muted); }
.score .num { display: block; font-size: 30px; font-weight: 700; line-height: 1.1; }
.score.safe .num { color: var(--safe); }
.score small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.delta { margin: 10px 0 0; font-size: 13px; text-align: center; }

.btn { width: 100%; padding: 10px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; margin-bottom: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }

.legend ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.cctv { background: #38bdf8; } .dot.lamp { background: #fbbf24; }
.dot.store { background: #a78bfa; } .dot.risk { background: var(--risk); }
.line { width: 16px; height: 3px; display: inline-block; border-radius: 2px; }
.line.safe { background: var(--safe); } .line.short { background: var(--short); }

#toasts { position: absolute; top: 16px; right: 16px; z-index: 1200; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.toast { background: var(--card); border-left: 4px solid var(--accent); color: var(--text); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.4); font-size: 13px; animation: slide .25s ease; }
.toast.risk { border-color: var(--risk); }
.toast.alert { border-color: #f59e0b; }
.toast.sos { border-color: var(--risk); background: #3b1414; }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 640px) {
  #panel { width: 100%; height: 45%; top: auto; bottom: 0; right: 0; }
  #map { bottom: 45%; }
}
