/* ============================================================
   Fuentes self-hosted
   Las descarga scripts/download_assets.py la primera vez. Si por algún
   motivo faltan, los `font-family` con fallback caen a la fuente del
   sistema y la web sigue siendo legible.
   `font-display: swap` evita que el texto se quede invisible mientras
   carga. Tras la 1ª visita el navegador las cachea (Cache-Control
   immutable en /static) y las páginas siguientes ya no parpadean.
   ============================================================ */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/static/fonts/fraunces-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/fraunces-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/fraunces-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/fraunces-600.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-300.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-600.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-300.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-500.woff2') format('woff2');
}

/* ====== DARK (default) ====== */
html[data-theme="dark"] {
  --bg: #0A0E14;
  --bg-2: #0D121A;
  --surface: #10151E;
  --surface-2: #161C28;
  --surface-3: #1C2433;
  --border: #1F2937;
  --border-2: #2A3441;
  --text: #F2EDE2;
  --text-muted: #9BA1AB;
  --text-dim: #5A6371;
  --accent: #B5D17A;
  --accent-deep: #87A559;
  --accent-warm: #E8B86D;
  --accent-cool: #7DAFC9;
  --danger: #E47862;
  --easy: #7DAFC9;
  --moderate: #B5D17A;
  --hard: #E8B86D;
  --very-hard: #E47862;
  --map-bg: #0a0a0a;
  --grid-mask-strength: 0.4;
  --hero-bg-opacity: 0.18;
  --tag-easy-bg: rgba(125,175,201,0.07);
  --tag-easy-border: rgba(125,175,201,0.3);
  --tag-mod-bg: rgba(181,209,122,0.07);
  --tag-mod-border: rgba(181,209,122,0.3);
  --tag-hard-bg: rgba(232,184,109,0.07);
  --tag-hard-border: rgba(232,184,109,0.3);
  --tag-vh-bg: rgba(228,120,98,0.07);
  --tag-vh-border: rgba(228,120,98,0.3);
  --topbar-bg: rgba(10, 14, 20, 0.7);
  --donut-track: var(--surface-2);
  --cal-empty: var(--surface-2);
  --cal-1: rgba(181,209,122,0.18);
  --cal-2: rgba(181,209,122,0.42);
  --cal-3: rgba(181,209,122,0.7);
  --cal-4: var(--accent);
}

/* ====== LIGHT ====== */
html[data-theme="light"] {
  --bg: #FAFAF7;
  --bg-2: #F4F2EA;
  --surface: #FFFFFF;
  --surface-2: #F5F2E9;
  --surface-3: #ECE8DC;
  --border: #E5E1D2;
  --border-2: #D2CCB8;
  --text: #1B2230;
  --text-muted: #5A6371;
  --text-dim: #8E94A0;
  --accent: #6E8847;
  --accent-deep: #4F6630;
  --accent-warm: #B8853F;
  --accent-cool: #4E83A0;
  --danger: #C75A44;
  --easy: #4E83A0;
  --moderate: #6E8847;
  --hard: #B8853F;
  --very-hard: #C75A44;
  --map-bg: #f4f2ea;
  --grid-mask-strength: 0.5;
  --hero-bg-opacity: 0.22;
  --tag-easy-bg: rgba(78,131,160,0.08);
  --tag-easy-border: rgba(78,131,160,0.4);
  --tag-mod-bg: rgba(110,136,71,0.08);
  --tag-mod-border: rgba(110,136,71,0.4);
  --tag-hard-bg: rgba(184,133,63,0.1);
  --tag-hard-border: rgba(184,133,63,0.4);
  --tag-vh-bg: rgba(199,90,68,0.08);
  --tag-vh-border: rgba(199,90,68,0.4);
  --topbar-bg: rgba(250, 250, 247, 0.85);
  --donut-track: #ECE8DC;
  --cal-empty: #F1EDE0;
  --cal-1: rgba(110,136,71,0.18);
  --cal-2: rgba(110,136,71,0.4);
  --cal-3: rgba(110,136,71,0.65);
  --cal-4: var(--accent);
}

:root {
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --serif: 'Fraunces', Georgia, serif;
  /* aliases para analisis.css */
  --font-mono: var(--mono);
  --font-serif: var(--serif);
  /* sombra de tarjeta — definida aquí para que styles.css no dependa de detail.css */
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 12px 40px -16px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; text-decoration: none; }

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  align-items: start;
}

/* ===== Sidebar overlay (móvil) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  /* min-height cubre el viewport; height:100% se estira con el grid
     cuando el contenido principal es más alto que 100vh — evita que
     el sidebar quede cortado en screenshots de página completa. */
  min-height: 100vh;
  height: 100%;
  transition: background-color 0.25s ease, border-color 0.25s ease;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  display: grid; place-items: center;
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: -0.005em;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); border-left-color: var(--border-2); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  border-left-color: var(--accent);
}
.nav-item.active .icon { color: var(--accent); }
.nav-item .icon {
  width: 16px; height: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 16px 12px 6px;
  font-weight: 500;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 12px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-footer-user {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer-version {
  margin-top: 4px;
  color: var(--text-dim);
}

/* ===== Main =====
   flex-column + min-height:100vh permite que el footnote use margin-top:auto
   y quede pegado al fondo cuando el contenido no llena la pantalla. Si hay
   contenido suficiente, el footnote vuelve a colocarse después del último
   bloque sin más. */
.main {
  padding: 0;
  /* `overflow-x: clip` (no `hidden`) — `hidden` convierte a `.main` en
     contenedor de scroll en el eje Y por la regla de simetría del spec
     y rompe `position: sticky` de hijos como `.topbar` y `.filter-bar`
     porque `.main` no scrollea (lo hace el body). `clip` recorta sin
     crear contenedor de scroll. */
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Botón hamburguesa — solo visible en móvil */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface); color: var(--text); }
.breadcrumb {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.breadcrumb .sep { color: var(--text-dim); margin: 0 8px; }
.breadcrumb .current { color: var(--text); }
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ctrl {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  height: 32px;
  border-radius: 7px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.ctrl:hover { color: var(--text); border-color: var(--text-dim); }
.ctrl svg { width: 13px; height: 13px; flex-shrink: 0; }

.ctrl-select-wrap {
  position: relative;
  height: 32px;
}
.ctrl-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  height: 32px;
  border-radius: 7px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0 28px 0 32px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 30px;
}
.ctrl-select:hover { color: var(--text); border-color: var(--text-dim); }
.ctrl-select:focus { outline: none; border-color: var(--accent); }
.ctrl-select option {
  background: var(--surface-2);
  color: var(--text);
}
.ctrl-select-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}
.ctrl-select-chev {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.topbar-btn {
  background: transparent;
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.15s;
}
.topbar-btn:hover { background: var(--surface); color: var(--text); }

/* ===== Nombre del usuario logeado en el topbar ===== */
.user-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Chip de rol ===== */
.role-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.role-chip.role-admin {
  color: #c39c00;
  border-color: rgba(195, 156, 0, 0.45);
  background: rgba(195, 156, 0, 0.08);
}
.role-chip.role-user {
  color: var(--accent);
  border-color: rgba(0, 200, 120, 0.4);
  background: rgba(0, 200, 120, 0.08);
}
.role-chip.role-viewer {
  color: var(--text-muted);
}

/* ===== Hero ===== */
.hero {
  padding: 56px 40px 40px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  container-type: inline-size;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: var(--hero-bg-opacity);
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.4s ease;
}
.hero-bg svg {
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 100%;
  height: 240px;
}
.hero-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: var(--grid-mask-strength);
  mask-image: radial-gradient(ellipse 70% 60% at 30% 50%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 30% 50%, #000 0%, transparent 80%);
}
.hero-elev-path {
  transition: opacity 0.6s ease;
}
.hero-elev-path.fading { opacity: 0; }

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 1200px;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--accent);
}
.hero-headline {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 22px;
  color: var(--text-muted);
  letter-spacing: -0.005em;
  margin-bottom: 8px;
  font-style: italic;
}
.hero-number {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(48px, 10vw, 92px);
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.hero-number .unit {
  font-size: 36px;
  color: var(--text-muted);
  font-weight: 300;
  margin-left: 6px;
  letter-spacing: -0.02em;
}
.hero-sub {
  display: flex;
  gap: 32px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14px;
  flex-wrap: wrap;
}
.hero-sub-item { display: flex; align-items: baseline; gap: 8px; }
.hero-sub-item .v {
  font-family: var(--mono);
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hero-sub-item .l {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.hero-route-tag {
  position: absolute;
  bottom: 16px;
  right: 24px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.4s ease;
}
.hero-route-tag::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 8px var(--accent);
}

/* ===== Sections ===== */
.section {
  padding: 40px;
  border-bottom: 1px solid var(--border);
  overflow-x: hidden;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.section-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ===== KPI grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}
.kpi {
  background: var(--surface);
  padding: 22px 22px 20px;
  transition: background 0.2s;
  cursor: default;
  position: relative;
}
.kpi:hover { background: var(--surface-2); }
.kpi-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.kpi-value {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: -0.025em;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 300;
}
.kpi-detail {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.kpi-detail .pos { color: var(--accent); }
.kpi-detail .neg { color: var(--danger); }
.kpi-description {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* ===== Map ===== */
.map-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  isolation: isolate;
}
#map,
#routes-map {
  height: 420px;
  background: var(--map-bg);
  transition: background-color 0.25s ease;
  min-height: 260px;
}
.leaflet-container {
  background: var(--map-bg) !important;
  font-family: var(--sans) !important;
}
.leaflet-popup-content-wrapper {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-2);
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35) !important;
}
.leaflet-popup-tip { background: var(--surface-2) !important; }
.leaflet-popup-close-button { color: var(--text-muted) !important; }
.map-legend {
  display: flex;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  align-items: center;
  flex-wrap: wrap;
}
.legend-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-right: 8px;
}
.legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot::before {
  content: '';
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.legend-dot.easy::before { background: var(--easy); }
.legend-dot.moderate::before { background: var(--moderate); }
.legend-dot.hard::before { background: var(--hard); }
.legend-dot.very-hard::before { background: var(--very-hard); }

/* ===== Charts ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  min-width: 0;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px 20px;
}
.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}
.chart-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.chart-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  font-size: 12.5px;
}
.donut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.donut-row:last-child { border-bottom: none; }
.donut-row .l {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.donut-row .l::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 2px;
  display: inline-block;
  background: var(--c, var(--accent));
}
.donut-row .v {
  font-family: var(--mono);
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ===== Table ===== */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  font-weight: 500;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.name { color: var(--text); font-weight: 500; }
td.name .sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 2px;
  font-family: var(--mono);
}
td.num { font-family: var(--mono); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--mono);
  border: 1px solid;
}
.tag.easy { color: var(--easy); border-color: var(--tag-easy-border); background: var(--tag-easy-bg); }
.tag.moderate { color: var(--moderate); border-color: var(--tag-mod-border); background: var(--tag-mod-bg); }
.tag.hard { color: var(--hard); border-color: var(--tag-hard-border); background: var(--tag-hard-bg); }
.tag.very-hard { color: var(--very-hard); border-color: var(--tag-vh-border); background: var(--tag-vh-bg); }

/* ===== Calendar ===== */
.cal-heatmap {
  display: grid;
  grid-template-columns: 32px repeat(12, 1fr);
  gap: 2px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}
.cal-month {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 0;
}
.cal-row-label { color: var(--text-dim); font-size: 10.5px; }
.cal-cell {
  aspect-ratio: 1;
  max-width: 18px;
  max-height: 18px;
  border-radius: 3px;
  background: var(--cal-empty);
  border: 1px solid var(--border);
  transition: transform 0.15s;
  position: relative;
}
.cal-cell.lvl1 { background: var(--cal-1); border-color: var(--tag-mod-border); }
.cal-cell.lvl2 { background: var(--cal-2); border-color: var(--tag-mod-border); }
.cal-cell.lvl3 { background: var(--cal-3); border-color: var(--accent); }
.cal-cell.lvl4 { background: var(--cal-4); border-color: var(--accent); }
.cal-cell:hover { transform: scale(1.4); z-index: 2; }

.footnote {
  padding: 24px 40px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-family: var(--mono);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-2);
  /* Empuja el footer al fondo cuando el contenido no llena la pantalla.
     Como .main es flex-column con min-height:100vh, este auto absorbe
     todo el espacio sobrante por encima del footnote. */
  margin-top: auto;
}
.footnote .demo-badge {
  color: var(--accent-warm);
  border: 1px solid var(--tag-hard-border);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   RESPONSIVE — tablet (≤ 900px) y móvil (≤ 600px)
   ============================================================ */
@media (max-width: 900px) {
  /* Sidebar: se convierte en drawer lateral */
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    width: 240px;
    height: 100vh;
    transition: left 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.is-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .sidebar-overlay.is-open {
    display: block;
  }
  .sidebar-toggle {
    display: inline-flex;
  }

  /* Topbar */
  .topbar { padding: 12px 20px; }

  /* Hero */
  .hero { padding: 36px 20px 28px; }

  /* Sections */
  .section { padding: 28px 20px; }
  .featured-section { padding: 28px 20px; }
  .routes-section { padding: 28px 20px; }
  .page-head { padding: 32px 20px 20px; }
  .footnote { padding: 18px 20px; }
  .importar-wrap > .tabs,
  .importar-wrap > .tab-panel,
  .importar-wrap > .flash { margin: 0 20px; }

  /* KPIs: 2 columnas */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  /* Charts: apilados */
  .charts-grid { grid-template-columns: 1fr; }

  /* Mapa */
  #map,
  #routes-map { height: 300px; }

  /* Tabla: scroll horizontal */
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }

  /* Featured card */
  .featured-card { grid-template-columns: 1fr; }
  .featured-visual { border-left: none; border-top: 1px solid var(--border); }

  /* Route rows */
  .route-row { grid-template-columns: 40px 1fr 1fr; gap: 14px; }
  .route-elev-wrap, .route-tag-wrap { display: none; }

  /* Filter bar */
  .filter-bar { padding: 12px 20px; flex-wrap: wrap; }

  /* Section head */
  .section-head { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (max-width: 600px) {
  /* KPIs: 1 columna */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  /* Hero sub: wrap */
  .hero-sub { gap: 16px; }

  /* Topbar: ocultar breadcrumb en pantallas muy pequeñas */
  .breadcrumb .sep,
  .breadcrumb .current { display: none; }

  /* Tabs de importar: scroll horizontal */
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .tabs .tab { white-space: nowrap; }

  /* Chips de filtro */
  .pop-chips { gap: 4px; }

  /* Route row: simplificado */
  .route-row { grid-template-columns: 1fr; gap: 8px; padding: 16px; }
  .route-num { display: none; }

  /* Featured stats: 2 columnas */
  .featured-stats { grid-template-columns: repeat(2, 1fr); }
  .featured-stat { border-right: none; border-bottom: 1px dashed var(--border); padding-bottom: 12px; }
  .featured-stat:nth-child(odd) { border-right: 1px dashed var(--border); }
  .featured-stat:last-child, .featured-stat:nth-last-child(2):nth-child(odd) { border-bottom: none; }

  /* Calendario: scroll horizontal */
  #resumen-calendar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-heatmap { min-width: 480px; }
}

/* ===== Importar / Empty states ===== */
.empty {
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted);
}
.empty .icon {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  color: var(--text-dim);
  opacity: 0.6;
}
.empty h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.empty p { margin-bottom: 24px; font-size: 13.5px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 18px;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn.btn-ghost:hover { background: var(--surface-2); filter: none; }

.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: var(--surface-2);
}
.dropzone .icon {
  width: 40px; height: 40px;
  margin: 0 auto 14px;
  color: var(--accent);
}
.dropzone h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 6px;
}
.dropzone p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.dropzone .filelist-wrap {
  margin-top: 16px;
  text-align: left;
  display: block;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.dropzone .filelist-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.dropzone .filelist {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  max-height: 220px;
  overflow-y: auto;
  cursor: default;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.dropzone .filelist::-webkit-scrollbar { width: 8px; }
.dropzone .filelist::-webkit-scrollbar-track { background: transparent; }
.dropzone .filelist::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 4px;
}
.dropzone .filelist:empty { display: none; }
.dropzone .filelist .fname {
  display: block;
  padding: 4px 0;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropzone input[type=file] { display: none; }

/* ===== Importar — contenedor con padding consistente =====
   El resto de páginas envuelven su contenido en secciones con padding 40px
   (.hero, .routes-section, etc.), pero la página de importar usa pestañas
   sueltas. Sin este wrapper el contenido quedaba pegado al sidebar. */
.importar-wrap {
  padding: 0;
}
.importar-wrap > .tabs,
.importar-wrap > .tab-panel,
.importar-wrap > .flash {
  margin: 0 40px;
}
.importar-wrap > .tabs { margin-top: 32px; }
.importar-wrap > .tab-panel { padding-bottom: 40px; }

/* ===== Tabs (página importar) ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding: 0;
}
.tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tabs .tab svg {
  width: 14px;
  height: 14px;
}
.tabs .tab:hover {
  color: var(--text);
}
.tabs .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: tab-in 0.18s ease-out; }
@keyframes tab-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Overlay de procesamiento (importar) ===== */
.import-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.import-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.import-overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 40px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.import-overlay-card .spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 18px;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.import-overlay-title {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text);
  margin-bottom: 6px;
}
.import-overlay-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.import-overlay-card--wide {
  max-width: 540px;
  text-align: left;
}
.import-overlay-card--wide .spinner,
.import-overlay-card--wide .import-overlay-title,
.import-overlay-card--wide .import-overlay-sub {
  text-align: center;
}
.import-overlay-card--wide .import-overlay-title { margin-top: 4px; }

.import-progress {
  margin-top: 16px;
}
.import-progress-bar {
  height: 6px;
  background: var(--border-2, var(--border));
  border-radius: 3px;
  overflow: hidden;
}
.import-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.18s ease;
}
.import-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  gap: 10px;
}
.import-progress-meta > :last-child {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.import-log {
  list-style: none;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg, transparent);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  max-height: 180px;
  overflow-y: auto;
}
.import-log:empty {
  display: none;
}
.import-log-line {
  color: var(--text-muted);
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-log-ok { color: var(--accent); }
.import-log-dup { color: var(--accent-cool, var(--text-dim)); }
.import-log-err { color: var(--very-hard, #E47862); }

.import-overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* ===== Grupos de duplicados (pestaña Duplicados) ===== */
.dup-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.dup-group-hash {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.dup-group-keep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
}
.dup-group-keep a { color: var(--text); text-decoration: none; }
.dup-group-keep a:hover { color: var(--accent); }
.dup-group-remove {
  list-style: none;
  margin: 6px 0 0 0;
  padding: 6px 0 0 0;
  border-top: 1px dashed var(--border);
}
.dup-group-remove li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
  opacity: 0.85;
}
.dup-group-remove a { color: var(--text-dim); text-decoration: none; }
.dup-group-remove a:hover { color: var(--very-hard, #E47862); }
.dup-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}
.dup-tag-keep {
  background: rgba(181, 209, 122, 0.16);
  color: var(--accent);
}
.dup-tag-remove {
  background: rgba(228, 120, 98, 0.14);
  color: var(--very-hard, #E47862);
}

@keyframes spin { to { transform: rotate(360deg); } }

.flash {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  font-family: var(--mono);
}
.flash.ok {
  background: var(--tag-mod-bg);
  border: 1px solid var(--tag-mod-border);
  color: var(--moderate);
}
.flash.err {
  background: var(--tag-vh-bg);
  border: 1px solid var(--tag-vh-border);
  color: var(--very-hard);
}

td .row-actions {
  display: inline-flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
tbody tr:hover .row-actions { opacity: 1; }
.row-detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
tbody tr:hover .row-detail-link { opacity: 1; }
.row-detail-link:hover { color: var(--accent); background: var(--surface-2); }
.route-name-link {
  color: var(--text);
  font-weight: 500;
}
tr.recent-route-row {
  cursor: pointer;
}
tr.recent-route-row:hover td { background: var(--surface-2); }
.table-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  text-align: right;
}
.table-footer-link {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.table-footer-link:hover { color: var(--accent); }
.row-actions button {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.15s;
}
.row-actions button:hover { color: var(--text); border-color: var(--text-dim); }
.row-actions button.danger:hover { color: var(--danger); border-color: var(--danger); }
.editable-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  width: 100%;
  margin: -2px -6px;
}
.editable-name:hover { border-color: var(--border-2); }
.editable-name:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}

/* ========================================================
   RUTAS · estilos del mockup rutas-mockup.html (100% fiel)
   ======================================================== */

/* ===== Page header ===== */
.page-head {
  padding: 48px 40px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.page-head-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 70% 60% at 80% 50%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 80% 50%, #000 0%, transparent 80%);
  pointer-events: none;
}
.page-head-content { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 24px; }
.page-eyebrow {
  font-family: var(--mono);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.page-eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--accent); }
.page-title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(32px, 7vw, 56px); line-height: 1; letter-spacing: -0.03em;
  margin-bottom: 14px;
}
.page-title em { font-style: italic; font-weight: 400; color: var(--accent); }
.page-meta { display: flex; gap: 24px; color: var(--text-muted); font-size: 13.5px; flex-wrap: wrap; }
.page-meta .v { font-family: var(--mono); color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.page-meta .l { color: var(--text-dim); font-size: 12px; margin-left: 4px; }

.view-switch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 3px; }
.view-switch button {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); height: 28px; padding: 0 12px;
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  border-radius: 5px; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.view-switch button:hover { color: var(--text); }
.view-switch button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--border-2); }
.view-switch button svg { width: 13px; height: 13px; }

/* ===== Filter bar (rutas) ===== */
.filter-bar {
  padding: 14px 40px;
  display: flex; gap: 12px; align-items: center; flex-wrap: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  /* Se ancla bajo el topbar (sticky a 0). top=60px ≈ alto del topbar
     (14px + 32px botón + 14px + 1px borde). Si cambia, ajusta aquí.
     z-index 9 = justo por debajo del topbar (10) y por encima del
     contenido de la lista. */
  position: sticky;
  top: 60px;
  z-index: 9;
}
.filter-bar .filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.filter-bar .filter-label {
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Filtros trigger + popover */
.filters-trigger {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text-muted);
  font-family: var(--mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.1em;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filters-trigger:hover { color: var(--text); border-color: var(--text-dim); }
.filters-trigger.open {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface);
}
.filters-trigger svg { width: 13px; height: 13px; }
.filters-trigger .count-badge {
  background: var(--accent);
  color: var(--bg);
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0;
}
.filters-trigger .count-badge.zero { display: none; }

.filters-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 18px 18px 16px;
  box-shadow: 0 16px 48px -12px rgba(0,0,0,0.5),
              0 4px 12px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  gap: 16px;
}
.filters-popover.open { display: flex; }
html[data-theme="light"] .filters-popover {
  box-shadow: 0 16px 48px -12px rgba(0,0,0,0.18),
              0 4px 12px rgba(0,0,0,0.06);
}
.filters-popover::before {
  content: '';
  position: absolute;
  top: -6px; left: 28px;
  width: 11px; height: 11px;
  background: var(--surface);
  border-left: 1px solid var(--border-2);
  border-top: 1px solid var(--border-2);
  transform: rotate(45deg);
}
.pop-section { display: flex; flex-direction: column; gap: 8px; }
.pop-section-label {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--text-dim);
}
.pop-section .ctrl-select-wrap { width: 100%; }
.pop-section .ctrl-select { width: 100%; }
.pop-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-section + .pop-section { padding-top: 14px; border-top: 1px solid var(--border); }
.filter-trigger-wrap { position: relative; }

/* Combobox de región estilo Select2 */
.region-combo { position: relative; }
.region-combo-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s;
  user-select: none;
}
.region-combo-trigger:hover { border-color: var(--text-dim); }
.region-combo-trigger:focus { outline: none; border-color: var(--accent); }
.region-combo[data-open] .region-combo-trigger {
  border-color: var(--accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.region-combo-value {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.region-combo-value.selected { color: var(--text); }
.region-combo-chev {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.region-combo[data-open] .region-combo-chev { transform: rotate(180deg); }

.region-combo-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-top: none;
  border-bottom-left-radius: 7px;
  border-bottom-right-radius: 7px;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.4);
  overflow: hidden;
}
.region-combo-dropdown.open { display: block; }

.region-combo-search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.region-combo-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
}
.region-combo-search::placeholder { color: var(--text-dim); }

.region-combo-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
  padding: 4px 0;
}
.region-combo-list::-webkit-scrollbar { width: 6px; }
.region-combo-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.region-combo-opt {
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.1s, color 0.1s;
  outline: none;
}
.region-combo-opt:hover,
.region-combo-opt:focus { background: var(--surface-2); color: var(--text); }
.region-combo-opt[aria-selected="true"] { color: var(--accent); }
.region-combo-opt[hidden] { display: none; }
.region-combo-count {
  color: var(--text-dim);
  font-size: 10.5px;
  flex-shrink: 0;
}

/* Search */
.search-wrap {
  flex: 1 1 220px;
  position: relative;
  min-width: 200px;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  height: 38px;
  border-radius: 8px;
  padding: 0 38px 0 38px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  transition: all 0.15s;
  outline: none;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:hover { border-color: var(--text-dim); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181,209,122,0.12);
}
.search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none;
  color: var(--text-dim); cursor: pointer;
  width: 22px; height: 22px; border-radius: 5px;
  display: none; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear.visible { display: flex; }
.search-shortcut {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2);
  pointer-events: none;
}
.search-shortcut.hidden { display: none; }

.filter-bar .filter-spacer { flex: 1; min-width: 8px; }
.filter-stats {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.filter-stats .v { color: var(--text); }
.reset-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  height: 38px; padding: 0 12px;
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.1em;
  border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.reset-btn:hover { color: var(--text); border-color: var(--text-dim); }
.reset-btn svg { width: 12px; height: 12px; }
.reset-btn.hidden { display: none; }

/* Compact selects in main filter bar */
.filter-bar .ctrl-select {
  height: 38px;
  border-radius: 8px;
  line-height: 36px;
  font-size: 11.5px;
}
.filter-bar > .filter-group .ctrl-select { padding-right: 30px; }

/* ===== Date range picker ===== */
.date-range-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 10px;
  height: 38px;
  transition: border-color 0.15s;
}
.date-range-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181,209,122,0.10);
}
.ctrl-date {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11.5px;
  outline: none;
  cursor: pointer;
  width: 112px;
  padding: 0;
  line-height: 36px;
  color-scheme: dark;
}
html[data-theme="light"] .ctrl-date { color-scheme: light; }
.ctrl-date::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
  opacity: 0.6;
  margin-left: 2px;
}
.ctrl-date::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.ctrl-date:focus { color: var(--text); }
.date-range-sep {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}
.date-range-clear {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.date-range-clear:hover { color: var(--text); background: var(--surface-2); }
.date-range-clear.hidden { display: none; }

@media (max-width: 1100px) {
  .filter-bar { flex-wrap: wrap; }
}

/* Chips (de dificultad) */
.chip {
  background: transparent; border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: 5px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px;
  cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--text-dim); color: var(--text); }
.chip.active {
  background: var(--surface-2); border-color: var(--text-muted); color: var(--text);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chip.active.diff-easy { border-color: var(--easy); background: var(--tag-easy-bg); color: var(--easy); }
.chip.active.diff-mod  { border-color: var(--moderate); background: var(--tag-mod-bg); color: var(--moderate); }
.chip.active.diff-hard { border-color: var(--hard); background: var(--tag-hard-bg); color: var(--hard); }
.chip.active.diff-vh   { border-color: var(--very-hard); background: var(--tag-vh-bg); color: var(--very-hard); }
.chip.diff-easy .dot { background: var(--easy); }
.chip.diff-mod  .dot { background: var(--moderate); }
.chip.diff-hard .dot { background: var(--hard); }
.chip.diff-vh   .dot { background: var(--very-hard); }

/* ===== Featured card (Última actividad) ===== */
.featured-section { padding: 40px; border-bottom: 1px solid var(--border); overflow-x: hidden; }
.featured-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
}
.featured-content { padding: 32px 36px; display: flex; flex-direction: column; gap: 20px; }
.featured-tagline {
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-warm);
  display: flex; align-items: center; gap: 8px;
}
.featured-tagline::before { content: ''; width: 16px; height: 1px; background: var(--accent-warm); }
.featured-title {
  font-family: var(--serif); font-weight: 300;
  font-size: 38px; line-height: 1.05; letter-spacing: -0.02em;
}
.featured-title .sub {
  display: block;
  font-family: var(--mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim); font-weight: 400;
  margin-top: 8px;
}
.featured-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--border); padding-top: 20px; }
.featured-stat { padding-right: 18px; border-right: 1px dashed var(--border); }
.featured-stat:last-child { border-right: none; }
.featured-stat .l {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim); margin-bottom: 6px;
}
.featured-stat .v {
  font-family: var(--serif); font-weight: 400;
  font-size: 22px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.featured-stat .v .u { font-size: 12px; color: var(--text-muted); margin-left: 2px; font-weight: 300; }
.featured-actions { display: flex; gap: 10px; align-items: center; margin-top: auto; padding-top: 8px; }

.btn-primary {
  background: var(--accent); color: var(--bg);
  border: none; height: 36px; padding: 0 18px;
  border-radius: 7px; font-family: var(--mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.1em; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-primary svg { width: 13px; height: 13px; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-2); height: 36px; padding: 0 14px;
  border-radius: 7px; font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em; cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex; align-items: center;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* Visual de la card destacada — sizing determinista.
   Antes usábamos height:60%/40% en los hijos, pero al re-navegar a /rutas
   estando ya en /rutas el padre todavía no tiene una `height` resuelta
   (solo `min-height`), así que los porcentajes colapsaban a 0 y el mapa
   de Leaflet no podía calcular sus tiles → se superponía con la silueta
   o quedaba en blanco. Con flex-basis fijo en píxeles el layout es
   estable independientemente de cuándo Leaflet llame a invalidateSize(). */
.featured-visual {
  position: relative;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  height: 320px;
  display: flex;
  flex-direction: column;
}
.featured-elev-svg { flex: 0 0 192px; width: 100%; display: block; }
.featured-mini-map { flex: 1 1 auto; min-height: 128px; border-top: 1px solid var(--border); }
#featured-map { width: 100%; height: 100%; background: var(--map-bg); }

/* Rotación dinámica del featured */
#featured-elev-line, #featured-elev-area { transition: opacity 0.45s ease; }
#featured-elev-line.fading, #featured-elev-area.fading { opacity: 0; }
.featured-content .featured-tagline,
.featured-content .featured-title,
.featured-content .featured-stats,
#featured-elev-range, #featured-elev-summary { transition: opacity 0.35s ease; }
.featured-card.fading .featured-tagline,
.featured-card.fading .featured-title,
.featured-card.fading .featured-stats,
.featured-card.fading #featured-elev-range,
.featured-card.fading #featured-elev-summary { opacity: 0.15; }

/* ===== Routes map view ===== */
@media (max-width: 900px) {
  #routes-map { height: 360px; }
}

/* ===== Routes grid (vista cuadrícula) ===== */
.routes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: inherit;
}
.route-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.route-card-elev {
  height: 80px;
  position: relative;
  background: var(--surface-2);
  flex-shrink: 0;
}
.route-card-elev svg {
  width: 100%;
  height: 100%;
  display: block;
}
.route-card-elev-meta {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.route-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.route-card-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.3;
  /* Truncar a 2 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.route-card-meta {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.route-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.route-card-stat .l {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.route-card-stat .v {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .routes-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
}
@media (max-width: 600px) {
  .routes-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .route-card-stats { grid-template-columns: 1fr 1fr; }
  .route-card-stats .route-card-stat:last-child { display: none; }
}

/* ===== Routes list / section ===== */
.routes-section { padding: 40px; border-bottom: 1px solid var(--border); overflow-x: hidden; }
.routes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.route-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 56px 1.2fr 2fr 1fr 120px;
  align-items: center;
  gap: 24px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: inherit;
}
.route-row:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}
.route-row.hidden { display: none; }
.route-num {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 36px; line-height: 1;
  color: var(--text-dim); letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.route-info .name {
  font-family: var(--serif); font-weight: 500;
  font-size: 17px; letter-spacing: -0.01em;
  color: var(--text); margin-bottom: 4px;
}
.route-info .region {
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim);
}
.route-info .date {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-muted); margin-top: 6px;
}
.route-elev-wrap { height: 56px; position: relative; }
.route-elev-svg { width: 100%; height: 100%; }
.route-elev-meta {
  position: absolute; top: 0; right: 0;
  font-family: var(--mono); font-size: 9.5px;
  color: var(--text-dim); letter-spacing: 0.08em;
}
.route-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.route-stat .l {
  font-family: var(--mono); font-size: 9.5px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim); margin-bottom: 2px;
}
.route-stat .v {
  font-family: var(--mono); font-size: 13px;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.route-tag-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.route-arrow {
  color: var(--text-dim);
  transition: transform 0.18s, color 0.18s;
}
.route-row:hover .route-arrow { color: var(--accent); transform: translateX(2px); }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono); font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* Sentinel de scroll infinito */
.routes-sentinel {
  margin-top: 16px;
  padding: 18px;
  text-align: center;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 10px;
  opacity: 0; transition: opacity 0.25s ease;
}
.routes-sentinel.visible { opacity: 1; }
.routes-sentinel .dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin: 0 3px;
  animation: sentinelPulse 1.4s infinite ease-in-out both;
}
.routes-sentinel .dot:nth-child(2) { animation-delay: 0.2s; }
.routes-sentinel .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes sentinelPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* mark de búsqueda */
mark.search-hl {
  background: rgba(181,209,122,0.22);
  color: inherit; padding: 0 2px; border-radius: 2px;
}

/* ============================================================
   SKELETONS / LOADING — patrones reutilizables
   Respetan el lenguaje visual: monospace dim, shimmer sutil
   sobre var(--surface-2) → var(--border).
   ============================================================ */
@keyframes mendi-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--border) 50%,
    var(--surface-2) 100%
  );
  background-size: 800px 100%;
  animation: mendi-shimmer 1.6s linear infinite;
  border-radius: 4px;
  display: block;
}
.skeleton.line { height: 12px; }
.skeleton.line.lg { height: 18px; }
.skeleton.line.sm { height: 9px; }
.skeleton.block { height: 60px; border-radius: 8px; }

/* Overlay de carga sobre contenedores opacos (mapas, tarjetas) */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.loading-overlay.hidden { opacity: 0; }
.loading-overlay .lo-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.loading-overlay .lo-dots {
  display: inline-flex;
  gap: 5px;
}
.loading-overlay .lo-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: sentinelPulse 1.4s infinite ease-in-out both;
}
.loading-overlay .lo-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-overlay .lo-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Skeleton row para listado de rutas (formato compatible con .route-row) */
.route-row-skel {
  display: grid;
  grid-template-columns: 50px 1fr 110px 130px 140px 28px;
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.route-row-skel:last-child { border-bottom: none; }
.route-row-skel .col {
  display: flex; flex-direction: column; gap: 6px;
}

/* Skeleton card para grids de tarjetas (resumen, related) */
.card-skel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 140px;
}

/* Barra de progreso superior — cargas globales (navegacion futura) */
.page-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 10000;
  pointer-events: none;
}
.page-progress::before {
  content: "";
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  transition: width 0.3s ease;
}
.page-progress.active::before { width: 70%; }
.page-progress.done::before { width: 100%; opacity: 0; transition: width 0.2s ease, opacity 0.4s ease 0.2s; }

@media (max-width: 1180px) {
  .featured-card { grid-template-columns: 1fr; }
  .featured-visual { border-left: none; border-top: 1px solid var(--border); }
  .route-row { grid-template-columns: 40px 1fr 1fr; gap: 16px; }
  .route-elev-wrap, .route-tag-wrap { display: none; }
}

@media (max-width: 1100px) {
  .filter-bar { flex-wrap: wrap; }
}

/* ============================================================
   Admin · gestión de usuarios (/admin/usuarios)
   ============================================================ */
.admin-wrap { padding: 0; }

.page-head-content { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: 8px; align-items: center; }

.muted { color: var(--text-muted); }

/* Flash con sufijos -ok / -err / -info usados por admin_usuarios.js */
.flash-ok {
  background: var(--tag-mod-bg);
  border: 1px solid var(--tag-mod-border);
  color: var(--moderate);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  font-family: var(--mono);
}
.flash-err {
  background: var(--tag-vh-bg);
  border: 1px solid var(--tag-vh-border);
  color: var(--very-hard);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  font-family: var(--mono);
}
.flash-info {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  font-family: var(--mono);
}

/* Tabla CSS grid para que las celdas alineen perfecto sin <table> */
.users-table {
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.users-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 0.9fr 0.9fr 0.9fr 1.1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.users-row:last-child { border-bottom: none; }
.users-row .cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.users-row .cell.email { font-family: var(--mono); color: var(--text); white-space: nowrap; }
.users-row .cell.name { color: var(--text-dim); }
.users-name-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: border-color 0.12s, background 0.12s;
}
.users-name-input::placeholder { color: var(--text-muted); }
.users-name-input:hover { border-color: var(--border); }
.users-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.users-name-input:disabled { opacity: 0.5; cursor: wait; }
.users-name-input.is-saving { border-color: var(--text-dim); }
.users-name-input.is-error { border-color: var(--danger); }
.users-row .cell.login { font-family: var(--mono); color: var(--text-muted); font-size: 12px; }
.users-row .cell.actions { display: flex; gap: 6px; justify-content: flex-end; }

.users-head {
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.users-head .cell { text-overflow: clip; }

.users-self {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}

.users-role-select {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.users-role-select:hover { border-color: var(--text-dim); }
.users-role-select:focus { outline: none; border-color: var(--accent); }
.users-role-select:disabled { opacity: 0.5; cursor: wait; }

.users-state-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.12s, color 0.12s;
}
.users-state-toggle:hover { border-color: var(--text-dim); }
.users-state-toggle:disabled { opacity: 0.5; cursor: wait; }
.users-state-toggle .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.users-state-toggle.active { color: var(--accent); border-color: var(--tag-mod-border); }
.users-state-toggle.inactive { color: var(--text-muted); }

/* Etiqueta encima de inputs en los modales (admin) */
.modal-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 12px 0 6px;
}
.modal-label:first-child { margin-top: 0; }

/* Hint en estado vacío de /rutas para viewers */
.empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}
.empty-hint .role-chip { vertical-align: middle; }

@media (max-width: 900px) {
  .users-row { grid-template-columns: 1fr 1fr; row-gap: 6px; }
  .users-head { display: none; }
  .users-row .cell.actions { justify-content: flex-start; }
}

/* ===== Leaflet layer control — estilos de la app ===== */
.leaflet-control-layers {
  background: var(--surface) !important;
  border: 1px solid var(--border-2) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.4) !important;
  color: var(--text) !important;
}
.leaflet-control-layers-toggle {
  background-color: var(--surface) !important;
  border-radius: 7px !important;
}
.leaflet-control-layers-expanded {
  padding: 8px 12px !important;
  font-family: var(--mono) !important;
  font-size: 11.5px !important;
}
.leaflet-control-layers label {
  color: var(--text-muted) !important;
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  padding: 3px 0 !important;
  cursor: pointer !important;
  transition: color 0.12s !important;
}
.leaflet-control-layers label:hover { color: var(--text) !important; }
.leaflet-control-layers input[type="radio"] { accent-color: var(--accent); }
