/* Paleta "pôr do sol": ameixa #462446, malva #b05e6d, coral #e96b55, âmbar #fcc050, verde-água #47b29e */
:root {
  --bg:#f8f3f5; --surface:#ffffff; --text:#462446; --muted:#6e5370; --line:#eadfe5;
  --brand:#462446; --brand-ink:#ffffff; --brand-soft:#f1e5ec;
  --accent:#fcc050; --accent-ink:#462446;
  --hero-a:#462446; --hero-b:#a2546a;
  --in:#1f7f6d; --out:#c4472f; --warn-bg:#fff3d6; --warn:#7a5200; --err:#c4472f;
  --c1:#462446; --c2:#e96b55; --c3:#fcc050; --c4:#47b29e; --c5:#b05e6d; --c6:#8e6aa8; --c7:#2a7f70; --c8:#a89aa6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#2a132b; --surface:#38193a; --text:#f6eef2; --muted:#c4a9c3; --line:#573158;
    --brand:#fcc050; --brand-ink:#462446; --brand-soft:#52284f;
    --hero-a:#5a2d5c; --hero-b:#462446;
    --in:#5fd6bf; --out:#ff8a74; --warn-bg:#3d2b12; --warn:#fcc050; --err:#ff8a74;
    --c1:#47b29e; --c2:#ff8a74; --c3:#fcc050; --c4:#c27a8a; --c5:#a98bd0; --c6:#6fd3c0; --c7:#ffc2b3; --c8:#bda9bc;
  }
}
:root[data-theme="dark"] {
  --bg:#2a132b; --surface:#38193a; --text:#f6eef2; --muted:#c4a9c3; --line:#573158;
  --brand:#fcc050; --brand-ink:#462446; --brand-soft:#52284f;
  --hero-a:#5a2d5c; --hero-b:#462446;
  --in:#5fd6bf; --out:#ff8a74; --warn-bg:#3d2b12; --warn:#fcc050; --err:#ff8a74;
  --c1:#47b29e; --c2:#ff8a74; --c3:#fcc050; --c4:#c27a8a; --c5:#a98bd0; --c6:#6fd3c0; --c7:#ffc2b3; --c8:#bda9bc;
}
* { box-sizing:border-box; }
html,body { margin:0; background:var(--bg); color:var(--text); font:16px/1.45 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
[hidden] { display:none !important; }
#demo-banner { background:var(--warn-bg); color:var(--warn); text-align:center; font-size:13px; padding:6px 12px; }
#app, #login { max-width:520px; margin:0 auto; min-height:100vh; }
.screen { padding:8px 16px 110px; }
h1 { font-size:26px; margin:8px 0 4px; } h2 { font-size:18px; margin:22px 0 10px; } h3 { margin:0 0 10px; font-size:15px; }
.muted { color:var(--muted); } .small { font-size:13px; } .error { color:var(--err); font-size:14px; margin:10px 0 0; } .warn { background:var(--warn-bg); color:var(--warn); padding:10px 12px; border-radius:10px; font-size:14px; }
.in { color:var(--in); } .out { color:var(--out); }
.login-card { padding:48px 24px; display:grid; gap:10px; justify-items:start; }
form { display:grid; gap:14px; width:100%; }
label { display:grid; gap:6px; font-size:14px; font-weight:600; }
input, select { font:inherit; padding:13px 14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--text); width:100%; }
input:focus, select:focus, button:focus-visible { outline:2px solid var(--brand); outline-offset:1px; }
button { font:inherit; cursor:pointer; border:0; }
button.primary { background:var(--brand); color:var(--brand-ink); padding:14px 16px; border-radius:12px; font-weight:700; }
button.primary:disabled { opacity:.5; cursor:not-allowed; }
button.ghost { background:transparent; color:var(--brand); padding:10px 12px; border-radius:10px; font-weight:600; }
button.icon { background:transparent; color:var(--muted); width:40px; height:40px; border-radius:50%; display:inline-grid; place-items:center; font-size:22px; }
button.icon:hover, button.ghost:hover { background:var(--brand-soft); }
button.icon[aria-pressed="true"] { color:var(--brand); background:var(--brand-soft); }

.top { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; position:sticky; top:0; background:var(--bg); z-index:5; gap:8px; }
.top-actions { display:flex; align-items:center; gap:2px; }
.inst { background:transparent; color:var(--text); text-align:left; display:grid; padding:4px 0; min-width:0; }
.inst span { font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inst small { color:var(--muted); }
.row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.row h2, .row h3 { margin:0; }

.hero { background:linear-gradient(135deg,var(--hero-a),var(--hero-b)); color:#fff; border-radius:20px; padding:20px; display:grid; gap:8px; }
.hero .muted { color:inherit; opacity:.85; font-size:13px; }
.big { font-size:36px; letter-spacing:-.02em; font-variant-numeric:tabular-nums; }
.flow { display:flex; gap:18px; flex-wrap:wrap; font-size:14px; }
.flow b { margin-left:6px; font-variant-numeric:tabular-nums; }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; }
.dot.in { background:#6fe0c8; } .dot.out { background:#ffb4a0; }
.flowbar { display:flex; height:8px; border-radius:6px; overflow:hidden; background:rgba(255,255,255,.2); }
.flowbar #bar-in { background:#6fe0c8; } .flowbar #bar-out { background:#ffb4a0; }

.period { display:flex; align-items:center; justify-content:space-between; margin:18px 0 10px; }
.period-mid { display:grid; justify-items:center; gap:6px; text-align:center; }
.period-mid strong { font-size:17px; display:block; }
.period-mid strong::first-letter { text-transform:uppercase; }
.seg { display:grid; grid-template-columns:1fr 1fr; background:var(--brand-soft); border-radius:12px; padding:4px; margin-bottom:16px; }
.seg.mini { margin:0; padding:3px; border-radius:10px; min-width:140px; }
.seg button { background:transparent; padding:10px; border-radius:9px; font-weight:700; color:var(--text); }
.seg.mini button { padding:5px 10px; font-size:13px; }
.seg button.on { background:var(--surface); box-shadow:0 1px 3px rgba(0,0,0,.15); }
.seg button.on[data-tipo="E"] { color:var(--in); } .seg button.on[data-tipo="S"] { color:var(--out); }
.kpis3 { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.kpi { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:12px; display:grid; gap:2px; min-width:0; }
.kpi { padding:10px; }
.kpi span { font-size:12px; } .kpi b { font-size:13.5px; font-variant-numeric:tabular-nums; white-space:nowrap; } .kpi small { font-size:10.5px; min-height:14px; line-height:1.25; }
.grid2 { display:grid; gap:12px; margin-top:12px; }
.card { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:16px; margin-top:12px; }
.grid2 .card { margin-top:0; }

.donutwrap { display:grid; gap:14px; justify-items:center; }
.donutwrap svg { width:180px; height:180px; }
.donutwrap circle.seg { fill:none; stroke-width:18; cursor:pointer; }
.donutwrap circle.track { fill:none; stroke:var(--line); stroke-width:18; }
.dc-l { font-size:7px; fill:var(--muted); text-anchor:middle; }
.dc-v { font-size:10px; font-weight:700; fill:var(--text); text-anchor:middle; font-variant-numeric:tabular-nums; }
.legend-list { list-style:none; margin:0; padding:0; width:100%; display:grid; gap:2px; }
.legend-list button { all:unset; cursor:pointer; display:grid; grid-template-columns:12px 1fr auto auto; gap:8px; align-items:center; width:100%; padding:7px 6px; border-radius:8px; font-size:14px; box-sizing:border-box; }
.legend-list button:hover, .legend-list button:focus-visible { background:var(--brand-soft); }
.legend-list i { width:12px; height:12px; border-radius:3px; }
.legend-list em { color:var(--muted); font-style:normal; font-size:12px; min-width:38px; text-align:right; }
.legend-list b { font-variant-numeric:tabular-nums; }

.serie { display:flex; align-items:flex-end; gap:6px; min-height:150px; overflow-x:auto; padding-top:8px; }
.serie p { align-self:center; }
.scol { flex:1 0 34px; display:grid; gap:4px; justify-items:center; }
.sbars { display:flex; align-items:flex-end; gap:3px; height:120px; }
.sbars span { width:11px; border-radius:4px 4px 0 0; min-height:2px; }
.sbars .e { background:var(--in); } .sbars .s { background:var(--out); }
.scol small { font-size:11px; color:var(--muted); text-transform:capitalize; }

.list { list-style:none; padding:0; margin:0; display:grid; gap:8px; }
.list.tight { gap:2px; }
.list li { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:14px 16px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.list.tight li { border:0; border-bottom:1px solid var(--line); border-radius:0; padding:9px 2px; font-size:14px; background:transparent; }
.list li button { all:unset; cursor:pointer; display:flex; justify-content:space-between; width:100%; }
.list .v { font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }
.neg { color:var(--out); }
.formgrid { display:grid; gap:14px; }
.empty { background:var(--surface); border:1px dashed var(--line); border-radius:14px; padding:20px; }

.fab { position:fixed; right:18px; bottom:calc(72px + env(safe-area-inset-bottom)); height:56px; min-width:56px; padding:0 18px; border-radius:28px; background:var(--accent); color:var(--accent-ink); box-shadow:0 6px 16px rgba(0,0,0,.28); display:flex; align-items:center; justify-content:center; gap:8px; z-index:6; font-weight:700; }
.fab span { font-size:30px; line-height:1; margin-top:-3px; } .fab em { display:none; font-style:normal; }
.tabs { position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:520px; display:grid; grid-template-columns:repeat(3,1fr); background:var(--surface); border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); z-index:7; }
.tabs .brand { display:none; }
.tabs button { background:transparent; color:var(--muted); padding:14px 4px; font-weight:600; font-size:14px; }
.tabs button.on { color:var(--brand); box-shadow:inset 0 2px 0 var(--brand); }

dialog { border:0; border-radius:18px; padding:20px; width:min(92vw,440px); background:var(--surface); color:var(--text); }
dialog::backdrop { background:rgba(0,0,0,.5); }
dl { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; margin:14px 0; }
dt { color:var(--muted); font-size:14px; } dd { margin:0; font-weight:600; text-align:right; overflow-wrap:anywhere; }
.actions { display:flex; gap:10px; justify-content:flex-end; margin-top:12px; }
#toast { position:fixed; bottom:96px; left:50%; transform:translateX(-50%); background:var(--text); color:var(--bg); padding:10px 16px; border-radius:999px; font-size:14px; z-index:20; max-width:90vw; }

/* Ocultar valores (como no Organizze) */
body.hidev .big, body.hidev .flow b, body.hidev .val, body.hidev .list .v, body.hidev .dc-v,
body.hidev .legend-list b, body.hidev .legend-list em, body.hidev .scol, body.hidev .kpi small { filter:blur(9px); user-select:none; }

/* ---------- Desktop: menu lateral e grade ---------- */
@media (min-width: 960px) {
  #app { max-width:none; margin:0; padding-left:236px; }
  .tabs { top:0; bottom:0; left:0; transform:none; width:236px; max-width:none; grid-template-columns:1fr; grid-auto-rows:min-content; align-content:start; gap:4px; padding:20px 12px; border-top:0; border-right:1px solid var(--line); }
  .tabs .brand { display:flex; align-items:center; gap:10px; font-weight:800; font-size:18px; padding:4px 8px 22px; }
  .tabs button { text-align:left; padding:12px 14px; border-radius:10px; box-shadow:none !important; font-size:15px; }
  .tabs button.on { background:var(--brand-soft); color:var(--brand); }
  .top { padding:18px 40px; }
  .screen { max-width:1160px; padding:6px 40px 64px; }
  .hero { padding:26px 30px; } .big { font-size:46px; }
  .kpis3 { gap:14px; } .kpi { padding:16px 18px; } .kpi b { font-size:22px; } .kpi span { font-size:13px; }
  .grid2 { grid-template-columns:1fr 1fr; gap:16px; }
  .donutwrap { grid-template-columns:180px 1fr; align-items:center; justify-items:stretch; }
  .formgrid { grid-template-columns:1fr 1fr; max-width:760px; }
  .formgrid .wide { grid-column:1 / -1; }
  #caixas { grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); }
  .fab { right:40px; bottom:32px; }
  .fab em { display:inline; }
  .fab { padding:0 22px; }
  #toast { bottom:32px; }
  dialog { width:min(92vw,480px); }
}
