/* ---- 토큰: dataviz 레퍼런스 팔레트. 기본 라이트, 다크는 우측 상단 토글(data-theme)로만 ---- */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --seq-100:#cde2fb; --seq-200:#9ec5f4; --seq-300:#6da7ec; --seq-400:#3987e5; --seq-500:#256abf; --seq-600:#184f95; --seq-700:#0d366b;
  --deemph: #c3c2b7;

  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --delta-good: #006300; --delta-bad: #b42f2f;
}
:root[data-theme="dark"] { color-scheme: dark;
  --page:#0d0d0d; --surface:#1a1a19; --ink:#fff; --ink-2:#c3c2b7; --ink-muted:#898781;
  --grid:#2c2c2a; --axis:#383835; --border:rgba(255,255,255,.10); --wash:rgba(255,255,255,.05);
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500; --s5:#d55181; --s6:#008300;
  --deemph:#52514e; --delta-good:#0ca30c; --delta-bad:#e66767; }

/* ---- 레이아웃 ------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  word-break: keep-all; overflow-wrap: break-word;   /* 한글은 어절 단위로 줄바꿈("차/트에" 방지) */
}
main { max-width: 1240px; margin: 0 auto; padding: 0 20px 40px; }
a { color: inherit; }
.muted { color: var(--ink-muted); }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }

.top { max-width: 1240px; margin: 0 auto; padding: 22px 20px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); }
.status .dot.ok { background: var(--good); }
.status .dot.bad { background: var(--critical); }

.section { margin-top: 20px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } .kpis { grid-template-columns: 1fr 1fr !important; } }
@media (max-width: 700px) {
  main, .top, .foot { padding-left: 12px; padding-right: 12px; }
  .top { flex-direction: column; gap: 8px; padding-top: 14px; }
  .status { white-space: normal; }
  .kpis { gap: 10px; }
  .tile { padding: 12px 12px 10px; }
  .tile .value { font-size: 24px; }
  .tile.hero .value { font-size: 34px; }
  .tile .spark { display: none; }
  .card { padding: 12px 12px 10px; }
  figcaption { flex-wrap: wrap; }
  th.m-hide, td.m-hide { display: none; }
  .filters { gap: 8px 12px; }
  .chart.map { height: 380px; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  margin: 0 0 16px; padding: 14px 16px 12px;
  transition: opacity .2s;
}
.card.loading { opacity: .5; }
figcaption { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; margin-bottom: 8px; }
figcaption .muted { font-weight: 400; }
.chart { width: 100%; }
.chart.map { height: 480px; }
.map-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; font-size: 13px; }
.map-controls input[type=range] { flex: 1; min-width: 140px; accent-color: var(--s1); }
.table-view { margin-top: 10px; }

.empty { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 16px; color: var(--ink-2); }
.empty p { margin: 4px 0 0; }

/* ---- 버튼 / 필터 ---------------------------------------------------------- */
button { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { background: var(--wash); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); padding: 3px 8px; }
button.ghost:hover { background: var(--wash); }
button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 20px; margin-top: 8px; padding: 12px 0; border-top: 1px solid var(--grid); border-bottom: 1px solid var(--grid); }
.group { display: flex; align-items: center; gap: 4px; }
.glabel { color: var(--ink-muted); font-size: 12px; margin-right: 4px; }
.group > button { border-radius: 999px; padding: 4px 11px; }
.picker { display: block; position: relative; }
.picker summary { cursor: pointer; list-style: none; padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; }
.picker summary::-webkit-details-marker { display: none; }
.picker[open] summary { background: var(--wash); }
.picker-body { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; width: min(560px, 90vw); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
@media (max-width: 700px) {
  .filters { position: relative; }
  .picker { position: static; }
  .picker-body { left: 0; right: 0; width: auto; }   /* 필터 행 전체 폭으로 — picker 위치와 무관. 기본 규칙 뒤에 둬야 이긴다 */
  .group > button, .picker summary { min-height: 36px; }
  #theme-toggle { min-width: 40px; min-height: 40px; }
}
.picker-actions { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; }
.chips label:hover { background: var(--wash); }
.chips label.on { border-color: var(--ink); }
.chips label.off { opacity: .45; cursor: not-allowed; }
.chips input { display: none; }
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--deemph); flex: none; }

/* ---- KPI 타일 ------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 10px; position: relative; overflow: hidden; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 600; margin-top: 2px; line-height: 1.1; overflow-wrap: anywhere; }
.tile.hero .value { font-size: 48px; }
.tile .delta { font-size: 13px; margin-top: 4px; color: var(--ink-2); min-height: 1.4em; overflow-wrap: anywhere; }
.tile .delta.up-bad, .tile .delta.down-bad { color: var(--delta-bad); }
.tile .delta.up-good, .tile .delta.down-good { color: var(--delta-good); }
.tile .spark { position: absolute; right: 12px; bottom: 10px; width: 120px; height: 32px; }
.spark polyline { fill: none; stroke: var(--deemph); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }

/* ---- 테이블 ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink-muted); font-weight: 500; font-size: 12px; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[data-sort].asc::after { content: " ↑"; }
th[data-sort].desc::after { content: " ↓"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
table.live tbody tr { cursor: pointer; }
table.live tbody tr:hover td { background: var(--wash); }
table.live tbody tr.selected td:first-child { font-weight: 600; }
table.live td .swatch { display: inline-block; vertical-align: middle; margin-right: 6px; }
table.live td .swatch.off { visibility: hidden; }
@media (max-width: 700px) {
  table.live td .swatch.off { display: none; }   /* 선택 안 한 지역의 빈 자리 — 좁은 화면에선 이름을 왼쪽에 붙인다 */
  table.live th, table.live td { padding: 6px 6px; }
}
.chip { --c: var(--ink-muted); display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.chip.good { --c: var(--good); } .chip.warning { --c: var(--warning); } .chip.serious { --c: var(--serious); } .chip.critical { --c: var(--critical); }
.spark.row { width: 140px; height: 26px; display: block; }
.table-view table { font-size: 12px; }
.table-view th, .table-view td { padding: 3px 8px; }
.table-view td.num { text-align: right; }
.d-up { color: var(--delta-bad); } .d-down { color: var(--delta-good); }
.foot { max-width: 1240px; margin: 0 auto; padding: 0 20px 30px; font-size: 12px; }
.foot p { margin: 0 0 6px; }
.foot .products span { white-space: nowrap; }   /* 구분점은 앞 항목 끝에 붙여 한 덩어리로 — 둘째 줄이 "·"로 시작하지 않는다 */
.foot .products a { display: inline-block; padding: 8px 0; }
.foot .products b { font-weight: inherit; }   /* 지금 제품(공통 부품이 <b aria-current>로 그린다) — 글자 굵기는 그대로 */
.foot a { color: var(--ink-2); text-decoration-color: var(--axis); }
.foot a:hover { color: var(--ink); }

/* 의견 보내기(2026-10-25) */
.foot button.fb-open { padding: 8px 0; font-size: inherit; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--axis); }
dialog.fb { border: 1px solid var(--border); border-radius: 10px; padding: 18px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog.fb::backdrop { background: rgb(0 0 0 / 0.35); }
dialog.fb h2 { margin: 0 0 4px; font-size: 16px; }
dialog.fb p { margin: 0 0 10px; font-size: 13px; }
dialog.fb label { display: block; margin: 0 0 10px; font-size: 13px; }
dialog.fb textarea, dialog.fb input, dialog.fb select { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
.fb-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fb-actions button { min-height: 40px; padding: 8px 16px; }

/* conchiz 제품군 표시(2026-10-25 브랜드 통일) */
h1 .brand-mark { vertical-align: -5px; margin-right: 8px; border-radius: 7px; }
