:root {

  --paper: #f3eee4;

  --paper-2: #ebe4d6;

  --ink: #1c241d;

  --ink-soft: #4a564c;

  --line: #d5cdb8;

  --forest: #1f4a38;

  --forest-2: #2e6a50;

  --copper: #b45a2e;

  --gold: #c9a227;

  --ok: #2f6f4e;

  --below: #9c2f24;

  --above: #8a5a12;

  --white: #fffcf6;

  --shadow: 0 12px 32px rgba(28, 36, 29, 0.08);

  --radius: 14px;

}



* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {

  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;

  color: var(--ink);

  background:

    radial-gradient(1200px 500px at 10% -10%, #e7f0e4 0%, transparent 50%),

    var(--paper);

}



.app {

  max-width: 1440px;

  margin: 0 auto;

  padding: 28px 28px 64px;

}



.topbar {

  display: grid;

  grid-template-columns: 1fr auto auto;

  gap: 24px;

  align-items: center;

  padding-bottom: 20px;

  border-bottom: 1px solid var(--line);

}


.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.brand-logo {
  height: 56px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
  flex-shrink: 0;
}
.brand-copy { min-width: 0; }

.btn-recalc {
  margin-top: 16px;
  width: 100%;
  border: 1px solid var(--forest);
  background: var(--white);
  color: var(--forest);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.btn-recalc:hover { background: #eef5f0; }
.btn-recalc.pending {
  background: var(--forest);
  color: #f6f3ea;
  border-color: var(--forest);
}

.eyebrow {

  margin: 0 0 4px;

  letter-spacing: 0.16em;

  text-transform: uppercase;

  font-size: 11px;

  color: var(--ink-soft);

}

h1 {

  font-family: Fraunces, Georgia, serif;

  font-weight: 640;

  font-size: 34px;

  margin: 0;

  letter-spacing: -0.03em;

}

.period { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; }



.cluster-switch { display: flex; gap: 8px; }
.period-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 4px 0 2px; }

.chip, .ghost, .primary, kbd {

  font-family: inherit;

}

.chip, .ghost, .primary {

  border: 1px solid var(--line);

  background: var(--white);

  color: var(--ink);

  border-radius: 999px;

  padding: 10px 16px;

  cursor: pointer;

  font-weight: 500;

}

.chip.active {

  background: var(--forest);

  color: #f6f3ea;

  border-color: var(--forest);

}

.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#btnSave.pending {
  background: var(--forest);
  color: #f6f3ea;
  border-color: var(--forest);
}

.primary {

  background: var(--ink);

  color: var(--paper);

  border-color: var(--ink);

}

.primary kbd {

  margin-left: 8px;

  font-size: 10px;

  border: 1px solid rgba(243, 238, 228, 0.35);

  padding: 2px 6px;

  border-radius: 4px;

}

.ghost:hover, .chip:hover, .primary:hover { transform: translateY(-1px); }



.lojas-line {

  margin-top: 16px;

  font-size: 13px;

  color: var(--ink-soft);

}

.lojas-line strong { color: var(--ink); }



.kpis {

  display: grid;

  grid-template-columns: repeat(3, 1fr);

  gap: 12px;

  margin-top: 18px;

}

.kpi {

  background: var(--white);

  border: 1px solid var(--line);

  border-radius: var(--radius);

  padding: 14px 16px 16px;

  animation: rise 420ms ease both;

}

.kpi .lbl {

  font-size: 11px;

  text-transform: uppercase;

  letter-spacing: 0.08em;

  color: var(--ink-soft);

}

.kpi .val {

  font-family: Fraunces, Georgia, serif;

  font-size: 26px;

  margin-top: 8px;

  letter-spacing: -0.03em;

}

.kpi .sub { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }

.kpi.alert { border-color: #e3c2b8; }

.kpi.good { border-color: #c5d9cc; }

.kpi.perda {
  background: #fbf4f2;
  border-color: #efd8d4;
}

.kpi.perda .val {
  color: #a33d3d;
  animation: perda-pulso 2.6s ease-in-out infinite;
}

@keyframes perda-pulso {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px) scale(1.035); }
}

@media (prefers-reduced-motion: reduce) {
  .kpi.perda .val { animation: none; }
}

.neg { color: var(--below); }

.pos { color: var(--ok); }



.formula-strip {

  margin-top: 16px;

  background: var(--forest);

  color: #f4efe4;

  border-radius: var(--radius);

  padding: 14px 18px;

  display: flex;

  flex-wrap: wrap;

  gap: 10px 18px;

  align-items: center;

  font-size: 14px;

}

.formula-strip b { font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 640; }

.formula-strip .eq { opacity: 0.7; }



.workspace {

  display: grid;

  grid-template-columns: 300px 1fr;

  gap: 18px;

  margin-top: 18px;

  align-items: start;

}

.sim-panel, .memory, .table-wrap {

  background: var(--white);

  border: 1px solid var(--line);

  border-radius: var(--radius);

}

.sim-panel { padding: 18px; position: sticky; top: 16px; }

.sim-panel h2, .memory h2 {

  font-family: Fraunces, Georgia, serif;

  font-size: 22px;

  margin: 0 0 8px;

}

.hint { font-size: 12px; color: var(--ink-soft); line-height: 1.45; margin: 0 0 16px; }

.sim-panel label {

  display: block;

  font-size: 12px;

  font-weight: 600;

  margin: 14px 0 6px;

}

.slide-row { display: grid; grid-template-columns: 1fr 72px 16px; gap: 8px; align-items: center; }

input[type="range"] { width: 100%; accent-color: var(--forest); }

input[type="number"], input[type="search"], select {

  border: 1px solid var(--line);

  border-radius: 8px;

  padding: 7px 8px;

  font: inherit;

  background: var(--paper);

}

.bo-note { font-size: 11px; color: var(--ink-soft); margin-top: 8px; }

.legend { display: grid; gap: 6px; margin-top: 18px; font-size: 12px; color: var(--ink-soft); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.dot.below { background: var(--below); }

.dot.ok { background: var(--ok); }

.dot.above { background: var(--gold); }



.toolbar {

  display: flex;

  justify-content: space-between;

  gap: 12px;

  align-items: center;

  margin-bottom: 10px;

}

.crumbs { font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; }

.crumbs button {

  border: 0;

  background: transparent;

  color: var(--forest-2);

  cursor: pointer;

  padding: 0;

  font: inherit;

}

.crumbs span.sep { color: var(--line); }

.tools { display: flex; gap: 8px; }

#busca { min-width: 240px; }



.table-wrap { overflow: auto; max-height: 62vh; }

.grid { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 13px; }

.grid th {

  position: sticky; top: 0;

  background: #f7f2e8;

  text-align: left;

  font-size: 11px;

  letter-spacing: 0.06em;

  text-transform: uppercase;

  color: var(--ink-soft);

  padding: 10px 12px;

  border-bottom: 1px solid var(--line);

}

.grid td { padding: 9px 12px; border-bottom: 1px solid #eee6d6; }

.grid tbody tr { cursor: pointer; }

.grid tbody tr:hover { background: #f7f3ea; }

.grid tbody tr.selected { background: #e7f0e4; }

.grid tbody tr.subtotal { background: #efe6d4; font-weight: 600; }

.grid tbody tr.subtotal td { border-bottom-color: #e2d5bc; }

.grid td.nome-filho { padding-left: 28px; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.bar {

  height: 4px;

  background: var(--paper-2);

  border-radius: 4px;

  margin-top: 6px;

  overflow: hidden;

}

.bar > i { display: block; height: 100%; background: var(--forest-2); }

.name { font-weight: 500; }

.name small { display: block; color: var(--ink-soft); font-weight: 400; margin-top: 2px; }

.cell-edit {

  width: 72px;

  text-align: right;

  padding: 4px 6px;

  border-radius: 6px;

  border: 1px solid transparent;

  background: #f3eee4;

}

.cell-edit:focus { outline: 2px solid var(--forest-2); border-color: transparent; }

.badge {

  display: inline-block;

  min-width: 58px;

  text-align: right;

  padding: 2px 6px;

  border-radius: 6px;

}

.badge.below { background: #f4d7d2; color: var(--below); }

.badge.ok { background: #dceadf; color: var(--ok); }

.badge.above { background: #f3e6c2; color: var(--above); }

.table-foot { font-size: 12px; color: var(--ink-soft); margin: 8px 2px 0; }



.memory { margin-top: 18px; padding: 18px 20px 22px; }

.memory-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; }

.hidden { display: none !important; }

.waterfall { display: grid; gap: 8px; }

.wf-row { display: grid; grid-template-columns: 140px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }

.wf-bar { height: 18px; background: var(--paper-2); border-radius: 4px; overflow: hidden; }

.wf-bar i { display: block; height: 100%; }

.wf-bar i.perda { background: #9c2f24; }

.wf-bar i.desp { background: #3d6e8c; }

.wf-bar i.bo { background: #8a5a12; }

.wf-bar i.lucro { background: #2f6f4e; }

.wf-total {

  margin-top: 10px;

  padding-top: 10px;

  border-top: 1px solid var(--line);

  display: flex;

  justify-content: space-between;

  font-family: Fraunces, Georgia, serif;

  font-size: 22px;

}

.mem-copy { font-size: 13px; line-height: 1.55; color: var(--ink-soft); }

.mem-copy strong { color: var(--ink); }



.toast {

  position: fixed;

  right: 24px;

  bottom: 24px;

  background: var(--ink);

  color: var(--paper);

  padding: 12px 16px;

  border-radius: 10px;

  box-shadow: var(--shadow);

}



@keyframes rise {

  from { transform: translateY(8px); }

  to { transform: none; }

}



@media (max-width: 1100px) {

  .kpis { grid-template-columns: repeat(3, 1fr); }

  .workspace { grid-template-columns: 1fr; }

  .sim-panel { position: static; }

  .topbar { grid-template-columns: 1fr; }

  .memory-body { grid-template-columns: 1fr; }

}

@media print {

  .sim-panel, .top-actions, #busca { display: none !important; }

  .workspace { grid-template-columns: 1fr; }

  body { background: white; }

}

.check { display:flex; gap:8px; align-items:flex-start; font-size:12px; font-weight:600; margin-top:16px; line-height:1.35; }
.check input { margin-top:2px; }
.papel { display:inline-block; font-size:11px; font-weight:600; letter-spacing:.04em; text-transform:uppercase; padding:3px 7px; border-radius:999px; }
.papel.fluxo { background:#f4e0d4; color:#9c4a24; }
.papel.lucro { background:#dceadf; color:#2f6f4e; }
.papel.equilibrio { background:#eee9dc; color:#5a5648; }
.papel.misto { background:#e7eef4; color:#3d6e8c; }
.dot.fluxo { background:#b45a2e; }
.dot.lucro { background:#2f6f4e; }
.dot.piso { background:#6b5a2e; }
.papel.trafego { background:#e7eef4; color:#2a5d7c; }
.dot.trafego { background:#2a5d7c; }
.check + .check { margin-top:10px; }
