/* Biblioteca de componentes PCO — reproduz a linguagem visual de Rafatella_PCO.html
 * (contrato aprovado pelo Diretor/CFO). Depende de pco/tokens.css e pco/fonts.css.
 * Nenhum número/fórmula do protótipo é reproduzido aqui — só layout/interação. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Cartões / KPIs / tags ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
}
.card-h {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-h h3 { font-size: 14px; font-weight: 700; letter-spacing: -.012em; color: var(--ink); }
.card-h .note { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-b { padding: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 17px 18px 16px; }
.kpi .lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: -.005em; }
.kpi .val { font-size: 27px; font-weight: 800; letter-spacing: -.032em; margin-top: 10px; color: var(--ink); line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 9px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 2.5px 8px; border-radius: 20px; letter-spacing: -.005em;
}
.tag.pos { background: var(--pos-sf); color: var(--pos); }
.tag.neg { background: var(--neg-sf); color: var(--neg); }
.tag.neu { background: var(--surface-3); color: var(--muted); }
.tag.brand { background: var(--brand-sf); color: var(--brand-dp); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.mb { margin-bottom: 16px; }

/* ---------- Página ---------- */

.page { padding: 26px 28px 64px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.028em; color: var(--ink); line-height: 1.2; }
.page-head .desc { color: var(--muted); font-size: 13.5px; margin-top: 6px; max-width: 64ch; line-height: 1.55; }

/* ---------- Botões / campos ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px;
  border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  transition: .15s; letter-spacing: -.005em;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(241, 103, 34, .3); }
.btn-primary:hover { background: var(--brand-dp); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.btn-ghost:hover { border-color: var(--muted-2); background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.err { background: var(--neg-sf); border: 1px solid #F3CFCF; color: #A93232; padding: 10px 12px; border-radius: var(--r-sm); font-size: 12.5px; margin-bottom: 14px; }
.note-box { padding: 12px 14px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.note-box.ok { background: var(--pos-sf); border-color: #CDEBDD; color: #0E6B48; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); font-size: 14px; transition: .15s;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-sf); outline: none; }

/* ---------- Tabela ---------- */

.tbl-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.t th, table.t td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.t th {
  font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line-2); letter-spacing: -.005em;
}
table.t th.l, table.t td.l { text-align: left; }
table.t th.ct, table.t td.ct { text-align: center; }
table.t td.l { white-space: normal; }
table.t tbody tr:last-child td { border-bottom: none; }
.stick { position: sticky; left: 0; z-index: 3; background: var(--surface); }
table.t th.stick { z-index: 4; background: var(--surface-2); }
table.t tbody tr:hover td, table.t tbody tr:hover td.stick { background: var(--surface-2); }
tr.sub td { font-weight: 700; color: var(--ink); background: var(--surface-3) !important; }
tr.sub td.stick { background: var(--surface-3) !important; }
tr.tot td { font-weight: 700; background: var(--nav) !important; color: #fff; border-color: var(--nav); }
tr.tot td.stick { background: var(--nav) !important; color: #fff; }
tr.lvl2 td.l { padding-left: 30px; color: var(--muted); }
tr.lvl3 td.l { padding-left: 50px; color: var(--muted); }
tr.lvl4 td.l { padding-left: 70px; color: var(--muted-2); font-size: 12.5px; }
.n-neg { color: var(--neg); }
.n-pos { color: var(--pos); }
.n-zero { color: var(--muted-2); }
.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.03em; }
.cc-pill { font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); padding: 2px 6px; border-radius: 5px; color: var(--muted); margin-right: 7px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Chip / switch ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--line-2);
  border-radius: 20px; font-size: 11.5px; background: var(--surface); color: var(--muted); font-weight: 500; transition: .14s;
}
.chip:hover { border-color: var(--muted-2); }
.chip.on { background: var(--nav); border-color: var(--nav); color: #fff; font-weight: 600; }

.switch { position: relative; width: 36px; height: 20px; background: var(--line-2); border-radius: 20px; transition: .15s; flex: 0 0 36px; display: inline-block; }
.switch.on { background: var(--pos); }
.switch i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .15s; }
.switch.on i { left: 18px; }

/* ---------- Modal ---------- */

.modal-bg { position: fixed; inset: 0; background: rgba(27, 34, 48, .55); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: center; padding: 22px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 580px; max-height: 88vh; overflow: auto; box-shadow: var(--sh-lg); }
.modal-h { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h3 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.modal-b { padding: 22px 24px; }
.modal-f { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

/* ---------- Dropzone (Repositório de Dados) ---------- */

.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 40px 26px; text-align: center; cursor: pointer; transition: .16s; background: var(--surface-2); }
.dropzone:hover, .dropzone.ativa { border-color: var(--brand); background: var(--brand-sf); }
.dropzone h4 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 12px 0 6px; }
.dropzone p { font-size: 13px; color: var(--muted); max-width: 54ch; margin: 0 auto; line-height: 1.65; }

/* ---------- Toggle segmentado (Só diferenças / Tudo) ---------- */

.actions-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.feedback { min-height: 18px; margin-bottom: 10px; font-size: 12.5px; color: var(--pos); }
.feedback.err { color: var(--neg); }
.feedback:empty { margin-bottom: 0; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; max-height: 160px; overflow: auto; padding: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.seg button { padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); }
.seg button.on { background: var(--nav); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
