/* Prisma — estilos */
:root, [data-theme=light] {
  --bg: #f5f5fa; --surface: #ffffff; --surface2: #f0f0f7; --line: #e3e3ee; --ink: #1c1b2e; --ink2: #4b4a63; --muted: #74738a;
  --accent: #5b47d6; --accent-ink: #ffffff; --accent-soft: #ecebfb; --danger: #d03b3b;
  --grid: #ececf2; --axis: #c9c9d6; --other: #a9a8b8;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --shadow: 0 10px 30px rgba(28, 27, 46, .14);
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #0f1020; --surface: #181a2e; --surface2: #21243c; --line: #2e3150; --ink: #f1f0fa; --ink2: #c6c5d8; --muted: #9897ae;
  --accent: #9d8cf5; --accent-ink: #14122b; --accent-soft: #2a2750; --danger: #f07a7a;
  --grid: #262943; --axis: #3a3d5c; --other: #6b6a80;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root { font: 14px/1.5 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); overflow: hidden; }
[data-theme] { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); font-size: 12.5px; }
.err { color: var(--danger); }
.grow { flex: 1; }
.center { text-align: center; }
.pad { padding: 8px 10px; }
.onlysm { display: none !important; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100%; }
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--surface2); filter: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.sm .ic { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn.big { padding: 12px 22px; font-size: 16px; border-radius: 14px; }
.icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon:hover { background: var(--surface2); color: var(--ink); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; max-width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon:focus-visible, .tab:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
textarea { width: 100%; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }

/* Barra lateral */
#sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand svg:first-child { width: 30px; height: 30px; }
.list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; }
.item { display: flex; flex-direction: column; gap: 1px; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.item:hover { background: var(--surface2); }
.item.on { background: var(--accent-soft); }
.ititle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imeta { font-size: 12px; color: var(--muted); }
.sidefoot { display: flex; flex-direction: column; border-top: 1px solid var(--line); padding-top: 8px; }
.link { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; color: var(--ink2); cursor: pointer; text-align: left; }
.link:hover { background: var(--surface2); }

/* Topo */
#topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.trow { display: flex; align-items: center; gap: 8px; }
#title { flex: 1; min-width: 0; border-color: transparent; background: transparent; font-size: 18px; font-weight: 700; padding: 4px 6px; text-overflow: ellipsis; }
#title:hover { border-color: var(--line); }
.focus { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 2px; }
.focus label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.focus select { padding: 4px 8px; font-size: 13px; max-width: 190px; }
#tabs { display: flex; gap: 2px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 10px 12px; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500; }
.tab .ic { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Área das visões */
#view { flex: 1; overflow: auto; padding: 20px 16px 48px; }
.view { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.view > * { flex: none; }
.view.v-graficos, .view.v-dados, .view.v-cartoes { max-width: 1240px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.card h3, .doc h3 { font-size: 15px; }
.chead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero { padding: 22px 24px; }
.heronum { font-size: clamp(40px, 9vw, 64px); font-weight: 700; line-height: 1.1; margin: 2px 0 8px; overflow-wrap: anywhere; }
.lead { font-size: 16px; color: var(--ink2); max-width: 62ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; }
.tl { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv { font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts { font-size: 12px; color: var(--ink2); }
.points { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.para { margin-top: 8px; color: var(--ink2); }
.msg { margin: 0; white-space: pre-wrap; font: inherit; background: var(--surface2); border-radius: 10px; padding: 12px 14px; }
.findings { list-style: none; margin: 8px 0 0; padding: 0; }
.findings li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.findings li:first-child { border-top: 0; }
.findings p { color: var(--ink2); font-size: 13.5px; }
.findings div { flex: 1; min-width: 0; }
.femo { font-size: 22px; line-height: 1.2; }
.fbig { font-weight: 600; white-space: nowrap; color: var(--ink2); }
.findings .warn b::after { content: ' · atenção'; color: var(--danger); font-weight: 500; font-size: 12px; }
.hint, .empty { color: var(--muted); text-align: center; }
.empty { padding: 60px 20px; }

.gtitle { font-size: clamp(22px, 5vw, 30px); line-height: 1.2; margin: 2px 0 8px; }
.tlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 10px; margin-top: 10px; }
.tcard { display: flex; flex-direction: column; gap: 3px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; cursor: pointer; min-width: 0; }
.tcard:hover { border-color: var(--accent); background: var(--surface2); }
.tcard.on { border-color: var(--accent); background: var(--accent-soft); }
.tone { font-size: 12.5px; color: var(--ink2); }
.ts:empty { display: none; }

.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; }
.notice span { flex: 1 1 260px; }
.notice > .ic { color: var(--accent); }
.ver { font-size: 11px; color: var(--muted); padding: 0 6px 4px; }

.choice { display: flex !important; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0 !important; cursor: pointer; font-weight: 400 !important; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; padding: 0; }
.choice small { display: block; color: var(--ink2); font-size: 12.5px; }

/* Gráficos */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 14px; }
.chartcard { min-width: 0; }
.chartcard figcaption { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.chartcard figcaption div { min-width: 0; }
.tools { display: flex; flex: none; }
.plainchart { margin: 10px 0 4px; }
svg.ch { display: block; max-width: 100%; height: auto; font-variant-numeric: tabular-nums; }
.pt .guide, .pt .dot { opacity: 0; }
.pt:hover .guide, .pt:hover .dot { opacity: 1; }
.mk:hover path, circle.mk:hover { filter: brightness(1.12); }
#tip { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; background: var(--ink); color: var(--surface); padding: 5px 9px; border-radius: 8px; font-size: 12.5px; max-width: min(320px, 90vw); box-shadow: var(--shadow); }
.builder .brow { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.builder label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); flex: 1 1 150px; min-width: 0; }
.builder select { width: 100%; }
.ctable { margin-top: 10px; }
.tscroll { overflow: auto; max-height: 340px; }
.tscroll.big { max-height: none; padding: 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
th { color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
td.num { text-align: right; }
.rn { color: var(--muted); text-align: right; width: 1%; }
.thb { border: 0; background: transparent; font-weight: 600; cursor: pointer; padding: 0; display: block; color: var(--ink); }
.tsel { border: 0; padding: 0; font-size: 11px; color: var(--muted); background: transparent; margin-top: 2px; }
.dbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; flex: 1 1 220px; max-width: 380px; color: var(--muted); }
.searchbox input { border: 0; flex: 1; padding: 8px 0; background: transparent; box-shadow: none !important; }

/* Relatório */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: clamp(20px, 5vw, 48px); box-shadow: 0 2px 10px rgba(28, 27, 46, .06); }
.doc header { border-bottom: 2px solid var(--accent); padding-bottom: 14px; margin-bottom: 6px; }
.doc h1 { font-size: 28px; line-height: 1.2; margin: 4px 0; }
.doc h2 { font-size: 17px; margin: 26px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.doc h3 { margin: 16px 0 4px; }
.doc p, .doc li { color: var(--ink2); }
.doc ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.doc .tile { background: var(--surface2); border: 0; }

/* Infográfico */
.poster { max-width: 720px; width: 100%; margin: 0 auto; background: var(--surface); border-radius: 22px; overflow: hidden; border: 1px solid var(--line); }
.phead { background: linear-gradient(135deg, #5b47d6, #8f7cf7 60%, #f08ab4); color: #fff; padding: 30px 28px 34px; }
.phead .eyebrow { color: #fff; opacity: .85; }
.phead h1 { font-size: clamp(26px, 6vw, 38px); line-height: 1.15; margin: 6px 0 10px; }
.phead p { font-size: 15.5px; opacity: .95; }
.pbigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 0 20px; margin-top: -18px; }
.pbig { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; text-align: center; box-shadow: 0 6px 18px rgba(28, 27, 46, .08); min-width: 0; }
.pbig b { display: block; font-size: 26px; line-height: 1.15; color: var(--accent); overflow-wrap: anywhere; }
.pbig span { font-size: 12.5px; color: var(--ink2); }
.pblock { padding: 22px 28px 4px; }
.pblock h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.pnum { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; flex: none; }
.pfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.pfact { background: var(--accent-soft); border-radius: 14px; padding: 12px; }
.pfact span { font-size: 22px; }
.pfact b { display: block; font-size: 18px; }
.pfact p { font-size: 12.5px; color: var(--ink2); }
.pfoot { margin-top: 22px; padding: 14px 28px; background: var(--surface2); color: var(--muted); font-size: 12px; }
.hbars { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.hb { display: grid; grid-template-columns: 26px minmax(60px, 28%) 1fr auto; gap: 8px; align-items: center; }
.hbn { font-weight: 700; color: var(--muted); text-align: center; }
.hbk { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink2); }
.hbt { height: 14px; display: block; }
.hbt i { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.hbv { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Fofinho */
.fofo { max-width: 640px; width: 100%; margin: 0 auto; background: linear-gradient(160deg, #fff5fa, #f3f1ff 55%, #eefaf5); border-radius: 28px; padding: clamp(16px, 4vw, 28px); display: flex; flex-direction: column; gap: 16px; font-size: 16px; }
.say { display: flex; align-items: flex-end; gap: 6px; }
.say .pri { flex: none; }
.bubble { position: relative; background: #fff; border-radius: 22px 22px 22px 6px; padding: 14px 18px; box-shadow: 0 6px 0 rgba(143, 124, 247, .18); color: #2b2350; }
.fcard { position: relative; background: #fff; border-radius: 26px; padding: 20px 22px; border: 3px solid var(--fc); box-shadow: 0 6px 0 var(--fc); color: #2b2350; }
.fcard h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--ft); padding-right: 56px; }
.fcard p { color: #4a4368; }
.fico { position: absolute; right: 16px; top: -18px; font-size: 40px; transform: rotate(8deg); }
.fbignum { font-size: clamp(40px, 11vw, 60px); font-weight: 800; line-height: 1.15; color: var(--ft); overflow-wrap: anywhere; }
.fwho { font-size: 26px; margin: 4px 0; color: #2b2350 !important; }
.f1 { --fc: #d9dcff; --ft: #5b47d6; } .f2 { --fc: #ffe9ac; --ft: #8a6400; } .f3 { --fc: #ffd9e8; --ft: #b93a6d; }
.f4 { --fc: #c9f2e0; --ft: #0f7a57; } .f5 { --fc: #cde2fb; --ft: #1c5cab; } .f6 { --fc: #e6dcff; --ft: #5b47d6; }
.fofo .hbt { height: 20px; background: #f4f1ff; border-radius: 999px; }
.fofo .hbt i { border-radius: 999px; background: linear-gradient(90deg, #f08ab4, #8f7cf7); }
.fofo .hbn { font-size: 20px; }
.tenrow { display: flex; gap: 6px; margin: 12px 0 8px; flex-wrap: wrap; }
.tenrow i { width: 26px; height: 26px; border-radius: 50%; background: #f1e9f3; }
.tenrow i.on { background: #f08ab4; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .08); }
.flist { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; color: #4a4368; }
.flist li { display: flex; gap: 10px; }
.flist span { font-size: 22px; line-height: 1.15; }
.fdic { margin: 8px 0 0; }
.fdic dt { font-weight: 700; color: var(--ft); margin-top: 6px; }
.fdic dd { margin: 0; color: #4a4368; }
.fend { text-align: center; color: #8a7fb0; font-size: 13px; }

/* Cartões */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.pcard { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.pcimg { width: 100%; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); line-height: 0; }
.pcimg svg { width: 100%; height: auto; display: block; }

/* Boas-vindas */
.welcome { max-width: 560px; margin: 6vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.welcome h1 { font-size: clamp(22px, 5vw, 30px); line-height: 1.2; }
.welcome p { color: var(--ink2); font-size: 15px; }

/* Janelas e avisos */
.modalwrap { position: fixed; inset: 0; background: rgba(15, 16, 32, .5); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: var(--surface); border-radius: 16px; width: min(460px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(560px, 100%); }
.mhead { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.mhead h2 { font-size: 17px; }
.mbody { padding: 10px 18px 18px; }
.mbody label { display: block; font-weight: 600; margin: 14px 0 5px; }
.mbody select { width: 100%; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 22px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone > .ic { width: 34px; height: 34px; color: var(--accent); }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .2s; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; z-index: 70; display: flex; gap: 12px; align-items: center; max-width: min(560px, 92vw); box-shadow: var(--shadow); }
#toast.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.tact { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
#scrim { display: none; }

@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-102%); transition: transform .2s; padding-top: max(14px, env(safe-area-inset-top)); }
  body.side-open #sidebar { transform: none; box-shadow: var(--shadow); }
  body.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(15, 16, 32, .45); z-index: 20; }
  .onlysm { display: inline-grid !important; }
  .hidesm { display: none; }
  #topbar { padding: max(8px, env(safe-area-inset-top)) 10px 6px; }
  #view { padding: 14px 10px calc(40px + env(safe-area-inset-bottom)); }
  #tabs { padding: 0 4px; }
  .pblock { padding: 18px 16px 2px; }
  .phead { padding: 24px 18px 30px; }
  .pbigs { padding: 0 12px; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
  .pbig { padding: 12px 6px; }
  .pbig b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
