/* ==========================================================================
   Finanzas — Sistema de diseño
   --------------------------------------------------------------------------
   Único archivo de estilos de la aplicación. No hay CSS inline en las vistas
   (la CSP lo prohíbe), así que todo componente visual vive aquí.

   1. Tokens (claro / oscuro)      6. Formularios
   2. Base                          7. Botones
   3. Layout de la app              8. Tablas y listas
   4. Encabezados de página         9. Componentes (badges, alertas, diálogos…)
   5. Tarjetas y métricas          10. Autenticación · 11. Utilidades
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
    color-scheme: light;

    --bg: #f3f6fa;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f1b2d;
    --text-2: #3b4a5f;
    --text-3: #64748b;

    /* Azul marino tomado del isotipo "F" del favicon */
    --brand: #1b4f86;
    --brand-strong: #133b66;
    --brand-soft: #e8f0f9;
    --brand-contrast: #ffffff;
    --accent: #0e9fb3;

    --income: #047857;
    --income-soft: #e7f7ef;
    --expense: #c81e1e;
    --expense-soft: #fdecec;
    --transfer: #6d28d9;
    --transfer-soft: #f1ebfd;
    --warning: #b45309;
    --warning-soft: #fdf4e3;
    --info: #1d4ed8;
    --info-soft: #e8efff;

    --focus: 0 0 0 3px rgba(27, 79, 134, .28);
    --shadow-sm: 0 1px 2px rgba(15, 27, 45, .05);
    --shadow: 0 1px 3px rgba(15, 27, 45, .06), 0 6px 16px -6px rgba(15, 27, 45, .08);
    --shadow-lg: 0 20px 50px -12px rgba(15, 27, 45, .28);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --sidebar-w: 264px;
    --topbar-h: 64px;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0a1120;
        --surface: #101a2c;
        --surface-2: #142036;
        --surface-3: #1a2842;
        --border: #22324f;
        --border-strong: #2f4266;
        --text: #e7eef8;
        --text-2: #b4c1d4;
        --text-3: #8797ae;
        --brand: #7fb2ec;
        --brand-strong: #a3c8f2;
        --brand-soft: rgba(127, 178, 236, .12);
        --brand-contrast: #0a1120;
        --accent: #3cc6d8;
        --income: #34d399;
        --income-soft: rgba(52, 211, 153, .12);
        --expense: #f87171;
        --expense-soft: rgba(248, 113, 113, .12);
        --transfer: #b69cff;
        --transfer-soft: rgba(182, 156, 255, .13);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, .12);
        --info: #93b4ff;
        --info-soft: rgba(147, 180, 255, .12);
        --focus: 0 0 0 3px rgba(127, 178, 236, .35);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 20px -8px rgba(0, 0, 0, .45);
        --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .6);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a1120;
    --surface: #101a2c;
    --surface-2: #142036;
    --surface-3: #1a2842;
    --border: #22324f;
    --border-strong: #2f4266;
    --text: #e7eef8;
    --text-2: #b4c1d4;
    --text-3: #8797ae;
    --brand: #7fb2ec;
    --brand-strong: #a3c8f2;
    --brand-soft: rgba(127, 178, 236, .12);
    --brand-contrast: #0a1120;
    --accent: #3cc6d8;
    --income: #34d399;
    --income-soft: rgba(52, 211, 153, .12);
    --expense: #f87171;
    --expense-soft: rgba(248, 113, 113, .12);
    --transfer: #b69cff;
    --transfer-soft: rgba(182, 156, 255, .13);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .12);
    --info: #93b4ff;
    --info-soft: rgba(147, 180, 255, .12);
    --focus: 0 0 0 3px rgba(127, 178, 236, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 20px -8px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .6);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

::selection { background: var(--brand-soft); }

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

.num { font-variant-numeric: tabular-nums; }

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 200;
    padding: 10px 14px;
    background: var(--brand);
    color: var(--brand-contrast);
    border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

/* 3. Layout de la app ------------------------------------------------------ */
.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    flex: none;
    overflow: hidden;
}
.brand-mark img { width: 30px; height: 30px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; }
.brand-domain { font-size: .75rem; color: var(--text-3); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
}

.nav-section {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 16px 12px 6px;
}
.nav-section:first-child { padding-top: 4px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 550;
    font-size: .93rem;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] {
    background: var(--brand-soft);
    color: var(--brand);
}
.nav-link[aria-current="page"] .icon { stroke-width: 2.3; }

.app-version { font-size: .72rem; font-family: var(--font-mono); color: var(--text-3); opacity: .8; }
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--text-3);
}

.powered {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-3);
}
.powered a { color: var(--text-2); font-weight: 650; }
.powered a:hover { color: var(--brand); }

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-weight: 650; color: var(--text-2); font-size: .95rem; }
.topbar-spacer { flex: 1; }

.menu-toggle { display: none; }

.content {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 20px 28px 28px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    font-size: .8rem;
    color: var(--text-3);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 28, .5);
    z-index: 55;
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .sidebar.is-open + .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px; }
    .app-footer { padding: 16px; }
}

/* Menú de usuario (details/summary: accesible y sin JS) */
.user-menu { position: relative; }
.user-menu > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid transparent;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--surface-3); }
.user-menu[open] > summary { background: var(--surface); border-color: var(--border); }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-contrast);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .85rem;
    flex: none;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: .88rem; }
.user-role { font-size: .72rem; color: var(--text-3); }

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 80;
}
.menu-panel form { margin: 0; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-2);
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.menu-item.danger { color: var(--expense); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

@media (max-width: 640px) {
    .user-meta { display: none; }
    .topbar-title { display: none; }
}

/* 4. Encabezados de página ------------------------------------------------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header p { color: var(--text-3); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-title h2 { display: flex; align-items: center; gap: 8px; }

/* 5. Tarjetas y métricas --------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}
.card + .card { margin-top: 20px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.card-header p { color: var(--text-3); font-size: .85rem; margin-top: 2px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-header { padding: 18px 22px 0; }
.card-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 10px;
}
.stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
}
.stat-icon .icon { width: 17px; height: 17px; }
.stat-value { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .92rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-hint { font-size: .75rem; color: var(--text-3); margin-top: 8px; }

.stat.featured {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
    border-color: transparent;
    color: var(--brand-contrast);
}
.stat.featured .stat-label,
.stat.featured .stat-sub,
.stat.featured .stat-hint { color: color-mix(in srgb, var(--brand-contrast) 80%, transparent); }
.stat.featured .stat-icon { background: rgba(255, 255, 255, .16); color: var(--brand-contrast); }
.stat.featured .stat-value { color: var(--brand-contrast); }

.tone-income .stat-icon { background: var(--income-soft); color: var(--income); }
.tone-expense .stat-icon { background: var(--expense-soft); color: var(--expense); }
.tone-transfer .stat-icon { background: var(--transfer-soft); color: var(--transfer); }
.tone-warning .stat-icon { background: var(--warning-soft); color: var(--warning); }

/* Rejillas de página */
.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
@media (min-width: 1100px) {
    .layout-split { grid-template-columns: 380px minmax(0, 1fr); }
    .layout-split.reverse { grid-template-columns: minmax(0, 1fr) 360px; }
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
    align-items: start;
}

/* Tarjeta de entidad (cuenta, deuda, suscripción, activo) */
.tile {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow .2s, border-color .2s;
}
.tile:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.tile.is-muted { opacity: .62; }
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tile-title { font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.tile-sub { color: var(--text-3); font-size: .83rem; }
.tile-amount { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.tile-accent { border-top: 3px solid var(--brand); }
.tile-accent.credit { border-top-color: var(--brand); }
.tile-accent.debit { border-top-color: var(--income); }
.tile-accent.cash { border-top-color: var(--warning); }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.kv dt, .kv > span:first-child { color: var(--text-3); }
.kv dd, .kv > span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv-list { display: flex; flex-direction: column; gap: 6px; }

.subpanel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.subpanel-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
}

/* Tabla compacta dentro de tarjetas */
.mini-table { width: 100%; border-collapse: collapse; font-size: .84rem; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; }
.mini-table th, .mini-table td { padding: 7px 12px; text-align: right; font-variant-numeric: tabular-nums; }
.mini-table thead th { font-size: .7rem; font-weight: 700; letter-spacing: .06em; color: var(--text-3); border-bottom: 1px solid var(--border); }
.mini-table tbody th { text-align: left; font-weight: 500; color: var(--text-3); }
.mini-table td { font-weight: 600; }

/* Tarjeta de crédito física ------------------------------------------- */
.cards-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card-tile { gap: 14px; }

.cc {
    --cc-bg: linear-gradient(135deg, #1b4f86 0%, #0d2745 100%);
    --cc-fg: #f8fbff;
    position: relative;
    aspect-ratio: 1.586;
    width: 100%;
    border-radius: 16px;
    padding: 18px 20px;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    color: var(--cc-fg);
    background: var(--cc-bg);
    box-shadow: 0 14px 30px -14px rgba(8, 15, 28, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
    overflow: hidden;
    overflow: clip;   /* evita que el contenido se desplace dentro de la tarjeta */
    isolation: isolate;
    user-select: none;
}
/* Brillo sutil en diagonal */
.cc::before {
    content: "";
    position: absolute;
    inset: -40% -10% auto auto;
    width: 75%;
    height: 140%;
    background: radial-gradient(closest-side, rgba(255, 255, 255, .22), transparent);
    transform: rotate(18deg);
    z-index: -1;
}
.cc--navy     { --cc-bg: linear-gradient(135deg, #245a94 0%, #0d2745 100%); }
.cc--midnight { --cc-bg: linear-gradient(135deg, #1f2937 0%, #030712 100%); }
.cc--graphite { --cc-bg: linear-gradient(135deg, #52525b 0%, #18181b 100%); }
.cc--emerald  { --cc-bg: linear-gradient(135deg, #059669 0%, #064e3b 100%); }
.cc--wine     { --cc-bg: linear-gradient(135deg, #9f1239 0%, #4c0519 100%); }
.cc--gold     { --cc-bg: linear-gradient(135deg, #e7c46f 0%, #a67c2d 55%, #7a5a1c 100%); --cc-fg: #2b1d05; }
.cc--platinum { --cc-bg: linear-gradient(135deg, #f3f4f6 0%, #cbd5e1 55%, #94a3b8 100%); --cc-fg: #1e293b; }
.cc--sunset   { --cc-bg: linear-gradient(135deg, #fb923c 0%, #e11d48 60%, #9d174d 100%); }
.cc--custom   { --cc-custom: #1b4f86; --cc-bg: linear-gradient(135deg, var(--cc-custom) 0%, color-mix(in srgb, var(--cc-custom) 55%, #000) 100%); }

.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cc-bank { font-weight: 700; font-size: .9rem; letter-spacing: .01em; opacity: .95; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-chip {
    align-self: center;
    width: 42px;
    height: 32px;
    border-radius: 7px;
    background:
        linear-gradient(90deg, transparent 32%, rgba(0, 0, 0, .18) 33%, rgba(0, 0, 0, .18) 35%, transparent 36%, transparent 64%, rgba(0, 0, 0, .18) 65%, rgba(0, 0, 0, .18) 67%, transparent 68%),
        linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .18) 46%, rgba(0, 0, 0, .18) 54%, transparent 55%),
        linear-gradient(135deg, #f5dd9a, #c9a14a);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}
.cc-number { font-family: var(--font-mono); font-size: 1.05rem; letter-spacing: .14em; margin: 8px 0 6px; white-space: nowrap; }
.cc-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; font-size: .78rem; }
.cc-name { font-weight: 650; text-transform: uppercase; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-meta { opacity: .85; white-space: nowrap; }

/* Marcas de red simuladas con texto y formas (no se usan logotipos oficiales) */
.cc-network { font-weight: 800; font-size: 1rem; line-height: 1; }
.cc-network--visa { font-style: italic; font-size: 1.35rem; letter-spacing: .02em; text-transform: uppercase; }
.cc-network--amex { font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border: 1.5px solid currentColor; border-radius: 4px; max-width: 76px; text-align: center; }
.cc-network--mastercard { position: relative; width: 46px; height: 28px; font-size: 0; }
.cc-network--mastercard::before,
.cc-network--mastercard::after { content: ""; position: absolute; top: 0; width: 28px; height: 28px; border-radius: 50%; }
.cc-network--mastercard::before { left: 0; background: #eb001b; }
.cc-network--mastercard::after { right: 0; background: #f79e1b; mix-blend-mode: hard-light; opacity: .92; }

.cc-preview-wrap { max-width: 340px; margin: 0 auto 4px; width: 100%; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cc-bg);
    cursor: pointer;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);
    transition: box-shadow .15s, transform .1s;
}
.swatch:hover { transform: scale(1.06); }
.swatches input:checked + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.swatches input:focus-visible + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand), var(--focus); }
.swatch-custom { background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444); }
.input-color { height: 44px; padding: 4px; cursor: pointer; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
details.subpanel > summary { cursor: pointer; list-style: revert; }

/* Barra apilada de límite: consumo + retenido por tasa cero */
.limit-bar { width: 100%; height: 10px; display: block; border-radius: 999px; overflow: hidden; }
.limit-track { fill: var(--surface-3); }
.limit-used { fill: var(--brand); }
.limit-held { fill: var(--warning); }
.legend-dot.brand { background: var(--brand); }
.legend-dot.held { background: var(--warning); }

/* Estado del corte de una tarjeta */
.card-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .86rem;
    color: var(--text-2);
}
.card-status--financiamiento { background: var(--warning-soft); border-color: transparent; }
.card-status--mora { background: var(--expense-soft); border-color: color-mix(in srgb, var(--expense) 35%, transparent); }

/* Tabla del asistente "Cuadrar corte" */
.statement-table tbody th {
    text-transform: none;
    letter-spacing: 0;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-2);
    background: none;
}
.statement-table td { min-width: 110px; }

/* Conciliación */
.reconcile-toggle { color: var(--text-3); }
.reconcile-toggle.is-on { color: var(--income); }

/* Sobres / fondos reservados */
.bucket-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bucket {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.bucket:hover { border-color: var(--brand); }
.bucket .rank-row { margin: 0; font-size: .86rem; }
.bucket .rank-row > span { display: inline-flex; align-items: center; gap: 6px; }
.dialog-footer.between { justify-content: space-between; }

/* Pestañas de página ------------------------------------------------------ */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--text-3);
    font-weight: 600;
    font-size: .92rem;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }

/* Opciones en tarjeta (intralímite / extralímite) */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

/* Simulador de liquidación */
.sim-panel { padding: 0; }
.sim-summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 22px;
    cursor: pointer;
}
.sim-summary::-webkit-details-marker { display: none; }
.sim-panel[open] .sim-summary { border-bottom: 1px solid var(--border); }
.sim-panel[open] .sim-summary > .icon { transform: rotate(180deg); }
.sim-body { padding: 18px 22px 22px; }
.sim-results { margin-bottom: 14px; }
.sim-results .stat-value { font-size: 1.2rem; }
.sim-order { margin: 0 0 10px; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--text-2); }

/* Barras de progreso nativas (<progress>) — sin estilos inline */
.progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
    display: block;
}
.progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; transition: width .4s; }
.progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.progress.income::-webkit-progress-value { background: var(--income); }
.progress.income::-moz-progress-bar { background: var(--income); }
.progress.expense::-webkit-progress-value { background: var(--expense); }
.progress.expense::-moz-progress-bar { background: var(--expense); }
.progress.warning::-webkit-progress-value { background: var(--warning); }
.progress.warning::-moz-progress-bar { background: var(--warning); }
.progress-meta { display: flex; justify-content: space-between; font-size: .76rem; color: var(--text-3); margin-top: 6px; }

/* Gráfico de barras SVG del dashboard */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; }
.chart .bar-income { fill: var(--income); }
.chart .bar-expense { fill: var(--expense); }
.chart .bar-income, .chart .bar-expense { opacity: .88; }
.chart .bar-income:hover, .chart .bar-expense:hover { opacity: 1; }
.chart-legend { display: flex; flex-wrap: wrap; white-space: nowrap; gap: 16px; font-size: .8rem; color: var(--text-3); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend-dot.income { background: var(--income); }
.legend-dot.expense { background: var(--expense); }

/* 6. Formularios ----------------------------------------------------------- */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row.cols-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 520px) {
    .form-row, .form-row.cols-3, .form-row.cols-2-1 { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-2);
}
.label .optional { font-weight: 400; color: var(--text-3); font-size: .78rem; }
.hint { font-size: .78rem; color: var(--text-3); }
.hint.warn { color: var(--warning); }

.input, .select, .textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); opacity: .8; }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input:disabled, .select:disabled { background: var(--surface-3); cursor: not-allowed; }
.input-sm { min-height: 34px; padding: 5px 9px; font-size: .88rem; }
.select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
    background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.textarea { min-height: 90px; resize: vertical; }

.input-group { position: relative; display: flex; align-items: stretch; }
.input-group .input { padding-left: 42px; }
.input-affix {
    position: absolute;
    left: 1px;
    top: 1px;
    bottom: 1px;
    width: 38px;
    display: grid;
    place-items: center;
    color: var(--text-3);
    font-weight: 600;
    font-size: .88rem;
    pointer-events: none;
}
.input-group .input-action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}
.input-group.has-action .input { padding-right: 46px; }

.input-lg { min-height: 52px; font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: .9rem;
}
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }

/* Control segmentado (tipo de movimiento, filtros) */
.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--surface-3);
    border-radius: 12px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 8px;
    border-radius: 9px;
    font-weight: 600;
    font-size: .88rem;
    color: var(--text-3);
    cursor: pointer;
    transition: background .15s, color .15s;
    text-align: center;
}
.segmented label:hover { color: var(--text); }
.segmented input:focus-visible + label { box-shadow: var(--focus); }
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input[value="expense"]:checked + label { color: var(--expense); }
.segmented input[value="income"]:checked + label { color: var(--income); }
.segmented input[value="transfer"]:checked + label { color: var(--transfer); }

.callout {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-2);
}
.callout .icon { margin-top: 1px; }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--text-2); }
.callout.info .icon { color: var(--info); }
.callout.warning { background: var(--warning-soft); border-color: transparent; }
.callout.warning .icon { color: var(--warning); }
.callout.success { background: var(--income-soft); border-color: transparent; }
.callout.success .icon { color: var(--income); }
.callout.danger { background: var(--expense-soft); border-color: transparent; }
.callout.danger .icon { color: var(--expense); }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
}

/* 7. Botones --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }

.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-success { background: var(--income); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-soft-danger { background: var(--expense-soft); color: var(--expense); }
.btn-soft-danger:hover { background: var(--expense); color: #fff; }

.btn-sm { min-height: 32px; padding: 5px 11px; font-size: .82rem; border-radius: 8px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { min-height: 48px; padding: 12px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; min-height: 32px; }

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 8. Tablas y listas ------------------------------------------------------- */
.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 12px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table .nowrap { white-space: nowrap; }
.table .muted { color: var(--text-3); font-size: .82rem; }
.table-actions { display: flex; justify-content: flex-end; gap: 4px; }

.tx-list { list-style: none; padding: 0; }
.tx-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: 0; }
.tx-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}
.tx-icon .icon { width: 18px; height: 18px; }
.tx-icon.income { background: var(--income-soft); color: var(--income); }
.tx-icon.expense { background: var(--expense-soft); color: var(--expense); }
.tx-icon.transfer { background: var(--transfer-soft); color: var(--transfer); }
.tx-main { min-width: 0; }
.tx-title { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: .78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.amount-income { color: var(--income); }
.amount-expense { color: var(--expense); }
.amount-transfer { color: var(--transfer); }

.rank-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rank-row { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; margin-bottom: 6px; }
.rank-row strong { font-variant-numeric: tabular-nums; }

.timeline { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.timeline-item {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
}
.date-chip {
    width: 46px;
    border-radius: 10px;
    background: var(--surface-3);
    text-align: center;
    padding: 5px 0;
    line-height: 1.1;
}
.date-chip .d { font-weight: 750; font-size: 1.05rem; display: block; }
.date-chip .m { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.date-chip.is-today { background: var(--brand); color: var(--brand-contrast); }
.date-chip.is-today .m { color: inherit; opacity: .85; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-3);
}
.pagination-links { display: flex; gap: 6px; }

/* 9. Componentes ----------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-2);
}
.badge-income, .badge-success { background: var(--income-soft); color: var(--income); }
.badge-expense, .badge-danger { background: var(--expense-soft); color: var(--expense); }
.badge-transfer { background: var(--transfer-soft); color: var(--transfer); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.dot.on { background: var(--income); }

/* Mensajes flash (toasts) */
.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    animation: toast-in .25s ease-out;
}
.toast .icon { margin-top: 1px; }
.toast-body { flex: 1; }
.toast.success { border-left-color: var(--income); }
.toast.success > .icon { color: var(--income); }
.toast.error { border-left-color: var(--expense); }
.toast.error > .icon { color: var(--expense); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning > .icon { color: var(--warning); }
.toast.info > .icon { color: var(--brand); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast-close { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* Diálogos (<dialog> nativo: trampa de foco y Esc incluidos) */
.dialog {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    margin: auto;
}
.dialog::backdrop { background: rgba(8, 15, 28, .55); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in .2s ease-out; }
.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.dialog-body { padding: 20px 22px; }
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px 18px;
}
.dialog-message { color: var(--text-2); }
.dialog-wide { width: min(680px, calc(100vw - 32px)); }
.dialog .kv dd { overflow-wrap: anywhere; }
.code-block {
    margin: 0;
    max-height: 280px;
    overflow: auto;
    padding: 12px 14px;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.chart a:hover rect { opacity: 1; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Estado vacío */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 36px 20px;
    color: var(--text-3);
}
.empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--surface-3);
    display: grid;
    place-items: center;
    color: var(--text-3);
    margin-bottom: 4px;
}
.empty h3 { color: var(--text); }
.empty p { max-width: 360px; font-size: .88rem; }

/* Ayuda contextual (tooltip accesible con <details>) */
.help { position: relative; display: inline-block; }
.help > summary {
    list-style: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: .72rem;
    font-weight: 800;
    cursor: pointer;
}
.help > summary::-webkit-details-marker { display: none; }
.help-panel {
    position: absolute;
    z-index: 30;
    right: 0;
    top: 26px;
    width: 280px;
    padding: 12px 14px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius);
    font-size: .8rem;
    font-weight: 400;
    line-height: 1.45;
    box-shadow: var(--shadow-lg);
}
.help-panel strong { color: inherit; }
.help-panel p + p { margin-top: 8px; }

/* Código / valores técnicos */
.code {
    font-family: var(--font-mono);
    font-size: .8rem;
    background: var(--surface-3);
    padding: 2px 6px;
    border-radius: 6px;
    overflow-wrap: anywhere;
}
.copy-box {
    display: flex;
    gap: 8px;
    align-items: center;
}
.copy-box .input { font-family: var(--font-mono); font-size: .8rem; }

/* 10. Autenticación -------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: var(--surface);
}
.auth-aside {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    color: #eaf2fc;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(14, 159, 179, .35) 0%, transparent 55%),
        radial-gradient(90% 70% at 100% 100%, rgba(127, 178, 236, .25) 0%, transparent 60%),
        linear-gradient(160deg, #173f6c 0%, #0d2745 70%, #0a1d35 100%);
}
.auth-aside::after {
    content: "";
    position: absolute;
    inset: auto -120px -160px auto;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 0 0 60px rgba(255, 255, 255, .025), 0 0 0 120px rgba(255, 255, 255, .02);
}
.auth-aside .brand-mark { width: 46px; height: 46px; border: 0; }
.auth-aside .brand-mark img { width: 36px; height: 36px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem; }
.auth-pitch h2 { color: #fff; font-size: 2rem; line-height: 1.15; letter-spacing: -.03em; max-width: 440px; }
.auth-pitch p { margin-top: 14px; color: rgba(234, 242, 252, .78); max-width: 420px; }
.auth-features { list-style: none; padding: 0; margin-top: 28px; display: grid; gap: 12px; }
.auth-features li { display: flex; gap: 10px; align-items: center; color: rgba(234, 242, 252, .9); font-size: .92rem; }
.auth-features .icon { color: #7fdbe8; }
.auth-aside .powered, .auth-aside .powered a { color: rgba(234, 242, 252, .75); }
.auth-aside .powered a:hover { color: #fff; }

.auth-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 24px;
    background: var(--bg);
}
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card > p { color: var(--text-3); margin: 6px 0 26px; }
.auth-foot { margin-top: 24px; display: flex; justify-content: center; align-items: center; gap: 8px; text-align: center; font-size: .82rem; color: var(--text-3); }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 700; }
.auth-mobile-foot { display: none; margin-top: 32px; justify-content: center; font-size: .8rem; }

@media (max-width: 900px) {
    .auth-body { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-mobile-brand, .auth-mobile-foot { display: flex; }
}

/* Documentos legales */
.legal-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 20px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.legal-brand { border: 0; padding: 0; height: auto; }
.legal-main { max-width: 860px; margin: 0 auto; padding: 28px 16px 8px; }
.legal-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.legal-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: .86rem;
    font-weight: 600;
    color: var(--text-2);
    border: 1px solid var(--border);
    background: var(--surface);
}
.legal-tab:hover { text-decoration: none; border-color: var(--border-strong); }
.legal-tab[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.legal-note { margin: 14px 4px 0; }
.legal-links { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.legal-links a { color: inherit; }
.legal-links a:hover { color: var(--brand); }
.auth-legal { margin-top: 18px; display: flex; justify-content: center; font-size: .78rem; color: var(--text-3); }

.prose { padding: 32px; line-height: 1.65; color: var(--text-2); }
.prose-header { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.prose-header h1 { margin-bottom: 4px; }
.prose h2 { margin: 28px 0 10px; font-size: 1.08rem; scroll-margin-top: calc(var(--topbar-h) + 12px); }
.prose p + p { margin-top: 10px; }
.prose ul { padding-left: 22px; margin: 8px 0; }
.prose li + li { margin-top: 6px; }
.prose strong { color: var(--text); }
.prose .lead { font-size: 1.02rem; color: var(--text); }
.prose .callout { margin: 14px 0; }
.prose .table-wrap { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.prose .table td { vertical-align: top; }
@media (max-width: 640px) { .prose { padding: 20px; } }

/* Aviso informativo de cookies */
.cookie-notice {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 110;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 560px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .84rem;
    color: var(--text-2);
}
.cookie-notice .icon { color: var(--brand); }
@media (max-width: 640px) {
    .cookie-notice { right: 16px; flex-wrap: wrap; }
}

/* Página de error */
.error-page { max-width: 480px; margin: 12vh auto; text-align: center; padding: 0 20px; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--brand); letter-spacing: -.04em; }
.error-page p { color: var(--text-3); margin: 8px 0 24px; }

/* 11. Utilidades ----------------------------------------------------------- */
.hidden, [hidden] { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.text-muted { color: var(--text-3); }
.text-soft { color: var(--text-2); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .76rem; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; align-items: start; }
.inline-form { display: inline; }

@media print {
    .sidebar, .topbar, .toasts, .page-actions, .tile-actions, .app-footer, .btn { display: none !important; }
    .main { margin: 0; }
    body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
