/* Panel Medaplate — paleta de la marca: ciruela #2B1B2E, crema #F2E8DC, pistacho #C8D9A0 (verde oliva #6B8530 sobre claro). */
@font-face { font-family: 'Sora'; src: url('../fonts/Sora.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }

:root, html[data-tema="oscuro"] {
  --bg: #2B1B2E; --sup: #36243A; --sup2: #42304A; --linea: rgba(242, 232, 220, .13);
  --txt: #F2E8DC; --suave: rgba(242, 232, 220, .68); --acento: #C8D9A0; --sobre-acento: #2B1B2E;
  --barra: #C8D9A0; --barra-2: rgba(242, 232, 220, .24); --bien: #C8D9A0; --mal: #F2A59B; --aviso: #E9CB82;
  --sombra: 0 6px 22px rgba(0, 0, 0, .28);
}
html[data-tema="claro"] {
  --bg: #F2E8DC; --sup: #FBF6EE; --sup2: #EADFD0; --linea: rgba(43, 27, 46, .14);
  --txt: #2B1B2E; --suave: rgba(43, 27, 46, .7); --acento: #55691F; --sobre-acento: #F2E8DC;
  --barra: #6B8530; --barra-2: rgba(43, 27, 46, .2); --bien: #4C5F1B; --mal: #A8382F; --aviso: #8A6414;
  --sombra: 0 6px 18px rgba(43, 27, 46, .1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark light; }
html[data-tema="claro"] { color-scheme: light; }
html[data-tema="oscuro"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--txt); font: 15px/1.45 'Sora', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: clip; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 8px; }

.logo { display: block; height: 30px; width: auto; }
html[data-tema="oscuro"] .logo-l, html[data-tema="claro"] .logo-d { display: none; }

/* ---- PIN ---- */
.pin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.pin-caja { width: min(320px, 100%); text-align: center; }
.pin .logo { height: 58px; margin: 0 auto 4px; }
.pin-t { margin: 0 0 22px; color: var(--suave); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.puntos { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.puntos i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--suave); transition: background .12s, border-color .12s, transform .12s; }
.puntos i.on { background: var(--acento); border-color: var(--acento); transform: scale(1.1); }
.puntos.mal { animation: sacudir .35s; }
@keyframes sacudir { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-msg { min-height: 22px; margin: 0 0 14px; color: var(--suave); font-size: 14px; }
.pin-msg.mal { color: var(--mal); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.teclado button { height: 64px; border-radius: 18px; border: 1px solid var(--linea); background: var(--sup); font-size: 24px; font-weight: 500; transition: transform .08s, background .12s; }
.teclado button:active { transform: scale(.94); background: var(--sup2); }

/* ---- Estructura ---- */
#app { max-width: 600px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.cab { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--linea); }
.cab .logo { height: 28px; }
.cab-der { display: flex; align-items: center; gap: 10px; }
.vivo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--suave); }
.vivo i { width: 8px; height: 8px; border-radius: 50%; background: var(--acento); box-shadow: 0 0 0 0 var(--acento); animation: latido 2.4s infinite; }
.vivo.off i { background: var(--mal); animation: none; }
@keyframes latido { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--acento) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
.icono { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--linea); background: var(--sup); font-size: 18px; line-height: 1; }
main { padding: 16px 16px 8px; outline: none; }
main > * + * { margin-top: 14px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 600px; margin: 0 auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--linea); }
.nav button { display: grid; justify-items: center; gap: 1px; padding: 6px 0 4px; border: 0; background: none; color: var(--suave); font-size: 11px; border-radius: 12px; min-height: 52px; }
.nav b { font-size: 18px; font-weight: 600; line-height: 1.2; }
.nav button[aria-current="page"] { color: var(--acento); }
.nav button[aria-current="page"] b { transform: translateY(-1px); }

/* ---- Tarjetas ---- */
.card { background: var(--sup); border: 1px solid var(--linea); border-radius: 18px; padding: 16px; box-shadow: var(--sombra); }
.card h2 { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--suave); }
.titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.titulo h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.titulo small { color: var(--suave); font-size: 12px; }
.grande { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.med { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.sub { color: var(--suave); font-size: 13px; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rejilla > .card { padding: 14px; }
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tri > div { background: var(--sup2); border-radius: 12px; padding: 10px; }

.d { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--bien) 16%, transparent); color: var(--bien); white-space: nowrap; }
.d.mal { background: color-mix(in srgb, var(--mal) 16%, transparent); color: var(--mal); }
.d.neutro { background: var(--sup2); color: var(--suave); }

/* Chips de periodo */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--linea); background: var(--sup); font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); font-weight: 600; }

/* Barras */
.barras { width: 100%; height: auto; display: block; }
.barras .b { fill: var(--barra); } .barras .b.ant { fill: var(--barra-2); } .barras .b.cero { fill: var(--barra-2); }
.barras text { fill: var(--suave); font-size: 10px; font-family: inherit; }
.hb { display: grid; gap: 10px; }
.hb-i .fila { font-size: 14px; } .hb-i .v { font-weight: 600; white-space: nowrap; }
.hb-t { height: 6px; background: var(--sup2); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.hb-t i { display: block; height: 100%; background: var(--barra); border-radius: 99px; }
.prog { height: 12px; background: var(--sup2); border-radius: 99px; position: relative; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--barra); border-radius: 99px; transition: width .5s; }
.prog u { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--txt); opacity: .55; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--linea); }
.lista li:first-child { border-top: 0; padding-top: 2px; }
.lista .ico { flex: 0 0 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--sup2); font-size: 16px; }
.lista .ico.venta { background: color-mix(in srgb, var(--acento) 22%, transparent); }
.lista .tx { flex: 1; min-width: 0; }
.lista .tx b { display: block; font-weight: 600; }
.lista .tx span { display: block; color: var(--suave); font-size: 13px; overflow-wrap: anywhere; }
.lista .der { text-align: right; font-size: 12px; color: var(--suave); white-space: nowrap; }
.lista .der b { display: block; color: var(--txt); font-size: 14px; }
.vacio { color: var(--suave); text-align: center; padding: 14px 4px; font-size: 14px; }
.nota { font-size: 12.5px; color: var(--suave); overflow-wrap: anywhere; }
code { font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--sup2); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }
.aviso-card { border-color: color-mix(in srgb, var(--aviso) 55%, transparent); background: color-mix(in srgb, var(--aviso) 9%, var(--sup)); }
.aviso-card b { color: var(--aviso); }

/* Dinero */
.tabla { width: 100%; border-collapse: collapse; }
.tabla td, .tabla th { padding: 9px 0; border-top: 1px solid var(--linea); text-align: right; font-size: 14px; }
.tabla th { font-weight: 500; color: var(--suave); font-size: 12px; }
.tabla tr:first-child td, .tabla tr:first-child th { border-top: 0; }
.tabla td:first-child, .tabla th:first-child { text-align: left; }
.tabla .tot td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--linea); }
.tabla .neg { color: var(--suave); }
.mal-t { color: var(--mal); } .bien-t { color: var(--bien); }

/* Formularios */
.campo { display: grid; gap: 5px; margin-top: 12px; }
.campo label { font-size: 13px; color: var(--suave); }
input[type="text"], input[type="number"], input[type="date"], select { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--linea); background: var(--sup2); min-height: 44px; }
.btn { min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--linea); background: var(--sup2); font-weight: 600; }
.btn.pri { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); }
.btn.peligro { color: var(--mal); }
.btn[disabled] { opacity: .5; }
.btn.chico { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--linea); }
.sw:first-of-type { border-top: 0; }
.sw input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--sup2); border: 1px solid var(--linea); position: relative; transition: background .15s; flex: none; }
.sw input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--suave); transition: transform .15s, background .15s; }
.sw input:checked { background: var(--acento); border-color: var(--acento); }
.sw input:checked::after { transform: translateX(18px); background: var(--sobre-acento); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px 0; border-radius: 12px; border: 1px solid var(--linea); background: var(--sup2); }
.seg button[aria-pressed="true"] { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); font-weight: 600; }

/* Hoja (ajustes, formularios) */
.hoja { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
.hoja-in { max-width: 600px; margin: 0 auto; }
.hoja-in > * + * { margin-top: 14px; }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; }
.hoja-cab h1 { margin: 0; font-size: 22px; }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: min(92vw, 480px); padding: 11px 16px; border-radius: 14px; background: var(--txt); color: var(--bg); font-size: 14px; box-shadow: var(--sombra); }
.esqueleto { height: 120px; border-radius: 18px; background: linear-gradient(90deg, var(--sup) 25%, var(--sup2) 50%, var(--sup) 75%); background-size: 200% 100%; animation: brillo 1.3s infinite; }
@keyframes brillo { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
