:root {
  --bg: #f4efe4;
  --surface: #fffdf8;
  --surface-alt: #efe8d8;
  --navy: #14273d;
  --navy-light: #223e5e;
  --gold: #c68b28;
  --gold-soft: #f5e6c4;
  --crimson: #a82828;
  --crimson-soft: #faeaea;
  --green: #1f6b45;
  --green-soft: #e6f4ec;
  --ink: #1e242b;
  --muted: #5b6570;
  --border: #d8ceb8;
  --shadow: 0 2px 10px rgba(20, 39, 61, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, #0d1c2e 100%);
  color: #fffdf8;
  border-bottom: 4px solid var(--gold);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1070px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.brand-sub {
  margin: 0;
  font-size: 0.82rem;
  color: #d6c8a8;
  letter-spacing: 0.03em;
}

.header-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #d6c8a8;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(198, 139, 40, 0.35);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.stat-pill strong {
  color: #fffdf8;
}

/* Nav Tabs */
.nav-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  padding: 2px;
  flex-shrink: 0;
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover {
  color: var(--navy);
}

.lang-btn.active {
  background: var(--navy);
  color: #fffdf8;
}

.nav-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.85rem 1.2rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.nav-tab:hover {
  color: var(--navy);
}

.nav-tab.active {
  color: var(--navy);
  border-bottom-color: var(--crimson);
}

/* Main Container */
.container {
  max-width: 1120px;
  width: 100%;
  margin: 1.5rem auto 2.5rem;
  padding: 0 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

/* Search Form */
.search-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr 170px 170px;
  gap: 0.75rem;
  align-items: end;
}

.search-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}

.season-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.pill-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--navy);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pill-btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.field select,
.field input[type="date"],
.field input[type="text"],
.field input[type="search"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  font-family: inherit;
}

.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(20, 39, 61, 0.12);
}

.swap-btn {
  height: 39px;
  width: 39px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--navy);
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}

.swap-btn:hover {
  background: var(--gold-soft);
  transform: rotate(180deg);
}

.btn-primary {
  background: var(--crimson);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.4rem;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #8c1f1f;
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

/* HTMX Loading */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Results Header */
.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.results-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--navy);
}

.results-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.day-nav {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Itinerary Card */
.itin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
  overflow: hidden;
  transition: border-left-color 0.15s;
}

.itin-card:hover {
  border-left-color: var(--crimson);
}

.itin-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 1rem 1.25rem;
  align-items: center;
}

.itin-main {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr minmax(110px, auto);
  gap: 1rem;
  align-items: center;
}

.time-block {
  display: flex;
  flex-direction: column;
}

.time-block.arr {
  text-align: right;
}

.time-big {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
}

.next-day-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--crimson);
  vertical-align: super;
  margin-left: 2px;
}

.airport-code {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.tz-note {
  font-size: 0.73rem;
  color: var(--muted);
}

.route-line-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.duration-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.route-track {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}

.track-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--navy);
  flex-shrink: 0;
}

.track-dot.stop {
  background: var(--gold);
  border: 2px solid var(--navy);
  width: 10px;
  height: 10px;
}

.track-bar {
  flex: 1;
  height: 2px;
  background: var(--navy-light);
}

.stops-label {
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.flight-badge {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.flight-badge.zeppelin {
  background: var(--gold);
  color: var(--navy);
}

.badge-direct {
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.badge-stops {
  background: var(--gold-soft);
  color: #7c5310;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

/* Price Box */
.price-box {
  text-align: right;
  padding-left: 1.25rem;
  border-left: 1px dashed var(--border);
  min-width: 145px;
}

.price-main {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--crimson);
  line-height: 1.15;
}

.price-sub {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.price-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
  color: var(--navy);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-top: 0.25rem;
}

/* Expandable Leg Details */
.itin-details {
  border-top: 1px solid #ebe3d2;
  background: #faf6ec;
}

.itin-details summary {
  padding: 0.55rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy-light);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.itin-details summary::-webkit-details-marker {
  display: none;
}

.itin-details summary:hover {
  background: #f2ead8;
}

.details-body {
  padding: 0.9rem 1.25rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 1.25rem;
  border-top: 1px dashed var(--border);
}

.leg-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.leg-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.leg-times {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.92rem;
}

.leg-route {
  font-size: 0.86rem;
  color: var(--ink);
}

.leg-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.layover-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #7c5310;
  background: var(--gold-soft);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  margin-left: 1rem;
}

.map-box {
  background: #f3ecdb;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-box svg {
  width: 100%;
  height: auto;
  display: block;
}

.map-caption {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

/* Tables (Departures & Airports) */
.table-wrap {
  overflow-x: auto;
}

table.timetable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.timetable th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: var(--navy);
  color: #fffdf8;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.timetable td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e6decb;
}

table.timetable tbody tr:hover {
  background: #f7f1e3;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--muted);
}

.empty-state h3 {
  color: var(--navy);
  margin: 0 0 0.5rem;
}

.alert-error {
  background: var(--crimson-soft);
  border: 1px solid #e5b3b3;
  color: var(--crimson);
  padding: 0.85rem 1.1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-weight: 600;
}

.return-banner {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fffdf8;
  padding: 0.85rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.return-banner strong {
  color: #f7d58b;
}

.site-footer {
  text-align: center;
  padding: 1.25rem 1.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer a {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
  color: var(--crimson);
}

@media (max-width: 860px) {
  .search-grid {
    grid-template-columns: 1fr;
  }
  .swap-btn {
    justify-self: center;
    transform: rotate(90deg);
  }
  .itin-summary {
    grid-template-columns: 1fr;
  }
  .price-box {
    border-left: none;
    border-top: 1px dashed var(--border);
    padding-left: 0;
    padding-top: 0.75rem;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .details-body {
    grid-template-columns: 1fr;
  }
}

/* Additional classes used in results.html and departures.html */
.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.results-heading {
  margin: 0;
  font-size: 1.15rem;
  color: var(--navy);
}

.btn {
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem 0.6rem;
  margin-bottom: 1rem;
}

.map-card .map-caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.route-svg {
  width: 100%;
  height: auto;
  display: block;
  background: #f5efe1;
  border-radius: 4px;
  border: 1px solid #e3dac6;
}

.itin-card.direct {
  border-left-color: var(--green);
}

.airport-sub {
  font-size: 0.84rem;
  color: var(--ink);
  margin-top: 0.15rem;
}

.tz-tag {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface-alt);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.25rem;
}

.next-day-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--crimson);
  vertical-align: super;
  margin-left: 2px;
}

.journey-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.track {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--gold) 50%, var(--navy) 100%);
  position: relative;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
}

.badge-through {
  background: var(--gold-soft);
  color: #7c5310;
}

.badge-flight {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
}

.price-rm {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--crimson);
  line-height: 1.15;
}

.price-na {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
}

.legs-list {
  padding: 0.85rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border-top: 1px dashed var(--border);
}
