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

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        sans-serif;
    background-color: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ── Header ── */
header {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: white;
    padding: 18px 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 14px;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

header .logo-icon {
    font-size: 1.6rem;
}

/* ── Main layout ── */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── Tabs Navigation ── */
.tabs-header {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    background: white;
    border-radius: 10px 10px 0 0;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab-btn {
    padding: 14px 20px;
    border: none;
    background: transparent;
    color: #546e7a;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        color 0.2s,
        background-color 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    background-color: #f5f5f5;
    color: #1a237e;
}

.tab-btn.active {
    color: #3f51b5;
    border-bottom-color: #3f51b5;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ── Panel de filtros ── */
.filters-panel {
    background: white;
    border-radius: 10px;
    padding: 22px 26px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

.filters-panel h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #1a237e;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8eaf6;
}

.filters-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a237e;
    margin: 16px 0 12px 0;
}

.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #333;
    background-color: #fafafa;
    transition:
        border-color 0.2s,
        box-shadow 0.2s,
        background-color 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: #3f51b5;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.12);
}

select.form-control {
    cursor: pointer;
    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='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* ── Botones de acción ── */
.actions-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color 0.18s,
        transform 0.1s,
        box-shadow 0.18s;
    outline: none;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: #3f51b5;
    color: white;
    box-shadow: 0 2px 5px rgba(63, 81, 181, 0.35);
}

.btn-primary:hover:not(:disabled) {
    background-color: #303f9f;
    box-shadow: 0 3px 8px rgba(63, 81, 181, 0.45);
}

.btn-success {
    background-color: #2e7d32;
    color: white;
    box-shadow: 0 2px 5px rgba(46, 125, 50, 0.35);
}

.btn-success:hover:not(:disabled) {
    background-color: #1b5e20;
    box-shadow: 0 3px 8px rgba(46, 125, 50, 0.45);
}

.btn-secondary {
    background-color: #eceff1;
    color: #455a64;
    border: 1px solid #cfd8dc;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #cfd8dc;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Checkbox inline ── */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #555;
}

.checkbox-inline input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* ── Barra de estado / info de resultados ── */
.results-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.results-count {
    font-size: 0.85rem;
    color: #546e7a;
}

.results-count strong {
    color: #1a237e;
    font-size: 1rem;
}

.export-limit-note {
    font-size: 0.78rem;
    color: #78909c;
    font-style: italic;
}

/* ── Panel de resultados ── */
.results-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    overflow: hidden;
    margin-bottom: 20px;
}

/* ── Estado vacío / cargando ── */
.state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #90a4ae;
    gap: 12px;
    min-height: 220px;
}

.state-box .state-icon {
    font-size: 3rem;
    opacity: 0.6;
}

.state-box p {
    font-size: 0.95rem;
    text-align: center;
    max-width: 320px;
    line-height: 1.5;
}

/* Spinner de carga */
.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #e0e0e0;
    border-top-color: #3f51b5;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ── Tabla ── */
.table-wrapper {
    overflow-x: auto;
    max-height: 520px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    background-color: #e8eaf6;
    color: #1a237e;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 11px 14px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid #c5cae9;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.12s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f5f7ff;
}

tbody tr:nth-child(even) {
    background-color: #fafafa;
}

tbody tr:nth-child(even):hover {
    background-color: #f5f7ff;
}

tbody td {
    padding: 9px 14px;
    color: #424242;
}

tbody td.mono {
    font-family: "Courier New", Courier, monospace;
    letter-spacing: 0.3px;
    color: #1a237e;
}

tbody td.dim {
    color: #78909c;
    font-size: 0.83rem;
}

/* ── Badge de tipificación ── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-activo {
    background-color: #e8f5e9;
    color: #1b5e20;
}

.badge-inactivo {
    background-color: #ffebee;
    color: #b71c1c;
}

.badge-interesado {
    background-color: #e3f2fd;
    color: #0d47a1;
}

.badge-default {
    background-color: #f5f5f5;
    color: #616161;
}

/* ── Acciones en tabla (botones pequeños) ── */
.btn-small {
    padding: 4px 8px;
    font-size: 0.75rem;
    background-color: #e8eaf6;
    color: #3f51b5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-small:hover {
    background-color: #c5cae9;
}

.btn-small.danger {
    background-color: #ffebee;
    color: #c62828;
}

.btn-small.danger:hover {
    background-color: #ffcdd2;
}

/* ── Paginación ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.page-info {
    font-size: 0.85rem;
    color: #546e7a;
    padding: 0 10px;
}

.btn-page {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    background: white;
    color: #3f51b5;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color 0.15s,
        border-color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-page:hover:not(:disabled) {
    background-color: #e8eaf6;
    border-color: #9fa8da;
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Stats Panel ── */
.stats-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

.stats-panel h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #1a237e;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, #e8eaf6 0%, #f3e5f5 100%);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a237e;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    margin-top: 6px;
}

/* ── Sync Panel ── */
.sync-status {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    border-left: 4px solid #3f51b5;
}

.sync-status p {
    font-size: 0.9rem;
    color: #555;
    margin: 0;
}

.sync-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

#syncDetails {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    font-size: 0.8rem;
    font-family: "Courier New", Courier, monospace;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.4;
}

/* Checkbox grid for multi-state selection */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Form group styling */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 0.85rem;
}

/* Button small variant */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ── 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: 1000;
}

.modal-content {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #1a237e;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
}

/* ── Notificaciones / Toast ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 8px;
    color: white;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.25s ease;
    max-width: 360px;
}

.toast.info {
    background-color: #1565c0;
}
.toast.success {
    background-color: #2e7d32;
}
.toast.error {
    background-color: #c62828;
}
.toast.warning {
    background-color: #e65100;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 580px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1rem;
    }

    .container {
        padding: 14px 12px;
    }

    .actions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        justify-content: center;
    }

    .tabs-header {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 0.8rem;
    }

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