:root {
  --verde: #1B4D3E;
  --verde-2: #2E6B57;
  --fondo: #F4F7F5;
  --tarjeta: #FFFFFF;
  --texto: #1D2B26;
  --texto-suave: #4A5A53;
  --borde: #CBD8D1;
  --ambar: #C98A1B;
  --ambar-fondo: #FBF1DA;
  --ambar-texto: #5C3A00;
  --rojo: #B3261E;
  --rojo-fondo: #FCE9E7;
  --ok-fondo: #E1F1E8;
  --radio: 12px;
  --alto-tab: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--texto);
  background: var(--fondo);
  min-height: 100vh;
}

:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
h1:focus { outline: none; }
.saltar {
  position: absolute; left: -999px; top: 0; background: #fff; color: var(--verde);
  padding: .75rem 1rem; z-index: 100; font-weight: 700;
}
.saltar:focus { left: 0; }

/* Banner y cabecera */
.banner-demo {
  position: sticky; top: 0; z-index: 50;
  background: var(--ambar-fondo); color: var(--ambar-texto);
  border-bottom: 2px solid var(--ambar);
  text-align: center; font-weight: 700; font-size: .85rem;
  padding: .4rem .75rem;
}
.cabecera {
  background: var(--verde); color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .6rem 1rem;
}
.cabecera-izq { display: flex; align-items: center; gap: .75rem; }
.volver {
  color: #fff; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.5); border-radius: 999px;
  font: inherit; font-size: .95rem; font-weight: 600; min-height: 44px; padding: 0 .9rem; cursor: pointer;
}
.volver:hover { background: rgba(255,255,255,.28); }
.volver[hidden] { display: none; }
.cabecera :focus-visible { outline-color: #fff; }
.marca { color: #fff; text-decoration: none; display: flex; flex-direction: column; min-height: 44px; justify-content: center; }
.marca-nombre { font-size: 1.15rem; font-weight: 700; }
.marca-sub { font-size: .8rem; opacity: .9; }
.cabecera-nav { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; }
.cabecera-nav a, .cabecera-nav button {
  color: #fff; background: transparent; border: 0; font: inherit; font-size: .9rem;
  text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0 .25rem;
  display: inline-flex; align-items: center;
}

main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(var(--alto-tab) + 2rem); }
main.sin-tabs { padding-bottom: 2rem; }
.cargando-inicial { color: var(--texto-suave); }

h1 { font-size: 1.5rem; margin: .5rem 0 1rem; color: var(--verde); line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; color: var(--verde); }
h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
p { margin: .25rem 0 .75rem; }
.suave { color: var(--texto-suave); font-size: .92rem; }
.pequeno { font-size: .85rem; }

/* Tarjetas */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1rem; margin-bottom: 1rem;
}
.tarjeta.destacada { border: 2px solid var(--ambar); background: var(--ambar-fondo); color: var(--ambar-texto); }
.tarjeta.destacada h2 { color: var(--ambar-texto); }
.tarjeta.error { border-color: var(--rojo); background: var(--rojo-fondo); }
.tarjeta.ok { border-color: var(--verde-2); background: var(--ok-fondo); }

/* Chips */
.chip {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 700;
  border: 1px solid transparent; vertical-align: middle;
}
.chip.ok { background: var(--ok-fondo); color: var(--verde); border-color: var(--verde-2); }
.chip.aviso { background: var(--ambar-fondo); color: var(--ambar-texto); border-color: var(--ambar); }
.chip.error { background: var(--rojo-fondo); color: var(--rojo); border-color: var(--rojo); }
.chip.neutro { background: #E8EEEA; color: var(--texto); border-color: var(--borde); }

/* Botones */
.boton, button.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; min-width: 44px; padding: .6rem 1.1rem;
  background: var(--verde); color: #fff; border: 2px solid var(--verde); border-radius: 10px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.boton:hover { background: var(--verde-2); border-color: var(--verde-2); }
.boton.secundario { background: #fff; color: var(--verde); }
.boton.secundario:hover { background: var(--ok-fondo); }
.boton.ambar { background: var(--ambar-texto); border-color: var(--ambar-texto); color: #fff; }
.boton[disabled], .boton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.boton.bloque { display: flex; width: 100%; }
.acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.enlace { color: var(--verde); font-weight: 600; }

/* Formularios */
label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%; min-height: 48px; padding: .5rem .75rem; font: inherit;
  border: 2px solid #7A8C84; border-radius: 10px; background: #fff; color: var(--texto);
}
.fila-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.fila-form > div { flex: 1 1 180px; }
.fila-form label { margin-top: 0; }
.msg-error { color: var(--rojo); font-weight: 600; margin: .5rem 0; }
.demo-usuarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-top: .5rem; }
.demo-usuarios .boton { flex-direction: column; align-items: flex-start; gap: 0; font-size: .92rem; }
.demo-usuarios small { font-weight: 400; }

/* Listas de datos */
dl.datos { margin: 0; display: grid; grid-template-columns: 1fr; gap: .1rem; }
dl.datos dt { color: var(--texto-suave); font-size: .88rem; margin-top: .6rem; }
dl.datos dd { margin: 0; font-weight: 600; word-break: break-word; }
@media (min-width: 560px) {
  dl.datos { grid-template-columns: minmax(180px, 38%) 1fr; column-gap: 1rem; }
  dl.datos dt { margin-top: 0; padding: .4rem 0; border-bottom: 1px solid #E3EAE6; }
  dl.datos dd { padding: .4rem 0; border-bottom: 1px solid #E3EAE6; }
}
.monto-grande { font-size: 2rem; font-weight: 800; color: var(--verde); line-height: 1.2; }
.cifra { font-size: 1.8rem; font-weight: 800; color: var(--verde); }

/* Barra de índice */
.barra { position: relative; height: 18px; background: #E3EAE6; border-radius: 9px; margin: 1.4rem 0 .4rem; overflow: visible; }
.barra-relleno { height: 100%; border-radius: 9px; background: var(--verde-2); transition: width .4s ease; }
.barra.alerta .barra-relleno { background: var(--ambar); }
.barra.evento .barra-relleno { background: var(--rojo); }
.barra-umbral { position: absolute; top: -6px; bottom: -6px; width: 3px; background: var(--texto); }
.barra-umbral span { position: absolute; top: -1.15rem; left: 50%; transform: translateX(-50%); font-size: .75rem; white-space: nowrap; font-weight: 700; }
.barra-leyenda { display: flex; justify-content: space-between; font-size: .8rem; color: var(--texto-suave); }

/* Tablas */
.tabla-scroll { overflow-x: auto; max-height: 360px; overflow-y: auto; border: 1px solid var(--borde); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #E3EAE6; vertical-align: top; }
th { background: #EAF0ED; position: sticky; top: 0; }
.hash { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: .78rem; word-break: break-all; background: #EEF3F0; padding: .1rem .3rem; border-radius: 4px; }

/* Pasos */
ol.pasos { list-style: none; margin: 0; padding: 0; }
ol.pasos li { display: grid; grid-template-columns: 2.2rem 1fr; gap: .6rem; padding: .75rem 0; border-bottom: 1px solid #E3EAE6; }
ol.pasos li:last-child { border-bottom: 0; }
.paso-num {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: #E8EEEA; color: var(--texto); border: 2px solid var(--borde);
}
.paso-hecho .paso-num { background: var(--verde); color: #fff; border-color: var(--verde); }
.paso-en_curso .paso-num { background: var(--ambar-fondo); color: var(--ambar-texto); border-color: var(--ambar); }
.paso-no_aplica .paso-num { background: #fff; border-style: dashed; }
.paso-titulo { font-weight: 700; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.paso-detalle { color: var(--texto-suave); font-size: .92rem; }

/* Gráfico */
.grafico { width: 100%; height: auto; display: block; }
.grafico text { font-size: 11px; fill: #3b4a43; font-family: inherit; }
.grafico .eje { stroke: #9FB1A8; stroke-width: 1; }
.grafico .rejilla { stroke: #E3EAE6; stroke-width: 1; }
.grafico .linea { fill: none; stroke: var(--verde); stroke-width: 2.5; stroke-linejoin: round; }
.grafico .area { fill: rgba(46, 107, 87, .12); stroke: none; }
.grafico .umbral { stroke: var(--ambar); stroke-width: 2; stroke-dasharray: 6 4; }
.grafico .etq-umbral { fill: var(--ambar-texto); font-weight: 700; }
.grafico .punto { fill: var(--verde); stroke: #fff; stroke-width: 2; }
.leyenda-graf { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; margin-top: .4rem; }
.leyenda-graf i { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--verde); vertical-align: middle; margin-right: .3rem; }
.leyenda-graf i.u { border-top: 3px dashed var(--ambar); }

/* Tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--alto-tab);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 2px solid var(--borde);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; color: var(--texto-suave); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--verde); border-top: 4px solid var(--verde); margin-top: -2px; background: var(--ok-fondo); }

/* Spinner y diálogos */
.overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(244, 247, 245, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; padding: 1rem;
}
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid #CBD8D1; border-top-color: var(--verde);
  animation: giro .9s linear infinite;
}
.spinner.chico { width: 22px; height: 22px; border-width: 3px; display: inline-block; vertical-align: middle; }
@keyframes giro { to { transform: rotate(360deg); } }
dialog { border: 2px solid var(--verde); border-radius: var(--radio); padding: 1.25rem; max-width: min(92vw, 440px); color: var(--texto); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin-top: 0; }

.vacio { text-align: center; color: var(--texto-suave); padding: 1.5rem 1rem; }
.aviso-js { padding: 1rem; background: var(--rojo-fondo); color: var(--rojo); font-weight: 700; }
.migas { font-size: .9rem; margin-bottom: .25rem; }
.migas a { color: var(--verde); font-weight: 600; }
.limpia { list-style: none; padding: 0; margin: 0; }
.limpia li { padding: .35rem 0; border-bottom: 1px solid #E3EAE6; }
ul.condiciones { padding-left: 1.2rem; }
ul.condiciones li { margin-bottom: .5rem; }

@media (min-width: 760px) {
  .tabbar { max-width: 760px; margin: 0 auto; border-left: 2px solid var(--borde); border-right: 2px solid var(--borde); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--verde); border-right-color: var(--verde); }
}

/* ---- Paneles de aseguradora y territorial (fase 3b) ---- */
.panel-cab { margin: .25rem 0 .5rem; }
.pestanas { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 2px solid var(--borde); margin: .75rem 0 1rem; }
.pestana {
  min-height: 44px; padding: .5rem .9rem; background: transparent; border: 2px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0; font: inherit; font-weight: 600; color: var(--texto-suave); cursor: pointer; white-space: nowrap;
}
.pestana:hover { background: var(--ok-fondo); }
.pestana[aria-selected="true"] { background: #fff; color: var(--verde); border-color: var(--borde); border-bottom: 3px solid var(--verde); margin-bottom: -2px; }
.panel-pestana:focus-visible { outline-offset: 4px; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: .5rem; }
.cifra-caja { border: 1px solid var(--borde); border-radius: 8px; padding: .5rem .75rem; background: var(--fondo); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.fila-dif th, tr.fila-dif td { background: var(--rojo-fondo); color: var(--rojo); font-weight: 700; }
tr.fila-total th, tr.fila-total td { background: #EAF0ED; font-weight: 700; }
.grafico .barra-h { fill: var(--verde-2); }
.grafico .valor-barra { font-weight: 700; }
.sel { min-height: 44px; padding: .4rem .6rem; border: 2px solid var(--borde); border-radius: 8px; font: inherit; background: #fff; color: var(--texto); }
.avisos { margin-bottom: .75rem; }
.avisos .tarjeta { margin: 0; }
.acciones.pag { align-items: center; justify-content: space-between; }
.nota-privacidad { border-left: 6px solid var(--verde-2); }
.aviso-offline { background: var(--ambar-texto); color: #fff; text-align: center; font-weight: 700; padding: .5rem 1rem; }
.aviso-offline[hidden] { display: none; }
