/* 업무용 3단 화면: 조건 | 지도·목록 | 안내지. 좁은 화면에서는 위→아래로 쌓는다.
   색: 차분한 소나무 녹색 하나를 강조색으로 쓰고, 상태(접수 중/예정/마감/확인 필요)는 별도 의미색. */
:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --ink: #1c2622;
  --muted: #5a6762;
  --line: #d6ddd9;
  --accent: #1e6655;
  --accent-ink: #ffffff;
  --accent-soft: #e0efe9;
  --ok: #24724a;
  --ok-soft: #e3f3e9;
  --soon: #2f5ea8;
  --soon-soft: #e6eefb;
  --warn: #9a5200;
  --warn-soft: #fdf0dc;
  --off: #6f7673;
  --off-soft: #eceeed;
  --focus: #e0a100;
  --shadow: 0 1px 2px rgb(20 40 32 / .06), 0 4px 16px rgb(20 40 32 / .06);
  --font: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121816; --surface: #1a2220; --surface-2: #222c29; --ink: #e6ece9; --muted: #9fb0aa;
    --line: #33403c; --accent: #5cc0a4; --accent-ink: #0d1a16; --accent-soft: #1f3a33;
    --ok: #7fd3a0; --ok-soft: #1d3628; --soon: #8fb4f0; --soon-soft: #1e2b44;
    --warn: #f0b660; --warn-soft: #3a2b14; --off: #9aa29f; --off-soft: #2a302e;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121816; --surface: #1a2220; --surface-2: #222c29; --ink: #e6ece9; --muted: #9fb0aa;
  --line: #33403c; --accent: #5cc0a4; --accent-ink: #0d1a16; --accent-soft: #1f3a33;
  --ok: #7fd3a0; --ok-soft: #1d3628; --soon: #8fb4f0; --soon-soft: #1e2b44;
  --warn: #f0b660; --warn-soft: #3a2b14; --off: #9aa29f; --off-soft: #2a302e;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; margin: 0; }

/* ── 상단 ── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px;
  padding-block: 16px 14px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.data-status { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.banner {
  margin: 12px max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  padding: 10px 14px; border-radius: var(--r);
  background: var(--warn-soft); color: var(--warn); font-size: 14px;
}

/* ── 3단 ── */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
  gap: 16px; align-items: start;
  padding-block: 16px 40px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; position: sticky; top: 16px;
  max-height: calc(100vh - 32px); overflow: auto;
}
.panel-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

/* ── 조건 ── */
.filters { display: flex; flex-direction: column; gap: 18px; }
.filters .panel-title { margin-bottom: 0; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field > label, .field legend { font-weight: 600; font-size: 14px; padding: 0; }
.field legend { margin-bottom: 6px; }
.legend-note { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.input-row { display: flex; gap: 6px; }
input[type="text"], input[type="search"], select {
  width: 100%; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.stack { flex-direction: column; align-items: stretch; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span {
  display: block; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 13.5px; white-space: nowrap;
}
.chips.stack span { border-radius: 6px; }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.chips .n { opacity: .65; margin-left: 3px; font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-text { border: 0; background: none; padding: 4px 0; color: var(--accent); cursor: pointer; font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; align-self: flex-start; }

/* ── 결과 ── */
.results { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: none; padding: 10px 14px; cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.count {
  display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.tab[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent); }

.map-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.map { height: 340px; width: 100%; }
.map-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 20px; color: var(--muted); font-size: 14px; background: var(--surface-2);
}
.result-summary { margin: 0; color: var(--muted); font-size: 13.5px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.place {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; scroll-margin-top: 16px;
}
.place.flash { box-shadow: 0 0 0 3px var(--focus); }
.place-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
  padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.pin-no {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pin-no.none { background: var(--off-soft); color: var(--off); }
.place-name { font-size: 16px; font-weight: 700; }
.place-type { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 6px; }
.place-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.place-dist { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14px; }
.place-dist.none { color: var(--muted); font-weight: 500; font-size: 12.5px; }

.svc { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
.svc:first-of-type { border-top: 0; }
.group-head { font-size: 14px; font-weight: 700; color: var(--muted); margin: 8px 0 -2px; letter-spacing: .02em; }
.svc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.svc-title { font-weight: 600; font-size: 15px; }
.svc-org { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.svc-desc { color: var(--ink); font-size: 14px; margin: 2px 0 0; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.b-open { background: var(--ok-soft); color: var(--ok); }
.b-soon { background: var(--soon-soft); color: var(--soon); }
.b-closed { background: var(--off-soft); color: var(--off); }
.b-none { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-elig { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.svc.closed .svc-title { color: var(--muted); }

.add {
  align-self: start; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--accent); background: var(--surface); color: var(--accent); white-space: nowrap;
}
.add[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

details.more { grid-column: 1 / -1; }
details.more summary { cursor: pointer; color: var(--accent); font-size: 13.5px; width: fit-content; }
.detail-grid { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; font-size: 14px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }

.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }

/* ── 안내지 트레이 ── */
.tray-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: t; }
.tray-list li {
  counter-increment: t; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: start;
  padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 13.5px;
}
.tray-list li::before { content: counter(t); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.tray-list .t-org { display: block; color: var(--muted); font-size: 12px; }
.tray-list button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }
.tray-list li.dragging { opacity: .5; }
.tray-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tray-actions .btn { width: 100%; padding: 10px; }
.tray-fab {
  position: fixed; z-index: 20;
  right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding: 12px 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: var(--shadow);
}

/* ── 지도 핀 ── */
.kpin {
  transform: translate(-50%, -100%); cursor: pointer;
  background: #1e6655; color: #fff; border: 2px solid #fff; border-radius: 14px 14px 14px 2px;
  min-width: 26px; height: 26px; padding: 0 6px; display: grid; place-items: center;
  font: 700 12px/1 var(--font); box-shadow: 0 1px 4px rgb(0 0 0 / .35);
}
.kpin.on { background: #e0a100; color: #1c2622; }
.kbase {
  transform: translate(-50%, -50%); background: #c0392b; color: #fff; border: 2px solid #fff; border-radius: 6px;
  padding: 3px 8px; font: 700 12px/1.2 var(--font); white-space: nowrap; box-shadow: 0 1px 4px rgb(0 0 0 / .35);
}

/* ── 미리보기 ── */
.preview { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: end; gap: 10px 20px;
  padding-block: calc(12px + env(safe-area-inset-top, 0px)) 12px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.preview-bar h2 { font-size: 16px; width: 100%; }
.preview-controls { display: flex; flex-wrap: wrap; gap: 10px; flex: 1 1 600px; }
.preview-controls label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.preview-controls select { width: auto; }
.preview-controls input { width: 170px; }
.preview-actions { display: flex; gap: 8px; }
.preview-stage { flex: 1; overflow: auto; padding: 24px 16px 60px; }

/* ── 안내지 (화면·인쇄 공통, 항상 밝은 종이) ── */
.handout {
  --h-ink: #111; --h-muted: #444; --h-line: #999; --h-accent: #1e6655;
  --hs: 16pt;
  width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 14mm;
  background: #fff; color: var(--h-ink); box-shadow: 0 2px 12px rgb(0 0 0 / .18);
  font: var(--hs)/1.5 var(--font); color-scheme: light;
}
.handout.paper-A3 { width: 297mm; min-height: 420mm; }
.handout.size-xl { --hs: 19pt; }
.handout .h-top { display: flex; justify-content: space-between; align-items: end; gap: 12px; border-bottom: 3px solid var(--h-accent); padding-bottom: 8px; margin-bottom: 6mm; }
.handout .h-top h1 { font-size: 1.55em; line-height: 1.25; }
.handout .h-date { font-size: .8em; color: var(--h-muted); white-space: nowrap; }
.handout .h-intro { margin: 0 0 6mm; font-size: .95em; }
.handout .h-item { break-inside: avoid; page-break-inside: avoid; border: 1.5px solid var(--h-line); border-radius: 3mm; padding: 4.5mm 5mm; margin-bottom: 5mm; }
.handout .h-item h2 { font-size: 1.25em; line-height: 1.3; display: flex; gap: 3mm; align-items: baseline; }
.handout .h-num { flex: none; width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--h-accent); color: #fff; display: inline-grid; place-items: center; font-size: .8em; }
.handout .h-org { margin: 1mm 0 3mm; color: var(--h-muted); font-size: .9em; }
.handout .h-rows { display: grid; grid-template-columns: 5.2em minmax(0, 1fr); gap: 1.5mm 4mm; margin: 0; }
.handout .h-rows dt { font-weight: 700; }
.handout .h-rows dd { margin: 0; overflow-wrap: anywhere; }
.handout .h-phone { font-size: 1.3em; font-weight: 700; letter-spacing: .02em; }
.handout .h-caution { margin: 3mm 0 0; padding: 2mm 3mm; background: #f3f3f3; border-left: 4px solid #333; font-size: .85em; }
.handout .h-foot { margin-top: 8mm; padding-top: 4mm; border-top: 1.5px solid var(--h-line); font-size: .85em; color: var(--h-muted); }
.handout .h-foot strong { color: var(--h-ink); }

/* ── 반응형 ── */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .tray { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .panel { position: static; max-height: none; }
  .map { height: 260px; }
  .preview-controls input { width: 140px; }
  .handout { padding: 8mm; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ── 인쇄: 안내지만 ── */
@media print {
  body { background: #fff; }
  .app, .preview-bar { display: none !important; }
  .preview { position: static; display: block !important; background: #fff; }
  .preview-stage { padding: 0; overflow: visible; }
  .handout { width: auto !important; min-height: 0 !important; margin: 0; padding: 0; box-shadow: none; }
  .handout .h-item, .handout .h-caution { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
