:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --blue-light: #e8f0fe;
  --green: #137333;
  --orange: #e37400;
  --red: #d93025;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-400: #bdc1c6;
  --gray-500: #9aa0a6;
  --gray-700: #5f6368;
  --gray-900: #202124;
  --white: #fff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Google Sans', Roboto, 'Segoe UI', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  background: var(--blue);
  color: var(--white);
  padding: 14px 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,.18);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1140px;
  margin: 0 auto;
}

.logo { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 500; letter-spacing: -.3px; }

/* ── Main layout ─────────────────────────────────────────────────────────── */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}

/* ── Search panel ────────────────────────────────────────────────────────── */

.search-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 28px;
  margin-bottom: 28px;
}

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.autocomplete-wrap {
  position: relative;
  flex: 1 1 180px;
}

.field-wrap {
  flex: 0 1 auto;
}

/* "optional" marker inside a field label — inherits the label's uppercase
   treatment, so it is toned down rather than restyled. */
.field-hint {
  font-weight: 400;
  color: var(--gray-500);
  letter-spacing: .2px;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  height: 42px;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

select { cursor: pointer; }

.swap-btn {
  flex: 0 0 auto;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-700);
  transition: background .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
  flex-shrink: 0;
}
.swap-btn:hover { background: var(--gray-100); border-color: var(--gray-500); }

.search-btn {
  flex: 0 0 auto;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 0 28px;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  height: 42px;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.search-btn:hover { background: var(--blue-dark); box-shadow: 0 2px 8px rgba(26,115,232,.3); }
.search-btn:active { background: #0d47a1; }

/* ── Dropdown ────────────────────────────────────────────────────────────── */

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.dropdown.open { display: block; }

.dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover,
.dropdown-item.highlighted { background: var(--gray-50); }

.iata-badge {
  font-weight: 700;
  font-size: 14px;
  color: var(--blue);
  min-width: 38px;
  font-family: monospace;
}
.airport-info { flex: 1; min-width: 0; }
.airport-city { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.airport-name { font-size: 12px; color: var(--gray-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.airport-country { font-size: 11px; color: var(--gray-500); margin-left: auto; flex-shrink: 0; }

/* ── Results header ──────────────────────────────────────────────────────── */

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.tab-bar {
  display: flex;
  gap: 4px;
}

.tab {
  background: none;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--gray-100); }
.tab.active { background: var(--blue-light); color: var(--blue); }

.count-badge {
  display: inline-block;
  background: var(--gray-200);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}
.tab.active .count-badge { background: #c5d9f7; }

.route-info {
  font-size: 13px;
  color: var(--gray-700);
}

/* ── Flight list ─────────────────────────────────────────────────────────── */

.flight-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Flight card ─────────────────────────────────────────────────────────── */

.flight-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 200px 1fr auto auto;
  align-items: center;
  gap: 20px;
  transition: box-shadow .15s, transform .1s;
}
.flight-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.flight-card.award-card { border-left: 3px solid var(--blue); }

/* Airline column */
.card-airline {}
.airline-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-900);
  line-height: 1.3;
}
.flight-num {
  font-size: 12px;
  color: var(--gray-700);
  margin-top: 3px;
  font-family: monospace;
  letter-spacing: .3px;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.tag {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.tag-award { background: var(--blue-light); color: var(--blue); }
.tag-vi    { background: #fef7e0; color: #a05700; }
.tag-source { background: var(--gray-100); color: var(--gray-700); }

/* Times column */
.card-times {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.time-block { text-align: center; flex-shrink: 0; }
.time {
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.time-airport {
  font-size: 12px;
  color: var(--gray-700);
  margin-top: 3px;
  font-weight: 500;
}
.route-line {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 60px;
}
.route-line .duration {
  font-size: 12px;
  color: var(--gray-700);
  white-space: nowrap;
}
.line-bar {
  width: 100%;
  height: 1.5px;
  background: var(--gray-300);
  position: relative;
}
.line-bar::before,
.line-bar::after {
  content: '';
  position: absolute;
  top: -3.5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-400);
}
.line-bar::before { left: -1px; }
.line-bar::after  { right: -1px; }

.stops-label {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.stops-label.nonstop   { color: var(--green); }
.stops-label.one-stop  { color: var(--orange); }
.stops-label.multi-stop { color: var(--red); }

/* Price column */
.card-price { text-align: right; flex-shrink: 0; }
.price-amount {
  font-size: 24px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
}
.price-amount.award-price {
  font-size: 20px;
  color: var(--blue);
}
.price-unit { font-size: 13px; font-weight: 400; color: var(--gray-700); }
.price-note { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* Actions column */
.card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.deep-link-btn {
  display: inline-block;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  background: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.deep-link-btn:hover { background: var(--blue-light); }

/* Award card — no times (seats.aero only gives date + source) */
.award-details {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.7;
}
.award-details strong { color: var(--gray-900); }

/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 13px;
  color: var(--gray-700);
}
.btn-more, .btn-all {
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 8px 22px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  color: var(--gray-900);
}
.btn-more { color: var(--blue); border-color: var(--blue); }
.btn-more:hover { background: var(--blue-light); }
.btn-all:hover  { background: var(--gray-100); border-color: var(--gray-500); }

/* ── Loading ─────────────────────────────────────────────────────────────── */

.loading-section {
  text-align: center;
  padding: 72px 20px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-section p { color: var(--gray-700); font-size: 15px; }

/* ── Error ───────────────────────────────────────────────────────────────── */

.error-section {
  background: #fce8e6;
  border: 1px solid #f28b82;
  border-radius: var(--radius);
  padding: 16px 20px;
  color: var(--red);
  font-weight: 500;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--gray-700);
}
.empty-state h3 { font-size: 17px; margin-bottom: 8px; color: var(--gray-900); }
.empty-state p  { font-size: 14px; }

/* ── Utilities ───────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .flight-card {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .card-airline { grid-column: 1; grid-row: 1; }
  .card-price   { grid-column: 2; grid-row: 1; }
  .card-times   { grid-column: 1 / -1; grid-row: 2; }
  .card-actions { grid-column: 2; grid-row: 1; align-items: flex-end; }
}

@media (max-width: 640px) {
  .search-row { flex-direction: column; align-items: stretch; }
  .swap-btn   { width: 100%; border-radius: var(--radius); height: 38px; }
  .field-wrap { width: 100%; }
  .search-btn { width: 100%; }
  .flight-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 14px;
  }
  .card-airline, .card-times, .card-price, .card-actions {
    grid-column: 1;
    grid-row: auto;
  }
  .card-price, .card-actions { text-align: left; align-items: flex-start; }
  .results-header { flex-direction: column; align-items: flex-start; }
  .search-panel { padding: 18px 16px; }
}

/* ── Nav ──────────────────────────────────────────────────────────────────── */

.nav { margin-left: auto; display: flex; gap: 4px; }

.nav-link {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
.nav-link:hover  { background: rgba(255,255,255,.12); color: var(--white); }
.nav-link.active { background: rgba(255,255,255,.20); color: var(--white); font-weight: 500; }

/* ── Watch form ───────────────────────────────────────────────────────────── */

.watch-options {
  display: flex;
  gap: 28px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.option-group { flex: 1 1 420px; min-width: 0; }
.option-group-narrow { flex: 0 1 220px; }
.option-group-narrow input { margin-bottom: 12px; }

.program-controls { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }

.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 14px;
  max-height: 230px;
  overflow-y: auto;
  padding: 10px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--gray-50);
}

.program-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-900);
  cursor: pointer;
  padding: 2px 0;
}
.program-item input { width: auto; margin: 0; cursor: pointer; }
.program-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; cursor: pointer; }

.hint        { font-size: 12px; color: var(--gray-500); margin-top: 8px; }
.hint-inline { font-size: 12px; color: var(--gray-500); }

.submit-row { margin-top: 20px; }

.chip-btn {
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--gray-700);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip-btn:hover        { background: var(--gray-100); border-color: var(--gray-500); }
.chip-btn:disabled     { opacity: .6; cursor: default; }
.chip-btn.danger       { color: var(--red); border-color: #f3c2be; }
.chip-btn.danger:hover { background: #fce8e6; border-color: var(--red); }

/* ── Watch list ───────────────────────────────────────────────────────────── */

.section-title { font-size: 17px; font-weight: 500; color: var(--gray-900); }

.watch-list { display: flex; flex-direction: column; gap: 12px; }

.watch-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
}

.watch-main { min-width: 0; }

.watch-route {
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.watch-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--blue);
  background: var(--blue-light);
  padding: 2px 10px;
  border-radius: 999px;
}

.watch-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--gray-700);
  margin-top: 6px;
}

.watch-programs { font-size: 13px; color: var(--gray-700); margin-top: 8px; }
.watch-target   { font-size: 13px; color: var(--green); margin-top: 6px; font-weight: 500; }
.watch-checked  { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

.watch-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.watch-history {
  grid-column: 1 / -1;
  border-top: 1px solid var(--gray-200);
  padding-top: 14px;
  overflow-x: auto;
}

.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th {
  text-align: left;
  font-weight: 500;
  color: var(--gray-700);
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.history-table td {
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
.history-table .num { text-align: right; }

@media (max-width: 720px) {
  .watch-card    { grid-template-columns: 1fr; }
  .watch-actions { flex-direction: row; flex-wrap: wrap; }
  .watch-options { gap: 20px; }
  .option-group-narrow { flex: 1 1 100%; }
}
