/* Plano de Compra — escala de espaçamento em múltiplos de 4 (4/8/12/16/24/32).
   Quatro níveis tipográficos: título, seção, corpo, auxiliar. Cor é semântica:
   verde = retorno bom, âmbar = atenção, vermelho = problema, cinza = neutro. */
.pc-page {
  --pc-ink:    #24313b;
  --pc-muted:  #6b747b;
  --pc-line:   #e2e7eb;
  --pc-good:   #147a4b;
  --pc-warn:   #9b6414;
  --pc-danger: #bd3d3a;
  --pc-info:   #2f6f9f;
  --pc-surface:#fff;
  color: var(--pc-ink);
}

/* ── Cabeçalho ── */
.pc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.pc-eyebrow { color: #a23b36; font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.pc-head h2 { margin: 4px 0 4px; font-size: 1.6rem; font-weight: 750; }
.pc-head p { margin: 0; color: var(--pc-muted); font-size: .88rem; max-width: 60ch; }
.pc-fresh { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--pc-line);
            border-radius: 8px; background: #f8fafb; color: var(--pc-muted); font-size: .74rem; white-space: nowrap; }
.pc-fresh i { color: var(--pc-info); font-size: 1rem; }
.pc-fresh strong { display: block; color: var(--pc-ink); font-size: .78rem; font-weight: 650; }

/* ── Parâmetros ── */
.pc-params { background: var(--pc-surface); border: 1px solid var(--pc-line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.pc-params-grid { display: grid; grid-template-columns: 180px 128px 1fr 156px 186px auto; gap: 16px; align-items: end; }
.pc-field label { display: block; font-size: .72rem; font-weight: 650; color: #555; margin-bottom: 4px; }
.pc-field label small { font-weight: 400; color: #97a0a7; }
.pc-field input[type=text], .pc-field select {
  width: 100%; padding: 7px 10px; border: 1px solid #ced4da; border-radius: 6px; font-size: .86rem; background: #fff; color: var(--pc-ink);
}
.pc-field input[type=text]:focus, .pc-field select:focus,
.pc-slider input:focus-visible { outline: 2px solid var(--pc-info); outline-offset: 1px; }
.pc-money input { font-weight: 700; font-size: 1rem !important; text-align: right; }
.pc-slider { display: flex; flex-direction: column; }
.pc-slider input[type=range] { width: 100%; accent-color: var(--pc-info); }
.pc-slider-legend { display: flex; justify-content: space-between; font-size: .68rem; color: #97a0a7; margin-top: 2px; }
.pc-slider-legend b { color: var(--pc-info); font-weight: 700; }
.pc-run { padding: 8px 20px; font-weight: 650; white-space: nowrap; }

.pc-more { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px;
           padding-top: 16px; border-top: 1px dashed var(--pc-line); }
.pc-more.pc-open { display: grid; }
.pc-more select[multiple] { min-height: 108px; }
.pc-params-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pc-linkbtn { background: none; border: none; padding: 0; color: var(--pc-info); font-size: .78rem; font-weight: 650; cursor: pointer; }
.pc-linkbtn:hover { text-decoration: underline; }
.pc-chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2f5; color: #52616d;
           border: 1px solid #dde4e9; border-radius: 999px; padding: 3px 8px; font-size: .72rem; }
.pc-chip button { background: none; border: none; padding: 0; line-height: 1; color: #8a949c; cursor: pointer; font-size: .9rem; }
.pc-chip button:hover { color: var(--pc-danger); }

/* ── KPIs ── */
.pc-kpis:empty { display: none; }
.pc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; margin-bottom: 24px; }
.pc-kpi { position: relative; background: var(--pc-surface); border: 1px solid var(--pc-line); border-radius: 10px; padding: 12px 12px 12px 16px; overflow: hidden; }
.pc-kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #adb5bd; }
.pc-kpi.good::before   { background: var(--pc-good); }
.pc-kpi.warn::before   { background: var(--pc-warn); }
.pc-kpi.danger::before { background: var(--pc-danger); }
.pc-kpi.neutral::before{ background: var(--pc-info); }
.pc-kpi span   { display: block; color: var(--pc-muted); font-size: .72rem; }
.pc-kpi strong { display: block; margin: 4px 0; font-size: 1.22rem; font-weight: 700; line-height: 1.2; }
.pc-kpi small  { display: block; color: #8a949c; font-size: .68rem; line-height: 1.35; }

/* ── Blocos ── */
.pc-block { background: var(--pc-surface); border: 1px solid var(--pc-line); border-radius: 10px; margin-bottom: 24px; overflow: hidden; }
.pc-block-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid #eef1f3; }
.pc-block-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.pc-block-head p  { margin: 2px 0 0; color: var(--pc-muted); font-size: .76rem; }
.pc-block-head .pc-actions { display: flex; gap: 8px; align-items: center; }

/* ── Origem (fabricar × comprar) ── */
.pc-origem { display: flex; gap: 24px; padding: 16px; align-items: center; flex-wrap: wrap; }
.pc-origem-bar { flex: 1; min-width: 240px; display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: #eef1f3; }
.pc-origem-bar i { display: block; height: 100%; }
.pc-origem-bar i.fab { background: var(--pc-info); }
.pc-origem-bar i.com { background: #7aa5c4; }
.pc-origem-item { display: flex; flex-direction: column; min-width: 150px; }
.pc-origem-item span { font-size: .72rem; color: var(--pc-muted); display: flex; align-items: center; gap: 6px; }
.pc-origem-item span::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--pc-info); }
.pc-origem-item.com span::before { background: #7aa5c4; }
.pc-origem-item strong { font-size: 1.05rem; font-weight: 700; }
.pc-origem-item small { color: #8a949c; font-size: .68rem; }

/* ── Mix ── */
.pc-mix { padding: 8px 16px 16px; }
.pc-mix-row { display: grid; grid-template-columns: 140px 1fr 96px; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid #f4f6f7; }
.pc-mix-row:last-child { border-bottom: none; }
.pc-mix-cat { font-size: .8rem; font-weight: 600; }
.pc-mix-cat small { display: block; color: #97a0a7; font-weight: 400; font-size: .68rem; }
.pc-mix-bars { display: flex; flex-direction: column; gap: 3px; }
.pc-mix-track { height: 9px; background: #f4f6f8; border-radius: 3px; overflow: hidden; }
.pc-mix-track i { display: block; height: 100%; border-radius: 3px; }
.pc-mix-track.plano i { background: var(--pc-info); }
.pc-mix-track.venda i { background: #a9b4bd; }
.pc-mix-val { text-align: right; font-size: .76rem; font-variant-numeric: tabular-nums; }
.pc-mix-val b { display: block; color: var(--pc-info); }
.pc-mix-val span { color: #97a0a7; font-size: .7rem; }
.pc-mix-legend { display: flex; gap: 16px; padding: 0 16px 12px; font-size: .7rem; color: var(--pc-muted); }
.pc-mix-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.pc-mix-legend i.plano { background: var(--pc-info); }
.pc-mix-legend i.venda { background: #a9b4bd; }

/* ── Lote mínimo ── */
.pc-lote { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; padding: 16px; }
.pc-lote-item { border: 1px solid var(--pc-line); border-left: 3px solid var(--pc-good); border-radius: 8px; padding: 8px 12px; }
.pc-lote-item.incerto { border-left-color: var(--pc-warn); background: #fdfaf4; }
.pc-lote-item strong { display: block; font-size: 1rem; }
.pc-lote-item span   { display: block; font-size: .74rem; color: var(--pc-muted); }
.pc-lote-item small  { display: block; font-size: .68rem; color: #97a0a7; margin-top: 2px; }
.pc-lote-notas { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.pc-lote-notas > div { display: flex; gap: 8px; align-items: flex-start; font-size: .78rem; }
.pc-lote-notas i { color: var(--pc-info); font-size: 1rem; line-height: 1.3; }
.pc-lote-notas span { display: block; color: var(--pc-muted); font-size: .74rem; line-height: 1.45; }
.pc-lote-alerta { display: flex; gap: 8px; align-items: flex-start; margin: 0 16px 16px;
                  padding: 12px; border: 1px dashed #d5a452; background: #fffaf0; border-radius: 8px; }
.pc-lote-alerta i { color: var(--pc-warn); font-size: 1.05rem; }
.pc-lote-alerta strong { display: block; font-size: .84rem; color: #7a5713; }
.pc-lote-alerta span { display: block; font-size: .74rem; color: #806d4b; line-height: 1.45; margin-top: 2px; }

/* ── Tabela ── */
.pc-table-wrap { max-height: 62vh; overflow: auto; }
.pc-table { width: 100%; border-collapse: collapse; font-size: .8rem; min-width: 1080px; }
.pc-table thead th { position: sticky; top: 0; z-index: 2; background: #f7f9fa; border-bottom: 1px solid var(--pc-line);
                     padding: 8px 12px; text-align: left; font-size: .7rem; font-weight: 700; color: #5a656d;
                     text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.pc-table th.pc-sort { cursor: pointer; user-select: none; }
.pc-table th.pc-sort:hover { color: var(--pc-ink); }
.pc-table tbody tr { border-bottom: 1px solid #f4f6f7; }
.pc-table tbody tr:hover { background: #f8fbfc; }
.pc-table tbody td { padding: 8px 12px; vertical-align: middle; }
.pc-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-prod { min-width: 300px; max-width: 420px; }
.pc-prod strong { display: block; font-weight: 600; line-height: 1.25; }
.pc-prod small  { display: block; color: #8a949c; font-size: .68rem; margin-top: 2px; }
.pc-table td.pc-qtd { font-weight: 700; color: var(--pc-info); }
.pc-table td.pc-money-strong { font-weight: 650; }
.pc-neg { color: var(--pc-danger); }

.pc-badge { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.pc-badge.fab { background: #e7f0f7; color: #1d5c86; }
.pc-badge.com { background: #f0ece6; color: #7a5c2e; }
.pc-badge.ruptura { background: #fbeaea; color: var(--pc-danger); }
.pc-badge.baixa   { background: #fcf3e3; color: var(--pc-warn); }
.pc-badge.ok      { background: #eaf5ef; color: var(--pc-good); }
.pc-cover-after { display: block; color: #8a949c; font-size: .66rem; margin-top: 2px; }
.pc-parcial { color: var(--pc-warn); font-size: .66rem; display: block; margin-top: 2px; }

/* ── Qualidade + procedência ── */
.pc-quality { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 16px; }
.pc-quality-item { border: 1px solid var(--pc-line); border-left: 3px solid #c6ced4; border-radius: 8px; padding: 8px 12px; }
.pc-quality-item.critico { border-left-color: var(--pc-danger); background: #fdf7f7; }
.pc-quality-item strong { display: block; font-size: 1rem; }
.pc-quality-item span   { display: block; font-size: .74rem; color: var(--pc-muted); }
.pc-quality-item small  { display: block; font-size: .68rem; color: #97a0a7; margin-top: 2px; }

.pc-method { display: grid; gap: 8px; padding: 16px; background: #f8fafb; border-top: 1px solid #eef1f3;
             font-size: .76rem; color: #55636d; line-height: 1.5; }
.pc-method b { color: var(--pc-ink); }

/* ── Estados ── */
.pc-empty { padding: 32px 16px; text-align: center; color: var(--pc-muted); }
.pc-empty i { font-size: 1.8rem; color: #c6ced4; display: block; margin-bottom: 8px; }
.pc-empty strong { display: block; font-size: .95rem; color: var(--pc-ink); margin-bottom: 4px; }
.pc-empty p { margin: 0 auto; max-width: 46ch; font-size: .82rem; }
.pc-error { margin: 16px; border: 1px solid #f0cfcf; border-left: 3px solid var(--pc-danger); background: #fdf7f7;
            border-radius: 8px; padding: 12px 16px; color: #7d3230; }
.pc-error strong { display: block; margin-bottom: 4px; }
.pc-error p { margin: 0; font-size: .82rem; color: #8b5250; }
.pc-recarregando { opacity: .45; transition: opacity .12s; pointer-events: none; }

.pc-skeleton { padding: 16px; }
.pc-skeleton i { display: block; height: 14px; border-radius: 4px; margin-bottom: 10px;
                 background: linear-gradient(90deg, #eef1f3 25%, #f6f8f9 37%, #eef1f3 63%);
                 background-size: 400% 100%; animation: pc-shine 1.2s ease infinite; }
.pc-skeleton i:nth-child(2n) { width: 82%; }
.pc-skeleton i:nth-child(3n) { width: 66%; }
@keyframes pc-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.pc-kpis.pc-skel .pc-kpi { height: 84px; background: linear-gradient(90deg, #eef1f3 25%, #f6f8f9 37%, #eef1f3 63%);
                           background-size: 400% 100%; animation: pc-shine 1.2s ease infinite; border-color: transparent; }
.pc-kpis.pc-skel .pc-kpi::before { display: none; }

/* ── Responsivo ── */
@media (max-width: 1100px) {
  .pc-params-grid { grid-template-columns: 1fr 1fr; }
  .pc-params-grid .pc-run { grid-column: 1 / -1; width: 100%; }
  .pc-more { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .pc-head { flex-direction: column; align-items: flex-start; }
  .pc-fresh { width: 100%; }
  .pc-kpis { grid-template-columns: 1fr 1fr; }
  .pc-params-grid, .pc-more { grid-template-columns: 1fr; }
  .pc-mix-row { grid-template-columns: 104px 1fr 76px; }
  .pc-block-head { flex-direction: column; align-items: flex-start; }
}
