* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: #0b1724;
  color: #f2f7fb;
}

.app-header {
  padding: 24px 20px 12px;
  background: linear-gradient(180deg, #102235 0%, #0b1724 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.header-top,
.app-header .header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
  width: 100%;
}

.top-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
  margin-left: auto;
  width: auto;
}

.nav-link {
  color: #d9e6f2;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  white-space: nowrap;
  flex: 0 0 auto;
}

.nav-link.active {
  background: rgba(37, 99, 235, .25);
  border-color: rgba(37, 99, 235, .5);
}

.small-note {
  margin: 8px 0 0;
  color: #ffd9a6;
  font-size: 12px;
}

.container {
  max-width: 1760px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 18px;
}

.db-container {
  max-width: 1600px;
}

.card {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.section-header.compact {
  align-items: center;
}

.section-header p,
.muted {
  margin: 6px 0 0;
  color: #c7d2da;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 22px;
  align-items: start;
}

@media (max-width: 520px) {
  .performance-grid {
    grid-template-columns: 1fr;
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 14px;
}

.form-airport {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.form-runway {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.form-aircraft-basic {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

@media (max-width: 980px) {
  .grid,
  .form-airport,
  .form-runway {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1180px) {
  .form-aircraft-basic {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .form-aircraft-basic {
    grid-template-columns: 1fr;
  }
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: #d9e6f2;
}

input,
select,
button,
.button-link,
textarea {
  font: inherit;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .07);
  color: #fff;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, monospace;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, .8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
}

select option {
  color: #111;
  background: #fff;
}

input.invalid-rule {
  border-color: #ef4444 !important;
  background: rgba(127, 29, 29, .22) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

button,
.button-link {
  padding: 10px 14px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-link.secondary,
button.secondary {
  background: #334155;
}

.button-link.primary,
button.primary {
  background: #0f9d58;
}

.button-link.danger,
button.danger {
  background: #b91c1c;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar {
  display: grid;
  gap: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.aircraft-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.aircraft-inline > label:first-child {
  min-width: 240px;
}

.aircraft-inline > label:first-child select {
  height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 10px;
}

.aircraft-meta {
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}

.meta-label {
  display: block;
  color: #cfe0ee;
  font-size: 12px;
  margin-bottom: 4px;
}

.aircraft-inline .aircraft-meta {
  min-width: 180px;
  min-height: 34px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 10px;
}

.aircraft-inline .aircraft-meta .meta-label {
  font-size: 11px;
  margin-bottom: 2px;
  line-height: 1.1;
}

.aircraft-inline .aircraft-meta strong {
  font-size: 13px;
  line-height: 1.1;
}

.aircraft-inline .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: auto;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 10px;
  white-space: nowrap;
}

.aircraft-inline .checkbox:nth-of-type(2) {
  margin-left: auto;
}

.aircraft-inline .checkbox input {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

.aircraft-inline #btnClearPerformance {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 10px;
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .aircraft-inline .checkbox:nth-of-type(2) {
    margin-left: 0;
  }
}

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 720px) {
  .results {
    grid-template-columns: 1fr;
  }
}

.result-item {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.result-item span {
  color: #cfe0ee;
}

.result-item strong {
  color: #ffd166;
}

.perf-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.perf-box h3 {
  margin: 0 0 12px;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

@media (max-width: 720px) {
  .check-grid {
    grid-template-columns: 1fr;
  }
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .03);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
}

.checkbox input {
  width: auto;
}

.rule-tag {
  color: #8be9a8;
  font-size: 12px;
}

.rule-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  color: #cfe0ee;
  font-size: 13px;
}

.rule-summary strong {
  color: #8be9a8;
}

.hidden {
  display: none !important;
}

.editing-banner,
.folder-box,
.success-banner {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08);
}

.editing-banner {
  margin: 0 0 14px;
  background: rgba(37, 99, 235, .16);
}

.folder-box {
  background: rgba(255, 255, 255, .05);
}

.success-banner {
  background: linear-gradient(90deg, rgba(15, 157, 88, .18), rgba(34, 197, 94, .12));
  border-color: rgba(34, 197, 94, .35);
  color: #dcfce7;
}

.success-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 880px) {
  .success-grid {
    grid-template-columns: 1fr;
  }
}

.success-pill {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}

.success-pill strong {
  display: block;
  color: #8be9a8;
  font-size: 12px;
  margin-bottom: 4px;
}

.success-pill span {
  display: block;
  color: #e2e8f0;
  font-size: 13px;
  word-break: break-word;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .05);
  color: #dbeafe;
}

.sync-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  display: inline-block;
}

.sync-badge.synced .dot {
  background: #22c55e;
}

.sync-badge.synced {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, .35);
  background: rgba(20, 83, 45, .22);
}

.sync-badge.pending .dot {
  background: #f59e0b;
}

.sync-badge.pending {
  color: #fde68a;
  border-color: rgba(245, 158, 11, .35);
  background: rgba(120, 53, 15, .22);
}

.sync-badge.browser .dot {
  background: #60a5fa;
}

.sync-badge.browser {
  color: #bfdbfe;
  border-color: rgba(96, 165, 250, .35);
  background: rgba(30, 64, 175, .20);
}

.sync-badge.error .dot {
  background: #ef4444;
}

.sync-badge.error {
  color: #fecaca;
  border-color: rgba(239, 68, 68, .35);
  background: rgba(127, 29, 29, .22);
}

.runway-list-wrapper,
.matrix-wrapper {
  overflow: auto;
  margin-bottom: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
  vertical-align: top;
}

th {
  color: #cfe0ee;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid rgba(255, 255, 255, .08);
}

.matrix-table input {
  padding: 8px 10px;
  min-width: 90px;
}

.matrix-section {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
}

.small-help {
  font-size: 12px;
  color: #c7d2da;
}

/* DB pages — spacing/rhythm fix */
.db-container > .card:first-child {
  display: grid;
  gap: 16px;
}

.db-container > .card:first-child .folder-box,
.db-container > .card:first-child .editing-banner,
.db-container > .card:first-child .success-banner,
.db-container > .card:first-child .small-help,
.db-container > .card:first-child .grid,
.db-container > .card:first-child .matrix-section,
.db-container > .card:first-child .runway-list-wrapper,
.db-container > .card:first-child .button-row {
  margin: 0;
}

/* =========================================
   Performance correction blocks
   ========================================= */
.correction-blocks {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.correction-block {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 12px 14px;
}

.correction-block-title {
  font-size: 13px;
  color: #cfe0ee;
  margin-bottom: 8px;
}

.correction-block-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .correction-block-grid {
    grid-template-columns: 1fr;
  }
}

.correction-delta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .06);
}

.correction-delta span {
  color: #cfe0ee;
  font-size: 13px;
}

.correction-delta strong {
  color: #ffd166;
  font-size: 14px;
}

.correction-empty {
  color: #94a3b8;
}

/* ----------------------------
   Animated Go Around Club logo beside page titles
   ---------------------------- */
.page-title-with-logo {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.page-logo-mini {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
  border-radius: 999px;
  animation: pageLogoFloat 3.2s ease-in-out infinite;
}

.page-logo-mini::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(74, 163, 255, .34), transparent 68%);
  opacity: .9;
  filter: blur(6px);
  animation: pageLogoGlow 2.4s ease-in-out infinite;
}

.page-logo-mini::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 1px solid rgba(74, 163, 255, .42);
  box-shadow:
    0 0 14px rgba(74, 163, 255, .22),
    inset 0 0 10px rgba(74, 163, 255, .12);
  animation: pageLogoRing 2.8s linear infinite;
}

.page-logo-mini img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 2;
  border-radius: 999px;
  filter:
    drop-shadow(0 4px 10px rgba(0, 0, 0, .38))
    drop-shadow(0 0 8px rgba(74, 163, 255, .28));
}

@keyframes pageLogoFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes pageLogoGlow {
  0%,
  100% {
    opacity: .45;
    transform: scale(.96);
  }

  50% {
    opacity: .95;
    transform: scale(1.08);
  }
}

@keyframes pageLogoRing {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* =========================================
   Performance layout — separated cards side-by-side
   ========================================= */
/* For the updated Performance HTML:
   #performanceGrid.performance-stack contains one .performance-card per phase. */
.performance-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.performance-card {
  max-width: 1680px;
  width: 100%;
  box-sizing: border-box;
}

.performance-card > div > h2 {
  margin-top: 0;
  margin-bottom: 14px;
}

.performance-card .grid {
  margin-bottom: 14px;
}

.performance-card .perf-box {
  margin-top: 16px;
}

/* Alternate keeps the same id used by the existing JS toggle. */
#altSection.hidden {
  display: none !important;
}

/* Desktop: Take-off and Landing side-by-side, but still in separate boxes. */
@media (min-width: 1100px) {
  .performance-stack {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .perf-takeoff-card {
    grid-column: 1;
  }

  .perf-landing-card {
    grid-column: 2;
  }

  .perf-alternate-card,
  #altSection {
    grid-column: 1 / -1;
  }
}

/* Very wide screens: when Alternate is enabled, all three boxes can sit side-by-side. */
@media (min-width: 1700px) {
  .performance-stack {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .perf-takeoff-card,
  .perf-landing-card,
  .perf-alternate-card,
  #altSection {
    grid-column: auto;
  }
}

/* Keep fields readable inside each separate performance card. */
@media (min-width: 1200px) {
  .performance-card .grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 1099px) {
  .performance-stack {
    gap: 16px;
  }
}
