/* Layout: 지도(좌) + 배정 패널(우) 작업대, 아래로 선발 결과 요약이 이어지는 단일 컬럼 리포트 */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #5c6878;
  --line: #dde2ea;
  --soft: #eaeef4;
  --district: rgba(40, 60, 90, 0.045);
  --district-line: rgba(40, 60, 90, 0.22);
  --c0: #2257c7;
  --c1: #7a49c6;
  --c2: #0f8a73;
  --c3: #b97c0b;
  --pick: #d7192f;
  --focus: #18202b;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141a; --panel: #181e27; --ink: #e5e9ef; --muted: #98a3b3; --line: #2a3340; --soft: #212935;
    --district: rgba(200, 215, 235, 0.05); --district-line: rgba(200, 215, 235, 0.2);
    --c0: #5b8cf0; --c1: #a682ec; --c2: #2fc0a1; --c3: #e3ac3c; --pick: #ff4b5f; --focus: #ffffff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10141a; --panel: #181e27; --ink: #e5e9ef; --muted: #98a3b3; --line: #2a3340; --soft: #212935;
  --district: rgba(200, 215, 235, 0.05); --district-line: rgba(200, 215, 235, 0.2);
  --c0: #5b8cf0; --c1: #a682ec; --c2: #2fc0a1; --c3: #e3ac3c; --pick: #ff4b5f; --focus: #ffffff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  margin: 0;
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.55;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 48px;
}
.wrap { max-width: 1280px; margin: 0 auto; display: grid; gap: 20px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lede { color: var(--muted); max-width: 68ch; margin: 6px 0 0; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 0.8rem; }
.meta b { color: var(--ink); font-weight: 600; }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .work { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stage { position: relative; min-width: 0; overflow: hidden; }
#map { display: block; width: 100%; height: min(72vh, 680px); min-height: 380px; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
.zoom { position: absolute; top: 12px; right: 12px; display: grid; gap: 4px; }
.zoom button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: 600 16px/1 var(--font-body); cursor: pointer;
}
.zoom button.wide { font-size: 11px; }
.legend {
  position: absolute; left: 12px; bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; display: grid; gap: 4px; font-size: 0.78rem; max-width: calc(100% - 24px);
}
.legend button {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 2px 0; color: var(--ink);
  font: inherit; cursor: pointer; text-align: left;
}
.legend button[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.legend .hint { color: var(--muted); font-size: 0.72rem; }
@media (max-width: 600px) {
  #map { height: min(90vw, 460px); min-height: 300px; }
  .legend { position: static; max-width: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .legend .hint { grid-column: 1 / -1; }
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ring { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--pick); background: var(--soft); flex: none; }
.legend .row { display: flex; align-items: center; gap: 8px; }
.tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 0.78rem; box-shadow: 0 6px 20px rgba(0,0,0,0.14); min-width: 190px; max-width: 260px; z-index: 3;
}
.tip strong { display: block; font-size: 0.86rem; }
.tip .kv { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin-top: 6px; }
.tip .kv span:nth-child(odd) { color: var(--muted); }
.tip .kv span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.badge.pick { background: var(--pick); color: #fff; }

.panel { padding: 16px; display: grid; gap: 14px; }
.panel p { margin: 0; }
.small { font-size: 0.78rem; color: var(--muted); }
.slider { display: grid; gap: 4px; }
.slider .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.slider label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.88rem; }
.slider .alloc { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.slider .alloc b { color: var(--ink); font-family: var(--font-num); font-weight: 500; }
.slider input[type="range"] { width: 100%; margin: 0; }
.slider .cut { font-size: 0.74rem; color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--soft); font-size: 0.82rem; }
.total.warn b { color: var(--pick); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px 10px;
  font: 500 0.8rem var(--font-body); cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); font-weight: 600; padding: 10px 14px; font-size: 0.9rem; width: 100%; }
.btn.primary.dirty { background: var(--pick); border-color: var(--pick); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, th button:focus-visible { outline: 2px solid var(--c0); outline-offset: 2px; }
.applied { font-size: 0.78rem; color: var(--muted); }

.results { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 12px 14px; min-width: 0; }
.kpi .v { font-family: var(--font-num); font-size: 1.35rem; font-weight: 500; margin-top: 2px; }
.kpi .s { font-size: 0.76rem; color: var(--muted); overflow-wrap: anywhere; }
.mix { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 8px; background: var(--soft); }

.split { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.section { padding: 16px; display: grid; gap: 12px; min-width: 0; }
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 64px minmax(0, 1fr) 28px; align-items: center; gap: 8px; font-size: 0.8rem; }
.bar .track { display: flex; height: 14px; }
.bar .track span { height: 100%; }
.bar .track span:first-child { border-radius: 3px 0 0 3px; }
.bar .track span:last-child { border-radius: 0 3px 3px 0; }
.bar .n { text-align: right; font-family: var(--font-num); }
.bar button { all: unset; cursor: pointer; }
.bar button:hover { text-decoration: underline; }
.bar button:focus-visible { outline: 2px solid var(--c0); }
.zero { font-size: 0.76rem; color: var(--muted); }

.tbl-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
select { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 560px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 0.82rem; }
thead th { position: sticky; top: 0; background: var(--soft); z-index: 1; text-align: left; font-weight: 600; color: var(--muted); padding: 0; white-space: nowrap; }
th button { all: unset; display: block; padding: 8px 10px; cursor: pointer; }
th.r button, td.r { text-align: right; }
td { padding: 7px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
td.r { font-variant-numeric: tabular-nums; }
td.name { white-space: normal; min-width: 180px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--soft); }
tbody tr.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--pick); }
.gu-wrap { max-height: 380px; }
.gu-tbl { min-width: 520px; }
.gu-tbl tfoot td { position: sticky; bottom: 0; background: var(--soft); font-weight: 700; border-top: 2px solid var(--line); }
.gu-tbl td.top { font-weight: 600; }
.gu-tbl td.top.none { color: var(--muted); font-weight: 400; }
.gbar { display: inline-block; width: 70px; height: 6px; background: var(--soft); border-radius: 3px; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.gbar i { display: block; height: 100%; background: var(--pick); }
.gbar.avg i { background: var(--muted); }
.mini { display: inline-block; width: 46px; height: 6px; background: var(--soft); border-radius: 3px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--muted); }
.err { padding: 24px; color: var(--pick); }
.foot { font-size: 0.76rem; color: var(--muted); max-width: 80ch; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
