/* ==========================================================================
   PEPETOS — design system (mobile-first)
   Sem frameworks, sem dependências externas. Tokens no :root.
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e8ebf2;
  --line-2: #d9deea;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8592a6;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef0ff;
  --primary-100: #e0e4ff;

  --pos: #059669;
  --pos-bg: #e8f8f1;
  --pos-line: #bfeedc;
  --neg: #e11d48;
  --neg-bg: #fff0f3;
  --neg-line: #fdc9d4;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --warn-line: #fde2a8;
  --info: #0369a1;
  --info-bg: #eaf6fd;
  --info-line: #bde3f7;

  --link: #4f46e5;
  --primary-h: #4338ca;
  --on-strong: #ffffff;
  --fill: #eef1f6;
  --fill-2: #eceff6;
  --raised: #ffffff;
  --hover: rgba(15, 23, 42, .06);
  --hover-2: rgba(15, 23, 42, .05);
  --line-3: #c5ccdc;
  --placeholder: #a3adbd;
  --track: #cdd4e1;
  --faint: #b8c1d2;
  --faint-2: #c7cee0;
  --pos-solid: #059669;
  --pos-solid-h: #047857;
  --neg-solid: #e11d48;
  --neg-solid-h: #be123c;
  --pos-text: #065f46;
  --neg-text: #9f1239;
  --info-text: #075985;
  --warn-text: #92400e;
  --neg-soft: #fffafb;
  --topbar-bg: rgba(255, 255, 255, .86);
  --bottom-bg: rgba(255, 255, 255, .94);
  --scrim: rgba(15, 23, 42, .5);
  --veil: rgba(255, 255, 255, .7);
  --ai-bg: rgba(255, 255, 255, .7);
  --skel-a: #eef0f6;
  --skel-b: #f6f7fb;
  --flash: #fff8d6;
  --auth-glow: #e4e7ff;
  --handle: #d3d9e6;
  --toast-bg: #111827;
  --ring: #ffffff;
  --rep-bg: #f3e8ff;
  --rep-fg: #7e22ce;
  --pdf-bg: #fff1f0;
  --pdf-fg: #dc2626;
  --pdf-line: #fcd0cc;
  --off-bg: #eaf3ff;
  --off-fg: #2563eb;
  --off-line: #c9defa;
  color-scheme: light;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --bottom-nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* -------------------------------------------------------------- reset/base -- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 24px; height: 24px; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.hide-mobile { display: none !important; }
.show-mobile { display: initial; }

/* ------------------------------------------------------------------ botões -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px; font-weight: 600; font-size: 15px; line-height: 1; text-decoration: none;
  background: var(--surface); color: var(--text); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  user-select: none; -webkit-user-select: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3), 0 6px 16px rgba(79, 70, 229, .22); }
.btn-primary:hover { background: var(--primary-h); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--line-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover-2); }
.btn-danger { background: var(--neg-solid); color: #fff; }
.btn-danger:hover { background: var(--neg-solid-h); }
.btn-danger-soft { background: var(--neg-bg); color: var(--neg); border-color: var(--neg-line); }
.btn-pos { background: var(--pos-solid); color: #fff; }
.btn-pos:hover { background: var(--pos-solid-h); }
.btn-neg { background: var(--neg-solid); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 12px; }
.btn-icon.btn-sm { width: 34px; min-height: 34px; }
.btn.is-loading::after {
  content: ""; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- formulários -- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--neg); font-weight: 500; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--neg); background: var(--neg-soft); }
.field-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field-sm { max-width: 110px; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface);
  font-size: 16px; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .13); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); }
.input-lg { min-height: 52px; font-size: 17px; }
.input-sm, .select-sm { min-height: 38px; font-size: 14px; border-radius: 10px; padding: 0 10px; }
.textarea { min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.select {
  padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238592a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select-sm { padding-right: 32px; }
input[type="date"].input { padding-right: 10px; min-width: 0; }
.input-money {
  font-size: 28px; font-weight: 700; letter-spacing: -.02em; min-height: 62px; padding-left: 52px; font-variant-numeric: tabular-nums;
}
.money-wrap { position: relative; }
.money-wrap::before {
  content: "R$"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--muted); font-size: 15px; pointer-events: none;
}
.input-group { display: flex; align-items: stretch; position: relative; }
.input-group .input { padding-right: 52px; }
.input-addon {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 44px; border: 0; background: transparent; color: var(--muted); border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.input-addon:hover { color: var(--text); background: var(--surface-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.checklist { list-style: none; padding: 0; margin: 12px 0; font-size: 13.5px; display: grid; gap: 4px; }
.checklist .ok { color: var(--pos); } .checklist .bad { color: var(--neg); font-weight: 600; } .checklist .warn { color: var(--warn); }

/* switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); cursor: pointer; min-height: 50px; }
.switch .sw-text { display: flex; flex-direction: column; font-weight: 600; font-size: 14.5px; }
.switch .sw-text small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .sw-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--track); transition: background .2s; flex: none; }
.switch .sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .sw-track { background: var(--pos); }
.switch input:checked + .sw-track::after { transform: translateX(18px); }
.switch input:focus-visible + .sw-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* segmented */
.seg { display: inline-flex; width: 100%; padding: 3px; background: var(--fill-2); border-radius: 12px; gap: 2px; }
.seg label { flex: 1 1 0; text-align: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; white-space: nowrap; }
.seg input:checked + span { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }
.seg.seg-pos input:checked + span { color: var(--pos); }
.seg.seg-neg input:checked + span { color: var(--neg); }
.seg-sm span { min-height: 34px; font-size: 13px; padding: 0 10px; }

/* ------------------------------------------------------------------ cards -- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 14px 18px 18px; }
.card-flush { padding: 0; overflow: hidden; }

.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--fill); color: var(--text-2); }
.badge-pos { background: var(--pos-bg); color: var(--pos); }
.badge-neg { background: var(--neg-bg); color: var(--neg); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-50); color: var(--primary-600); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; border: 1px solid; }
.alert-danger { background: var(--neg-bg); border-color: var(--neg-line); color: var(--neg-text); }
.alert-success { background: var(--pos-bg); border-color: var(--pos-line); color: var(--pos-text); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-text); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }

/* ------------------------------------------------------------ autenticação -- */
.auth-body { min-height: 100vh; min-height: 100dvh; background: radial-gradient(1200px 500px at 50% -10%, var(--auth-glow) 0%, transparent 60%), var(--bg); }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-wide .auth-card { max-width: 560px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 26px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-logo img { border-radius: 18px; box-shadow: 0 8px 24px rgba(79, 70, 229, .35); }
.auth-logo span { font-weight: 800; letter-spacing: .28em; font-size: 20px; padding-left: .28em; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin-top: -6px; }
.auth-title { text-align: center; font-size: 18px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------- shell -- */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); background: var(--surface); border-right: 1px solid var(--line); z-index: 70;
  display: flex; flex-direction: column; padding: calc(18px + var(--safe-t)) 14px calc(14px + var(--safe-b)); transform: translateX(-102%); transition: transform .25s ease;
}
.sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
.drawer-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
.brand b { font-weight: 800; letter-spacing: .24em; font-size: 15.5px; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 0 14px; border-radius: 12px; color: var(--text-2); font-weight: 600; font-size: 15px;
  position: relative; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--primary-50); color: var(--primary-600); }
.nav a.is-active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); }
.nav .nav-badge { margin-left: auto; background: var(--neg-solid); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
/* avatar: foto 500x500 (img) ou inicial colorida (span). Tamanho por --av (inline) ou .avatar-xs/-sm/-lg */
.avatar { --av: 38px; width: var(--av); height: var(--av); border-radius: 50%; background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; font-size: calc(var(--av) * .4); line-height: 1; overflow: hidden; user-select: none; vertical-align: middle; }
.avatar[data-c="1"] { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.avatar[data-c="2"] { background: linear-gradient(135deg, #10b981, #0d9488); }
.avatar[data-c="3"] { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.avatar[data-c="4"] { background: linear-gradient(135deg, #ec4899, #be185d); }
.avatar[data-c="5"] { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
img.avatar { object-fit: cover; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.avatar-xs { --av: 20px; } .avatar-sm { --av: 28px; } .avatar-md { --av: 34px; } .avatar-lg { --av: 96px; }
.user-chip .who { min-width: 0; line-height: 1.2; }
.user-chip .who b { display: block; font-size: 14.5px; }
.user-chip .who small { color: var(--muted); font-size: 12.5px; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 8px; height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) 12px 0;
  background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; gap: 9px; }
.topbar .brand img { width: 32px; height: 32px; border-radius: 9px; }
.topbar .brand b { font-size: 14px; }
.topbar-spacer { flex: 1; }
.icon-btn { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); }
.icon-btn .count { position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--neg-solid); color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.search { position: relative; flex: 1; max-width: 560px; display: none; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px 0 42px; font-size: 15px; }
.search input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.search.is-open { display: block; position: absolute; left: 12px; right: 12px; top: calc(var(--topbar-h) + var(--safe-t) - 10px); max-width: none; z-index: 45; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  max-height: min(70vh, 560px); overflow-y: auto; padding: 8px;
}
.sr-group { padding: 6px 8px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sr-item { display: block; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.sr-item:hover, .sr-item:focus { background: var(--primary-50); text-decoration: none; outline: none; }
.sr-item b { display: block; font-size: 14.5px; font-weight: 600; }
.sr-item small { color: var(--muted); font-size: 12.5px; }
.sr-empty { padding: 18px; text-align: center; color: var(--muted); }

.content { padding: 18px 16px calc(var(--bottom-nav-h) + var(--safe-b) + 36px); max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.subnav { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.subnav a:hover { text-decoration: none; border-color: var(--line-2); }
.subnav a.is-active { background: var(--text); color: var(--on-strong); border-color: var(--text); }

/* menu inferior (celular) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--bottom-nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bottom-bg); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.bottom-nav a, .bottom-nav button.bn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--bottom-nav-h); color: var(--muted);
  font-size: 11px; font-weight: 600; text-decoration: none; border: 0; background: transparent;
}
.bottom-nav a.is-active { color: var(--link); }
.bottom-nav .i { width: 23px; height: 23px; }
.fab-wrap { display: flex; justify-content: center; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff; display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 8px 22px rgba(79, 70, 229, .45); border: 4px solid var(--bg);
}
.fab .i { width: 26px; height: 26px; stroke-width: 2.4; }

/* menu suspenso / folha de ação */
.menu { position: absolute; z-index: 80; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu button, .menu a { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; font-size: 14.5px; font-weight: 600; color: var(--text); text-align: left; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu .danger { color: var(--neg); }
.menu hr { margin: 6px 4px; }

/* ----------------------------------------------------------------- modais -- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s; overscroll-behavior: contain;
}
.modal-backdrop.is-open { opacity: 1; }
.modal {
  width: 100%; max-height: 94vh; max-height: 94dvh; background: var(--surface); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(24px); transition: transform .22s ease; box-shadow: var(--shadow-lg); padding-bottom: var(--safe-b);
}
.modal-backdrop.is-open .modal { transform: none; }
.modal::before { content: ""; width: 38px; height: 4px; border-radius: 4px; background: var(--handle); margin: 8px auto 0; flex: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 10px; flex: none; }
.modal-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-body { padding: 4px 18px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; overscroll-behavior: contain; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex: none; background: var(--surface); }
.modal-foot .btn { flex: 1; }
.modal-foot .btn-ghost-left { flex: none; margin-right: auto; }
.modal-lg { }
.kind-pill { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 11px; flex: none; }
.kind-pill.in { background: var(--pos-bg); color: var(--pos); }
.kind-pill.out { background: var(--neg-bg); color: var(--neg); }
.modal-full .modal { max-height: 100dvh; height: 100dvh; border-radius: 0; }
.modal-full .modal::before { display: none; }
body.modal-open { overflow: hidden; }

/* toasts */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 14px); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 440px; width: 100%; padding: 13px 16px; border-radius: 14px; background: var(--toast-bg); color: #fff; font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); animation: toast-in .25s ease; }
.toast.success { background: #065f46; }
.toast.error { background: #9f1239; }
.toast.warn { background: #92400e; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------- lista de lançamentos -- */
.filters { margin-bottom: 14px; }
.filters-toggle { display: flex; }
.filters-body { display: none; padding: 14px 0 2px; }
.filters.is-open .filters-body { display: block; }
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters-grid .span-2 { grid-column: 1 / -1; }
.filters-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.filters-actions .btn { flex: 1 1 calc(50% - 8px); }
.summary-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }

.tx-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tx-head { display: none; }
.tx {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 4px 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer;
  background: var(--surface); position: relative;
}
.tx:last-child { border-bottom: 0; }
.tx:hover { background: var(--surface-2); }
.tx.is-flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: var(--flash); } 100% { background: var(--surface); } }
.tx-ico { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; grid-row: span 2; align-self: start; }
.tx-ico.in { background: var(--pos-bg); color: var(--pos); }
.tx-ico.out { background: var(--neg-bg); color: var(--neg); }
.tx-main { min-width: 0; }
.tx-desc { font-weight: 650; font-size: 15px; line-height: 1.3; }
.tx-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.tx-amount { text-align: right; font-weight: 800; font-size: 15.5px; white-space: nowrap; }
.tx-amount small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tx-extra { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.tx-cat, .tx-origin, .tx-acc, .tx-status, .tx-date, .tx-user { display: none; }
.tx-actions { display: none; }
.tx-pay { margin-left: auto; }
.tx.is-pending .tx-ico { background: var(--warn-bg); color: var(--warn); }
.tx.is-overdue .tx-ico { background: var(--neg-bg); color: var(--neg); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 4px 0; color: var(--text-2); font-size: 14px; }
.pager .btn { min-width: 44px; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .i { width: 40px; height: 40px; color: var(--faint); }
.empty b { color: var(--text); font-size: 16px; }
.empty-art { width: 120px; color: var(--faint-2); }
.skeleton { background: linear-gradient(90deg, var(--skel-a) 25%, var(--skel-b) 37%, var(--skel-a) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-row { height: 62px; margin: 10px 14px; }

/* ---------------------------------------------------------------- dashboard -- */
.dash { display: flex; flex-direction: column; gap: 14px; }
.dash > * { min-width: 0; }
.greet { display: flex; flex-direction: column; gap: 14px; }
.greet h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.greet p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick .btn { min-height: 48px; }
.quick .btn-doc { grid-column: 1 / -1; }
.dash-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.dash-filters .span-2 { grid-column: 1 / -1; }
.dash-filters .field > label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.period-note { font-size: 12.5px; color: var(--muted); }

.hero { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); color: #fff; border-radius: 22px; padding: 20px; position: relative; overflow: hidden; box-shadow: 0 14px 34px rgba(79, 70, 229, .32); }
.hero::after { content: ""; position: absolute; right: -40px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero .k { font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em; opacity: .85; font-weight: 600; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 4px 0 14px; }
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; z-index: 1; }
.hero-pill { background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 10px 12px; }
.hero-pill .k { font-size: 11.5px; display: flex; align-items: center; gap: 5px; }
.hero-pill .v { font-size: 17px; font-weight: 700; margin-top: 2px; }

.kpi { padding: 18px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .k { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; min-height: 20px; }
.kpi .spark { position: relative; height: 70px; margin: 10px -4px -4px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.delta.up { background: var(--pos-bg); color: var(--pos); }
.delta.down { background: var(--neg-bg); color: var(--neg); }
.delta.flat { background: var(--fill); color: var(--text-2); }
.delta.inverse.up { background: var(--neg-bg); color: var(--neg); }
.delta.inverse.down { background: var(--pos-bg); color: var(--pos); }
.balance-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.brow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--line); }
.brow:first-child { border-top: 0; padding-top: 0; }
.brow .nm { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.brow .amt { font-weight: 800; font-size: 15.5px; text-align: right; }
.brow .io { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.brow .bar { grid-column: 1 / -1; height: 5px; border-radius: 4px; background: var(--neg-bg); overflow: hidden; }
.brow .bar i { display: block; height: 100%; background: var(--pos); border-radius: 4px; }
.brow.total .nm { color: var(--primary-600); }

.chart-card .card-head { padding-bottom: 0; }
.chart-box { position: relative; height: 230px; padding: 10px 14px 14px; }
.chart-box.sm { height: 190px; }
.chart-box.lg { height: 260px; }
.chart-box canvas { max-width: 100%; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; background: var(--veil); }
.legend-list { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 2px; }
.lg-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 10px; cursor: pointer; font-size: 14px; border: 0; background: transparent; text-align: left; width: 100%; }
.lg-row:hover, .lg-row.is-active { background: var(--surface-2); }
.lg-row .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lg-row .vp { text-align: right; line-height: 1.25; }
.lg-row .vl { font-weight: 700; display: block; }
.lg-row .pc { color: var(--muted); font-size: 12px; display: block; }
.donut-wrap { position: relative; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center small { color: var(--muted); font-size: 12px; }
.donut-center b { font-size: 20px; letter-spacing: -.02em; }
.toggle-mini { display: inline-flex; background: var(--fill-2); padding: 2px; border-radius: 9px; }
.toggle-mini button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.toggle-mini button.is-active { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.mini-list { display: flex; flex-direction: column; }
.mini { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--line); cursor: pointer; }
.mini:first-child { border-top: 0; }
.mini:hover { background: var(--surface-2); }
.mini .ico { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.mini .ico.in { background: var(--pos-bg); color: var(--pos); }
.mini .ico.out { background: var(--neg-bg); color: var(--neg); }
.mini .t { font-weight: 650; font-size: 14.5px; }
.mini .s { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.mini .a { text-align: right; font-weight: 800; font-size: 14.5px; white-space: nowrap; }
.mini .a small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.rank { width: 24px; height: 24px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); }

.alert-item { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: inherit; border: 1px solid; align-items: start; }
.alert-item:hover { text-decoration: none; filter: brightness(.98); }
.alert-item .ai { width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--ai-bg); }
.alert-item b { display: block; font-size: 14.5px; }
.alert-item span { font-size: 13.5px; }
.alert-item.warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.alert-item.danger { background: var(--neg-bg); border-color: var(--neg-line); color: var(--neg-text); }
.alerts-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; }

/* timeline */
.tl { display: flex; flex-direction: column; }
.tl-day { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 18px 4px 8px; }
.tl-day:first-child { padding-top: 4px; }
.tl-item { display: grid; grid-template-columns: 40px 1fr; gap: 12px; position: relative; padding: 0 0 18px; }
.tl-item::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-ico { width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center; z-index: 1; }
.tl-ico.income { background: var(--pos-bg); color: var(--pos); }
.tl-ico.expense { background: var(--neg-bg); color: var(--neg); }
.tl-ico.document { background: var(--info-bg); color: var(--info); }
.tl-ico.edit { background: var(--warn-bg); color: var(--warn); }
.tl-ico.delete { background: var(--neg-bg); color: var(--neg); }
.tl-ico.login, .tl-ico.logout { background: var(--primary-50); color: var(--primary-600); }
.tl-ico.report { background: var(--rep-bg); color: var(--rep-fg); }
.tl-ico.settings { background: var(--fill-2); color: var(--text-2); }
.tl-ico.alert { background: var(--neg-bg); color: var(--neg); }
.tl-body { padding-top: 2px; min-width: 0; }
.tl-time { font-size: 12.5px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-text { font-size: 14.5px; font-weight: 550; word-break: break-word; }
.tl-card { padding: 16px 18px 4px; }

/* contas */
.accounts-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.acc-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.acc-card:hover { box-shadow: var(--shadow); }
.acc-card.is-off { opacity: .6; }
.acc-top { display: flex; align-items: center; gap: 12px; }
.acc-ico { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-50); color: var(--primary-600); display: flex; align-items: center; justify-content: center; flex: none; }
.acc-name { font-weight: 700; font-size: 16px; }
.acc-bal { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.acc-split { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.total-banner { padding: 18px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* árvore de categorias */
.cat-grid { display: grid; gap: 12px; }
.cat-card { overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cat-head .nm { font-weight: 700; flex: 1; min-width: 0; }
.cat-sub { display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 36px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.cat-sub:last-child { border-bottom: 0; }
.cat-sub .nm { flex: 1; min-width: 0; }
.cat-count { font-size: 12px; color: var(--muted); }

/* abas */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--fill-2); border-radius: 14px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; min-height: 40px; padding: 0 16px; border: 0; background: transparent; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--text-2); white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tab.is-active { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.tab-panel[hidden] { display: none; }

/* lista de itens (configurações) */
.item-list { display: flex; flex-direction: column; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.item-row:first-child { border-top: 0; }
.item-row .grow b { font-weight: 650; }
.item-row .grow small { color: var(--muted); display: block; font-size: 12.5px; }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }

/* relatórios */
.report-types { display: grid; grid-template-columns: 1fr; gap: 10px; }
.rtype { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.rtype:hover { border-color: var(--line-2); }
.rtype.is-active { border-color: var(--primary); background: var(--primary-50); }
.rtype .ri { width: 44px; height: 44px; border-radius: 13px; background: var(--primary-50); color: var(--primary-600); display: flex; align-items: center; justify-content: center; flex: none; }
.rtype.is-active .ri { background: var(--surface); }
.rtype b { display: block; font-size: 16px; }
.rtype small { color: var(--muted); font-size: 13px; }
.preview-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* --------------------------------------------------------- arquivo digital -- */
.doc-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.doc-search { position: relative; }
.doc-search .i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.doc-search .input { padding-left: 44px; min-height: 52px; border-radius: 16px; font-size: 16px; }
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.chip:hover { border-color: var(--line-2); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--on-strong); }
.chip .n { font-size: 11.5px; opacity: .7; }
.docs-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.doc-card { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 12px; align-items: center; cursor: pointer; transition: box-shadow .15s, border-color .15s; text-align: left; width: 100%; background: var(--surface); }
.doc-card:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.doc-thumb { width: 64px; height: 64px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); position: relative; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .ext { position: absolute; bottom: 4px; left: 4px; font-size: 9px; font-weight: 800; letter-spacing: .04em; background: rgba(15, 23, 42, .75); color: #fff; padding: 1px 5px; border-radius: 5px; text-transform: uppercase; }
.doc-thumb.pdf { background: var(--pdf-bg); color: var(--pdf-fg); border-color: var(--pdf-line); }
.doc-thumb.office { background: var(--off-bg); color: var(--off-fg); border-color: var(--off-line); }
.doc-name { font-weight: 700; font-size: 15px; line-height: 1.3; word-break: break-word; }
.doc-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--primary-50); color: var(--primary-600); font-weight: 600; border: 0; cursor: pointer; }
.val-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.val-valido { background: var(--pos-bg); color: var(--pos); }
.val-vencendo { background: var(--warn-bg); color: var(--warn); }
.val-vencido { background: var(--neg-bg); color: var(--neg); }

.viewer { display: flex; flex-direction: column; height: 100%; min-height: 0; background: #11141d; }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: #0b0d14; color: #fff; flex: none; padding-top: calc(10px + var(--safe-t)); }
.viewer-bar .title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; }
.viewer-bar .title small { display: block; font-weight: 500; color: #9aa3b5; font-size: 12px; }
.viewer-bar .icon-btn { color: #dbe0ec; }
.viewer-bar .icon-btn:hover { background: rgba(255,255,255,.1); }
.viewer-stage { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px; min-height: 0; }
.viewer-stage img.view-img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; margin: auto; }
.viewer-stage canvas { max-width: 100%; height: auto !important; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.4); border-radius: 3px; }
.pdf-page { width: 100%; max-width: 980px; display: flex; justify-content: center; min-height: 200px; }
.viewer-msg { color: #cbd2e0; text-align: center; margin: auto; display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 20px; }
.viewer-info { background: var(--surface); padding: 14px 16px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); flex: none; max-height: 40%; overflow-y: auto; }
.viewer-info .kv { font-size: 13.5px; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.viewer-actions .btn { flex: 1 1 calc(50% - 8px); }

.file-drop { border: 2px dashed var(--line-2); border-radius: 16px; padding: 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.file-drop.has-file { border-style: solid; border-color: var(--pos-line); background: var(--pos-bg); }
.file-drop .fd-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.file-drop .fd-actions .btn { flex: 1 1 140px; }
.file-list { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; font-size: 13.5px; }
.file-item .nm { flex: 1; min-width: 0; font-weight: 600; }
.file-item small { color: var(--muted); }
.more-details { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.more-details > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 14px; font-weight: 700; font-size: 14.5px; cursor: pointer; color: var(--text-2); }
.more-details > summary::-webkit-details-marker { display: none; }
.more-details[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.more-details > summary .i { transition: transform .2s; }
.more-details[open] > summary .i { transform: rotate(180deg); }
.more-details .md-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

/* instalação PWA */
.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: 14px; margin-bottom: 14px; }
.install-banner .grow { font-size: 13.5px; color: var(--primary-600); }
.install-banner b { display: block; font-size: 14.5px; }

/* ------------------------------------------------------------- breakpoints -- */
@media (min-width: 560px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .accounts-grid { grid-template-columns: repeat(2, 1fr); }
  .docs-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-strip { grid-template-columns: repeat(4, 1fr); }
  .report-types { grid-template-columns: repeat(2, 1fr); }
  .preview-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { max-width: 580px; border-radius: 22px; max-height: 90vh; transform: translateY(14px) scale(.98); }
  .modal::before { display: none; }
  .modal-lg .modal { max-width: 760px; }
  .modal-full .modal { max-width: 1100px; height: 90vh; max-height: 90vh; border-radius: 22px; }
  .modal-foot .btn { flex: 0 1 auto; min-width: 140px; }
  .modal-foot .btn-primary { margin-left: auto; }
  .toasts { bottom: 24px; }
  .hero { display: none; }
  .quick { grid-template-columns: repeat(3, auto); justify-content: start; }
  .quick .btn-doc { grid-column: auto; }
  .dash-filters { display: flex; flex-wrap: wrap; align-items: flex-end; }
  .dash-filters .field { min-width: 170px; }
  .dash-filters .span-2 { grid-column: auto; }
  .filters-actions .btn { flex: 0 1 auto; min-width: 120px; }
  .page-title { font-size: 28px; }
  .viewer-actions .btn { flex: 0 1 auto; }
}

@media (min-width: 1024px) {
  .sidebar { transform: none; width: var(--sidebar-w); box-shadow: none; z-index: 30; }
  .drawer-backdrop { display: none; }
  .main { margin-left: var(--sidebar-w); }
  .topbar { padding-left: 28px; padding-right: 28px; gap: 12px; }
  .topbar .brand, .topbar .menu-btn, .topbar .search-toggle { display: none; }
  .search { display: block; }
  .content { padding: 26px 28px 48px; }
  .bottom-nav { display: none; }
  .hide-mobile { display: initial !important; }
  .show-mobile { display: none !important; }
  .hide-mobile.flex { display: flex !important; }
  .toasts { left: auto; right: 24px; align-items: flex-end; bottom: 24px; }
  .filters-toggle { display: none; }
  .filters-body { display: block; padding-top: 0; }
  .filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
  .filters-grid { grid-template-columns: repeat(4, 1fr); }
  .filters-grid .span-2 { grid-column: span 2; }
  .accounts-grid { grid-template-columns: repeat(3, 1fr); }
  .docs-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-chips { flex-wrap: wrap; overflow: visible; padding: 0; margin: 0; }
  .subnav { margin: 0 0 18px; padding: 0; }
  .modal-full .modal { max-width: 1180px; }
  .viewer { flex-direction: row; flex-wrap: wrap; }
  .viewer-bar { width: 100%; }
  .viewer-stage { flex: 1 1 0; min-width: 0; height: calc(100% - 64px); }
  .viewer-info { width: 320px; max-height: none; border-top: 0; border-left: 1px solid var(--line); height: calc(100% - 64px); }

  /* dashboard em grade de 12 colunas */
  .dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
  .dash .greet { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .dash .dash-filters-card { grid-column: 1 / -1; }
  .dash .kpi { grid-column: span 6; }
  .dash .alerts-card { grid-column: 1 / -1; }
  .dash .c-6 { grid-column: span 6; }
  .dash .c-4 { grid-column: span 4; }
  .dash .c-8 { grid-column: span 8; }
  .dash .c-12 { grid-column: 1 / -1; }
  .dash > .order { order: 0 !important; }
}

@media (min-width: 1280px) {
  .dash .kpi { grid-column: span 3; }
  .kpi .v { font-size: 27px; }
}

/* ordem do dashboard no celular (§36: saldo → mensal → gastos → entradas x saídas → últimas) */
@media (max-width: 1023.98px) {
  .dash .o-1 { order: 1; } .dash .o-2 { order: 2; } .dash .o-3 { order: 3; } .dash .o-4 { order: 4; } .dash .o-5 { order: 5; }
  .dash .o-6 { order: 6; } .dash .o-7 { order: 7; } .dash .o-8 { order: 8; } .dash .o-9 { order: 9; } .dash .o-10 { order: 10; }
  .dash .o-11 { order: 11; } .dash .o-12 { order: 12; } .dash .o-13 { order: 13; } .dash .o-14 { order: 14; } .dash .o-15 { order: 15; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .toasts, .page-actions, .filters { display: none !important; }
  .main { margin: 0; } body { background: #fff; }
}

/* visualizador em tela cheia: o corpo do modal não tem padding */
.modal-full .modal-body { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.modal-full .viewer { flex: 1 1 auto; }
@media (max-width: 1023.98px) {
  .dash .o-16 { order: 16; } .dash .o-17 { order: 17; } .dash .o-18 { order: 18; }
}
.summary-strip { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tx-amount .warn { color: var(--warn); }
@media (max-width: 1023.98px) { .tx-extra .badge { font-size: 11px; } }

/* --------------------------------------------------------------------------
   Lista de lançamentos: vira tabela conforme a LARGURA DA PRÓPRIA LISTA
   (container query), não da tela — funciona com ou sem sidebar aberta.
   -------------------------------------------------------------------------- */
.tx-list { container-type: inline-size; container-name: txl; }
@container txl (min-width: 800px) {
  .tx-head, .tx {
    display: grid; gap: 12px; align-items: center; padding: 12px 18px;
    grid-template-columns: 92px minmax(170px, 1.8fr) minmax(90px, 1fr) minmax(90px, 1fr) 108px 124px 92px;
    grid-template-areas: "date main cat origin status amount actions";
  }
  .tx-head { padding: 11px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .tx-head span:nth-child(1) { grid-area: date; } .tx-head span:nth-child(2) { grid-area: main; } .tx-head span:nth-child(3) { grid-area: cat; }
  .tx-head span:nth-child(4) { grid-area: origin; } .tx-head span:nth-child(5) { display: none; grid-area: acc; } .tx-head span:nth-child(6) { grid-area: status; }
  .tx-head span:nth-child(7) { grid-area: amount; } .tx-head span:nth-child(8) { grid-area: actions; }
  .tx-ico, .tx-meta, .tx-extra, .tx-amount small.pend-mobile { display: none; }
  .tx-main { grid-area: main; } .tx-date { display: block; grid-area: date; color: var(--text-2); font-size: 14px; }
  .tx-cat { display: block; grid-area: cat; font-size: 14px; } .tx-origin { display: block; grid-area: origin; font-size: 14px; }
  .tx-acc { display: none; grid-area: acc; font-size: 13.5px; color: var(--text-2); }
  .tx-status { display: block; grid-area: status; } .tx-amount { grid-area: amount; }
  .tx-actions { display: flex; grid-area: actions; justify-content: flex-end; gap: 2px; }
  .tx-desc small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
  .tx-amount small { display: block; }
}
@container txl (min-width: 1080px) {
  .tx-head, .tx {
    grid-template-columns: 92px minmax(180px, 1.8fr) 1fr 1fr 1fr 108px 124px 92px;
    grid-template-areas: "date main cat origin acc status amount actions";
  }
  .tx-head span:nth-child(5) { display: block; }
  .tx-acc { display: block; }
}
.tx-desc small { display: none; }
@container txl (min-width: 800px) { .tx-desc small { display: block; } }

/* ---- dashboard: saudação/ações como itens separados no celular + filtros recolhíveis ---- */
.greet { display: contents; }
.dash-filters-card { overflow: hidden; }
.df-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 54px; padding: 0 16px; border: 0; background: transparent; font-weight: 650; font-size: 14.5px; color: var(--text-2); text-align: left; }
.df-toggle > .i { transition: transform .2s; color: var(--muted); }
.dash-filters { display: none; padding: 4px 16px 16px; }
.dash-filters-card.is-open .dash-filters { display: grid; }
.dash-filters-card.is-open .df-toggle > .i { transform: rotate(180deg); }
@media (min-width: 768px) { .dash-filters-card.is-open .dash-filters { display: flex; } }
@media (min-width: 1024px) {
  .greet { display: flex; }
  .df-toggle { display: none; }
  .dash-filters { display: flex; padding: 16px 18px; }
}
@media (max-width: 767.98px) {
  #pw-nudge { font-size: 13.5px; padding: 10px 12px; }
}

/* seletor de cor */
.swatch { cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ring); box-shadow: 0 0 0 1px var(--line-2); transition: transform .12s; }
.swatch input:checked + span { box-shadow: 0 0 0 2.5px var(--text); transform: scale(1.06); }
.swatch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 3px; }
.acc-split { flex-direction: column; gap: 3px; }
.acc-split span:last-child { display: flex; gap: 10px; flex-wrap: wrap; }
.icon-btn.btn-sm { width: 34px; height: 34px; border-radius: 10px; }
.cat-head { gap: 6px; padding: 12px 10px 12px 14px; }
.cat-head .nm { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cat-head .nm small { font-weight: 500; color: var(--muted); font-size: 12px; }
.cat-head .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-head .dot { margin-right: 4px; }
.cat-sub { padding-right: 10px; }

/* filtros recolhíveis também no desktop (Arquivo: a busca é o foco) */
@media (min-width: 1024px) {
  .filters.filters-collapsed { background: transparent; border: 0; padding: 0; margin-bottom: 8px; }
  .filters.filters-collapsed .filters-toggle { display: inline-flex; width: auto; }
  .filters.filters-collapsed .filters-body { display: none; padding: 14px 18px 4px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .filters.filters-collapsed.is-open .filters-body { display: block; }
}

/* celular: faixa de aviso fina e resumo compacto */
@media (max-width: 767.98px) {
  #pw-nudge { padding: 8px 10px 8px 14px; font-size: 13.5px; }
  #pw-nudge .btn { min-height: 32px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
  .summary-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-strip .stat:nth-child(3) { display: none; }
  .stat .v { font-size: 17px; }
  .stat { padding: 10px 12px; }
}
@media (max-width: 480px) { #rperiod span { padding: 0 3px; font-size: 12.5px; } }

/* ==========================================================================
   Topo direito: tema claro/escuro, contagem regressiva de inatividade, avatar
   ========================================================================== */
.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: inline; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }
.topbar-me { display: inline-flex; align-items: center; border-radius: 50%; margin-left: 2px; flex: none; }
.topbar-me:hover { text-decoration: none; }
.topbar-me .avatar { --av: 34px; }
.idle-chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: default; flex: none; }
.idle-chip .i { width: 16px; height: 16px; }
.idle-chip.is-urgent { background: var(--neg-bg); border-color: var(--neg-line); color: var(--neg); animation: idle-pulse 1s ease-in-out infinite; }
@keyframes idle-pulse { 50% { opacity: .55; } }
.idle-count { font-size: 46px; font-weight: 800; letter-spacing: -.02em; text-align: center; font-variant-numeric: tabular-nums; color: var(--neg); margin: 6px 0 2px; }
.auth-theme { position: fixed; top: calc(12px + var(--safe-t)); right: 12px; z-index: 5; }
@media (max-width: 479.98px) { .topbar .brand b { display: none; } }
@media (max-width: 1023.98px) { .topbar:has(.idle-chip:not([hidden])) .brand { display: none; } }
@media (min-width: 1024px) { .topbar-me { display: none; } }

/* usuário citado (avatar + nome) em listas e selos */
.who-inline { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.badge-user { padding-left: 3px; gap: 6px; }
.badge-user .avatar { --av: 18px; font-size: 9px; }
.tl-who { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.tl-item .tl-time { display: flex; align-items: center; gap: 6px; }

/* foto de perfil: edição e recorte */
.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-edit .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }
.avatar-edit .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cropper { width: min(100%, 320px); aspect-ratio: 1; margin: 0 auto; position: relative; overflow: hidden; border-radius: 16px; background: #0b0d14; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.cropper:active { cursor: grabbing; }
.cropper canvas { width: 100%; height: 100%; display: block; }
.cropper::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .5); outline: 2px solid rgba(255, 255, 255, .9); outline-offset: -2px; pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.crop-zoom input[type="range"] { flex: 1; accent-color: var(--primary); }

/* ==========================================================================
   Tema escuro (html[data-theme="dark"]) — só redefine as variáveis; botão no topo direito.
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1018; --surface: #141a26; --surface-2: #19212f; --line: #222b3b; --line-2: #2e394d;
  --text: #e7ebf3; --text-2: #a9b4c7; --muted: #7d899f;
  --primary: #6366f1; --primary-600: #b0b6ff; --primary-50: rgba(99, 102, 241, .17); --primary-100: rgba(99, 102, 241, .3);
  --primary-h: #4f46e5; --link: #959cff;
  --pos: #34d399; --pos-bg: rgba(16, 185, 129, .14); --pos-line: rgba(16, 185, 129, .32);
  --neg: #fb7185; --neg-bg: rgba(244, 63, 94, .14); --neg-line: rgba(244, 63, 94, .32);
  --warn: #fbbf24; --warn-bg: rgba(245, 158, 11, .14); --warn-line: rgba(245, 158, 11, .32);
  --info: #38bdf8; --info-bg: rgba(14, 165, 233, .14); --info-line: rgba(14, 165, 233, .32);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .28);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);

  --on-strong: #0c1018;
  --fill: #222b3b; --fill-2: #10151f; --raised: #2a3549;
  --hover: rgba(255, 255, 255, .07); --hover-2: rgba(255, 255, 255, .06);
  --line-3: #3b4760; --placeholder: #6b778d; --track: #3a465c; --faint: #4a566d; --faint-2: #3e4a61;
  --pos-text: #6ee7b7; --neg-text: #fda4af; --info-text: #7dd3fc; --warn-text: #fcd34d;
  --neg-soft: rgba(244, 63, 94, .1);
  --topbar-bg: rgba(12, 16, 24, .82); --bottom-bg: rgba(16, 21, 31, .94);
  --scrim: rgba(0, 0, 0, .62); --veil: rgba(20, 26, 38, .72); --ai-bg: rgba(255, 255, 255, .08);
  --skel-a: #19212f; --skel-b: #212b3d; --flash: rgba(251, 191, 36, .2);
  --auth-glow: rgba(99, 102, 241, .22); --handle: #3b4760; --toast-bg: #2a3549; --ring: #141a26;
  --rep-bg: rgba(168, 85, 247, .18); --rep-fg: #d8b4fe;
  --pdf-bg: rgba(239, 68, 68, .14); --pdf-fg: #fca5a5; --pdf-line: rgba(239, 68, 68, .32);
  --off-bg: rgba(59, 130, 246, .15); --off-fg: #93c5fd; --off-line: rgba(59, 130, 246, .32);
}
:root[data-theme="dark"] .toast { border: 1px solid rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .icon-btn .count { border-color: var(--bg); }
:root[data-theme="dark"] .hero { box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .auth-logo img { box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d899f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
