/* ============================================================
   Herança & Aluguéis — identidade navy · ciano · dourado
   ============================================================ */
:root, [data-theme="dark"] {
  --bg: #07101f;
  --bg2: #0c1f42;
  --glass: rgba(255, 255, 255, .055);
  --glass-2: rgba(255, 255, 255, .09);
  --stroke: rgba(255, 255, 255, .10);
  --text: #eef3ff;
  --muted: #93a4c6;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, .14);
  --gold: #f5c451;
  --gold-soft: rgba(245, 196, 81, .15);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, .14);
  --input: rgba(255, 255, 255, .06);
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --glowA: rgba(34, 211, 238, .20);
  --glowB: rgba(245, 196, 81, .12);
  --navy-ink: #0a1730;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f6fc;
  --bg2: #e3ebf8;
  --glass: rgba(255, 255, 255, .72);
  --glass-2: rgba(255, 255, 255, .95);
  --stroke: rgba(10, 23, 48, .08);
  --text: #0a1730;
  --muted: #5b6b8a;
  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, .10);
  --gold: #b7860b;
  --gold-soft: rgba(245, 196, 81, .22);
  --red: #e11d48;
  --red-soft: rgba(225, 29, 72, .08);
  --input: rgba(10, 23, 48, .04);
  --shadow: 0 10px 30px rgba(10, 23, 48, .08);
  --glowA: rgba(8, 145, 178, .12);
  --glowB: rgba(245, 196, 81, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh;
  font-family: 'Sora', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 15px; line-height: 1.45;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--cyan); text-decoration: none; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.neg { color: var(--red) !important; }

.glow { position: fixed; z-index: -1; border-radius: 50%; filter: blur(80px); pointer-events: none; }
.g1 { width: 420px; height: 420px; background: var(--glowA); top: -120px; right: -120px; }
.g2 { width: 480px; height: 480px; background: var(--glowB); bottom: -160px; left: -160px; }

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--cyan), #2563eb 55%, var(--gold) 130%);
  color: #fff; box-shadow: 0 6px 20px rgba(34, 211, 238, .25);
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 11px; }
.brand-mark.sm .ic { width: 18px; height: 18px; }
.brand.big .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.brand.big strong { font-size: 19px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--stroke);
}
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar-title small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.topbar-title strong { display: block; font-size: 17px; }

.content {
  max-width: 760px; margin: 0 auto;
  padding: 16px 16px calc(110px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.sidebar { display: none; }

.bottombar {
  position: fixed; z-index: 30; left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 6px; border-radius: 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
}
.bottombar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--muted); padding: 6px 10px; border-radius: 14px; min-width: 60px;
}
.bottombar a.on { color: var(--cyan); }
.bottombar a.on:not(.fab) { background: var(--cyan-soft); }
.bottombar .fab {
  width: 56px; height: 56px; min-width: 0; border-radius: 18px; margin-top: -28px; justify-content: center;
  background: linear-gradient(135deg, var(--gold), #f59e0b); color: var(--navy-ink);
  box-shadow: 0 10px 28px rgba(245, 196, 81, .4);
}
.bottombar .fab .ic { width: 26px; height: 26px; stroke-width: 2.4; }

@media (min-width: 960px) {
  body { padding-left: 280px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
  .topbar .brand-mark, .topbar .icon-btn { display: none; }
  .bottombar { display: none; }
  .content { padding: 28px 32px 48px; max-width: 980px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 22px;
    position: fixed; top: 16px; bottom: 16px; left: 16px; width: 248px;
    padding: 22px 16px; border-radius: 26px; z-index: 40;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar nav a {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px;
    color: var(--muted); font-weight: 500;
  }
  .sidebar nav a:hover { background: var(--glass-2); color: var(--text); }
  .sidebar nav a.on { background: var(--cyan-soft); color: var(--cyan); }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
  .side-foot > * { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; }
  .kpis { grid-template-columns: repeat(3, 1fr) !important; }
  .kpi.wide { grid-column: auto !important; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}

/* ---------- Tema toggle ---------- */
.t-light { display: none; }
[data-theme="light"] .t-dark { display: none; }
[data-theme="light"] .t-light { display: inline-flex; }
.t-dark, .t-light { align-items: center; gap: 8px; }
.theme-toggle { font: inherit; }

/* ---------- Botões ---------- */
.btn, .ghost, .icon-btn, .chip, .mini {
  font: inherit; cursor: pointer; border: 0; color: inherit; background: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 16px; font-weight: 600; font-size: 15px;
  transition: transform .12s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--cyan), #2563eb); color: #fff; box-shadow: 0 8px 22px rgba(37, 99, 235, .3); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #f59e0b); color: var(--navy-ink); box-shadow: 0 8px 22px rgba(245, 158, 11, .28); }
.btn.ghost, .ghost { background: var(--glass-2); color: var(--text); border: 1px solid var(--stroke); }
.btn.danger-ghost { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .6; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--text);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--text); font-size: 13px; font-weight: 500;
}
.chip .ic { width: 16px; height: 16px; color: var(--gold); }
.mini {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: var(--cyan-soft); color: var(--cyan);
}
.mini .ic { width: 16px; height: 16px; }
.mini.on { background: var(--cyan); color: var(--navy-ink); }

/* ---------- Mês ---------- */
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-pick {
  flex: 1; position: relative; text-align: center; padding: 10px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--stroke); font-weight: 600; font-size: 16px;
}
.month-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { border-radius: 22px; padding: 16px; position: relative; overflow: hidden; }
.kpi.wide { grid-column: 1 / -1; }
.kpi small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.kpi strong { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.kpi.wide strong { font-size: 28px; }
.kpi-ic {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 11px;
  display: grid; place-items: center; background: var(--glass-2);
}
.kpi-ic .ic { width: 17px; height: 17px; }
.kpi.in .kpi-ic { color: var(--cyan); background: var(--cyan-soft); }
.kpi.out .kpi-ic { color: var(--red); background: var(--red-soft); }
.kpi.net { background: linear-gradient(135deg, var(--gold-soft), var(--glass)); }
.kpi.net .kpi-ic { color: var(--gold); background: var(--gold-soft); }
.kpi.net strong { color: var(--gold); }

.report-cta { padding: 15px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick form { margin: 0; }

/* ---------- Cards ---------- */
.card { border-radius: 24px; padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 16px; font-weight: 600; }
.card-head h2 .ic { color: var(--gold); }
.card-head h2.in .ic { color: var(--cyan); }
.card-head h2.out .ic { color: var(--red); }

.empty { border-radius: 24px; padding: 24px; text-align: center; }
.empty > .ic { width: 36px; height: 36px; color: var(--gold); }

/* ---------- Divisão ---------- */
.shares { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.shares li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--stroke); }
.shares li:first-child { border-top: 0; }
.share-who { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.share-who > div { min-width: 0; }
.share-who strong { display: block; }
.share-who small { display: block; color: var(--muted); font-size: 12px; }
.share-val { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.share-val form { margin: 0; }
.share-val strong { font-size: 17px; color: var(--gold); white-space: nowrap; }
.shares li.paid .avatar { background: var(--cyan); color: var(--navy-ink); }
.avatar {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: var(--gold-soft); color: var(--gold); font-weight: 700;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 18px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--glass-2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag .ic { width: 14px; height: 14px; }
.tag.ok { background: var(--cyan-soft); color: var(--cyan); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }

/* ---------- Listas ---------- */
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { border-top: 1px solid var(--stroke); }
.entries li:first-child { border-top: 0; }
.entries li.inactive { opacity: .55; }
.entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; color: var(--text); }
a.entry[href]:active { background: var(--glass-2); }
.entry > div { min-width: 0; }
.entry strong { display: block; font-weight: 600; font-size: 14.5px; }
.entry small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry b { white-space: nowrap; font-size: 15px; }
.entry b.in { color: var(--cyan); }
.entry b.out { color: var(--red); }
.city-split { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.city-split span { font-size: 12px; color: var(--muted); padding: 5px 10px; border-radius: 999px; background: var(--glass-2); }
.city-split b { color: var(--text); }

.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-list > * {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.menu-list > * > .ic:first-child, .menu-list .t-dark .ic, .menu-list .t-light .ic { color: var(--gold); }
.menu-list > * > div { flex: 1; }
.menu-list strong { display: block; }
.menu-list small { display: block; color: var(--muted); font-size: 12px; }
.menu-list > * > .ic:last-child { color: var(--muted); }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.form label.check input { width: 20px; height: 20px; accent-color: var(--cyan); }
.opt { font-weight: 400; }
input, select, textarea {
  font: inherit; font-size: 16px; /* evita zoom no iPhone */
  color: var(--text); background: var(--input);
  border: 1px solid var(--stroke); border-radius: 14px; padding: 12px 14px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
[data-theme="dark"] select option { background: #0c1f42; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.actions .btn { flex: 1; }
@media (min-width: 600px) { .actions .btn { flex: none; } }

.money-in { position: relative; }
.money-in span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money-in input { padding-left: 44px; }
.amount .money-in input { font-size: 30px; font-weight: 700; padding: 16px 16px 16px 54px; letter-spacing: -.02em; }
.amount .money-in span { font-size: 18px; left: 18px; }
.entry-form[data-type="in"] .amount input { color: var(--cyan); }
.entry-form[data-type="out"] .amount input { color: var(--red); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; border-radius: 18px; background: var(--input); border: 1px solid var(--stroke); }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; border-radius: 13px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg input:checked + span { background: var(--glass-2); color: var(--text); box-shadow: var(--shadow); }
.seg .in input:checked + span { color: var(--cyan); }
.seg .out input:checked + span { color: var(--red); }
.seg.sm span { padding: 8px; font-size: 13px; }

.ben-row { display: grid; grid-template-columns: 1fr 120px 42px; gap: 8px; align-items: center; margin-bottom: 8px; }
.pct-in { position: relative; }
.pct-in input { padding-right: 30px; text-align: right; }
.pct-in span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pct-total { text-align: right; color: var(--muted); }
.pct-total b { color: var(--cyan); }
.pct-total b.bad { color: var(--red); }

.danger-zone { margin: 0; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 16px; font-size: 14px; font-weight: 500; transition: opacity .4s, transform .4s; }
.flash.ok { background: var(--cyan-soft); color: var(--cyan); border: 1px solid color-mix(in srgb, var(--cyan) 30%, transparent); }
.flash.err { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.flash.hide { opacity: 0; transform: translateY(-6px); pointer-events: none; height: 0; padding: 0; margin: -7px 0; border: 0; overflow: hidden; }

/* ---------- Histórico ---------- */
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .in::before { background: var(--cyan); }
.legend .out::before { background: var(--red); }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; height: 160px; align-items: end; margin: 8px 0 16px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; color: var(--muted); }
.bar-col small { font-size: 10px; }
.bar-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar { width: 42%; max-width: 14px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bar.in { background: linear-gradient(var(--cyan), color-mix(in srgb, var(--cyan) 50%, transparent)); }
.bar.out { background: linear-gradient(var(--red), color-mix(in srgb, var(--red) 50%, transparent)); }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: right; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 6px; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { text-align: right; padding: 10px 6px; border-top: 1px solid var(--stroke); white-space: nowrap; }
.tbl tr { cursor: pointer; }
.tbl td.in { color: var(--cyan); }
.tbl td.out { color: var(--red); }

/* ---------- Relatório ---------- */
.report-card { display: flex; flex-direction: column; gap: 14px; }
.report-stage { border-radius: 18px; overflow: hidden; background: var(--input); min-height: 300px; display: grid; place-items: center; }
.report-stage img { width: 100%; height: auto; display: block; }
.report-loading { color: var(--muted); padding: 40px; }
.report-stage:not(.busy) .report-loading { display: none; }
.report-stage.busy img { opacity: .4; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Login ---------- */
body.auth { display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; border-radius: 28px; padding: 28px 22px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { margin: 6px 0 0; font-size: 24px; letter-spacing: -.02em; }
.auth-card p { margin: 0; }
.auth-card .theme-toggle { align-self: center; padding: 8px 14px; border-radius: 999px; font-size: 13px; display: inline-flex; gap: 8px; cursor: pointer; }
