/* ===================================================================
   Rumbo a Colombia — Visor de vuelos SCL → BOG · MDE · CLO
   Misma familia visual que el Visor de Arriendos: papel cálido, tinta
   profunda, Fraunces + Inter. Acentos: tricolor colombiano contenido.
   Ciudades (paleta validada CVD): BOG azul · MDE ámbar · CLO rojo.
   =================================================================== */
:root {
  --bg:        #f7f4ec;   /* papel hueso cálido */
  --surface:   #ffffff;
  --surface-2: #fbf9f3;
  --ink:       #201e1a;
  --muted:     #7b7468;
  --line:      #e8e2d4;
  --primary:   #1d4e94;   /* azul profundo (acción) */
  --primary-d: #143a72;
  --amarillo:  #FCD116;   /* tricolor — solo decorativo */
  --azul-co:   #003893;
  --rojo-co:   #CE1126;
  --good:      #2f8f6f;   /* bajadas / ofertas */
  --bad:       #b25a4a;   /* subidas */
  --bog:       #3563b0;   /* series ciudades (validadas) */
  --mde:       #c29500;
  --clo:       #a3312e;
  --shadow:    0 1px 2px rgba(32,30,26,.06), 0 8px 24px rgba(32,30,26,.06);
  --shadow-h:  0 6px 16px rgba(32,30,26,.10), 0 16px 40px rgba(32,30,26,.10);
  --r:         14px;
  --r-sm:      9px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------- Topbar ----------------------------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1000;
  /* guiño tricolor, minimalista */
  border-top: 4px solid var(--amarillo);
  box-shadow: inset 0 4px 0 -2px var(--azul-co);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  height: 44px; border-radius: 12px; flex: none; padding: 0 10px;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.flag { width: 27px; height: 18px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(32,30,26,.12); }
.flag-arrow { font-size: 13px; color: var(--muted); font-weight: 600; }
.topbar h1 {
  font-family: 'Fraunces', serif; font-weight: 600;
  font-size: 21px; line-height: 1; margin: 0; letter-spacing: -.01em;
}
.sub { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }

.stats { display: flex; gap: 10px; margin-left: auto; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 14px; min-width: 84px;
  box-shadow: var(--shadow);
}
.stat b { font-family: 'Fraunces', serif; font-size: 18px; display: block; line-height: 1.1; white-space: nowrap; }
.stat span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.hl b { color: var(--good); }

.view-toggle { display: flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 3px; }
.view-toggle button {
  border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 7px 14px; border-radius: 7px; transition: .15s; white-space: nowrap;
}
.view-toggle button.active { background: var(--ink); color: #fff; box-shadow: var(--shadow); }

/* ------------------------- Banner update -------------------------- */
.update-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 9px 24px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); }
.update-bar .ub-date b { color: var(--ink); }
.ub-tag { font-weight: 600; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; }
.ub-tag.ofertas { background: rgba(47,143,111,.12); color: var(--good); }
.ub-tag.corridas { background: rgba(29,78,148,.10); color: var(--primary); }

/* ----------------------------- Layout ----------------------------- */
.layout { display: grid; grid-template-columns: 290px 1fr; align-items: start; }
.content { padding: 22px 24px 60px; min-height: calc(100vh - 77px); }

/* En las vistas sin filtros (Recomendación / Temporal / Planificador) el
   contenido ocupa todo el ancho, acotado y centrado para leer cómodo. */
.layout.sin-filtros { grid-template-columns: 1fr; }
.layout.sin-filtros .content { max-width: 1240px; width: 100%; margin: 0 auto; }

/* ----------------------------- Filtros ---------------------------- */
.filters {
  position: sticky; top: 77px; align-self: start;
  height: calc(100vh - 77px); overflow-y: auto;
  padding: 20px; border-right: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 18px;
}
.filters-head { display: flex; align-items: center; justify-content: space-between; }
.filters-head h2 { font-family: 'Fraunces', serif; font-size: 17px; margin: 0; }
.link { background: none; border: 0; color: var(--primary); font: inherit;
  font-size: 12.5px; font-weight: 600; cursor: pointer; }
.link:hover { text-decoration: underline; }

/* Botón Solo Ofertas */
.match-btn { display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer;
  border: 1.5px solid var(--good); background: linear-gradient(135deg, #fff, #f0f9f5);
  color: var(--ink); border-radius: 12px; padding: 12px 14px; font: inherit; text-align: left;
  box-shadow: var(--shadow); transition: .16s; }
.match-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-h); }
.match-btn.active { background: linear-gradient(135deg, var(--good), #257a5d); color: #fff; border-color: #257a5d; }
.match-btn .match-emoji { font-size: 22px; flex: none; }
.match-btn .match-txt { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.match-btn .match-txt b { font-size: 14px; }
.match-btn .match-txt small { font-size: 10.5px; color: var(--muted); }
.match-btn.active .match-txt small { color: rgba(255,255,255,.85); }
.match-btn .match-count { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600;
  background: var(--good); color: #fff; min-width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; flex: none; padding: 0 6px; }
.match-btn.active .match-count { background: rgba(255,255,255,.22); }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.field select {
  font: inherit; font-size: 13px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); width: 100%;
}
.field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,148,.12); }
input[type=range] { width: 100%; accent-color: var(--primary); }
#f-precio-val { color: var(--primary); font-variant-numeric: tabular-nums; }

.seg { display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.seg.seg-3 { grid-template-columns: repeat(3,1fr); }
.seg button {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 8px 0; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--muted); transition: .15s;
}
.seg button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; font-weight: 500; cursor: pointer;
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  transition: .15s; user-select: none; display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.switches { display: flex; flex-direction: column; gap: 11px;
  border-top: 1px solid var(--line); padding-top: 16px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 12.5px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--primary); }

.millas-box { background: rgba(252,209,22,.14); border: 1px solid rgba(194,149,0,.35);
  border-radius: 10px; padding: 12px 14px; font-size: 11.5px; line-height: 1.5; color: var(--ink); }
.millas-box b { font-weight: 700; }
.millas-box p { margin: 6px 0 0; color: #5d5747; }

/* --------------------------- Result bar --------------------------- */
.result-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
#count { font-size: 14px; font-weight: 600; }
#count b { font-family: 'Fraunces', serif; color: var(--primary); }
.legend { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; vertical-align: middle; }

/* ----------------------------- Tarjetas --------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px; align-items: start; }
.hidden { display: none !important; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); transition: .18s;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  border-top: 3px solid var(--line);
}
.card:hover { box-shadow: var(--shadow-h); transform: translateY(-3px); }
.card.c-BOG { border-top-color: var(--bog); }
.card.c-MDE { border-top-color: var(--mde); }
.card.c-CLO { border-top-color: var(--clo); }

.card .body { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ruta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ruta { font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; }
.ruta .cdot { width: 9px; height: 9px; border-radius: 50%; }
.tipo-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; }

.badge-oferta { position: absolute; top: 10px; right: 10px; z-index: 2;
  font-size: 10.5px; font-weight: 700; color: #fff; padding: 4px 9px; border-radius: 999px;
  background: var(--good); box-shadow: var(--shadow); letter-spacing: .02em; }

.price-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.price { font-family: 'Fraunces', serif; font-size: 23px; font-weight: 600; line-height: 1; }
.price small { font-size: 12px; color: var(--muted); font-family: 'Inter'; font-weight: 500; }
.delta { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.delta.baja { background: rgba(47,143,111,.12); color: var(--good); }
.delta.sube { background: rgba(178,90,74,.12); color: var(--bad); }
.prom-ref { font-size: 11px; color: var(--muted); }

.fecha-vuelo { font-size: 13.5px; font-weight: 600; }
.fecha-vuelo small { color: var(--muted); font-weight: 500; }

.specs { display: flex; flex-wrap: wrap; gap: 6px; }
.spec { font-size: 11.5px; font-weight: 500; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 7px; }
.spec.direct { background: rgba(47,143,111,.10); border-color: rgba(47,143,111,.25); color: var(--good); }
.spec.millas { background: rgba(252,209,22,.18); border-color: rgba(194,149,0,.4); color: #7a6200; }

.actions { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; }
.btn { flex: 1; text-align: center; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }

/* ------------------ Bloques de análisis / paneles ------------------ */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; box-shadow: var(--shadow); }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { font-family: 'Fraunces', serif; font-size: 16px; margin: 0 0 4px; }
.panel .p-sub { font-size: 11.5px; color: var(--muted); margin: 0 0 14px; }
.panel .empty-note { font-size: 12.5px; color: var(--muted); background: var(--surface-2);
  border: 1px dashed var(--line); border-radius: 10px; padding: 14px; line-height: 1.5; }

.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--muted);
  margin-top: 8px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.tooltip { position: fixed; z-index: 5000; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 11.5px; line-height: 1.45;
  padding: 8px 11px; border-radius: 8px; box-shadow: var(--shadow-h); max-width: 240px; }
.tooltip b { font-size: 12.5px; }
.tooltip .tt-muted { color: rgba(255,255,255,.7); }

/* filas tipo lista (cambios, internos) */
.ts-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.ts-row:last-child { border-bottom: 0; }
.ts-t { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-t small { color: var(--muted); }
.ts-row:hover .ts-t { color: var(--primary); }
.ts-d { font-size: 12px; font-weight: 700; white-space: nowrap; }
.ts-d.baja { color: var(--good); } .ts-d.sube { color: var(--bad); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 14px; box-shadow: var(--shadow); }
.kpi b { font-family: 'Fraunces', serif; font-size: 22px; display: block; line-height: 1.05; }
.kpi span { font-size: 11px; color: var(--muted); margin-top: 5px; display: block; }
.kpi.hl b { color: var(--good); }

/* ------------------------ Planificador ---------------------------- */
.rank-row { display: grid; grid-template-columns: 26px minmax(150px, 210px) 1fr 92px; align-items: center;
  gap: 10px; margin-bottom: 9px; }
.rank-pos { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 600; color: var(--muted); }
.rank-label { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-label small { display: block; font-weight: 500; color: var(--muted); font-size: 10.5px; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 12px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.rank-row.best .bar-fill { background: var(--good); }
.rank-val { font-size: 12.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.combo { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.combo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.combo-head b { font-size: 14px; }
.combo-total { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; color: var(--good); }
.tramo { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.tramo:last-child { border-bottom: 0; }
.tramo a { color: var(--primary); text-decoration: none; font-weight: 600; }
.tramo a:hover { text-decoration: underline; }
.tramo .t-fecha { color: var(--muted); font-size: 11.5px; }
.tramo .t-precio { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Calculadora */
.calc-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.calc-controls .seg { grid-template-columns: repeat(3, auto); display: inline-grid; }
.calc-controls .seg button { padding: 8px 14px; }
.calc-city { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.calc-city h4 { margin: 0 0 8px; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.calc-city h4 .cdot { width: 9px; height: 9px; border-radius: 50%; }
.calc-line { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--muted); }
.calc-line b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.calc-line.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 700; color: var(--ink); }
.calc-line.total b { font-family: 'Fraunces', serif; font-size: 16px; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.gran-total { margin-top: 16px; background: linear-gradient(135deg, #fff, #f0f6ff);
  border: 1.5px solid var(--primary); border-radius: 12px; padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gran-total b { font-family: 'Fraunces', serif; font-size: 24px; color: var(--primary); }
.gran-total .gt-sub { font-size: 11.5px; color: var(--muted); }

.nota { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* ----------------------------- Vacío ------------------------------ */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h3 { font-family: 'Fraunces', serif; color: var(--ink); }

/* --------------------------- Responsive --------------------------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .stats { display: none; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
