/* ═══════════════════════════════════════════════════════════════
   DASHBOARD.CSS — Compras · Dashboard analítico e Pipeline
   Prefixo: dash- / pipe-
   ═══════════════════════════════════════════════════════════════ */

/* ── Period selector ── */
.dash-period-bar { position: sticky; top: 98px; z-index: 1001; background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: .75rem 1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dps-mode-btns { display: flex; gap: 4px; }
.dps-mode-btn { font-family: inherit; font-size: 12px; padding: 4px 12px; border-radius: 20px; border: 1px solid var(--bdr); background: var(--card); color: var(--t2); cursor: pointer; transition: all .15s; }
.dps-mode-btn.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.dps-mode-btn:hover:not(.active) { background: var(--muted); }
.dps-sep { width: 1px; height: 20px; background: var(--bdr); }
.dps-date-row { display: flex; align-items: center; gap: 6px; }
.dps-date-inp { font-family: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--bdr); border-radius: var(--r); background: var(--inp); color: var(--t1); }
.dps-apply { font-family: inherit; font-size: 12px; padding: 4px 12px; border-radius: var(--r); border: none; background: var(--marca-azul); color: #fff; cursor: pointer; }
.dps-mes-nav { display: flex; align-items: center; gap: 6px; }
.dps-nav-btn { font-family: inherit; font-size: 16px; line-height: 1; padding: 2px 8px; border-radius: var(--r); border: 1px solid var(--bdr); background: var(--card); color: var(--t1); cursor: pointer; }
.dps-mes-label { font-size: 13px; font-weight: 600; color: var(--t1); min-width: 100px; text-align: center; }
.dps-label-pill { font-size: 11px; font-weight: 600; background: var(--muted); color: var(--t2); padding: 3px 10px; border-radius: 20px; }

/* ── Botões de modelo ── */
.dash-model-btn { font-family: inherit; font-size: 12px; font-weight: 500; padding: 5px 14px; border-radius: 20px; border: 1px solid var(--bdr); background: var(--card); color: var(--t2); cursor: pointer; transition: all .15s; }
.dash-model-btn.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.dash-model-btn:hover:not(.active) { background: var(--muted); }
.dash-model-btn--visao-geral.active { background: var(--marca-azul); border-color: var(--marca-azul); }

/* ── Cards e grids base ── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.dash-card { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: 1.25rem; box-shadow: var(--sh); }
.dash-card-full { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: .75rem 1.25rem; box-shadow: var(--sh); margin-bottom: 1rem; }
.dash-title { font-size: 14px; font-weight: 600; color: var(--t1); margin-bottom: .25rem; }
.dash-sub { font-size: 12px; color: var(--t2); margin-bottom: 1rem; }

/* ── KPIs ── */
.kpi-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kpi-box { background: var(--muted); border-radius: var(--r); padding: .35rem .75rem; text-align: center; flex: 1; min-width: 130px; white-space: nowrap; }
.kpi-val { font-size: 15px; font-weight: 700; }
.kpi-lbl { font-size: 10px; color: var(--t2); text-transform: uppercase; letter-spacing: .5px; margin-top: 1px; white-space: nowrap; font-weight: 600; }

/* ── Gráficos ── */
.chart-canvas-wrap { position: relative; width: 100%; height: 260px; }
.chart-canvas-wrap.tall { height: 380px; }
.pipe-graf-duplo { display: flex; gap: 1.25rem; }
.pipe-graf-wrap--meio { flex: 1; min-width: 0; }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: .75rem; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--t2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   PIPELINE CONSOLIDADO
   ═══════════════════════════════════════════════════════════════ */

/* ── KPIs consolidados ── */
.pipe-kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.pipe-kpi-box { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: .85rem 1rem; text-align: center; box-shadow: var(--sh); }
.pipe-kpi-val { font-size: 22px; font-weight: 700; color: var(--t1); line-height: 1.1; }
.pipe-kpi-val--alerta { color: #dc2626; }
.pipe-kpi-val--ok { color: #16a34a; }
.pipe-kpi-lbl { font-size: 10px; font-weight: 600; color: var(--t2); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }

/* ── Seção título ── */
.pipe-section { margin-bottom: 1.5rem; }
.pipe-section-header { display: flex; align-items: center; gap: 8px; margin-bottom: .75rem; }
.pipe-section-title { font-size: 13px; font-weight: 700; color: var(--t1); text-transform: uppercase; letter-spacing: .6px; }
.pipe-section-count { font-size: 11px; font-weight: 600; background: var(--muted); color: var(--t2); padding: 2px 8px; border-radius: 20px; }

/* ── Grid de cards pipeline ── */
.pipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

/* ── Card de modelo no pipeline ── */
.pipe-card { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); overflow: hidden; box-shadow: var(--sh); cursor: pointer; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.pipe-card[data-tooltip] { overflow: visible; }
.pipe-card[data-tooltip] .pipe-card-foto { border-radius: var(--rl) var(--rl) 0 0; }
.pipe-card[data-tooltip] .pipe-card-foto--vazia { border-radius: var(--rl) var(--rl) 0 0; }
.pipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.pipe-tooltip { position: absolute; bottom: calc(100% + 6px); left: 0; background: #1e293b; color: #fff; font-size: 11px; font-weight: 500; padding: 6px 10px; border-radius: 6px; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 200; line-height: 1.8; box-shadow: 0 4px 12px rgba(0,0,0,.25); white-space: nowrap; }
.pipe-card[data-tooltip]:hover .pipe-tooltip { opacity: 1; }
.pipe-card--ruptura { border-color: var(--bdr); }
.pipe-card--atencao { border-color: var(--bdr); }
.pipe-card--saudavel { border-color: var(--bdr); }
.pipe-card--transito { border-color: var(--bdr); }

/* ── Foto do modelo ── */
.pipe-card-foto { width: 100%; height: 140px; object-fit: contain; object-position: center bottom; background: var(--card); display: block; padding: 12px 16px 4px; }
.pipe-card-foto--vazia { width: 100%; height: 160px; background: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--t3); }

/* ── Conteúdo do card ── */
.pipe-card-acomprar { font-size: 10px; color: var(--marca-laranja); margin-top: 2px; }
.pipe-card-cob-info { font-size: 10px; color: var(--t2); margin-top: 4px; }
.pipe-card-ver { display: block; text-align: center; font-size: 11px; font-weight: 600; color: var(--marca-azul); padding: 8px 0 6px; border-top: 1px solid var(--bdr); margin-top: 8px; opacity: 0; transition: opacity .15s; }
.pipe-card:hover .pipe-card-ver { opacity: 1; }
.pipe-rupt-sku { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 3px; }
.pipe-rupt-tam { font-weight: 700; color: var(--t1); min-width: 36px; }
.pipe-rupt-zero { color: #dc2626; font-weight: 700; }
.pipe-rupt-cob { color: var(--t3); font-size: 11px; }
.pipe-tendencia { font-size: 11px; font-weight: 700; margin-left: 6px; }
.pipe-tendencia--alta { color: #16a34a; }
.pipe-tendencia--baixa { color: #dc2626; }
.pipe-tendencia--neutro { color: var(--t3); }

/* ── Corpo do card ── */
.pipe-card-body { padding: .6rem .75rem; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pipe-card-ref { font-size: 15px; font-weight: 700; color: var(--t1); text-align: center; letter-spacing: .3px; }
.pipe-card-desc { font-size: 11px; color: var(--t2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-card-estagio-wrap { display: flex; justify-content: center; margin-bottom: 4px; }

/* ── Tabela de cores ── */
.pipe-cor-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pipe-cor-table th { font-size: 10px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: .4px; padding: 2px 4px; border-bottom: 1px solid var(--bdr); text-align: left; }
.pipe-cor-table th:last-child, .pipe-cor-table td:last-child { text-align: right; }
.pipe-cor-table td { padding: 3px 4px; color: var(--t1); border-bottom: 1px solid var(--bdr2); }
.pipe-cor-table tr:last-child td { border-bottom: none; }
.pipe-cor-table-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; margin-right: 4px; flex-shrink: 0; }
.pipe-cor-table-nome { color: var(--t2); }
.pipe-cor-table-num { font-weight: 600; color: var(--t1); }

/* ── Badge de estágio ── */
.pipe-estagio { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .4px; width: fit-content; }
.pipe-estagio--ruptura { background: #fee2e2; color: #dc2626; }
.pipe-estagio--atencao { background: #fef3c7; color: #d97706; }
.pipe-estagio--saudavel { background: #dcfce7; color: #16a34a; }
.pipe-estagio--transito { background: #dbeafe; color: #1d4ed8; }
.pipe-estagio--recebido { background: #ede9fe; color: #7c3aed; }

/* ── Métricas no card ── */
.pipe-card-metricas { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 2px; }
.pipe-metrica { background: var(--muted); border-radius: var(--r); padding: 5px 6px; text-align: center; }
.pipe-metrica-val { font-size: 14px; font-weight: 700; color: var(--t1); }
.pipe-metrica-lbl { font-size: 9px; color: var(--t2); text-transform: uppercase; letter-spacing: .4px; }

/* ── Barra de cobertura ── */
.pipe-cobertura-bar { height: 8px; border-radius: 4px; background: var(--muted); margin-top: 6px; overflow: hidden; }
.pipe-cobertura-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.pipe-cobertura-fill--ok { background: #16a34a; }
.pipe-cobertura-fill--atencao { background: #d97706; }
.pipe-cobertura-fill--critico { background: #dc2626; }

/* ── Ruptura iminente consolidada ── */
.pipe-ruptura-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.pipe-ruptura-card { background: #fff5f5; border: 1.5px solid #dc2626; border-radius: var(--rl); padding: .75rem; cursor: pointer; transition: transform .15s; }
.pipe-ruptura-card:hover { transform: translateY(-1px); }
.pipe-ruptura-ref { font-size: 12px; font-weight: 700; color: #dc2626; margin-bottom: 2px; }
.pipe-ruptura-cor { font-size: 11px; color: var(--t2); margin-bottom: 4px; }
.pipe-ruptura-zero { font-size: 20px; font-weight: 800; color: #dc2626; }
.pipe-ruptura-vmd { font-size: 10px; color: #dc2626; margin-top: 2px; }

/* ── Gráfico comparativo entre modelos ── */
.pipe-comparativo-wrap { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: 1.25rem; box-shadow: var(--sh); margin-bottom: 1.25rem; }
.pipe-bars { display: flex; align-items: flex-end; gap: 12px; height: 120px; padding-top: 8px; }
.pipe-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.pipe-bar-val { font-size: 11px; font-weight: 700; color: var(--t1); }
.pipe-bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--marca-azul); min-height: 4px; transition: height .3s; }
.pipe-bar--destaque { background: var(--marca-laranja); }
.pipe-bar-lbl { font-size: 10px; color: var(--t2); text-align: center; word-break: break-all; max-width: 100%; }

/* ── Estado vazio ── */
.pipe-empty { text-align: center; padding: 3rem 2rem; color: var(--t3); }
.pipe-empty-icon { font-size: 36px; margin-bottom: .75rem; }
.pipe-empty-msg { font-size: 14px; color: var(--t2); font-weight: 500; }

/* ── Gráficos consolidados ── */
.pipe-graf-wrap { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: 1.25rem; box-shadow: var(--sh); margin-bottom: 1.25rem; }

/* ── Bolinhas de cor no card pipeline ── */
.pipe-cor-dots { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px 2px; background: var(--card); }
.pipe-cor-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid rgba(0,0,0,.15); }
.pipe-cor-lista { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.pipe-cor-linha { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--t1); }
.pipe-cor-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t2); }
.pipe-cor-stat { font-size: 10px; font-weight: 600; color: var(--t2); background: var(--muted); padding: 1px 5px; border-radius: 4px; white-space: nowrap; }

/* ── Responsive ── */
@media (max-width: 900px) { .pipe-kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .dash-grid { grid-template-columns: 1fr; } .pipe-kpi-row { grid-template-columns: repeat(2, 1fr); } .pipe-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }

/* ── Ranking ── */
.rank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.rank-card { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--rl); padding: 1rem; box-shadow: var(--sh); }
.rank-card-title { font-size: 13px; font-weight: 700; color: var(--t1); margin-bottom: .75rem; }
.rank-item2 { display: flex; align-items: center; gap: 8px; margin-bottom: .35rem; }
.rank-item2-info { flex: 1; min-width: 0; }
.rank-item2-nome { font-size: 12px; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.rank-item2-val { font-size: 11px; color: var(--t2); margin-top: 2px; }
.rank-bar-wrap { height: 6px; background: var(--muted); border-radius: 3px; overflow: hidden; }
.rank-bar { height: 100%; background: var(--marca-azul); border-radius: 3px; transition: width .3s; }
.rank-pos { font-size: 11px; color: var(--t3); margin-right: 4px; }
.rank-foto { width: 44px; height: 44px; object-fit: contain; border-radius: var(--r); background: var(--card); flex-shrink: 0; padding: 2px; }
.rank-foto--vazia { display: flex; align-items: center; justify-content: center; font-size: 18px; }
.rank-cor-dot { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid rgba(0,0,0,.25); }
.rank-num-badge { min-width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--muted); border-radius: var(--r); font-size: 14px; font-weight: 700; color: var(--t1); flex-shrink: 0; }

/* ── Comparativo de períodos ── */
.hist-table { width: 100%; border-collapse: collapse; font-size: 12px; border: 1px solid var(--bdr); }
.hist-table th { padding: 7px 10px; text-align: center; font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--t3); border-bottom: 1px solid var(--bdr); border-right: 1px solid var(--bdr); background: var(--muted); }
.hist-table th:first-child { text-align: center; }
.hist-table th:last-child { border-right: none; }
.hist-table td { padding: 7px 10px; border-bottom: 1px solid var(--bdr); border-right: 1px solid var(--bdr); vertical-align: middle; text-align: center; }
.hist-table td:last-child { border-right: none; }
.hist-table tr:last-child td { border-bottom: none; }
.hist-table tr:hover td { background: rgba(0,0,0,.015); }
.comp-toggle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 1rem; }
.comp-sel { font-family: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--bdr); border-radius: var(--r); background: var(--inp); color: var(--t1); }
.comp-badge-a { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 4px; background: #1d4ed8; color: #fff; font-size: 10px; font-weight: 700; }
.comp-badge-b { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 4px; background: #d97706; color: #fff; font-size: 10px; font-weight: 700; }
.comp-titulo-row { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.comp-titulo-row .dash-title { margin-bottom: 0; }
.comp-titulo-row .comp-toggle { margin-bottom: 0; margin-left: auto; }
.comp-header-row { display: flex; gap: 0; align-items: flex-end; margin-bottom: .35rem; background: var(--muted); border-radius: var(--r); padding: .5rem .75rem; }
.comp-kpi-wrap { flex: 1; display: flex; flex-direction: column; gap: .25rem; }
.comp-kpi-wrap .comp-kpi-row { margin-bottom: 0; }
.comp-kpi-row { display: flex; gap: .25rem; flex-wrap: nowrap; margin-bottom: 0; align-items: stretch; }
.comp-resumo-lado { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; border-left: 1px solid var(--bdr); padding-left: .75rem; margin-left: .75rem; }
.comp-resumo-lado .hist-table { margin-bottom: 0; background: transparent; width: 100%; }
.comp-resumo-lado .hist-table th { background: transparent; }
.comp-toggle-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--t2); margin-bottom: .35rem; }
.comp-toggle-inline label { color: var(--t2); }
.comp-kpi-box { flex: 1; white-space: nowrap; background: var(--muted); border-radius: var(--r); padding: .35rem .5rem; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.comp-kpi-num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.comp-kpi-label { font-size: 11px; color: var(--t3); margin-top: 3px; white-space: nowrap; }
.comp-kpi-val--pos { color: #15803D; }
.comp-kpi-val--neg { color: #DC2626; }
.comp-kpi-val--neu { color: #64748B; }
.comp-cor-card { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--r); padding: .75rem; }
.comp-cor-header { font-size: 12px; font-weight: 700; color: var(--t1); margin-bottom: .5rem; display: flex; align-items: center; gap: 6px; }
.comp-cor-saldo { font-size: 11px; margin-left: auto; }
.comp-cor-grid { display: grid; gap: .75rem; margin-bottom: .75rem; }
.comp-cor-grid--2 { grid-template-columns: repeat(2, 1fr); }
.comp-cor-grid--3 { grid-template-columns: repeat(3, 1fr); }
.comp-resumo-table { margin-bottom: 0; }
.comp-resumo-table--cons { margin-top: .75rem; }
.comp-td-cor { font-weight: 600; text-align: center; }
.comp-td-delta-pos { color: #15803D; font-weight: 700; }
.comp-td-delta-neg { color: #DC2626; font-weight: 700; }
.comp-td-delta-neu { color: #64748B; font-weight: 700; }
.comp-td-pct-pos { color: #15803D; }
.comp-td-pct-neg { color: #DC2626; }
.comp-td-pct-neu { color: #64748B; }
.comp-td-saldo-zero { color: #DC2626; font-weight: 700; }
.comp-td-saldo-baixo { color: #d97706; font-weight: 600; }
.comp-td-saldo-ok { color: #15803D; font-weight: 600; }
.comp-td-ultv-zero { color: #DC2626; font-weight: 600; }
.comp-td-ultv { color: var(--t3); }
.comp-cor-delta { font-weight: 400; font-size: 11px; margin-left: 6px; }
.comp-cor-saldo-total { font-size: 11px; margin-left: auto; }
.comp-inner-table { font-size: 11px; }
