/* ============================================================
   Núcleo de Pagos — tema "consola financiera"
   Convención: BEM.  Base: Bootstrap 5 (solo grid/reset).
   ============================================================ */

:root {
    --bg:        #070a14;
    --bg-2:      #0b1020;
    --surface:   rgba(20, 27, 48, 0.55);
    --surface-2: rgba(30, 40, 68, 0.5);
    --border:    rgba(124, 148, 255, 0.14);
    --border-hi: rgba(124, 148, 255, 0.30);

    --text:   #e8ecf8;
    --muted:  #8b93b5;
    --faint:  #5b638a;

    --cyan:   #35e0d0;
    --violet: #7c5cff;
    --ok:     #4ef0a3;
    --due:    #ff6b8b;
    --warn:   #ffcf5c;

    --grad:      linear-gradient(120deg, #35e0d0 0%, #7c5cff 100%);
    --grad-soft: linear-gradient(120deg, rgba(53,224,208,.16), rgba(124,92,255,.16));

    --radius:    18px;
    --radius-sm: 12px;
    --shadow:    0 24px 60px -30px rgba(0, 0, 0, .8);

    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body:    'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body.app {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ---------- Fondo: aurora + malla ---------- */
.aurora {
    position: fixed;
    inset: -20% -10% auto -10%;
    height: 90vh;
    z-index: -2;
    background:
        radial-gradient(38% 45% at 18% 12%, rgba(53, 224, 208, .22), transparent 60%),
        radial-gradient(42% 50% at 82% 8%,  rgba(124, 92, 255, .26), transparent 62%),
        radial-gradient(50% 55% at 55% 40%, rgba(56, 120, 255, .12), transparent 70%);
    filter: blur(30px);
    animation: aurora-drift 18s ease-in-out infinite alternate;
}
@keyframes aurora-drift {
    0%   { transform: translate3d(-2%, -1%, 0) scale(1);    opacity: .9; }
    100% { transform: translate3d(3%, 2%, 0)  scale(1.08);  opacity: 1;  }
}
.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(124, 148, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124, 148, 255, .05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 40%, transparent 85%);
            mask-image: radial-gradient(120% 80% at 50% 0%, #000 40%, transparent 85%);
    pointer-events: none;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(14px);
    background: linear-gradient(to bottom, rgba(7, 10, 20, .85), rgba(7, 10, 20, .4));
    border-bottom: 1px solid var(--border);
}
.topbar__inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand__mark {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border-radius: 11px;
    background: var(--grad-soft);
    border: 1px solid var(--border-hi);
}
.brand__text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text);
}
.brand__accent { color: var(--cyan); }
.topbar__nav { display: flex; align-items: center; gap: 18px; }
.topbar__link { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem; }
.topbar__link:hover { color: var(--text); }

/* ---------- Botón principal ---------- */
.btn-glow {
    --pad-y: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: var(--pad-y) 24px;
    border: none;
    border-radius: 999px;
    background: var(--grad);
    color: #05121a;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .96rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 30px -10px rgba(53, 224, 208, .6), inset 0 1px 0 rgba(255, 255, 255, .3);
    transition: transform .18s ease, box-shadow .25s ease, filter .2s ease;
}
.btn-glow:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -12px rgba(124, 92, 255, .7); filter: brightness(1.06); }
.btn-glow:active { transform: translateY(0); }
.btn-glow--sm { --pad-y: 9px; padding: 9px 18px; font-size: .88rem; }
.btn-glow--full { width: 100%; margin-top: 4px; }

.btn-danger {
    width: 100%;
    padding: 11px 18px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid rgba(255, 107, 139, .3);
    color: var(--due);
    font-family: var(--font-display);
    font-weight: 500;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}
.btn-danger:hover { background: rgba(255, 107, 139, .1); border-color: rgba(255, 107, 139, .55); }

/* ---------- Layout ---------- */
.main { max-width: 1320px; padding: 34px 22px 60px; }
.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 22px;
    align-items: start;
}
@media (max-width: 900px) { .layout-split { grid-template-columns: 1fr; } }

/* ---------- Flash ---------- */
.flash {
    border-radius: var(--radius-sm);
    padding: 13px 18px;
    margin-bottom: 20px;
    font-weight: 500;
    border: 1px solid transparent;
    animation: flash-in .4s ease both;
}
.flash--ok    { background: rgba(78, 240, 163, .1);  border-color: rgba(78, 240, 163, .35);  color: var(--ok); }
.flash--error { background: rgba(255, 107, 139, .1); border-color: rgba(255, 107, 139, .35); color: var(--due); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 34px;
    padding: 8px 4px 20px;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.eyebrow {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .28em;
    font-size: .72rem;
    color: var(--cyan);
    margin: 0 0 14px;
}
.hero__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin: 0 0 16px;
}
.grad-text {
    background: var(--grad);
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}
.hero__sub { color: var(--muted); font-size: 1.02rem; max-width: 44ch; margin: 0 0 24px; }

.hero__panel {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 26px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}
@media (max-width: 520px) { .hero__panel { flex-direction: column; text-align: center; } }
.hero__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; flex: 1; }

/* ---------- Gauge radial ---------- */
.gauge { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.gauge--lg { width: 172px; height: 172px; }
.gauge__svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge__track { fill: none; stroke: rgba(124, 148, 255, .12); stroke-width: 9; }
.gauge__fill {
    fill: none;
    stroke: url(#gauge-grad);
    stroke: var(--cyan);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-dasharray: 326.7;         /* 2πr, r=52 */
    stroke-dashoffset: 326.7;
    filter: drop-shadow(0 0 6px rgba(53, 224, 208, .55));
    transition: stroke-dashoffset 1.1s cubic-bezier(.2, .8, .2, 1);
}
.gauge__center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
}
.gauge__pct { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1; }
.gauge__pct small { font-size: .9rem; color: var(--muted); margin-left: 1px; }
.gauge__label { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-top: 4px; }

/* ---------- Stats / métricas ---------- */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat__label { font-size: .74rem; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.stat__value { font-size: 1.05rem; font-weight: 600; }
.stat__value--ok  { color: var(--ok); }
.stat__value--due { color: var(--due); }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 22px 0;
}
@media (max-width: 720px) { .metric-grid { grid-template-columns: 1fr 1fr; } }
.metric {
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.metric::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--grad);
    opacity: .7;
}
.metric--ok::before  { background: var(--ok); }
.metric--due::before { background: var(--due); }
.metric__label { display: block; font-size: .74rem; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.metric__value { font-size: 1.4rem; font-weight: 600; }
.metric--ok  .metric__value { color: var(--ok); }
.metric--due .metric__value { color: var(--due); }

/* ---------- Panel ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel__title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: -0.02em; margin: 0; }
.panel__hint { font-size: .78rem; color: var(--faint); }

/* ---------- Formulario ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.field__label { font-size: .82rem; font-weight: 500; color: var(--muted); }
.field__opt { color: var(--faint); font-weight: 400; }

.field__input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(7, 11, 22, .6);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: .96rem;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    appearance: none;
}
.field__input::placeholder { color: var(--faint); }
.field__input:focus {
    outline: none;
    border-color: var(--border-hi);
    background: rgba(7, 11, 22, .85);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
}
.field__input--money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.field__money { position: relative; display: flex; align-items: center; }
.field__prefix, .field__suffix {
    position: absolute;
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: .9rem;
    pointer-events: none;
}
.field__prefix { left: 14px; }
.field__prefix ~ .field__input { padding-left: 30px; }
.field__suffix { right: 14px; }

.field__select { position: relative; }
.field__select::after {
    content: "▾";
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    font-size: .8rem;
}
.field__select .field__input { padding-right: 34px; cursor: pointer; }
.field__input option { background: #0b1020; color: var(--text); }

.field__quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 3px; }
.chip-btn {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: .76rem;
    cursor: pointer;
    transition: all .18s ease;
}
.chip-btn:hover { color: var(--text); border-color: var(--border-hi); background: rgba(124, 92, 255, .12); }

.form__error { color: var(--due); font-size: .85rem; margin: 6px 0 0; }

/* ---------- Vista previa del total ---------- */
.total-preview {
    margin-top: 4px;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    background: var(--grad-soft);
    border: 1px solid var(--border-hi);
}
.total-preview__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.total-preview__row span:first-child { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.total-preview__value { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.total-preview__hint { font-size: .78rem; color: var(--faint); margin-top: 4px; }
.total-preview.is-active .total-preview__value { color: var(--cyan); }

/* ---------- Lista de préstamos ---------- */
.loan-list { display: flex; flex-direction: column; gap: 12px; }
.loan-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 17px 19px;
    border-radius: var(--radius-sm);
    background: rgba(11, 16, 32, .5);
    border: 1px solid var(--border);
    transition: transform .18s ease, border-color .2s ease, background .2s ease;
}
.loan-card:hover { transform: translateY(-2px); border-color: var(--border-hi); background: rgba(20, 27, 48, .7); }
.loan-card--done { opacity: .82; }
.loan-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.loan-card__title { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; margin: 0 0 3px; letter-spacing: -0.01em; }
.loan-card__meta { font-size: .8rem; color: var(--muted); margin: 0; }
.loan-card__figures { display: flex; justify-content: space-between; margin-top: 12px; }
.fig__label { display: block; font-size: .68rem; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.fig__value { font-size: 1rem; font-weight: 600; }
.fig__value--ok  { color: var(--ok); }
.fig__value--due { color: var(--due); }
.ta-r { text-align: right; }

.badge {
    font-family: var(--font-mono);
    font-size: .76rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--cyan);
    white-space: nowrap;
}
.badge--done { color: var(--ok); border-color: rgba(78, 240, 163, .35); background: rgba(78, 240, 163, .1); }

.progress-line { height: 6px; border-radius: 999px; background: rgba(124, 148, 255, .1); overflow: hidden; margin: 12px 0 2px; }
.progress-line__fill { display: block; height: 100%; border-radius: 999px; background: var(--grad); box-shadow: 0 0 10px rgba(53, 224, 208, .5); transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* ---------- Estados vacíos ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty--sm { padding: 26px 16px; }
.empty__icon { font-size: 2.2rem; color: var(--faint); margin-bottom: 10px; }
.empty__title { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; color: var(--text); }
.empty__text { margin: 0; font-size: .9rem; }

/* ---------- Detalle ---------- */
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: 16px; transition: color .2s; }
.back-link:hover { color: var(--cyan); }
.detail__hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.detail__title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 3vw, 2.2rem); letter-spacing: -0.02em; margin: 4px 0 12px; }
.detail__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.chip {
    font-size: .8rem;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
.chip--muted { color: var(--muted); }

.liquidado-note {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(78, 240, 163, .1);
    border: 1px solid rgba(78, 240, 163, .3);
    color: var(--ok);
    font-size: .88rem;
    margin-bottom: 16px;
}
.liquidado-note__icon { font-weight: 700; }

.danger-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- Historial de pagos ---------- */
.pago-list { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; padding-right: 2px; }
.pago {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    background: rgba(11, 16, 32, .5);
    border: 1px solid var(--border);
    animation: flash-in .35s ease both;
}
.pago__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pago__monto { font-size: 1.05rem; font-weight: 600; color: var(--ok); }
.pago__nota { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pago__side { display: flex; align-items: center; gap: 12px; }
.pago__fecha { font-family: var(--font-mono); font-size: .76rem; color: var(--faint); white-space: nowrap; }
.pago__del {
    background: transparent; border: none; color: var(--faint); cursor: pointer;
    font-size: .9rem; line-height: 1; padding: 4px; border-radius: 6px; transition: color .2s, background .2s;
}
.pago__del:hover { color: var(--due); background: rgba(255, 107, 139, .12); }

/* ---------- Estado de error ---------- */
.error-state { display: grid; place-items: center; padding: 60px 20px; }
.error-state__panel { text-align: center; max-width: 460px; }
.error-state__glyph { font-size: 2.6rem; color: var(--warn); margin-bottom: 12px; }
.error-state__title { font-family: var(--font-display); margin: 0 0 8px; }
.error-state__text { color: var(--muted); margin: 0 0 22px; }

/* ---------- Footer ---------- */
.footer {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 22px 40px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--faint);
    font-size: .82rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.footer__dim { font-family: var(--font-mono); }

/* ---------- Barra: usuario / logout ---------- */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .9rem;
    font-weight: 500;
    color: var(--text);
}
.user-chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.user-chip__dot--dios { background: var(--cyan); box-shadow: 0 0 8px rgba(53, 224, 208, .8); }
.user-chip__rol {
    font-family: var(--font-mono);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--cyan);
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(53, 224, 208, .12);
}
.logout-form { margin: 0; }
.topbar__logout {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: .92rem;
    font-weight: 500;
    padding: 0;
    color: var(--muted);
}
.topbar__logout:hover { color: var(--due); }

/* ---------- Login ---------- */
.auth {
    display: grid;
    place-items: center;
    min-height: 62vh;
    padding: 30px 16px;
}
.auth__card {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth__badge {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: var(--grad-soft);
    border: 1px solid var(--border-hi);
}
.auth__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.7rem;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}
.auth__sub { color: var(--muted); margin: 0 0 22px; font-size: .95rem; }
.auth .form { text-align: left; }

/* ---------- Lista de usuarios ---------- */
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    background: rgba(11, 16, 32, .5);
    border: 1px solid var(--border);
}
.user-row__main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-row__name { font-weight: 600; font-size: .98rem; }
.user-row__side { display: flex; align-items: center; gap: 12px; }
.user-row__lock { opacity: .6; font-size: .85rem; }
.badge--dios { color: var(--cyan); border-color: rgba(53, 224, 208, .35); background: rgba(53, 224, 208, .1); }
.field__hint { font-size: .76rem; color: var(--faint); }

/* ---------- Accesibilidad: menos movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
