* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 i {
    font-size: 30px;
}

.header-info span {
    font-size: 14px;
    opacity: 0.9;
    font-style: italic;
}

/* ============================================
   BÚSQUEDA
   ============================================ */
.search-bar {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    position: relative;
    min-width: 250px;
}

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-container input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 2px solid #e1e5eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.search-container input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================
   TABLA
   ============================================ */
.table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 25px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.table-title h2 {
    font-size: 20px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-title h2 i {
    color: #667eea;
}

.record-count {
    background: #edf2f7;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: #4a5568;
}

.table-actions {
    display: flex;
    gap: 10px;
}

.table-wrapper {
    background: white;
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
    min-width: 800px;
}

thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

thead th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #2d3748;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 10;
}

tbody tr {
    background: white;
    border-bottom: 1px solid #edf2f7;
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: #f7fafc;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody td {
    padding: 14px 16px;
    color: #2d3748;
    vertical-align: middle;
}

tbody td:first-child {
    font-weight: 600;
    color: #667eea;
}

/* ============================================
   BOTONES
   ============================================ */
.btn-add {
    padding: 10px 20px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-add:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.btn-refresh {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-refresh:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-edit, .btn-delete, .btn-atencion {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-edit {
    background: #4299e1;
    color: white;
}

.btn-edit:hover {
    background: #3182ce;
}

.btn-delete {
    background: #fc8181;
    color: white;
}

.btn-delete:hover {
    background: #f56565;
}

.btn-atencion {
    background: #667eea;
    color: white;
}

.btn-atencion:hover {
    background: #5a67d8;
}

.btn-pagination {
    padding: 8px 16px;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    margin: 0 3px;
}

.btn-pagination:hover {
    background: #e2e8f0;
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-cancel {
    padding: 10px 25px;
    background: #e2e8f0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    color: #4a5568;
}

.btn-cancel:hover {
    background: #cbd5e0;
}

.btn-save {
    padding: 10px 25px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-save:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

/* ============================================
   PAGINACIÓN
   ============================================ */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 10px 0;
}

#pageInfo {
    color: #718096;
    font-size: 14px;
}

/* ============================================
   RESUMEN
   ============================================ */
.summary-container {
    background: linear-gradient(135deg, #f6f9fc 0%, #edf2f7 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 25px;
}

.summary-card {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.summary-icon {
    font-size: 40px;
    color: #667eea;
    padding: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.summary-content h3 {
    font-size: 16px;
    color: #4a5568;
    margin-bottom: 8px;
}

.summary-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.summary-item {
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.summary-item strong {
    color: #667eea;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close {
    font-size: 30px;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.2s;
    line-height: 1;
}

.close:hover {
    color: #4a5568;
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================
   FORMULARIO
   ============================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #4a5568;
    font-size: 14px;
}

.form-group label i {
    color: #667eea;
    margin-right: 6px;
    width: 18px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-container {
        width: 100%;
    }

    .filter-container {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .table-title {
        justify-content: center;
    }

    .table-actions {
        justify-content: center;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }

    .summary-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .summary-details {
        justify-content: center;
    }

    .actions-cell {
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 22px;
    }

    table {
        font-size: 12px;
    }

    thead th, tbody td {
        padding: 8px 10px;
    }
}

/* ============================================
   ESTILOS CORREGIDOS PARA LA TABLA
   ============================================ */

/* Badge de código - Sin distorsión */
.codigo-badge {
    background: #ebf4ff;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    color: #667eea;
    font-size: 12px;
    display: inline-block;
    white-space: nowrap;
}

/* Badge de área */
.area-badge {
    background: #f7fafc;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: #4a5568;
    display: inline-block;
    white-space: nowrap;
}

/* Contenedor de acciones - botones en línea */
.acciones-container {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Botón Atención */
.btn-atencion-tabla {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-atencion-tabla:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

/* Botón Eliminar */
.btn-delete-tabla {
    background: #fc8181;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-delete-tabla:hover {
    background: #f56565;
    transform: scale(1.05);
}

/* Asegurar que las celdas no se rompan */
table td {
    vertical-align: middle;
    padding: 10px 12px;
}

/* Asegurar que los badges no se rompan */
table td span {
    display: inline-block;
    white-space: nowrap;
}