:root {
  --bg: #0f172a;
  --card: #1e293b;
  --field: #0f172a;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --error: #f87171;
  --ok: #34d399;
  --rwy: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.field {
  margin-bottom: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-weight: 600;
  font-size: 0.92rem;
}

.hint {
  color: var(--muted);
  font-weight: 400;
}

input, select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--error);
}

input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus {
  outline-color: var(--error);
}

code {
  background: rgba(148, 163, 184, 0.18);
  padding: 0 0.25rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.zone-row {
  display: flex;
  gap: 0.5rem;
}

.iata {
  flex: 1 1 40%;
  min-width: 6.5rem;
  font-weight: 600;
}

.iata::placeholder {
  font-weight: 400;
  letter-spacing: normal;
}

.zone-row select { flex: 1 1 60%; }

.airport-label {
  color: var(--accent);
}

.airport-label.unknown {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

button {
  flex: 1;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent-strong);
  color: #04293a;
}

button:hover { background: var(--accent); }

button.secondary {
  flex: 0 0 auto;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover { background: rgba(148, 163, 184, 0.12); }

.error {
  margin: 1rem 0 0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--error);
  font-size: 0.92rem;
}

.result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.eta-label {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.eta-label strong {
  color: var(--text);
}

.arrival {
  margin: 0;
  font-size: 1.35rem;
  color: var(--ok);
  line-height: 1.3;
}

.dayoffset {
  margin: 0.3rem 0 0;
  color: var(--accent);
  font-weight: 600;
}

.arrival-alt {
  margin: 0.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
}

.alt-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.alt-key {
  display: inline-block;
  min-width: 2.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.alt-val {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.countdown {
  margin: 1.1rem 0 0;
  padding: 0.9rem 1rem;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  text-align: center;
}

.countdown.done {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.4);
}

.countdown-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.countdown-time {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.countdown.done .countdown-time { color: var(--ok); }

.progress {
  margin-top: 0.7rem;
  height: 7px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s linear;
}

.countdown.done .progress-bar { background: var(--ok); }

.details {
  margin: 1.1rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.92rem;
}

.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; }

.foot {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ---- App shell / header ---------------------------------------------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.app-header h1 {
  margin: 0;
  outline: none;
}

.back-btn {
  flex: 0 0 auto;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.back-btn:hover { background: rgba(148, 163, 184, 0.12); }

/* ---- Menu ------------------------------------------------------------- */
.menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.menu-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: left;
  padding: 1rem 1.1rem;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.menu-item:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--accent);
}

.menu-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.menu-desc {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
}

/* ---- Base Training Legs ---------------------------------------------- */
.bt-legs {
  width: 100%;
  margin: 0.25rem 0 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.bt-legs th,
.bt-legs td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.bt-legs th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bt-legs td.bt-hdg {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ok);
  white-space: nowrap;
}

.bt-legs tbody tr:last-child td { border-bottom: none; }
.bt-legs tbody tr:first-child td,
.bt-legs tbody tr:last-child td { color: var(--text); }

.bt-check {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.bt-check input[type="checkbox"] {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.bt-figure {
  margin: 1.1rem 0 0;
}

.bt-diagram {
  width: 100%;
  height: auto;
  max-width: 100%;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.bt-leg-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.bt-arrowhead { fill: var(--accent); }

.bt-leg-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bt-runway-line {
  stroke: var(--muted);
  stroke-width: 11;
  stroke-linecap: butt;
}

.bt-rwy-num {
  fill: var(--rwy);
  font-size: 11px;
  font-weight: 700;
}

.bt-north { stroke: var(--error); stroke-width: 2; }
.bt-arrowhead-n { fill: var(--error); }
.bt-north-label { fill: var(--error); font-size: 12px; font-weight: 700; }

.bt-caption {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.bt-note {
  margin: 1rem 0 0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--muted);
  font-size: 0.85rem;
}

.bt-note strong { color: var(--text); }
