/* Painel ROI — Alquimia Ascensional / Imanto
   Fontes travadas pela identidade da Imanto: Space Grotesk (display) + Inter (texto).
   Categoricas validadas com o validador do dataviz nos dois modos. */

:root {
  --blue: #2D4BFF;
  --purple: #7B3FF2;
  --red: #FF3B6B;
  --grad: linear-gradient(96deg, #2D4BFF, #7B3FF2 52%, #FF3B6B);

  --surface: #fcfcfb;
  --card: #ffffff;
  --raise: #ffffff;
  --ink: #10122E;
  --muted: #5B5F86;
  --faint: #8A8FB5;
  --line: #E4E6F5;
  --grid: #EDEEF8;

  --s1: #2D4BFF;
  --s2: #FF3B6B;
  --s3: #7B3FF2;

  --pos: #1B7F5A;
  --neg: #C2334D;

  --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --r: 16px;
  --shadow: 0 1px 2px rgba(16,18,46,.04), 0 8px 24px -18px rgba(16,18,46,.35);
  --ease: cubic-bezier(.2,.7,.2,1);
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) { }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1a1a19; --card: #232326; --raise: #2A2A2E;
    --ink: #F2F3FA; --muted: #A8ADCE; --faint: #767B9E;
    --line: #33344A; --grid: #2B2C3F;
    --s1: #5B7BFF; --s2: #F25078; --s3: #A278F5;
    --pos: #4FC08D; --neg: #FF7A8F;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -18px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  --surface: #1a1a19; --card: #232326; --raise: #2A2A2E;
  --ink: #F2F3FA; --muted: #A8ADCE; --faint: #767B9E;
  --line: #33344A; --grid: #2B2C3F;
  --s1: #5B7BFF; --s2: #F25078; --s3: #A278F5;
  --pos: #4FC08D; --neg: #FF7A8F;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -18px rgba(0,0,0,.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--surface); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* atmosfera: dois campos de luz nos polos da marca, bem discretos */
.atmosfera {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(46% 34% at 88% -4%, color-mix(in oklab, var(--purple) 13%, transparent), transparent 68%),
    radial-gradient(42% 32% at 2% 4%, color-mix(in oklab, var(--blue) 11%, transparent), transparent 66%);
}
body > *:not(.atmosfera) { position: relative; z-index: 1; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

header { border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--card) 82%, transparent); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 30; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 13px; }
.brand .logo { height: 36px; width: auto; display: block; }
.brand .divider { width: 1px; height: 26px; background: var(--line); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -.025em; }
.brand-txt em { font-style: normal; }
.brand-txt small { font-size: 12px; color: var(--muted); letter-spacing: .01em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.controls { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 15px;
  transition: color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--s3); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .5; cursor: wait; }
a.icon-btn.sair { display: inline-grid; place-items: center; text-decoration: none; line-height: 1; }
a.icon-btn.sair:hover { color: var(--neg); border-color: var(--neg); }

.datas { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-bottom: 16px; padding-top: 2px; }
.datas-lbl { font-size: 12.5px; color: var(--faint); font-weight: 500; }
.datas.ativo { position: relative; }
.datas.ativo::before { content: ""; position: absolute; left: 24px; right: 24px; top: -6px; height: 2px; background: var(--grad); border-radius: 2px; }
.datas label { font-size: 13px; color: var(--muted); display: flex; gap: 7px; align-items: center; }
.datas input {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px;
}
.datas input:focus-visible { outline: 2px solid var(--s3); outline-offset: 1px; }
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 9px; padding: 8px 15px;
  background: var(--ink); color: var(--surface);
}
.btn.ghost { background: none; color: var(--muted); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { color: var(--ink); }
.hint { font-size: 12.5px; color: var(--neg); }

.avisos { display: grid; gap: 8px; margin-top: 22px; }
.aviso {
  border: 1px solid var(--line); border-left: 3px solid var(--s3);
  background: var(--card); border-radius: 10px; padding: 11px 15px;
  font-size: 13.5px; color: var(--muted); box-shadow: var(--shadow);
}

/* ---- cards ---- */
.cards { margin-top: 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow);
  animation: sobe .5s var(--ease) both;
}
.cards .card:nth-child(1) { animation-delay: .02s }
.cards .card:nth-child(2) { animation-delay: .06s }
.cards .card:nth-child(3) { animation-delay: .10s }
.cards .card:nth-child(4) { animation-delay: .14s }
.cards .card:nth-child(5) { animation-delay: .18s }
.cards .card:nth-child(6) { animation-delay: .22s }
.cards .card:nth-child(7) { animation-delay: .26s }
@keyframes sobe { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { .card { animation: none } }

.card .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.card .v { font-family: var(--display); font-size: 28px; font-weight: 600; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.card.hero {
  grid-column: span 2; position: relative; overflow: hidden;
  border-color: color-mix(in oklab, var(--s3) 28%, var(--line));
}
.card.hero::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--grad);
}
.card.hero .v { font-size: 46px; line-height: 1.02; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.delta { font-size: 12px; font-weight: 600; margin-left: 8px; vertical-align: 2px; }

.skeleton {
  height: 118px; border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--card) 25%, var(--grid) 50%, var(--card) 75%);
  background-size: 240% 100%; animation: brilho 1.3s infinite linear;
}
@keyframes brilho { from { background-position: 140% 0 } to { background-position: -40% 0 } }

/* ---- blocos ---- */
.bloco { margin-top: 38px; }
.bloco-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
h2 { font-family: var(--display); font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.sub { font-size: 12.5px; color: var(--faint); }
.bloco-tools { display: flex; gap: 14px; align-items: baseline; }
.link-btn { background: none; border: 0; font: inherit; font-size: 12.5px; color: var(--s3); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.chart-wrap { position: relative; height: 310px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

.tablebox { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.tablebox.flat { box-shadow: none; border: 0; margin-top: 16px; border-top: 1px solid var(--line); border-radius: 0; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 580px; }
th, td { padding: 11px 15px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 220px; font-variant-numeric: normal; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklab, var(--s3) 4%, transparent); }
td .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }

footer { margin-top: 46px; padding: 20px 0 60px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--faint); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.fonte-ok { color: var(--pos); font-weight: 600; }
.fonte-erro { color: var(--neg); font-weight: 600; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 50; opacity: 0; transition: opacity .12s;
  background: var(--raise); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 12.5px; box-shadow: 0 12px 32px -14px rgba(16,18,46,.5);
  min-width: 190px;
}
.tooltip b { font-family: var(--display); display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tooltip .row { display: flex; justify-content: space-between; gap: 20px; }
.tooltip .row span:last-child { font-variant-numeric: tabular-nums; }

.empty { padding: 34px; text-align: center; color: var(--faint); font-size: 14px; }

@media (max-width: 640px) {
  .head { padding: 14px 20px; }
  .wrap { padding: 0 20px; }
  .card.hero { grid-column: 1 / -1; }
  .card.hero .v { font-size: 38px; }
  .chart-wrap { height: 250px; }
  .brand .divider { display: none; }
  .brand .logo { height: 30px; }
  .controls { width: 100%; justify-content: space-between; }
}
