:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #080808;
  --ink-2: #3f4642;
  --muted: #84908a;
  --line: #e7e5dd;
  --brand: #16a34a;
  --brand-2: #22c55e;
  --brand-soft: #e7f8ed;
  --red: #d9443f;
  --red-soft: #fbe9e8;
  --amber: #c98a0c;
  --amber-soft: #fbf1db;
  --side: #080808;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 20, 17, .04), 0 8px 24px rgba(11, 20, 17, .05);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 'DM Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pos { color: var(--brand); } .neg { color: var(--red); }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-2); color: #080808; font-weight: 800; font-size: 14px; letter-spacing: -.04em; }
.brand.big .logo { width: 44px; height: 44px; font-size: 18px; border-radius: 13px; }
.brand.big { font-size: 24px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--side); color: #e9efe9; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 20px; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; width: 520px; height: 520px; right: -200px; bottom: -220px; border-radius: 50%; background: radial-gradient(circle, rgba(34,197,94,.22), transparent 65%); }
.auth-side h1 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: clamp(34px, 4vw, 54px); line-height: 1.05; letter-spacing: -.01em; margin: 12px 0 0; }
.auth-side h1 em { font-style: normal; color: var(--brand-2); }
.auth-side p { color: #a9b6af; max-width: 440px; font-size: 16px; }
.auth-bubbles { display: flex; flex-direction: column; gap: 8px; max-width: 360px; margin-top: 8px; z-index: 1; }
.bub { padding: 9px 13px; border-radius: 14px; font-size: 14px; width: fit-content; max-width: 90%; }
.bub.in { background: #1a1a1a; border-top-left-radius: 4px; }
.bub.out { background: #14532d; align-self: flex-end; border-top-right-radius: 4px; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 96px); max-width: 560px; width: 100%; margin: 0 auto; }
.auth-card h2 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: 34px; margin: 0 0 20px; }
.auth.login .reg-only { display: none; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { padding: 32px 24px; } .auth-bubbles { display: none; } }

/* ---------- Formulários ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; outline: none; transition: border .15s, box-shadow .15s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 0 0 8px; }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.btn { font: inherit; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform .05s, background .15s; white-space: nowrap; }
.btn:hover { background: #fafaf7; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #1f1f1f; }
.btn.accent { background: var(--brand-2); border-color: var(--brand-2); color: #080808; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.full { width: 100%; justify-content: center; padding: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.seg { display: inline-flex; background: #ecebe4; border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-weight: 600; font-size: 13px; border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg.type button.on[data-v=expense] { color: var(--red); }
.seg.type button.on[data-v=income] { color: var(--brand); }

/* ---------- Layout do app ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: #dfe7e2; padding: 22px 14px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 10px; color: #fff; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: #a3a3a3; font-weight: 600; font-size: 14.5px; }
#nav a i { font-style: normal; width: 20px; text-align: center; font-size: 16px; }
#nav a:hover { background: #151515; color: #fff; }
#nav a.on { background: #161f19; color: #fff; box-shadow: inset 2px 0 0 var(--brand-2); }
#nav a.on i { color: var(--brand-2); }
.side-foot { margin-top: auto; font-size: 13px; color: #a3a3a3; padding: 12px; border-radius: 12px; background: #121212; }
.side-foot b { color: #fff; display: block; }
.wa-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--amber); }
.wa-dot.on { background: #38d996; }

main { padding: 30px clamp(18px, 3vw, 40px) 60px; min-width: 0; max-width: 1280px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: 32px; letter-spacing: -.005em; margin: 0; line-height: 1.1; }
.head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.month-pick { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.month-pick span { min-width: 128px; text-align: center; font-weight: 700; font-size: 14px; }
.month-pick button { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; color: var(--ink-2); }
.month-pick button:hover { background: #f1f0ea; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: -.01em; display: flex; justify-content: space-between; align-items: center; }
.panel h3 a { font-size: 13px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(4, 1fr); }
.g-2 { grid-template-columns: 1.35fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .g-kpi { grid-template-columns: repeat(2, 1fr); } .g-2 { grid-template-columns: 1fr; } .g-3 { grid-template-columns: 1fr 1fr; } }

.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 8px; }
.kpi.hero { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi.hero .label { color: #a3a3a3; }
.kpi.hero .value { color: var(--brand-2); }
.bar { height: 7px; border-radius: 9px; background: #ecebe4; overflow: hidden; margin-top: 12px; }
.bar > div { height: 100%; background: var(--brand); border-radius: 9px; }
.bar.warn > div { background: var(--amber); } .bar.over > div { background: var(--red); }
.kpi .foot { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.chart-wrap { position: relative; height: 240px; }
.donut-row { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
@media (max-width: 560px) { .donut-row { grid-template-columns: 1fr; } }

/* Listas */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: #f1f0ea; font-size: 17px; }
.item .t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12.5px; color: var(--muted); }
.item .r { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: #f1f0ea; color: var(--ink-2); }
.chip.green { background: var(--brand-soft); color: var(--brand); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.wa { background: #e1f7e9; color: #128c4a; }

/* Tabela */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; padding: 9px 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fbfbf8; }
.table td.r, .table th.r { text-align: right; }
.table .row-actions { opacity: 0; transition: opacity .15s; white-space: nowrap; }
.table tr:hover .row-actions { opacity: 1; }
.totals { display: flex; gap: 22px; font-size: 14px; color: var(--ink-2); margin: 4px 0 14px; flex-wrap: wrap; }
.totals b { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .table thead { display: none; }
  .table tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 2px 4px; }
  .table td.hide-m { display: none; }
  .table .row-actions { opacity: 1; grid-column: 1 / -1; }
}

/* Cartões */
.ccards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.cc { border-radius: 18px; padding: 20px; color: #fff; min-height: 172px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; cursor: pointer; box-shadow: 0 10px 30px rgba(11,20,17,.15); }
.cc::after { content: ''; position: absolute; width: 240px; height: 240px; border-radius: 50%; right: -90px; top: -110px; background: rgba(255,255,255,.12); }
.cc .top { display: flex; justify-content: space-between; font-weight: 700; z-index: 1; }
.cc .amt { font-size: 26px; font-weight: 700; z-index: 1; }
.cc .meta { display: flex; justify-content: space-between; font-size: 12.5px; opacity: .9; z-index: 1; }
.cc .bar { background: rgba(255,255,255,.25); z-index: 1; } .cc .bar > div { background: #fff; }
.cc-add { border: 2px dashed var(--line); border-radius: 18px; min-height: 172px; display: grid; place-items: center; color: var(--muted); font-weight: 700; cursor: pointer; background: transparent; font: inherit; }
.cc-add:hover { border-color: var(--brand); color: var(--brand); }
.mini-cc { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.mini-cc:first-child { border-top: 0; }
.mini-cc .sw { width: 38px; height: 26px; border-radius: 6px; }
.colors { display: flex; gap: 8px; margin-bottom: 14px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors button.on { border-color: var(--ink); }

/* Chat */
.chat { display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - 150px); min-height: 480px; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: #f7f6f1; border-bottom: 1px solid var(--line); }
.chat-head .logo { width: 40px; height: 40px; border-radius: 50%; }
.chat-body { overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 8px;
  background: #efeae2 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23d9d2c5'/%3E%3C/svg%3E"); }
.msg { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: 12px; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg.in { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 3px; }
.msg.out { background: #fff; align-self: flex-start; border-top-left-radius: 3px; }
.msg time { display: block; text-align: right; font-size: 11px; color: #8a9a92; margin-top: 2px; }
.msg img { max-width: 220px; border-radius: 8px; display: block; margin-bottom: 4px; }
.typing { align-self: flex-start; background: #fff; padding: 10px 14px; border-radius: 12px; font-size: 20px; letter-spacing: 2px; color: var(--muted); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #f7f6f1; align-items: center; }
.chat-input input[type=text] { border-radius: 22px; padding: 11px 16px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; font-size: 19px; flex: none; color: var(--ink-2); display: grid; place-items: center; }
.icon-btn:hover { background: #ebe9e1; }
.icon-btn.send { background: var(--brand); color: #fff; }
.icon-btn.rec { background: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px 10px; background: #f7f6f1; }
.suggest button { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 11px; cursor: pointer; color: var(--ink-2); }

/* Ajustes */
.code-box { font-family: var(--mono); font-size: 34px; letter-spacing: .25em; font-weight: 700; background: var(--brand-soft); color: var(--brand); border-radius: 14px; padding: 16px; text-align: center; margin: 12px 0; }
.steps { padding-left: 18px; color: var(--ink-2); font-size: 14px; } .steps li { margin-bottom: 6px; }

/* Modal / toast */
.modal { position: fixed; inset: 0; background: rgba(11, 20, 17, .45); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal-box { background: #fff; border-radius: 20px; padding: 24px; width: min(520px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: 0 30px 80px rgba(0,0,0,.25); animation: pop .16s ease-out; }
.modal-box h2 { margin: 0 0 18px; font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: 24px; display: flex; justify-content: space-between; align-items: center; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.amount-input { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; padding: 14px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Mobile: menu embaixo */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 40; flex-direction: row; }
  .sidebar .brand, .side-foot { display: none; }
  #nav { flex-direction: row; width: 100%; justify-content: space-around; }
  #nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; text-align: center; }
  main { padding: 20px 14px 96px; }
  .g-kpi { grid-template-columns: 1fr 1fr; } .g-3 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
  .chat { height: calc(100dvh - 210px); min-height: 420px; }
  .suggest { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .suggest button { flex: none; }
  #nav a span { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}
