:root {
  --marca: #1E7367;
  --marca-osc: #155A50;
  --marca-suave: #E6F2F0;
  --fondo: #F4F6F6;
  --tarjeta: #FFFFFF;
  --texto: #1F2A2A;
  --sub: #667575;
  --borde: #DDE4E3;
  --verde: #1F9D55;
  --naranja: #D97706;
  --rojo: #C0392B;
  --wa: #25D366;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Cabecera */
.cab { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--marca); color: #fff; }
.cab img { width: 34px; height: 34px; border-radius: 8px; background: #fff; object-fit: contain; padding: 2px; }
.cab h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab .atras { background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; padding: 0 6px 0 0; cursor: pointer; }
.cab .salir { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 13px; }

main { padding: 14px 16px 24px; max-width: 720px; margin: 0 auto; }

/* Barra inferior */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: #fff; border-top: 1px solid var(--borde); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 9px; color: var(--sub); text-decoration: none; font-size: 12px; font-weight: 550; }
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a.activo { color: var(--marca); }

/* Tarjetas y listas */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.tarjeta h2 { margin: 0 0 10px; font-size: 15px; color: var(--marca); font-weight: 700; }
.titulo-sec { margin: 18px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--sub); font-weight: 700; }
.lista { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin-bottom: 12px; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--borde);
  text-decoration: none; color: inherit; min-height: 56px; cursor: pointer; }
.fila:last-child { border-bottom: 0; }
.fila:active { background: var(--marca-suave); }
.fila .princ { flex: 1; min-width: 0; }
.fila .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .t2 { color: var(--sub); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hora { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--marca); min-width: 48px; }
.importe { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.vacio { color: var(--sub); text-align: center; padding: 22px 10px; }

.chip { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.chip.ok { background: #E3F5EA; color: var(--verde); }
.chip.pend { background: #FDF0DC; color: var(--naranja); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 0 16px; border-radius: 12px; border: 0; background: var(--marca); color: #fff;
  font-weight: 650; cursor: pointer; text-decoration: none; }
.btn:active { background: var(--marca-osc); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.sec { background: var(--marca-suave); color: var(--marca); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.peligro { background: #FBE9E7; color: var(--rojo); }
.btn.bloque { width: 100%; }
.btn.peq { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; }
.botones { display: flex; gap: 8px; flex-wrap: wrap; }
.botones > .btn { flex: 1 1 0; }
.icono-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; flex: none; }
.icono-btn svg { width: 22px; height: 22px; }

/* Formularios */
label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 12px; background: #fff; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: -1px; border-color: var(--marca); }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--marca); }
.eva { display: flex; align-items: center; gap: 12px; }
.eva input { flex: 1; accent-color: var(--marca); }
.eva b { min-width: 28px; text-align: center; font-size: 20px; color: var(--marca); }
.buscador { position: sticky; top: 56px; z-index: 4; background: var(--fondo); padding: 2px 0 10px; }

/* Cifras */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.kpi .e { font-size: 13px; color: var(--sub); }
.kpi .d { font-size: 12px; font-weight: 650; }
.d.sube { color: var(--verde); } .d.baja { color: var(--rojo); }

.aviso { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radio);
  background: #FDF0DC; color: #7A4A00; margin-bottom: 12px; font-weight: 550; text-decoration: none; }
.aviso.info { background: var(--marca-suave); color: var(--marca-osc); }
.alergia { background: #FBE9E7; color: var(--rojo); border-radius: 10px; padding: 8px 10px; font-weight: 600; margin-bottom: 10px; }
.dato { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--borde); }
.dato:last-child { border-bottom: 0; }
.dato span:first-child { color: var(--sub); }
.dato span:last-child { text-align: right; overflow-wrap: anywhere; }
.bono-barra { height: 10px; border-radius: 99px; background: var(--marca-suave); overflow: hidden; margin: 8px 0 12px; }
.bono-barra i { display: block; height: 100%; background: var(--marca); }
details.sesion { border-bottom: 1px solid var(--borde); padding: 10px 0; }
details.sesion:last-child { border-bottom: 0; }
details.sesion summary { cursor: pointer; font-weight: 600; list-style: none; }
details.sesion summary::-webkit-details-marker { display: none; }
details.sesion p { margin: 6px 0 0; white-space: pre-wrap; }
details.sesion small { color: var(--sub); font-weight: 600; }

/* Acceso */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login img { width: 120px; height: 120px; object-fit: contain; margin: 0 auto 8px; display: block; }
.login h1 { text-align: center; margin: 0 0 24px; font-size: 22px; color: var(--marca); }

/* Avisos flotantes y cargando */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  background: #1F2A2A; color: #fff; border-radius: 12px; padding: 12px 14px; text-align: center;
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; max-width: 560px; margin: 0 auto; }
#toast.ver { opacity: 1; transform: none; }
#toast.error { background: var(--rojo); }
.cargando { text-align: center; color: var(--sub); padding: 40px 0; }
.cargando::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 10px;
  border: 3px solid var(--marca-suave); border-top-color: var(--marca); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.oculto { display: none !important; }

.clave-fila { display: flex; gap: 8px; }
.clave-fila input { flex: 1; min-width: 0; }
.clave-fila .btn { flex: none; }
.login-texto { text-align: center; color: var(--sub); margin: -14px 0 18px; }
.pasos { margin: 0; padding-left: 20px; } .pasos li { margin-bottom: 10px; }

/* --- Mejoras: secciones de Finanzas, gráfico de barras, datos de salud --- */
.segmentos { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 6px; scrollbar-width: none; }
.segmentos::-webkit-scrollbar { display: none; }
.segmentos a { flex: none; padding: 8px 14px; border-radius: 99px; background: #fff; color: var(--sub);
  text-decoration: none; font-weight: 650; font-size: 14px; box-shadow: var(--sombra); }
.segmentos a.activo { background: var(--marca); color: #fff; }
.anio-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.anio-nav b { font-size: 18px; }
.barra-fila { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; }
.barra-fila .mes { color: var(--sub); font-size: 13px; font-weight: 650; }
.barra-fila .importe { font-size: 13px; min-width: 76px; text-align: right; }
.barra { height: 14px; background: var(--marca-suave); border-radius: 99px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--marca); border-radius: 99px; }
.tarjeta.salud { border-left: 4px solid var(--rojo); }
.tarjeta.salud h2 { color: var(--rojo); }
.sub { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--sub); font-weight: 700; }
.aviso.cumple { background: #E3F5EA; color: #1B5E3A; justify-content: space-between; }
.tri { border: 1px solid var(--borde); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.tri.actual { border-color: var(--marca); background: var(--marca-suave); }
.tri-cab { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tri-cab span { color: var(--sub); font-size: 13px; }
.lista.plana { box-shadow: none; border: 1px solid var(--borde); }
