:root {
  --bg: #0b1020;
  --bg-soft: #121a31;
  --surface: #161f3a;
  --surface-2: #1d2747;
  --border: #25304f;
  --text: #e7ecf6;
  --text-dim: #93a0bd;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, .15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, .15);
  --amber: #f59e0b;
  --cyan: #06b6d4;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
[data-theme="light"] {
  --bg: #eef2fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4fb;
  --border: #dce3f2;
  --text: #14213d;
  --text-dim: #5b6884;
  --shadow: 0 10px 30px rgba(20,33,61,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; max-width: 100%; overflow-x: clip; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-x: none;
}
img, svg, canvas { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }

/* ---------- PUBLIC HOME ---------- */
.public-home {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(11,16,32,.96), rgba(18,26,49,.92)),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.04) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 72px 72px, 72px 72px;
}
.public-nav {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 0 36px;
}
.public-name {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: .3px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.public-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 17px; }
.public-brand span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
}
.public-actions, .public-cta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.public-hero {
  min-height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(420px, 1.05fr);
  align-items: center;
  gap: 38px;
  padding: 28px 7vw 70px;
}
.public-copy h1 {
  max-width: 760px;
  font-size: 54px;
  line-height: 1.02;
  letter-spacing: 0;
  margin-bottom: 18px;
}
.public-copy p {
  max-width: 620px;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1.55;
  margin-bottom: 26px;
}
.public-map {
  position: relative;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(99,102,241,.16), transparent 34%),
    var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.public-map::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--border) 50%, transparent) 1px, transparent 1px),
    linear-gradient(0deg, color-mix(in srgb, var(--border) 50%, transparent) 1px, transparent 1px);
  background-size: 54px 54px;
  opacity: .65;
}
.map-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  z-index: 3;
}
.map-node {
  position: absolute;
  z-index: 2;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  font-weight: 800;
}
.map-node.n1 { left: 12%; top: 18%; }
.map-node.n2 { right: 12%; top: 22%; }
.map-node.n3 { left: 16%; bottom: 19%; }
.map-node.n4 { right: 15%; bottom: 17%; }
.map-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36%;
  height: 1px;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, rgba(6,182,212,.85), rgba(99,102,241,.12));
  z-index: 1;
}
.map-line.l1 { transform: rotate(220deg); }
.map-line.l2 { transform: rotate(315deg); }
.map-line.l3 { transform: rotate(140deg); }
.map-line.l4 { transform: rotate(40deg); }

/* ---------- AUTH ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(11,16,32,.96), rgba(18,26,49,.94)),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.04) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 72px 72px, 72px 72px;
}
.auth-wrap::before {
  content: "";
  position: absolute;
  inset: -35%;
  background:
    linear-gradient(115deg, transparent 38%, rgba(99,102,241,.16) 45%, rgba(6,182,212,.12) 51%, transparent 60%);
  animation: authSheen 14s ease-in-out infinite alternate;
}
.auth-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.16));
  pointer-events: none;
}
.auth-bg-line {
  position: absolute;
  width: 58vw;
  max-width: 720px;
  height: 1px;
  top: 23%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(129,140,248,.55), rgba(6,182,212,.35), transparent);
  animation: authLine 6s ease-in-out infinite;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 82%, rgba(255,255,255,.16));
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: 0 24px 70px rgba(0,0,0,.36);
  backdrop-filter: blur(16px);
}
.auth-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}
.auth-brand { text-align: center; color: var(--text); font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.auth-card h1 { font-size: 24px; text-align: center; margin: 6px 0 4px; letter-spacing: 0; }
.auth-card .sub { text-align: center; color: var(--text-dim); margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-dim); }
.auth-switch a { color: var(--primary-2); font-weight: 600; cursor: pointer; }
.auth-link { display: block; margin: 12px auto 0; background: transparent; color: var(--primary-2); font-weight: 700; }
.error-msg { background: var(--red-dim); color: #fecaca; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.success-msg { background: var(--green-dim); color: #bbf7d0; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }

@keyframes authSheen {
  from { transform: translateX(-8%) translateY(-4%); }
  to { transform: translateX(8%) translateY(4%); }
}
@keyframes authLine {
  0%, 100% { opacity: .35; transform: translateX(-50%) scaleX(.82); }
  50% { opacity: .9; transform: translateX(-50%) scaleX(1); }
}

/* ---------- LAYOUT ---------- */
.layout {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh;
  transition: grid-template-columns .2s ease;
}
.layout.sidebar-collapsed { grid-template-columns: 76px 1fr; }
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: padding .2s ease, width .2s ease;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 22px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 800; font-size: 18px; padding: 0 8px; }
.brand .logo { font-size: 24px; }
.brand-title, .nav-label, .logout-label, .user-chip .meta { transition: opacity .15s ease; }
.sidebar-collapse {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-dim);
  font-size: 20px; line-height: 1;
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--text-dim); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0;
}
.user-chip .meta { overflow: hidden; }
.user-chip .meta .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta .em { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout.sidebar-collapsed .sidebar { padding: 22px 10px; }
.layout.sidebar-collapsed .brand-row { justify-content: center; padding-bottom: 22px; }
.layout.sidebar-collapsed .brand { justify-content: center; padding: 0; }
.layout.sidebar-collapsed .brand-title,
.layout.sidebar-collapsed .nav-label,
.layout.sidebar-collapsed .logout-label,
.layout.sidebar-collapsed .user-chip .meta {
  opacity: 0; width: 0; overflow: hidden; pointer-events: none;
}
.layout.sidebar-collapsed .sidebar-collapse {
  position: absolute; top: 54px; right: -14px; z-index: 2;
  background: var(--surface-2);
}
.layout.sidebar-collapsed .nav-item {
  justify-content: center; gap: 0; padding: 11px; min-height: 42px;
}
.layout.sidebar-collapsed .nav-item .ic { width: 18px; }
.layout.sidebar-collapsed .sidebar-foot { display: flex; flex-direction: column; align-items: center; }
.layout.sidebar-collapsed .user-chip { justify-content: center; padding: 8px 0; }
.layout.sidebar-collapsed #logout-btn {
  width: 42px; height: 36px; padding: 0; margin-left: auto; margin-right: auto;
}
.logout-ic { line-height: 1; }
.layout.sidebar-collapsed .notif-badge {
  position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px;
  padding: 0 4px; font-size: 10px;
}

.main { min-width: 0; max-width: 100vw; padding: 26px 30px 50px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.topbar h2 { font-size: 24px; font-weight: 800; }
.topbar .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); }
select.year-select { padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; font-weight: 600; }

/* ---------- KPI CARDS ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; position: relative; overflow: hidden;
}
.kpi .label { color: var(--text-dim); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 8px; }
.kpi .ic { position: absolute; right: 14px; top: 14px; font-size: 20px; opacity: .85; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.kpi.green .ic { background: var(--green-dim); }
.kpi.red .ic { background: var(--red-dim); }
.kpi.blue .ic { background: rgba(99,102,241,.15); }
.kpi.amber .ic { background: rgba(245,158,11,.15); }
.kpi.invest .ic { background: rgba(6,182,212,.15); }
.kpi .value.pos { color: var(--green); }
.kpi .value.neg { color: var(--red); }
.receivable { color: var(--green); font-weight: 800; }
.payable { color: var(--red); font-weight: 800; }

/* ---------- CHART GRID ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.card .chart-box { position: relative; height: 260px; }
.card .chart-box.tall { height: 300px; }
.wealth-goal { display: flex; align-items: center; height: 260px; }
.wealth-goal-track {
  position: relative; width: 100%; height: 54px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.wealth-goal-fill {
  height: 100%; background: linear-gradient(90deg, var(--cyan), var(--primary));
  transition: width .6s ease;
}
.wealth-goal-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--text); font-weight: 800; font-size: 18px;
}
.debt-progress-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.debt-progress-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 13px; margin-bottom: 10px; flex-wrap: wrap;
}
.debt-progress-head strong { color: var(--text); font-size: 14px; }
.debt-progress-track {
  height: 18px; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
}
.debt-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width .55s ease;
}
.debt-selected-meta {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  margin-bottom: 12px; color: var(--text-dim); font-size: 12px;
}
.debt-selected-meta strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 3px; }
.debt-pct {
  flex-shrink: 0; color: var(--amber); font-weight: 800;
  background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.28);
  border-radius: 8px; padding: 5px 8px;
}

/* ---------- TABLE ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input, .toolbar select {
  padding: 9px 12px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; font-size: 13px;
}
.toolbar input.search { min-width: 220px; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 13px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-dim); background: var(--surface-2); font-weight: 700;
  white-space: nowrap;
}
thead th.right { text-align: right; }
.sort-th {
  display: inline-flex; align-items: center; gap: 6px; width: 100%;
  border: 0; background: transparent; color: inherit; padding: 0;
  font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}
thead th.right .sort-th { justify-content: flex-end; }
.sort-th:hover, .sort-th.active { color: var(--text); }
.sort-arrow { width: 12px; color: var(--text-dim); font-size: 10px; }
tbody td { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.selected-row { background: rgba(99,102,241,.12); }
tbody tr.asset-row { box-shadow: inset 4px 0 0 var(--asset-color); background: color-mix(in srgb, var(--asset-color) 6%, transparent); }
tbody tr.asset-row:hover { background: color-mix(in srgb, var(--asset-color) 12%, var(--surface-2)); }
td.amount { font-weight: 700; text-align: right; white-space: nowrap; }
td.amount.in { color: var(--green); }
td.amount.out { color: var(--red); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge { padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge.in { background: var(--green-dim); color: var(--green); }
.badge.out { background: var(--red-dim); color: var(--red); }
.badge.invest { background: rgba(6,182,212,.15); color: var(--cyan); }
td.amount.invest { color: var(--cyan); }
.badge.pago { background: rgba(99,102,241,.15); color: var(--primary-2); }
.badge.pendente { background: rgba(245,158,11,.15); color: var(--amber); }
.badge.reference { background: rgba(148,163,184,.14); color: var(--text-dim); margin-left: 4px; }
.badge.monthly { background: rgba(6,182,212,.15); color: var(--cyan); margin-left: 4px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); width: 30px; height: 30px; border-radius: 8px; }
.row-actions button:hover { color: var(--text); }
.row-actions button.monthly.active { background: rgba(6,182,212,.15); border-color: rgba(6,182,212,.45); color: var(--cyan); }
.row-actions button.collection-note.active { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.45); color: var(--amber); }
.collection-summary { margin-bottom: 16px; }
.collection-period-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid rgba(99,102,241,.35); border-radius: 12px; background: rgba(99,102,241,.1); }
.collection-period-banner span { color: var(--text-dim); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.collection-period-banner strong { color: var(--primary-2); }
.collection-period-banner small { margin-left: auto; color: var(--text-dim); }
.collection-period-chip { display: inline-flex; margin: 0 0 8px; padding: 3px 8px; border-radius: 999px; background: rgba(99,102,241,.14); color: var(--primary-2); font-size: 11px; font-weight: 700; }
.collection-total { font-size: 20px; }
.collection-message-cell { width: 110px; }
.copy-note-btn { min-width: 86px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.copy-note-btn:hover { border-color: var(--primary); color: var(--primary); }
.copy-note-source { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; opacity: 0; }
.collection-company-grid { display: grid; gap: 18px; }
.collection-company-card { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.collection-company-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.collection-company-head h3 { margin: 0 0 8px; font-size: 18px; }
.collection-company-contact { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--text-dim); font-size: 12px; }
.collection-company-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.collection-company-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.collection-items { padding: 0 20px 16px; }
.collection-item { display: grid; grid-template-columns: minmax(220px, 1fr) 110px 130px 80px; align-items: center; gap: 14px; min-height: 54px; border-bottom: 1px solid var(--border); font-size: 13px; }
.collection-item-heading { min-height: 42px; color: var(--text-dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.collection-item small { display: block; margin-top: 4px; color: var(--text-dim); }
.collection-item .amount { text-align: right; font-weight: 700; }
.collection-item-actions { display: flex; justify-content: flex-end; gap: 6px; }
.collection-item-actions .icon-btn { width: 30px; height: 30px; font-size: 13px; }
.collection-company-total { display: flex; justify-content: flex-end; align-items: center; gap: 30px; padding: 16px 80px 0 0; }
.collection-company-total span { color: var(--text-dim); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.collection-company-total strong { min-width: 130px; text-align: right; color: var(--green); font-size: 18px; }
.collection-no-items { padding: 28px 0 12px; text-align: center; color: var(--text-dim); }
.collection-empty { border: 1px dashed var(--border); border-radius: 14px; background: var(--surface); }
.collection-empty p { margin: 8px 0 18px; }
.collection-empty-icon { margin-bottom: 8px; font-size: 34px; }
.collection-assignment-preview { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text-dim); line-height: 1.8; }
@media (max-width: 760px) {
  .collection-period-banner { align-items: flex-start; flex-direction: column; }
  .collection-period-banner small { margin-left: 0; }
  .collection-company-head { flex-direction: column; }
  .collection-company-actions { width: 100%; flex-wrap: wrap; }
  .collection-item-heading { display: none; }
  .collection-item { grid-template-columns: 1fr auto; gap: 8px; padding: 12px 0; }
  .collection-item > :nth-child(2) { justify-self: start; }
  .collection-item .amount { justify-self: end; grid-column: 2; grid-row: 1; }
  .collection-item-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .collection-company-total { padding-right: 0; justify-content: space-between; }
}
.row-actions button:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { background: transparent; color: var(--primary-2); font-weight: 700; text-align: left; }
.link-btn:hover { color: var(--text); }
.amount-action { color: inherit; font: inherit; padding: 0; text-align: right; width: 100%; }
.amount-action:hover { color: var(--primary-2); }
.editable-amount { cursor: text; border-radius: 8px; padding: 2px 4px; }
.editable-amount:hover { background: var(--surface-2); }
.inline-money-input {
  width: 120px;
  max-width: 100%;
  padding: 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-align: right;
  outline: none;
}
.period-list { display: flex; gap: 10px; flex-wrap: wrap; }
.period-chip {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); min-width: 170px;
}
.period-chip span { color: var(--text-dim); font-size: 12px; font-weight: 600; }
.period-chip.active { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent); }
.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 13px;
}
.pager-actions { display: flex; align-items: center; gap: 10px; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.tag-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; margin: 1px; }
.empty { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.sheet-paste {
  min-height: 150px;
  resize: vertical;
  line-height: 1.45;
}
.import-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.template-box { display: flex; flex-direction: column; gap: 12px; }
.import-preview { margin-top: 16px; }
.preview-summary {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-dim); background: var(--surface-2);
}
.preview-summary strong { color: var(--text); }
.preview-summary span { color: var(--red); font-weight: 800; }
.inline-select {
  min-width: 150px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.cc-bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.cc-bulkbar select { min-width: 190px; }
.cc-check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; font-weight: 700; }
tr.cc-categorized { background: color-mix(in srgb, #e5e7eb 18%, transparent); opacity: .78; }
tr.cc-categorized:hover { background: color-mix(in srgb, #e5e7eb 26%, var(--surface-2)); opacity: 1; }
.cc-dashboard {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  margin-bottom: 16px;
}
.cc-metric {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.cc-metric span { color: var(--text-dim); font-size: 12px; font-weight: 700; }
.cc-metric strong { color: var(--text); font-size: 20px; letter-spacing: 0; }
.cc-metric.warn strong { color: var(--amber); }
@media (max-width: 900px) {
  .cc-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .cc-dashboard { grid-template-columns: 1fr; }
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,8,18,.65); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 100;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); font-weight: 600; }
.seg button.active.in { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.seg button.active.out { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.seg button.active.invest { background: rgba(6,182,212,.15); color: var(--cyan); border-color: var(--cyan); }
.seg button.active.pago { background: rgba(99,102,241,.15); color: var(--primary-2); border-color: var(--primary); }
.seg button.active.pendente { background: rgba(245,158,11,.15); color: var(--amber); border-color: var(--amber); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-picker .opt { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; font-size: 13px; }
.tag-picker .opt.sel { color: #fff; }

/* ---------- SETTINGS ---------- */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.settings-tabs button {
  padding: 9px 14px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-dim); font-weight: 700;
}
.settings-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-accordion { padding: 0; overflow: hidden; }
.settings-accordion-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.settings-accordion-head:hover { background: var(--surface-2); }
.settings-accordion-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.settings-accordion-title .swatch { width: 18px; height: 18px; border-radius: 6px; flex-shrink: 0; }
.settings-accordion-title strong { display: block; font-size: 15px; font-weight: 800; }
.settings-accordion-title small {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}
.settings-accordion-meta { display: inline-flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 12px; font-weight: 800; white-space: nowrap; }
.settings-accordion-meta .chevron { font-size: 18px; line-height: 1; transition: transform .18s ease; }
.settings-accordion.open .settings-accordion-meta .chevron { transform: rotate(180deg); }
.settings-accordion-body { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.cat-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.cat-row .swatch { width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0; }
.cat-row .nm { flex: 1; font-weight: 600; }
.cat-row button { background: transparent; color: var(--text-dim); }
.cat-row button:hover { color: var(--red); }
.dashboard-chart-option { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 600; cursor: pointer; }
.dashboard-chart-option input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.add-cat { display: flex; gap: 8px; margin-top: 12px; }
.add-cat input[type=text] { flex: 1; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; }
.add-cat input[type=color] { width: 42px; height: 38px; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.custom-goals-section { margin-bottom: 4px; }
.custom-goals-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.custom-goals-head h3 { font-size: 17px; margin-bottom: 4px; }
.custom-goals-head p { font-size: 13px; }
.custom-goals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 14px; }
.custom-goal-empty { display: flex; flex-direction: column; gap: 6px; }
.custom-goal-card { border-top: 3px solid var(--goal-color); }
.custom-goal-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.custom-goal-card-head h3 { margin-bottom: 5px; font-size: 16px; }
.custom-goal-card-head .muted { font-size: 12px; }
.custom-goal-progress { height: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; margin: 18px 0 10px; }
.custom-goal-progress span { display: block; height: 100%; border-radius: inherit; background: var(--goal-color); transition: width .4s ease; }
.custom-goal-values { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.custom-goal-values strong { color: var(--goal-color); font-size: 20px; }
.custom-goal-values span { color: var(--text-dim); font-size: 12px; text-align: right; }
.custom-goals-chart { min-height: 220px; height: min(420px, calc(90px + 54px * var(--goal-count, 3))); }

/* ---------- FULL ADMIN ---------- */
.admin-grid { display: grid; grid-template-columns: minmax(420px, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.admin-topology-card { overflow: hidden; }
.admin-topology {
  position: relative;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--border) 48%, transparent) 1px, transparent 1px),
    linear-gradient(0deg, color-mix(in srgb, var(--border) 48%, transparent) 1px, transparent 1px),
    var(--surface-2);
  background-size: 48px 48px;
  overflow: hidden;
  touch-action: none;
}
.admin-app-node {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150px;
  height: 86px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid color-mix(in srgb, var(--primary) 70%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--primary));
  box-shadow: var(--shadow);
  z-index: 3;
}
.admin-app-node strong { font-size: 22px; letter-spacing: 0; }
.admin-app-node span { color: var(--text-dim); font-size: 12px; font-weight: 700; }
.admin-user-node {
  position: absolute;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
  z-index: 4;
  cursor: grab;
  user-select: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.admin-user-node small {
  position: absolute; right: -7px; bottom: -5px;
  min-width: 20px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 9px; line-height: 1; font-weight: 900;
}
.admin-user-node:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(6,182,212,.12), 0 8px 20px rgba(0,0,0,.2);
}
.admin-user-node.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.08);
  z-index: 6;
}
.admin-user-node.admin {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(245,158,11,.12);
}
.admin-topology-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
}
/* Linhas de conexão estilo Zabbix: pontilhadas, neon e com fluxo do sistema → usuário.
   A cor indica há quanto tempo o usuário fez login (ver loginStatus em admin.js). */
.admin-topology-lines line {
  fill: none;
  stroke-width: var(--link-width, 2px);
  opacity: var(--link-opacity, .7);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 10;
  animation: topology-flow var(--link-speed, 1s) linear infinite, topology-pulse calc(var(--link-speed, 1s) * 2.4) ease-in-out infinite alternate;
}
/* O fluxo desloca os pontos do centro (APP) em direção ao nó do usuário. */
@keyframes topology-flow {
  to { stroke-dashoffset: -26; }
}
@keyframes topology-pulse {
  from { opacity: .25; }
  to { opacity: var(--link-opacity, .7); }
}
/* Azul neon — login recente (menos de ~20 dias) */
.topology-link--fresh {
  stroke: #22e0ff;
  filter: drop-shadow(0 0 3px #22e0ff) drop-shadow(0 0 6px rgba(34,224,255,.55));
}
/* Amarelo neon — inativo há mais de 20 dias */
.topology-link--idle {
  stroke: #eaff00;
  filter: drop-shadow(0 0 3px #eaff00) drop-shadow(0 0 6px rgba(234,255,0,.5));
}
/* Vermelho neon — inativo há mais de 3 meses (ou nunca acessou) */
.topology-link--stale {
  stroke: #ff2d6b;
  filter: drop-shadow(0 0 3px #ff2d6b) drop-shadow(0 0 7px rgba(255,45,107,.55));
  animation-duration: 1.6s;
}
@media (prefers-reduced-motion: reduce) {
  .admin-topology-lines line { animation: none; }
}
.admin-user-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; padding-right: 4px; }
.admin-user-pill {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}
.admin-user-pill:hover { border-color: var(--primary); }
.admin-user-pill span { font-weight: 800; }
.admin-user-pill small { color: var(--text-dim); font-weight: 700; }
.admin-menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field-label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; font-weight: 700; }
.danger-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--border));
  border-radius: 8px;
  background: var(--red-dim);
}
.danger-panel strong { color: var(--text); }
.danger-panel span { color: var(--text-dim); font-size: 13px; }

/* ---------- TOAST ---------- */
#toast-root { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { padding: 13px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 600; animation: slidein .25s ease; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 900px) {
  .public-hero { grid-template-columns: 1fr; padding: 18px 22px 44px; }
  .public-copy h1 { font-size: 38px; }
  .public-map { min-height: 380px; }
  .layout, .layout.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .25s; width: 240px; }
  .sidebar.open { left: 0; }
  .layout.sidebar-collapsed .sidebar { padding: 22px 16px; }
  .layout.sidebar-collapsed .brand-row { justify-content: space-between; padding-bottom: 22px; }
  .layout.sidebar-collapsed .brand { justify-content: flex-start; padding: 0 8px; }
  .layout.sidebar-collapsed .brand-title,
  .layout.sidebar-collapsed .nav-label,
  .layout.sidebar-collapsed .logout-label,
  .layout.sidebar-collapsed .user-chip .meta {
    opacity: 1; width: auto; overflow: visible; pointer-events: auto;
  }
  .layout.sidebar-collapsed .sidebar-collapse { position: static; }
  .layout.sidebar-collapsed .nav-item { justify-content: flex-start; gap: 11px; padding: 11px 12px; }
  .layout.sidebar-collapsed .sidebar-foot { display: block; }
  .layout.sidebar-collapsed .user-chip { justify-content: flex-start; padding: 8px; }
  .layout.sidebar-collapsed #logout-btn { width: 100%; height: auto; padding: 7px 11px; }
  .layout.sidebar-collapsed .notif-badge { position: static; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; }
  .grid.cols-2, .grid.cols-3, .settings-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-topology { height: 340px; }
  .menu-toggle { display: grid !important; }
}
@media (max-width: 560px) {
  .public-nav { padding: 0 16px; }
  .public-brand { font-size: 14px; }
  .public-copy h1 { font-size: 32px; }
  .public-map { min-height: 330px; }
  .map-core { width: 100px; height: 100px; font-size: 22px; }
  .map-node { font-size: 12px; padding: 9px 10px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 40px; }
}

/* ---------- MOBILE / PWA ---------- */
@media (max-width: 900px) {
  .layout { min-height: 100dvh; }
  .main {
    width: 100%;
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
  .sidebar {
    height: 100dvh;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    box-shadow: 14px 0 35px rgba(0, 0, 0, .38);
  }
  .sidebar:not(.open) { box-shadow: none; }
  .card, .table-card, .toolbar, .topbar, .bulk-bar { min-width: 0; max-width: 100%; }
  .scroll-x {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .settings-tabs {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }
  .settings-tabs button { flex: 0 0 auto; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  button, .btn, .icon-btn, select, input, textarea { font-size: 16px; }
  .main {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .topbar { margin-bottom: 16px; gap: 10px; flex-wrap: nowrap; }
  .topbar h2 { min-width: 0; font-size: 21px; }
  .topbar .actions { flex-wrap: nowrap; margin-left: auto; }
  .topbar .btn { min-height: 44px; padding-inline: 12px; }
  .icon-btn { width: 44px; height: 44px; flex: 0 0 44px; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar input.search { grid-column: 1 / -1; min-width: 0; width: 100%; }
  .toolbar select { min-width: 0; width: 100%; min-height: 44px; }
  .kpi, .card { padding: 15px; }
  .kpi .value { padding-right: 34px; font-size: 21px; overflow-wrap: anywhere; }
  .card .chart-box, .card .chart-box.tall { height: 230px; }
  .wealth-goal { height: 210px; }
  .modal-overlay {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    align-items: end;
  }
  .modal {
    max-width: none !important;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)));
    border-radius: 18px 18px 10px 10px;
  }
  .modal-head { padding: 14px 16px; position: sticky; top: 0; z-index: 2; background: var(--surface); }
  .modal-body { padding: 16px; }
  .modal-foot {
    position: sticky; bottom: 0; z-index: 2; padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--surface);
  }
  .modal-foot .btn { flex: 1; min-height: 44px; }
  .seg { gap: 6px; }
  .seg button { min-height: 46px; padding: 8px 5px; font-size: 13px; }
  .field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 44px; }
  .due-row input[type=date] { min-width: 0; flex-basis: 100%; }
  .notify-toggle { min-height: 40px; white-space: normal; }
  .settings-accordion-head { padding: 14px; }
  .custom-goals-head { align-items: stretch; flex-direction: column; }
  .custom-goals-head .btn { min-height: 44px; }
  .custom-goals-grid { grid-template-columns: 1fr; }
  .settings-accordion-title small { overflow-wrap: anywhere; }
  .settings-accordion-meta > span:first-child { display: none; }
  .settings-accordion-body { padding: 0 12px 14px; }
  .add-cat { display: grid; grid-template-columns: 44px minmax(0, 1fr); }
  .add-cat .btn { grid-column: 1 / -1; min-height: 44px; }
  .cat-row { padding: 9px; gap: 7px; }
  .cat-row .nm { min-width: 0; overflow-wrap: anywhere; }
  .bulk-bar .btn { min-height: 40px; }
  .notif-item { align-items: flex-start; flex-direction: column; }
  .ni-side { width: 100%; align-items: flex-start; }
  .admin-menu-grid { grid-template-columns: 1fr; }
  .admin-topology { height: 300px; }
  .public-hero { padding-inline: 16px; }
  .public-map { min-height: 290px; }
  #toast-root {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .toast { width: 100%; }
}
.menu-toggle { display: none; }
.hidden { display: none !important; }

/* ---------- NOTIFICAÇÕES ---------- */
.notif-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
#notif-bell { cursor: pointer; }
.due-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.due-row input[type=date] {
  flex: 1; min-width: 150px; padding: 11px 13px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text); outline: none;
}
.notify-toggle { display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text-dim); font-weight: 600; cursor: pointer; font-size: 13px; }
.notify-toggle input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.due-tag { display: inline-block; margin-top: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.due-tag.over { background: var(--red-dim); color: var(--red); }
.due-tag.today { background: rgba(245,158,11,.15); color: var(--amber); }
.due-tag.soon { background: rgba(99,102,241,.15); color: var(--primary-2); }
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-item {
  position: relative;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 14px 13px 22px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; border-left: 3px solid var(--text-dim);
}
.notif-item.over { border-left-color: var(--red); }
.notif-item.today { border-left-color: var(--amber); }
.notif-item.soon { border-left-color: var(--primary); }
.notif-item.read { opacity: .62; }
.unread-dot { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.ni-title { font-weight: 600; }
.ni-meta { display: flex; gap: 8px; align-items: center; margin-top: 5px; flex-wrap: wrap; font-size: 12px; }
.ni-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.ni-amount { font-weight: 700; color: var(--red); white-space: nowrap; }
.ni-actions { display: flex; gap: 6px; }
.notif-group { margin-bottom: 22px; }
.notif-group-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.muted { color: var(--text-dim); }
.scroll-x { overflow-x: auto; }

/* Edição inline na tabela de lançamentos */
td.editable, td.snap-editable { cursor: text; position: relative; }
td.editable:hover, td.snap-editable:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); box-shadow: inset 0 0 0 1px var(--primary); }
td.editing { background: transparent; }
.inline-editor {
  width: 100%;
  min-width: 90px;
  box-sizing: border-box;
  padding: 6px 8px;
  margin: -4px 0;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 6px;
  outline: none;
}

/* Seleção múltipla / ação em massa */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--primary); border-radius: 10px;
}
.bulk-count { font-size: 14px; }
.bulk-label { color: var(--text-dim); font-size: 13px; margin-left: 6px; }
.chk-col { width: 34px; text-align: center; }

/* Caixa de seleção customizada — discreta e moderna */
.chk-col input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 17px;
  height: 17px;
  margin: 0;
  vertical-align: middle;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.chk-col input[type="checkbox"]:hover {
  border-color: var(--primary-2);
}
.chk-col input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}
.chk-col input[type="checkbox"]:checked,
.chk-col input[type="checkbox"]:indeterminate {
  background: var(--primary);
  border-color: var(--primary);
}
/* Marca de seleção (✓) */
.chk-col input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  border-radius: 1px;
  transform: rotate(45deg);
}
/* Estado indeterminado (traço) */
.chk-col input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 6.5px;
  width: 9px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

tr.row-selected > td { background: color-mix(in srgb, var(--primary) 10%, transparent); }
