/* ============================ Carteira — tema ============================ */
:root {
  --bg: #f2f5f9; --surface: #ffffff; --surface-2: #f7f9fc; --text: #0f1b2d; --muted: #66758a; --line: #e2e8f0;
  --primary: #1f3a5f; --primary-2: #2b4c7e; --accent: #1f9d57; --accent-soft: #e2f5ea; --neg: #d14343; --neg-soft: #fde8e8;
  --gold: #c58a1a; --gold-soft: #fbf0db; --blue-soft: #e6eefb; --shadow: 0 1px 2px rgba(15,27,45,.06), 0 4px 16px rgba(15,27,45,.06);
  --radius: 16px; --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b111b; --surface: #131c2b; --surface-2: #1a2537; --text: #e7eef7; --muted: #94a3b8; --line: #243248;
    --primary: #8fb6ff; --primary-2: #1b2a40; --accent: #34d399; --accent-soft: #10392a; --neg: #f87171; --neg-soft: #3b1a1d;
    --gold: #f2c14e; --gold-soft: #3a2f14; --blue-soft: #18284a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b111b; --surface: #131c2b; --surface-2: #1a2537; --text: #e7eef7; --muted: #94a3b8; --line: #243248;
  --primary: #8fb6ff; --primary-2: #1b2a40; --accent: #34d399; --accent-soft: #10392a; --neg: #f87171; --neg-soft: #3b1a1d;
  --gold: #f2c14e; --gold-soft: #3a2f14; --blue-soft: #18284a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  min-height: 100vh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--primary); }

/* ---------- estrutura ---------- */
.app { display: flex; min-height: 100vh; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: calc(var(--safe-t) + 0px) 0 calc(var(--tab-h) + var(--safe-b) + 24px); }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  padding: calc(var(--safe-t) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid transparent; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { border: 0; background: var(--surface); width: 36px; height: 36px; border-radius: 12px; box-shadow: var(--shadow); font-size: 18px; cursor: pointer; }
.icon-btn { border: 0; background: var(--surface); height: 36px; min-width: 36px; padding: 0 10px; border-radius: 12px; box-shadow: var(--shadow); cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.content { max-width: 1040px; margin: 0 auto; padding: 4px 16px 0; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a, .side a { text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; }
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(1) opacity(.7); }
.tabbar a.on { color: var(--primary); }
.tabbar a.on .ico { filter: none; }

.fab { position: fixed; right: 20px; bottom: calc(var(--tab-h) + var(--safe-b) + 18px); z-index: 31; width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: linear-gradient(135deg, var(--accent), #168048); color: #fff; font-size: 32px; font-weight: 300; box-shadow: 0 10px 24px rgba(31,157,87,.35); cursor: pointer; }
.fab:active { transform: scale(.96); }

@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 4px; width: 230px; flex: 0 0 230px; position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line); }
  .side .brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 17px; padding: 0 10px 18px; }
  .side .brand img { width: 34px; height: 34px; border-radius: 10px; }
  .side a { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 14.5px; padding: 10px 12px; border-radius: 12px; color: var(--text); font-weight: 550; }
  .side a .ico { font-size: 18px; width: 22px; text-align: center; }
  .side a.on { background: var(--blue-soft); color: var(--primary); }
  .side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 4px; font-weight: 700; }
  .tabbar { display: none; }
  .main { padding-bottom: 40px; }
  .fab { bottom: 28px; right: 32px; }
}

/* ---------- blocos ---------- */
.section { margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; flex: 1; }
.section .link { font-size: 13px; font-weight: 600; color: var(--primary); background: none; border: 0; cursor: pointer; padding: 4px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .g2.wide4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.hero { background: linear-gradient(140deg, #1f3a5f 0%, #24507f 55%, #1f7a5a 130%); color: #fff; border-radius: 22px; padding: 20px; box-shadow: 0 12px 30px rgba(31,58,95,.28); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero .lbl { font-size: 13px; opacity: .8; font-weight: 600; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 10px; }
.hero .row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.hero .row b { display: block; font-size: 16px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.pill.pos { background: var(--accent-soft); color: var(--accent); }
.pill.neg { background: var(--neg-soft); color: var(--neg); }
.pill.neu { background: var(--surface-2); color: var(--muted); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.pill.blue { background: var(--blue-soft); color: var(--primary); }
.hero .pill.pos { background: rgba(52,211,153,.2); color: #b9f5d8; }
.hero .pill.neg { background: rgba(248,113,113,.22); color: #ffd0d0; }

.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 650; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 20px; font-weight: 750; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pos { color: var(--accent); } .neg { color: var(--neg); } .muted { color: var(--muted); }

.seg { display: inline-flex; background: var(--surface); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 650; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .seg button.on { color: #0b111b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { color: #0b111b; } }

/* lista de ativos */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--surface-2); }
.avatar { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: 0 0 42px; letter-spacing: -.02em; }
.item .mid { flex: 1; min-width: 0; }
.item .t { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.item .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .right { text-align: right; flex: 0 0 auto; }
.item .right .v { font-weight: 700; }
.bar { height: 5px; background: var(--surface-2); border-radius: 9px; overflow: hidden; margin-top: 6px; position: relative; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--gold); }
.tag { font-size: 10.5px; font-weight: 750; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); letter-spacing: .02em; }

.row-tx { display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-tx:last-child { border-bottom: 0; }
.row-tx .d { font-size: 12.5px; color: var(--muted); }
.row-tx .m { min-width: 0; }
.row-tx .m b { font-weight: 650; }
.row-tx .m .sub { font-size: 12.5px; color: var(--muted); }
.row-tx .r { text-align: right; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 26px 16px; font-size: 14px; }
.empty .e { font-size: 34px; display: block; margin-bottom: 6px; }

/* tabelas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: right; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 750; background: var(--surface-2); }

/* gráficos */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* sugestões */
.tip { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tip:last-child { border-bottom: 0; }
.tip .e { font-size: 20px; }
.tip .tx { font-size: 14px; }
.tip .tx small { display: block; color: var(--muted); font-size: 12.5px; }

/* menu "Mais" */
.menu { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
@media (min-width: 700px) { .menu { grid-template-columns: repeat(3, minmax(0,1fr)); } }
.menu a { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; min-height: 104px; }
.menu a .e { font-size: 26px; }
.menu a b { font-size: 15px; }
.menu a small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* folhas (modais) */
.scrim { position: fixed; inset: 0; background: rgba(8,14,24,.45); z-index: 50; opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg); border-radius: 22px 22px 0 0; max-height: 92vh; overflow: auto;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); padding: 8px 16px calc(var(--safe-b) + 20px); -webkit-overflow-scrolling: touch; }
.sheet.show { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet .head h3 { margin: 0; font-size: 19px; flex: 1; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; border-radius: 22px; transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: all .2s; max-height: 88vh; }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
}

.choices { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.choice { background: var(--surface); border: 0; border-radius: 16px; box-shadow: var(--shadow); padding: 16px 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.choice .e { font-size: 24px; }
.choice b { font-size: 15px; }
.choice small { color: var(--muted); font-size: 12px; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 13px; font-size: 16px; outline: none; min-height: 46px; -webkit-appearance: none; appearance: none; }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--blue-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.toggle button { flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 9px; font-weight: 650; cursor: pointer; color: var(--muted); font-size: 14px; }
.toggle button.on { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .toggle button.on { color: #0b111b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toggle button.on { color: #0b111b; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 13px; font-weight: 650; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.hint { font-size: 12.5px; color: var(--muted); }
.warn { font-size: 13px; color: var(--neg); background: var(--neg-soft); padding: 9px 12px; border-radius: 10px; }
.calc { font-size: 14px; background: var(--surface); border-radius: 12px; padding: 10px 13px; display: flex; justify-content: space-between; }

.btn { border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 16px; cursor: pointer; background: var(--primary); color: #fff; width: 100%; }
:root[data-theme="dark"] .btn { color: #0b111b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0b111b; } }
.btn.green { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.sm { padding: 9px 12px; font-size: 14px; width: auto; border-radius: 11px; }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 90px); transform: translateX(-50%) translateY(20px); background: #0f1b2d; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 60; opacity: 0; transition: all .25s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
@media (min-width: 900px) { .toast { bottom: 40px; } }

.banner { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 14px; background: var(--gold-soft); color: var(--text); font-size: 13.5px; margin-top: 12px; }
.banner button { margin-left: auto; }
.progress { height: 10px; background: var(--surface-2); border-radius: 9px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #5ad19a); border-radius: 9px; }
.privacy .money { filter: blur(7px); }
.sep { height: 1px; background: var(--line); margin: 4px 0; }
.footnote { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* correções: cores dos botões secundários em qualquer tema; ações das sugestões à direita */
.btn.ghost { color: var(--text) !important; }
.btn.green { color: #fff !important; }
.btn.danger { color: var(--neg) !important; }
.tip > .btn, .tip > a.btn { margin-left: auto; flex: 0 0 auto; align-self: center; }
.tip .tx { flex: 1; min-width: 0; }

/* modo visualizador (iPad, só consulta) */
html.view .fab{display:none!important}
html.view [data-act="edit"],html.view [data-act="price"]{pointer-events:auto}
html.login .fab, html.login .tabbar, html.login .side { display: none !important; }
html.login .login-card { max-width: 420px; margin: 40px auto !important; }
html.login .topbar .icon-btn { display: none !important; }
