:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-border: #263040;
  --accent: #38bdf8;
  --text: #e5e7eb;
  --text-dim: #94a3b8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Noto Sans KR", system-ui, sans-serif; }

#loginScreen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
#loginBox {
  width: 320px; padding: 28px; background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px;
}
#loginBox h1 { font-size: 18px; margin: 0 0 16px; }
#loginBox input {
  width: 100%; padding: 10px; margin-bottom: 10px; border-radius: 6px; border: 1px solid var(--panel-border);
  background: #0b1220; color: var(--text);
}
#loginBox button, .btn {
  width: 100%; padding: 10px; border-radius: 6px; border: none; background: var(--accent);
  color: #06202e; font-weight: 700; cursor: pointer;
}
.btn.secondary { background: #1f2937; color: var(--text); border: 1px solid var(--panel-border); }
.btn.small { width: auto; padding: 6px 10px; font-size: 13px; }
#loginError { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

#app { display: none; height: 100%; flex-direction: column; }
#topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; gap: 10px;
  background: var(--panel); border-bottom: 1px solid var(--panel-border);
}
#topbar .who { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .who b { color: var(--text); }

/* ---------------------------------------------------------------------
   모바일 우선 탭 구조: #main은 탭들이 겹쳐지는 자리이고, 한 번에 하나의
   .tabview만 .active로 보인다(display:none/flex 토글, innerHTML 교체 아님 —
   지도 탭 안의 #cesiumContainer는 Cesium Viewer가 떠나지 않는 DOM이라야 함).
--------------------------------------------------------------------- */
#main { flex: 1; min-height: 0; position: relative; }
.tabview {
  position: absolute; inset: 0; display: none; flex-direction: column; min-height: 0;
}
.tabview.active { display: flex; }

#tabview-map { }
#mapToolbar { padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--panel-border); }
#cesiumContainer { flex: 1; min-height: 0; }

#searchWrap, #destSearchWrap { position: relative; display: flex; gap: 6px; }
#searchWrap input, #destSearchWrap input { margin-bottom: 0; flex: 1; }
#searchWrap .btn.small, #destSearchWrap .btn.small { white-space: nowrap; }
#searchResults, #destSearchResults {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: #0b1220; border: 1px solid var(--panel-border); border-radius: 8px;
  max-height: 280px; overflow-y: auto; z-index: 50; display: none;
}
#searchResults .item, #destSearchResults .item { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #1e293b; }
#searchResults .item:last-child, #destSearchResults .item:last-child { border-bottom: none; }
#searchResults .item:hover, #destSearchResults .item:hover { background: #142033; }
#searchResults .item .meta, #destSearchResults .item .meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
#destSearchWrap { margin-bottom: 8px; }

.tabpanel-inner {
  flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); padding: 14px;
}
.tabpanel-inner h2 { font-size: 14px; color: var(--accent); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.tabpanel-inner h2:first-child { margin-top: 0; }

/* 하단 탭바 — 모바일에서 한 손으로 쓰기 쉬운 위치 */
#tabbar {
  display: flex; background: var(--panel); border-top: 1px solid var(--panel-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#tabbar button {
  flex: 1; padding: 10px 2px 8px; background: none; border: none; color: var(--text-dim);
  font-size: 12px; font-family: inherit; cursor: pointer; border-top: 2px solid transparent;
}
#tabbar button.active { color: var(--accent); font-weight: 700; border-top-color: var(--accent); }

/* 관할경계 필터(체크박스) 탭 / 메시지 발송 탭의 대상 다중선택 체크박스 — 같은 스타일 재사용 */
#jurisdictionLegend { font-size: 12px; }
.jl-toggle-all { margin-bottom: 8px; display: flex; gap: 6px; }
.jl-toggle-all button {
  background: #1f2937; border: 1px solid var(--panel-border); color: var(--text);
  font-size: 11px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.jl-item { display: flex; align-items: center; gap: 6px; padding: 5px 0; cursor: pointer; }
.jl-item input { margin: 0; }
.jl-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #1e293b; font-size: 13px; }
.row:last-child { border-bottom: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.moving { background: var(--accent); }
.dot.arrived { background: var(--green); }
.dot.delayed { background: var(--red); }
.dot.unread { background: var(--yellow); }

.card { background: #0b1220; border: 1px solid var(--panel-border); border-radius: 8px; padding: 10px; margin-bottom: 10px; font-size: 13px; }
.card .meta { color: var(--text-dim); font-size: 11px; margin-top: 4px; }
textarea, select, input[type=text], input[type=number] {
  width: 100%; padding: 8px; margin-bottom: 8px; border-radius: 6px; border: 1px solid var(--panel-border);
  background: #0b1220; color: var(--text); font-family: inherit; font-size: 13px;
}
label.small { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 2px; }
.hint { font-size: 12px; color: var(--text-dim); margin: 4px 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: #0b1220; border: 1px solid var(--accent); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 999; max-width: 90vw; text-align: center;
}

/* 발송 탭: 선택된 목적지 칩 */
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #0b1220; border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 4px 10px; font-size: 12px; margin-bottom: 8px;
}
.chip button {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; padding: 0; width: auto;
}
