/* ========================================================================== */
/* POPULAR PAGE - Administración De Populación                                */
/* ========================================================================== */

/* Eliminar padding del main-content para esta página */
.main-content:has(.popular-page) {
    padding: 0 !important;
}

.popular-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 95px);
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

    /* Ajuste del camara-panel para que ocupe todo el espacio */
    .popular-page .camara-panel {
        margin: 0;
        padding: 0.75rem;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    /* Ajuste del camara-header */
    .popular-page .camara-header {
        margin: 0 0 0.5rem 0;
        padding: 0.25rem 0.5rem;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

/* ========================================================================== */
/* MODE TOGGLE (Static / Screen)                                              */
/* ========================================================================== */

.popular-mode-toggle {
    display: flex;
    gap: 0;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 3px;
    flex-shrink: 0;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.mode-btn svg {
    flex-shrink: 0;
}

.mode-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(240, 116, 0, 0.08);
}

.mode-btn.active {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
    box-shadow: 0 2px 8px rgba(240, 116, 0, 0.35);
}

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

.mode-btn:disabled:hover {
    background: transparent;
    color: var(--text-secondary);
}

.mode-btn.active:disabled {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
}

/* ========================================================================== */
/* SCREEN VIDEO BUTTON                                                        */
/* ========================================================================== */

.btn-video-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 180, 255, 0.15);
    color: #00b4ff;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-video-screen:hover {
    background: rgba(0, 180, 255, 0.3);
    transform: scale(1.1);
}

/* ========================================================================== */
/* SCREEN REVIEW GRID (Header fijo, Body scroll, Footer fijo)                 */
/* ========================================================================== */

.scr-grid {
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.7rem;
}

/* Columnas compartidas: icono, ruta, items, tipo, costo, loop, spots, usr, video */
.scr-grid-header,
.scr-grid-row,
.scr-grid-footer {
    display: grid;
    grid-template-columns: 22px 58px 55px 1fr 80px 50px 50px 1fr 38px;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
}

/* Header: fijo arriba */
.scr-grid-header {
    background: var(--bg-tertiary);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Body: scrollable */
.scr-grid-body {
    max-height: 200px;
    overflow-y: auto;
    flex: 0 1 auto;
}

/* Rows */
.scr-grid-row {
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-color);
}

.scr-grid-row:hover {
    background: rgba(0, 180, 255, 0.08);
}

.scr-grid-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Expand icon */
.scr-expand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.scr-expand-icon svg {
    transition: transform 0.25s ease;
    color: var(--text-secondary);
}

.scr-expand-icon svg.expanded {
    transform: rotate(90deg);
    color: #00b4ff;
}

/* Detail rows (expandidas) */
.scr-grid-detail {
    display: grid;
    grid-template-columns: 22px 1fr;
    padding: 0.3rem 0.6rem;
    background: var(--bg-tertiary);
    border-left: 3px solid #00b4ff;
    border-bottom: 1px solid var(--border-color);
    animation: scrSlideIn 0.2s ease;
}

@keyframes scrSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.scr-det-content {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.scr-det-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.scr-det-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.7rem;
}

.scr-det-separator {
    margin: 0 0.4rem;
    color: var(--border-color);
}

/* Footer: fijo abajo */
.scr-grid-footer {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
    flex-shrink: 0;
    padding: 0.5rem 0.6rem;
    align-items: center;
}

.scr-grid-footer > span {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 24px;
    overflow: visible;
}

.scr-grid-footer .scr-footer-label,
.scr-grid-footer .scr-summary-badge {
    margin-left: -1rem;
}

.scr-footer-label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.scr-summary-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.scr-summary-badge.items {
    background: rgba(240, 116, 0, 0.15);
    color: #F07400;
}

.scr-summary-badge.costo-ok {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.scr-summary-badge.costo-warn {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

    /* Override de camara-body para layout en columna */
    .popular-page .camara-body {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 0.75rem;
        flex: 1;
        min-height: 0;
    }

/* ========================================================================== */
/* CALENDAR WRAPPER (usa estilos de bitacora-rutas.css)                        */
/* ========================================================================== */

.popular-page .calendar-wrapper {
    width: 100%;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    box-sizing: border-box;
}

/* ========================================================================== */
/* STEPS ROW (Pasos + Ciclo Seleccionado en misma fila)                        */
/* ========================================================================== */

.popular-steps-row {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    justify-content: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    width: fit-content;
    margin: 0 auto;
}

/* Botones de acción en la fila de pasos */
.popular-actions-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* ========================================================================== */
/* STEPS INDICATOR                                                             */
/* ========================================================================== */

.popular-steps-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 1;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    border-color: transparent;
    color: white;
    box-shadow: 0 3px 10px rgba(240, 116, 0, 0.4);
}

.step.completed .step-number {
    background: #00ff88;
    border-color: transparent;
    color: #1a1a2e;
}

.step-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step.active .step-label {
    color: var(--text-primary);
}

.step-connector {
    width: 40px;
    height: 2px;
    background: var(--border-color);
    margin: 0 0.35rem;
    margin-bottom: 1.2rem;
    transition: background 0.3s ease;
}

.step-connector.completed {
    background: linear-gradient(90deg, #00ff88, #00b4ff);
}

/* ========================================================================== */
/* MAIN CONTENT                                                                */
/* ========================================================================== */

.popular-main-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

/* ========================================================================== */
/* CYCLE INFO BAR                                                              */
/* ========================================================================== */

.popular-cycle-info {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cycle-info-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.1), rgba(0, 180, 255, 0.1));
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.cycle-info-header svg {
    color: #F07400;
    flex-shrink: 0;
}

.badge-populated {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cycle-info-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    flex: 1;
}

.info-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.info-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-label::after {
    content: ':';
}

.info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================================================== */
/* VALIDATION PANELS                                                           */
/* ========================================================================== */

.popular-validation-panels {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
}

.validation-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.panel-header svg {
    color: #00b4ff;
}

.panel-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Panel de Rutas dentro del grid */
.validation-panel.route-panel {
    display: flex;
    flex-direction: column;
}

.route-panel-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Panel de Items Sin Proveedor */
.no-provider-panel {
    display: flex;
    flex-direction: column;
}

.no-provider-panel-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.panel-header.warning-header svg {
    color: #ffc107;
}

/* Empty state para paneles */
.panel-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
}

.panel-empty-state.ok {
    color: #00ff88;
}

.panel-empty-state.ok svg {
    color: #00ff88;
}

/* Badge ok para sin items */
.no-provider-count-badge.ok {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

/* Validation Rows */
.validation-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.validation-icon.ok {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.validation-icon.warning {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.validation-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.validation-value {
    margin-left: auto;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.validation-value.warning {
    color: #ffc107;
}

.validation-value.highlight {
    color: #F07400;
    font-size: 1rem;
}

.validation-row.total {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.validation-row.total.match .validation-value {
    color: #00ff88;
}

.validation-row.total.no-match .validation-value {
    color: #ff6b6b;
}


/* ========================================================================== */
/* PROGRESS PANEL                                                              */
/* ========================================================================== */

.popular-progress-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.1), rgba(0, 180, 255, 0.1));
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.progress-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: #F07400;
    border-right-color: #00b4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-bar-container {
    position: relative;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #F07400, #00b4ff);
    border-radius: 12px;
    transition: width 0.5s ease;
    animation: shimmer 2s infinite;
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.progress-percentage {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-message {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.progress-step.completado {
    color: #00ff88;
}

.progress-step.enproceso {
    color: #F07400;
    background: rgba(240, 116, 0, 0.1);
}

.progress-step.error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.step-status {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.pending-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    opacity: 0.5;
}

.step-desc {
    flex: 1;
}

/* ========================================================================== */
/* RESULT PANEL                                                                */
/* ========================================================================== */

.popular-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popular-result.success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.popular-result.error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.result-icon {
    flex-shrink: 0;
}

.popular-result.success .result-icon {
    color: #00ff88;
}

.popular-result.error .result-icon {
    color: #ff6b6b;
}

.result-message {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========================================================================== */
/* CITY SUMMARY (Resumen por Ciudad)                                           */
/* ========================================================================== */

.popular-city-summary {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-top: 1rem;
}

.city-summary-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(0, 180, 255, 0.1), rgba(0, 255, 136, 0.1));
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.city-summary-header svg {
    color: #00b4ff;
}

.city-summary-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
}

.city-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.city-row:hover {
    background: rgba(0, 180, 255, 0.1);
}

.city-row.total {
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.15), rgba(0, 180, 255, 0.15));
    border: 1px solid rgba(240, 116, 0, 0.3);
}

.city-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.city-row.total .city-name {
    font-weight: 700;
    color: var(--text-primary);
}

.city-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.city-row.total .city-count {
    font-size: 1rem;
    color: #00ff88;
}

/* ========================================================================== */
/* ACTIONS                                                                     */
/* ========================================================================== */

.btn-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #00b4ff;
    color: white;
    border: 1px solid #00b4ff;
}

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

.btn-primary {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 116, 0, 0.4);
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================================================== */
/* EMPTY STATE                                                                 */
/* ========================================================================== */

.popular-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
    flex: 1;
    min-height: 300px;
    width: 100%;
    box-sizing: border-box;
}

.empty-icon {
    color: var(--text-secondary);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.popular-empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.popular-empty-state p {
    margin: 0;
    font-size: 0.9rem;
}

.popular-empty-state .hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #00ff88;
}

/* ========================================================================== */
/* ROUTE SUMMARY (Resumen por Ruta - Badge)                                   */
/* ========================================================================== */

.route-count-badge {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    background: rgba(0, 180, 255, 0.15);
    color: #00b4ff;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.route-table-header,
.route-table-footer {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-table-header {
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.route-table-footer {
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.route-table-footer .warning {
    color: #ffc107;
}

.route-table-scroll {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.route-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.route-row:hover {
    background: rgba(0, 180, 255, 0.05);
}

.route-row.has-pending {
    background: rgba(255, 193, 7, 0.05);
    border-left: 2px solid #ffc107;
}

.route-id {
    font-weight: 600;
    color: var(--text-primary);
}

.route-total,
.route-tabulados {
    color: var(--text-secondary);
}

.route-pendientes {
    color: var(--text-secondary);
}

.route-pendientes.warning {
    color: #ffc107;
    font-weight: 600;
}

/* ========================================================================== */
/* NO PROVIDER TABLE                                                          */
/* ========================================================================== */

.no-provider-count-badge {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.no-provider-count-badge.warning {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.no-provider-table-header {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.no-provider-table-scroll {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.no-provider-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.no-provider-row:hover {
    background: rgba(255, 193, 7, 0.05);
}

.np-ruta {
    font-weight: 600;
    color: var(--text-primary);
}

.np-tipo {
    color: var(--text-secondary);
}

/* ========================================================================== */
/* UNTABULATED ITEMS TABLE (Items Sin Tabular Y Sin Publicidad)               */
/* ========================================================================== */

.untabulated-panel {
    display: flex;
    flex-direction: column;
}

.untabulated-panel-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.panel-header.untabulated-header svg {
    color: #ff9500;
}

.untabulated-count-badge {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.untabulated-count-badge.warning {
    background: rgba(255, 149, 0, 0.15);
    color: #ff9500;
}

.untabulated-count-badge.ok {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.untabulated-table-container {
    max-height: 200px;
    overflow: auto;
    border-radius: 6px;
}

.untabulated-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.7rem;
}

.untabulated-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.untabulated-table thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.5rem 0.6rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.untabulated-table tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.untabulated-table tbody tr:hover {
    background: rgba(255, 149, 0, 0.08);
}

.untabulated-table tbody tr.sin-tabular {
    border-left: 3px solid #ffc107;
}

.untabulated-table tbody tr.sin-publicidad {
    border-left: 3px solid #00b4ff;
}

.untabulated-table tbody tr.sin-tabular:hover {
    background: rgba(255, 193, 7, 0.1);
}

.untabulated-table tbody tr.sin-publicidad:hover {
    background: rgba(0, 180, 255, 0.1);
}

.untabulated-table tbody td {
    padding: 0.4rem 0.6rem;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.untabulated-table tbody tr:last-child td {
    border-bottom: none;
}

.ut-marca {
    font-weight: 600;
    color: #ffc107 !important;
}

.ut-tipo {
    font-weight: 600;
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    text-align: center;
    display: inline-block;
}

.ut-tipo.tipo-sin-tabular {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.ut-tipo.tipo-sin-publicidad {
    background: rgba(0, 180, 255, 0.15);
    color: #00b4ff;
}

.untabulated-table-footer {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.footer-summary {
    display: flex;
    gap: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.summary-item {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.summary-item.sin-tabular-count {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.summary-item.sin-publicidad-count {
    background: rgba(0, 180, 255, 0.15);
    color: #00b4ff;
}

/* ========================================================================== */
/* LOADING SPINNER                                                            */
/* ========================================================================== */

.popular-main-content .loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.popular-main-content .loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.popular-main-content .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid #F07400;
    border-right: 4px solid #00b4ff;
    border-radius: 50%;
    animation: spinPopular 1s linear infinite;
}

@keyframes spinPopular {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.popular-main-content .loading-text {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* ========================================================================== */
/* RESPONSIVE                                                                 */
/* ========================================================================== */

@media (max-width: 1400px) {
    .popular-validation-panels {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .popular-page {
        gap: 0.75rem;
        height: calc(100vh - 95px);
        min-height: calc(100vh - 95px);
        max-height: calc(100vh - 95px);
        overflow: hidden;
    }

        .popular-page .camara-panel {
            display: flex;
            flex-direction: column;
            height: 100%;
            overflow: hidden;
        }

        .popular-page .camara-header {
            flex-shrink: 0;
        }

        .popular-page .camara-body {
            flex: 1;
            overflow-y: auto !important;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            min-height: 0;
        }

    .popular-steps-row {
        flex-direction: column;
        width: 100%;
    }

    .popular-steps-indicator {
        padding: 0.75rem;
        gap: 0;
    }

    .step-connector {
        width: 30px;
    }

    .step-number {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .step-label {
        font-size: 0.65rem;
    }

    .cycle-info-details {
        gap: 1rem;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .info-label::after {
        content: '';
    }

    .popular-validation-panels {
        grid-template-columns: repeat(2, 1fr);
    }

    .untabulated-table-container {
        max-height: 180px;
    }

    .untabulated-table {
        font-size: 0.65rem;
    }

    .untabulated-table thead th,
    .untabulated-table tbody td {
        padding: 0.35rem 0.5rem;
    }

    .popular-actions-row {
        width: 100%;
        justify-content: center;
    }

    .no-provider-panel-body,
    .route-panel-body,
    .untabulated-panel-body {
        min-height: 150px;
    }

    .progress-steps {
        grid-template-columns: 1fr;
    }

    .route-table-header,
    .route-table-footer,
    .route-row {
        grid-template-columns: 60px 1fr 1fr 1fr;
        font-size: 0.7rem;
    }

    .no-provider-table-header,
    .no-provider-row {
        grid-template-columns: 60px 1fr;
        font-size: 0.7rem;
    }

    .popular-actions-row {
        flex-direction: column;
    }

    .popular-actions-row .btn-action {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .popular-page {
        height: calc(100vh - 95px);
        min-height: calc(100vh - 95px);
        max-height: calc(100vh - 95px);
        overflow: hidden;
    }

        .popular-page .camara-panel {
            display: flex;
            flex-direction: column;
            height: 100%;
            overflow: hidden;
        }

        .popular-page .camara-header {
            flex-shrink: 0;
        }

        .popular-page .camara-body {
            flex: 1;
            overflow-y: auto !important;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            min-height: 0;
        }

    .popular-validation-panels {
        grid-template-columns: 1fr;
    }

    .popular-steps-indicator {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .step-connector {
        display: none;
    }

    .step {
        flex-direction: row;
        gap: 0.5rem;
    }

    .cycle-info-header {
        flex-wrap: wrap;
    }

    .badge-populated {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
        text-align: center;
    }

    .untabulated-table-container {
        max-height: 150px;
    }

    .untabulated-table {
        font-size: 0.6rem;
    }

    .untabulated-table thead th,
    .untabulated-table tbody td {
        padding: 0.3rem 0.4rem;
    }

    .footer-summary {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .post-population-panels {
        grid-template-columns: 1fr;
    }
}

/* ========================================================================== */
/* POST-POPULATION PANELS (4 Cards Horizontales)                              */
/* ========================================================================== */

.post-population-panels {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
}

.validation-panel.post-panel {
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

.panel-header.post-header {
    background: linear-gradient(135deg, rgba(0, 180, 255, 0.1), rgba(0, 255, 136, 0.1));
}

.panel-header.post-header svg {
    color: #00b4ff;
}

.panel-header.post-header.warning-header svg {
    color: #ffc107;
}

.post-count-badge {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.post-count-badge.ok {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.post-count-badge.warning {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.post-panel-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.post-table-scroll {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

/* Post Row - Resumen por Localidad */
.post-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.post-row:hover {
    background: rgba(0, 180, 255, 0.05);
}

.post-localidad {
    font-weight: 500;
    color: var(--text-secondary);
}

.post-cantidad {
    font-weight: 600;
    color: var(--text-primary);
}

/* Post Table Footer */
.post-table-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.post-table-footer .match {
    color: #00ff88;
}

.post-table-footer .no-match {
    color: #ff6b6b;
}

/* Post Validation Footer */
.post-validation-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.post-validation-footer.match {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.post-validation-footer.no-match {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

/* Post Table Header - Rutas por Localidad */
.post-table-header-rutas {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.post-row-rutas {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.post-row-rutas:hover {
    background: rgba(0, 180, 255, 0.05);
}

.post-ruta-id {
    font-weight: 600;
    color: var(--text-primary);
}

.post-ruta-loc {
    color: var(--text-secondary);
}

/* Post Table Header - Items Sin Localidad */
.post-table-header-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.post-row-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.post-row-items.warning-row {
    background: rgba(255, 193, 7, 0.05);
    border-left: 2px solid #ffc107;
}

.post-row-items:hover {
    background: rgba(255, 193, 7, 0.1);
}

.post-item-id {
    font-weight: 600;
    color: var(--text-primary);
}

.post-item-loc {
    color: #ffc107;
    font-weight: 500;
}

/* Post Table Header - Items Sin Costo */
.post-table-header-costo {
    display: grid;
    grid-template-columns: 70px 50px 1fr 80px;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.post-row-costo {
    display: grid;
    grid-template-columns: 70px 50px 1fr 80px;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.post-row-costo.warning-row {
    background: rgba(255, 193, 7, 0.05);
    border-left: 2px solid #ffc107;
}

.post-row-costo:hover {
    background: rgba(255, 193, 7, 0.1);
}

.post-costo-id {
    font-weight: 600;
    color: var(--text-primary);
}

.post-costo-ruta {
    font-weight: 500;
    color: var(--text-secondary);
}

.post-costo-tipo {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-costo-loc {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* More Items Indicator */
.post-more-items {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive para Post-Population Panels */
@media (max-width: 1400px) {
    .post-population-panels {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .post-population-panels {
        grid-template-columns: repeat(2, 1fr);
    }

    .post-table-header-costo,
    .post-row-costo {
        grid-template-columns: 60px 40px 1fr 60px;
        font-size: 0.65rem;
    }
}
