/* ── Reset & tokens ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3250;
  --accent:    #3b82f6;
  --accent2:   #60a5fa;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}


/* ══════════════════════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════════════════════ */
#landing {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1e2a4a 0%, var(--bg) 65%);
  padding: 32px 20px;
}

.landing-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: -.01em;
  margin-bottom: 32px;
}

.landing-plane {
  font-size: 1.5rem;
}

.landing-h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 16px;
}

.landing-sub {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 36px;
}

.btn-signin {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -.01em;
  min-height: 52px;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 36px;
}

.btn-signin:hover  { opacity: .88; }
.btn-signin:active { transform: scale(.98); }

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.feat {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  color: var(--muted);
  text-align: left;
}

.feat span { color: var(--text); }

/* ══════════════════════════════════════════════════════════
   APP — HEADER
══════════════════════════════════════════════════════════ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.plane { font-size: 1.25rem; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.user-btn:hover { opacity: .8; }

/* ══════════════════════════════════════════════════════════
   APP — MAIN LAYOUT (mobile-first)
══════════════════════════════════════════════════════════ */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

h3 { font-size: .95rem; font-weight: 600; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ── Form card ───────────────────────────────────────────── */
.form-card { margin-bottom: 0; }

/* ── Form fields ─────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }

/* Mobile: all grids are single column by default */
.three-col,
.two-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.label-optional {
  font-size: .7rem;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

input[type=text],
input[type=email],
input[type=number],
input[type=date],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 1rem;
  width: 100%;
  outline: none;
  min-height: 48px;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

input:focus, select:focus { border-color: var(--accent); }
select option { background: var(--surface2); }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.error-msg {
  margin-top: 10px;
  color: var(--red);
  font-size: .875rem;
}

/* ── Toggle group (trip type / stops) ───────────────────── */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface2);
}

.toggle-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: .8rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
  min-height: 42px;
  -webkit-tap-highlight-color: transparent;
}
.toggle-btn:last-child  { border-right: none; }
.toggle-btn:hover       { background: var(--surface); color: var(--text); }
.toggle-btn.active      { background: var(--accent); color: #fff; font-weight: 600; }

/* ── Autocomplete ────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.suggestions li {
  padding: 13px 14px;
  cursor: pointer;
  font-size: .9rem;
  transition: background .1s;
}
.suggestions li:hover,
.suggestions li.active { background: var(--surface); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  min-height: 48px;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover  { opacity: .85; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-sm      { padding: 9px 13px; font-size: .82rem; min-height: 38px; }
.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: transparent; color: var(--red); border: 1px solid var(--red); }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 6px;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { color: var(--text); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.badge-test       { background: #7c3aed22; color: #a78bfa; border: 1px solid #7c3aed55; }
.badge-production { background: #16a34a22; color: #4ade80; border: 1px solid #16a34a55; }

.muted     { font-size: .85rem; color: var(--muted); }
.empty-msg { color: var(--muted); font-style: italic; font-size: .9rem; }

.alert-count {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: 8px;
  vertical-align: middle;
}

.alert-limit-msg {
  font-size: .82rem;
  color: var(--amber);
  background: #f59e0b11;
  border: 1px solid #f59e0b44;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════
   ALERT CARDS
══════════════════════════════════════════════════════════ */
.alerts-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
  position: relative;
}
.alert-card:hover { border-color: var(--accent); }

.active-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.card-top { padding-right: 20px; }

.destination {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 3px;
}

.route-label {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 1px;
}

.deadline-row { margin-top: 6px; }

.card-price {}

.price-display {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.price-below   { color: var(--green); }
.price-near    { color: var(--amber); }
.price-above   { color: var(--text); }
.price-unknown { color: var(--muted); font-size: 1rem !important; font-weight: 400 !important; }

.threshold-label { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.card-meta {
  font-size: .75rem;
  color: var(--muted);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.alert-card.loading { opacity: .6; pointer-events: none; }


/* ── Preview prices ──────────────────────────────────────── */
.preview-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0 10px;
}

.preview-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.preview-hint { font-size: .75rem; }

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 24px;
}

.preview-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: border-color .15s;
  color: var(--text);
  font-family: inherit;
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}
.preview-chip:hover    { border-color: var(--accent); }
.preview-chip.selected { border-color: var(--green); background: #16a34a11; }

.preview-price { font-size: 1.1rem; font-weight: 700; }
.preview-meta  { font-size: .75rem; color: var(--muted); }

.preview-hint-top {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ── Trend & advice ──────────────────────────────────────── */
.trend-line {
  font-size: .78rem;
  margin-top: 4px;
  min-height: 18px;
}

.trend-arrow   { font-weight: 600; }
.trend-rising  { color: var(--red); }
.trend-falling { color: var(--green); }
.trend-stable  { color: var(--muted); }

.advice-chip-wrap { margin-top: 6px; min-height: 22px; }

.advice-chip {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: default;
}

.chip-buy     { background: #16a34a22; color: #4ade80; border: 1px solid #16a34a55; }
.chip-consider{ background: #d9770611; color: #fbbf24; border: 1px solid #d9770655; }
.chip-wait    { background: #3b82f611; color: #93c5fd; border: 1px solid #3b82f655; }
.chip-monitor { background: #64748b22; color: #94a3b8; border: 1px solid #64748b55; }

.advice-inline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.chip-buy-inline     { background: #16a34a0d; border-color: #16a34a33; }
.chip-consider-inline{ background: #d976060d; border-color: #d9770633; }
.chip-wait-inline    { background: #3b82f60d; border-color: #3b82f633; }
.chip-monitor-inline { background: #64748b0d; border-color: #64748b33; }

.advice-inline-msg {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
  min-width: 0;
}

/* ── Deadline badge ──────────────────────────────────────── */
.deadline-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: #7c3aed22;
  color: #c4b5fd;
  border: 1px solid #7c3aed55;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   DRAWER
══════════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 300;
}

/* Mobile: slide up from bottom */
.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92dvh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.drawer-header h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── Results table ───────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 380px;
}

.results-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.results-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td      { background: var(--surface2); }

.price-cell      { font-weight: 700; }
.below-threshold { color: var(--green); }

.book-link {
  color: var(--accent2);
  font-size: .8rem;
  text-decoration: none;
  font-weight: 600;
}
.book-link:hover { text-decoration: underline; }

/* ── Spinner ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

.drawer-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .9rem;
  padding: 20px 0;
}

/* ── Chart ───────────────────────────────────────────────── */
.chart-wrap {
  margin-bottom: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 4px;
  overflow: hidden;
}
.sparkline-chart { width: 100%; height: auto; display: block; }

/* ── Analysis ────────────────────────────────────────────── */
.analysis-advice {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chip-buy-bg     { border-color: #16a34a55; background: #16a34a0d; }
.chip-consider-bg{ border-color: #d9770655; background: #d976060d; }
.chip-wait-bg    { border-color: #3b82f655; background: #3b82f60d; }
.chip-monitor-bg { border-color: #64748b55; background: #64748b0d; }

.advice-message { font-size: .875rem; line-height: 1.5; }

.advice-detail {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.analysis-stats {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.analysis-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .875rem;
}

.analysis-label { color: var(--muted); font-size: .8rem; }
.analysis-value { font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   TABLET  ≥ 640px
══════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  main { padding: 24px 24px 80px; gap: 32px; }

  .card { padding: 20px; }

  /* 2-col grids */
  .two-col   { display: grid; grid-template-columns: 1fr 1fr; }
  .three-col { display: grid; grid-template-columns: 1fr 1fr; }

  /* Form actions: side by side */
  .form-actions { flex-direction: row; }
  .form-actions .btn { flex: 1; }

  /* Alert grid: 2 cols */
  .alerts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

  /* Alert card actions: row */
  .card-actions { display: flex; flex-wrap: wrap; }

  /* Preview: wrap chips */
  .preview-list { flex-direction: row; flex-wrap: wrap; }
  .preview-chip { width: auto; flex-direction: column; align-items: flex-start; justify-content: center; }
  .preview-header { flex-direction: row; align-items: baseline; gap: 12px; }

  /* Drawer: slide from right on tablet+ */
  .drawer {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(560px, 100vw);
    max-height: 100vh;
    border-top: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
  }

  #drawer-content { padding: 20px; }
  .drawer-header  { padding: 16px 20px; }
  .table-scroll   { margin: 0 -20px; padding: 0 20px; }

  /* Analysis rows: side by side */
  .analysis-row { flex-direction: row; justify-content: space-between; align-items: center; }
  .analysis-label { flex-shrink: 0; font-size: .85rem; }
  .analysis-value { text-align: right; }
}

/* ══════════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px
══════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  main { padding: 32px 24px 80px; }

  .header-inner { padding: 14px 24px; }

  .three-col { grid-template-columns: 1fr 1fr 1fr; }

  .alerts-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
