:root {
  --bg: #0f1419;
  --bg-panel: #1a2332;
  --bg-card: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b9eff;
  --accent-hover: #5cb0ff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 8px;
  --toolbar-h: 52px;
  --sidebar-w: 340px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden { display: none !important; }

/* Landing */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 1.5rem;
  position: relative;
  background: radial-gradient(ellipse at 50% 0%, #1a3050 0%, var(--bg) 70%);
}

.landing-brand {
  position: absolute;
  top: 2.5rem;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.landing-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.landing-tagline {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.landing-card {
  text-align: center;
  padding: 3rem 2.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}

.logo {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.landing-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: .5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.btn-import {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn-import:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.hint {
  margin-top: 1.25rem;
  font-size: .78rem;
  color: var(--text-muted);
}

/* Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--toolbar-h);
  padding: 0 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.toolbar-left { justify-self: start; }
.toolbar-right { justify-self: end; }

.toolbar-center { justify-self: center; text-align: center; }

.toolbar-title {
  font-weight: 600;
  font-size: .95rem;
}

.filename {
  font-size: .85rem;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-grid {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel h2 {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .85rem;
}

.panel-flights {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.field label {
  display: block;
  font-size: .85rem;
  margin-bottom: .4rem;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group input {
  flex: 1;
  padding: .55rem .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text);
  font-size: .95rem;
  min-width: 0;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .82rem;
  color: var(--text-muted);
}

.field-hint {
  margin-top: .4rem;
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: .4rem;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-card);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-accent {
  background: var(--success);
  color: #0f1419;
}

.btn-accent:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-block {
  width: 100%;
  margin-top: .85rem;
  padding: .65rem;
}

.btn-sm {
  padding: .35rem .65rem;
  font-size: .78rem;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .85rem;
}

.stat-row dt { color: var(--text-muted); }
.stat-row dd { font-weight: 600; }

.flight-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.empty-state {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.flight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  border-left: 3px solid var(--accent);
}

.flight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .35rem;
}

.flight-card-title {
  font-weight: 600;
  font-size: .88rem;
}

.flight-card-meta {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.flight-card-actions {
  margin-top: .55rem;
}

.map-panel {
  flex: 1;
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #0a0e14;
}

.map-legend {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(26, 35, 50, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .85rem;
  font-size: .78rem;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .25rem;
}

.legend-item:last-child { margin-bottom: 0; }

.legend-color {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.error-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-size: .85rem;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 768px) {
  .main-grid { flex-direction: column; }

  .sidebar {
    width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .map-panel { min-height: 280px; }
}
