@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --azul: #003087;
    --azul-hover: #002060;
    --azul-claro: #E3F2FD;
    --azul-medio: #1565C0;
    --blanco: #FFFFFF;
    --gris-bg: #F0F2F5;
    --gris-borde: #D0D5DD;
    --gris-texto: #667085;
    --negro: #101828;
    --verde: #2E7D32;
    --verde-bg: #E8F5E9;
    --rojo: #C62828;
    --rojo-bg: #FFEBEE;
    --amarillo: #F57F17;
    --sombra: 0 1px 3px rgba(0,0,0,0.12);
    --sombra-md: 0 4px 12px rgba(0,0,0,0.1);
    --radio: 8px;
    --radio-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--gris-bg);
    color: var(--negro);
    min-height: 100vh;
}

/* ---- HEADER ---- */
.header {
    background: var(--azul);
    color: var(--blanco);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    height: 44px;
    width: auto;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.75;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    font-size: 13px;
    opacity: 0.85;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radio);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--azul);
    color: var(--blanco);
}
.btn-primary:hover { background: var(--azul-hover); }

.btn-secondary {
    background: var(--blanco);
    color: var(--azul);
    border: 1px solid var(--gris-borde);
}
.btn-secondary:hover { background: var(--azul-claro); }

.btn-danger {
    background: var(--rojo);
    color: var(--blanco);
}
.btn-danger:hover { background: #B71C1C; }

.btn-success {
    background: var(--verde);
    color: var(--blanco);
}
.btn-success:hover { background: #1B5E20; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: var(--blanco);
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ---- LOGIN ---- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 100%);
    padding: 20px;
}

.login-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-logo {
    width: 100px;
    height: auto;
    margin-bottom: 16px;
}

.login-club-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--azul);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--gris-texto);
    margin-bottom: 32px;
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--negro);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
    background: var(--blanco);
    color: var(--negro);
}

.form-control:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(0,48,135,0.12);
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-color: var(--blanco);
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

.error-msg {
    color: var(--rojo);
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

/* ---- MAIN LAYOUT ---- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ---- CARDS ---- */
.card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--negro);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: 20px 24px;
    box-shadow: var(--sombra);
    border-left: 4px solid var(--azul);
}

.stat-card.ingreso { border-left-color: var(--verde); }
.stat-card.egreso { border-left-color: var(--rojo); }
.stat-card.resultado { border-left-color: var(--azul); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gris-texto);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 4px;
}

.stat-value.positivo { color: var(--verde); }
.stat-value.negativo { color: var(--rojo); }

/* ---- ACTIVITY GRID (Editor) ---- */
.activities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.activity-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: 28px 16px;
    text-align: center;
    box-shadow: var(--sombra);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}

.activity-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sombra-md);
    border-color: var(--azul);
}

.activity-icon {
    font-size: 42px;
    margin-bottom: 10px;
    display: block;
}

.activity-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--negro);
}

.activity-divider {
    grid-column: 1 / -1;
    padding: 8px 0 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--gris-texto);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 2px solid var(--gris-borde);
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
}

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

th {
    background: var(--azul);
    color: var(--blanco);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--gris-borde);
}

tr:hover td {
    background: var(--azul-claro);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.badge-ingreso { background: var(--verde-bg); color: var(--verde); }
.badge-egreso { background: var(--rojo-bg); color: var(--rojo); }

.monto { font-weight: 700; font-variant-numeric: tabular-nums; }
.monto.ingreso { color: var(--verde); }
.monto.egreso { color: var(--rojo); }

/* ---- FILTER BAR ---- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin-bottom: 0;
}

.filter-bar .form-control {
    min-width: 140px;
}

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: 32px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--azul);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ---- TOOLBAR ---- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gris-borde);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gris-texto);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover { color: var(--azul); }
.tab.active {
    color: var(--azul);
    border-bottom-color: var(--azul);
}

/* ---- TOAST ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radio);
    color: var(--blanco);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--sombra-md);
    z-index: 300;
    transform: translateY(80px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--verde); }
.toast.error { background: var(--rojo); }

/* ---- CHART CONTAINER ---- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-box {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra);
    padding: 20px;
}

.chart-box canvas {
    max-height: 300px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .activities-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .header { padding: 0 12px; }
    .header-title { font-size: 15px; }
    .login-card { padding: 32px 24px; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-control { min-width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .modal { padding: 24px; margin: 10px; }
    .stat-value { font-size: 22px; }
    table { font-size: 12px; }
    th, td { padding: 8px 10px; }
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gris-texto);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 15px;
    font-weight: 500;
}

/* ---- LOADING ---- */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gris-texto);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gris-borde);
    border-top-color: var(--azul);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ---- PASSWORD TOGGLE ---- */
.password-wrapper {
    position: relative;
}
.password-wrapper input {
    padding-right: 40px;
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--gris-texto);
    padding: 2px;
}
.password-toggle:hover { color: var(--negro); }

/* ---- SORTABLE COLUMNS ---- */
th.sortable {
    cursor: pointer;
    user-select: none;
}
th.sortable:hover {
    background: var(--azul-hover);
}
th.sortable::after {
    content: ' ⇅';
    font-size: 10px;
    opacity: 0.6;
}
th.sortable.asc::after { content: ' ▲'; opacity: 1; }
th.sortable.desc::after { content: ' ▼'; opacity: 1; }

/* ---- TOTALS ROW ---- */
.totals-row td {
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid var(--azul);
    background: var(--azul-claro) !important;
}

/* ---- PASSWORD MODAL (Activity) ---- */
.password-modal-icon {
    font-size: 48px;
    display: block;
    text-align: center;
    margin-bottom: 8px;
}

.password-modal-name {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    color: var(--azul);
    margin-bottom: 16px;
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 13px;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    background: var(--blanco);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
}
.pagination button:hover { background: var(--azul-claro); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button:disabled:hover { background: var(--blanco); }
.pagination .page-info { color: var(--gris-texto); font-weight: 500; }
