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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
}

/* ── Layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Topbar ── */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  z-index: 1000;
  flex-shrink: 0;
}

#topbar h1 {
  font-size: 18px;
  font-weight: 700;
  color: #e94560;
  white-space: nowrap;
}

#search-input {
  flex: 1;
  max-width: 300px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #0f3460;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input::placeholder {
  color: #8899aa;
}

#search-input:focus {
  border-color: #e94560;
}

#flight-count-container {
  font-size: 13px;
  color: #8899aa;
  white-space: nowrap;
}

#flight-count {
  font-weight: 700;
  color: #e0e0e0;
}

#weather-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

#btn-weather {
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid #0f3460;
  background: #2a2a3e;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#btn-weather:hover {
  border-color: #4a90d9;
  color: #e0e0e0;
}

#btn-weather.active {
  background: #0f3460;
  border-color: #4a90d9;
  color: #4a90d9;
}

#weather-type {
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #0f3460;
  background: #2a2a3e;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

#weather-type:focus {
  border-color: #4a90d9;
}

/* ── Map ── */
#map {
  flex: 1;
  z-index: 1;
}

/* ── Details panel ── */
.details-panel {
  position: absolute;
  right: 16px;
  top: 70px;
  width: 280px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  overflow: hidden;
}

.details-panel.hidden {
  display: none;
}

.details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0f3460;
}

.details-callsign {
  font-size: 16px;
  font-weight: 700;
  color: #e94560;
  letter-spacing: 1px;
}

.details-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.2s;
}

.details-close:hover {
  color: #e94560;
}

.dp-aircraft {
  border-bottom: 1px solid #0f3460;
}

.dp-aircraft a#dp-photo-link {
  display: block;
  width: 100%;
  overflow: hidden;
  max-height: 160px;
}

.dp-aircraft img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}

.dp-photo-credit {
  font-size: 11px;
  color: #667;
  padding: 4px 10px;
  background: #0d1a2e;
}

.dp-photo-credit a {
  color: #4a90d9;
  text-decoration: none;
}

.dp-aircraft-info {
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dp-model {
  font-size: 13px;
  font-weight: 700;
  color: #e0e0e0;
}

.dp-reg {
  font-size: 12px;
  color: #8899aa;
  letter-spacing: 1px;
}

.dp-loading {
  padding: 10px 14px;
  font-size: 12px;
  color: #667;
  font-style: italic;
}

.details-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid #0f3460;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #8899aa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  color: #e0e0e0;
  font-weight: 500;
}

/* ── Status bar ── */
#statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  background: #16213e;
  border-top: 1px solid #0f3460;
  font-size: 12px;
  z-index: 1000;
  flex-shrink: 0;
}

#statusbar .status-label {
  color: #8899aa;
}

#status-text {
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 3px;
}

.status-live {
  color: #2ecc71;
  background: rgba(46,204,113,0.15);
}

.status-cached {
  color: #f39c12;
  background: rgba(243,156,18,0.15);
}

.status-stale {
  color: #e67e22;
  background: rgba(230,126,34,0.15);
}

.status-error {
  color: #e74c3c;
  background: rgba(231,76,60,0.15);
}

#status-time {
  color: #8899aa;
  margin-left: auto;
}

/* ── OWM modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-box {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  width: 380px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #0f3460;
  font-weight: 600;
  font-size: 14px;
}

.modal-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
}
.modal-close:hover { color: #e94560; }

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body p {
  font-size: 13px;
  color: #aaa;
  line-height: 1.5;
}

.modal-body a {
  color: #4a90d9;
  text-decoration: none;
}

.modal-body a:hover { text-decoration: underline; }

#owm-key-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #0f3460;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

#owm-key-input:focus { border-color: #4a90d9; }

#owm-key-save {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  background: #4a90d9;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#owm-key-save:hover { background: #357abd; }

/* ── Leaflet overrides ── */
.leaflet-container {
  background: #1a1a2e;
}
