/* ==========================================================================
   PIV — Painel de Inteligência de Vendas, Metas e Perdas
   CSS Moderno, Elegante e Responsivo
   ========================================================================== */

#piv-view {
    width: 100%;
    min-height: 100vh;
    background: #f8fafc;
    color: #0f172a;
    font-family: inherit;
    box-sizing: border-box;
}

/* Header & Barra Superior */
.piv-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.piv-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.piv-brand-title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.piv-brand-sub {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.piv-badge-beta {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 6px;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Container Principal — 100% Full-Width sem desperdício de espaço lateral */
.piv-container {
    padding: 1.25rem 2rem;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Card de Filtros */
.piv-filter-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.2rem 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.piv-filter-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.piv-preset-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.piv-preset-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.piv-preset-btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.piv-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.piv-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.piv-filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 4px;
}

.piv-filter-input, .piv-filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s;
}

.piv-filter-input:focus, .piv-filter-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Grid de KPIs */
.piv-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.1rem;
}

.piv-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s, box-shadow 0.15s;
}

.piv-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.04);
}

.piv-kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.piv-kpi-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.piv-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.piv-kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.piv-kpi-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Badges de Variação */
.piv-var-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
}

.piv-var-badge.pos {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.piv-var-badge.neg {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.piv-var-badge.neutral {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* Barra de Progresso de Meta */
.piv-progress-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

.piv-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: #2563eb;
    transition: width 0.5s ease-out;
}

.piv-progress-bar.bar-success,
.piv-progress-bar.bar-green   { background: linear-gradient(90deg, #10b981, #059669) !important; }
.piv-progress-bar.bar-warning,
.piv-progress-bar.bar-amber   { background: linear-gradient(90deg, #f59e0b, #d97706) !important; }
.piv-progress-bar.bar-danger,
.piv-progress-bar.bar-red     { background: linear-gradient(90deg, #ef4444, #dc2626) !important; }
.piv-progress-bar.bar-blue    { background: linear-gradient(90deg, #3b82f6, #2563eb) !important; }

/* Status da Meta */
.piv-status-pill {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.piv-status-pill.status-atingida {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.piv-status-pill.status-no-ritmo {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.piv-status-pill.status-abaixo-ritmo {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.piv-status-pill.status-sem-meta {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

/* Card de Gráfico Comparativo Geral */
.piv-chart-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.piv-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.8rem;
}

.piv-chart-title {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Gavetas / Accordions dos Grupos & Combos */
.piv-group-drawer {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.piv-group-drawer:hover {
    border-color: #cbd5e1;
}

.piv-group-header {
    padding: 1.25rem 1.6rem;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    user-select: none;
    transition: background-color 0.15s;
}

.piv-group-header:hover {
    background: #f8fafc;
}

.piv-group-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.piv-group-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.piv-group-count-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.piv-group-metrics {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.piv-group-metric-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.piv-group-metric-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

.piv-group-metric-val {
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
}

.piv-drawer-toggle-arrow {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    transition: transform 0.2s ease;
}

.piv-group-drawer.open .piv-drawer-toggle-arrow {
    transform: rotate(180deg);
}

.piv-group-content {
    display: none;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 1.5rem;
}

.piv-group-drawer.open .piv-group-content {
    display: block;
    animation: pivSlideDown 0.2s ease-out;
}

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

/* Grid de Produtos do Grupo */
.piv-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.2rem;
}

/* Card Individual de Produto */
.piv-product-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.9rem;
    transition: transform 0.15s, border-color 0.15s;
}

.piv-product-card:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.piv-prod-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.piv-prod-codes {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.piv-code-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.piv-prod-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
}

.piv-prod-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.piv-stat-col {
    display: flex;
    flex-direction: column;
}

.piv-stat-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

.piv-stat-main {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
}

.piv-stat-comp {
    font-size: 0.75rem;
    color: #64748b;
}

/* Tabela de Perdas Comparativa */
.piv-loss-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.piv-loss-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.piv-loss-table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

.piv-loss-table tr:hover td {
    background: #f8fafc;
}

/* Modais de Configuração */
.piv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
}

.piv-modal-card {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 950px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
    overflow: hidden;
    animation: pivModalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pivModalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.piv-modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.piv-modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.piv-modal-close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.piv-modal-close-btn:hover {
    color: #0f172a;
}

.piv-modal-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    padding: 0 1.5rem;
}

.piv-modal-tab-btn {
    padding: 0.85rem 1.2rem;
    border: none;
    background: none;
    font-size: 0.88rem;
    font-weight: 700;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.piv-modal-tab-btn:hover {
    color: #0f172a;
}

.piv-modal-tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.piv-modal-body {
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
    flex: 1;
}

.piv-modal-footer {
    padding: 1.1rem 1.75rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.piv-modal-changes-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 9999px;
    animation: pivPulseBadge 2s infinite ease-in-out;
}

@keyframes pivPulseBadge {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(0.98); }
}

.piv-btn-save-changes {
    background: #16a34a !important;
    color: #ffffff !important;
    border: 1px solid #15803d !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3) !important;
    transition: all 0.2s ease !important;
}

.piv-btn-save-changes:hover {
    background: #15803d !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.4) !important;
}

/* Loading Overlay Global */
.piv-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: pivFadeIn 0.2s ease-out;
}

.piv-loading-card {
    background: #ffffff;
    padding: 2.2rem 2.8rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    max-width: 90vw;
    text-align: center;
}

.piv-loading-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

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

/* Botões Padrão */
.piv-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.piv-btn-primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.piv-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.piv-btn-secondary {
    background: #ffffff;
    color: #334155;
    border-color: #cbd5e1;
}

.piv-btn-secondary:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.piv-btn-success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.piv-btn-success:hover {
    filter: brightness(1.05);
}

.piv-btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.piv-btn-danger:hover {
    background: #fecaca;
    color: #b91c1c;
}

/* Workspace Master-Detail Layout */
.piv-workspace-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    align-items: start;
    margin-top: 1rem;
}

@media (max-width: 1024px) {
    .piv-workspace-layout {
        grid-template-columns: 1fr;
    }
}

.piv-items-sidebar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.1rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

.piv-items-header {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #f1f5f9;
}

.piv-items-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.piv-items-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.piv-items-count-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    padding: 2px 8px;
    border-radius: 9999px;
}

.piv-items-list-container {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-right: 4px;
    flex: 1;
}

.piv-item-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 11px;
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.piv-item-card:hover {
    border-color: #93c5fd;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.piv-item-card.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
}

.piv-item-card.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: #2563eb;
}

.piv-item-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
}

.piv-item-card-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.piv-item-card.active .piv-item-card-name {
    color: #1d4ed8;
}

.piv-item-type-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.piv-item-type-badge.combo {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.piv-item-type-badge.produto {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.piv-item-card-metrics {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    color: #64748b;
    margin-top: 2px;
}

.piv-item-card-val {
    font-size: 0.92rem;
    font-weight: 800;
    color: #0f172a;
}

/* Painel de Detalhes do Item Ativo */
.piv-item-detail-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.piv-detail-header-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.piv-detail-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.piv-combo-prods-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
}

.piv-combo-prod-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.piv-combo-prod-row:hover {
    background: #f8fafc !important;
}

.piv-combo-prod-row.selected {
    background: #eff6ff !important;
    font-weight: 600;
}

/* Empty State do Mês */
.piv-empty-state-card {
    background: #ffffff;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 3.5rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.piv-empty-state-icon {
    font-size: 3rem;
    line-height: 1;
}

/* Navegação de Abas Principais (Acompanhamento vs Cadastro) */
.piv-nav-tabs-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.piv-nav-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    color: #475569;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.18s ease;
}

.piv-nav-tab-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.6);
}

.piv-nav-tab-btn.active {
    color: #2563eb;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Grid de Metas por Loja (FLEX, EXTRA, COHAB, ESTRELA) */
.piv-store-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin: 0.5rem 0;
}

@media (max-width: 900px) {
    .piv-store-meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .piv-store-meta-grid {
        grid-template-columns: 1fr;
    }
}

.piv-store-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.15s ease;
}

.piv-store-card.participa {
    border-color: #3b82f6;
    background: #f8fafc;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.08);
}

.piv-store-card.nao-participa {
    opacity: 0.75;
    background: #ffffff;
}

.piv-store-card:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    opacity: 1;
}

/* Ferramenta de Distribuição Rápida de Metas */
.piv-quick-fill-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 0.9rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    flex-wrap: wrap;
}

.piv-quick-btn {
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.piv-quick-btn:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* Estados da Tabela de Gestão de Produtos */
.piv-cad-row-staged-delete {
    background: #fef2f2 !important;
    opacity: 0.65;
}

.piv-cad-row-staged-delete td {
    color: #991b1b !important;
}

.piv-cad-row-staged-delete .piv-cad-prod-title {
    text-decoration: line-through;
}

.piv-cad-row-new {
    background: #f0fdf4 !important;
}

.piv-badge-staged {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.piv-badge-staged.novo {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.piv-badge-staged.excluir {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.piv-badge-staged.editado {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.piv-store-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.piv-store-badge {
    font-size: 0.72rem;
    font-weight: 800;
    color: #1e40af;
    background: #eff6ff;
    padding: 2px 6px;
    border-radius: 4px;
}

.piv-store-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
}

.piv-store-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: right;
    color: #0f172a;
    transition: all 0.15s ease;
}

.piv-store-input:focus {
    border-color: #2563eb;
    outline: none;
    background: #f0fdf4;
}

.piv-store-hist {
    font-size: 0.73rem;
    color: #64748b;
    margin-top: 5px;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

.piv-store-hist strong {
    color: #0f172a;
    font-weight: 700;
}

/* Barra de Sugestão Inteligente com Base no Histórico */
.piv-hist-suggestion-bar {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(22, 101, 52, 0.05);
}

.piv-hist-sugg-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: #166534;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.piv-pct-input-wrap {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #86efac;
    border-radius: 6px;
    padding: 3px 8px;
    gap: 4px;
}

.piv-pct-input-wrap input {
    width: 44px;
    border: none;
    outline: none;
    font-weight: 800;
    color: #15803d;
    text-align: right;
    font-size: 0.88rem;
    padding: 0;
}

.piv-pct-input-wrap span {
    font-weight: 800;
    color: #15803d;
    font-size: 0.82rem;
}

.piv-pct-preset-group {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.piv-pct-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.piv-pct-btn:hover {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.piv-pct-btn.active {
    background: #15803d;
    border-color: #15803d;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(21, 128, 61, 0.25);
}

.piv-mode-toggle-btn {
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 700;
    border: none;
    background: transparent;
    color: #166534;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.piv-mode-toggle-btn.active {
    background: #15803d !important;
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 1px 3px rgba(21, 128, 61, 0.2);
}

.piv-btn-apply-sugg {
    background: #16a34a;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}

.piv-btn-apply-sugg:hover {
    background: #15803d;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.35);
}

.piv-btn-apply-sugg:active {
    transform: translateY(0);
}

/* =============================================================================
   AUTOCOMPLETE & DROPDOWN DE PESQUISA DE PRODUTO
   ============================================================================= */
.piv-search-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #ffffff !important;
    border: 1.5px solid #2563eb !important;
    border-radius: 12px !important;
    box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.22), 0 6px 14px -3px rgba(15, 23, 42, 0.1) !important;
    max-height: 310px;
    overflow-y: auto;
    z-index: 9999 !important;
    padding: 4px 0 !important;
}

.piv-search-dropdown::-webkit-scrollbar {
    width: 6px;
}
.piv-search-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.piv-search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #ffffff;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s ease;
    user-select: none;
}

.piv-search-result-item:last-child {
    border-bottom: none;
}

.piv-search-result-item:hover,
.piv-search-result-item.active {
    background: #eff6ff !important;
}

.piv-search-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.piv-search-item-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.piv-search-item-title strong {
    color: #1e40af;
    margin-right: 6px;
}

.piv-search-item-meta {
    font-size: 0.76rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.piv-search-item-meta span {
    display: inline-flex;
    align-items: center;
}

.piv-search-item-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.piv-search-item-badge.un {
    background: #dbeafe;
    color: #1e40af;
}

.piv-search-item-badge.kg {
    background: #dcfce7;
    color: #15803d;
}

.piv-search-empty-state {
    padding: 18px 16px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

/* Tabela de Gestão de Produtos com Edição Inline */
.piv-gestao-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.piv-table-inline-input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    color: #0f172a;
    transition: all 0.15s ease;
}

.piv-table-inline-input:focus {
    border-color: #2563eb;
    outline: none;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.piv-table-inline-input.zero {
    color: #94a3b8;
    background: #f8fafc;
}

/* Barra de Ações Flutuante / Rodapé de Salvamento */
.piv-save-floating-bar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.9rem 1.4rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    position: sticky;
    bottom: 1.5rem;
    z-index: 100;
}

/* Responsividade */
@media (max-width: 768px) {
    .piv-header {
        padding: 0.8rem 1rem;
    }
    .piv-container {
        padding: 1rem;
    }
    .piv-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .piv-products-grid {
        grid-template-columns: 1fr;
    }
    .piv-group-metrics {
        justify-content: space-between;
        width: 100%;
    }
}

/* ==========================================================================
   MATRIZ CONSOLIDADA DE PERFORMANCE & COCKPIT EXECUTIVO
   ========================================================================== */

.piv-btn-capture {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border: 1px solid #334155;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.piv-btn-capture:hover {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    color: #ffffff;
    border-color: #475569;
    transform: translateY(-1px);
}

/* Card Principal da Matriz */
.piv-scorecard-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.piv-scorecard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1.5px solid #f1f5f9;
    padding-bottom: 0.9rem;
}

.piv-scorecard-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.piv-scorecard-badge {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.piv-scorecard-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.piv-scorecard-subtitle {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.piv-scorecard-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   NAVEGAÇÃO POR CATEGORIAS & SEÇÕES (ESTILO CONSTRUÇÃO DE MARGEM)
   ========================================================================== */

.piv-cat-nav-wrapper {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.piv-cat-tabs-track {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow-x: auto;
    scrollbar-width: thin;
    max-width: 100%;
    padding-bottom: 2px;
}

.piv-cat-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.8rem;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.piv-cat-tab-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.piv-cat-tab-btn.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.piv-cat-tab-badge {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #475569;
}

.piv-cat-tab-btn.active .piv-cat-tab-badge {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.piv-cat-nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.piv-cat-action-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.piv-cat-action-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

/* Linha de Cabeçalho de Categoria / Seção na Tabela */
.piv-cat-row {
    background: #f8fafc !important;
    border-top: 2px solid #cbd5e1 !important;
    border-bottom: 1.5px solid #e2e8f0 !important;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.piv-cat-row:hover {
    background: #f1f5f9 !important;
}

.piv-cat-cell {
    padding: 9px 12px !important;
    vertical-align: middle;
}

.piv-cat-title-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.88rem;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.piv-cat-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 900;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.piv-cat-row.collapsed .piv-cat-chevron {
    transform: rotate(-90deg);
}

.piv-cat-count-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    white-space: nowrap;
}

.piv-cat-type-pill {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.piv-cat-type-pill.combo {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

/* Subitens indentados dentro de uma Categoria */
.piv-scorecard-row.is-subitem td:first-child {
    padding-left: 2rem !important;
}

.piv-scorecard-row.is-subitem .piv-table-item-cell {
    border-left: 2.5px solid #cbd5e1;
    padding-left: 10px;
    margin-left: 2px;
}

.piv-scorecard-row.cat-hidden {
    display: none !important;
}

/* Tabela de Matriz Executiva */
.piv-scorecard-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
}

.piv-scorecard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

/* Super Header */
.piv-scorecard-table thead .tr-super-header th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    text-align: center;
}

.piv-scorecard-table thead .tr-super-header th:last-child {
    border-right: none;
}

.piv-scorecard-table thead .th-super-prod {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    text-align: left !important;
}

.piv-scorecard-table thead .th-super-rede {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
}

.piv-scorecard-table thead .th-super-lojas {
    background: #f8fafc !important;
    color: #0f172a !important;
    letter-spacing: 0.08em;
}

.piv-scorecard-table thead .th-super-perda {
    background: #fef2f2 !important;
    color: #b91c1c !important;
}

/* Sub Header */
.piv-scorecard-table thead .tr-sub-header th {
    background: #ffffff;
    color: #334155;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 9px 12px;
    border-bottom: 2px solid #cbd5e1;
    border-right: 1px solid #f1f5f9;
    white-space: nowrap;
}

.piv-scorecard-table thead .tr-sub-header th:last-child {
    border-right: none;
}

.piv-scorecard-table thead .th-store-col {
    background: #fafafa;
    min-width: 140px;
}

.piv-scorecard-table thead .th-col-flex {
    border-top: 2px solid #2563eb;
    color: #1d4ed8;
}

.piv-scorecard-table thead .th-col-extra {
    border-top: 2px solid #16a34a;
    color: #15803d;
}

.piv-scorecard-table thead .th-col-cohab {
    border-top: 2px solid #7c3aed;
    color: #6d28d9;
}

.piv-scorecard-table thead .th-col-estrela {
    border-top: 2px solid #d97706;
    color: #b45309;
}

/* Linhas e Células */
.piv-scorecard-table tbody tr {
    transition: background 0.12s ease;
    cursor: pointer;
}

.piv-scorecard-table tbody tr:hover {
    background: #f8fafc;
}

.piv-scorecard-table tbody tr.piv-row-selected {
    background: #f0fdf4 !important;
}

.piv-scorecard-table tbody tr.piv-row-selected td:first-child {
    border-left: 3.5px solid #16a34a;
}

.piv-scorecard-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f8fafc;
    vertical-align: middle;
}

.piv-scorecard-table tbody td:last-child {
    border-right: none;
}

/* Formatação do Item na Tabela */
.piv-table-item-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 200px;
}

.piv-table-item-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
}

.piv-table-item-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #64748b;
}

/* Célula de Loja */
.piv-store-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
}

.piv-store-cell-vals {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.piv-store-cell-vals strong {
    color: #0f172a;
    font-weight: 800;
}

.piv-store-badge-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 9999px;
    letter-spacing: -0.01em;
}

.piv-store-badge-mini.status-atingida {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.piv-store-badge-mini.status-ritmo {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.piv-store-badge-mini.status-abaixo {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.piv-store-badge-mini.status-sem-meta {
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
}

/* Rodapé de Totais da Matriz */
.piv-scorecard-table tfoot tr {
    background: #f8fafc;
    font-weight: 800;
}

.piv-scorecard-table tfoot td {
    padding: 11px 12px;
    border-top: 2px solid #cbd5e1;
    border-bottom: none;
    color: #0f172a;
    font-size: 0.88rem;
}

/* ==========================================================================
   PAINEL ANALÍTICO DETALHADO (DUAL CHARTS & DIAGNÓSTICO)
   ========================================================================== */

.piv-detail-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.piv-charts-dual-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    width: 100%;
}

@media (max-width: 1100px) {
    .piv-charts-dual-grid {
        grid-template-columns: 1fr;
    }
}

.piv-diagnostics-dual-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    width: 100%;
}

@media (max-width: 1100px) {
    .piv-diagnostics-dual-grid {
        grid-template-columns: 1fr;
    }
}

.piv-chart-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    font-weight: 700;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #475569;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-dot.dot-cur { background: #2563eb; }
.legend-dot.dot-prev { background: #cbd5e1; }
.legend-dot.dot-loss { background: #ef4444; }

/* ==========================================================================
   MODO CAPTURA / PRINT & RELATÓRIO
   ========================================================================== */

.piv-print-header {
    background: #ffffff;
    border: 2px solid #0f172a;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}

.piv-print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.piv-print-brand-tag {
    font-size: 0.68rem;
    font-weight: 800;
    color: #2563eb;
    letter-spacing: 0.1em;
}

.piv-print-brand-title {
    margin: 2px 0 0 0;
    font-size: 1.4rem;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.piv-print-brand-sub {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

.piv-print-meta-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.78rem;
    color: #334155;
    background: #f8fafc;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.piv-print-meta-line {
    display: flex;
    gap: 6px;
}

/* Barra Flutuante de Captura */
.piv-capture-floating-bar {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 9999;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Modo Captura Ativo: Limpa a tela para Screenshot Perfeito */
body.piv-modo-print-active .app-sidebar,
body.piv-modo-print-active .mobile-sidebar-toggle,
body.piv-modo-print-active .sidebar-backdrop,
body.piv-modo-print-active .piv-header,
body.piv-modo-print-active .piv-filter-card,
body.piv-modo-print-active .piv-print-hide {
    display: none !important;
}

body.piv-modo-print-active .piv-container {
    padding: 1rem !important;
    max-width: 100% !important;
}

body.piv-modo-print-active #pivPrintBanner {
    display: block !important;
}

/* Folha de Estilo de Impressão Nativa (Ctrl+P / Salvar PDF) */
@media print {
    @page {
        size: landscape;
        margin: 8mm;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .app-sidebar,
    .mobile-sidebar-toggle,
    .sidebar-backdrop,
    .piv-header,
    .piv-filter-card,
    .piv-print-hide,
    .piv-capture-floating-bar,
    .piv-loading-overlay {
        display: none !important;
    }

    .piv-container {
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #pivPrintBanner {
        display: block !important;
    }

    .piv-scorecard-card {
        box-shadow: none !important;
        border: 1px solid #94a3b8 !important;
        page-break-inside: avoid;
    }

    .piv-scorecard-table {
        font-size: 7.5pt !important;
    }

    .piv-scorecard-table tbody td {
        padding: 6px 8px !important;
    }

    .piv-detail-section {
        page-break-before: always;
    }
}

/* =============================================================================
   MÓDULO PIV: FRENTE DE CAIXA (ESTILOS CORPORATIVOS EXECUTIVOS)
   ============================================================================= */

.piv-fc-kpis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.piv-fc-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.piv-fc-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.piv-fc-kpi-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.piv-fc-kpi-val {
    font-size: 1.6rem;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.15;
}

.piv-fc-kpi-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.piv-fc-main-grid {
    display: grid;
    grid-template-columns: 1.7fr 1.1fr;
    gap: 1.25rem;
}

@media (max-width: 1024px) {
    .piv-fc-main-grid {
        grid-template-columns: 1fr;
    }
}

/* Pódio Executivo dos Top 3 Operadores */
.piv-fc-podium-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .piv-fc-podium-wrapper {
        grid-template-columns: 1fr;
    }
}

.piv-fc-podium-card {
    border-radius: 10px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    border: 1px solid #e2e8f0;
}

.piv-fc-podium-card.rank-1 {
    background: linear-gradient(135deg, #fefce8 0%, #fef08a 100%);
    border-color: #facc15;
}

.piv-fc-podium-card.rank-2 {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-color: #cbd5e1;
}

.piv-fc-podium-card.rank-3 {
    background: linear-gradient(135deg, #fffbeb 0%, #fed7aa 100%);
    border-color: #fdba74;
}

.piv-fc-podium-rank-tag {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.piv-fc-podium-card.rank-1 .piv-fc-podium-rank-tag {
    color: #854d0e;
}

.piv-fc-podium-card.rank-2 .piv-fc-podium-rank-tag {
    color: #475569;
}

.piv-fc-podium-card.rank-3 .piv-fc-podium-rank-tag {
    color: #9a3412;
}

.piv-fc-podium-name {
    font-size: 0.92rem;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.piv-fc-podium-store {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
}

.piv-fc-podium-val {
    font-size: 1.25rem;
    font-weight: 900;
    color: #0f172a;
    margin-top: 4px;
}

/* Lista de Produtos da Campanha de Caixa */
.piv-fc-prod-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.piv-fc-prod-item:hover {
    background: #f1f5f9;
}

.piv-fc-prod-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    display: block;
}

.piv-fc-prod-sub {
    font-size: 0.72rem;
    color: #64748b;
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.piv-fc-prod-stat {
    text-align: right;
    min-width: 90px;
}

.piv-fc-prod-stat-num {
    font-size: 1.05rem;
    font-weight: 900;
    color: #2563eb;
    display: block;
}

.piv-fc-prod-stat-lbl {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 700;
}

/* Campos de meta desabilitados quando o produto for Frente de Caixa */
.piv-cad-meta-store.disabled-fc {
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    cursor: not-allowed !important;
    border-color: #e2e8f0 !important;
    font-style: italic;
}


