/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #000000;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background:#efefef ;
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* Header */
.main-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: var(--dark);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--primary-color);
    color: var(--white);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 450px;
}

.auth-box {
    background: var(--white);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.auth-box h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--gray);
    font-weight: normal;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Cards */
.card {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.card h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

.card-success { border-left: 4px solid var(--success-color); }
.card-danger { border-left: 4px solid var(--danger-color); }
.card-warning { border-left: 4px solid var(--warning-color); }
.card-info { border-left: 4px solid var(--info-color); }

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-cards .card {
    text-align: center;
}

.summary-cards .amount {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 1rem 0;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

/* Category List */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.category-amount {
    text-align: right;
}

.category-amount small {
    color: var(--gray);
    margin-left: 0.5rem;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    transition: width 0.3s;
}

/* Transactions */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--light);
    border-radius: 8px;
    transition: transform 0.2s;
}

.transaction-item:hover {
    transform: translateX(5px);
}

.transaction-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.transaction-amount {
    font-weight: bold;
    font-size: 1.1rem;
}

.transaction-amount.ingreso {
    color: var(--success-color);
}

.transaction-amount.gasto {
    color: var(--danger-color);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--light);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--gray);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-success:hover {
    background: #27ae60;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
    text-align: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

.button-group {
    display: flex;
    gap: 1rem;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.table th {
    font-weight: 600;
    color: var(--dark);
    background: var(--light);
}

.table tr:hover {
    background: #f8f9fa;
}

.amount-cell {
    font-weight: bold;
}

.amount-cell.ingreso {
    color: var(--success-color);
}

.amount-cell.gasto {
    color: var(--danger-color);
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-success {
    background: #d5f4e6;
    color: var(--success-color);
}

.badge-danger {
    background: #fadbd8;
    color: var(--danger-color);
}

.category-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    color: var(--white);
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #d5f4e6;
    color: #27ae60;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background: #fadbd8;
    color: #c0392b;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: #fef5e7;
    color: #d68910;
    border-left: 4px solid var(--warning-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal.active {
    display: block;
}

.modal-content {
    background: var(--white);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--gray);
}

.close:hover {
    color: var(--dark);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    color: var(--dark);
}

/* Month Selector */
.month-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.month-selector span {
    font-weight: 500;
    min-width: 150px;
    text-align: center;
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--light);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 1.5rem;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f8f9fa;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.upload-area input[type="file"] {
    display: none;
}

.upload-placeholder {
    cursor: pointer;
}

.upload-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.receipt-preview {
    margin: 1rem 0;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.info-box {
    background: var(--light);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.info-box strong {
    display: block;
    margin-bottom: 0.5rem;
}

.info-box ul,
.info-box ol {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--light);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.category-card {
    padding: 1rem;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.category-stats {
    display: flex;
    gap: 1rem;
    color: var(--gray);
}

/* Color Picker */
.color-picker input {
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: var(--light);
    color: var(--dark);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s;
}

.pagination a:hover,
.pagination a.active {
    background: var(--primary-color);
    color: var(--white);
}

/* Loading Spinner */
.spinner {
    border: 4px solid var(--light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.text-muted {
    color: var(--primary-color);
}

.text-success {
    color: var(--success-color);
}

.text-warning {
    color: var(--warning-color);
}

.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1.5rem;
}

/* ========================================
   HEADER RESPONSIVE
   ======================================== */

.main-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

/* Logo */
.logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark);
    text-decoration: none;
    transition: transform 0.3s;
}

.logo a:hover {
    transform: scale(1.05);
}

.logo-icon {
    font-size: 2rem;
}

.logo-text {
    font-size: 1.3rem;
}

/* Menú hamburguesa (oculto en desktop) */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--dark);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.menu-toggle.active .hamburger:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.menu-toggle.active .hamburger:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Navegación principal */
.main-nav {
    display: flex;
    gap: 0.5rem;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    transition: all 0.3s;
    font-weight: 500;
}

.main-nav a:hover {
    background: var(--light);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.main-nav a.active {
    background: var(--primary-color);
    color: var(--white);
}

.nav-icon {
    font-size: 1.2rem;
}

.nav-text {
    font-size: 1rem;
}

/* Usuario */
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-icon {
    font-size: 1.5rem;
}

.user-name {
    font-weight: 500;
    color: var(--dark);
}

.btn-logout {
    background: var(--danger-color) !important;
    color: var(--white) !important;
}

.btn-logout:hover {
    background: #c0392b !important;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */

@media (max-width: 1024px) {
    .header-container {
        gap: 1rem;
    }

    .main-nav {
        gap: 0.25rem;
    }

    .main-nav a {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    /* Ocultar texto en tablet, solo iconos */
    .nav-text {
        display: none;
    }

    .nav-icon {
        font-size: 1.4rem;
    }

    .user-name {
        display: none;
    }

    .logo-text {
        font-size: 1.1rem;
    }
}

/* ========================================
   RESPONSIVE - MÓVIL
   ======================================== */

@media (max-width: 768px) {
    .header-container {
        padding: 1rem;
    }

    /* Mostrar botón hamburguesa */
    .menu-toggle {
        display: flex;
    }

    /* Ocultar texto del logo en móvil */
    .logo-text {
        display: none;
    }

    /* Menú móvil - Panel lateral */
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--white);
        flex-direction: column;
        gap: 0;
        padding: 5rem 1.5rem 2rem;
        box-shadow: -5px 0 20px rgba(0,0,0,0.3);
        transition: right 0.3s ease;
        overflow-y: auto;
        z-index: 1000;
    }

    .main-nav.active {
        right: 0;
    }

    .main-nav a {
        width: 100%;
        padding: 1rem;
        justify-content: flex-start;
        border-radius: 8px;
        margin-bottom: 0.5rem;
    }

    /* Mostrar texto en menú móvil */
    .nav-text {
        display: inline;
        font-size: 1rem;
    }

    .nav-icon {
        font-size: 1.3rem;
    }

    /* Usuario en menú móvil */
    .user-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        background: var(--white);
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.5rem;
        margin-top: calc(100vh - 8rem);
        border-top: 2px solid var(--light);
        transition: right 0.3s ease;
        z-index: 1000;
    }

    .main-nav.active ~ .user-menu {
        right: 0;
    }

    .user-info {
        width: 100%;
        padding: 0.5rem 0;
    }

    .user-name {
        display: inline;
    }

    .btn-logout {
        width: 100%;
        justify-content: center;
        padding: 0.75rem !important;
    }

    /* Overlay oscuro cuando el menú está abierto */
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        animation: fadeIn 0.3s;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Móvil muy pequeño */
@media (max-width: 480px) {
    .main-nav {
        width: 85%;
    }

    .user-menu {
        width: 85%;
    }
}
/* Logo imagen */
.logo-img {
    height: 50px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s;
}

.logo a:hover .logo-img {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 1024px) {
    .logo-img { height: 55px; }
}

@media (max-width: 768px) {
    .logo-img { height: 52px; }
}