/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --page: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f3f2ee;
  --surface-3: #ebe9e3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e6e4dd;
  --line-strong: #d6d3ca;
  --grid: #ecebe5;
  --accent: #2a78d6;
  --accent-soft: #e8f1fc;
  --pos: #006300;
  --neg: #c4352f;
  --neg-soft: #fbecea;
  --warn: #a86400;
  --warn-soft: #fdf3e1;
  --good-soft: #e7f3e7;
  --btn: #111111;
  --btn-ink: #ffffff;
  --s1: #2a78d6;  /* séries: entradas / essencial */
  --s2: #eb6834;  /* gastos / estilo de vida */
  --s3: #1baf7a;  /* futuro */
  --bar: #2a78d6;
  --shadow-sm: 0 1px 2px rgba(16, 16, 14, .05);
  --shadow-lg: 0 24px 64px -12px rgba(16, 16, 14, .25), 0 0 0 1px rgba(16, 16, 14, .06);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8d8b84; --line: #2c2c2a; --line-strong: #3a3a37; --grid: #262624;
    --accent: #3987e5; --accent-soft: #14253a; --pos: #3fb950; --neg: #ef6b65; --neg-soft: #2d1716;
    --warn: #e6a23c; --warn-soft: #2b2112; --good-soft: #13251a; --btn: #f0efec; --btn-ink: #0d0d0d;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --bar: #3987e5;
    --shadow-sm: none; --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8d8b84; --line: #2c2c2a; --line-strong: #3a3a37; --grid: #262624;
  --accent: #3987e5; --accent-soft: #14253a; --pos: #3fb950; --neg: #ef6b65; --neg-soft: #2d1716;
  --warn: #e6a23c; --warn-soft: #2b2112; --good-soft: #13251a; --btn: #f0efec; --btn-ink: #0d0d0d;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --bar: #3987e5;
  --shadow-sm: none; --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ============ Layout ============ */
.layout { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--page);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 650; letter-spacing: -0.01em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--btn); color: var(--btn-ink); display: grid; place-items: center; }
.logo svg { width: 15px; height: 15px; stroke-width: 2.2; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; margin-bottom: 1px; border: 1px solid transparent;
}
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a.active { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
#nav a.active svg { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 10px; border-top: 1px solid var(--line); }

main { padding: 28px 40px 64px; min-width: 0; }
.container { max-width: 1180px; margin: 0 auto; }
.topbar { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar .titles { flex: 1; min-width: 200px; }
.topbar h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.025em; }
.topbar .subtitle { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; align-items: center; }

/* ============ Controles ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 550; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.primary:hover { opacity: .88; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.danger { color: var(--neg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
kbd { font: 11px/1 system-ui; padding: 3px 5px; border-radius: 4px; background: rgba(255,255,255,.18); }
.btn:not(.primary) kbd { background: var(--surface-3); color: var(--muted); }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.month-picker { display: flex; align-items: center; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.month-picker .icon-btn { height: 32px; border-radius: 0; }
.month-picker strong { min-width: 128px; text-align: center; font-weight: 550; }

label.lbl { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 6px; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.input-icon input { padding-left: 32px; }
.field { margin-bottom: 14px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.amount-input { font-size: 28px; font-weight: 650; height: 56px; letter-spacing: -0.02em; }
.segmented { display: flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented label { flex: 1; text-align: center; padding: 6px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 550; }
.segmented input { display: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ============ Superfícies ============ */
.grid { display: grid; gap: 16px; }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.panel-head .link { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.panel-head .link:hover { color: var(--ink); }
.panel-body { padding: 14px 18px 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)); }
.hero > div { padding: 20px 22px; }
.hero > div + div { border-left: 1px solid var(--line); }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; }
.hero .main .stat-value { font-size: 36px; letter-spacing: -0.035em; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; margin-top: 6px; color: var(--muted); }
.delta b { font-weight: 600; }
.delta.up-good b, .delta.down-good b { color: var(--pos); }
.delta.up-bad b, .delta.down-bad b { color: var(--neg); }

/* Badges de categoria */
.badge { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 15px; flex: none; }
.badge.sm { width: 26px; height: 26px; border-radius: 7px; font-size: 13px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.neg { background: var(--neg-soft); color: var(--neg); }
.tag.good { background: var(--good-soft); color: var(--pos); }

/* Barras */
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--bar); }
.meter.warn > i { background: var(--warn); }
.meter.over > i { background: var(--neg); }
.meter .target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; border-radius: 2px; }
.meter-row { margin-bottom: 14px; }
.meter-row:last-child { margin-bottom: 0; }
.meter-row .top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 13px; }

.cat-line { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; margin-bottom: 12px; }
.cat-line .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-line .meter { grid-column: 2 / 4; height: 5px; }
.cat-line .share { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* Próximos passos */
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: 0; padding-top: 2px; }
.todo .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; }
.todo .dot svg { width: 13px; height: 13px; stroke-width: 2.2; }
.todo.alerta .dot { background: var(--neg-soft); color: var(--neg); }
.todo.info .dot { background: var(--accent-soft); color: var(--accent); }
.todo.bom .dot { background: var(--good-soft); color: var(--pos); }
.todo p { flex: 1; color: var(--ink-2); font-size: 13px; }
.todo a { color: var(--muted); }
.todo a:hover { color: var(--ink); }

/* Gráfico */
.chart-wrap { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar-in { fill: var(--s1); }
.chart .bar-out { fill: var(--s2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--surface-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 9px 11px; font-size: 12.5px; min-width: 160px; opacity: 0; transition: opacity .1s; z-index: 2;
}
.tooltip.show { opacity: 1; }
.tooltip .t-title { font-weight: 600; margin-bottom: 4px; text-transform: capitalize; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .t-row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* Lista de lançamentos */
.tx-day { display: flex; justify-content: space-between; padding: 14px 18px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tx { display: flex; align-items: center; gap: 12px; padding: 9px 18px; cursor: pointer; position: relative; }
.tx:hover { background: var(--surface-2); }
.tx .info { flex: 1; min-width: 0; }
.tx .desc { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .amt { font-weight: 600; text-align: right; }
.tx .tx-actions { display: flex; opacity: 0; transition: opacity .1s; }
.tx:hover .tx-actions { opacity: 1; }
.list-compact .tx { padding: 8px 0; }
.list-compact .tx:hover { background: transparent; }
.toolbar { display: grid; grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.summary-strip { display: flex; gap: 22px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.summary-strip b { font-weight: 600; }

/* Tabelas */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
.table-wrap { overflow-x: auto; }
td input, td select { height: 32px; }

/* Cartão de crédito */
.cc {
  position: relative; aspect-ratio: 1.586; border-radius: 16px; padding: 18px 20px; color: #fff; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--cc) 70%, #fff 10%) 0%, var(--cc) 45%, color-mix(in srgb, var(--cc) 55%, #000) 100%);
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--cc) 60%, transparent);
}
.cc::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.12) 50%, transparent 60%); pointer-events: none; }
.cc .cc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cc .cc-name { font-weight: 600; font-size: 15px; }
.cc .chip { width: 34px; height: 25px; border-radius: 5px; background: linear-gradient(135deg, #e9d9a5, #b8a165); opacity: .9; }
.cc .cc-label { font-size: 11.5px; opacity: .75; }
.cc .cc-value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.cc .cc-foot { display: flex; justify-content: space-between; font-size: 12px; opacity: .85; }
.cc-meta { padding: 14px 4px 0; }
.cc-meta .line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; color: var(--ink-2); }
.cc-meta .line b { color: var(--ink); font-weight: 600; }

.mini-cc { width: 40px; height: 26px; border-radius: 5px; background: linear-gradient(135deg, var(--cc), color-mix(in srgb, var(--cc) 55%, #000)); flex: none; }
.acc-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Metas */
.ring { width: 64px; height: 64px; flex: none; }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--s3); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }

/* Ajuda contextual */
.help { margin-bottom: 18px; }
.help summary { list-style: none; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.help summary::-webkit-details-marker { display: none; }
.help summary:hover { color: var(--ink); }
.help .help-body { margin-top: 10px; padding: 14px 16px; border-left: 2px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; color: var(--ink-2); max-width: 760px; }
.help .help-body p + p { margin-top: 8px; }

/* Importação */
.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; font-size: 13px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; }
.step.on { color: var(--ink); }
.step.on .n { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.step + .step::before { content: ""; width: 24px; height: 1px; background: var(--line-strong); }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 36px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 26px; height: 26px; color: var(--muted); margin-bottom: 6px; }

/* Modal */
dialog { border: 0; padding: 0; border-radius: 18px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 10, 9, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
dialog form { padding: 22px 22px 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 120px); background: var(--btn); color: var(--btn-ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 500; transition: transform .25s cubic-bezier(.2,.9,.3,1.2); z-index: 20; box-shadow: var(--shadow-lg);
}
#toast { visibility: hidden; }
#toast.show { transform: translate(-50%, 0); visibility: visible; }

.empty { text-align: center; padding: 48px 20px; }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: inline-grid; place-items: center; margin-bottom: 12px; color: var(--ink-2); }
.empty h2 { font-size: 16px; margin-bottom: 4px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto; }

.onboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 24px 0; text-align: left; }
.onboard div { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.onboard b { display: block; margin-bottom: 4px; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--r); background: var(--surface); border: 1px dashed var(--line-strong); color: var(--ink-2); flex-wrap: wrap; }

.skeleton { height: 120px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 460px; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.messages-inner { max-width: 720px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 80%; background: var(--surface-3); padding: 9px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg.assistant { display: flex; gap: 12px; }
.msg.assistant .av { width: 26px; height: 26px; border-radius: 7px; background: var(--btn); color: var(--btn-ink); display: grid; place-items: center; flex: none; }
.msg.assistant .av svg { width: 14px; height: 14px; }
.msg.assistant .body { flex: 1; min-width: 0; color: var(--ink); line-height: 1.6; }
.msg.assistant .body p { margin: 0 0 10px; } .msg.assistant .body p:last-child { margin: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 10px; padding-left: 20px; }
.msg.assistant code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.chat-empty { max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 0 24px; }
.chat-empty h2 { font-size: 22px; letter-spacing: -0.02em; margin: 14px 0 6px; }
.prompts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; text-align: left; }
.prompt { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.prompt:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); }
.prompt b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.composer-wrap { padding: 12px 24px 18px; border-top: 1px solid var(--line); }
.composer { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line-strong); border-radius: 14px; padding: 6px 6px 6px 14px; background: var(--surface); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; box-shadow: none !important; padding: 7px 0; height: 36px; max-height: 160px; resize: none; background: transparent; }
.composer .btn { height: 32px; width: 32px; padding: 0; border-radius: 9px; }
.typing::after { content: ""; display: inline-block; width: 7px; height: 14px; background: var(--ink); margin-left: 2px; vertical-align: -2px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.banner { display: flex; gap: 10px; align-items: center; background: var(--warn-soft); color: var(--warn); padding: 10px 16px; font-size: 13px; }

/* ============ Responsivo ============ */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .hero > div:nth-child(3) { border-left: 0; }
  .hero > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .g-main, .g-3 { grid-template-columns: 1fr 1fr; }
  .g-main > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); gap: 8px; }
  .brand { padding: 0; } .brand span, .nav-label, .sidebar-foot { display: none; }
  #nav { display: flex; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  #nav a { flex: none; margin: 0; }
  #nav a span { display: none; }
  #nav a.active span { display: inline; }
  main { padding: 18px 16px 48px; }
  .g-main, .g-3, .g-2, .onboard, .prompts { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .input-icon { grid-column: 1 / -1; }
  .topbar h1 { font-size: 22px; }
  .topbar .actions { width: 100%; }
  .month-picker { flex: 1; } .month-picker strong { flex: 1; min-width: 0; }
  .hero .main .stat-value { font-size: 28px; }
  .tx .tx-actions { display: none; }
  .chat { height: calc(100vh - 190px); }
}
@media (max-width: 480px) {
  .hero { grid-template-columns: 1fr; }
  .hero > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .fields-2 { grid-template-columns: 1fr; }
  #quickAdd .lbl-txt, #quickAdd kbd { display: none; }
}
.panel.flush .panel-body { padding: 8px 0; }

.list-compact .tx-actions { display: none; }
.g-main { align-items: start; }
.prompt { text-align: left; }

/* ============ Componentes novos (ondas 1-3) ============ */
.sidebar #nav { overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--neg); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 600; }
.sidebar-foot .foot-link { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; padding: 6px 8px; border-radius: var(--r-sm); }
.sidebar-foot .foot-link:hover, .sidebar-foot .foot-link.active { background: var(--surface-2); color: var(--ink); }
.link-muted { color: var(--muted); font-size: 12.5px; display: inline-flex; gap: 4px; align-items: center; background: none; border: 0; padding: 0; cursor: pointer; }
.link-muted:hover { color: var(--ink); }

.quick-entry { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 6px 6px 14px; box-shadow: var(--shadow-sm); }
.quick-entry:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-entry svg { color: var(--s2); }
.quick-entry input { border: 0; box-shadow: none !important; padding: 0; height: 32px; background: transparent; }

.explain { margin-top: 10px; font-size: 12.5px; }
.explain summary { cursor: pointer; color: var(--muted); list-style: none; }
.explain summary::-webkit-details-marker { display: none; }
.explain summary::before { content: "▸ "; }
.explain[open] summary::before { content: "▾ "; }
.calc-lines { margin-top: 8px; display: grid; gap: 4px; max-width: 380px; }
.calc-lines > div { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.calc-lines .total { border-top: 1px solid var(--line); padding-top: 4px; color: var(--ink); font-weight: 600; }

.cal-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.cal-row:first-child { border-top: 0; padding-top: 0; }
.cal-row .info { flex: 1; min-width: 0; }
.cal-row .desc { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row .sub { font-size: 12px; color: var(--muted); }
.cal-date { width: 38px; text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 2px 0; flex: none; background: var(--surface-2); }
.cal-date b { display: block; font-size: 14px; line-height: 1.2; }
.cal-date span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; }
.recap-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 8px; }
.recap-top .stat-value { margin-top: 2px; }

.person-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pc, #888); margin-right: 5px; vertical-align: 1px; }
.tx-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.tx.dim { opacity: .5; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; height: 36px; }
label.check input { width: 16px; height: 16px; }

.review-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 200px 110px auto; gap: 12px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); }
.review-list { margin-top: 10px; }
.review-row .desc { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-row .sub { font-size: 12px; color: var(--muted); }
.review-row .amt { text-align: right; }
.review-row.changed select { border-color: var(--s2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--s2) 20%, transparent); }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-chip, .person-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 12.5px; background: var(--surface-2); }
.rule-chip .icon-btn, .person-chip .icon-btn { width: 22px; height: 22px; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }

.panel-body.flush-list { padding: 8px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); padding: 4px; font-size: 11.5px; position: relative; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.cal-cell span { color: var(--muted); }
.cal-cell.today { border-color: var(--ink); }
.cal-cell.today span { color: var(--ink); font-weight: 700; }
.cal-cell.has { background: color-mix(in srgb, var(--s2) 10%, var(--surface)); border-color: color-mix(in srgb, var(--s2) 35%, var(--line)); }
.cal-cell i { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--s2); }
.cal-cell i.in { background: var(--s1); }
.cal-cell small { font-size: 10px; font-weight: 600; overflow: hidden; white-space: nowrap; }

.notice.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); color: var(--warn); justify-content: flex-start; }
.segmented.sm { display: inline-flex; padding: 2px; }
.segmented.sm label { padding: 4px 10px; font-size: 12.5px; flex: none; }
.segmented.tabs { flex-wrap: wrap; }
.mini-history { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; display: grid; gap: 4px; max-height: 160px; overflow: auto; }

.action-card { border: 1px solid var(--line-strong); border-radius: var(--r); padding: 12px 14px; margin-top: 10px; background: var(--surface); max-width: 520px; }
.action-card svg { color: var(--pos); }
.action-card p { margin: 6px 0 10px; color: var(--ink-2); }
.action-card.done { background: var(--surface-2); border-style: dashed; }
.action-card.done svg { color: var(--muted); }
.msg .tools { display: flex; flex-wrap: wrap; gap: 6px; }
.msg .tools:not(:empty) { margin-bottom: 8px; }
.tool-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; }
.tool-chip svg { width: 12px; height: 12px; }
.tool-chip:not(.done) { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.sankey svg { width: 100%; height: auto; display: block; }
.sk-label { fill: var(--ink); font-size: 12px; font-weight: 550; }
.sk-value { fill: var(--muted); font-size: 11px; }
.sankey path:hover { opacity: .45; }
table.compact td { padding-top: 7px; padding-bottom: 7px; }
.settle-result { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.settle-result svg { vertical-align: -3px; margin-right: 4px; }

.weeks { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.weeks span { font-size: 10px; text-align: center; padding: 3px 0; border-radius: 4px; background: color-mix(in srgb, var(--s3) 15%, var(--surface)); color: var(--ink-2); }
.plan-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(120px, 1fr) 44px 110px; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.plan-row:first-child { border-top: 0; }
.plan-row .pct { color: var(--muted); text-align: right; }
.plan-row b.num { text-align: right; }
input[type=range] { height: auto; padding: 0; border: 0; accent-color: var(--ink); box-shadow: none !important; }

.settings-section .settings-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 18px 0; }
.settings-head h2 { font-size: 15px; font-weight: 600; }
.settings-head p { margin-top: 2px; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; font: 12px/1.5 ui-monospace, Menlo, monospace; overflow-x: auto; margin: 8px 0 10px; color: var(--ink); }
.steps-list { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 4px; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--pos); }
.switch input:checked + span::after { transform: translateX(16px); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 28px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.login-card h1 { font-size: 20px; letter-spacing: -0.02em; }
.login-card input { text-align: center; }

@media (max-width: 820px) {
  .review-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .review-row select { grid-column: 2 / 4; }
  .review-row .amt { grid-column: 3; grid-row: 1; }
  .review-row [data-ok] { grid-column: 3; }
  .plan-row { grid-template-columns: 1fr 44px 96px; }
  .plan-row input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  .tx-tags { display: none; }
  .quick-entry .btn { padding: 0 10px; }
}

/* ============ Divisão, subcategorias, reembolsos, comprovantes, saúde ============ */
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tag svg { width: 11px; height: 11px; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-list:empty { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 3px 4px 3px 9px; font-size: 12.5px; max-width: 100%; }
.attach-chip a { display: inline-flex; gap: 5px; align-items: center; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.attach-chip a:hover { color: var(--accent); }
.attach-chip.new { border-style: dashed; }
.attach-chip .icon-btn { width: 22px; height: 22px; }
.attach-btn { cursor: pointer; }
.split-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.split-hint .btn { margin-left: auto; }
.split-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 130px 30px; gap: 8px; margin-bottom: 8px; align-items: center; }
.split-total { margin-top: 12px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.split-total svg { vertical-align: -3px; }
.sub-cats { grid-column: 2 / 4; font-size: 11.5px; color: var(--muted); margin-top: -2px; }
tr.subcat td:first-child { padding-left: 30px; }
.sub-arrow { color: var(--muted); margin-right: -2px; }
.who-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gauge { display: block; height: auto; }
.health-mini { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.pillar { padding: 14px 0; border-top: 1px solid var(--line); }
.pillar:first-child { border-top: 0; padding-top: 0; }
.pillar svg { vertical-align: -3px; }
@media (max-width: 1080px) { .g-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .g-4 { grid-template-columns: 1fr; }
  .split-row { grid-template-columns: 1fr 110px 30px; }
  .split-row input[data-k="label"] { grid-column: 1 / -1; }
}

/* elementos com o atributo hidden sempre somem, mesmo com display definido */
[hidden] { display: none !important; }
.gauge-empty { display: grid; place-items: center; font-size: 34px; font-weight: 700; color: var(--muted); aspect-ratio: 1.7; border: 2px dashed var(--line-strong); border-radius: 999px 999px 12px 12px; }
.gauge-empty span { font-size: 11px; font-weight: 500; margin-top: -18px; }

/* ============ Planejador: perfil, plano, tarefas, resumo diário, voz ============ */
:root { --s4: #eda100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s4: #c98500; } }
:root[data-theme="dark"] { --s4: #c98500; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-opt input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.chip-opt span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 99px; font-size: 13px; cursor: pointer; background: var(--surface); color: var(--ink-2); }
.chip-opt span:hover { border-color: var(--ink-2); }
.chip-opt input:checked + span { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.chip-opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.interview { max-width: 860px; }
.iv-title { font-size: 18px; letter-spacing: -0.015em; margin-bottom: 4px; }
.iv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.profile-strip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.profile-strip .info { flex: 1; min-width: 0; }
.profile-strip .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-status { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--ink-2); flex-wrap: wrap; }
.plan-status svg { color: var(--accent); }
.plan-status.on { background: var(--good-soft); }
.plan-status.on svg { color: var(--pos); }
.plan-status span { flex: 1; min-width: 220px; }

.money-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.money-bar i { display: block; height: 100%; }
.money-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 6px; font-size: 13px; }
.money-legend div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.money-legend .dot { width: 9px; height: 9px; border-radius: 3px; }
.alloc-list { margin-top: 14px; border-top: 1px solid var(--line); }
.alloc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alloc .info { flex: 1; min-width: 0; }
.alloc-n { width: 24px; height: 24px; border-radius: 50%; background: var(--good-soft); color: var(--pos); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.plan-notes { margin-top: 12px; display: grid; gap: 6px; }
.plan-notes p { font-size: 13px; color: var(--ink-2); }
.plan-notes svg, .trade svg, .brief-tip svg { vertical-align: -3px; margin-right: 4px; color: var(--accent); }

.goal-plan { padding: 12px 0; border-top: 1px solid var(--line); }
.goal-plan:first-child { border-top: 0; padding-top: 0; }
.trade { margin-top: 6px; color: var(--ink); background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; }
.sim-goal { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sim-goal input { width: 100px; height: 28px; }
.sim-out b { color: var(--pos); }

.task-list { display: grid; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task .t-title { flex: 1; min-width: 0; font-size: 13.5px; }
.task .t-due { font-size: 12px; white-space: nowrap; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task.overdue { background: linear-gradient(90deg, var(--neg-soft), transparent 60%); }
.task .icon-btn { opacity: .4; }
.task:hover .icon-btn { opacity: 1; }
.mem-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.mem-row span { flex: 1; }

.briefing { padding: 14px 18px; border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.brief-head b { font-size: 15px; }
.brief-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.brief-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brief-list li svg { color: var(--muted); }
.brief-list a { color: var(--accent); font-size: 12.5px; }
.brief-tip { margin-top: 10px; }

.mic-btn.listening { color: #fff; background: var(--neg); animation: pulse 1s infinite; }
.composer .mic-btn { height: 32px; width: 32px; flex: none; }

@media (max-width: 820px) {
  .iv-grid, .money-legend { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) { .iv-grid { grid-template-columns: 1fr; } }

/* ============ Impressão / salvar em PDF ============ */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; }
  .sidebar, .topbar .actions, .no-print, #toast, dialog, .help, .segmented, .quick-entry { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  .panel { box-shadow: none; break-inside: avoid; border-color: #ddd; }
  .grid { gap: 10px; }
  .g-main, .g-3, .g-2, .g-4 { grid-template-columns: 1fr 1fr; }
}

/* celular: o menu rola sozinho em vez de alargar a página */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; }
  .sidebar #nav { min-width: 0; flex: 1; overflow-x: auto; overflow-y: hidden; }
  .sidebar-foot { display: none; }
}
@media (max-width: 820px) {
  .panel.hero[style] { grid-template-columns: 1fr 1fr !important; }
  .panel.hero[style] > div:nth-child(odd) { border-left: 0; }
  .panel.hero[style] > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .panel.hero[style] { grid-template-columns: 1fr !important; }
  .panel.hero[style] > div + div { border-left: 0; border-top: 1px solid var(--line); }
}

.segmented.sm { flex-wrap: wrap; max-width: 100%; }

.notice.warn { flex-wrap: nowrap; align-items: flex-start; }
.notice.warn svg { flex: none; margin-top: 2px; }
