* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  background: #1a3a5c;
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

header h1 { font-size: 16px; font-weight: 600; }

#status-bar {
  font-size: 12px;
  color: #a0bcd0;
  margin-left: auto;
}

.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── 控制面板 ───────────────────────────────── */

#panel {
  width: 300px;
  min-width: 260px;
  background: #f5f7fa;
  border-right: 1px solid #d0d8e4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-section {
  padding: 12px 14px;
  border-bottom: 1px solid #d0d8e4;
}

.panel-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: #1a3a5c;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.btn {
  display: inline-block;
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary { background: #2e75b6; color: #fff; }
.btn-primary:hover { background: #245d92; }
.btn-primary:disabled { background: #a0b8d0; cursor: default; }

.btn-secondary { background: #e0e8f0; color: #1a3a5c; }
.btn-secondary:hover { background: #c8d8e8; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 即時模式 */
#realtime-info {
  margin-top: 8px;
  font-size: 12px;
  color: #4a6a8a;
  min-height: 18px;
}

/* 假設情境 */
#scenario-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.sensor-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sensor-row select {
  flex: 1;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid #c0ccd8;
  border-radius: 3px;
  background: #fff;
}

.sensor-row input[type=range] {
  width: 70px;
}

.sensor-row .depth-val {
  width: 36px;
  font-size: 12px;
  text-align: right;
  color: #2e75b6;
  font-weight: 600;
}

.sensor-row button.remove-row {
  background: none;
  border: none;
  cursor: pointer;
  color: #a05050;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

#scenario-controls {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* 淹水面積摘要 */
#summary-section {
  padding: 10px 14px;
  border-bottom: 1px solid #d0d8e4;
  font-size: 12px;
}

#summary-section .summary-item {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

#summary-section .summary-item span:last-child {
  font-weight: 600;
  color: #2e75b6;
}

/* 圖例 */
#legend {
  padding: 10px 14px;
}

#legend h2 {
  font-size: 13px;
  font-weight: 600;
  color: #1a3a5c;
  margin-bottom: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.legend-swatch {
  width: 18px;
  height: 12px;
  border: 1px solid #999;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── 地圖 ───────────────────────────────────── */

#map {
  flex: 1;
  position: relative;
}

/* 載入 spinner */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-size: 14px;
  color: #1a3a5c;
  gap: 10px;
}

#loading-overlay.hidden { display: none; }

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #d0d8e4;
  border-top-color: #2e75b6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#error-msg {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 1001;
  display: none;
}
