:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-alt: #162032;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --low: #10b981;
  --mod: #f59e0b;
  --high: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 2rem 1rem;
}

/* === ANISVELLE 3D BUTTERFLY INTRO === */
.intro-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 45%, #162544 0%, #090d16 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.intro-splash.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sky-grid {
  position: absolute;
  width: 200%;
  height: 200%;
  bottom: -60%;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(500px) rotateX(68deg);
  animation: gridDrift 4s linear infinite;
}

@keyframes gridDrift {
  from { background-position: 0 0; }
  to { background-position: 0 48px; }
}

.butterfly-stage {
  perspective: 900px;
  width: 160px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: butterflyGlide 2.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.butterfly {
  position: relative;
  width: 120px;
  height: 100px;
  transform-style: preserve-3d;
  transform: rotateX(22deg) rotateZ(-8deg);
  animation: hoverBob 1.6s ease-in-out infinite alternate;
}

.body-core {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 6px;
  height: 62px;
  margin-left: -3px;
  background: linear-gradient(180deg, #e0f2fe, #38bdf8);
  border-radius: 99px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
  z-index: 2;
}

.wing {
  position: absolute;
  top: 8px;
  width: 56px;
  height: 84px;
  transform-style: preserve-3d;
}

.wing-left {
  right: 50%;
  transform-origin: right center;
  animation: flapLeft 0.38s ease-in-out infinite alternate;
}

.wing-right {
  left: 50%;
  transform-origin: left center;
  animation: flapRight 0.38s ease-in-out infinite alternate;
}

.wing-upper {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 55%, #c084fc 100%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.45);
}

.wing-lower {
  width: 78%;
  height: 34px;
  margin-top: -4px;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.wing-left .wing-upper {
  border-radius: 44px 8px 6px 26px;
}
.wing-left .wing-lower {
  margin-left: auto;
  border-radius: 22px 4px 12px 32px;
}

.wing-right .wing-upper {
  border-radius: 8px 44px 26px 6px;
}
.wing-right .wing-lower {
  margin-right: auto;
  border-radius: 4px 22px 32px 12px;
}

@keyframes flapLeft {
  from { transform: rotateY(18deg); }
  to { transform: rotateY(72deg); }
}

@keyframes flapRight {
  from { transform: rotateY(-18deg); }
  to { transform: rotateY(-72deg); }
}

@keyframes hoverBob {
  from { transform: rotateX(22deg) rotateZ(-6deg) translateY(0px); }
  to { transform: rotateX(28deg) rotateZ(6deg) translateY(-12px); }
}

@keyframes butterflyGlide {
  0% {
    opacity: 0;
    transform: translate(-180px, 70px) scale(0.45);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

.intro-brand {
  text-align: center;
  margin-top: 1.2rem;
  z-index: 2;
  animation: fadeUpBrand 1s ease 0.4s both;
}

.brand-tag {
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  font-weight: 800;
  color: #a5b4fc;
  margin-bottom: 0.35rem;
}

.brand-title {
  font-size: 2rem;
  font-weight: 800;
  color: #f8fafc;
}

.brand-title span {
  color: #38bdf8;
}

.brand-sub {
  font-size: 0.88rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.loader-bar {
  width: 210px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  margin: 1.1rem auto 0;
  overflow: hidden;
}

.loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #c084fc);
  animation: loadFill 2.8s ease-in-out forwards;
}

@keyframes loadFill {
  to { width: 100%; }
}

@keyframes fadeUpBrand {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.skip-intro {
  position: absolute;
  bottom: 2rem;
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  border: 1px solid #334155;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  z-index: 2;
}

.skip-intro:hover {
  border-color: #38bdf8;
  color: #fff;
}

/* === MAIN DASHBOARD === */
.container {
  max-width: 1020px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

.badge {
  display: inline-block;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

header h1 {
  font-size: 2.3rem;
  font-weight: 800;
}

header h1 span {
  color: var(--accent);
}

header p {
  color: var(--muted);
  margin-top: 0.4rem;
}

.controls-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr auto;
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

@media (max-width: 820px) {
  .controls-card {
    grid-template-columns: 1fr;
  }
  .swap-btn {
    width: 100%;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

select, input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  font-size: 0.92rem;
  width: 100%;
}

optgroup {
  background: var(--card);
  color: var(--accent);
  font-weight: 700;
}

option {
  background: var(--bg);
  color: var(--text);
}

.swap-btn {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.62rem 0.85rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.swap-btn:hover {
  border-color: var(--accent);
}

.primary-btn {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.3rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.primary-btn:hover {
  opacity: 0.9;
}

.hidden {
  display: none;
}

.route-meta-bar {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.meta-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-item strong {
  font-size: 1.05rem;
  color: var(--text);
}

.flight-lookup {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.flight-lookup input {
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.flight-lookup button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.verdict-banner {
  background: var(--card);
  border-left: 6px solid var(--low);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.verdict-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.verdict-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.copy-btn {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--accent);
}

.risk-pill {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--low);
}

.score-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.optimizer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.optimizer-header h3 {
  font-size: 1.1rem;
  color: var(--accent);
}

.optimizer-header p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.slot-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.slot-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.slot-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--low);
  text-transform: uppercase;
}

.slot-time {
  font-size: 1rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.slot-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.airport-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.telemetry-card, .chart-card, .radar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.telemetry-card {
  margin-bottom: 0;
}

.telemetry-card h3, .chart-card h3, .radar-card h3 {
  font-size: 1.1rem;
  color: var(--accent);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.chart-tabs {
  display: flex;
  gap: 0.4rem;
}

.tab-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}

.metric {
  background: var(--bg);
  padding: 0.7rem;
  border-radius: 8px;
}

.metric span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.metric strong {
  font-size: 1.05rem;
}

.flag-list {
  margin-top: 1rem;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  color: #cbd5e1;
}

.flag-list li {
  margin-bottom: 0.3rem;
}

.radar-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.3rem 0 1rem;
}

.radar-frame-wrap {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  height: 360px;
}

.radar-frame-wrap iframe {
  width: 100%;
  height: 100%;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

footer strong {
  color: var(--accent);
}