/* 결측 복원 화면 — 토스식 원칙: 선 대신 여백, 숫자가 주인공, 결론 먼저, 화면마다 주인공 버튼 하나, 부드러운 움직임.
   (토스의 로고·전용 글꼴·디자인 시스템은 쓰지 않는다. 글꼴은 Pretendard 로컬 사본)
   색 뜻: 파랑 = 버튼·선택(조작), 주황 = 결측, 방법 4색 = 선형(청록)·IDW(초록)·RF(보라)·XGB(분홍), 회색 선 = 관측 */

:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --text: #191f28;
  --text2: #4e5968;
  --text3: #8b95a1;
  --line: #e5e8eb;
  --fill: #f2f4f6;
  --fill2: #f9fafb;
  --blue: #3478f6;
  --blue-press: #2563e0;
  --blue-weak: #e8f1ff;
  --obs: #6b7684;
  --miss: #ff8a3d;
  --miss-weak: #fff1e7;
  --m-linear: #12a4c8;
  --m-idw: #2db46c;
  --m-rf: #6e56cf;
  --m-xgb: #f2649b;
  --grid: rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --r-card: 20px;
  --r-ctl: 12px;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --chrome-h: 92px;   /* 상단 막대 52 + 탭 40 */
}
/* 첫 화면 다음부터는 맨 위 막대와 탭 줄을 숨겨 화면을 넓게 쓴다(열린 자료 탭은 첫 화면에서 고른다) */
body.in-tab { --chrome-h: 0px; }
body.in-tab .topbar { display: none; }
:root[data-seed-user-color-scheme="dark"] {
  --bg: #101013;
  --card: #1c1c21;
  --text: #f2f4f6;
  --text2: #b0b8c1;
  --text3: #7e8792;
  --line: #2c2c33;
  --fill: #26262c;
  --fill2: #212126;
  --blue: #4c8df7;
  --blue-press: #3b7cf0;
  --blue-weak: #1d2a44;
  --obs: #9aa4ae;
  --miss: #ff9a52;
  --miss-weak: #3a2717;
  --m-linear: #2bb7d9;
  --m-idw: #3cc77c;
  --m-rf: #9583ec;
  --m-xgb: #f47aa9;
  --grid: rgba(255, 255, 255, 0.07);
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
sub { font-size: 0.72em; line-height: 0; vertical-align: -0.28em; }
small { font-size: 12px; }
h1, h2, h3 { letter-spacing: -0.02em; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px; border: 0; border-radius: var(--r-ctl);
  background: var(--fill); color: var(--text); font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; white-space: nowrap; transition: background .15s, transform .08s;
}
.btn:hover { background: color-mix(in srgb, var(--fill) 70%, var(--text) 6%); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-press); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .35; cursor: default; transform: none; }

/* ---------- 상단 막대 · 탭 ---------- */
.topbar { position: sticky; top: 0; z-index: 6; height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--card); }
.brand { font-size: 17px; font-weight: 800; white-space: nowrap; }
.brand span { color: var(--blue); margin: 0 2px; }
.topbar-meta { margin: 0; color: var(--text3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-link { margin-left: auto; color: var(--text3); font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.topbar-link:hover { background: var(--fill); color: var(--text); }

.tabbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tabbar[hidden] { display: none; }
.tabbar-label { margin-right: 4px; color: var(--text3); font-size: 13px; }
.tab { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; height: 30px; padding: 0 8px 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text3); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.tab .t-name { overflow: hidden; text-overflow: ellipsis; }
.tab .t-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--fill); color: var(--text3); }
.tab .t-badge.run { background: var(--blue); color: #fff; font-family: var(--f-mono); }
.tab .t-badge.done { background: var(--blue-weak); color: var(--blue); }
.tab .t-close { border: 0; background: transparent; color: var(--text3); font-size: 15px; line-height: 1; padding: 3px 5px; border-radius: 6px; cursor: pointer; }
.tab .t-close:hover { background: var(--fill); color: var(--text); }
.tab.new { color: var(--blue); padding: 0 12px; }

/* ---------- 공통 ---------- */
.page { padding: 8px 16px 16px; }
.screen { display: grid; gap: 14px; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card { background: var(--card); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow); }
.screen-head { display: grid; gap: 8px; }
.screen-head h1 { margin: 0; font-size: 28px; font-weight: 800; }
.lead { margin: 0; color: var(--text2); font-size: 16px; max-width: 70ch; }
.note { margin: 10px 0 0; color: var(--text3); font-size: 13px; }
.back { justify-self: start; border: 0; background: transparent; color: var(--text2); font: inherit; font-size: 14px; font-weight: 600; padding: 6px 10px; margin-left: -10px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.back:hover { background: var(--card); color: var(--text); }
.steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; color: var(--text3); font-size: 12px; white-space: nowrap; }
.steps li { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border-radius: 999px; }
.steps b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--fill); font-size: 10px; }
.steps li.done { color: var(--text2); }
.steps li.now { color: var(--blue); font-weight: 700; background: var(--blue-weak); }
.steps li.now b { background: var(--blue); color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--fill); color: var(--text2); }
.tag.ok { background: var(--blue-weak); color: var(--blue); }

/* ---------- 화면 1: 자료 올리기 ---------- */
#viewRun { max-width: 960px; width: 100%; margin: 24px auto 0; }
/* 첫 화면은 창 높이 안에: 제목 줄 + 두 칸. 칸 안의 파일 칸·지역 목록이 남는 높이에 맞춰 줄고, '결측 현황 보기'는 오른쪽 칸 맨 아래 */
#viewHome { max-width: 1240px; width: 100%; margin: 12px auto 0; height: calc(100vh - 52px - 40px); grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
#viewHome .card { padding: 20px 22px; }
#viewHome .screen-head { gap: 6px; }
#viewHome .screen-head h1 { font-size: 24px; }
#viewHome .lead { font-size: 14px; max-width: none; }
.drop { display: grid; gap: 8px; place-items: center; text-align: center; padding: 48px 20px; border: 2px dashed var(--line); border-radius: 16px; background: var(--fill2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-weak); }
.drop strong { font-size: 18px; font-weight: 700; }
.drop span { color: var(--text3); font-size: 13px; max-width: 64ch; }
.demo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; color: var(--text3); font-size: 13px; }
/* 예시 버튼: 회색 칩이 아니라 누르는 버튼으로 보이게(파란 테두리·글자, 화살표, 누르면 파랗게 채움) */
.demo-row .btn { height: 38px; padding: 0 14px; background: var(--blue-weak); color: var(--blue); border: 1px solid color-mix(in srgb, var(--blue) 45%, transparent); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.demo-row .btn::after { content: "→"; font-weight: 700; transition: transform .15s; }
.demo-row .btn:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.demo-row .btn:hover::after { transform: translateX(3px); }
.demo-row .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 첫 화면: 왼쪽 파일(예시) · 오른쪽 분석 조건(지역·기간·오염물질) */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; min-height: 0; }
.home-file { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.home-h { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 17px; font-weight: 800; }
.home-h b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 13px; }
.home-file .drop { flex: 1; min-height: 120px; padding: 20px; }
.home-file .status { margin-top: 10px; }
.demo-row > span { flex-basis: 100%; }
.demo-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.demo-btns .btn { justify-content: space-between; }
.home-pick { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
#boxStations { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
#boxStations .tree-box { flex: 1; min-height: 0; max-height: none; }
.pick-empty { margin: 0 0 2px; color: var(--text3); font-size: 13px; }
.home-pick.ready .pick-empty { color: var(--text2); font-weight: 600; }
.pick-box { min-width: 0; margin: 0; padding: 8px 12px 12px; border: 1px solid var(--line); border-radius: 14px; transition: opacity .15s; }
.pick-box:disabled { opacity: .45; }
.pick-box legend { padding: 0 6px; font-size: 14px; font-weight: 700; }
.pick-box legend small { margin-left: 6px; color: var(--text3); font-size: 12px; font-weight: 500; }
.tree-box { max-height: 236px; overflow-y: auto; font-size: 14px; }
.tree-box.short { max-height: none; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree .row { display: flex; align-items: center; gap: 6px; padding: 3px 0 3px calc(var(--d) * 22px); }
.tree li.closed > ul { display: none; }
.tree .tw { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--text2); font: inherit; font-size: 13px; line-height: 1; cursor: pointer; }
.tree .tw:hover { border-color: var(--blue); color: var(--blue); }
.tree .tw-gap { width: 18px; }
.tree label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.tree input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.tree input:disabled + span { color: var(--text3); }
.tree .branch > .row > label { font-weight: 700; }
.tree small { margin-left: 4px; color: var(--text3); font-size: 11px; font-weight: 500; }
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.period input, .period select { height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; }
.period span { color: var(--text3); }
.pick-go { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 4px; }
.pick-sum { flex: 1; min-width: 0; margin: 0; color: var(--text2); font-size: 13px; }
.pick-sum.error { color: #f04452; font-weight: 600; }
@media (max-width: 900px), (max-height: 560px) {
  .home-grid { grid-template-columns: 1fr; }
  #viewHome { height: auto; }
  .home-file, .home-pick { overflow: visible; }
  #boxStations .tree-box { max-height: 236px; }
}
.status { min-height: 1.4em; margin: 12px 0 0; color: var(--text2); font-weight: 600; }
.status.error { color: #f04452; }

/* ---------- 화면 2·4: 결측 현황 · 복원 결과 ---------- */
#viewData.app { height: calc(100vh - var(--chrome-h) - 24px); display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; }
.appbar { display: flex; align-items: center; gap: 8px 14px; min-width: 0; }
.appbar h1 { margin: 0; font-size: 22px; font-weight: 800; white-space: nowrap; }
.appbar .facts-line { flex: 1; min-width: 0; margin: 0; color: var(--text3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .actions { display: flex; gap: 8px; margin-left: auto; }
.appbar.sub { position: relative; }

.polbar { display: flex; gap: 6px; flex-wrap: nowrap; }
.polbar button { display: inline-flex; align-items: baseline; gap: 6px; height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--card); color: var(--text2); font: inherit; font-size: 14px; line-height: 36px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); transition: background .15s, color .15s; }
.polbar button small { color: var(--text3); font-weight: 600; font-size: 11px; }
.polbar button:hover { color: var(--text); }
.polbar button[aria-selected="true"] { background: var(--blue); color: #fff; }
.polbar button[aria-selected="true"] small { color: rgba(255, 255, 255, .8); }

.strip { flex: 1; min-width: 0; background: var(--card); border-radius: 14px; padding: 8px 14px; box-shadow: var(--shadow); }
.strip summary { cursor: pointer; list-style: none; color: var(--text2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip summary::-webkit-details-marker { display: none; }
.strip summary b { color: var(--text); }
.strip summary .more { margin-left: 10px; color: var(--blue); font-weight: 700; }
.strip summary .more:first-child { margin-left: 0; }
.strip summary .more::after { content: " ›"; }
.strip #stripMore { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: min(780px, 100%); background: var(--card); border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .14); animation: fade .15s; }

.three { height: 100%; min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr) minmax(360px, 30%); gap: 12px; }
.pick { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
.three .card, .pick .card { padding: 16px; }
.pick h2 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.pick h2 small { margin-left: 6px; color: var(--text3); font-weight: 500; font-size: 12px; }
/* 상세 칸: 이전·다음 줄은 고정, 아래 상세 내용만 스크롤 */
.detail-card { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.detail-card .detail { flex: 1; min-height: 0; overflow-y: auto; }
/* 측정소·결측 칸: 가운데 그래프 칸처럼 제목은 고정, 목록만 스크롤 */
.stations, .gaps { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.stations .station-list, .gaps .gap-list { flex: 1; min-height: 0; overflow-y: auto; }

.station-list, .gap-list { list-style: none; margin: 0; padding: 0; }
.station-list li { display: grid; grid-template-columns: 1fr 52px 46px; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; cursor: pointer; font-size: 14px; transition: background .12s; }
.station-list li:hover { background: var(--fill2); }
.station-list li.sel { background: var(--blue-weak); color: var(--blue); font-weight: 700; }
.station-list .s-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-list .s-rate { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text3); }
.station-list li.sel .s-rate { color: var(--blue); }
.station-list .rbar, .station-list .stack { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--fill); }
.station-list .rbar i { display: block; height: 100%; background: var(--miss); border-radius: 3px; }
.station-list .stack i { display: block; height: 100%; }

.gap-list li { display: grid; grid-template-columns: minmax(58px, auto) minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; cursor: pointer; font-size: 14px; white-space: nowrap; transition: background .12s; }
.gap-list li:hover { background: var(--fill2); }
.gap-list li.sel { background: var(--blue-weak); }
.gap-list li.sel b { color: var(--blue); }
.gap-list li span { color: var(--text3); font-variant-numeric: tabular-nums; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.gap-list li em { font-style: normal; font-size: 11px; color: var(--text3); }
/* 72시간 넘는 결측 = 학습 범위 밖: 주황(결측 색) 계열로 요약 칩·목록 표시·상세 문구 */
.range-warn { flex: none; max-width: 46%; margin: 0; padding: 7px 12px; border-radius: 12px; background: var(--miss-weak); color: color-mix(in srgb, var(--miss) 55%, var(--text)); font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.range-warn::before { content: "!"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 6px; border-radius: 50%; background: var(--miss); color: #fff; font-size: 11px; font-weight: 800; vertical-align: -2px; }
.gap-list li i.beyond { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 5px; border-radius: 50%; background: var(--miss); color: #fff; font-style: normal; font-size: 10px; font-weight: 800; vertical-align: -2px; cursor: help; }
.detail .beyond-note { margin: -4px 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--miss-weak); color: var(--text); font-size: 13px; line-height: 1.55; }
.detail .beyond-note b { display: block; margin-bottom: 2px; color: color-mix(in srgb, var(--miss) 55%, var(--text)); }

.center { display: flex; flex-direction: column; min-height: 0; }
.chart-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.chart-box { flex: 1; min-height: 0; overflow-y: auto; }
#chart { width: 100%; display: block; }
.legend { display: flex; flex-wrap: nowrap; gap: 4px 14px; margin-top: 8px; color: var(--text3); font-size: 12px; overflow: hidden; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.legend i.line { height: 2px; border-radius: 1px; }

/* 상세: 한 줄 판정 → 핵심 3개 → 그래프 → 자세히 */
.gap-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.gap-nav span { color: var(--text3); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600; }
.detail { animation: fade .18s; }
.detail h3 { margin: 0; font-size: 20px; font-weight: 800; }
.detail .sub { margin: 2px 0 12px; color: var(--text3); font-size: 13px; }
.detail .placeholder { margin: 0; color: var(--text3); }
.detail .gone-btn { margin-top: 14px; }
.detail .verdict { margin: 0 0 14px; padding: 14px 16px; border-radius: 14px; background: var(--fill2); color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.55; }
.detail .trio { display: grid; gap: 2px; margin-bottom: 14px; }
.detail .trio div { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 12px; padding: 10px 2px; }
.detail .trio div + div { border-top: 1px solid var(--line); }
.detail .trio span { color: var(--text3); font-size: 13px; }
.detail .trio b { font-size: 18px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.detail .trio small { grid-column: 1 / -1; color: var(--text3); font-size: 12px; line-height: 1.45; }
.detail canvas { width: 100%; display: block; margin: 4px 0 6px; }
.detail .caption { margin: 0 0 12px; color: var(--text3); font-size: 12px; }
.detail .mini-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.mini-legend .lg-curve { white-space: nowrap; }
.mini-legend .lg-curve i { display: inline-block; width: 18px; margin-right: 4px; vertical-align: middle; }
.mini-legend .lg-curve.on { color: var(--text); font-weight: 700; }
.detail details { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.detail summary { cursor: pointer; list-style: none; color: var(--blue); font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.detail summary::-webkit-details-marker { display: none; }
.detail summary::after { content: " ›"; }
.detail details[open] summary::after { content: " ⌄"; }
.detail .kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.detail .kv dt { color: var(--text3); }
.detail .kv dd { margin: 0; font-weight: 600; }
.detail .kv small, .detail td small { color: var(--text3); font-weight: 400; }
.detail table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail th, .detail td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.detail th { color: var(--text3); font-weight: 600; }
.detail td:first-child { white-space: nowrap; }
.detail td.num, .detail th.num { text-align: right; font-variant-numeric: tabular-nums; }
.detail tr.chosen td { font-weight: 800; }
.detail tr.failed td { color: var(--text3); }
.detail .why { margin: 12px 0 0; color: var(--text3); font-size: 13px; }

/* 권역 요약 표(요약 줄을 펼쳤을 때) */
.matrix { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.matrix th { text-align: left; font-weight: 700; padding: 4px 8px; white-space: nowrap; }
.matrix thead th { color: var(--text3); font-weight: 600; text-align: center; }
.matrix td { text-align: right; padding: 7px 10px; border-radius: 8px; background: var(--fill2); position: relative; font-variant-numeric: tabular-nums; }
.matrix .cbar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--miss-weak); border-radius: 8px; }
.matrix td b { position: relative; font-weight: 700; }
.matrix td.wide { text-align: left; min-width: 0; }
.matrix .stack { display: flex; height: 10px; margin-bottom: 4px; border-radius: 5px; overflow: hidden; background: var(--fill); }
.matrix .stack i { display: block; height: 100%; }
.matrix td.wide small { color: var(--text3); }
/* 결측 현황의 결측 길이 표: 길이 구분 색 견본 */
.matrix .sw, .matrix-legend .sw { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
.matrix-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px; padding: 0 8px; color: var(--text2); font-size: 12px; }

/* ---------- 화면 3: 복원 중 ---------- */
.run-card { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 56px 24px; }
.run-title { margin: 0; color: var(--text2); font-weight: 600; }
.big-pct { font-size: 64px; font-weight: 800; line-height: 1; color: var(--blue); font-variant-numeric: tabular-nums; }
.bar.big { width: min(560px, 100%); height: 10px; background: var(--fill); border-radius: 999px; overflow: hidden; }
.bar.big i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width .45s ease; }
.run-card .msg { margin: 0; min-height: 1.4em; color: var(--text2); font-size: 14px; }

/* ---------- 말풍선(그래프 막대에 마우스) ---------- */
.tip { position: fixed; z-index: 20; pointer-events: none; background: #191f28; color: #fff; font-size: 12px; line-height: 1.5; padding: 8px 11px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: fade .1s; }

/* ---------- 좁거나 낮은 화면: 꽉 채우기를 풀고 위아래로 ---------- */
@media (max-width: 1100px) {
  .topbar-meta { display: none; }
}
@media (max-width: 1000px), (max-height: 540px) {
  #viewData.app { height: auto; }
  .appbar { flex-wrap: wrap; }
  .appbar.sub .polbar { flex-wrap: wrap; }
  .three { grid-template-columns: 1fr; height: auto; }
  .pick { grid-template-rows: auto auto; }
  .stations, .gaps { max-height: 280px; }
  .chart-box { flex: none; height: 520px; }
  .detail-card { overflow: visible; }
  .detail-card .detail { overflow: visible; }
  .detail .trio div { grid-template-columns: 1fr; }
}

/* ---------- 줄 넘김: 어디서나 어절 단위로만. 숫자+단위 같은 한 덩어리(.nw)는 넘기지 않음 ---------- */
body, button, input, select, table { word-break: keep-all; overflow-wrap: normal; line-break: strict; }
.nw { white-space: nowrap; }

/* ---------- 상세 '자세히': 작은 제목이 붙은 묶음 ---------- */
.detail .sec { margin: 0 0 20px; }
.detail .sec h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--text2); }
.detail .sec h4 small { margin-left: 6px; color: var(--text3); font-weight: 500; font-size: 12px; }
.detail .foot { margin: 6px 0 0; color: var(--text3); font-size: 12px; line-height: 1.5; }
.detail table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail table.grid th, .detail table.grid td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.detail table.grid thead th { color: var(--text3); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
.detail table.grid tbody th { text-align: left; color: var(--text2); font-weight: 600; white-space: nowrap; }
.detail table.grid tbody tr:last-child th, .detail table.grid tbody tr:last-child td { border-bottom: 0; }
.detail table.grid td.num { text-align: right; font-weight: 700; color: var(--text); white-space: nowrap; }
.detail table.grid tr.chosen th, .detail table.grid tr.chosen td { color: var(--blue); font-weight: 800; }
.detail table.grid tr.failed th, .detail table.grid tr.failed td { color: var(--text3); font-weight: 500; }
.detail .cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.detail .cells.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail .cells.five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.detail .cells > div { display: grid; align-content: start; gap: 3px; padding: 10px 12px; border-radius: 12px; background: var(--fill2); min-width: 0; }
.detail .cells.five > div { padding: 8px 8px; text-align: center; }
.detail .cells span { color: var(--text3); font-size: 12px; }
.detail .cells b { font-size: 16px; font-weight: 800; color: var(--text); }
.detail .cells small { color: var(--text3); font-size: 11px; line-height: 1.45; }
.detail .cells .hit b { color: var(--miss); }
.detail .cells .mbar { display: block; height: 4px; margin-top: 4px; border-radius: 2px; overflow: hidden; background: var(--line); }
.detail .cells .mbar i { display: block; height: 100%; background: var(--miss); border-radius: 2px; }

/* 오염물질은 세 개뿐이라 한 줄로: 전체 · NO₂ · PM10 · PM2.5 (펼침 버튼 없이) */
#treePols .tree > li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
#treePols .tree > li > ul { display: flex; flex-wrap: wrap; gap: 4px 18px; }
#treePols .row { padding-left: 0; }
#treePols .tw, #treePols .tw-gap { display: none; }

/* 복원 결과 물질별 지표 표(복원율=자연 결측, RMSE=인위적 결측) */
.matrix.scores { margin-bottom: 6px; }
.matrix.scores td { text-align: right; }
.matrix.scores td.muted, .strip .muted { color: var(--text3); text-align: left; }
.matrix-note { margin: 0 4px 14px; color: var(--text3); font-size: 12px; }

/* ---------- 오른쪽 그래프 확대 창 ---------- */
#mini { cursor: zoom-in; }
.zoom { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgb(0 0 0 / .45); animation: fade .15s; }
.zoom[hidden] { display: none; }
.zoom-box { width: min(1200px, 100%); background: var(--card); border-radius: 18px; padding: 16px 20px 12px; box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.zoom-box header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.zoom-box h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 800; }
.zoom-tools { display: flex; gap: 6px; }
.zoom-tools .btn { min-width: 36px; }
#zoomCanvas { display: block; width: 100%; cursor: grab; touch-action: none; }
#zoomCanvas:active { cursor: grabbing; }
.zoom-hint { margin: 8px 0 0; color: var(--text3); font-size: 12px; }

/* ---------- 지도 공통 ---------- */
.map { position: relative; width: 100%; height: 100%; min-height: 320px; border-radius: 14px; overflow: hidden; background: #0b1a33; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* 대기 화면: 지도 + 설명 */
#viewRun { max-width: 1400px; height: calc(100vh - var(--chrome-h) - 40px); grid-template-rows: auto minmax(0, 1fr); }
#viewRun .screen-head { grid-template-columns: auto 1fr; align-items: center; }
#viewRun .screen-head h1 { grid-column: 1 / -1; font-size: 24px; }
.run-map { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 14px; min-height: 0; }
.run-map-main { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.run-map-main .polbar { box-shadow: none; }
.run-map-main .polbar button { box-shadow: none; border: 1px solid var(--line); }
.run-map .map { min-height: 0; flex: 1; }
.run-idw-opts { display: grid; gap: 6px; }
.run-idw-rule { margin: 0; color: var(--text2); font-size: 12px; line-height: 1.5; }
.run-idw-rule b { color: var(--text); }
.run-map-list.idw li span { min-width: 7.5em; text-align: right; }
.run-map-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; font-size: 13px; }
.run-map-side > * { flex-shrink: 0; }
.run-map-side .run-card { padding: 4px 0 14px; gap: 8px; border-bottom: 1px solid var(--line); }
.run-map-side .big-pct { font-size: 44px; }
.run-map-side .run-card .note { font-size: 12px; }
.run-map-side h2 { margin: 0; font-size: 16px; font-weight: 800; }
.run-map-now { margin: 0; color: var(--text2); min-height: 2.6em; }
.run-map-now .link { border: 0; background: none; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.run-map-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.run-map-list li { display: flex; justify-content: space-between; gap: 8px; }
.run-map-list span { color: var(--text3); font-variant-numeric: tabular-nums; }
.run-map-how { margin: 4px 0 0; display: grid; gap: 4px; }
.run-map-how dt { font-weight: 800; color: var(--text); }
.run-map-how dd { margin: 0 0 6px; color: var(--text2); line-height: 1.5; }
.rm-dot { width: 11px; height: 11px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 2px rgb(0 0 0 / .35); cursor: pointer; }
.rm-dot.on { background: #ffd25a; width: 14px; height: 14px; }
.run-map-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.run-map-pick button { padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--text2); font: inherit; font-size: 12px; cursor: pointer; }
.run-map-pick button:hover { border-color: var(--blue); color: var(--text); }
.run-map-pick button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 700; }
.rm-target b { display: block; padding: 4px 9px; border-radius: 8px; background: #ffd25a; color: #1b1b1b; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 8px rgb(0 0 0 / .4); }
.rm-nb { padding: 2px 7px 2px 2px; border-radius: 999px; background: rgb(0 0 0 / .62); color: #fff; font-size: 11px; white-space: nowrap; }
.rm-nb i { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 4px; border-radius: 50%; background: #ffd25a; color: #1b1b1b; font-style: normal; font-weight: 800; font-size: 10px; }

/* 복원 결과 지도 화면 */
#viewMap.app-map { height: calc(100vh - var(--chrome-h) - 24px); display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; }
.map-card { position: relative; padding: 10px; min-height: 0; }
.map-card .map { height: 100%; }
.map-hint { flex: 1; min-width: 0; margin: 0; color: var(--text3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-legend { position: absolute; left: 22px; bottom: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 12px; border-radius: 12px; background: rgb(255 255 255 / .92); color: #333; font-size: 12px; box-shadow: 0 2px 10px rgb(0 0 0 / .25); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .3); }
.lg.full, .rs-mark.full i { background: #3478f6; }
.lg.part, .rs-mark.part i { background: #ff8a3d; }
.lg.zero, .rs-mark.zero i { background: #f04452; }
.lg.none, .rs-mark.none i { background: #9aa3ad; }
.rs-mark { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0; border: 0; background: none; cursor: pointer; }
.rs-mark i { display: block; width: var(--sz); height: var(--sz); border: 2px solid #fff; border-radius: 50%; opacity: .92; box-shadow: 0 0 0 2px rgb(0 0 0 / .3), 0 4px 12px rgb(0 0 0 / .35); transition: transform .12s; }
.rs-mark span { padding: 2px 7px; border-radius: 8px; background: rgb(0 0 0 / .62); color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.rs-mark span small { margin-left: 4px; font-weight: 500; opacity: .85; }
.rs-mark:hover i, .rs-mark.sel i { transform: scale(1.18); box-shadow: 0 0 0 3px #ffd25a, 0 4px 14px rgb(0 0 0 / .4); }
@media (max-width: 1000px), (max-height: 560px) { #viewRun { height: auto; } .run-map { grid-template-columns: 1fr; } .run-map .map { height: 380px; flex: none; } }
.rs-mark:hover span { visibility: visible !important; position: relative; z-index: 2; }
.rs-mark:hover { z-index: 5; }
