:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
}

.auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form h2 {
    font-size: 24px;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
    flex: 1;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    resize: vertical;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.section-header .btn-primary {
    width: auto;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.btn-icon:hover {
    background: var(--bg-color);
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user span {
    font-weight: 500;
    color: var(--text-primary);
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 64px);
}

.sidebar {
    width: 250px;
    background: var(--card-bg);
    padding: 24px 0;
    box-shadow: var(--shadow-sm);
}

.sidebar-menu {
    list-style: none;
}

.menu-item {
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-weight: 500;
}

.menu-item:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--bg-color);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 32px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

 .section-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 24px;
 }

.section-header h2 {
    font-size: 28px;
    color: var(--text-primary);
}

 .month-selector {
     display: flex;
     align-items: center;
     justify-content: flex-end;
     gap: 12px;
     margin-left: auto;
 }

/* Month picker input styling */
.month-input {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1;
    width: 170px;
    height: 40px;
    box-sizing: border-box;
    cursor: pointer;
}

/* Make the calendar icon visually consistent */
.month-input::-webkit-calendar-picker-indicator {
    filter: none;
    opacity: 0.9;
    cursor: pointer;
    padding: 4px;
}

/* Firefox specific styling for month input */
input[type="month"]::-moz-focus-inner {
    border: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 40px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Progress Card */
.progress-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
}

.progress-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.progress-bar {
    height: 14px;
    /* make track slightly darker than page background so it stands out */
    background: #d3d3d3;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    /* visible fill gradient */
    background: linear-gradient(90deg, var(--primary-color), #7c3aed);
    border-radius: 999px;
    transition: width 0.5s ease;
    box-shadow: 0 2px 6px rgba(79,70,229,0.12);
}

.progress-text {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Recent Sales Card */
.recent-sales-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.recent-sales-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.sales-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.sale-item {
    padding: 18px 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sale-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sale-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.sale-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--success-color);
}

/* Chart View Selector */
.chart-view-selector {
    display: flex;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    gap: 6px;
}

.radio-label input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.radio-label span {
    color: var(--text-primary);
    font-weight: 500;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

/* Sales Table */
.sales-table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.sales-table th {
    background: var(--bg-color);
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.sales-table td {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.sales-table tbody tr:hover {
    background: var(--bg-color);
}

.table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 4px;
}

.action-edit {
    background: #e0e7ff;
    color: var(--primary-color);
}

.action-edit:hover {
    background: #c7d2fe;
}

.action-view {
    background: #dbeafe;
    color: #2563eb;
}

.action-view:hover {
    background: #bfdbfe;
}

.action-delete {
    background: #fee2e2;
    color: var(--danger-color);
}

.action-delete:hover {
    background: #fecaca;
}

/* Form Container */
.form-container {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.sale-form h3 {
    margin-bottom: 20px;
}

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

.form-actions .btn {
    width: auto;
    min-width: 120px;
}

/* Profile Card */
.profile-card {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 600px;
}

/* Admin Dashboard */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px;
}

.users-table-container {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-top: 32px;
}

.users-table-container h3 {
    margin-bottom: 20px;
}

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

.users-table th {
    background: var(--bg-color);
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.users-table td {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.users-table tbody tr:hover {
    background: var(--bg-color);
}

.progress-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
}

.progress-low {
    background: #fee2e2;
    color: var(--danger-color);
}

.progress-medium {
    background: #fef3c7;
    color: var(--warning-color);
}

.progress-high {
    background: #d1fae5;
    color: var(--success-color);
}

.pendiente-positive {
    color: var(--danger-color);
    font-weight: 600;
}

.pendiente-negative {
    color: var(--success-color);
    font-weight: 600;
}

/* Circular progress per user with details to the right */
.user-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
}
.progress-circle {
    position: relative;
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
}
.progress-circle svg { display: block; }
.progress-center {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: var(--text-primary);
}
.progress-detail {
    text-align: left;
    min-width: 150px;
}
.progress-detail .small-label {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 4px;
}
.progress-detail .large-accumulated {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Estilos de tabla estilo spreadsheet */
.users-table th:first-child {
    text-align: left;
}

.users-table th:not(:first-child) {
    text-align: right;
}

/* Alinear específicamente la columna 'Progreso' (segunda columna) a la izquierda */
.users-table-container .users-table th:nth-child(2),
.users-table-container .users-table td:nth-child(2) {
    text-align: left;
}

/* Alineación específica para la tabla de gestión de usuarios: mantener
   las columnas 'Usuario' y 'Nombre' alineadas a la izquierda */
.users-management-table .users-table th:nth-child(1),
.users-management-table .users-table th:nth-child(2),
.users-management-table .users-table th:nth-child(3),
.users-management-table .users-table td:nth-child(1),
.users-management-table .users-table td:nth-child(2),
.users-management-table .users-table td:nth-child(3) {
    text-align: left;
}

.users-table td strong {
    font-size: 14px;
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-color);
}

.modal-body {
    padding: 24px;
}

.user-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-item {
    background: var(--bg-color);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}

.stat-item .stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-item .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 3001;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: var(--success-color);
    color: white;
}

.notification.error {
    background: var(--danger-color);
    color: white;
}

.notification.info {
    background: var(--primary-color);
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Error Message */
.error-message {
    background: #fee2e2;
    color: var(--danger-color);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 14px;
}

/* Responsive Mobile-First */
@media (max-width: 768px) {
    /* Force full height layout with fixed footer navigation */
    html {
        height: 100%;
        overflow: hidden;
    }

    body {
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        font-size: 16px;
        position: relative;
    }

    .navbar {
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 500;
    }

    .dashboard-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
    }

    /* Main content is scrollable with fixed bottom space for footer tabs */
    .main-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        padding-bottom: 90px;
        margin-bottom: 0;
    }

    /* Footer tabs - ALWAYS FIXED at bottom with highest z-index */
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        background: var(--card-bg) !important;
        z-index: 9999 !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
        transform: none !important;
        pointer-events: auto !important;
    }

    .dashboard-container > * {
        position: relative;
        z-index: 1;
    }

    .sidebar-menu {
        display: flex;
        justify-content: space-around;
        padding: 0;
    }

    .menu-item {
        flex: 1;
        text-align: center;
        padding: 12px 8px;
        border-left: none;
        border-top: 3px solid transparent;
        font-size: 12px;
    }

    .menu-item.active {
        border-left: none;
        border-top: 3px solid var(--primary-color);
    }

    .menu-item span {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        font-size: 22px;
    }

    .menu-item .menu-text {
        font-size: 11px;
        font-weight: 500;
    }

    .nav-container {
        padding: 12px 16px;
    }

    .nav-logo {
        font-size: 18px;
    }

    .nav-user span {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .stat-value {
        font-size: 20px;
    }

    .form-row {
        flex-direction: column;
    }

    /* Profile update mobile adjustments */
    .profile-avatar-row {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .profile-avatar-row .profile-avatar {
        width: 64px !important;
        height: 64px !important;
        border-radius: 8px;
    }

    .profile-upload-controls {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    #profilePhotoInput {
        width: 100%;
    }

    #uploadPhotoBtn {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .section-header h2 {
        font-size: 22px;
    }

    .month-selector {
        width: 100%;
        justify-content: space-between;
    }

    .btn {
        padding: 14px 24px;
        font-size: 16px;
        min-height: 48px;
    }

    .btn-icon {
        padding: 10px 20px;
        font-size: 18px;
        min-width: 48px;
        min-height: 48px;
    }

    /* Tablas responsive */
    .sales-table-container,
    .users-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    /* Ensure any floating form is above the fixed bottom sidebar */
    .form-container {
        position: relative;
        z-index: 110;
    }

    .sales-table,
    .users-table {
        font-size: 13px;
    }

    .sales-table th,
    .sales-table td,
    .users-table th,
    .users-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Formularios móviles */
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px;
        padding: 14px;
        min-height: 48px;
    }

    .form-group textarea {
        min-height: 100px;
    }

    /* Modal móvil - below footer tabs */
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 85vh;
        margin-bottom: 80px;
    }

    .modal-body {
        padding: 16px;
    }

    .user-stats {
        grid-template-columns: 1fr;
    }

    /* Auth mobile */
    .auth-card {
        padding: 24px;
        margin: 10px;
    }

    /* Progress card */
    .progress-card {
        padding: 16px;
    }

    /* Recent sales */
    .sale-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sale-amount {
        align-self: flex-end;
    }

    /* Admin container */
    .admin-container {
        padding: 16px;
        padding-bottom: 20px;
    }

    /* Botones de acción más grandes */
    .action-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Notificaciones móviles - below footer */
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        font-size: 14px;
        z-index: 8500 !important;
    }

    .admin-container {
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    .admin-container > * {
        padding-left: 16px;
        padding-right: 16px;
    }

    .tabs-container,
    .tab-content {
        position: relative;
        z-index: 1;
    }
}

/* Tabs Navigation */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Users Management Table */
.users-management-table {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.users-management-table .users-table th:nth-child(5),
.users-management-table .users-table td:nth-child(5) {
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.action-btn.action-delete {
    background: #fee2e2;
    color: #ef4444;
}

.action-btn.action-delete:hover {
    background: #fecaca;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

