:root {
  --navy: #1C3B6E;
  --navy-dark: #142a52;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --muted: #7A96B8;
  --ink: #1A2542;
  --ink-soft: #4A5878;
  --line: #E2EAF4;
  --accent: #2E66C9;
  --success: #1F9A6A;
  --warning: #E0A23A;
  --gradient: linear-gradient(135deg, #1C3B6E 0%, #2E66C9 100%);
  --shadow-sm: 0 1px 2px rgba(28, 59, 110, 0.06), 0 2px 8px rgba(28, 59, 110, 0.04);
  --shadow-md: 0 6px 24px rgba(28, 59, 110, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--gradient);
  color: #fff;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 14px; max-width: 1100px; margin: 0 auto; }
.brand-mark svg { display: block; border-radius: 10px; }
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text p { margin: 2px 0 0; font-size: 13px; opacity: 0.85; }

.mode-nav {
  display: flex;
  gap: 6px;
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 0 4px;
  flex-wrap: wrap;
}
.mode-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover { background: rgba(255,255,255,0.22); }
.mode-btn.active { background: #fff; color: var(--navy); }

textarea#plan-prompt {
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
  min-height: 110px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea#plan-prompt:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 102, 201, 0.15);
}
.search-grid.two-up {
  grid-template-columns: 1fr 1fr auto;
}

/* Stay cards */
.stay {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 16px;
  align-items: center;
  border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.08s;
  cursor: pointer;
}
.stay:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stay-photo {
  width: 160px; height: 120px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--line);
}
.stay-name { font-size: 17px; font-weight: 700; color: var(--navy); margin: 0 0 4px; }
.stay-meta { font-size: 13px; color: var(--ink-soft); }
.stay-rating { color: var(--warning); font-weight: 600; margin-right: 6px; }
.stay-amenities { margin-top: 8px; font-size: 12px; color: var(--muted); }
.stay-price { text-align: right; }
.stay-price .price { font-size: 22px; font-weight: 700; color: var(--navy); }
.stay-price .pn { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stay-savings {
  margin-top: 6px;
  display: inline-block;
  background: rgba(31, 154, 106, 0.12);
  color: var(--success);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Ride cards */
.ride-summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.ride-summary h3 { margin: 0 0 6px; color: var(--navy); font-size: 16px; }
.ride-summary .muted { font-size: 13px; }
.ride-option {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  transition: box-shadow 0.15s;
}
.ride-option:hover { box-shadow: var(--shadow-md); }
.ride-service { font-weight: 700; color: var(--navy); font-size: 15px; }
.ride-eta { font-size: 12px; color: var(--ink-soft); }
.ride-price { font-size: 18px; font-weight: 700; color: var(--navy); text-align: right; }
.ride-cta {
  background: var(--gradient);
  color: #fff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: box-shadow 0.15s;
}
.ride-cta:hover { box-shadow: 0 4px 12px rgba(46,102,201,0.35); }
.ride-cheapest-badge {
  display: inline-block;
  background: var(--success);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Plan output */
.plan-output {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
}
.plan-output h1, .plan-output h2, .plan-output h3 { color: var(--navy); }

@media (max-width: 768px) {
  .stay { grid-template-columns: 1fr; }
  .stay-photo { width: 100%; height: 180px; }
  .stay-price { text-align: left; }
  .search-grid.two-up { grid-template-columns: 1fr; }
  .ride-option { grid-template-columns: 1fr; gap: 8px; }
  .ride-price { text-align: left; }
  .mode-nav { padding: 0 16px; }
  .mode-btn { padding: 8px 12px; font-size: 13px; }
}

.container {
  max-width: 1100px;
  margin: -20px auto 40px;
  padding: 0 16px;
}

.search-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  position: relative;
  z-index: 2;
}

.search-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1fr 1fr 0.7fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.field { display: flex; flex-direction: column; position: relative; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field .muted { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; }

.field input, .field select {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 102, 201, 0.15);
}

.search-btn {
  background: var(--gradient);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 14px 22px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s;
  white-space: nowrap;
  min-height: 46px;
}
.search-btn:hover { box-shadow: 0 6px 18px rgba(46, 102, 201, 0.35); }
.search-btn:active { transform: translateY(1px); }
.search-btn:disabled { opacity: 0.6; cursor: progress; }

.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 5;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.suggest.open { display: block; }
.suggest-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: #F0F5FC; }
.suggest-iata { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 600; }

.status-area {
  margin: 32px auto;
  text-align: center;
  color: var(--ink-soft);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  margin-top: 36px;
  padding: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.empty-state h2 { margin: 0 0 10px; color: var(--navy); font-size: 22px; }
.empty-state p { margin: 0 auto 18px; max-width: 560px; color: var(--ink-soft); }
.empty-state .tips {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 560px;
  text-align: left;
  display: grid;
  gap: 8px;
}
.empty-state .tips li {
  background: #F0F5FC;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.results { margin-top: 24px; }

.best-pick {
  background: var(--gradient);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}
.best-pick.empty { display: none; }
.best-pick .badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.best-pick h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.best-pick .meta { font-size: 14px; opacity: 0.92; }
.best-pick .pick-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.best-pick .pick-price { font-size: 28px; font-weight: 700; }
.best-pick .pick-why { margin-top: 10px; font-size: 13px; opacity: 0.88; }

.tabs {
  display: flex;
  background: var(--card);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  gap: 4px;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 12px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--navy); }
.tab.active {
  background: var(--navy);
  color: #fff;
}

.tab-panel { display: grid; gap: 12px; }

.offer {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.offer:hover { border-color: var(--accent); box-shadow: var(--shadow-md); cursor: pointer; transform: translateY(-1px); }
.offer:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,102,201,0.18); }
.offer .select-cta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Offer detail modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 42, 82, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 30px 80px rgba(20, 42, 82, 0.35);
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--line); color: var(--ink);
  border: none; width: 36px; height: 36px;
  border-radius: 50%; font-size: 22px; line-height: 1;
  cursor: pointer; transition: background 0.15s;
}
.modal-close:hover { background: #D0DBEC; }
.modal-head {
  padding: 26px 26px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0 0 6px; color: var(--navy); font-size: 20px; padding-right: 40px; }
.modal-head .muted { color: var(--ink-soft); font-size: 14px; }
.modal-body { padding: 18px 26px; }
.detail-slice + .detail-slice { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.detail-slice-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.detail-slice-head strong { color: var(--navy); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-slice-head span { color: var(--ink-soft); font-size: 14px; }
.detail-seg {
  display: grid; grid-template-columns: 130px 1fr; gap: 18px;
  padding: 12px 0;
}
.seg-times { font-size: 16px; font-weight: 700; color: var(--navy); }
.seg-times .arrow { color: var(--muted); margin: 0 4px; font-weight: 400; }
.seg-info { font-size: 14px; line-height: 1.5; }
.seg-info .muted { color: var(--ink-soft); font-size: 13px; }
.layover {
  font-size: 12px; padding: 6px 14px;
  background: #FFF6E6; color: #8A5A12;
  border-radius: 6px; margin: 6px 0 6px 148px;
  display: inline-block;
}
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; border-top: 1px solid var(--line);
  gap: 14px; flex-wrap: wrap;
}
.modal-price { font-size: 24px; font-weight: 700; color: var(--navy); }
.book-btn {
  background: var(--gradient); color: #fff;
  border: none; padding: 14px 24px;
  border-radius: 10px; font-family: inherit;
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: box-shadow 0.15s;
}
.book-btn:hover { box-shadow: 0 6px 18px rgba(46, 102, 201, 0.35); }
.book-btn:disabled { opacity: 0.6; cursor: progress; }
.book-status { padding: 0 26px 22px; }
.book-notice {
  background: #F0F5FC; border: 1px solid var(--line);
  padding: 14px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.55; color: var(--ink-soft);
}
.book-notice.error { background: #FEF1F1; border-color: #F5C4C4; color: #8B2A2A; }
.book-notice code { background: #fff; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

@media (max-width: 640px) {
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .detail-seg { grid-template-columns: 1fr; gap: 4px; }
  .layover { margin-left: 0; }
  .modal-foot { flex-direction: column; align-items: stretch; }
  .book-btn { width: 100%; }
}

.offer-slices { display: grid; gap: 10px; }
.slice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
}
.slice-times {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.slice-times .arrow { color: var(--muted); margin: 0 6px; font-weight: 400; }
.slice-route { font-size: 13px; color: var(--ink-soft); }
.slice-route .iata { font-weight: 700; color: var(--ink); }
.slice-meta { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.slice-meta .stops { color: var(--ink-soft); font-weight: 600; }
.slice-meta .direct { color: var(--success); font-weight: 600; }

.offer-carrier {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.offer-price {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.offer-price .price {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}
.offer-price .currency {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hidden { display: none !important; }

.footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}

.error-banner {
  background: #FEF1F1;
  border: 1px solid #F5C4C4;
  color: #8B2A2A;
  padding: 14px 18px;
  border-radius: 10px;
  margin: 18px 0;
  font-size: 14px;
}

/* Mobile */
@media (max-width: 768px) {
  .topbar { padding: 16px; }
  .brand-text h1 { font-size: 18px; }
  .brand-text p { font-size: 12px; }
  .container { padding: 0 12px; margin-top: -16px; }
  .search-card { padding: 16px; }
  .search-grid {
    grid-template-columns: 1fr 1fr;
  }
  .field-airport { grid-column: span 2; }
  .search-btn { grid-column: span 2; width: 100%; }
  .best-pick h2 { font-size: 18px; }
  .best-pick .pick-price { font-size: 22px; }
  .tab { font-size: 13px; padding: 10px 4px; }
  .offer { grid-template-columns: 1fr; padding: 14px 16px; }
  .offer-price { text-align: left; align-items: flex-start; flex-direction: row; gap: 8px; align-items: baseline; }
  .slice { grid-template-columns: 1fr; gap: 4px; }
  .slice-meta { text-align: left; }
  .slice-times { font-size: 16px; }
}
