:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --line-2: #cfd7e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8492a6;
  --primary: #1d4ed8;
  --primary-2: #2563eb;
  --primary-soft: #e8efff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, .18);
  --top: 56px;
  --left: 248px;
  --right: 340px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 13.5px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 14px; height: 14px; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: #0b1220; color: #e2e8f0; position: relative; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--left) - 14px); flex: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-2); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: -.01em; }
.brand-text span { font-size: 11px; color: #94a3b8; }
.beta { font-style: normal; font-size: 9.5px; font-weight: 800; background: #f59e0b; color: #1f2937; border-radius: 4px; padding: 1px 4px; vertical-align: 2px; margin-left: 2px; }
.search { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.search .ico { position: absolute; left: 11px; color: #94a3b8; }
.search input {
  width: 100%; height: 36px; border-radius: 8px; border: 1px solid #1f2a3d; background: #141d2e; color: #f1f5f9;
  padding: 0 12px 0 36px; outline: none; transition: border-color .15s, background .15s;
}
.search input::placeholder { color: #6b7a90; }
.search input:focus { border-color: var(--primary-2); background: #0f1828; }
.search-results {
  position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); color: var(--text);
  border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line);
}
.search-results button { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results button:last-child { border-bottom: 0; }
.search-results button:hover, .search-results button.on { background: var(--primary-soft); }
.search-results small { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 2px; }
.search-results .msg { padding: 12px 14px; color: var(--text-2); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar .btn { background: #141d2e; border-color: #1f2a3d; color: #e2e8f0; }
.topbar .btn:hover { background: #1b2740; }
.topbar .btn.ghost { background: transparent; border-color: transparent; width: 34px; padding: 0; justify-content: center; }
.topbar .btn.ghost:hover { background: #1b2740; }
.topbar .seg { background: #141d2e; border-color: #1f2a3d; }
.topbar .seg button { color: #94a3b8; }
.topbar .seg button.on { background: #2a3955; color: #fff; }

/* ---------- buttons ---------- */
.btn {
  height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.big { height: 46px; width: 100%; justify-content: center; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .tool:focus-visible, .seg button:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }
.link { border: 0; background: none; color: var(--primary); cursor: pointer; font-weight: 600; padding: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.seg button { white-space: nowrap; border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 40px; min-width: 210px; background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; border: 1px solid var(--line); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--primary-soft); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- layout ---------- */
.workspace { position: absolute; top: var(--top); left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: var(--left) 1fr var(--right); }
.tools, .panel { background: var(--surface); overflow-y: auto; z-index: 500; }
.tools { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.panel { border-left: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- steps ---------- */
.tools-head { padding: 14px 16px 6px; font-size: 11.5px; font-weight: 700; color: var(--text-3); letter-spacing: .04em; }
.steps { list-style: none; margin: 0; padding: 0 10px; flex: 1; }
.step { border-radius: 10px; padding: 10px 8px; margin-bottom: 2px; }
.step + .step { border-top: 1px solid var(--line); border-radius: 0; }
.step-row { display: flex; gap: 10px; align-items: flex-start; }
.step-row b { display: block; font-size: 13.5px; }
.step-row em { font-style: normal; font-size: 11px; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.step-row small { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 1px; }
.step-no { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--text-2); flex: none; }
.step.done .step-no { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-check { margin-left: auto; }
.step-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px 32px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text);
}
.tool .ico { width: 15px; height: 15px; }
.tool:hover { border-color: var(--primary-2); color: var(--primary); }
.tool.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tool.sub { color: var(--text-2); font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.both { background: #2563eb; } .dot.in { background: #16a34a; } .dot.out { background: #dc2626; }
.fac-grid { display: grid !important; grid-template-columns: 1fr 1fr; }
.fac-grid .tool { justify-content: flex-start; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fac-grid .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tools-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.toggle { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.toggle input { accent-color: var(--primary); }

/* ---------- map ---------- */
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #1e293b; }
.leaflet-container { font-family: inherit; }
.map-wrap.mode-draw #map, .map-wrap.mode-place #map { cursor: crosshair; }
.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 600;
  background: rgba(11, 18, 32, .88); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 12.5px;
  box-shadow: var(--shadow); backdrop-filter: blur(6px); white-space: nowrap; pointer-events: none;
}
.hint kbd { background: rgba(255,255,255,.16); border: 0; color: #fff; }
.banner {
  position: absolute; top: 12px; left: 12px; right: 304px; z-index: 590; margin: 0 auto; max-width: 640px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 8px 10px 8px 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); font-size: 12.5px;
}
.banner .btn { margin-left: auto; }
.provider-note.err { background: #fef2f2; color: #991b1b; }
.provider-note { position: absolute; bottom: 24px; right: 12px; z-index: 590; background: rgba(255,255,255,.92); border-radius: 8px; padding: 6px 10px; font-size: 11.5px; color: var(--text-2); box-shadow: var(--shadow); max-width: 320px; }
.empty {
  position: absolute; z-index: 580; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(255,255,255,.97); border-radius: 14px; padding: 22px 26px; width: min(420px, calc(100% - 32px));
  box-shadow: var(--shadow-lg);
}
.empty h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -.01em; }
.empty ol { margin: 0 0 16px; padding-left: 18px; color: var(--text-2); line-height: 1.8; }
.empty-actions { display: flex; gap: 8px; }
.legend {
  position: absolute; left: 12px; bottom: 24px; z-index: 590; background: rgba(255,255,255,.95); border-radius: 10px;
  padding: 8px 10px; box-shadow: var(--shadow); font-size: 11.5px; color: var(--text-2); display: grid; grid-template-columns: auto auto; gap: 4px 12px;
}
.legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 14px; height: 9px; border-radius: 2px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.inspector {
  position: absolute; right: 12px; top: 12px; z-index: 595; width: 280px; background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 14px;
}
.inspector h4 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.inspector h4 .x { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; }
.inspector .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inspector .kv { display: flex; justify-content: space-between; color: var(--text-2); font-size: 12.5px; padding: 3px 0; }
.inspector .kv b { color: var(--text); font-variant-numeric: tabular-nums; }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 6px; }
.type-grid button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 6px 4px; cursor: pointer; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 5px; justify-content: center; }
.type-grid button:hover { border-color: var(--primary-2); }
.type-grid i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.btn.danger { color: var(--err); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }

/* ---------- map objects ---------- */
.ent-marker { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.ent-marker.both { background: #2563eb; } .ent-marker.in { background: #16a34a; } .ent-marker.out { background: #dc2626; }
.ent-marker.sel { outline: 3px solid #facc15; }
.fac-label { background: rgba(15, 23, 42, .82); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; transform: translate(-50%, -50%); display: inline-block; pointer-events: none; }
.dim-label { background: rgba(255,255,255,.92); color: #0f172a; padding: 1px 5px; border-radius: 4px; font-size: 10.5px; font-weight: 700; white-space: nowrap; transform: translate(-50%, -50%); display: inline-block; pointer-events: none; font-variant-numeric: tabular-nums; }
.arrow-ico { color: #fff; font-size: 15px; line-height: 1; display: grid; place-items: center; width: 18px; height: 18px; text-shadow: 0 0 3px rgba(0,0,0,.6); pointer-events: none; }
.flow-ico { width: 26px; height: 26px; display: grid; place-items: center; pointer-events: none; }
.leaflet-tooltip.mini { padding: 3px 7px; font-size: 11.5px; border-radius: 6px; }

/* ---------- panel ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card-h { font-size: 12px; font-weight: 700; color: var(--text-3); letter-spacing: .03em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.badge { background: #fef3c7; color: #92400e; border-radius: 999px; padding: 1px 7px; font-size: 11px; }
.total { background: linear-gradient(135deg, #0b1220, #1e2b47); color: #fff; border: 0; }
.total-label { font-size: 12px; color: #94a3b8; font-weight: 600; }
.total-num { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.total-num small { font-size: 16px; font-weight: 600; color: #94a3b8; margin-left: 4px; }
.total-sub { font-size: 12px; color: #cbd5e1; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.1); border-radius: 999px; padding: 3px 9px; font-size: 12px; }
.chip i { width: 8px; height: 8px; border-radius: 2px; }
.chip.bad { background: rgba(220, 38, 38, .25); }
.metrics { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; margin: 0; font-size: 12.5px; }
.metrics dt { color: var(--text-2); }
.metrics dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.alts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.alt { border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px; cursor: pointer; background: var(--surface); text-align: left; }
.alt:hover { border-color: var(--primary-2); }
.alt.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.alt b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.alt span { font-size: 11.5px; color: var(--text-2); }
.warns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warns li { font-size: 12.5px; padding: 7px 9px; border-radius: 8px; background: #fffbeb; color: #92400e; line-height: 1.45; }
.warns li.error { background: #fef2f2; color: #991b1b; }
.warns li.info { background: var(--surface-2); color: var(--text-2); }
.form { display: flex; flex-direction: column; gap: 6px; }
.f-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.f-label i { font-style: normal; color: var(--text-3); cursor: help; }
.f-label a { margin-left: auto; color: var(--primary); font-weight: 500; text-decoration: none; }
.form select, .form input[type=text], .dlg select, .dlg input[type=text], .inspector select, .inspector input[type=text] {
  height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--surface); width: 100%; outline: none;
}
.form select:focus, .form input:focus, .inspector input:focus, .dlg input:focus { border-color: var(--primary-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.num { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; height: 34px; overflow: hidden; background: var(--surface); }
.num input { border: 0; outline: none; width: 100%; height: 100%; padding: 0 8px; font-variant-numeric: tabular-nums; background: transparent; }
.num span { padding: 0 9px; color: var(--text-3); font-size: 12px; border-left: 1px solid var(--line); height: 100%; display: grid; place-items: center; background: var(--surface-2); }
.num:focus-within { border-color: var(--primary-2); }
.veh-info { font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; line-height: 1.6; }
.veh-info .tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.veh-info .tag.legal { background: #dcfce7; color: #166534; }
.veh-info .tag.ref { background: #fef3c7; color: #92400e; }
.veh-info .dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.veh-info .dims label { font-size: 10.5px; color: var(--text-3); display: block; }
.veh-info .dims .num { height: 28px; }
.gen { position: sticky; bottom: -14px; background: var(--surface); padding: 6px 0 14px; margin-top: auto; }
.progress { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--text-2); }
.progress .bar { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--primary-2); transition: width .2s; }
.fine { font-size: 11.5px; color: var(--text-3); line-height: 1.5; margin: 8px 0 0; }

/* ---------- dialogs & toast ---------- */
.dlg { border: 0; border-radius: 14px; padding: 22px; width: min(440px, calc(100% - 32px)); box-shadow: var(--shadow-lg); color: var(--text); }
.dlg.wide { width: min(820px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(15, 23, 42, .45); }
.dlg h3 { margin: 0 0 12px; font-size: 17px; }
.dlg h4 { margin: 0 0 6px; font-size: 13px; }
.dlg form { display: flex; flex-direction: column; gap: 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.help-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.help-grid ul { margin: 0; padding-left: 16px; color: var(--text-2); line-height: 1.7; font-size: 12.5px; }
kbd { font-family: inherit; font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2000; background: #0b1220; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: calc(100% - 32px); }
.toast.err { background: #991b1b; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { :root { --left: 220px; --right: 300px; } .brand-text span { display: none; } }
@media (max-width: 860px) {
  :root { --top: 104px; }
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--top); padding: 8px 12px; gap: 8px; }
  .brand { width: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .workspace { position: static; display: flex; flex-direction: column; height: auto; }
  .map-wrap { height: 62vh; order: 1; }
  .tools { order: 2; border-right: 0; border-bottom: 1px solid var(--line); }
  .panel { order: 3; border-left: 0; }
  .inspector { left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; }
  .banner { right: 12px; }
  .legend { display: none; }
  .help-grid { grid-template-columns: 1fr; }
  .gen { position: static; }
}
@media (max-width: 480px) {
  .brand-text { display: none; }
  .topbar .seg button { padding: 5px 7px; font-size: 12px; }
  .top-actions { gap: 2px; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .tools, .gen, .hint, .banner, .inspector, .empty, .provider-note, .leaflet-control-container .leaflet-control-zoom { display: none !important; }
  body { overflow: visible; }
  .workspace { position: static; display: grid; grid-template-columns: 1fr 300px; height: 100vh; }
  .panel { overflow: visible; }
}

/* ================= v2: 단순화 UI ================= */
:root { --left: 76px; --right: 320px; }
.vsep { width: 1px; height: 22px; background: #263247; margin: 0 4px; }
.topbar .btn.accent { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.topbar .btn.accent:hover { background: #3b82f6; }

/* 도구 막대 */
.rail { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; z-index: 600; overflow: visible; }
.rail-btn {
  position: relative; width: 62px; padding: 8px 0 6px; border: 0; background: none; border-radius: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-2); font-size: 11px; font-weight: 600;
}
.rail-btn .ico { width: 21px; height: 21px; }
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn.on { background: var(--primary-soft); color: var(--primary); }
.rail-btn.done::after { content: ""; position: absolute; top: 6px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.rail-btn.next { box-shadow: inset 0 0 0 2px var(--primary-2); color: var(--primary); }
.rail-sep { width: 36px; height: 1px; background: var(--line); margin: 4px 0; }
.rail-fill { flex: 1; }
.fly-wrap { position: relative; }
.fly {
  position: absolute; left: 68px; top: 0; width: 232px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 700;
}
.fly.up { top: auto; bottom: 0; }
.fly-h { font-size: 12px; font-weight: 700; color: var(--text-2); display: flex; align-items: baseline; gap: 6px; }
.fly-h small { font-weight: 500; color: var(--text-3); }
.fly .tool { justify-content: flex-start; height: 34px; }
.fac-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fac-grid .tool { justify-content: flex-start; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; height: 34px; }

/* 다음 단계 안내 */
.guide {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 585;
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-lg); padding: 6px 6px 6px 16px;
  display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; max-width: calc(100% - 24px);
}
.guide .n { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.guide .btn { height: 30px; border-radius: 999px; }
.map-wrap.has-hint .guide { display: none; }

/* 하단 동작 막대 */
.actionbar {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 590;
  display: flex; gap: 6px; background: rgba(11, 18, 32, .92); padding: 6px; border-radius: 14px; box-shadow: var(--shadow-lg); backdrop-filter: blur(6px);
}
.ab-btn {
  height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: #e2e8f0; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; touch-action: none;
}
.ab-btn:hover { background: rgba(255,255,255,.1); }
.ab-btn.primary { background: var(--primary-2); color: #fff; }
.ab-btn.primary:hover { background: #3b82f6; }
.ab-btn.on { background: #facc15; color: #111827; }
.ab-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 원본 보기: 설계 레이어 숨김 */
.map-wrap.peek .leaflet-map-pane > .leaflet-pane:not(.leaflet-tile-pane) { visibility: hidden; }
.map-wrap.peek .legend, .map-wrap.peek .inspector, .map-wrap.peek .guide, .map-wrap.peek .banner, .map-wrap.peek .sim-panel { visibility: hidden; }
.map-wrap.peek .actionbar > :not(#btnPeek) { opacity: .3; }

/* 오른쪽 패널 */
.panel { gap: 10px; }
.gen { position: static; padding: 0; margin: 0; background: none; }
.card.fold summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.card.fold summary::-webkit-details-marker { display: none; }
.card.fold summary::after { content: "▾"; margin-left: auto; color: var(--text-3); }
.card.fold[open] summary { margin-bottom: 10px; }
.card.fold[open] summary::after { content: "▴"; }
details.adv { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
details.adv summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
details.adv[open] summary { margin-bottom: 6px; }
.panel > .fine { margin: 0 2px 4px; }
.chip.max { background: rgba(250, 204, 21, .22); }

/* 초기화 대화상자 */
.reset-opts { display: flex; flex-direction: column; gap: 8px; }
.opt { text-align: left; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.opt:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.opt b { font-size: 14px; } .opt span { font-size: 12.5px; color: var(--text-2); }
.opt.danger b { color: var(--err); }
.opt.danger:hover { border-color: #fca5a5; background: #fef2f2; }

/* 운영 시뮬레이션 패널 */
.sim-panel {
  position: absolute; left: 12px; right: 12px; bottom: 80px; margin: 0 auto; max-width: 720px; z-index: 592;
  background: rgba(11, 18, 32, .94); color: #e2e8f0; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px 14px; backdrop-filter: blur(6px);
}
.sim-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sim-top b { font-size: 14px; color: #fff; }
.sim-clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 800; color: #fff; margin-left: auto; }
.sim-ctrl { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.sim-ctrl .sbtn { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; font-weight: 600; cursor: pointer; }
.sim-ctrl .sbtn.on { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.sim-ctrl label { font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.sim-ctrl input[type=number] { width: 64px; height: 30px; border-radius: 8px; border: 1px solid #334155; background: #0f172a; color: #fff; padding: 0 8px; }
.sim-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.sim-kpis div { background: #111c30; border-radius: 9px; padding: 7px 9px; }
.sim-kpis small { display: block; font-size: 11px; color: #94a3b8; }
.sim-kpis b { font-size: 16px; font-variant-numeric: tabular-nums; color: #fff; }
.sim-stages { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; font-size: 11.5px; color: #cbd5e1; }
.sim-stages span { display: inline-flex; align-items: center; gap: 5px; }
.sim-stages i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.sim-verdict { margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: #e2e8f0; }
.sim-verdict.warn { color: #fcd34d; }
.sim-close { border: 0; background: none; color: #94a3b8; font-size: 20px; cursor: pointer; line-height: 1; }

/* 보고서(화면 밖에서 렌더) */
.report-sheet { position: fixed; left: -10000px; top: 0; width: 794px; background: #fff; color: #0f172a; font-family: inherit; }

@media (max-width: 860px) {
  .rail { flex-direction: row; overflow-x: auto; padding: 6px; order: 2; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-fill { display: none; }
  .fly { left: 0; top: 66px; position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; }
  .fly.up { bottom: 12px; }
  .topbar .lbl { display: none; }
  .actionbar { bottom: 12px; }
  .ab-btn { padding: 0 10px; font-size: 12px; }
  .sim-kpis { grid-template-columns: repeat(3, 1fr); }
  .guide { top: 8px; font-size: 12px; }
}

.brand { width: auto; padding-right: 8px; }
.toast { bottom: 86px; }
@media (max-width: 560px) {
  .guide { white-space: normal; border-radius: 14px; left: 8px; right: 8px; transform: none; max-width: none; padding: 8px 8px 8px 12px; flex-wrap: wrap; }
  .actionbar { left: 8px; right: 8px; transform: none; justify-content: space-between; }
  .ab-btn { flex: 1; justify-content: center; padding: 0 6px; font-size: 11.5px; gap: 4px; white-space: normal; line-height: 1.15; text-align: center; }
  .ab-btn .ico { width: 16px; height: 16px; flex: none; }
  .sim-panel { bottom: 70px; left: 8px; right: 8px; }
  .toast { bottom: 76px; }
}
@media (max-width: 560px) { .leaflet-bottom.leaflet-right { bottom: 64px; } }

.total-max { margin: 2px 0 8px; padding: 8px 10px; border-radius: 9px; background: rgba(250, 204, 21, .16); color: #fde68a; font-size: 12.5px; }
.total-max b { color: #fff; font-size: 18px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.total-max span { display: block; color: #cbd5e1; font-size: 11.5px; margin-top: 2px; }

/* 시뮬레이션 창 v2: 작고 이동 가능 */
.sim-panel { left: 12px; top: 12px; right: auto; bottom: auto; width: 340px; max-width: calc(100% - 24px); margin: 0; padding: 0; border-radius: 12px; font-size: 12px; overflow: hidden; }
.sim-panel .sim-top { cursor: move; padding: 8px 10px; gap: 8px; background: rgba(255,255,255,.04); border-bottom: 1px solid #1e293b; flex-wrap: nowrap; touch-action: none; user-select: none; }
.sim-panel .sim-top b { font-size: 12.5px; white-space: nowrap; }
.sim-panel .sim-top .grip { color: #64748b; font-size: 13px; letter-spacing: -2px; }
.sim-panel .sim-clock { font-size: 15px; }
.sim-panel .sim-close, .sim-panel .sim-min { border: 0; background: none; color: #94a3b8; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.sim-panel .sim-body { padding: 8px 10px 10px; }
.sim-panel .sim-ctrl { margin-top: 0; gap: 4px; }
.sim-panel .sim-ctrl + .sim-ctrl { margin-top: 6px; }
.sim-panel .sim-ctrl .sbtn { height: 24px; padding: 0 7px; font-size: 11.5px; border-radius: 6px; }
.sim-panel .sim-ctrl label { font-size: 11px; gap: 3px; }
.sim-panel .sim-ctrl input[type=number] { width: 46px; height: 24px; padding: 0 5px; font-size: 11.5px; border-radius: 6px; }
.sim-panel .sim-kpis { grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 8px; }
.sim-panel .sim-kpis div { padding: 4px 6px; border-radius: 6px; }
.sim-panel .sim-kpis small { font-size: 10px; white-space: nowrap; }
.sim-panel .sim-kpis b { font-size: 13px; }
.sim-panel .sim-stages { font-size: 10.5px; gap: 3px 8px; margin-top: 6px; }
.sim-panel .sim-stages i { width: 7px; height: 7px; }
.sim-panel .sim-verdict { font-size: 11.5px; margin-top: 6px; max-height: 120px; overflow-y: auto; }
.sim-panel.min .sim-body { display: none; }
@media (max-width: 560px) { .sim-panel { width: auto; left: 8px; right: 8px; top: 8px; } .sim-panel .sim-kpis { grid-template-columns: repeat(3, 1fr); } }
