/* Observatorio de Turismo — tablero público */
:root {
  --brand: #2f6b3a;
  --brand-2: #8a5a2b;
  --page: #f5f3ec;
  --surface: #fcfcfb;
  --ink: #18201a;
  --ink-2: #4f564f;
  --muted: #858a82;
  --line: #e3e0d6;
  --grid: #ebe9e1;
  --s1: #2a78d6; /* nacionales / pernoctación */
  --s2: #eb6834; /* extranjeros / fuga */
  --s3: #1baf7a;
  --good: #0f7a28;
  --bad: #b83232;
  --warn: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 30, .05), 0 6px 20px rgba(30, 40, 30, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--brand); }
img { max-width: 100%; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink-2); margin: 2px 0 0; font-size: 13px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Hero ---------- */
.hero {
  color: #fff; position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 300px at 85% -20%, rgba(255,255,255,.14), transparent 60%),
    linear-gradient(115deg, color-mix(in srgb, var(--brand) 92%, #000) 0%, var(--brand) 55%, color-mix(in srgb, var(--brand-2) 85%, var(--brand)) 100%);
}
.hero::after { /* surcos de cultivo */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .09;
  background: repeating-linear-gradient(-28deg, #fff 0 2px, transparent 2px 22px);
  mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
}
.hero-inner { display: flex; align-items: center; gap: 22px; padding-top: 26px; padding-bottom: 26px; position: relative; z-index: 1; }
.hero-logo { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 16px; padding: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.hero-text { flex: 1; min-width: 0; }
.eyebrow { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .12em; font-size: 11.5px; font-weight: 700; opacity: .85; }
.hero h1 { font-size: clamp(24px, 3.2vw, 36px); font-weight: 800; letter-spacing: -.02em; }
.hero h1 span { font-weight: 500; opacity: .85; font-size: .62em; letter-spacing: 0; }
.hero-sub { margin: 6px 0 0; opacity: .92; font-size: 14px; }
.hero-partners { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; max-width: 46%; }
.hero-partners a { display: block; }
.hero-partners img { display: block; height: 64px; max-width: 170px; object-fit: contain; background: #fff; border-radius: 12px; padding: 8px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.hero-partners.many img { height: 50px; max-width: 130px; padding: 6px 10px; }
.hero-sm .wrap { padding-top: 40px; padding-bottom: 40px; }

.demo-banner { background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f0dca0; font-size: 13px; }
.demo-banner .wrap { padding-top: 8px; padding-bottom: 8px; }

/* ---------- Filtros ---------- */
.filters { position: sticky; top: 0; z-index: 1000; background: rgba(252,252,251,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.filters-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding-top: 10px; padding-bottom: 10px; }
.seg { display: inline-flex; background: #eceae2; border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.fld { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.fld input, .fld select, #dir-q {
  font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-height: 34px;
}
.fld.sm select { padding: 4px 8px; min-height: 30px; }
.filters-note { font-size: 12.5px; color: var(--muted); margin-left: auto; }

/* ---------- KPIs ---------- */
main.wrap { padding-top: 20px; padding-bottom: 40px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-height: 132px; position: relative;
}
.kpi .k-top { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.kpi .k-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); flex: none; }
.kpi .k-ic svg { width: 17px; height: 17px; }
.kpi .k-ic.brown { background: color-mix(in srgb, var(--brand-2) 14%, #fff); color: var(--brand-2); }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-val small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.kpi .k-sub { font-size: 12.5px; color: var(--ink-2); }
.kpi .k-delta { font-size: 12.5px; font-weight: 700; }
.k-delta.up { color: var(--good); } .k-delta.down { color: var(--bad); } .k-delta.flat { color: var(--muted); }
.kpi .k-meta { margin-top: auto; font-size: 12px; color: var(--muted); }
.kpi .bar { height: 6px; background: #ecebe4; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.kpi .bar > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.kpi .gauge { position: absolute; right: 14px; top: 44px; width: 86px; }
.skeleton { background: linear-gradient(90deg, #f0eee7 25%, #f8f7f2 50%, #f0eee7 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 18px; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.link-btn { border: 0; background: none; color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Mapa ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
.map-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
#map { height: 560px; background: #e8efe4; }
.layer-chips { position: absolute; top: 10px; left: 54px; z-index: 500; display: flex; flex-wrap: wrap; gap: 6px; }
.layer-chips label { background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.18); cursor: pointer; user-select: none; }
.layer-chips input { accent-color: var(--brand); margin: 0; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-zona { background: color-mix(in srgb, var(--brand) 45%, #fff); border: 1.5px solid var(--brand); }
.sw-atr { background: var(--brand); border-radius: 50%; }
.sw-ruta { background: #c0392b; height: 3px; width: 14px; border-radius: 2px; }
.sw-est { background: var(--brand-2); border-radius: 50%; }
.map-legend { position: absolute; bottom: 14px; left: 10px; z-index: 500; background: #fff; border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.map-legend .ramp { display: flex; height: 8px; width: 160px; border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.map-legend .ramp span { flex: 1; }
.map-legend .ends { display: flex; justify-content: space-between; color: var(--ink-2); }
.map-side { display: flex; flex-direction: column; min-height: 0; max-height: 560px; }
.tabs { display: flex; gap: 4px; background: #eceae2; padding: 3px; border-radius: 10px; margin-bottom: 10px; }
.tabs button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.side-list { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.side-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.side-item:hover, .side-item.active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, #fff); }
.side-item .dot { width: 12px; height: 12px; border-radius: 4px; flex: none; margin-top: 4px; }
.side-item strong { display: block; font-size: 13.5px; }
.side-item small { color: var(--ink-2); font-size: 12px; }
.side-item .badge { margin-left: auto; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eceae2; color: var(--ink-2); white-space: nowrap; }
.badge.b-alto, .badge.b-activo { background: #e1f1e4; color: #145c26; }
.badge.b-medio, .badge.b-pendiente { background: #fdf0d5; color: #7a5208; }
.badge.b-bajo { background: #e6eef9; color: #1d4f91; }
.badge.b-suspendido, .badge.b-cancelado, .badge.b-sin, .badge.b-over { background: #f8e1e1; color: #8c1f1f; }
.side-detail { border: 1px solid var(--brand); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: color-mix(in srgb, var(--brand) 4%, #fff); }
.side-detail h3 { font-size: 15px; margin-bottom: 4px; }
.side-detail p { margin: 4px 0; font-size: 13px; color: var(--ink-2); }
.side-detail .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.side-detail .stats div { background: #fff; border-radius: 8px; padding: 6px 8px; border: 1px solid var(--line); }
.side-detail .stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.side-detail .stats span { font-size: 11.5px; color: var(--ink-2); }
.side-detail .close { float: right; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--ink-2); line-height: 1; }
.leaflet-popup-content { font: 13px/1.45 "Plus Jakarta Sans", system-ui, sans-serif; margin: 12px 14px; }
.leaflet-popup-content h4 { margin: 0 0 4px; font-size: 14px; }
.leaflet-popup-content p { margin: 3px 0; }
.leaflet-popup-content img { border-radius: 8px; margin-bottom: 6px; width: 100%; max-height: 130px; object-fit: cover; }
.pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,.35); display: grid; place-items: center; }
.pin i { transform: rotate(45deg); font-style: normal; color: #fff; font-size: 12px; font-weight: 800; }
.est-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.zone-label { background: rgba(255,255,255,.88); border: 0; border-radius: 6px; box-shadow: none; font-weight: 700; font-size: 11.5px; color: var(--ink); padding: 2px 6px; }
.zone-label::before { display: none; }

/* ---------- Barras horizontales HTML ---------- */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 36%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 500; }
.hbar .track { height: 14px; background: #f0eee7; border-radius: 4px; position: relative; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; transition: width .5s ease; }
.hbar .fill.alt { background: var(--brand-2); }
.hbar .v { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 64px; text-align: right; }
.hbar .v small { display: block; font-weight: 500; color: var(--ink-2); font-size: 11px; }
.rnt-states { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rnt-states .badge { font-size: 12px; padding: 4px 10px; }

/* ---------- ESCNNA ---------- */
.escnna-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: center; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.mini-stats b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 12px; color: var(--ink-2); }
.mini-stats .ok b { color: var(--good); }
.mini-stats .alert b { color: var(--bad); }

/* ---------- Rutas ---------- */
.rutas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ruta { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; border-top: 4px solid var(--c, var(--brand)); }
.ruta:hover { box-shadow: var(--shadow); }
.ruta h3 { font-size: 15px; margin-bottom: 6px; }
.ruta p { font-size: 13px; color: var(--ink-2); margin: 6px 0; }
.ruta .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ruta .stops { font-size: 12px; color: var(--ink-2); }

/* ---------- Directorio ---------- */
#dir-q { width: 280px; max-width: 100%; }
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: #f4f2eb; text-align: left; font-weight: 700; padding: 9px 12px; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; z-index: 1; }
.tbl td { padding: 9px 12px; border-top: 1px solid var(--grid); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: #faf9f5; }

/* ---------- Galería ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chips button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.gallery button { border: 0; padding: 0; background: #eee; border-radius: 10px; overflow: hidden; cursor: zoom-in; aspect-ratio: 4 / 3; position: relative; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.gallery button:hover img { transform: scale(1.04); }
.gallery .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 11.5px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible; }
.lightbox::backdrop { background: rgba(10,14,10,.88); }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 90vw; max-height: 82vh; border-radius: 8px; display: block; margin: 0 auto; }
.lightbox figcaption { color: #fff; margin-top: 10px; font-size: 14px; }
.lb-close { position: fixed; top: 14px; right: 18px; border: 0; background: rgba(255,255,255,.15); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 24px; cursor: pointer; }
.lb-close.dark { position: absolute; top: 10px; right: 10px; background: #eee; color: #333; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); border: 0; background: rgba(255,255,255,.15); color: #fff; width: 46px; height: 64px; border-radius: 10px; font-size: 34px; cursor: pointer; }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
.table-dialog { border: 0; border-radius: 14px; padding: 22px; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.table-dialog::backdrop { background: rgba(0,0,0,.4); }
.table-dialog h3 { margin-bottom: 12px; }

/* ---------- Pie ---------- */
.foot { background: color-mix(in srgb, var(--brand) 88%, #000); color: rgba(255,255,255,.9); font-size: 13px; }
.foot-inner { display: flex; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.foot a { color: #fff; font-weight: 600; margin-left: 14px; }

/* ---------- Landing ---------- */
.mun-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding: 24px 20px; }
.mun-card { display: flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.mun-card img { width: 72px; height: 72px; object-fit: contain; }
.mun-card span { color: var(--ink-2); font-size: 13px; }

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

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-layout { grid-template-columns: 1fr; }
  .map-side { max-height: 420px; }
}
@media (max-width: 820px) {
  .grid-2, .escnna-grid { grid-template-columns: 1fr; }
  .hero-inner { flex-wrap: wrap; }
  .hero-partners { width: 100%; max-width: none; justify-content: flex-start; }
  .hero-partners img, .hero-partners.many img { height: 46px; max-width: 120px; }
  .filters { position: static; }
  .filters-note { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .kpis { grid-template-columns: 1fr; }
  .hero-logo { width: 64px; height: 64px; }
  #map { height: 420px; }
  .layer-chips { left: 10px; top: auto; bottom: 64px; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: minmax(90px, 40%) minmax(0, 1fr) auto; }
}
