/* ForestGuard 대시보드 — 관제 중심 배치
   상단 바 → 상황 요약 → [지도 | 노드 상세 | 노드 현황·경보] → (시뮬레이션일 때) 하단 시연 제어 바
   1920×1080 은 한 화면 고정, 노트북(가로 1500 미만·세로 760 미만)은 2열 + 스크롤, 920 미만은 1열 */
:root {
  color-scheme: light;
  --font: "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --page: #e9edea;
  --surface: #ffffff;
  --surface-2: #f5f7f6;
  --ink: #16211b;
  --ink-2: #47554d;
  --muted: #6f7b75;
  --line: #dde3df;
  --line-2: #c6cfca;
  --brand: #10301f;
  --brand-ink: #e7f2ec;
  --fire: #eb6834;   /* 산불 지수 계열색 (범주 2번) */
  --land: #2a78d6;   /* 산사태 지수 계열색 (범주 1번) */
  --lost: #8b928e;
  --crit-bg: #fff1f0;
  --crit-line: #f1b1ac;
  --crit-ink: #9b1414;
  --g0: #2b8a3e; --g1: #f2c200; --g2: #f76707; --g3: #e03131;
  --g0-ink: #fff; --g1-ink: #2b2100; --g2-ink: #241000; --g3-ink: #fff;
  --focus: #1c64c4;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-width: 320px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ 상단 바 */
.topbar {
  flex: none; min-height: 56px;
  display: flex; align-items: center; gap: 16px;
  padding: 6px 16px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand svg { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 19px; color: #fff; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: #9fc3b1; }
.clock { display: flex; align-items: baseline; gap: 8px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.14); flex: none; }
.clock-label { font-size: 12px; color: #9fc3b1; }
.clock-time { font-size: 18px; font-variant-numeric: tabular-nums; color: #fff; letter-spacing: .3px; }
.speed-chip { font-size: 12px; font-weight: 700; background: #f2c200; color: #2b2100; padding: 2px 8px; border-radius: 999px; }
.top-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-mode.sim { background: #fff4c2; color: #4a3800; }
.badge-mode.real { background: #d9f2e1; color: #10472a; }
.badge-conn { background: #ffe1df; color: #8a1212; }
.badge-ro { background: #e9ecef; color: #343a40; }
/* 읽기 전용(관리자 토큰 미입력): 경보 확인 버튼 숨김 — 시연 바는 스크립트에서 숨김 */
body.locked .alert-item .ack, body.locked #ackAll { display: none !important; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.top-btn {
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.06); color: #fff;
  padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.top-btn small { font-weight: 500; color: #f2d36b; }
.top-btn:hover { background: rgba(255,255,255,.14); }
.top-btn[aria-pressed="true"] { background: #f2c200; border-color: #f2c200; color: #2b2100; }
.disclaimer { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; padding: 4px 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; flex: none; }
.disclaimer b { font-size: 13px; color: #fff; }
.disclaimer span { font-size: 11px; color: #b4cfc1; }

/* ------------------------------------------------------------------ 상황 요약 */
.statusbar {
  flex: none;
  display: grid; gap: 10px; padding: 12px 12px 0;
  grid-template-columns: 1.45fr 1fr 1.15fr 1.15fr .95fr 1.1fr;
}
.kpi {
  --c: var(--line-2);
  position: relative; overflow: hidden; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px 8px 16px; min-height: 74px;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.kpi .k-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .k-main { display: flex; align-items: center; gap: 8px; margin-top: 3px; min-width: 0; }
.kpi .k-value { font-size: 24px; font-weight: 800; line-height: 1.15; white-space: nowrap; }
.kpi .k-value small { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.kpi .k-sub { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi .k-sub b { color: var(--ink); }
.kpi .gb.xl { font-size: 17px; padding: 3px 14px; }
.kpi.kpi-top { background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
.kpi.alarm { background: var(--crit-bg); border-color: var(--crit-line); }
.kpi.alarm .k-value { color: var(--crit-ink); }
.kpi.warn { background: #fff8e1; border-color: #f0d68a; }
.dist { display: flex; gap: 2px; height: 9px; margin-top: 6px; }
.dist i { flex: 1; border-radius: 3px; background: var(--c); }

/* ------------------------------------------------------------------ 레이아웃 */
.layout {
  flex: 1; min-height: 0;
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1.75fr) minmax(400px, 1fr) minmax(400px, .9fr);
  grid-template-rows: minmax(0, 1.8fr) minmax(0, 1fr);
  grid-template-areas:
    "map   detail side"
    "trend detail side";
}
/* 오른쪽 열: 노드 현황판은 내용 높이만큼, 경보는 남은 높이 전부 */
.side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.side .board-panel { flex: none; max-height: 60%; }
.side .alert-panel { flex: 1; min-height: 160px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 32, 24, .04);
}
.panel-head {
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap;
  padding: 8px 14px; border-bottom: 1px solid var(--line); min-height: 46px;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; }
.map-panel { grid-area: map; }
.detail-panel { grid-area: detail; }
.trend-panel { grid-area: trend; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; list-style: none; }

/* ------------------------------------------------------------------ 공용 컨트롤 */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.seg button:hover { background: #e9eeeb; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { padding: 3px 8px; font-size: 12px; }
.btn { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.select { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 5px 8px; font-size: 13px; max-width: 100%; }
.select.small { padding: 3px 6px; font-size: 12.5px; margin-left: auto; }

/* 등급 배지: 색 + 글자 함께 */
.gb { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-weight: 700; font-size: 12.5px; white-space: nowrap; line-height: 1.5; font-variant-numeric: tabular-nums; }
.gb.g0 { background: var(--g0); color: var(--g0-ink); }
.gb.g1 { background: var(--g1); color: var(--g1-ink); }
.gb.g2 { background: var(--g2); color: var(--g2-ink); }
.gb.g3 { background: var(--g3); color: var(--g3-ink); }
.gb.gn { background: #e4e8e6; color: #3d4742; }
.gb.lg { font-size: 14px; padding: 3px 12px; }

/* ------------------------------------------------------------------ 지도 */
.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #e3e6e4; }
#map3d { position: absolute; inset: 0; background: #dfe8ef; }
.map3d-tools { display: inline-flex; gap: 2px; }
.map3d-tools .btn[aria-pressed="true"] { background: #e8f1fc; color: var(--ink); font-weight: 700; }
/* 3D 핀: 점 아래 막대 끝이 지형 위 노드 위치 */
.mk3d { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.mk3d .stick { display: block; width: 2px; height: 18px; background: linear-gradient(#1f2a24, rgba(31, 42, 36, .25)); }
#map3d .maplibregl-ctrl-attrib { font-size: 11px; }
/* 배경 지도는 무채색으로 낮춰 등급 색이 돋보이게 */
#map .leaflet-tile-pane { filter: grayscale(.9) brightness(1.06) contrast(.86); }
#fitBtn { margin-left: auto; }
/* 범례: 지도를 가리지 않도록 지도 아래 한 줄 */
.map-legend {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px;
  padding: 6px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2);
}
.map-legend .lg-title { color: var(--ink); font-size: 12px; }
.map-legend .lg-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.map-legend .lg-item small { color: var(--muted); font-variant-numeric: tabular-nums; }
.map-legend .lg-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.map-legend .lg-dot.sq { border-radius: 3px; }
.map-legend .lg-ev { display: grid; place-items: center; color: #fff; font-size: 8px; font-weight: 800; font-style: normal; }
.map-legend .lg-sep { width: 1px; height: 14px; background: var(--line-2); }
.map-legend .lg-zone { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--zc); background: color-mix(in srgb, var(--zc) 25%, transparent); flex: none; }
/* 감지 구역 (2D, Leaflet SVG 원): 화재 감지·지반 변형 노드 주변을 깜빡이며 강조 */
.zone { stroke-width: 2; animation: fg-zone 1.6s ease-in-out infinite; }
.zone-fire { fill: #e03131; stroke: #e03131; }
.zone-slide { fill: #a0461c; stroke: #a0461c; }
@keyframes fg-zone { 0%, 100% { fill-opacity: .10; stroke-opacity: .45; } 50% { fill-opacity: .30; stroke-opacity: .95; } }
@media (prefers-reduced-motion: reduce) { .zone { animation: none; fill-opacity: .2; } }
.crit-text { color: var(--crit-ink); }
.map-note { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 500; background: #fff8db; border: 1px solid #ecd98c; color: #5a4700; padding: 5px 12px; border-radius: 8px; font-size: 12.5px; }

/* 노드 마커: 등급이 높을수록 크고 진하게, 낮음은 조용하게 */
.mk-wrap { background: none; border: 0; }
.mk { --s: 24px; position: relative; width: var(--s); height: var(--s); cursor: pointer; }
.mk-dot {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; line-height: 1;
}
.mk.real .mk-dot { border-radius: 6px; }
.mk-label {
  position: absolute; left: calc(var(--s) + 5px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: rgba(255,255,255,.96); color: var(--ink);
  border: 1px solid var(--line-2); border-left: 4px solid var(--c); border-radius: 6px;
  padding: 2px 8px 2px 6px; font-size: 12.5px; box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.mk-label b { margin-right: 5px; }
.mk-label .hz { margin-right: 4px; color: var(--ink-2); }
.mk-label .gtxt { font-weight: 700; }
.mk-label .mk-score { color: var(--ink-2); font-variant-numeric: tabular-nums; margin-left: 4px; }
.mk.lv0 .mk-label { background: rgba(255,255,255,.88); color: #46514b; font-size: 12px; box-shadow: none; }
.mk.lv0 .mk-label .gtxt { font-weight: 600; }
.mk.lv2 .mk-label, .mk.lv3 .mk-label, .mk.event .mk-label {
  background: color-mix(in srgb, var(--c) 14%, #fff); border-color: var(--c); font-size: 13.5px; font-weight: 600;
}
.mk.event .mk-label .gtxt, .mk.lv3 .mk-label .gtxt { color: #8f1313; }
.mk.selected .mk-dot { box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(0,0,0,.45); }
.mk.selected .mk-label { border-color: var(--ink); border-left-color: var(--c); }
/* 겹치거나 지도 밖으로 나가는 라벨은 왼쪽에 배치 */
.mk.left .mk-label { left: auto; right: calc(var(--s) + 5px); border-left-width: 1px; border-right: 4px solid var(--c); padding: 2px 6px 2px 8px; }
.mk.left.selected .mk-label { border-left-color: var(--ink); border-right-color: var(--c); }
.mk.up .mk-label { transform: translateY(-135%); }
.mk.down .mk-label { transform: translateY(35%); }
.mk.up2 .mk-label { transform: translateY(-225%); }
.mk.down2 .mk-label { transform: translateY(125%); }
.mk.blink::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 3px solid var(--c); animation: fg-pulse 1.3s ease-out infinite; pointer-events: none;
}
.mk.blink-strong .mk-dot { animation: fg-blink .9s ease-in-out infinite; }
.mk.lost .mk-label, .mk.nodata .mk-label { color: #4f5753; }
@keyframes fg-pulse { from { transform: scale(.55); opacity: .95; } to { transform: scale(1.5); opacity: 0; } }
@keyframes fg-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .mk.blink::before { animation: none; transform: scale(1.05); opacity: .9; }
  .mk.blink-strong .mk-dot { animation: none; }
}

/* ------------------------------------------------------------------ 노드 현황판 */
.board-body { padding: 2px 10px 8px; }
.board { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: 13px; }
.board th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 2px 8px 0; }
.board td { padding: 4px 8px; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: middle; }
.board td:first-child { border-left: 5px solid var(--c); border-radius: 8px 0 0 8px; }
.board td:last-child { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: #edf1ef; }
.board tbody tr.selected td { background: #e8f1fc; border-top-color: #b4cdf0; border-bottom-color: #b4cdf0; }
.board tbody tr.selected td:last-child { border-right-color: #b4cdf0; }
.board tbody tr.hot td { background: var(--crit-bg); }
.board .nid { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.board .nid b { font-size: 13.5px; }
.board .nid small { color: var(--muted); font-size: 11.5px; }
.board .real-mark { font-style: normal; font-size: 10px; color: #10472a; margin-left: 2px; }
.board .idx { white-space: nowrap; }
.trend { font-size: 11px; font-weight: 700; margin-left: 4px; font-variant-numeric: tabular-nums; }
.trend.up { color: #b4231b; }
.trend.down { color: #2b6a3a; }
.st-chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; margin: 1px 2px 1px 0; white-space: nowrap; border: 1px solid; }
.st-chip.crit { color: var(--crit-ink); background: var(--crit-bg); border-color: var(--crit-line); }
.st-chip.lost { color: #3e4541; background: #eceeed; border-color: #cfd4d1; }
.st-chip.warn { color: #7a4b00; background: #fff5d6; border-color: #f0d68a; }
.st-chip.info { color: #134a85; background: #e6f0fd; border-color: #b4cdf0; }
.st-chip.ok { color: var(--muted); background: transparent; border-color: transparent; font-weight: 500; }

/* ------------------------------------------------------------------ 노드 상세 */
.node-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.node-title { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 17px; }
.node-title b { font-size: 18px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface-2); }
.tag.real { border-color: #9cc3ad; color: #10472a; background: #e5f4ea; }
.node-sub { font-size: 12.5px; color: var(--muted); }
.node-status { display: flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.node-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--g0); }
.node-status.lost .dot, .node-status.nodata .dot { background: var(--lost); }
.node-status.lost { color: #5b2a00; }

.index-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.index-card { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface-2); position: relative; overflow: hidden; }
.index-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--line-2)); }
.index-card .ic-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.index-card .ic-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.index-card .ic-value { font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.index-card .ic-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; letter-spacing: 0; }

.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.flag { --fc: #555; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 7px; border: 1px solid; color: var(--fc); }
.flag::before { content: "!"; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; font-size: 10.5px; font-weight: 800; color: #fff; background: var(--fc); flex: none; }
.flag.warn { --fc: #7a4b00; background: #fff5d6; border-color: #f0d68a; }
.flag.info { --fc: #134a85; background: #e6f0fd; border-color: #b4cdf0; }
.flag.crit { --fc: #9b1414; background: #ffe8e6; border-color: #f1b1ac; }
.flag.lost { --fc: #3e4541; background: #eceeed; border-color: #cfd4d1; }
.flag small { font-weight: 500; opacity: .85; }

.contrib { margin-bottom: 12px; }
.contrib-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; }
.contrib-head h3 { font-size: 13.5px; margin: 0; display: flex; align-items: center; gap: 6px; }
.contrib-head .eq { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.renorm { font-size: 12px; color: #7a4b00; background: #fff5d6; border: 1px solid #f0d68a; border-radius: 7px; padding: 4px 8px; margin-bottom: 6px; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bars li { display: grid; grid-template-columns: 92px minmax(0, 1fr) 82px; grid-template-rows: auto auto; column-gap: 8px; align-items: center; }
.bars .b-label { font-size: 12.5px; font-weight: 600; }
.bars .b-track { height: 10px; background: #eef1ef; border-radius: 4px; position: relative; overflow: hidden; }
.bars .b-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--c); min-width: 2px; }
.bars .b-val { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .b-val b { font-size: 13px; }
.bars .b-val small { color: var(--muted); }
.bars .b-detail { grid-column: 2 / 4; font-size: 11.5px; color: var(--muted); line-height: 1.35; margin-top: 1px; }
.bars li.excluded .b-label, .bars li.excluded .b-val { color: var(--muted); text-decoration: line-through; }
.bars li.excluded .b-track { background: repeating-linear-gradient(135deg, #eef1ef 0 4px, #f8f9f8 4px 8px); }

.idgrid { margin: 8px 0 2px; }
.idgrid .idg-title { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.idgrid .idg-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.idgrid .idg-cell { border: 1px solid var(--line); border-radius: 7px; padding: 3px 4px; text-align: center; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.idgrid .idg-cell b { display: block; font-size: 11.5px; color: var(--ink-2); }
.idgrid .idg-cell span { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.idgrid .idg-cell em { display: block; font-style: normal; font-weight: 800; font-size: 13px; }
.idgrid .idg-cell.gov { border-color: var(--land); background: #eaf2fc; }

.sensors h3 { font-size: 13.5px; margin: 0 0 6px; }
.sensor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin: 0; }
.sensor-grid > div { border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; }
.sensor-grid dt { font-size: 11.5px; color: var(--muted); }
.sensor-grid dd { margin: 0; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sensor-grid dd small { font-size: 11px; font-weight: 500; color: var(--muted); display: block; }
.sensor-grid > div.hot { border-color: var(--crit-line); background: #fff3f2; }

/* ------------------------------------------------------------------ 추이 */
.trend-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 8px 14px 10px; }
.chart-block { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chart-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-bottom: 4px; min-height: 28px; }
.chart-title .key { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.sw-fire { background: var(--fire); }
.sw-land { background: var(--land); }
.chart-wrap { position: relative; flex: 1; min-height: 120px; }
.chart-wrap canvas { position: absolute; inset: 0; }
.table-view { flex: 1; min-height: 0; overflow: auto; padding: 0 14px 12px; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view thead th { position: sticky; top: 0; background: var(--surface); font-weight: 700; color: var(--ink-2); }

/* ------------------------------------------------------------------ 경보 */
.count { background: var(--g3); color: #fff; font-size: 12px; border-radius: 999px; padding: 1px 8px; min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.count.zero { background: #dfe4e1; color: var(--ink-2); }
.crit-count { font-size: 12px; font-weight: 700; color: var(--crit-ink); background: var(--crit-bg); border: 1px solid var(--crit-line); border-radius: 999px; padding: 1px 8px; }
#ackAll { margin-left: auto; }
.alert-list { list-style: none; margin: 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  border: 1px solid var(--line); border-left: 5px solid var(--c, var(--lost)); border-radius: 9px;
  padding: 6px 10px; cursor: pointer; background: var(--surface);
}
.alert-item:hover { background: var(--surface-2); }
.alert-item.critical { background: var(--crit-bg); border-color: var(--crit-line); border-left-color: var(--c); }
.alert-item.critical .al-title b { color: var(--crit-ink); }
.alert-item .al-tag { font-size: 11px; font-weight: 800; color: #fff; background: var(--crit-ink); border-radius: 4px; padding: 0 5px; margin-right: 5px; vertical-align: 1px; }
.alert-item.fresh { animation: fg-fresh 2.4s ease-out; }
@keyframes fg-fresh { from { box-shadow: 0 0 0 3px #f2c200; } to { box-shadow: 0 0 0 0 transparent; } }
.alert-item.acked { opacity: .62; border-left-color: #c9d0cc; }
.alert-item .al-main { min-width: 0; }
.alert-item .al-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-item .al-title b { margin-right: 4px; }
.alert-item .al-msg { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-item .al-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.alert-item time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.alert-item .ack { padding: 2px 10px; font-size: 12px; }
.alert-item .acked-label { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------------ 시연 제어 바 */
.controlbar {
  flex: none;
  background: #1b2822; color: #e4efe8;
  border-top: 3px solid #f2c200;
  padding: 7px 14px 8px;
}
/* 한 컨테이너에서 자동 줄바꿈: 넓은 화면은 조작 1줄 + 진행 중 1줄 */
.cb-wrap { display: flex; align-items: center; gap: 7px 16px; flex-wrap: wrap; }
.cb-title { font-weight: 800; font-size: 13px; color: #2b2100; background: #f2c200; padding: 2px 10px; border-radius: 6px; }
.cb-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #b9cdc2; }
.select.dark { background: #26352d; border-color: #46594e; color: #f0f6f2; }
.seg.dark { background: #26352d; border-color: #46594e; }
.seg.dark button { color: #cfe0d6; }
.seg.dark button:hover { background: #33443a; }
.seg.dark button[aria-pressed="true"] { background: #f2c200; color: #2b2100; }
.cb-scenarios { display: flex; gap: 5px; flex-wrap: wrap; }
.sc {
  position: relative; overflow: hidden;
  border: 1px solid #4a5e52; background: #2b3a32; color: #f0f6f2;
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.sc:hover { background: #36483e; }
.sc.active { background: #f2c200; color: #2b2100; border-color: #f2c200; }
.sc.active::after {  /* 진행률 */
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p, 1) * 100%); background: #8a5a00;
}
.sc:disabled { opacity: .55; cursor: wait; }
/* [산불 발생]·[산사태 발생]: 단계별 시나리오와 구분되는 강조 버튼 */
.cb-events { display: inline-flex; align-items: center; gap: 5px; padding-right: 14px; border-right: 1px solid #3f5247; }
.sc.ev { font-weight: 800; color: #fff; padding: 5px 12px; }
.sc.ev-fire { background: #b42318; border-color: #f0623f; }
.sc.ev-fire:hover { background: #d0321f; }
.sc.ev-slide { background: #7a4a22; border-color: #b07a45; }
.sc.ev-slide:hover { background: #91592a; }
.sc.ev.active { background: #f2c200; border-color: #f2c200; color: #2b2100; }
.cb-rain { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #b9cdc2; white-space: nowrap; }
.cb-rain input { width: 54px; background: #26352d; border: 1px solid #46594e; color: #f0f6f2; border-radius: 6px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.cb-btn { border: 1px solid #4a5e52; background: #2b3a32; color: #f0f6f2; border-radius: 7px; padding: 4px 10px; cursor: pointer; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.cb-btn:hover { background: #36483e; }
.cb-btn.ghost { background: transparent; }
.cb-btn.danger { border-color: #8f3a36; color: #ffb4ae; }
.cb-btn.danger:hover { background: #3d2522; }
.cb-reset { display: inline-flex; gap: 6px; margin-left: auto; }
.cb-active { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex: 1 1 360px; min-width: 0; }
.cb-label { color: #9fb7aa; font-weight: 700; white-space: nowrap; }
.active-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.active-chips .muted { color: #8ba497; }
.chip {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px;
  background: #33443a; border: 1px solid #4f6458; border-radius: 8px; padding: 2px 4px 2px 9px; white-space: nowrap;
}
.chip b { color: #ffd84a; }
.chip .chip-detail { color: #c7d9cf; }
.chip .bar { position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--p, 0) * 100%); background: #f2c200; }
.chip button { border: 0; background: #4a5e52; color: #fff; border-radius: 5px; padding: 1px 7px; cursor: pointer; font-size: 12px; }
.chip button:hover { background: #8f3a36; }
.cb-hint { color: #8ba497; font-size: 11.5px; margin-left: auto; }

/* ------------------------------------------------------------------ 사면 안전율 대화상자 */
.slope-dialog { width: min(600px, 94vw); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); color: var(--ink); }
.slope-dialog::backdrop { background: rgba(10, 22, 16, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 16px; }
.dlg-body { padding: 12px 16px 14px; }
.assume-banner { background: #fff1d6; border: 1px solid #ecc879; color: #5f4200; font-weight: 700; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; }
.formula { font-family: "Cambria Math", "Times New Roman", serif; font-size: 14.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; text-align: center; }
.slope-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-bottom: 8px; font-size: 13px; }
.slope-inputs label { display: flex; align-items: center; gap: 5px; }
.slope-inputs input { width: 58px; border: 1px solid var(--line-2); border-radius: 7px; padding: 2px 6px; text-align: right; }
.slider-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.slider-row input { width: 100%; accent-color: var(--land); }
.slider-row output { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 150px; text-align: right; }
.fs-result { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.fs-label { font-size: 12.5px; color: var(--ink-2); margin-right: 8px; }
.fs-num { font-size: 30px; font-weight: 800; }
.fs-state { font-weight: 800; padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.fs-state.stable { background: #e1f3e6; color: #135c28; border: 1px solid #a9d9b6; }
.fs-state.unstable { background: var(--g3); color: #fff; }
.fs-chart { min-height: 170px; height: 190px; flex: none; margin-bottom: 6px; }
.slope p { margin: 4px 0 0; }

/* ------------------------------------------------------------------ 토스트 (상단: 새 경보가 눈에 띄게) */
.toast {
  position: fixed; left: 50%; top: 66px; transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
  background: #16211b; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 2000;
  transition: opacity .2s, transform .2s; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: min(92vw, 720px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.alert { background: #8f1515; }
.toast.error { background: #6b1d1d; }

/* ------------------------------------------------------------------ 반응형 */
/* 노트북(가로 1500px 미만 또는 세로 760px 미만): 2열 + 페이지 스크롤, 시연 바는 화면 아래에 고정 */
@media (max-width: 1499px), (max-height: 759px) {
  body { height: auto; display: block; overflow: visible; }
  .statusbar { gap: 8px; }
  .kpi { min-height: 64px; padding: 6px 10px 6px 14px; }
  .kpi .k-label { font-size: 12px; }
  .kpi .k-value { font-size: 20px; }
  .kpi .gb.xl { font-size: 15px; padding: 2px 11px; }
  .kpi .gb.lg { font-size: 13px; padding: 2px 9px; }
  .kpi .k-main { flex-wrap: wrap; row-gap: 0; }
  .cb-hint { display: none; }
  .layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(380px, 1fr);
    grid-template-rows: 560px 360px auto;
    grid-template-areas:
      "map   detail"
      "trend detail"
      "side  side";
  }
  .side { flex-direction: row; align-items: flex-start; }
  .side .board-panel, .side .alert-panel { flex: 1 1 0; max-height: 520px; }
  .controlbar { position: sticky; bottom: 0; z-index: 1000; }
}
@media (max-width: 1180px) {
  .statusbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; padding: 8px 14px; gap: 8px 14px; }
  .top-actions { margin-left: 0; }
  .disclaimer { align-items: flex-start; }
  .cb-reset, .cb-hint { margin-left: 0; }
}
/* 좁은 화면(태블릿·휴대폰): 1열 */
@media (max-width: 920px) {
  .statusbar { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px 16px 0; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "map" "side" "detail" "trend";
    padding: 10px 16px;
  }
  .side { flex-direction: column; align-items: stretch; }
  .map-panel { height: 460px; }
  .trend-body { grid-template-columns: minmax(0, 1fr); }
  .chart-wrap { min-height: 200px; }
  .clock { border-left: 0; padding-left: 0; }
  .controlbar { position: static; }
}
@media (max-width: 520px) {
  .statusbar { grid-template-columns: minmax(0, 1fr); }
  .index-cards { grid-template-columns: 1fr; }
  .bars li { grid-template-columns: 76px minmax(0, 1fr) 74px; }
  .legend { font-size: 11px; min-width: 0; }
}
