* { box-sizing: border-box; margin: 0; }
html, body, #app { height: 100%; }
body {
  font-family: 'Apple SD Gothic Neo', 'Pretendard', -apple-system, sans-serif;
  font-size: 14px; color: #1a1d21; background: #f6f7f9;
}
#app { display: flex; }

/* ── 사이드바 ── */
#sidebar {
  width: 280px; flex: none; background: #fff; border-right: 1px solid #e4e7ec;
  display: flex; flex-direction: column; overflow-y: auto; z-index: 10;
}
#sidebar header { padding: 18px 16px 12px; border-bottom: 1px solid #eef0f3; }
#sidebar h1 { font-size: 17px; font-weight: 700; }
#sidebar nav { margin-top: 6px; }
#sidebar nav a { color: #3b82f6; text-decoration: none; font-size: 13px; }
#sidebar nav a:hover { text-decoration: underline; }
#layer-groups { flex: 1; padding: 8px 0; }
.group-title { padding: 12px 16px 4px; font-size: 11px; font-weight: 700; color: #8a919c; letter-spacing: .06em; }
.layer-item { display: flex; align-items: center; gap: 8px; padding: 7px 16px; cursor: pointer; user-select: none; }
.layer-item:hover { background: #f4f6f8; }
.layer-item input { accent-color: #3b82f6; width: 15px; height: 15px; cursor: pointer; }
.layer-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.layer-name { flex: 1; }
.layer-count { font-size: 12px; color: #8a919c; font-variant-numeric: tabular-nums; }
.layer-item.loading .layer-count::after { content: '…'; }
#status { padding: 10px 16px; font-size: 12px; color: #8a919c; border-top: 1px solid #eef0f3; min-height: 38px; }

/* ── 지도 ── */
#map { flex: 1; min-width: 0; }
#map-error {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #f6f7f9; z-index: 100; padding: 24px; text-align: center;
  font-size: 15px; line-height: 1.7; color: #444; white-space: pre-line;
}
#map-error[hidden] { display: none; }

/* ── 지도 오버레이(팝업·배지) ── */
.iw { padding: 10px 12px; font-size: 13px; line-height: 1.55; max-width: 320px; word-break: keep-all; }
.iw b { font-size: 13.5px; }
.iw .sub { color: #667085; font-size: 12px; }
.iw a { color: #3b82f6; }
.iw-section { margin-top: 8px; padding-top: 7px; border-top: 1px solid #eef0f3; }
.iw-title { font-weight: 700; font-size: 12px; color: #475467; margin-bottom: 3px; }
.iw-table { border-collapse: collapse; margin-top: 5px; font-size: 11.5px; width: 100%; }
.iw-table th { text-align: left; color: #8a919c; font-weight: 600; padding: 1px 8px 1px 0; }
.iw-table td { padding: 1px 8px 1px 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cluster-badge {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px; opacity: .88;
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 1px 5px rgba(0,0,0,.3); cursor: pointer;
}
.air-badge {
  border-radius: 50%; width: 46px; height: 46px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; font-weight: 700;
  font-size: 13px; box-shadow: 0 1px 6px rgba(0,0,0,.3); cursor: pointer; line-height: 1.1;
}
.air-badge small { font-size: 9px; font-weight: 500; opacity: .9; }

/* ── 히스토리 페이지 ── */
.history-page { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.history-page h1 { font-size: 20px; margin-bottom: 4px; }
.history-page .back { font-size: 13px; }
.history-page .back a { color: #3b82f6; text-decoration: none; }
#controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #fff; border: 1px solid #e4e7ec; border-radius: 10px; padding: 14px; margin: 16px 0;
}
#controls select, #controls input[type=text] {
  padding: 7px 10px; border: 1px solid #d4d9e0; border-radius: 8px; font-size: 13.5px; background: #fff;
}
#entity-select { min-width: 260px; max-width: 380px; }
.period-btns { display: flex; gap: 4px; margin-left: auto; }
.period-btns button {
  padding: 7px 12px; border: 1px solid #d4d9e0; background: #fff; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
.period-btns button.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
#chart-wrap { background: #fff; border: 1px solid #e4e7ec; border-radius: 10px; padding: 16px; height: 380px; }
#chart-note { font-size: 12.5px; color: #8a919c; margin: 8px 2px 20px; }
#history-table-wrap { background: #fff; border: 1px solid #e4e7ec; border-radius: 10px; overflow: auto; max-height: 480px; }
#history-table-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
#history-table-wrap th, #history-table-wrap td { padding: 8px 12px; border-bottom: 1px solid #eef0f3; text-align: left; white-space: nowrap; }
#history-table-wrap th { position: sticky; top: 0; background: #f9fafb; font-weight: 600; color: #667085; }
#history-table-wrap td { font-variant-numeric: tabular-nums; }

/* ── 상태 페이지 ── */
.status-h2 { font-size: 15px; margin: 24px 0 8px; }
#status-meta { font-size: 12.5px; color: #8a919c; margin-top: 6px; }
.status-card { background: #fff; border: 1px solid #e4e7ec; border-radius: 10px; overflow: auto; margin-top: 12px; }
.status-card table { border-collapse: collapse; width: 100%; font-size: 13px; }
.status-card th, .status-card td { padding: 8px 12px; border-bottom: 1px solid #eef0f3; text-align: left; white-space: nowrap; }
.status-card th { background: #f9fafb; font-weight: 600; color: #667085; }
.status-card td { font-variant-numeric: tabular-nums; }
.status-card td.sub { white-space: normal; color: #8a919c; font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.err { background: #fee2e2; color: #b91c1c; }
