/*
 * Compartidos — estilos.
 *
 * Dirección «viva»: bloques de color, cada cosa con su color e icono, letra
 * redondeada y esquinas amplias. Móvil primero, un solo archivo, sin
 * compilación.
 *
 * - Tokens en :root, redefinidos para el modo oscuro.
 * - Cada persona tiene un color (.c-azul, .c-verde…): --p es el color sólido
 *   (texto blanco encima con contraste suficiente), --p-suave el fondo claro y
 *   --p-tinta el texto sobre ese fondo.
 * - Cada tipo de evento y categoría de gasto (.ev-*): --ev sólido y --ev-suave.
 * - La política de seguridad no admite estilos en línea: todo vive aquí.
 */

:root {
    --bg: #f3f4fa;
    --superficie: #ffffff;
    --superficie-2: #eef0f7;
    --borde: #e3e6f0;
    --borde-fuerte: #cbd0e0;
    --texto: #191c2b;
    --texto-2: #545b74;
    --texto-3: #8a90a7;
    --acento: #5046e5;
    --acento-tinta: #ffffff;
    --acento-suave: #ecebff;
    --ok: #0b8a5a;
    --ok-suave: #dcf6ea;
    --aviso: #a35c00;
    --aviso-suave: #fff0d4;
    --error: #d1303f;
    --error-suave: #ffe6e8;
    --neutro-suave: #eceef5;
    --foco: #5046e5;
    --sombra: 0 1px 2px rgba(25, 28, 60, .05), 0 6px 18px rgba(25, 28, 60, .06);
    --sombra-flotante: 0 12px 32px rgba(25, 28, 60, .18);
    --radio: 20px;
    --radio-m: 14px;
    --radio-s: 10px;
    --nav-alto: 68px;
    --cabecera-alto: 58px;
    --ancho: 760px;
    --fuente: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11131c;
        --superficie: #1a1d29;
        --superficie-2: #242838;
        --borde: #2d3244;
        --borde-fuerte: #42495f;
        --texto: #eceef6;
        --texto-2: #aab0c4;
        --texto-3: #7d849b;
        --acento: #8b84ff;
        --acento-tinta: #14123a;
        --acento-suave: #262457;
        --ok: #4fd39a;
        --ok-suave: #143326;
        --aviso: #f5b74e;
        --aviso-suave: #3a2b10;
        --error: #ff7d89;
        --error-suave: #3d1a20;
        --neutro-suave: #262a39;
        --foco: #a8a3ff;
        --sombra: 0 1px 2px rgba(0, 0, 0, .35);
        --sombra-flotante: 0 12px 32px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

/* Personas: color sólido con texto blanco (contraste ≥ 4,5:1), fondo suave y tinta. */
.c-azul { --p: #2563eb; --p-suave: #e2ecff; --p-tinta: #1a49b3; }
.c-verde { --p: #08875c; --p-suave: #d9f5e9; --p-tinta: #076a48; }
.c-violeta { --p: #7c3aed; --p-suave: #efe7ff; --p-tinta: #5b25c2; }
.c-naranja { --p: #c2410c; --p-suave: #ffeadb; --p-tinta: #9a330a; }
.c-rosa { --p: #c81e6c; --p-suave: #fde4f0; --p-tinta: #9d1755; }
.c-turquesa { --p: #0e7490; --p-suave: #d8f3fa; --p-tinta: #0b5c72; }
.c-nadie { --p: #6b7287; --p-suave: var(--superficie-2); --p-tinta: var(--texto-2); }

@media (prefers-color-scheme: dark) {
    .c-azul { --p-suave: #1b2a4f; --p-tinta: #aac6ff; }
    .c-verde { --p-suave: #13342a; --p-tinta: #8ee5bf; }
    .c-violeta { --p-suave: #2c2050; --p-tinta: #cbb4ff; }
    .c-naranja { --p-suave: #3a2416; --p-tinta: #ffbf94; }
    .c-rosa { --p-suave: #3c1a2c; --p-tinta: #ffadd2; }
    .c-turquesa { --p-suave: #11313b; --p-tinta: #94e2f2; }
}

/* Tipos de evento y categorías de gasto. */
.ev-colegio { --ev: #4f46e5; --ev-suave: #ecebff; }
.ev-no-lectivo { --ev: #b45309; --ev-suave: #fff1d6; }
.ev-extraescolar { --ev: #0f766e; --ev-suave: #d7f6f0; }
.ev-examen { --ev: #dc2626; --ev-suave: #ffe5e5; }
.ev-medico { --ev: #db2777; --ev-suave: #fde5f1; }
.ev-cumple { --ev: #7c3aed; --ev-suave: #efe7ff; }
.ev-plan { --ev: #15803d; --ev-suave: #ddf6e5; }
.ev-otro { --ev: #475569; --ev-suave: #eaeef4; }

@media (prefers-color-scheme: dark) {
    .ev-colegio { --ev: #a5a1ff; --ev-suave: #262457; }
    .ev-no-lectivo { --ev: #f7b955; --ev-suave: #3a2b10; }
    .ev-extraescolar { --ev: #5fd6c4; --ev-suave: #12322e; }
    .ev-examen { --ev: #ff8a8a; --ev-suave: #3d1a1a; }
    .ev-medico { --ev: #ff8cc0; --ev-suave: #3c1a2c; }
    .ev-cumple { --ev: #c3a6ff; --ev-suave: #2c2050; }
    .ev-plan { --ev: #6fdc95; --ev-suave: #143322; }
    .ev-otro { --ev: #aab4c5; --ev-suave: #262a39; }
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--texto);
    font-family: var(--fuente);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--acento); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 750; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3, .h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .peq { font-size: .875rem; }
.sec { color: var(--texto-2); }
.ter { color: var(--texto-3); }
.num { font-variant-numeric: tabular-nums; }
abbr[title] { text-decoration: none; }
.visualmente-oculto {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; border-radius: 6px; }

.saltar {
    position: absolute; left: 8px; top: -60px; z-index: 100;
    background: var(--superficie); color: var(--texto); padding: .6rem 1rem; border-radius: var(--radio-s);
    box-shadow: var(--sombra);
}
.saltar:focus { top: 8px; }

/* Iconos: tamaño por defecto y dentro de una línea de texto. */
svg { flex: none; }
.chevron { width: 20px; height: 20px; color: var(--texto-3); flex: none; }
.fila__detalle svg, .leyenda svg, .peq svg, p > a > svg { width: 1em; height: 1em; vertical-align: -.15em; }

/* --- Estructura ---------------------------------------------------------------- */
.cabecera {
    position: sticky; top: 0; z-index: 30;
    height: calc(var(--cabecera-alto) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    display: flex; align-items: center; gap: 12px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(12px);
    backdrop-filter: saturate(1.6) blur(12px);
}
.cabecera__marca {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 1.1rem; color: var(--texto); text-decoration: none; letter-spacing: -.02em;
}
.cabecera__logo {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
    background: var(--acento); color: #fff;
}
.cabecera__logo svg { width: 20px; height: 20px; }
.cabecera__marca span.cabecera__menor { color: var(--texto-3); font-weight: 600; }
.cabecera__espacio { flex: 1; }

.principal {
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 12px 16px calc(var(--nav-alto) + env(safe-area-inset-bottom) + 32px);
}

/* Navegación: barra inferior en el móvil, lateral en pantallas anchas. */
.nav {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--nav-alto) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom);
    display: flex; gap: 2px;
    background: color-mix(in srgb, var(--superficie) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(12px);
    backdrop-filter: saturate(1.6) blur(12px);
    border-top: 1px solid var(--borde);
}
.nav a {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--texto-2); text-decoration: none; font-size: .72rem; font-weight: 650;
    position: relative; border-radius: var(--radio-m);
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--acento); }
.nav a[aria-current="page"] svg { background: var(--acento-suave); border-radius: 999px; padding: 3px 14px; width: 54px; height: 30px; }
.nav__globo {
    position: absolute; top: 2px; left: calc(50% + 8px);
    min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
    background: var(--error); color: #fff; font-size: .7rem; line-height: 19px; text-align: center; font-weight: 800;
    box-shadow: 0 0 0 2px var(--superficie);
}

@media (min-width: 900px) {
    .nav {
        top: var(--cabecera-alto); bottom: 0; right: auto; width: 230px; height: auto;
        flex-direction: column; padding: 16px 12px; gap: 4px;
        border-top: 0; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .nav a {
        flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
        padding: 11px 14px; font-size: .98rem;
    }
    .nav a:hover { background: var(--superficie); }
    .nav a[aria-current="page"] { background: var(--acento); color: #fff; box-shadow: var(--sombra); }
    .nav a[aria-current="page"] svg { background: none; padding: 0; width: 22px; height: 22px; }
    .nav a svg { width: 22px; height: 22px; }
    .nav__globo { position: static; margin-left: auto; box-shadow: none; }
    .principal { padding: 24px 32px 48px; margin-left: max(230px, calc(50% - var(--ancho) / 2 + 115px)); }
}

/* Menú de la cuenta (details/summary: funciona con teclado y sin JavaScript). */
.menu { position: relative; }
.menu > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px;
    border-radius: 22px;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
    min-width: 240px; padding: 8px;
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-m);
    box-shadow: var(--sombra-flotante);
}
.menu__panel a, .menu__panel button {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
    border: 0; background: none; font: inherit; font-weight: 600; color: var(--texto); text-decoration: none; text-align: left;
    border-radius: var(--radio-s); cursor: pointer;
}
.menu__panel a:hover, .menu__panel button:hover { background: var(--superficie-2); }
.menu__panel hr { border: 0; border-top: 1px solid var(--borde); margin: 6px 0; }
.menu__panel .ter { padding: 6px 12px 2px; display: block; font-size: .8rem; }

/* --- Persona ----------------------------------------------------------------------- */
.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--p); color: #fff; font-weight: 800; font-size: .9rem;
}
.avatar--g { width: 48px; height: 48px; font-size: 1.15rem; }
.avatar--p { width: 22px; height: 22px; font-size: .7rem; }

.persona {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    padding: 3px 11px 3px 3px; border-radius: 999px;
    background: var(--p-suave); color: var(--p-tinta); font-weight: 700; font-size: .88rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.persona .avatar { width: 22px; height: 22px; font-size: .7rem; }

/* Icono con fondo de color: tipo de evento o categoría de gasto. */
.icono-ev {
    display: inline-grid; place-items: center; flex: none;
    width: 40px; height: 40px; border-radius: 13px;
    background: var(--ev-suave); color: var(--ev);
}
.icono-ev svg { width: 22px; height: 22px; }
.icono-ev--p { width: 30px; height: 30px; border-radius: 10px; }
.icono-ev--p svg { width: 17px; height: 17px; }

/* --- Bloques ---------------------------------------------------------------------- */
.tarjeta {
    background: var(--superficie); border-radius: var(--radio);
    padding: 18px; margin-bottom: 16px; box-shadow: var(--sombra);
}
.tarjeta--plana { box-shadow: none; border: 1px solid var(--borde); }
.tarjeta > :last-child { margin-bottom: 0; }
.tarjeta__titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tarjeta__titulo h2 { margin: 0; }

.encabezado { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 4px 0 16px; }
.encabezado h1 { margin: 0; }
.encabezado .sec { width: 100%; margin: -2px 0 0; }

.volver { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -6px 0 2px; color: var(--texto-2); text-decoration: none; font-weight: 600; font-size: .95rem; }
.volver:hover { color: var(--texto); }
.volver svg { width: 18px; height: 18px; }

.seccion-titulo { font-size: 1.05rem; font-weight: 800; color: var(--texto); margin: 24px 0 10px; letter-spacing: -.01em; }

.vacio { text-align: center; padding: 28px 16px; color: var(--texto-2); }
.vacio p { margin-bottom: 14px; }

.saludo { margin: 2px 0 14px; }
.saludo__fecha { color: var(--texto-2); font-weight: 600; font-size: .95rem; margin: 0; }
.saludo__hola { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 0; line-height: 1.15; }

/* Bloque principal: quién libra (o con quién está). Color sólido de la persona. */
.encargado {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 14px;
    padding: 20px 18px; border-radius: var(--radio); margin-bottom: 16px;
    background: var(--p); color: #fff;
}
.encargado .avatar { background: rgba(255, 255, 255, .22); color: #fff; }
.encargado__texto { min-width: 0; position: relative; z-index: 1; }
.encargado__etiqueta { font-size: .9rem; font-weight: 700; margin: 0; color: rgba(255, 255, 255, .92); }
.encargado__nombre { font-size: 2.1rem; font-weight: 850; margin: 0; letter-spacing: -.02em; line-height: 1.1; }
.encargado__hasta { font-size: .92rem; margin: 6px 0 0; color: rgba(255, 255, 255, .95); }
.encargado__dibujo {
    position: absolute; right: -14px; bottom: -18px; width: 120px; height: 120px;
    color: rgba(255, 255, 255, .16); pointer-events: none;
}
.encargado__dibujo svg { width: 100%; height: 100%; stroke-width: 1.4; }

/* Franja de días: cada día del color de quien libra. */
.franja { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 5px; }
.franja a {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 7px 0 8px; border-radius: var(--radio-s); text-decoration: none;
    background: var(--p); color: #fff; min-height: 44px;
}
.franja a.es-hoy { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--p); }
.franja__dia { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: rgba(255, 255, 255, .85); }
.franja__num { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.franja__ini { font-size: .72rem; font-weight: 800; }

/* Mosaico de accesos: teselas de color. */
.mosaico { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
@media (min-width: 600px) { .mosaico { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tesela {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    min-height: 92px; padding: 14px; border-radius: var(--radio-m);
    background: var(--ev-suave); color: var(--texto); text-decoration: none;
    font-weight: 750; line-height: 1.2;
}
.tesela .icono-ev { background: var(--ev); color: #fff; width: 36px; height: 36px; border-radius: 11px; }
.tesela .icono-ev svg { width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) { .tesela .icono-ev { color: #11131c; } }
.tesela small { display: block; font-weight: 600; color: var(--texto-2); font-size: .8rem; margin-top: 2px; }
.tesela:hover { filter: brightness(.97); }

/* --- Listas ------------------------------------------------------------------------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li + li { border-top: 1px solid var(--borde); }
.fila {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 0;
    color: inherit; text-decoration: none;
}
a.fila:hover .fila__titulo { text-decoration: underline; text-decoration-thickness: 1px; }
.fila__cuerpo { flex: 1; min-width: 0; }
.fila__titulo { font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.fila__detalle { font-size: .875rem; color: var(--texto-2); margin: 2px 0 0; overflow-wrap: anywhere; }
.fila__lateral { flex: none; text-align: right; }
.fila__hora { flex: none; min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--texto); font-size: .95rem; }
.fila--anulada .fila__titulo { text-decoration: line-through; color: var(--texto-3); }
.fila--anulada .icono-ev { filter: grayscale(1); opacity: .6; }

.dia-grupo { margin-bottom: 10px; }
.dia-grupo__cabecera {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 0 6px;
    position: sticky; top: calc(var(--cabecera-alto) + env(safe-area-inset-top)); z-index: 5; background: var(--bg);
}
.dia-grupo__fecha { font-weight: 800; text-decoration: none; color: var(--texto); }
.dia-grupo__fecha.es-hoy::after { content: "Hoy"; margin-left: 8px; font-size: .72rem; padding: 2px 9px; border-radius: 999px; background: var(--acento); color: var(--acento-tinta); vertical-align: 2px; }
.dia-grupo > .lista { background: var(--superficie); border-radius: var(--radio-m); padding: 0 14px; box-shadow: var(--sombra); }

.punto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ev, var(--texto-3)); }

/* --- Etiquetas y avisos ------------------------------------------------------------------ */
.etiqueta {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 750;
    background: var(--neutro-suave); color: var(--texto-2); white-space: nowrap;
}
.etiqueta--ok { background: var(--ok-suave); color: var(--ok); }
.etiqueta--aviso { background: var(--aviso-suave); color: var(--aviso); }
.etiqueta--error { background: var(--error-suave); color: var(--error); }

.aviso {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px; border-radius: var(--radio-m); margin-bottom: 14px;
    background: var(--neutro-suave); color: var(--texto);
}
.aviso > :last-child { margin-bottom: 0; }
.aviso--ok { background: var(--ok-suave); }
.aviso--aviso { background: var(--aviso-suave); }
.aviso--error { background: var(--error-suave); }
.aviso--info { background: var(--acento-suave); }
.aviso > svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.aviso--ok > svg { color: var(--ok); }
.aviso--aviso > svg { color: var(--aviso); }
.aviso--error > svg { color: var(--error); }
.aviso--info > svg { color: var(--acento); }
.aviso__cuerpo { flex: 1; min-width: 0; }
.aviso__cuerpo p { margin: 0; }
.aviso__cuerpo p + p, .aviso__cuerpo .acciones { margin-top: 10px; }

.flashes { position: relative; }

/* --- Botones ----------------------------------------------------------------------------- */
.boton {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 18px; border-radius: 999px;
    border: 1.5px solid var(--borde-fuerte); background: var(--superficie); color: var(--texto);
    font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.boton:hover { background: var(--superficie-2); }
.boton:active { transform: scale(.98); }
.boton svg { width: 19px; height: 19px; flex: none; }
.boton--primario { background: var(--acento); border-color: var(--acento); color: var(--acento-tinta); }
.boton--primario:hover { background: color-mix(in srgb, var(--acento) 88%, #000); }
.boton--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .boton--ok { color: #0b1f15; } }
.boton--peligro { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, transparent); background: var(--superficie); }
.boton--peligro:hover { background: var(--error-suave); }
.boton--texto { border-color: transparent; background: none; color: var(--acento); padding: 0 10px; }
.boton--texto:hover { background: var(--acento-suave); }
.boton--bloque { width: 100%; }
.boton[disabled], .boton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.boton-icono {
    display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
    border-radius: 50%; border: 0; background: var(--superficie); color: var(--texto); cursor: pointer; text-decoration: none;
    box-shadow: var(--sombra); font: inherit; font-size: 1.2rem; font-weight: 700;
}
.boton-icono:hover { background: var(--superficie-2); }
.boton-icono svg { width: 22px; height: 22px; }

.acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acciones--fin { justify-content: flex-end; }
.acciones form { margin: 0; }

/* --- Formularios ------------------------------------------------------------------------------- */
.campo { margin-bottom: 16px; }
.campo > label, .campo > .campo__etiqueta, fieldset > legend {
    display: block; font-weight: 750; margin-bottom: 7px; font-size: .95rem; padding: 0;
}
.campo__ayuda { font-size: .85rem; color: var(--texto-2); margin: 6px 0 0; }
.campo__error { font-size: .875rem; color: var(--error); margin: 6px 0 0; font-weight: 700; }
.opcional { font-weight: 500; color: var(--texto-3); font-size: .85rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"],
input[type="number"], input[type="search"], input[type="url"], input[type="file"], select, textarea {
    width: 100%; min-height: 50px; padding: 11px 14px;
    font: inherit; font-size: 16px; color: var(--texto);
    background: var(--superficie-2); border: 1.5px solid transparent; border-radius: var(--radio-m);
    appearance: none; -webkit-appearance: none;
}
input[type="date"], input[type="time"] { min-width: 0; display: block; }
input[type="file"] { padding: 12px; min-height: 0; }
textarea { min-height: 100px; resize: vertical; line-height: 1.45; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238a90a7' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px;
}
input:hover, select:hover, textarea:hover { border-color: var(--borde-fuerte); }
input:focus, select:focus, textarea:focus { outline: none; background-color: var(--superficie); border-color: var(--foco); box-shadow: 0 0 0 4px color-mix(in srgb, var(--foco) 20%, transparent); }
.is-invalid { border-color: var(--error) !important; background-color: var(--error-suave) !important; }
input::placeholder, textarea::placeholder { color: var(--texto-3); }

.importe { position: relative; }
.importe input { padding-right: 38px; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.importe::after { content: "€"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--texto-2); font-weight: 800; }

.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dos-col > .campo { margin-bottom: 0; }
.dos-col + .campo, .dos-col + .dos-col, .dos-col + fieldset { margin-top: 16px; }

fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }

.check {
    display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 650;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--acento); }
.check span small { display: block; color: var(--texto-2); font-weight: 500; }

/* Opciones en pastillas (radio o checkbox). */
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opcion { position: relative; }
.opcion input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opcion > span {
    display: inline-flex; align-items: center; gap: 7px; min-height: 46px; padding: 0 16px;
    border: 1.5px solid var(--borde-fuerte); border-radius: 999px; background: var(--superficie);
    font-weight: 750; cursor: pointer; user-select: none;
}
.opcion input:checked + span { background: var(--acento); border-color: var(--acento); color: var(--acento-tinta); }
.opcion[class*="c-"] input:checked + span { background: var(--p); border-color: var(--p); color: #fff; }
.opcion input:checked + span .avatar { background: rgba(255, 255, 255, .25); color: #fff; }
.opcion input:focus-visible + span { outline: 3px solid var(--foco); outline-offset: 2px; }
.opcion--dia > span { width: 46px; padding: 0; justify-content: center; }

.pie-form {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
    padding-top: 8px;
}
.pie-form .acciones { margin-left: auto; }

[hidden] { display: none !important; }

/* --- Calendario de mes ------------------------------------------------------------------ */
.mes-nav { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.mes-nav h1, .mes-nav p { flex: 1; text-align: center; font-size: 1.4rem; margin: 0; }
.mes-nav p { font-size: 1rem; }

.calendario { border-collapse: separate; border-spacing: 4px; table-layout: fixed; margin: 6px -4px 8px; width: calc(100% + 8px); }
.calendario th { font-size: .72rem; font-weight: 800; color: var(--texto-3); text-transform: uppercase; padding: 4px 0; }
.calendario td { padding: 0; vertical-align: top; }
.dia {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    min-height: 62px; padding: 6px 6px 7px; border-radius: 12px;
    background: var(--p); color: #fff; text-decoration: none;
}
.dia:hover { filter: brightness(1.06); }
.dia--fuera { opacity: .35; }
.dia--hoy { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--texto); }
.dia__num { font-weight: 850; font-size: .98rem; font-variant-numeric: tabular-nums; line-height: 1.3; }
.dia__ini { font-size: .72rem; font-weight: 800; color: rgba(255, 255, 255, .88); }
.dia__puntos { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.dia__puntos .punto { width: 7px; height: 7px; background: #fff; }
.dia__marcas { position: absolute; top: 5px; right: 5px; display: flex; gap: 2px; color: #fff; }
.dia__marcas svg { width: 13px; height: 13px; }
.dia--cambio { background-image: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, .22) 7px 10px); }
.c-nadie.dia { background: var(--superficie-2); color: var(--texto-2); }
.c-nadie.dia .dia__ini, .c-nadie.dia .dia__marcas { color: var(--texto-3); }
.c-nadie.dia .dia__puntos .punto { background: var(--texto-3); }
@media (min-width: 600px) {
    .dia { min-height: 86px; padding: 9px; border-radius: 14px; }
    .dia__ini { font-size: .8rem; }
    .dia__puntos .punto { width: 8px; height: 8px; }
}

.leyenda { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: .86rem; color: var(--texto-2); font-weight: 600; margin: 10px 0 16px; }
.leyenda > span { display: inline-flex; align-items: center; gap: 6px; }
.muestra { width: 16px; height: 16px; border-radius: 5px; background: var(--p); flex: none; }
.muestra--cambio { background: repeating-linear-gradient(135deg, var(--texto-3) 0 3px, var(--superficie-2) 3px 5px); }

.recuento { display: flex; gap: 8px; flex-wrap: wrap; }
.recuento .persona { font-variant-numeric: tabular-nums; }

/* Editor del reparto. */
.reparto-semana { margin-bottom: 14px; }
.reparto-semana__titulo { font-size: .9rem; font-weight: 800; color: var(--texto-2); margin: 0 0 6px; }
.reparto { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.reparto__dia { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.reparto__nombre { font-size: .72rem; font-weight: 800; color: var(--texto-3); text-align: center; text-transform: uppercase; }
.reparto__opcion { position: relative; }
.reparto__opcion input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.reparto__opcion > span {
    display: grid; place-items: center; height: 46px; border-radius: 12px;
    border: 1.5px dashed var(--borde-fuerte); background: transparent; color: var(--texto-3);
    font-weight: 800; font-size: .9rem; cursor: pointer; user-select: none;
}
.reparto__opcion input:checked + span { background: var(--p); border: 1.5px solid var(--p); color: #fff; }
.reparto__opcion input:focus-visible + span { outline: 3px solid var(--foco); outline-offset: 1px; }

/* --- Gastos ----------------------------------------------------------------------------- */
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.cifra { background: var(--superficie); border-radius: var(--radio-m); padding: 14px 16px; box-shadow: var(--sombra); }
.cifra__etiqueta { font-size: .82rem; color: var(--texto-2); font-weight: 650; margin: 0 0 2px; }
.cifra__valor { font-size: 1.45rem; font-weight: 850; font-variant-numeric: tabular-nums; margin: 0; letter-spacing: -.01em; }
.cifra--destacada { background: var(--acento); color: var(--acento-tinta); }
.cifra--destacada .cifra__etiqueta { color: color-mix(in srgb, var(--acento-tinta) 85%, transparent); }

.saldo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.saldo__texto { flex: 1; min-width: 200px; margin: 0; font-weight: 650; }
.saldo__importe { font-size: 1.5rem; font-weight: 850; font-variant-numeric: tabular-nums; }

/* Barras con <progress>: la política de seguridad no admite estilos en línea. */
.barras { list-style: none; margin: 10px 0 0; padding: 0; }
.barras li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 7px 0; font-size: .92rem; font-weight: 650; }
.barras progress {
    grid-column: 1 / -1; width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden;
    appearance: none; -webkit-appearance: none; background: var(--superficie-2); color: var(--acento);
}
.barras progress::-webkit-progress-bar { background: var(--superficie-2); border-radius: 4px; }
.barras progress::-webkit-progress-value { background: var(--acento); border-radius: 4px; }
.barras progress::-moz-progress-bar { background: var(--acento); border-radius: 4px; }

.importe-fila { font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filtros select { width: auto; flex: 1 1 160px; min-height: 46px; background-color: var(--superficie); }

.miniatura {
    display: block; width: 100%; max-height: 420px; object-fit: contain;
    background: var(--superficie-2); border-radius: var(--radio-m);
}
.adjuntos { display: grid; gap: 12px; }
.adjunto { display: flex; flex-direction: column; gap: 6px; }

/* --- Ficha de datos -------------------------------------------------------------------------- */
.datos { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 12px 16px; margin: 0; }
.datos dt { color: var(--texto-2); font-size: .9rem; font-weight: 650; }
.datos dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }

.cita { margin: 0 0 12px; padding: 12px 14px; background: var(--superficie-2); border-radius: var(--radio-m); white-space: pre-line; overflow-wrap: anywhere; }

.tramo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; }
.flecha { color: var(--texto-3); font-weight: 800; }

.linea-tiempo { list-style: none; margin: 0; padding: 0; position: relative; }
.linea-tiempo li { position: relative; padding: 0 0 14px 24px; font-size: .9rem; }
.linea-tiempo li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--acento); }
.linea-tiempo li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1.5px; background: var(--borde); }
.linea-tiempo li:last-child::after { display: none; }
.linea-tiempo time { display: block; color: var(--texto-3); font-size: .8rem; font-weight: 650; }

.paginacion { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }

details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 750; }
details.tarjeta > summary { margin: -4px 0; }

/* --- Acceso ------------------------------------------------------------------------------- */
.acceso { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.acceso__caja { width: 100%; max-width: 390px; }
.acceso__marca { text-align: center; margin-bottom: 22px; }
.acceso__logo { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--acento); color: #fff; box-shadow: var(--sombra-flotante); }
.acceso__logo svg { width: 40px; height: 40px; }
.acceso__marca h1 { margin: 14px 0 4px; font-size: 1.9rem; }
.acceso__marca p { color: var(--texto-2); font-weight: 600; margin: 0; }

/* --- Utilidades ------------------------------------------------------------------------------ */
.mt-0 { margin-top: 0; }
.mt-s { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-s { margin-bottom: 8px; }
.texto-centro { text-align: center; }
.fila-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.separador { border: 0; border-top: 1px solid var(--borde); margin: 18px 0; }
.campo-corto { width: 6.5rem !important; }
.campo-medio { max-width: 12rem; }

@media (prefers-reduced-motion: no-preference) {
    .boton, .opcion > span, .reparto__opcion > span, .dia, .nav a, .tesela, .franja a { transition: background-color .15s, border-color .15s, color .15s, filter .15s, transform .1s; }
}

@media print {
    .nav, .cabecera, .acciones, .mosaico, form { display: none !important; }
    .principal { margin: 0; padding: 0; max-width: none; }
    body { background: #fff; }
}

/* Desplegables (salvo el menú de la cuenta): una flecha que indica que se abren. */
details:not(.menu) > summary { list-style: none; gap: 10px; }
details:not(.menu) > summary::-webkit-details-marker { display: none; }
details:not(.menu) > summary::after {
    content: ""; margin-left: auto; width: 9px; height: 9px; flex: none;
    border-right: 2.5px solid var(--texto-3); border-bottom: 2.5px solid var(--texto-3);
    transform: translateY(-2px) rotate(45deg);
}
details:not(.menu)[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
@media (prefers-reduced-motion: no-preference) { details:not(.menu) > summary::after { transition: transform .15s; } }

/* Botón de elegir archivo (foto del ticket) con el mismo aspecto que los demás. */
input[type="file"]::file-selector-button {
    margin-right: 12px; min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
    border: 0; background: var(--acento); color: var(--acento-tinta); font: inherit; font-weight: 750;
}
input[type="file"] { color: var(--texto-2); font-size: .9rem; }

/* Días que ya han pasado en la franja: siguen ahí para situarse, pero en segundo plano. */
.franja a.es-pasado { opacity: .38; }
.franja a.es-pasado:hover { opacity: .7; }
