/* Organização Financeira — tokens da paleta validada (dataviz) + UI */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #fff;
  --good: #006300;
  --danger: #d03b3b;
  --s0: #898781;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --bia: #e87ba4;      /* magenta — Beatriz */
  --victor: #2a78d6;   /* azul — Victor */
  --shadow: 0 1px 3px rgba(11,11,11,.08), 0 6px 24px rgba(11,11,11,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good: #0ca30c;
    --danger: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --bia: #d55181;
    --victor: #3987e5;
    --shadow: none;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--baseline);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); margin: 8px 0; }
.lbl { font-size: 13px; color: var(--ink-2); display: block; margin: 8px 0 4px; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; margin-top: 6px; }

/* ===== login ===== */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(rgba(20, 15, 5, 0.18), rgba(20, 15, 5, 0.38)),
    url('img/capa.jpg') center / cover no-repeat;
}
.login-card {
  width: 100%; max-width: 360px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 32px 24px; text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 26px; line-height: 1.15; margin: 8px 0 4px; }
.login-sub { color: var(--muted); margin-bottom: 20px; }
.user-pills { display: flex; gap: 8px; margin-bottom: 12px; }
.pill {
  flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--ink); font-weight: 600;
}
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#login-pass { margin-bottom: 12px; text-align: center; }
.btn-primary {
  width: 100%; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700;
}
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: 12px; padding: 12px 18px; font-weight: 600; }

/* ===== shell ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  font-weight: 700; font-size: 18px;
  border-bottom: 1px solid var(--border);
}
.topbar-user { font-size: 13px; font-weight: 500; color: var(--muted); }
main { padding: 16px 16px 110px; max-width: 640px; margin: 0 auto; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; border: 0; background: none; color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.nav-btn span { font-size: 20px; }
.nav-btn.active { color: var(--accent); }
#fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 72px); z-index: 21;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-size: 30px; line-height: 1; box-shadow: var(--shadow);
}

/* ===== cards & tiles ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow);
}
.tile .t-label { font-size: 12px; color: var(--muted); }
.tile .t-value { font-size: 20px; font-weight: 750; margin-top: 2px; }
.tile .t-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tile.wide { grid-column: 1 / -1; }

/* ===== registro rápido ===== */
.quick { padding: 12px 14px; }
.qk-row { display: flex; gap: 8px; }
.qk-row input { flex: 1; font-size: 15px; }
.qk-prev { font-size: 13px; color: var(--ink-2); margin-top: 8px; min-height: 0; line-height: 1.5; }
.qk-prev b { color: var(--ink); }
.qk-prev a { color: var(--accent); font-weight: 600; }

/* ===== filtros de período ===== */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--baseline); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); }
.custom-range { display: flex; gap: 8px; margin-bottom: 10px; }
.custom-range label { flex: 1; margin: 0; }

/* ===== listas de lançamentos ===== */
.month-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 4px 8px; font-weight: 700; font-size: 15px;
}
.month-head small { color: var(--muted); font-weight: 600; }
.tx {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.tx .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tx .tx-main { flex: 1; min-width: 0; }
.tx .tx-desc { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .tx-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.tx .tx-val { font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx .tx-val.in { color: var(--good); }
.tx .tx-val.inv { color: var(--accent); }
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }

/* ===== gráficos ===== */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--page);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.35;
  transform: translate(-50%, calc(-100% - 8px)); white-space: nowrap;
  opacity: 0; transition: opacity .1s;
}
.chart-tip b { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .lv { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
svg text { font-family: inherit; }

/* ===== barras de progresso ===== */
.progress { background: var(--grid); border-radius: 999px; height: 12px; overflow: hidden; margin: 6px 0 2px; }
.progress > div { height: 100%; border-radius: 999px; }
.prog-row { margin-bottom: 12px; }
.prog-row .p-head { display: flex; justify-content: space-between; font-size: 13px; }
.prog-row .p-sub { font-size: 12px; color: var(--muted); }

/* ===== tabelas ===== */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: right; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--grid); padding: 6px 8px; white-space: nowrap;
}
table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr.clickable { cursor: pointer; }
.pct-bia { color: var(--bia); font-weight: 700; }
.pct-victor { color: var(--victor); font-weight: 700; }

/* ===== modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: grid; place-items: end center;
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--page); border-radius: 20px 20px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
}
@media (min-width: 640px) { .modal { place-items: center; } .modal-card { border-radius: 20px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { font-size: 18px; }
.icon-btn { border: 0; background: var(--surface); border-radius: 50%; width: 32px; height: 32px; color: var(--ink-2); }
.seg { display: flex; gap: 6px; margin: 8px 0; }
.seg button {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14px;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.split-quick { display: flex; gap: 6px; }
.split-quick button {
  flex: 1; font-size: 12px; padding: 8px 4px; border-radius: 8px;
  border: 1px solid var(--baseline); background: var(--surface); color: var(--ink-2);
}
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn-primary { flex: 1; }

/* ===== misc ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 140px);
  transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--page);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
.note-pj {
  font-size: 12.5px; color: var(--ink-2); background: color-mix(in srgb, var(--s4) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--s4) 35%, transparent);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px;
}
.mais-list { display: flex; flex-direction: column; gap: 8px; }
.mais-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; font-weight: 600; cursor: pointer;
}
.bill { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--grid); font-size: 14px; }
.bill:last-child { border-bottom: 0; }
.bill .b-status { font-size: 12px; font-weight: 700; }
.bill .paid { color: var(--good); }
.bill .pending { color: var(--muted); }
