/* ═══════════════════════════════════════════════════════════════════
   Responsables — Hoja de estilos.

   Identidad: panel de control futurista. Fondo profundo azul-negro,
   acentos de cian eléctrico y violeta con brillo, cifras en monoespaciada
   tabular. El rojo se reserva EXCLUSIVAMENTE para lo vencido: si algo se
   pone rojo en esta app, es porque exige tu atención hoy.

   Se compromete con el modo oscuro a propósito. Un panel futurista en
   fondo claro no es lo mismo, así que no se ofrece a medias.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    color-scheme: dark;

    /* Superficies: del espacio profundo hacia arriba */
    --ground:    #070A11;
    --surface:   #0F1420;
    --surface-2: #171E2C;
    --surface-3: #1F2839;

    /* Tinta */
    --ink:       #E9EFFA;
    --ink-soft:  #94A4BF;
    --ink-faint: #64748B;

    /* Líneas */
    --rule:      #202A3C;
    --rule-soft: #171F2D;

    /* Acentos */
    --accent:      #22D3EE;   /* cian eléctrico: la acción */
    --accent-2:    #8B5CF6;   /* violeta: el acompañante */
    --accent-ink:  #041019;   /* texto sobre el cian */
    --accent-bg:   #0C2A33;
    --accent-line: #1B5F70;

    /* Semánticos: separados del acento a propósito */
    --good:     #34D399;
    --good-bg:  #08231C;
    --warn:     #FBBF24;
    --warn-bg:  #2A1F06;
    --bad:      #FB7185;
    --bad-bg:   #2C0F16;

    /* Brillos */
    --glow:      0 0 24px -4px rgba(34, 211, 238, .45);
    --glow-soft: 0 0 18px -6px rgba(34, 211, 238, .3);
    --shadow:    0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -20px rgba(0, 0, 0, .9);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .6), 0 24px 50px -28px rgba(0, 0, 0, 1);

    --f-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --r: 12px;
    --shell: 30rem;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--f-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Resplandor ambiental: da profundidad sin ensuciar el contenido. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(70rem 40rem at 50% -10%, rgba(34, 211, 238, .07), transparent 60%),
        radial-gradient(50rem 30rem at 100% 100%, rgba(139, 92, 246, .06), transparent 60%);
}

/* ─── Estructura ────────────────────────────────────────────────── */

.shell {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    max-width: var(--shell);
    margin: 0 auto;
    background: transparent;
}
@media (min-width: 900px) {
    :root { --shell: 44rem; }
    .shell {
        min-height: calc(100vh - 2rem);
        margin: 1rem auto;
        border: 1px solid var(--rule);
        border-radius: 20px;
        overflow: hidden;
        background: var(--ground);
        box-shadow: var(--shadow-lg);
    }
}

.main {
    flex: 1;
    padding: 16px 16px 120px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ─── Cabecera ──────────────────────────────────────────────────── */

.hdr {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(11px + env(safe-area-inset-top)) 16px 11px;
    background: rgba(15, 20, 32, .82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rule);
}
.hdr__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.hdr__mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    color: var(--accent-ink);
    font-family: var(--f-mono);
    font-size: 15px;
    font-weight: 600;
    box-shadow: var(--glow-soft);
}
.hdr__name {
    font-size: 14.5px; font-weight: 700; line-height: 1.15;
    letter-spacing: -.01em;
}
.hdr__who { font-size: 11px; color: var(--ink-faint); line-height: 1.2; }
.hdr__acts { display: flex; gap: 5px; }
.hdr__btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink-soft);
    text-decoration: none;
    transition: color .15s, border-color .15s;
}
.hdr__btn:hover { color: var(--accent); border-color: var(--accent-line); }
.hdr__btn svg { width: 17px; height: 17px; }
.hdr__btn--badge { position: relative; }
.hdr__badge {
    position: absolute;
    top: -5px; right: -5px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--f-mono);
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1;
    box-shadow: var(--glow-soft);
}

/* ─── Navegación inferior ───────────────────────────────────────── */

/* Flota siempre por encima del contenido, nunca pegada al borde ni
   arrastrada por el scroll: en una pantalla larga tiene que seguir ahí. */
.nav {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 40;
    display: flex;
    justify-content: center;
    padding: 0 12px;
    pointer-events: none;   /* el hueco alrededor deja pasar los clics */
}
@media (min-width: 900px) {
    /* En escritorio se separa del borde inferior de la tarjeta. */
    .nav { bottom: 30px; }
}

.nav__bar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    padding: 7px;
    background: rgba(18, 24, 36, .78);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid rgba(148, 164, 191, .16);
    border-radius: 18px;
    box-shadow:
        0 10px 30px -8px rgba(0, 0, 0, .75),
        0 30px 60px -20px rgba(0, 0, 0, .9),
        inset 0 1px 0 rgba(255, 255, 255, .07);
}
.nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 11px;
    color: var(--ink-faint);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    transition: color .15s, background .15s;
}
.nav__item svg { width: 20px; height: 20px; }
.nav__item:hover { color: var(--ink-soft); }
.nav__item.is-active { color: var(--accent); background: var(--accent-bg); }

.nav__fab {
    flex: 0 0 auto;
    width: 50px; height: 50px;
    margin: 0 6px;
    display: grid; place-items: center;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    color: var(--accent-ink);
    cursor: pointer;
    box-shadow: var(--glow);
    transition: transform .12s;
}
.nav__fab svg { width: 24px; height: 24px; }
.nav__fab:active { transform: scale(.93); }

/* ─── Tipografía ────────────────────────────────────────────────── */

h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p  { margin: 0; }

a { color: var(--accent); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .sub { font-size: 12.5px; color: var(--ink-soft); }

.eyebrow {
    font-family: var(--f-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12.5px; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section__head a { font-size: 12.5px; font-weight: 600; text-decoration: none; }

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}
.card__body { padding: 15px 16px; }

.stack { display: flex; flex-direction: column; gap: 11px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.spread { flex: 1; }

/* ─── Bloque principal ──────────────────────────────────────────── */

.hero {
    position: relative;
    overflow: hidden;
    padding: 20px 18px;
    border: 1px solid var(--accent-line);
    border-radius: 16px;
    background:
        linear-gradient(150deg, rgba(34, 211, 238, .14), rgba(139, 92, 246, .12) 55%, transparent),
        var(--surface);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
}
/* Línea de luz superior: el detalle que lo hace parecer un panel encendido. */
.hero::after {
    content: "";
    position: absolute;
    top: 0; left: 12%; right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: .7;
}
.hero__label {
    font-family: var(--f-mono);
    font-size: 10.5px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.hero__amount {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    font-size: 36px;
    font-weight: 600;
    letter-spacing: -.04em;
    line-height: 1.05;
    margin-top: 6px;
    color: var(--ink);
    text-shadow: 0 0 30px rgba(34, 211, 238, .35);
}
.hero__meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--ink-soft); }
.hero__bar {
    height: 5px;
    margin-top: 14px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
}
.hero__bar > i {
    display: block; height: 100%; border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    box-shadow: var(--glow-soft);
}

/* ─── Fichas de dato ────────────────────────────────────────────── */

.tile { padding: 13px 14px; }
.tile__label {
    font-family: var(--f-mono);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.tile__value {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.04em;
    margin-top: 6px;
}
.tile__value.is-warn { color: var(--warn); }
.tile__value.is-bad  { color: var(--bad); }
.tile__value.is-good { color: var(--good); }
.tile__foot { font-size: 11px; color: var(--ink-faint); margin-top: 3px; line-height: 1.4; }

/* ─── Etiquetas de estado ───────────────────────────────────────── */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.chip--pendiente { background: var(--surface-3); color: var(--ink-soft); border-color: var(--rule); }
.chip--parcial   { background: var(--warn-bg);   color: var(--warn); border-color: rgba(251,191,36,.3); }
.chip--pagada    { background: var(--good-bg);   color: var(--good); border-color: rgba(52,211,153,.3); }
.chip--vencida   { background: var(--bad-bg);    color: var(--bad);  border-color: rgba(251,113,133,.35); }
.chip--tarjeta,
.chip--credito   {
    background: var(--surface-3); color: var(--ink-soft); border-color: var(--rule);
    font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
}

/* ─── Fila de deuda ─────────────────────────────────────────────── */

.debt {
    position: relative;
    display: block;
    padding: 14px 15px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: border-color .15s;
}
/* Franja vertical de estado en el borde izquierdo. */
.debt::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--accent);
}
.debt:hover { border-color: var(--accent-line); }
.debt.is-paid { opacity: .6; }
.debt.is-paid::before { background: var(--good); }
.debt.is-late::before { background: var(--bad); }

.debt__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.debt__name { font-size: 15px; font-weight: 700; line-height: 1.25; }
.debt__who  { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.debt__amt  {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.03em;
    text-align: right;
    white-space: nowrap;
}
.debt__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--ink-soft); }

.bar { height: 4px; margin-top: 10px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar > i {
    display: block; height: 100%; border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.bar > i.is-good { background: var(--good); }

/* ─── Listas y tablas ───────────────────────────────────────────── */

.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--rule-soft); }
.list__row { display: flex; align-items: center; gap: 11px; padding: 12px 15px; }
a.list__row { text-decoration: none; color: inherit; transition: background .15s; }
a.list__row:hover { background: var(--surface-2); }
.list__main { flex: 1; min-width: 0; }
.list__title { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.list__sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.list__amt {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -.03em;
    white-space: nowrap;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
th {
    font-family: var(--f-mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    background: var(--surface-2);
    position: sticky;
    top: 0;
}
td.n { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }
tr.is-paid td { color: var(--ink-faint); }
tr.is-next td { background: var(--accent-bg); color: var(--ink); }

/* ─── Formularios ───────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
    font-family: var(--f-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.field__hint { font-size: 11.5px; color: var(--ink-faint); line-height: 1.45; }

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: .7; }
input[type="number"], input[type="date"] { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, .14);
}
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A4BF' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 32px;
}
textarea { min-height: 68px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 12px 17px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--accent-ink);
    background: linear-gradient(140deg, var(--accent), #06B6D4);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--glow-soft);
    transition: transform .12s, box-shadow .15s;
}
.btn:hover { box-shadow: var(--glow); }
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn--ghost {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--rule);
    box-shadow: none;
}
.btn--ghost:hover { border-color: var(--accent-line); color: var(--accent); box-shadow: none; }
.btn--danger {
    background: transparent;
    color: var(--bad);
    border-color: rgba(251, 113, 133, .4);
    box-shadow: none;
}
.btn--danger:hover { background: var(--bad-bg); box-shadow: none; }
.btn--sm { padding: 8px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; box-shadow: none; }

.seg {
    display: flex;
    gap: 3px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 12px;
}
.seg a, .seg button {
    flex: 1;
    padding: 8px 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.seg a:hover, .seg button:hover { color: var(--ink); }
.seg a.is-active, .seg button.is-active {
    background: var(--accent-bg);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* ─── Avisos ────────────────────────────────────────────────────── */

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid;
}
.flash--ok    { background: var(--good-bg); color: var(--good); border-color: rgba(52,211,153,.35); }
.flash--error { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(251,113,133,.4); }
.flash--info  { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }

/* Detalle dentro de un aviso: qué vencimientos son, no solo cuántos. */
.flash__items { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-top: 7px; }
.flash__items li { font-size: 12px; font-weight: 400; opacity: .92; }
.flash__items a { color: inherit; font-weight: 600; text-decoration: underline; }

/* Minimo / total / margen: los tres numeros del mes, uno al lado del otro. */
.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.split > div { display: flex; flex-direction: column; gap: 3px; }
.split__label { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.split__num { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.split--good .split__num { color: var(--good); }
.split--bad  .split__num { color: var(--bad); }
@media (max-width: 560px) { .split { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .split { grid-template-columns: 1fr 1fr; } }

/* Deuda partida en capital + intereses, bajo la cifra grande. */
.hero__break { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.hero__break .num { font-weight: 650; color: var(--ink); }
.hero__plus { opacity: .5; margin: 0 3px; }

/* Lo que gana abonar de mas: el unico numero del panel que invita a actuar. */
.gain {
    margin-top: 12px; padding: 9px 11px; font-size: 12px; line-height: 1.5;
    border-radius: 9px; color: var(--ink-soft);
    background: var(--good-bg); border: 1px solid rgba(52,211,153,.28);
}
.gain__num { color: var(--good); font-weight: 700; font-variant-numeric: tabular-nums; }
.gain a { color: var(--good); font-weight: 600; white-space: nowrap; }

/* Barra del minimo del mes: en verde lo que ya se cubrio de lo obligatorio. */
.minbar { height: 7px; border-radius: 99px; background: var(--rule); overflow: hidden; margin-top: 12px; }
.minbar > i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width .35s ease; }
.minbar__note { margin-top: 7px; color: var(--ink-soft); }
.minbar__paid { color: var(--good); font-weight: 600; }

/* Pie de la lista de vencimientos: las sumas, separadas del detalle. */
.list__row--total { background: var(--rule-soft); }
.list__row--total .list__title { font-weight: 600; }

.empty {
    padding: 32px 22px;
    text-align: center;
    border: 1px dashed var(--rule);
    border-radius: var(--r);
    color: var(--ink-faint);
    font-size: 13px;
    background: var(--surface);
}
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 5px; }

/* ─── Panel desplegable ─────────────────────────────────────────── */

details.panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}
details.panel > summary {
    padding: 13px 16px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
    content: "+";
    font-family: var(--f-mono);
    font-size: 17px;
    color: var(--accent);
}
details.panel[open] > summary::after { content: "−"; }
details.panel[open] > summary { border-bottom: 1px solid var(--rule-soft); }
details.panel > .panel__body { padding: 15px 16px; display: flex; flex-direction: column; gap: 12px; }

/* ─── Hoja inferior (registro rápido) ───────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }
.sheet__scrim {
    position: absolute; inset: 0;
    background: rgba(4, 7, 13, .72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: sheet-fade .18s ease-out;
}
.sheet__panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-lg);
    animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
}
.sheet__grip {
    width: 40px; height: 4px;
    margin: 0 auto 16px;
    border-radius: 2px;
    background: var(--surface-3);
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet__close {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 1px solid var(--rule);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--ink-soft);
    cursor: pointer;
}
.sheet__close:hover { color: var(--accent); border-color: var(--accent-line); }
.sheet__close svg { width: 16px; height: 16px; }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

/* ─── Gráfica ───────────────────────────────────────────────────── */

.chart { width: 100%; height: auto; display: block; }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .grid { stroke: var(--rule-soft); stroke-width: 1; }
.chart .axis { stroke: var(--rule); stroke-width: 1; }
.chart .dot  { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .tick { fill: var(--ink-faint); font-family: var(--f-mono); font-size: 9px; }

/* ─── Entrada ───────────────────────────────────────────────────── */

.auth {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100dvh;
    max-width: 21rem;
    margin: 0 auto;
    padding: 24px 20px;
    gap: 22px;
}
.auth__mark {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    color: var(--accent-ink);
    font-family: var(--f-mono);
    font-size: 24px;
    font-weight: 600;
    box-shadow: var(--glow);
}

/* ─── Accesibilidad ─────────────────────────────────────────────── */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ─── Datos concretos dentro de una deuda ───────────────────────── */
/* Rejilla de pares dato/valor: fecha de corte, próximo pago, cuánto
   falta. Es lo que se mira al abrir la app, así que se lee sin abrir
   la deuda. */

.debt__facts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    margin-top: 12px;
    background: var(--rule-soft);
    border: 1px solid var(--rule-soft);
    border-radius: 9px;
    overflow: hidden;
}
@media (min-width: 460px) {
    .debt__facts { grid-template-columns: repeat(4, 1fr); }
}
.fact {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: var(--surface-2);
}
.fact__k {
    font-family: var(--f-mono);
    font-size: 9px;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
}
.fact__v {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
}
.fact__v.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.fact__v.is-warn { color: var(--warn); }
.fact__v.is-bad  { color: var(--bad); }
.fact__v.is-good { color: var(--good); }

.debt__alert {
    margin-top: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--bad-bg);
    color: var(--bad);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}
.debt__alert.is-info { background: var(--surface-3); color: var(--ink-soft); }

/* ─── Calendario mensual ────────────────────────────────────────── */

/* Un color = un significado, en todas las pantallas:
   verde por venir · gris pagado · rojo atrasado. */
.dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.dot--proxima { background: var(--good); }
.dot--vencida { background: var(--bad); }
.dot--pagada  { background: var(--ink-faint); }
.dot--corte   { background: transparent; border: 1.5px solid var(--accent); width: 8px; height: 8px; }

.cal__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 12px;
}
.cal__arrow {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--rule);
    color: var(--ink-soft);
    text-decoration: none;
    transition: color .15s, border-color .15s;
}
.cal__arrow:hover { color: var(--accent); border-color: var(--accent-line); }
.cal__arrow svg { width: 17px; height: 17px; }
.cal__title { text-align: center; line-height: 1.25; }
.cal__month { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.cal__sum { font-size: 11.5px; color: var(--ink-soft); }

.cal { padding: 12px; }

.cal__week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}
.cal__wd {
    text-align: center;
    font-family: var(--f-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--ink-faint);
}

.cal__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal__day {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 2px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--ink-faint);
    text-decoration: none;
    font-size: 13px;
}
.cal__day.is-empty { visibility: hidden; }
.cal__n { font-family: var(--f-mono); font-variant-numeric: tabular-nums; line-height: 1; }

.cal__day.has-events {
    background: var(--surface-2);
    border-color: var(--rule);
    color: var(--ink);
    font-weight: 600;
    transition: border-color .15s, transform .12s;
}
.cal__day.has-events:hover { border-color: var(--accent-line); transform: translateY(-1px); }

/* El día toma el color del caso más grave que contenga. */
.cal__day.is-proxima { border-color: rgba(52, 211, 153, .45); }
.cal__day.is-vencida { border-color: rgba(251, 113, 133, .55); background: var(--bad-bg); }
.cal__day.is-pagada  { opacity: .65; }

.cal__day.is-today {
    box-shadow: inset 0 0 0 2px var(--accent);
    color: var(--accent);
}

.cal__dots { display: flex; align-items: center; gap: 3px; min-height: 8px; }
.cal__more {
    font-family: var(--f-mono);
    font-size: 8.5px;
    font-style: normal;
    color: var(--ink-faint);
}

.cal__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--rule-soft);
    font-size: 11px;
    color: var(--ink-soft);
}
.cal__legend span { display: inline-flex; align-items: center; gap: 5px; }

.cal__dayhead {
    display: flex;
    align-items: baseline;
    gap: 9px;
    padding: 10px 15px;
    background: var(--surface-2);
    font-size: 12px;
    color: var(--ink-soft);
}
.cal__dayhead .num { font-size: 17px; font-weight: 700; color: var(--ink); }
.cal__dayhead.is-today .num { color: var(--accent); }

/* ─── Semáforo de compra en tarjeta ─────────────────────────────── */
/* Qué tan conveniente es comprar hoy: verde recién pasado el corte
   (ganas el ciclo entero), rojo cuando el corte está encima. */

.grace { border-left: 3px solid var(--rule); }
.grace--bueno { border-left-color: var(--good); }
.grace--medio { border-left-color: var(--warn); }
.grace--malo  { border-left-color: var(--bad); }

.grace__label {
    font-family: var(--f-mono);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.grace--bueno .grace__label { color: var(--good); }
.grace--medio .grace__label { color: var(--warn); }
.grace--malo  .grace__label { color: var(--bad); }

.grace__days {
    font-size: 15px;
    font-weight: 600;
    margin-top: 4px;
    color: var(--ink);
}
.grace__days .num { font-size: 26px; letter-spacing: -.03em; }

.grace__dot {
    width: 12px; height: 12px;
    margin-top: 4px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.grace--bueno .grace__dot { background: var(--good); box-shadow: 0 0 14px -2px var(--good); }
.grace--medio .grace__dot { background: var(--warn); box-shadow: 0 0 14px -2px var(--warn); }
.grace--malo  .grace__dot { background: var(--bad);  box-shadow: 0 0 14px -2px var(--bad); }

/* La barra va del inicio del ciclo al corte. El degradado avisa que el
   beneficio se va perdiendo conforme avanza. */
.grace__bar {
    position: relative;
    height: 7px;
    margin-top: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--good) 45%, transparent),
        color-mix(in srgb, var(--warn) 45%, transparent) 55%,
        color-mix(in srgb, var(--bad) 55%, transparent));
    overflow: visible;
}
.grace__bar > i {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: var(--surface-3);
    opacity: .78;
}
/* Dónde estás hoy dentro del ciclo. */
.grace__now {
    position: absolute;
    top: -4px;
    width: 3px; height: 15px;
    margin-left: -1.5px;
    border-radius: 2px;
    background: var(--ink);
    box-shadow: 0 0 0 2px var(--surface);
}

.grace__ends {
    margin-top: 7px;
    font-family: var(--f-mono);
    font-size: 10px;
    color: var(--ink-faint);
}

.grace__text { margin-top: 12px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }
.grace__warn {
    margin-top: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 11.5px;
    color: var(--ink-faint);
    line-height: 1.5;
}

/* Versión compacta del semáforo, para la tarjeta del inicio. */
.grace-mini {
    margin-top: 11px;
    padding: 10px 11px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--rule-soft);
}
.grace-mini__txt {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
}
.grace-mini .grace__dot { width: 9px; height: 9px; margin: 0; }
.grace-mini--x { display: none; }
.grace--bueno .grace-mini__txt, .grace-mini.grace--bueno .grace-mini__txt { color: var(--good); }
.grace--medio .grace-mini__txt, .grace-mini.grace--medio .grace-mini__txt { color: var(--warn); }
.grace--malo  .grace-mini__txt, .grace-mini.grace--malo  .grace-mini__txt { color: var(--bad); }
.grace-mini__days { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }
.grace__bar--mini { height: 5px; margin-top: 9px; }
.grace__bar--mini .grace__now { top: -3px; height: 11px; }
.grace-mini__tip {
    margin-top: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--bad);
}

/* ─── El contorno de la tarjeta lleva el color del semáforo ─────── */
/* Se ve de lejos, sin leer nada: verde conviene comprar, rojo mejor
   esperar al corte. La franja izquierda sigue marcando el estado de
   pago, así que son dos señales que no se pisan. */

/* El borde va a color pleno, no diluido: la idea es reconocerlo de una
   ojeada desde el otro lado de la mesa. */
.debt.grace--bueno,
.debt.grace--medio,
.debt.grace--malo { border-width: 1.5px; }

.debt.grace--bueno {
    border-color: var(--good);
    box-shadow: var(--shadow),
                0 0 0 1px color-mix(in srgb, var(--good) 30%, transparent),
                0 0 28px -6px color-mix(in srgb, var(--good) 70%, transparent);
}
.debt.grace--medio {
    border-color: var(--warn);
    box-shadow: var(--shadow),
                0 0 0 1px color-mix(in srgb, var(--warn) 30%, transparent),
                0 0 28px -6px color-mix(in srgb, var(--warn) 70%, transparent);
}
.debt.grace--malo {
    border-color: var(--bad);
    box-shadow: var(--shadow),
                0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent),
                0 0 28px -5px color-mix(in srgb, var(--bad) 80%, transparent);
}

/* La franja lateral deja de ser cian y se suma al semáforo: si tira de
   otro color, le quita fuerza al contorno en vez de reforzarlo. */
.debt.grace--bueno::before { background: var(--good); }
.debt.grace--medio::before { background: var(--warn); }
.debt.grace--malo::before  { background: var(--bad); }

.debt.grace--bueno::before,
.debt.grace--medio::before,
.debt.grace--malo::before { width: 4px; }

/* Un tinte muy leve del mismo color en el fondo, para que el bloque
   entero se lea como una unidad. */
.debt.grace--bueno { background: color-mix(in srgb, var(--good) 4%, var(--surface)); }
.debt.grace--medio { background: color-mix(in srgb, var(--warn) 4%, var(--surface)); }
.debt.grace--malo  { background: color-mix(in srgb, var(--bad) 6%, var(--surface)); }

.debt.grace--bueno:hover { box-shadow: var(--shadow), 0 0 34px -4px color-mix(in srgb, var(--good) 85%, transparent); }
.debt.grace--medio:hover { box-shadow: var(--shadow), 0 0 34px -4px color-mix(in srgb, var(--warn) 85%, transparent); }
.debt.grace--malo:hover  { box-shadow: var(--shadow), 0 0 34px -4px color-mix(in srgb, var(--bad) 85%, transparent); }

/* El atraso NO pisa el contorno: ya se anuncia con la franja izquierda
   roja, el fondo teñido y el aviso al pie. El borde queda para el
   semáforo, que es la señal que se pidió ver de un vistazo. */

/* En el mini-semáforo, el punto toma su color aunque herede clases. */
.grace-mini.grace--bueno .grace__dot { background: var(--good); box-shadow: 0 0 10px -1px var(--good); }
.grace-mini.grace--medio .grace__dot { background: var(--warn); box-shadow: 0 0 10px -1px var(--warn); }
.grace-mini.grace--malo  .grace__dot { background: var(--bad);  box-shadow: 0 0 10px -1px var(--bad); }
