/* ===================== DebtPlan · estilos propios (mobile-first) ===================== */
:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #4f46e5;
    --primary-ink: #ffffff;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --amber: #d97706;
    --amber-soft: #fef3c7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --radius: 16px;
    --nav-h: 64px;
    --max: 480px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

h1, h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- Splash ---------- */
.app-splash {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 20px; background: var(--bg);
}
.app-splash__logo {
    width: 64px; height: 64px; border-radius: 18px; background: var(--primary);
    color: #fff; font-weight: 800; font-size: 26px; display: flex; align-items: center; justify-content: center;
}
.app-splash__spinner, .spinner {
    width: 28px; height: 28px; border: 3px solid var(--line);
    border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shell / layout ---------- */
.shell {
    max-width: var(--max); margin: 0 auto; min-height: 100dvh;
    display: flex; flex-direction: column; background: var(--bg);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px calc(14px) 18px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: var(--ink); color: #fff;
}
.topbar__title { font-size: 18px; font-weight: 700; }
.topbar__user { font-size: 13px; opacity: .8; display: flex; align-items: center; gap: 10px; }
.topbar__logout {
    background: rgba(255,255,255,.14); color: #fff; border: none;
    padding: 6px 10px; border-radius: 9px; font-size: 12px;
}
.content { flex: 1; padding: 16px; }

/* ---------- Bottom nav ---------- */
.bottomnav {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
    width: 100%; max-width: var(--max); height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--card); border-top: 1px solid var(--line);
    display: flex; z-index: 30;
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.bottomnav a.active { color: var(--primary); }
.bottomnav a .ico { font-size: 22px; line-height: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 14px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* ---------- Buttons ---------- */
.btn {
    border: none; border-radius: 14px; padding: 15px 18px; font-size: 16px; font-weight: 700;
    background: var(--primary); color: var(--primary-ink); width: 100%;
    transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn--ghost { background: #eef2ff; color: var(--primary); }
.btn--soft { background: var(--line); color: var(--ink); }
.btn--sm { padding: 10px 14px; font-size: 14px; width: auto; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--red { background: var(--red-soft); color: var(--red); }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; border-radius: 999px; transition: width .3s ease; background: var(--primary); }
.progress__bar--green { background: var(--green); }
.progress__bar--amber { background: var(--amber); }
.progress__bar--red { background: var(--red); }

/* ===================== Login ===================== */
.login {
    min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 22px; padding: 24px; max-width: var(--max); margin: 0 auto;
}
.login__logo {
    width: 72px; height: 72px; border-radius: 20px; background: var(--primary); color: #fff;
    font-weight: 800; font-size: 28px; display: flex; align-items: center; justify-content: center;
}
.login h1 { font-size: 24px; }
.login__form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
    width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
    font-size: 16px; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.login__error { color: var(--red); font-size: 14px; font-weight: 600; text-align: center; }
.login__users { display: flex; gap: 10px; width: 100%; }
.login__users button { flex: 1; }

/* ===================== Captura de gastos ===================== */
.capture { display: flex; flex-direction: column; gap: 14px; }
.capture__amount {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; text-align: center;
}
.capture__amount .cur { font-size: 22px; color: var(--muted); font-weight: 700; vertical-align: super; margin-right: 4px; }
.capture__amount .val { font-size: 52px; font-weight: 800; letter-spacing: -1px; }
.capture__amount .val.empty { color: #cbd5e1; }
.capture__hint { font-size: 13px; color: var(--muted); margin-top: 4px; min-height: 18px; }

.catgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat {
    background: var(--card); border: 2px solid transparent; border-radius: 14px; box-shadow: var(--shadow);
    padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: var(--ink); min-height: 78px; justify-content: center;
}
.cat .ico { font-size: 24px; }
.cat.sel { border-color: var(--primary); background: #eef2ff; color: var(--primary); }
.cat--fixed { opacity: .95; }

/* Keypad */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
    background: var(--card); border: none; border-radius: 14px; box-shadow: var(--shadow);
    padding: 18px 0; font-size: 24px; font-weight: 700; color: var(--ink);
}
.key:active { background: #eef2ff; }
.key--wide { grid-column: span 1; }
.key--action { color: var(--muted); font-size: 20px; }

.capture__note {
    display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
}
.capture__note .input { flex: 1; }
.notetoggle { background: none; border: none; color: var(--primary); font-weight: 700; font-size: 13px; padding: 4px; }

/* ---------- Toast confirmación ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%);
    background: var(--green); color: #fff; padding: 12px 20px; border-radius: 999px;
    font-weight: 700; font-size: 15px; box-shadow: 0 8px 24px rgba(22,163,74,.35);
    display: flex; align-items: center; gap: 8px; z-index: 50;
    animation: toastIn .25s ease, toastOut .3s ease 1.4s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- Utils ---------- */
.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.big-num { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 2px 8px; }

/* ===================== Deudas ===================== */
.debt {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; margin-bottom: 12px;
}
.debt__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.debt__name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.debt__order { width: 22px; height: 22px; border-radius: 7px; background: #eef2ff; color: var(--primary);
    font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.debt__type { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.debt__balance { text-align: right; }
.debt__balance .amt { font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.debt__balance .of { font-size: 11px; color: var(--muted); }
.debt__meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 10px 0 12px; }
.debt__actions { display: flex; gap: 8px; }
.debt__actions .btn { flex: 1; }

.debt--paid { opacity: .85; padding: 14px 16px; }
.debt--paid .debt__name { color: var(--muted); text-decoration: line-through; }
.debt--paid .tomb { font-size: 12px; color: var(--green); font-weight: 700; }

/* Celebración de cascada */
.celebrate {
    background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border-radius: var(--radius);
    padding: 18px; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(22,163,74,.3);
}
.celebrate h3 { font-size: 17px; margin-bottom: 4px; }
.celebrate p { font-size: 14px; margin: 0; opacity: .95; }
.celebrate__close { background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; margin-top: 10px; }

/* ===================== Modal / bottom-sheet ===================== */
.sheet-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 60;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fade .2s ease;
}
.sheet {
    background: var(--card); width: 100%; max-width: var(--max);
    border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: slideup .25s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }
.sheet h3 { font-size: 18px; margin-bottom: 4px; }
.sheet__sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.sheet__field { margin-bottom: 14px; }
.sheet__field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.sheet__amount {
    width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
    font-size: 28px; font-weight: 800; text-align: center; color: var(--ink);
}
.sheet__actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet__error { color: var(--red); font-size: 13px; font-weight: 600; margin-bottom: 10px; }

/* ===================== Dashboard ===================== */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.monthnav button {
    width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--card);
    box-shadow: var(--shadow); font-size: 20px; color: var(--ink);
}
.monthnav button:disabled { opacity: .35; }
.monthnav__label { text-align: center; }
.monthnav__label .m { font-size: 17px; font-weight: 800; text-transform: capitalize; }
.monthnav__label .d { font-size: 12px; color: var(--muted); }

.dcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.dcard__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dcard__title { font-size: 15px; font-weight: 800; }
.dcard__title small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.dcard__big { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; margin: 6px 0 2px; }
.dcard__big.red { color: var(--red); }
.dcard__sub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.dcard__star {
    background: #eef2ff; color: var(--primary); border-radius: 12px; padding: 12px 14px;
    font-size: 15px; font-weight: 700; margin-top: 14px; text-align: center;
}
.dcard__star.red { background: var(--red-soft); color: var(--red); }

.fijo-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.fijo-row:first-of-type { border-top: none; }
.fijo-row .ic { font-size: 18px; }
.fijo-row .nm { flex: 1; font-weight: 600; font-size: 14px; }
.fijo-row .nm.paid { color: var(--muted); }
.fijo-row .amt { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fijo-row .amt.paid { color: var(--green); font-weight: 700; }

.dalert {
    background: var(--amber-soft); color: var(--amber); border-radius: 12px; padding: 10px 12px;
    font-size: 13px; font-weight: 600; margin-top: 10px; display: flex; gap: 8px; align-items: flex-start;
}
.dcard__foot { font-size: 13px; color: var(--muted); margin-top: 12px; }
.dcard__foot b { color: var(--ink); }

/* Blazor error ui */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff3cd; padding: 12px 16px; box-shadow: 0 -1px 3px rgba(0,0,0,.1); z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
