/* ── Auth Loader ──────────────────────────────────────── */
#authLoader {
    position: fixed;
    inset: 0;
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

#authLoader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.auth-loader-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(196, 69, 54, 0.2);
    border-top-color: var(--accent-red);
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

.auth-loader-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Variables ───────────────────────────────────────── */
:root {
    --accent-red: #c44536;
    --gradient-red: linear-gradient(135deg, #c44536, #d95f4e);
    --dark-bg: #0a0a0a;
    --dark-card: #111111;
    --dark-card-border: rgba(255, 255, 255, 0.07);
    --text-secondary: #a0a0a0;
    --text-muted: #5a5a5a;
    --color-ingreso: #2ea043;
    --color-egreso: #c44536;
}

/* ── Base ────────────────────────────────────────────── */
body {
    font-family: 'Raleway', sans-serif;
    background: var(--dark-bg);
    min-height: 100vh;
    padding: 80px 20px 60px;
}

/* ── Background decorations ──────────────────────────── */
.page-bg-glow {
    position: fixed;
    top: 0;
    right: 0;
    width: 65vw;
    height: 65vh;
    background: radial-gradient(ellipse at 75% 15%, rgba(196, 69, 54, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.page-bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
}

/* ── Page container ──────────────────────────────────── */
.finanzas-container {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ── Header ──────────────────────────────────────────── */
.finanzas-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.finanzas-eyebrow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent-red);
    background: rgba(196, 69, 54, 0.1);
    border: 1px solid rgba(196, 69, 54, 0.25);
    border-radius: 20px;
    padding: 0.35rem 1rem;
    margin-bottom: 1rem;
}

.finanzas-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.5rem;
    line-height: 1.15;
}

.gradient-text {
    background: var(--gradient-red);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Period pills ────────────────────────────────────── */
.period-pills {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.period-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 20px;
    padding: 0.3rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.period-pill:hover {
    border-color: rgba(196, 69, 54, 0.4);
    color: #fff;
}

.period-pill.active {
    background: rgba(196, 69, 54, 0.15);
    border-color: var(--accent-red);
    color: #fff;
}

/* ── Stat cards ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: rgba(196, 69, 54, 0.3);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon.ingreso  { background: rgba(46, 160, 67, 0.15);  color: var(--color-ingreso); }
.stat-icon.egreso   { background: rgba(196, 69, 54, 0.15);  color: var(--color-egreso); }
.stat-icon.balance  { background: rgba(88, 166, 255, 0.12); color: #58a6ff; }
.stat-icon.count    { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }

.stat-info { flex: 1; min-width: 0; }

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value.balance-positive { color: var(--color-ingreso); }
.stat-value.balance-negative { color: var(--color-egreso); }

/* ── Currency toggle ─────────────────────────────────── */
.currency-toggle {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.currency-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 0.25rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
}

.currency-btn:hover { color: #fff; border-color: rgba(196, 69, 54, 0.4); }

.currency-btn.active {
    background: rgba(196, 69, 54, 0.15);
    border-color: var(--accent-red);
    color: #fff;
}

/* ── Charts ──────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .charts-row { grid-template-columns: 1fr; }
}

.chart-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    padding: 1.5rem;
}

.chart-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 220px;
}

/* ── Filters bar ─────────────────────────────────────── */
.filters-bar {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.filter-input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 10px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-family: 'Raleway', sans-serif;
    min-width: 0;
    flex: 1 1 160px;
    transition: border-color 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: rgba(196, 69, 54, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.filter-input option { background: #1a1a1a; }

/* ── Entries table / list ────────────────────────────── */
.entries-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.entries-table {
    width: 100%;
    border-collapse: collapse;
}

.entries-table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--dark-card-border);
    text-align: left;
}

.entries-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.88rem;
    color: #e0e0e0;
    vertical-align: middle;
}

.entries-table tr:last-child td { border-bottom: none; }

.entries-table tr:hover td { background: rgba(255, 255, 255, 0.025); }

/* ── Badges ──────────────────────────────────────────── */
.badge-ingreso {
    background: rgba(46, 160, 67, 0.15);
    color: var(--color-ingreso);
    border: 1px solid rgba(46, 160, 67, 0.3);
    border-radius: 20px;
    padding: 0.15rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-egreso {
    background: rgba(196, 69, 54, 0.15);
    color: var(--color-egreso);
    border: 1px solid rgba(196, 69, 54, 0.3);
    border-radius: 20px;
    padding: 0.15rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-ars, .badge-usd {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.1rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-usd { color: #f0c040; border-color: rgba(240, 192, 64, 0.3); background: rgba(240, 192, 64, 0.1); }

/* ── Category chip ───────────────────────────────────── */
.category-chip {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 6px;
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

/* ── Amount cell ─────────────────────────────────────── */
.amount-ingreso { color: var(--color-ingreso); font-weight: 700; }
.amount-egreso  { color: var(--color-egreso);  font-weight: 700; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ── Pagination ──────────────────────────────────────── */
.pagination-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
}

.page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover { color: #fff; border-color: rgba(196, 69, 54, 0.4); }
.page-btn.active { background: rgba(196, 69, 54, 0.15); border-color: var(--accent-red); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Modal ───────────────────────────────────────────── */
.modal-content {
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: #fff;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding: 1rem 1.5rem;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    border-radius: 10px;
    font-family: 'Raleway', sans-serif;
    font-size: 0.88rem;
    transition: border-color 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    box-shadow: none !important;
    border-color: rgba(196, 69, 54, 0.5) !important;
    background: rgba(255, 255, 255, 0.09) !important;
}

.form-select option { background: #1a1a1a; }

.btn-danger {
    background: var(--gradient-red);
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-family: 'Raleway', sans-serif;
    letter-spacing: 0.04em;
}

.btn-outline-secondary {
    border-radius: 10px;
    font-weight: 600;
    font-family: 'Raleway', sans-serif;
}

/* ── Responsive table ────────────────────────────────── */
@media (max-width: 640px) {
    .col-hide-sm { display: none; }
    .entries-table td,
    .entries-table th { padding: 0.65rem 0.75rem; }
}

/* ── Btn nuevo movimiento ────────────────────────────── */
.btn-new-entry {
    background: var(--gradient-red);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    font-family: 'Raleway', sans-serif;
    letter-spacing: 0.04em;
    padding: 0.55rem 1.25rem;
    font-size: 0.88rem;
    transition: opacity 0.2s, transform 0.15s;
    cursor: pointer;
}

.btn-new-entry:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Action buttons in table ─────────────────────────── */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.btn-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.btn-icon.delete:hover { color: var(--color-egreso); }
