:root {
  --sky-deep: #0f2c4c;
  --sky-mid: #1c4a7a;
  --sky-accent: #ff8a3d;
  --cloud: #f5f8fc;
  --line: #dbe4ee;
  --ink: #142433;
  --ink-soft: #5b6b7c;
  --good: #1a7f5a;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cloud);
  color: var(--ink);
  line-height: 1.5;
}

.topbar {
  background: linear-gradient(135deg, var(--sky-deep), var(--sky-mid));
  color: white;
  padding: 2.25rem 1.5rem 2.75rem;
  text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.brand-icon { font-size: 1.6rem; }
.brand-name { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.tagline { margin: 0.4rem 0 0; color: #cfe0f2; font-size: 0.95rem; }

.container {
  max-width: 880px;
  margin: -2rem auto 3rem;
  padding: 0 1.25rem;
}

.search-card, .results-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 12px 30px -18px rgba(15, 44, 76, 0.35);
}
.search-card { margin-bottom: 1.5rem; }
.search-card h2 { margin: 0 0 1.25rem; font-size: 1.05rem; }

.row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field { flex: 1; min-width: 140px; position: relative; }
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}
.field input, .field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--ink);
  background: white;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--sky-mid);
  box-shadow: 0 0 0 3px rgba(28, 74, 122, 0.12);
}
.swap-icon {
  padding-bottom: 0.65rem;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 10px 24px -12px rgba(15,44,76,0.3);
  display: none;
}
.suggestions.open { display: block; }
.suggestion-item {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.suggestion-item:hover { background: var(--cloud); }
.suggestion-code {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--sky-deep);
  font-size: 0.8rem;
  min-width: 2.4rem;
}
.suggestion-main { display: flex; flex-direction: column; min-width: 0; }
.suggestion-city { color: var(--ink); }
.suggestion-airport {
  color: var(--ink-soft);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion-empty {
  padding: 0.6rem 0.7rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.toggle-group { display: flex; gap: 0.4rem; }
.toggle {
  flex: 1;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.toggle.active {
  background: var(--sky-deep);
  border-color: var(--sky-deep);
  color: white;
}

.search-btn {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 8px;
  background: var(--sky-accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
}
.search-btn:hover { filter: brightness(1.05); }
.search-btn:disabled { opacity: 0.6; cursor: default; }

.hint { margin: 0.6rem 0 0; font-size: 0.78rem; color: var(--ink-soft); text-align: center; }

.results-card { min-height: 220px; }

.empty-state, .loading-state, .error-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-soft);
}
.empty-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.empty-state h3 { margin: 0 0 0.4rem; color: var(--ink); }
.empty-state p { margin: 0; font-size: 0.9rem; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--sky-mid);
  border-radius: 50%;
  margin: 0 auto 0.8rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state { color: #b3311f; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.results-table th {
  text-align: left;
  padding: 0.6rem 0.6rem;
  border-bottom: 2px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}
.results-table th:hover { color: var(--ink); }
.results-table td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.results-table tbody tr.summary-row { cursor: pointer; }
.results-table tbody tr.summary-row:hover { background: var(--cloud); }
.results-table tbody tr.summary-row.expanded { background: var(--cloud); }
.expand-caret {
  display: inline-block;
  width: 1rem;
  color: var(--ink-soft);
  font-size: 0.75rem;
}
.detail-row td { padding: 0; border-bottom: 1px solid var(--line); }

.itinerary-detail {
  padding: 1rem 1.25rem 1.25rem;
  background: #fbfcfe;
}
.leg-block { margin-bottom: 1rem; }
.leg-block h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--ink);
}
.leg-airline { font-weight: 400; color: var(--ink-soft); font-size: 0.82rem; }

.segment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.segment-table th {
  text-align: left;
  padding: 0.45rem 0.6rem;
  background: var(--cloud);
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}
.segment-table td {
  padding: 0.45rem 0.6rem;
  border-top: 1px solid var(--line);
  white-space: nowrap;
}
.layover-row td {
  background: #fff7ed;
  color: #9a5b1f;
  font-style: italic;
  font-size: 0.78rem;
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}
.detail-summary > div {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  min-width: 110px;
}
.detail-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}
.price-total { font-weight: 700; color: var(--ink); }
.price-per { color: var(--ink-soft); }
.book-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--sky-deep);
  background: white;
  color: var(--sky-deep);
  font-size: 0.82rem;
  cursor: pointer;
}
.book-btn:hover { background: var(--sky-deep); color: white; }
.book-btn:disabled { opacity: 0.5; cursor: default; }

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-top: 1.5rem;
}
.footer a { color: var(--sky-mid); }
#visitor-count-line { display: inline-block; margin-top: 0.4rem; opacity: 0.8; }

@media (max-width: 560px) {
  .row { flex-direction: column; align-items: stretch; }
  .swap-icon { display: none; }
}
