:root {
  --bg: #0b1622;
  --panel: #132436;
  --panel2: #1b3049;
  --border: #2a4560;
  --text: #e8eef5;
  --text-dim: #9db0c4;
  --accent: #f0a528;
  --vfr: #2ecc71;
  --mvfr: #3498db;
  --ifr: #e74c3c;
  --lifr: #c04ee0;
  --danger-bg: #3a1f1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

button, input {
  font-family: inherit;
  font-size: 16px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-overlay.hidden { display: none; }

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.login-icon { width: 56px; height: 56px; border-radius: 12px; margin-bottom: 10px; }
.login-box h2 { margin: 0 0 6px 0; font-size: 1.1rem; }
.login-sub { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 16px 0; }

.login-box input {
  width: 100%;
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
  margin-bottom: 12px;
}

.login-box button { width: 100%; }

.login-error {
  color: #ff9b9b;
  font-size: 0.82rem;
  margin-top: 10px;
}

.login-toggle {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.login-toggle a {
  color: var(--accent);
  margin-left: 4px;
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 6px;
  min-height: auto;
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-icon { width: 28px; height: 28px; border-radius: 6px; }

.updated-info {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.disclaimer {
  background: var(--danger-bg);
  color: #ffcfcf;
  padding: 8px 16px;
  font-size: 0.8rem;
  line-height: 1.4;
  border-bottom: 1px solid #5a2b2b;
}

.disclaimer a { color: #ffb3b3; }

.app-grid {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 90px);
}

@media (min-width: 900px) and (orientation: landscape) {
  .app-grid {
    flex-direction: row;
    height: calc(100vh - 78px);
  }
  .controls {
    width: 420px;
    min-width: 380px;
    height: 100%;
    overflow-y: auto;
  }
  .map-section {
    flex: 1;
    height: 100%;
  }
}

.controls {
  padding: 12px;
  overflow-y: auto;
}

.field-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.field { flex: 1; min-width: 130px; position: relative; }

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  min-height: 44px;
}

.actions { justify-content: flex-start; }

button {
  min-height: 46px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #241505;
}

.btn-primary:disabled { opacity: 0.5; }

.btn-secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:disabled { opacity: 0.4; }

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 500;
  display: none;
}

.autocomplete-list.open { display: block; }

.autocomplete-item {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:active, .autocomplete-item.active { background: var(--panel); }

.autocomplete-item .code { font-weight: 700; }
.autocomplete-item .name { display: block; font-size: 0.78rem; color: var(--text-dim); }

.taf-advisories-box {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #3a1620;
  border: 1.5px solid var(--ifr);
}

.taf-advisories-box h3 {
  margin: 0 0 8px 0;
  font-size: 0.88rem;
  color: #ff8f8f;
}

.taf-advisory-item {
  background: rgba(0, 0, 0, 0.2);
  border-left: 4px solid var(--ifr);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.taf-advisory-item:last-child { margin-bottom: 0; }
.taf-advisory-item.lifr { border-left-color: var(--lifr); }

.taf-advisory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.taf-advisory-badges { display: flex; gap: 4px; }

.taf-advisory-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.taf-advisory-badge.ifr { background: var(--ifr); color: #2e0505; }
.taf-advisory-badge.lifr { background: var(--lifr); color: #260238; }
.taf-advisory-badge.ts { background: var(--accent); color: #241505; }

.taf-advisory-detail {
  color: #f0c8c8;
  margin-top: 4px;
  line-height: 1.4;
}

.forecast-context-box {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}

.forecast-context-box.medium {
  background: #2a2712;
  border-color: #6b5420;
  color: #f5d98a;
}

.forecast-context-box.beyond {
  background: #2a1c12;
  border-color: #6b3f20;
  color: #f5c08a;
}

.warnings-box {
  background: #3a2f14;
  border: 1px solid #6b5420;
  color: #f5d98a;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.hidden { display: none !important; }

.narrative-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.narrative-box h3 { margin: 0 0 8px 0; font-size: 0.95rem; color: var(--accent); }
.narrative-text { line-height: 1.55; font-size: 0.92rem; }
.narrative-loading { color: var(--text-dim); font-style: italic; }

.narrative-chart-wrap {
  margin-bottom: 10px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
}

.narrative-chart-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.narrative-chart-caption {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.checkbox-row input { width: 18px; height: 18px; }

.field select {
  width: 100%;
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  min-height: 44px;
}

.watches-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.watches-panel h3 { margin: 0 0 8px 0; font-size: 0.9rem; color: var(--accent); }

.watch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.watch-item:last-child { border-bottom: none; }

.watch-item button {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 0.75rem;
  background: var(--danger-bg);
  color: #ffcfcf;
  border: 1px solid #5a2b2b;
}

.stations-panel, .hazards-panel { margin-bottom: 14px; }

.station-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.station-card.vfr { border-left-color: var(--vfr); }
.station-card.mvfr { border-left-color: var(--mvfr); }
.station-card.ifr { border-left-color: var(--ifr); }
.station-card.lifr { border-left-color: var(--lifr); }

.station-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.station-id { font-weight: 700; font-size: 1.02rem; }
.station-cat { font-size: 0.75rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.station-cat.vfr { background: var(--vfr); color: #06210f; }
.station-cat.mvfr { background: var(--mvfr); color: #04202f; }
.station-cat.ifr { background: var(--ifr); color: #2e0505; }
.station-cat.lifr { background: var(--lifr); color: #260238; }

.station-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

.station-body { display: none; margin-top: 8px; font-size: 0.82rem; }
.station-body.open { display: block; }

.raw-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  background: #0e1b28;
  padding: 8px;
  border-radius: 6px;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.taf-group {
  border-left: 3px solid var(--border);
  padding: 4px 8px;
  margin: 4px 0;
  font-size: 0.78rem;
}

.taf-group.active { border-left-color: var(--accent); background: #1e2c1c; }

.hazard-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.hazard-title { font-weight: 700; }

.map-section {
  position: relative;
  flex: 1;
  min-height: 320px;
}

#map { width: 100%; height: 100%; }

.prog-chart-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background: rgba(19, 36, 54, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: rgba(19, 36, 54, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
}

.map-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.map-toggle input { width: 16px; height: 16px; cursor: pointer; }

.front-label {
  background: rgba(11, 22, 34, 0.88);
  border: 1.5px solid;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.isobar-label {
  background: rgba(11, 22, 34, 0.8);
  border: 1px solid #2dd4da;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #2dd4da;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  background: rgba(19, 36, 54, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.72rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 90vw;
}

.legend-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.vfr { background: var(--vfr); }
.dot.mvfr { background: var(--mvfr); }
.dot.ifr { background: var(--ifr); }
.dot.lifr { background: var(--lifr); }

.line { width: 16px; height: 3px; display: inline-block; }
.line.cold { background: #3498db; }
.line.warm { background: #e74c3c; }
.line.stationary { background: repeating-linear-gradient(90deg, #e74c3c 0 4px, #3498db 4px 8px); }
.line.occluded { background: #9b59b6; }
.line.isobar { background: #2dd4da; height: 2px; }

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2c1c;
  border: 1px solid #3c5a2f;
  color: #d8f5c8;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.85rem;
  z-index: 2000;
}

@media (max-width: 480px) {
  .field { min-width: 100%; }
}
