/* Flight Availabilities – modern UI */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f0f4f8;
  --bg-gradient: linear-gradient(175deg, #e8effa 0%, #f5f7fb 40%, #ffffff 100%);
  --surface: #ffffff;
  --surface-hover: #fafbfe;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --accent-shadow: rgba(37, 99, 235, 0.08);
  --indigo: #4f46e5;
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px var(--accent-shadow);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 8px 24px var(--accent-shadow);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.08), 0 16px 48px var(--accent-shadow);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
  --transition-slow: 0.35s cubic-bezier(.4,0,.2,1);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

/* ===== Header ===== */
.header {
  margin-bottom: 2.25rem;
  text-align: center;
}
.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.logo {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--indigo) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-icon {
  display: inline-block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.logo-icon svg {
  width: 100%;
  height: 100%;
}
.tagline {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== Search Card ===== */
.main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.search-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}
.search-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--indigo) 100%);
  border-radius: var(--radius) var(--radius) 0 0;
}
.search-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.search-form .form-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr;
  gap: 1rem;
  width: 100%;
  align-items: end;
}
@media (max-width: 640px) {
  .search-form .form-grid {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
  }
  .search-form .form-grid .form-group:last-child {
    grid-column: 1 / -1;
  }
}
@media (max-width: 420px) {
  .search-form .form-grid {
    grid-template-columns: 1fr;
  }
  .search-form .form-grid .form-group-switch {
    order: 0;
    align-items: center;
  }
  .search-form .form-grid .form-group:not(.form-group-switch) {
    order: 1;
  }
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.form-group-switch {
  padding-bottom: 0.1rem;
}
.form-group-switch .switch-label {
  visibility: hidden;
  height: 0;
  margin: 0;
  overflow: hidden;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.form-group input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
.form-group input[type="date"] {
  min-width: 0;
}
.form-group input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.form-group input:hover {
  border-color: #cbd5e1;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Swap button */
.btn-swap {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}
.btn-swap:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.btn-swap:active {
  transform: scale(0.93);
}
.btn-swap.spinning {
  animation: spinSwap 0.35s ease;
}
@keyframes spinSwap {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(180deg); }
}
.btn-swap-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Search button */
.btn-search {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--indigo) 100%);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-search:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
  transform: translateY(-1px);
}
.btn-search:active {
  transform: translateY(0) scale(0.99);
}
.btn-search:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-search .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-search.loading .spinner {
  display: block;
}
.btn-search.loading .btn-text {
  display: none;
}
.btn-search.loading::after {
  content: "Searching flights...";
  font-weight: 500;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Messages ===== */
.message {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.25s ease;
}
.message.info {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #bfdbfe;
}
.message.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #fecaca;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Results Section ===== */
.results-section {
  margin-top: 0.5rem;
  animation: slideUp 0.4s ease;
}
.results-header {
  margin-bottom: 1.25rem;
}
.results-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}
.results-summary {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
}
.results-summary strong {
  color: var(--accent);
  font-weight: 600;
}
.results-summary .results-count-row {
  white-space: nowrap;
}
.results-summary .results-count-all {
  color: var(--text-muted);
  font-size: 0.83rem;
}

/* ===== Toolbar / Filters ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toolbar-group .toolbar-label {
  flex-shrink: 0;
}
.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--border-light);
}
.chip {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.chip:hover {
  color: var(--accent);
  background: rgba(37,99,235,.06);
}
.chip.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.25);
}
.select,
.input-inline {
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.select {
  min-width: 140px;
}
.input-inline {
  width: 6rem;
  max-width: 100%;
}
.select:focus,
.input-inline:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.chip-group-time .chip {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .toolbar-group {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}

/* ===== Chart Section ===== */
.chart-section {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding: 1.75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slideUp 0.35s ease;
}
.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chart-header-text {
  min-width: 0;
}
.chart-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.chart-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--border-light);
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chart-legend-item:hover {
  background: var(--border);
  color: var(--text);
}
.chart-legend-item.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.chart-legend-item.active::before {
  background: rgba(255,255,255,0.9);
}
.chart-legend-item::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.chart-legend-all::before {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}
.chart-legend-business::before {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}
.chart-legend-economy::before {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.chart-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.chart-container {
  width: 100%;
  min-width: 320px;
  min-height: 260px;
  position: relative;
}
.seats-chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-axis-label-y {
  font-size: 0.7rem;
  font-weight: 600;
  fill: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.chart-bar {
  transition: transform 0.15s ease, filter 0.15s ease;
  cursor: pointer;
}
.chart-bar:hover {
  filter: brightness(1.08);
}
.chart-bar-business {
  fill: #4f46e5;
}
.chart-bar-economy {
  fill: #059669;
}
.chart-bar-empty {
  fill: var(--border-light, #e5e7eb);
  cursor: default;
}
.chart-bar-empty:hover {
  filter: none;
}
.chart-bar-label {
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--font);
  pointer-events: none;
  letter-spacing: 0.02em;
}
.chart-bar-label-business {
  fill: #fff;
  text-shadow: 0 0 1px rgba(0,0,0,0.3);
}
.chart-bar-label-economy {
  fill: #fff;
  text-shadow: 0 0 1px rgba(0,0,0,0.3);
}
.chart-gridline {
  stroke: var(--border-light);
  stroke-width: 1;
  stroke-dasharray: none;
}
.chart-axis {
  stroke: var(--border);
  stroke-width: 1.5;
}
.chart-label {
  font-size: 0.7rem;
  fill: var(--text-muted);
  font-family: var(--font);
  font-weight: 500;
}
.chart-label-y {
  font-variant-numeric: tabular-nums;
}
.chart-label-x {
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}

/* Chart tooltip */
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-width: 200px;
}
.chart-tooltip.visible {
  opacity: 1;
}
.chart-tooltip-time {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}
.chart-tooltip-row {
  display: block;
  margin-bottom: 0.2rem;
}
.chart-tooltip-row:last-of-type {
  margin-bottom: 0;
}
.chart-tooltip-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.chart-tooltip-dot-business {
  background: #818cf8;
}
.chart-tooltip-dot-economy {
  background: #34d399;
}
.chart-tooltip-total {
  display: block;
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.85);
}
.chart-tooltip-empty {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.8);
}

/* Bar animation */
@keyframes barGrow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
.chart-bar-animated {
  transform-origin: bottom;
  animation: barGrow 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

/* ===== Flight Cards ===== */
.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.75rem;
}

/* Card entrance animation */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-slow), border-color var(--transition), transform var(--transition-slow);
  animation: slideUp 0.4s ease backwards;
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  transform: translateY(-2px);
}
.card-header {
  padding: 1.4rem 1.5rem 1.15rem;
  border-bottom: 1px solid var(--border-light);
}

/* Route timeline */
.card-route-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0;
}
.card-route-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
}
.card-route-time {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.card-route-code {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.card-route-line {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  position: relative;
  padding: 0 0.75rem;
}
.card-route-line::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.75rem;
  right: 0.75rem;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}
.card-route-line-plane {
  position: relative;
  z-index: 1;
  font-size: 0.9rem;
  color: var(--accent);
  background: var(--surface);
  padding: 0 0.3rem;
  line-height: 1;
}
.card-route-line-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  background: var(--surface);
  padding: 0 0.35rem;
}
.card-route-line-duration {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}
.card-route-line-stops {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

/* Card meta row */
.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}
.card-airline {
  font-weight: 600;
  color: var(--text-secondary);
}
.card-flight-number {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Seat summary */
.card-seats-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.card-seats-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.card-seats-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.card-seats-dot.dot-plenty { background: #059669; }
.card-seats-dot.dot-few { background: #d97706; }
.card-seats-dot.dot-low { background: #dc2626; }
.card-seats-item strong {
  color: var(--text);
  font-weight: 700;
}
.card-seats-item.card-seats-total strong {
  color: var(--accent);
}
.card-seats-label {
  font-weight: 500;
  color: var(--text-muted);
}
.card-seats-bottleneck {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== Toggle button ===== */
.btn-toggle-classes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.55rem 1.5rem;
  margin: 0;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: none;
  border-top: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-toggle-classes:hover {
  background: #dbeafe;
}
.btn-toggle-chevron {
  display: inline-block;
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.btn-toggle-classes.open .btn-toggle-chevron {
  transform: rotate(180deg);
}

/* Card actions row */
.card-actions {
  display: flex;
  border-top: 1px solid var(--border-light);
}
.card-actions .btn-toggle-classes {
  flex: 1;
  border-top: none;
  border-right: 1px solid var(--border-light);
  border-radius: 0;
}
.card-actions .btn-toggle-classes:last-child {
  border-right: none;
}

/* History button */
.btn-history {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.25rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-hover);
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-history:hover {
  background: #f1f5f9;
  color: var(--accent);
}
.btn-history-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 000-1.5h-3.25V5z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 000-1.5h-3.25V5z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}
.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
}

/* History table */
.history-loading,
.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.5rem 0;
  margin: 0;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.history-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--border);
}
.history-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-weight: 500;
}
.history-table tbody tr:last-child td {
  border-bottom: none;
}
.history-table tbody tr:hover {
  background: var(--accent-light);
}
.history-ts {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.history-diff {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.2rem;
}
.history-diff.diff-up {
  background: var(--success-light);
  color: var(--success);
}
.history-diff.diff-down {
  background: var(--error-bg);
  color: var(--error);
}
.history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ===== Segments (collapsed by default) ===== */
.segments {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(.4,0,.2,1);
}
.segments.open {
  max-height: 2000px;
}
.segment {
  padding: 1.25rem 1.5rem;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border-light);
  position: relative;
  margin-left: 0;
}
.segment:last-child {
  border-bottom: none;
}
/* Timeline left border */
.segment::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--indigo));
  border-radius: 0 2px 2px 0;
}
.segment-flight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.segment-flight-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.segment-flight-number {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.segment-airline-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.segment-duration-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
}
.segment-times-route {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}
.segment-time-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.segment-time-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.segment-time-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}
.segment-airport-code {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.segment-connector {
  align-self: center;
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0 0.15rem;
}
.segment-classes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.segment-classes-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.segment-classes-cabin {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 0.2rem;
  min-width: 3.5rem;
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  border-left: 3px solid var(--border);
  background: var(--bg);
  transition: background var(--transition);
}
.tag.tag-first {
  background: #faf5ff;
  border-left-color: #8b5cf6;
  color: #5b21b6;
}
.tag.tag-business {
  background: #eef2ff;
  border-left-color: #4f46e5;
  color: #3730a3;
}
.tag.tag-premium {
  background: #ecfdf5;
  border-left-color: #059669;
  color: #047857;
}
.tag.tag-economy {
  background: #f0fdf4;
  border-left-color: #16a34a;
  color: #166534;
}
.tag.low {
  background: var(--error-bg);
  border-left-color: var(--error);
  color: var(--error);
}
.tag.tag-first.low {
  background: #fce7f3;
  border-left-color: #e11d48;
  color: #9d174d;
}
.tag.tag-business.low {
  background: #fce7f3;
  border-left-color: #e11d48;
  color: #9d174d;
}
.tag.tag-premium.low {
  background: var(--error-bg);
  border-left-color: var(--error);
  color: var(--error);
}
.tag.tag-economy.low {
  background: var(--error-bg);
  border-left-color: var(--error);
  color: var(--error);
}

/* No results */
.no-results {
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ===== Footer ===== */
.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}
.footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .page {
    padding: 1.5rem 1rem 2rem;
  }
  .logo {
    font-size: 1.5rem;
  }
  .logo-icon {
    width: 22px;
    height: 22px;
  }
  .tagline {
    font-size: 0.9rem;
  }
  .search-card {
    padding: 1.25rem;
  }
  .btn-search {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
  }
  /* Larger touch targets on mobile */
  .chip {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
  .select,
  .input-inline {
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    min-height: 40px;
  }
  .card-header {
    padding: 1.1rem 1.15rem 1rem;
  }
  .segment {
    padding: 1rem 1.15rem;
  }
  .card-route-time {
    font-size: 1.15rem;
  }
  .card-route-line {
    min-width: 50px;
    padding: 0 0.5rem;
  }
  .chart-section {
    padding: 1.25rem 1rem;
  }
  .chart-header {
    flex-direction: column;
    gap: 0.75rem;
  }
  .chart-wrapper {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }
}

@media (max-width: 420px) {
  .card-route-timeline {
    gap: 0;
  }
  .card-meta-row {
    font-size: 0.82rem;
  }
  .card-seats-summary {
    font-size: 0.82rem;
    gap: 0.4rem 0.8rem;
  }
  .segment-time-value {
    font-size: 1rem;
  }
  .segment-flight-number {
    font-size: 0.95rem;
  }
  .tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}
