/* ───────── Semáforo Colombia · estilos (mobile-first) ───────── */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #121614;
  --muted: #5f6762;
  --line: #dfe3dd;
  --verde: #16a34a;
  --amarillo: #d97706;
  --rojo: #dc2626;
  --off: #d4d8d2;
  --accent: #16a34a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f0d;
    --surface: #131816;
    --surface-2: #1b211e;
    --text: #eef2ef;
    --muted: #8d978f;
    --line: #232b27;
    --verde: #22c55e;
    --amarillo: #f59e0b;
    --rojo: #ef4444;
    --off: #2a322e;
    --accent: #22c55e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button { font: inherit; color: inherit; touch-action: manipulation; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ───── Header ───── */
.top { display: flex; align-items: center; justify-content: space-between; height: 52px; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-light { display: inline-flex; flex-direction: column; gap: 2px; padding: 4px 3px; background: var(--text); border-radius: 6px; }
.brand-light i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.brand-light i:nth-child(1) { background: var(--rojo); }
.brand-light i:nth-child(2) { background: var(--amarillo); }
.brand-light i:nth-child(3) { background: var(--verde); }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; line-height: 1; }
.brand-name small { display: block; font-weight: 500; font-size: 10px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.top-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.btn-ghost { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; text-decoration: none; font-weight: 600; }
.hide-sm { display: none; }
@media (min-width: 600px) { .hide-sm { display: inline; } .top-meta { font-size: 12px; } }

/* Barra de ciudades (fija) */
.cities-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.cities-bar.stuck { border-bottom-color: var(--line); }
.cities { display: flex; gap: 8px; overflow-x: auto; padding-top: 8px; padding-bottom: 10px; scrollbar-width: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.cities::-webkit-scrollbar { display: none; }
.city {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px; scroll-snap-align: start;
  min-height: 40px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 0 12px 0 11px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.city .mono { font-size: 12px; color: var(--muted); font-weight: 500; }
.city[aria-current="true"] { border-color: var(--text); background: var(--text); color: var(--bg); }
.city[aria-current="true"] .mono { color: inherit; opacity: .7; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.verde { background: var(--verde); }
.dot.amarillo { background: var(--amarillo); }
.dot.rojo { background: var(--rojo); }
.ring { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #a855f7; }

/* ───── Hero ───── */
main { padding-top: 6px; padding-bottom: 24px; }
.hero { display: grid; gap: 10px; grid-template-columns: 1fr; }

.status { padding: 16px 18px 14px; }
.status-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0; font-size: 14px; color: var(--muted); font-weight: 500; }
.light { display: flex; gap: 6px; padding: 6px 8px; background: #0d100f; border-radius: 999px; flex: none; }
.light i { width: 14px; height: 14px; border-radius: 50%; background: #2a302d; transition: background .4s, box-shadow .4s; }
.light[data-level="rojo"] i:nth-child(1) { background: var(--rojo); box-shadow: 0 0 12px var(--rojo); }
.light[data-level="amarillo"] i:nth-child(2) { background: var(--amarillo); box-shadow: 0 0 12px var(--amarillo); }
.light[data-level="verde"] i:nth-child(3) { background: var(--verde); box-shadow: 0 0 12px var(--verde); }

.status-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 6px; }
.status h1 { margin: 0; font-size: 46px; line-height: 1; letter-spacing: -.04em; font-weight: 800; }
.status h1 .lvl-verde { color: var(--verde); }
.status h1 .lvl-amarillo { color: var(--amarillo); }
.status h1 .lvl-rojo { color: var(--rojo); }
.score { text-align: right; white-space: nowrap; }
.score b { font: 700 30px/1 "JetBrains Mono", monospace; letter-spacing: -.04em; }
.score small { color: var(--muted); font-size: 12px; margin-left: 2px; }
.lvl-text { margin: 4px 0 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.summary { margin: 8px 0 12px; font-size: 15px; line-height: 1.45; }
.status-actions { display: flex; align-items: center; gap: 14px; }
.share { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; cursor: pointer; }
.link { background: none; border: 0; padding: 8px 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { padding: 12px 14px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi .k-label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi .k-value { font: 700 26px/1.15 "JetBrains Mono", monospace; letter-spacing: -.03em; white-space: nowrap; }
.kpi .k-value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .k-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .bar { height: 4px; background: var(--surface-2); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.kpi .bar span { display: block; height: 100%; border-radius: 4px; }

.map { position: relative; overflow: hidden; height: 260px; }
#map { position: absolute; inset: 0; }
.map-legend { position: absolute; left: 8px; top: 8px; display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px; max-width: calc(100% - 60px); }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.marker { display: grid; place-items: center; cursor: pointer; padding: 6px; }
.marker b { display: grid; grid-auto-flow: column; place-items: center; min-width: 34px; height: 26px; padding: 0 7px; border-radius: 999px; font: 700 12px/1 "JetBrains Mono", monospace; color: #fff; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.marker b .lbl { margin-right: 5px; opacity: .85; }
.map.far .marker b .lbl { display: none; }
.map.far .marker b { min-width: 30px; height: 24px; padding: 0 5px; font-size: 11px; }
.marker.active b { transform: scale(1.15); border-color: #fff; }
.maplibregl-popup-content { background: var(--surface); color: var(--text); border-radius: 10px; font: 13px/1.4 Inter, sans-serif; padding: 10px 12px; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-cooperative-gesture-screen { font: 600 15px/1.4 Inter, sans-serif; }

/* ───── Panel / Tabs ───── */
.panel { margin-top: 10px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 5px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-radius: 11px; min-height: 44px; font-weight: 600; font-size: 15px; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.tab-body { padding: 14px; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

.alerts { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.alert .dot { margin-top: 6px; grid-row: span 2; }
.alert b { display: block; font-size: 15px; }
.alert span { font-size: 13px; color: var(--muted); }
.alert .where { font-size: 12px; grid-column: 2; }
.ok-state { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--verde) 10%, transparent); }

.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

.ranking { display: grid; gap: 2px; }
.rank { display: grid; grid-template-columns: 22px 1fr auto 40px; gap: 10px; align-items: center; min-height: 46px; padding: 0 8px; border-radius: 10px; background: none; border: 0; text-align: left; cursor: pointer; }
.rank:active, .rank:hover { background: var(--surface-2); }
.rank .mono { font-size: 14px; text-align: right; }

.hours { display: grid; grid-auto-flow: column; grid-auto-columns: 58px; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; scroll-snap-type: x proximity; }
.hours::-webkit-scrollbar { display: none; }
.hour { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--surface-2); font-size: 12px; scroll-snap-align: start; }
.hour b { display: block; font: 700 15px "JetBrains Mono", monospace; margin: 2px 0; }
.hour .p { color: #3b82f6; font-weight: 600; }

.news { display: grid; }
.news a { display: grid; grid-template-columns: 1fr 76px; gap: 12px; padding: 12px 2px; text-decoration: none; border-bottom: 1px solid var(--line); }
.news a:last-child { border-bottom: 0; }
.news a.noimg { grid-template-columns: 1fr; }
.news b { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.news img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }

.grid-data { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.data-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.data-card .k-label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.data-card .big { font: 700 24px/1.2 "JetBrains Mono", monospace; letter-spacing: -.03em; margin: 4px 0; }
.data-card .delta { font-size: 12px; font-weight: 600; }
.up { color: var(--rojo); } .down { color: var(--verde); }
.spark { width: 100%; height: 44px; display: block; margin-top: 6px; }

.forecast { width: 100%; border-collapse: collapse; font-size: 14px; }
.forecast td { padding: 11px 4px; border-bottom: 1px solid var(--line); }
.forecast td:last-child { text-align: right; font-family: "JetBrains Mono", monospace; white-space: nowrap; }
.forecast .cond { color: var(--muted); font-size: 13px; }

.quakes { width: 100%; border-collapse: collapse; font-size: 13px; }
.quakes td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.quakes td:first-child { font: 700 13px "JetBrains Mono", monospace; white-space: nowrap; }
.quakes a { text-decoration: none; }

/* Noticias: filtros, etiquetas y botón "ver todas" */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: -2px -14px 6px; padding: 2px 14px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] span { color: inherit; opacity: .7; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 6px; margin-bottom: 5px; background: var(--surface-2); color: var(--muted); }
.pill.urgent { background: var(--rojo); color: #fff; }
.pill.cat-servicios, .pill.cat-clima { background: color-mix(in srgb, #3b82f6 16%, transparent); color: #3b82f6; }
.pill.cat-seguridad { background: color-mix(in srgb, var(--rojo) 14%, transparent); color: var(--rojo); }
.pill.cat-movilidad { background: color-mix(in srgb, var(--amarillo) 16%, transparent); color: var(--amarillo); }
.pill.cat-salud { background: color-mix(in srgb, var(--verde) 14%, transparent); color: var(--verde); }
.more { width: 100%; min-height: 44px; margin-top: 8px; border: 1px solid var(--line); background: none; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; }
.more:active { background: var(--surface-2); }

/* ───── Footer / dialog / toast ───── */
.foot { padding-top: 4px; padding-bottom: 36px; font-size: 12.5px; }
.foot p { margin: 0 0 6px; max-width: 80ch; }
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); max-width: 440px; width: calc(100% - 24px); padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.02em; }
dialog ul { padding-left: 18px; margin: 8px 0 12px; }
dialog li { margin: 5px 0; }
.levels { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.levels span { display: inline-flex; gap: 6px; align-items: center; }
.btn { width: 100%; min-height: 46px; background: var(--text); color: var(--bg); border: 0; border-radius: 12px; font-weight: 600; cursor: pointer; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

/* ───── Skeleton ───── */
.skeleton { display: inline-block; height: .9em; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
.w60 { width: 60%; } .w90 { width: 90%; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }

/* ───── Pantallas grandes ───── */
@media (min-width: 600px) {
  .chips { margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; }
  .status { padding: 22px 24px 18px; }
  .status h1 { font-size: 56px; }
  .score b { font-size: 36px; }
  .light { gap: 8px; padding: 8px 10px; }
  .light i { width: 18px; height: 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px 16px; }
  .map { height: 340px; }
  .tabs { display: flex; }
  .tabs button { flex: 0 1 150px; }
  .tab-body { padding: 18px; }
  .alert { grid-template-columns: auto 1fr auto; }
  .alert .dot { grid-row: auto; }
  .alert .where { grid-column: auto; white-space: nowrap; }
}
@media (min-width: 960px) {
  main { padding-top: 12px; }
  .hero { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; gap: 12px; }
  .status { grid-column: 1; grid-row: 1; }
  .kpis { grid-column: 1; grid-row: 2; }
  .map { grid-column: 2; grid-row: 1 / span 2; height: auto; min-height: 460px; }
  .panel { margin-top: 12px; }
}
