:root {
  color-scheme: dark;
  --bg: #0a0d11;
  --surface: #11161f;
  --muted: #7b8798;
  --text: #e8ecf2;
  --accent: #5bc0de;
  --accent-2: #9b6bff;
  --border: #1f2530;
  --card: rgba(17, 22, 31, 0.8);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(91, 192, 222, 0.18), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(155, 107, 255, 0.14), transparent 30%),
    radial-gradient(circle at 70% 70%, rgba(91, 192, 222, 0.12), transparent 25%);
  opacity: 0.7;
  z-index: 0;
}

.background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("./DA40.png") center center / cover no-repeat;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
  filter: blur(0.5px);
}

.app {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 20px 72px;
  z-index: 1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(10, 13, 17, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
  border-radius: 50%;
}

.topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 6px;
}

h1 {
  margin: 0;
  font-size: 32px;
}

.lead {
  margin: 10px 0 0;
  max-width: 680px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: var(--shadow);
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #0a0d11;
}

button.ghost {
  background: rgba(255, 255, 255, 0.03);
}

.actions.align-right {
  justify-content: flex-end;
}

.card-grid {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.card.wide {
  grid-column: 1 / -1;
}

.card-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.card-header p {
  margin: 0 0 12px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.form-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.form-grid.compact {
  margin-top: 8px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 192, 222, 0.2);
}

textarea {
  min-height: 44px;
  resize: both;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  max-width: 100%;
}

textarea.large {
  min-height: 120px;
}

.fuel-phases {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.fuel-phase {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.fuel-phase.total {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(91, 192, 222, 0.12);
  border-color: var(--accent);
  padding: 10px 16px;
}

.fuel-total-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  min-width: 60px;
}

.fuel-result {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.fuel-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.fuel-value {
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
  min-width: 40px;
  text-align: right;
}

.fuel-phase.total .fuel-result {
  flex-direction: row;
  align-items: center;
}

.legs-table-wrapper {
  overflow-x: visible;
  margin: 16px 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  width: 100%;
  min-width: 100%;
}

.legs-table {
  width: 100% !important;
  min-width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed !important;
}

/* Segments (colonnes 1-5) : 65% de l'espace - beaucoup plus d'espace */
.legs-table th:nth-child(1),
.legs-table td:nth-child(1) { width: 13% !important; min-width: 13% !important; } /* Alti QNH */
.legs-table th:nth-child(2),
.legs-table td:nth-child(2) { width: 11% !important; min-width: 11% !important; } /* TSV */
.legs-table th:nth-child(3),
.legs-table td:nth-child(3) { width: 13% !important; min-width: 13% !important; } /* Dist NM */
.legs-table th:nth-child(4),
.legs-table td:nth-child(4) { width: 14% !important; min-width: 14% !important; } /* RM avec vent */
.legs-table th:nth-child(5),
.legs-table td:nth-child(5) { width: 14% !important; min-width: 14% !important; } /* RM sans vent */
/* Spacer (colonne 6) */
.legs-table th:nth-child(6),
.legs-table td:nth-child(6) { width: 3% !important; min-width: 3% !important; }
/* Points de report (colonnes 7-9) : 27% de l'espace */
.legs-table th:nth-child(7),
.legs-table td:nth-child(7) { width: 9% !important; min-width: 9% !important; } /* Report */
.legs-table th:nth-child(8),
.legs-table td:nth-child(8) { width: 9% !important; min-width: 9% !important; } /* Heure ESTI */
.legs-table th:nth-child(9),
.legs-table td:nth-child(9) { width: 9% !important; min-width: 9% !important; } /* Heure REEL */
/* Notes (colonne 10) : 5% seulement */
.legs-table th:nth-child(10),
.legs-table td:nth-child(10) { width: 5% !important; min-width: 5% !important; }

.legs-table thead {
  background: rgba(91, 192, 222, 0.15);
}

.legs-table th {
  padding: 14px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

.legs-table .sub-header th {
  padding: 12px 8px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.seg-header {
  text-align: center;
  background: rgba(91, 192, 222, 0.2);
}

.point-header {
  text-align: center;
  background: rgba(155, 107, 255, 0.2);
}

.spacer-header {
  width: 50px;
  background: transparent;
  position: relative;
}

.spacer-header::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
  transform: translateX(-50%);
}

.legs-table tbody tr {
  border-bottom: 10px solid transparent;
  background: rgba(255, 255, 255, 0.02);
}

.legs-table tbody tr:last-child {
  border-bottom: none;
}

.legs-table td {
  padding: 14px 10px;
  vertical-align: middle;
  line-height: 1.5;
}

.leg-seg-cell {
  background: rgba(91, 192, 222, 0.08);
  border-right: 2px solid rgba(91, 192, 222, 0.3);
}

.leg-spacer-cell {
  width: 50px;
  position: relative;
  padding: 0;
  background: linear-gradient(to right, rgba(91, 192, 222, 0.1), transparent);
}

.leg-spacer-cell::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-left: 10px solid var(--accent);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  filter: drop-shadow(0 0 4px rgba(91, 192, 222, 0.5));
}

.leg-point-cell {
  background: rgba(155, 107, 255, 0.08);
  border-left: 2px solid rgba(155, 107, 255, 0.3);
}

.leg-point-row {
  position: relative;
  transition: background 0.2s ease;
}

.leg-point-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.leg-point-row::before {
  content: "";
  position: absolute;
  left: calc(5 * (100% / 10) + 25px);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 2px;
  background: linear-gradient(to right, var(--accent), rgba(155, 107, 255, 0.5));
  z-index: 1;
}

.legs-table input {
  width: 100%;
  padding: 10px 12px;
  height: 44px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.legs-table td:last-child input {
  min-width: 0;
  width: 100%;
}

.legs-table input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 2px rgba(91, 192, 222, 0.2);
  outline: none;
}

.legs-table tbody td:last-child input {
  padding: 10px 12px;
  font-size: 14px;
  height: 44px;
}

.leg-row-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.leg-row-number {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  min-width: 50px;
}

.remove {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #f7b2b2;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: none;
}

.remove:hover {
  border-color: #f55;
  color: #fff;
}

.site-footer {
  padding: 24px 20px 36px;
  text-align: center;
  color: var(--muted);
  background: rgba(10, 13, 17, 0.9);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .fuel-phase {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .fuel-result {
    min-width: auto;
  }
  .legs-table-wrapper {
    font-size: 11px;
    overflow-x: auto;
  }
  .legs-table {
    width: 100% !important;
    min-width: 100% !important;
  }
  .legs-table th,
  .legs-table td {
    padding: 6px 4px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .actions {
    width: 100%;
  }
  .actions button {
    flex: 1;
  }
}

