:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --line: #dfddd5;
  --text: #171715;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --accent: #0f6b57;
  --accent-ink: #ffffff;
  --series-income: #2a78d6;
  --series-expense: #eb6834;
  --series-seq: #2a78d6;
  --good: #0e7a4f;
  --warn: #99630a;
  --bad: #c13232;
  --grid: #e7e5de;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #252523;
    --line: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #a3a297;
    --accent: #3fb79a;
    --accent-ink: #08201a;
    --series-income: #3987e5;
    --series-expense: #d95926;
    --series-seq: #3987e5;
    --good: #4cc08f;
    --warn: #e0aa4a;
    --bad: #ef7f7f;
    --grid: #2b2b28;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

.nav {
  position: sticky; top: 0; height: 100vh; padding: 20px 12px; display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; line-height: 1.15; padding: 0 8px; }
.brand small { font-weight: 500; color: var(--text-2); font-size: 13px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 800; }
.brand-mark.has-photo { background: none; overflow: hidden; border-radius: 50%; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-photo { display: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.account-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; }
.empty-photo { display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.account-person { font-size: 14px; font-weight: 550; margin-top: 1px; }
.nav-user-name { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.nav-user-name > span { color: var(--text); font-weight: 600; }
.nav-user-name small { font-size: 12px; }
.channel { border: 0; padding: 0; min-width: 0; }
.channel legend { padding: 0; margin-bottom: 4px; }
.channel-row { display: flex; gap: 8px; }
.channel-row label { flex: 1; cursor: pointer; position: relative; }
.channel-row input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.channel-row span { display: block; text-align: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-weight: 550; background: var(--bg); }
.channel-row input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.channel-row input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 550; cursor: pointer; }
.check-line input { width: 18px; height: 18px; flex: none; }
.check-line small { font-weight: 400; color: var(--text-2); }
.hint-block { margin: 5px 0 12px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 12px; }
.auth-links:not(:has(button:not([hidden]))) { display: none; }
.link-btn { background: none; border: 0; padding: 2px; color: var(--text); font-size: 13.5px; text-decoration: underline; cursor: pointer; }
#tabs { display: flex; flex-direction: column; gap: 2px; }
#tabs button { text-align: left; background: none; border: 0; border-radius: 8px; padding: 9px 12px; color: var(--text-2); font-weight: 500; }
#tabs button:hover { background: var(--surface-2); }
#tabs button.active { background: var(--surface-2); color: var(--text); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.service-status { margin-top: auto; font-size: 12.5px; color: var(--text-2); display: grid; gap: 5px; padding: 0 8px; }
.service-status span::before { content: "✓ "; color: var(--good); font-weight: 700; }
.service-status span.off::before { content: "○ "; color: var(--text-3); }

main { padding: 22px 28px 60px; min-width: 0; max-width: 1240px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.topbar h1 { font-size: 24px; letter-spacing: -0.02em; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.month-nav, .segmented { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.month-nav button { background: none; border: 0; width: 34px; height: 32px; border-radius: 7px; font-size: 18px; color: var(--text-2); }
.month-nav button:hover { background: var(--surface-2); }
.month-nav strong { min-width: 138px; text-align: center; font-weight: 600; font-size: 14px; }
.segmented button { background: none; border: 0; padding: 5px 13px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 14px; }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 650; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 650; }
.card .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.stat .label { color: var(--text-2); font-size: 13px; }
.stat .value { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat .note { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.stat.hero { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stat.hero .label, .stat.hero .note { color: inherit; opacity: 0.9; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 13px; font-weight: 550; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--text); display: inline-block; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; min-width: 290px; }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--text-2); font-size: 12px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--text); fill-opacity: 0.05; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
details.table-view { margin-top: 10px; font-size: 13px; color: var(--text-2); }
details.table-view summary { cursor: pointer; }

.hbars { display: grid; gap: 11px; }
.hbar-row { display: grid; gap: 4px; }
.hbar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.hbar-label strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-seq); min-width: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-2); font-weight: 550; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .muted { color: var(--text-2); font-size: 12.5px; }
.income { color: var(--good); font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }

.status { font-size: 13px; font-weight: 600; white-space: nowrap; }
.status.paga { color: var(--good); }
.status.pendente { color: var(--warn); }
.status.atrasada { color: var(--bad); }

.bill-list { display: grid; gap: 2px; }
.bill-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.bill-row:last-child { border-bottom: 0; }
.bill-row > div:first-child { min-width: 0; }
.bill-row .status { white-space: normal; }
.bill-row .amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.projects { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.progress { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.progress div { height: 100%; background: var(--accent); border-radius: 99px; }
.project-figures { display: flex; justify-content: space-between; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.project-plan { margin: 12px 0; padding: 9px 11px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; }

.report { white-space: pre-wrap; font-size: 14.5px; }
.report b { font-weight: 650; }
.empty { color: var(--text-2); text-align: center; padding: 26px 12px; }
.notice { background: var(--surface-2); border-radius: 9px; padding: 11px 13px; font-size: 13.5px; margin-bottom: 12px; color: var(--text-2); }

.chat { display: flex; flex-direction: column; height: min(66vh, 640px); padding: 0; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: min(78%, 560px); padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
.chat-form input[type=text] { flex: 1; min-width: 0; padding: 9px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.file-btn { cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 20px; width: min(450px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
.field { display: grid; gap: 4px; margin-bottom: 11px; font-size: 13.5px; font-weight: 550; }
.field input, .field select { padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-weight: 400; font-size: 15px; width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field .hint { font-weight: 400; color: var(--text-2); font-size: 12.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form-error { color: var(--bad); font-size: 13.5px; margin-bottom: 8px; }

body.auth-page { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; }
.auth-card { width: min(410px, 100%); padding: 24px; }
.auth-card .brand { padding: 0; margin-bottom: 18px; }
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.auth-card form { margin-top: 14px; }
.nav-user { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 0 8px; }
.nav-user button { background: none; border: 0; color: var(--text-2); text-decoration: underline; padding: 0; font-size: 13px; }
.copy-box { display: flex; gap: 8px; margin-top: 8px; }
.copy-box input { flex: 1; min-width: 0; padding: 7px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.mic-btn.recording { background: var(--bad); border-color: var(--bad); color: #fff; }
.pass-wrap { position: relative; display: block; }
.pass-wrap input { padding-right: 76px; }
.pass-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 5px 7px; color: var(--accent); font-size: 13px; font-weight: 600; }
.help-steps { margin: 0 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.mic-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.mic-row select { flex: 1 1 180px; min-width: 0; padding: 5px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.mic-meter { flex: 0 1 110px; height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.mic-meter div { width: 0; height: 100%; background: var(--accent); }

.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--bg); padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--bg); padding: 9px 15px; border-radius: 10px; font-size: 14px; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  body { display: block; padding-bottom: 62px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; padding: 4px; border-right: 0; border-top: 1px solid var(--line); z-index: 10; }
  .nav .brand, .service-status, .nav-user { display: none; }
  #tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  #tabs button { padding: 10px 11px; font-size: 13.5px; white-space: nowrap; flex: none; }
  #tabs button.active { box-shadow: inset 0 -3px 0 var(--accent); }
  main { padding: 16px 16px 30px; }
  .topbar h1 { font-size: 21px; }
  .page-title { width: 100%; }
  .top-photo:not([hidden]) { display: block; }
  .card-head:has(.account-id) { flex-direction: column; align-items: flex-start; }
  .filters { width: 100%; justify-content: space-between; }
  .month-nav strong { min-width: 112px; font-size: 13px; }
  .month-nav button { width: 28px; }
  .segmented button { padding: 5px 9px; }
  .stat .value { font-size: 20px; }
  .card { padding: 14px; }
  .hide-mobile { display: none; }
  .toolbar input { min-width: 0; width: 100%; }
  .chat { height: calc(100vh - 230px); }
  /* No celular, cada linha da tabela vira um pequeno cartão: nome e valor em cima, detalhes embaixo. */
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { padding: 0; border: 0; }
  table.stack .t-main { order: 1; flex: 1 1 50%; min-width: 0; font-weight: 550; }
  table.stack .t-value { order: 2; margin-left: auto; font-weight: 650; }
  table.stack tr::before { content: ""; order: 3; flex-basis: 100%; height: 0; } /* quebra de linha */
  table.stack .t-date { order: 4; color: var(--text-2); font-size: 13px; }
  table.stack .t-tag { order: 5; }
  table.stack .t-status { order: 6; }
  table.stack .t-actions { order: 7; margin-left: auto; }
}

/* Conta: dados em um painel e opções em lista, uma embaixo da outra. */
.account-card { margin-bottom: 14px; }
.settings-card { margin-bottom: 14px; padding: 8px 8px 6px; }
.settings-title { font-size: 17px; padding: 8px 10px 6px; }
.setting-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 10px; background: none; border: 0; border-radius: 8px; color: var(--text); text-align: left; text-decoration: none; font-size: 15px; font-weight: 550; cursor: pointer; }
.setting-row:hover { background: var(--surface-2); }
.setting-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.setting-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.setting-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.setting-text small { font-size: 12.5px; font-weight: 400; color: var(--text-2); }
.setting-chevron { color: var(--text-2); display: grid; flex: none; }
.setting-row.danger, .setting-row.danger .setting-icon { color: var(--bad); }

/* Dívidas: faixa de meses */
.month-strip { display: flex; align-items: stretch; gap: 6px; margin-bottom: 14px; }
.strip-scroll { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; padding-bottom: 3px; flex: 1; min-width: 0; }
.strip-chip { flex: 0 0 auto; scroll-snap-align: center; display: grid; gap: 1px; justify-items: center; min-width: 74px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.strip-chip span { font-weight: 650; font-size: 14px; }
.strip-chip span::first-letter { text-transform: uppercase; }
.strip-chip small { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.strip-chip.now { border-color: var(--accent); }
.strip-chip.late small { color: var(--bad); font-weight: 650; }
.strip-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.strip-chip.active small { color: inherit; opacity: 0.9; }
.strip-arrow { flex: 0 0 auto; width: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 18px; }
.status.cartao { color: var(--text-2); }

/* Dívidas: calendário */
.cal-head h2 { font-size: 15px; margin: 0 0 10px; }
.cal-head h2::first-letter { text-transform: uppercase; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-weekday { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 2px 0; }
.cal-cell { min-height: 86px; display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); text-align: left; min-width: 0; cursor: pointer; }
.cal-cell.blank { border: 0; background: none; cursor: default; }
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.has { background: var(--surface); }
.cal-cell.late { border-color: var(--bad); }
.cal-num { font-size: 13px; font-weight: 650; }
.cal-item { font-size: 11.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--warn); padding-left: 4px; }
.cal-item.paga { border-color: var(--good); color: var(--text-2); text-decoration: line-through; }
.cal-item.atrasada { border-color: var(--bad); }
.cal-item.cartao { border-color: var(--text-2); }
.cal-more { font-size: 11px; color: var(--text-2); }
.cal-total { margin-top: auto; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-cell.late .cal-total { color: var(--bad); }
.cal-cell.done .cal-total { color: var(--good); }
.cal-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--text-2); }
.day-list { display: grid; gap: 8px; margin-bottom: 14px; }
.day-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); font-size: 14px; }
.day-item .muted { color: var(--text-2); font-size: 12.5px; }
.day-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.form-sub { font-size: 14px; margin: 0 0 10px; }
@media (max-width: 720px) {
  .cal-cell { min-height: 54px; padding: 4px; }
  .cal-item, .cal-more { display: none; }
  .cal-cell.has::after { content: ''; width: 6px; height: 6px; border-radius: 99px; background: var(--warn); align-self: center; }
  .cal-cell.late::after { background: var(--bad); }
  .cal-cell.done::after { background: var(--good); }
  .cal-total { font-size: 10.5px; text-align: center; }
  .strip-arrow { display: none; }
  .strip-chip { min-width: 64px; }
}
