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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background: #f5f5f5;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

/* ===== FILTRO MES ===== */
.filtro-mes {
    margin-top: 0.5rem;
}

.filtro-form {
    display: flex;
    gap: 0.5rem;
}

.filtro-form select {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    color: #333;
    font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 1rem;
    padding-bottom: 80px;
}

/* ===== CARDS GRID ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.card:hover, .card:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.card h3 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.25rem;
}

.card-docs {
    font-size: 0.8rem;
    color: #666;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 20px;
    background: #e0e0e0;
    color: #333;
}

.badge-global {
    background: #667eea;
    color: white;
}

/* ===== DOCUMENTOS LIST ===== */
.documentos-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.documento-item {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.documento-item:hover, .documento-item:active {
    background: #f8f8f8;
}

.doc-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

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

.doc-info h4 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-info small {
    color: #888;
}

.doc-action {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ===== MODAL PDF ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-pdf {
    max-width: 95%;
    height: 90vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pdf-container {
    flex: 1;
    overflow: hidden;
}

.pdf-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

/* ===== FAB ADMIN ===== */
.fab-admin {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 50;
    transition: transform 0.2s ease;
}

.fab-admin:hover {
    transform: scale(1.1);
}

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #888;
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 0.85rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #888;
    font-size: 0.8rem;
}

.alert {
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.alert-error {
    background: #ffe0e0;
    color: #c00;
}

/* ===== BACK LINK ===== */
.back-link {
    color: white;
    opacity: 0.9;
    font-size: 0.9rem;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-icon {
    font-size: 1.5rem;
}

.period-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ===== ADMIN PANEL ===== */
.admin-body {
    background: #f5f5f5;
}

.admin-header {
    background: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.admin-header h1 {
    flex: 1;
    font-size: 1.1rem;
}

.admin-nav {
    display: flex;
    overflow-x: auto;
    background: white;
    padding: 0.5rem;
    gap: 0.25rem;
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: #667eea;
    color: white;
}

.admin-content {
    padding: 1rem;
}

.admin-content h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

@media (min-width: 768px) {
    .stats-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-icon {
    font-size: 2rem;
}

.stat-info h3 {
    font-size: 1.5rem;
    color: #333;
}

.stat-info p {
    font-size: 0.85rem;
    color: #888;
}

/* ===== ADMIN CARDS ===== */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.admin-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.admin-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.full-width {
    grid-column: 1 / -1;
}

/* ===== MINI LIST ===== */
.mini-list {
    list-style: none;
}

.mini-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.mini-list li:last-child {
    border-bottom: none;
}

.mini-list li span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-list li strong {
    background: #667eea;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* ===== RANKING LIST ===== */
.ranking-list {
    list-style: none;
}

.ranking-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.ranking-list li:last-child {
    border-bottom: none;
}

.ranking-list .rank {
    width: 24px;
    height: 24px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.ranking-list .text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-list .count {
    font-weight: 600;
    color: #667eea;
}

/* ===== ADMIN TABLE ===== */
.admin-table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

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

.admin-table th {
    background: #f8f8f8;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
}

.admin-table td {
    padding: 0.75rem;
    border-top: 1px solid #f0f0f0;
    vertical-align: middle;
}

.admin-table td strong {
    display: block;
    font-weight: 500;
}

.admin-table td small {
    color: #888;
}

.icon-cell {
    font-size: 1.5rem;
    text-align: center;
}

.actions-cell {
    white-space: nowrap;
}

/* ===== ADMIN FORM ===== */
.admin-form .form-group {
    margin-bottom: 1rem;
}

.admin-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ===== CHART ===== */
.chart-placeholder {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 150px;
    padding: 1rem 0;
    overflow-x: auto;
}

.chart-bar-container {
    flex: 1;
    min-width: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-bar {
    width: 100%;
    max-width: 40px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
    margin-top: auto;
}

.chart-label {
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.25rem;
}

.chart-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: #667eea;
}

/* ===== BADGE VARIANTS ===== */
.badge-admin {
    background: #764ba2;
    color: white;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== TABLE RESPONSIVE WRAPPER ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table table {
    min-width: 600px;
}

/* ===== MODAL MOBILE IMPROVEMENTS ===== */
@media (max-width: 600px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-height: 85vh;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 0.75rem;
    }
    
    .modal-header h3 {
        font-size: 0.95rem;
    }
    
    .admin-form {
        padding: 0.5rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* ===== ADMIN MOBILE IMPROVEMENTS ===== */
@media (max-width: 600px) {
    .admin-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .admin-header h1 {
        font-size: 1rem;
        width: 100%;
    }
    
    .admin-header .btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .admin-content {
        padding: 0.75rem;
    }
    
    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .admin-toolbar h2 {
        font-size: 1rem;
    }
    
    .admin-toolbar .btn {
        width: 100%;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .admin-table th {
        font-size: 0.75rem;
    }
    
    .icon-cell {
        font-size: 1.2rem;
    }
    
    .actions-cell {
        display: flex;
        gap: 0.25rem;
    }
    
    .actions-cell .btn-small {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
