:root {
  /* Marca "luxe" (ver static/img/logo-icon.png y el resto de los ícones):
     mismos roles que ya tenía la interfaz (navy = interactivo primario,
     rojo = alerta/negativo/hover) pero con los hex exactos de la marca
     en vez de los aproximados que había antes. */
  --tinta: #06090f;
  --marca: #1f2e7a; /* navy Chicago — antes #10245c */
  --marca-oscura: #16215c;
  --acento: #e3120b; /* rojo Economist — antes #b91c1c */
  --verde: #15803d;
  --amarillo: #a16207;
  --rojo: #e3120b;
  --gris-borde: #e2e2e2;
  --gris-fondo: #f7f7f5;
  --gris-texto: #595959;
  --texto: var(--tinta);
  --azul: var(--marca); /* alias histórico: mismo color, ahora es el acento de marca */
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: var(--gris-fondo);
  color: var(--texto);
}

a { color: var(--marca); }

/* --- Encabezado en dos franjas, al estilo de una portada editorial --- */
header.topbar {
  background: white;
  border-bottom: 1px solid var(--gris-borde);
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
}

.masthead-top .logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.masthead-top .logo .logo-icono {
  width: 34px;
  height: 34px;
  display: block;
}
.masthead-top .logo .logo-texto {
  color: var(--tinta);
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 700;
  font-size: 1.3rem;
}
.masthead-top .logo:hover .logo-texto { color: var(--acento); }

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--gris-texto);
  white-space: nowrap;
}
.masthead-actions .enlace-salir {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--marca); text-decoration: underline; font-size: 0.85rem; font-family: inherit;
}

/* Switch UYU/USD: dos botones de un mismo <form>, cada uno un submit con su
   propio value="moneda" — no hace falta JS, cualquiera de los dos recarga
   la página actual (ver el <input type="hidden" name="next">) ya convertida
   a la moneda elegida. */
.switch-moneda {
  display: inline-flex;
  border: 1px solid var(--gris-borde);
  border-radius: 4px;
  overflow: hidden;
}
.switch-moneda button {
  background: white;
  border: none;
  color: var(--gris-texto);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.02em;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}
.switch-moneda button + button { border-left: 1px solid var(--gris-borde); }
.switch-moneda button:hover { background: var(--gris-fondo); }
.switch-moneda button.activo { background: var(--marca); color: white; }

header.topbar nav {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  border-top: 1px solid var(--gris-borde);
}
header.topbar nav a {
  color: var(--tinta);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.65rem 0;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
header.topbar nav a:hover { border-bottom-color: var(--acento); }
header.topbar nav a.activo { border-bottom-color: var(--marca); font-weight: 700; }

/* Grupo de pestañas con submenú (ej. "Personal") — dropdown en CSS puro,
   sin JS: se abre con :hover (mouse) y :focus-within (teclado). */
.nav-grupo { position: relative; }
.nav-grupo-toggle {
  display: inline-block;
  color: var(--tinta);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.65rem 0;
  cursor: default;
  border-bottom: 2px solid transparent;
}
.nav-grupo-toggle.activo { border-bottom-color: var(--marca); font-weight: 700; }
.nav-grupo:hover .nav-grupo-toggle,
.nav-grupo:focus-within .nav-grupo-toggle { border-bottom-color: var(--acento); }

.nav-submenu {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: white;
  border: 1px solid var(--gris-borde);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  z-index: 20;
}
.nav-grupo:hover .nav-submenu,
.nav-grupo:focus-within .nav-submenu { display: flex; }
.nav-submenu a {
  padding: 0.55rem 0.85rem;
  border-bottom: none;
  border-left: 2px solid transparent;
}
.nav-submenu a:hover { background: var(--gris-fondo); border-bottom: none; border-left-color: var(--acento); }
.nav-submenu a.activo { border-left-color: var(--marca); font-weight: 700; background: var(--gris-fondo); }

main {
  max-width: 1080px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 { font-family: Georgia, "Times New Roman", Times, serif; font-size: 1.7rem; font-weight: 700; margin-bottom: 0.25rem; }
h2 { font-family: Georgia, "Times New Roman", Times, serif; font-size: 1.25rem; font-weight: 700; }
.subtitulo { color: var(--gris-texto); margin-top: 0; margin-bottom: 1.5rem; }

/* Página de acceso (login): tarjeta centrada, sin el ruido del resto de la app */
.pagina-acceso {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}
.pagina-acceso-tarjeta {
  width: 100%;
  max-width: 380px;
}
.pagina-acceso-tarjeta h1 { font-size: 1.4rem; }
.pagina-acceso-tarjeta form button { width: 100%; margin-top: 0.5rem; }

/* --- Lockup de marca (ícono + wordmark + tagline) para momentos tipo
   "portada" — hoy solo el login, ver static/img/logo-icon.png --- */
.lockup {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--marca);
}
.lockup-icono { width: 48px; height: 48px; display: block; border-radius: 6px; }
.lockup-wordmark {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--tinta);
  line-height: 1.15;
}
.lockup-tagline { font-size: 0.8rem; color: var(--gris-texto); margin-top: 0.1rem; }

.tarjeta {
  background: white;
  border: 1px solid var(--gris-borde);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

form .campo { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
label { font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--gris-borde);
  border-radius: 3px;
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: 1px; }

.fila { display: flex; gap: 1rem; flex-wrap: wrap; }
.fila .campo { flex: 1; min-width: 180px; }

button, .boton {
  background: var(--marca);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 3px;
  font-size: 1rem;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}
button:hover, .boton:hover { background: var(--marca-oscura); }

.ayuda { font-size: 0.8rem; color: var(--gris-texto); }
.error { color: var(--rojo); font-size: 0.85rem; margin: 0; }
.mensaje-exito { background: #dcfce7; border: 1px solid #86efac; color: #166534; padding: 0.75rem 1rem; border-radius: 3px; margin-bottom: 1rem; }
.mensaje-alerta { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; padding: 0.75rem 1rem; border-radius: 3px; margin-bottom: 1rem; }
.mensaje-error { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 0.75rem 1rem; border-radius: 3px; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--gris-borde); }
th { background: var(--gris-fondo); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.semaforo { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.semaforo.VERDE { background: var(--verde); }
.semaforo.AMARILLO { background: var(--amarillo); }
.semaforo.ROJO { background: var(--rojo); }
.semaforo.SIN_PRESUPUESTO { background: #9ca3af; }

.fila-partida { font-weight: 600; background: var(--gris-fondo); }
.negativo { color: var(--rojo); }
.positivo { color: var(--verde); }

/* Árbol WBS expandible (details/summary nativo, sin JS) */
details.nivel1 { margin-bottom: 0.75rem; }
details.nivel1 > summary { font-family: Georgia, "Times New Roman", Times, serif; font-size: 1.05rem; font-weight: 700; cursor: pointer; padding: 0.5rem 0; }
details.nivel2 { margin: 0.25rem 0 0.25rem 1.25rem; }
details.nivel2 > summary { font-weight: 600; cursor: pointer; padding: 0.35rem 0; color: #334155; }
summary::-webkit-details-marker { color: var(--marca); }
summary { list-style-position: outside; }

/* Tarjetas de estadística del dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: white; border: 1px solid var(--gris-borde); padding: 1.1rem 1.25rem; }
.stat-tile .etiqueta { font-size: 0.75rem; color: var(--gris-texto); margin: 0 0 0.35rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .valor { font-size: 1.6rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.stat-tile .valor.positivo { color: var(--verde); }
.stat-tile .valor.negativo { color: var(--rojo); }

.toggle-formato { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; }
.toggle-formato label { font-size: 0.85rem; color: var(--gris-texto); }

.lista-reportes { display: flex; flex-direction: column; gap: 1rem; }
.lista-reportes .item { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; border-bottom: 1px solid var(--gris-borde); }
.lista-reportes .item:last-child { border-bottom: none; padding-bottom: 0; }
.botones-descarga a { margin-left: 0.5rem; }
.filtros { display: flex; gap: 0.75rem; margin-bottom: 1rem; align-items: flex-end; }

/* --- Gráficos SVG generados en el servidor (ver dashboard/graficos.py) --- */
/* Acotado a role="img" (como marcan estos SVG en sus templates) y NO a
   ".tarjeta svg" a secas — esto último capturaba también los SVG internos
   de Leaflet dentro de #mapa-leaflet (que vive en una .tarjeta): forzarles
   width:100%;height:auto pisa el tamaño/posicionamiento en píxeles que
   Leaflet calcula para su propio renderer, rompiendo la posición de los
   polígonos del choropleth y estirando el ícono de bandera de la
   atribución (12x8 real) hasta ocupar buena parte del mapa. */
.tarjeta svg[role="img"] { display: block; width: 100%; height: auto; }
.grafico-titulo { font-family: Georgia, "Times New Roman", Times, serif; font-size: 1.05rem; font-weight: 700; margin: 0 0 0.15rem; }
.grafico-subtitulo { font-size: 0.85rem; color: var(--gris-texto); margin: 0 0 1rem; }
.grafico-etiqueta { font-size: 11px; fill: var(--gris-texto); font-family: -apple-system, "Segoe UI", system-ui, sans-serif; }
.grafico-eje { stroke: var(--gris-borde); stroke-width: 1; }

.pie-pagina { display: flex; justify-content: center; padding: 2rem 1rem; }
.pie-pagina-logo { height: 40px; width: auto; opacity: 0.7; }
.grafico-valor { font-variant-numeric: tabular-nums; font-weight: 600; font-family: -apple-system, "Segoe UI", system-ui, sans-serif; }
