/* APE 303 — stylesheet autocontido, inspirado no fluxo utilitário do Tailwind. */
:root {
  --ink-950: #17201f;
  --ink-900: #232d2b;
  --ink-800: #2e3a38;
  --ink-700: #45514f;
  --ink-600: #66716f;
  --ink-500: #7f8987;
  --ink-300: #bfc6c4;
  --ink-200: #d9deda;
  --ink-150: #e7eae7;
  --ink-100: #f0f2ef;
  --ink-50: #f7f8f5;
  --paper: #fffefb;
  --white: #ffffff;
  --green-900: #173f3a;
  --green-800: #1d5149;
  --green-700: #27685e;
  --green-600: #318073;
  --green-200: #bbf7d0;
  --green-100: #dcece7;
  --green-50: #eff7f4;
  --mint: #b8dacc;
  --amber-800: #8b4f08;
  --amber-700: #a9630e;
  --amber-100: #f8e8c8;
  --amber-50: #fff8e9;
  --red-800: #8f3030;
  --red-700: #ac4141;
  --red-200: #fecaca;
  --red-100: #f8dddd;
  --red-50: #fff3f2;
  --blue-800: #315b78;
  --blue-700: #3b6d91;
  --blue-100: #dceaf2;
  --blue-50: #f0f7fa;
  --purple-800: #684b77;
  --purple-100: #ede2f1;
  --purple-50: #f7f2f9;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-width: 16.25rem;
  --sidebar-collapsed-width: 4.5rem;
  --topbar-height: 5rem;
  --radius-sm: .5rem;
  --radius-md: .75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow-xs: 0 1px 2px rgb(23 32 31 / .05);
  --shadow-sm: 0 5px 18px rgb(23 32 31 / .06);
  --shadow-md: 0 16px 40px rgb(23 32 31 / .10);
  --focus: 0 0 0 3px rgb(49 128 115 / .22);
}

/* Memória de cálculo do painel */
.button-calculation {
  border-color: var(--green-700);
  color: var(--green-800);
  letter-spacing: .035em;
  font-weight: 800;
}
.button-calculation:hover { background: var(--green-50); }
.calculation-dialog {
  width: min(70rem, calc(100% - 2rem));
  max-width: none;
  max-height: min(92vh, 62rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ink-200);
  border-radius: 1.35rem;
  background: transparent;
  color: var(--ink-950);
  box-shadow: 0 30px 90px rgb(16 31 28 / .28);
}
.calculation-dialog::backdrop {
  background: rgb(15 28 26 / .64);
  backdrop-filter: blur(4px);
}
.calculation-modal {
  display: flex;
  max-height: min(92vh, 62rem);
  flex-direction: column;
  background: var(--ink-50);
}
.calculation-modal-header,
.calculation-modal-footer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  background: var(--paper);
}
.calculation-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--ink-150);
}
.calculation-modal-header h2 {
  margin: .15rem 0 .35rem;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  line-height: 1.15;
}
.calculation-modal-header p:last-child {
  margin: 0;
  color: var(--ink-600);
}
.dialog-close {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--ink-200);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink-700);
  font-size: 1.7rem;
  line-height: 1;
}
.dialog-close:hover { border-color: var(--green-600); color: var(--green-800); }
.dialog-close:focus-visible { outline: none; box-shadow: var(--focus); }
.calculation-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.5rem 1.75rem 2rem;
}
.calculation-section {
  padding: 1.35rem;
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow-xs);
}
.calculation-section + .calculation-section { margin-top: 1rem; }
.calculation-section-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .85rem;
  margin-bottom: 1.1rem;
}
.calculation-section-head h3 { margin: 0 0 .15rem; font-size: 1rem; }
.calculation-section-head p { margin: 0; color: var(--ink-600); font-size: .78rem; }
.calculation-step {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: var(--green-800);
  color: var(--white);
  font-size: .75rem;
  font-weight: 800;
}
.calculation-section-total { font-size: 1rem; color: var(--green-800); }
.calculation-base-grid,
.calculation-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}
.calculation-base-card,
.calculation-result-grid > article {
  padding: 1rem;
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-lg);
  background: var(--white);
}
.calculation-person-head { display: flex; align-items: center; gap: .7rem; }
.calculation-person-head > div { display: grid; gap: .05rem; min-width: 0; }
.calculation-person-head > div > span { color: var(--ink-600); font-size: .72rem; }
.calculation-income-list,
.calculation-transfer-list,
.calculation-details ul {
  margin: .85rem 0 0;
  padding: 0;
  list-style: none;
}
.calculation-income-list li,
.calculation-details li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .42rem 0;
  border-bottom: 1px dashed var(--ink-150);
  font-size: .76rem;
}
.calculation-income-list li:last-child,
.calculation-details li:last-child { border-bottom: 0; }
.calculation-formula,
.expense-person-calculation code {
  display: grid;
  gap: .3rem;
  margin-top: .8rem;
  padding: .65rem .75rem;
  border-radius: var(--radius-md);
  background: var(--green-50);
}
.calculation-formula span { color: var(--ink-600); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.calculation-formula code,
.expense-person-calculation code {
  overflow-wrap: anywhere;
  color: var(--green-900);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .72rem;
  font-weight: 700;
}
.calculation-details {
  margin-top: .9rem;
  padding: .75rem .9rem;
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
  background: var(--ink-50);
}
.calculation-details summary { cursor: pointer; color: var(--ink-700); font-size: .76rem; font-weight: 700; }
.expense-calculation-list { display: grid; gap: .75rem; }
.expense-calculation {
  overflow: hidden;
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-lg);
  background: var(--white);
}
.expense-calculation-error { border-color: var(--red-100); }
.expense-calculation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--ink-150);
  background: var(--ink-50);
}
.expense-calculation-head > div { display: grid; gap: .12rem; }
.expense-calculation-head span { color: var(--ink-600); font-size: .7rem; }
.expense-division-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  padding: .85rem 1rem;
}
.expense-person-calculation { min-width: 0; }
.expense-person-calculation > div { display: flex; justify-content: space-between; gap: .75rem; font-size: .78rem; }
.expense-person-calculation code { margin-top: .4rem; }
.expense-reconciliation {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: .65rem 1rem;
  border-top: 1px solid var(--ink-150);
  color: var(--ink-600);
  font-size: .7rem;
}
.calculation-ok { color: var(--green-700); font-weight: 800; }
.calculation-mismatch { color: var(--red-700); font-weight: 800; }
.calculation-empty { margin: .85rem 0 0; color: var(--ink-600); font-size: .76rem; }
.calculation-empty-bordered { padding: .8rem; border: 1px dashed var(--ink-200); border-radius: var(--radius-md); }
.calculation-transfer-list { display: grid; gap: .55rem; }
.calculation-transfer-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem .85rem;
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
  background: var(--white);
}
.calculation-transfer-list li > div { display: grid; gap: .1rem; }
.calculation-transfer-list span { color: var(--ink-600); font-size: .7rem; }
.calculation-result { border-color: var(--green-100); background: var(--green-50); }
.calculation-result-grid > article dl { margin: .85rem 0 0; }
.calculation-result-grid > article dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .38rem 0; font-size: .76rem; }
.calculation-result-grid dt { color: var(--ink-600); }
.calculation-result-grid dd { margin: 0; font-weight: 700; }
.calculation-result-grid .calculation-final-line { margin-top: .35rem; padding-top: .7rem; border-top: 1px solid var(--ink-200); font-size: .86rem; }
.calculation-check {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: .75rem;
  margin-top: .85rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--green-900);
  color: var(--white);
}
.calculation-check > div { display: grid; gap: .1rem; text-align: center; }
.calculation-check > div span { color: rgb(255 255 255 / .72); font-size: .66rem; }
.calculation-check-error { background: var(--red-800); }
.calculation-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.75rem;
  border-top: 1px solid var(--ink-150);
}
.calculation-modal-footer p { margin: 0; color: var(--ink-600); font-size: .7rem; }

@media (max-width: 720px) {
  .calculation-dialog { width: calc(100% - 1rem); max-height: calc(100vh - 1rem); border-radius: 1rem; }
  .calculation-modal { max-height: calc(100vh - 1rem); }
  .calculation-modal-header,
  .calculation-modal-body,
  .calculation-modal-footer { padding-left: 1rem; padding-right: 1rem; }
  .calculation-section { padding: 1rem; }
  .calculation-section-head { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .calculation-section-total { grid-column: 2; }
  .calculation-base-grid,
  .calculation-result-grid,
  .expense-division-grid { grid-template-columns: 1fr; }
  .expense-calculation-head,
  .expense-reconciliation,
  .calculation-modal-footer { align-items: stretch; flex-direction: column; }
  .expense-reconciliation { gap: .35rem; }
  .calculation-check { grid-template-columns: 1fr; gap: .4rem; }
  .calculation-check > span { transform: rotate(90deg); text-align: center; }
  .calculation-modal-footer .button { width: 100%; }
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 20rem; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink-50);
  color: var(--ink-950);
  font-family: var(--font-sans);
  font-size: .9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { color: inherit; font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
svg { stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
p, h1, h2, h3 { margin-top: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.skip-link {
  position: fixed; z-index: 100; top: .75rem; left: .75rem; padding: .65rem 1rem;
  border-radius: var(--radius-md); background: var(--green-900); color: white;
  transform: translateY(-160%); transition: transform .18s ease;
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.no-scroll { overflow: hidden; }

/* Estrutura */
html.sidebar-preload-collapsed .app-shell {
  --sidebar-width: var(--sidebar-collapsed-width);
}
html.sidebar-preload-collapsed .brand-text,
html.sidebar-preload-collapsed .nav-label,
html.sidebar-preload-collapsed .nav-item span,
html.sidebar-preload-collapsed .sidebar-status-text,
html.sidebar-preload-collapsed .logout-text {
  display: none;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; z-index: 40; inset: 0 auto 0 0; width: var(--sidebar-width);
  display: flex; flex-direction: column; padding: 1.5rem 1rem 1rem;
  overflow-y: auto; overflow-x: hidden; color: #dbe9e5;
  background:
    radial-gradient(circle at 15% 0%, rgb(76 137 122 / .26), transparent 30%),
    linear-gradient(180deg, #173f3a 0%, #102f2c 100%);
  transition: width .25s cubic-bezier(0.4, 0, 0.2, 1), padding .25s cubic-bezier(0.4, 0, 0.2, 1), transform .2s ease;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; gap: .5rem;
}
.brand { display: flex; align-items: center; gap: .8rem; min-height: 3rem; padding: 0 .55rem; color: white; min-width: 0; text-decoration: none; }
.brand-text { min-width: 0; white-space: nowrap; }
.brand-mark {
  display: grid; width: 2.65rem; height: 2.65rem; flex: 0 0 auto; place-items: center;
  border: 1px solid rgb(255 255 255 / .18); border-radius: .85rem; color: #eaf6f2;
  background: rgb(255 255 255 / .09); box-shadow: inset 0 1px rgb(255 255 255 / .08);
}
.brand-mark svg { width: 1.55rem; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: .08em; line-height: 1.15; }
.brand small { display: block; margin-top: .18rem; color: #a9c4bd; font-size: .72rem; letter-spacing: .035em; }

.sidebar-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; padding: 0;
  border: 1px solid rgb(255 255 255 / .15); border-radius: .55rem; background: rgb(255 255 255 / .06);
  color: #c5dcd5; cursor: pointer; flex-shrink: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sidebar-toggle:hover { background: rgb(255 255 255 / .16); color: white; border-color: rgb(255 255 255 / .3); }
.sidebar-toggle svg { width: 1.15rem; height: 1.15rem; transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.sidebar-toggle:hover svg { transform: scale(1.15); }

.nav-list { margin-top: 2rem; width: 100%; }
.nav-label { margin: 0 0 .55rem .65rem; color: #7fa49b; font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav-label-spaced { margin-top: 1.6rem; }
.nav-item {
  display: flex; align-items: center; gap: .8rem; min-height: 2.85rem; margin: .18rem 0;
  padding: .55rem .72rem; border: 1px solid transparent; border-radius: .72rem;
  color: #bfd3cd; font-size: .875rem; font-weight: 560; text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nav-item svg { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s ease; }
.nav-item:hover { color: white; background: rgb(255 255 255 / .06); }
.nav-item:hover svg { transform: scale(1.18); }
.nav-item.is-active { border-color: rgb(255 255 255 / .08); color: white; background: rgb(255 255 255 / .11); box-shadow: inset 3px 0 var(--mint); }

.sidebar-foot {
  display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; padding: .85rem .7rem .2rem;
  border-top: 1px solid rgb(255 255 255 / .09); color: #8eaaa3; font-size: .72rem;
  transition: padding .25s ease;
}
.sidebar-status-wrap { display: flex; align-items: center; gap: 0.5rem; }
.status-dot { width: .48rem; height: .48rem; border-radius: 999px; background: #7fc4a9; box-shadow: 0 0 0 4px rgb(127 196 169 / .1); }
.sidebar-logout-btn {
  width: 100%; font-size: 0.8rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.45rem 0.6rem;
}
.sidebar-logout-btn .logout-icon { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.sidebar-logout-btn:hover .logout-icon { transform: scale(1.18); }

.app-main {
  min-height: 100vh; margin-left: var(--sidebar-width); display: flex; flex-direction: column;
  transition: margin-left .25s cubic-bezier(0.4, 0, 0.2, 1);
}
.topbar {
  position: sticky; z-index: 30; top: 0; height: var(--topbar-height); display: flex; align-items: center;
  padding: 0 clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--ink-150);
  background: rgb(255 254 251 / .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.mobile-menu-button { display: none !important; margin-right: .7rem; }
.period-picker { display: flex; align-items: end; gap: .5rem; }
.period-picker label { display: block; }
.period-label { display: block; margin-bottom: .16rem; color: var(--ink-600); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.period-field {
  display: flex; align-items: center; gap: .45rem; min-width: 10.75rem; height: 2.35rem; padding: 0 .7rem;
  border: 1px solid var(--ink-200); border-radius: var(--radius-md); background: white; box-shadow: var(--shadow-xs);
}
.period-field:focus-within { border-color: var(--green-600); box-shadow: var(--focus); }
.period-field svg { width: 1rem; color: var(--green-700); }
.period-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: .875rem; font-weight: 650; }
.period-picker.is-loading .period-field { opacity: .6; }
.topbar-status { display: flex; align-items: center; margin-left: auto; }
.page { width: 100%; max-width: 100rem; margin: 0 auto; padding: 2.1rem clamp(1rem, 3vw, 2.5rem) 3rem; }
.app-footer { margin-top: auto; padding: 0 2rem 1.4rem; color: var(--ink-500); font-size: .72rem; text-align: center; }
.app-footer p { margin: 0; }
.mobile-nav, .sidebar-scrim { display: none; }

/* Cabeçalhos */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.55rem; }
.page-kicker { margin: 0 0 .32rem; color: var(--green-700); font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.page-title { margin: 0; color: var(--ink-950); font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 720; letter-spacing: -.035em; line-height: 1.12; }
.page-description { max-width: 42rem; margin: .45rem 0 0; color: var(--ink-600); font-size: .9rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .65rem; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .85rem; }
.section-heading h2 { margin: 0; font-size: 1rem; font-weight: 720; letter-spacing: -.015em; }
.section-heading p { margin: .2rem 0 0; color: var(--ink-600); font-size: .8rem; }
.section-heading a { color: var(--green-700); font-size: .8rem; font-weight: 650; }
.section-heading a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Botões e badges */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.6rem;
  padding: .62rem 1rem; border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: .82rem; font-weight: 680; line-height: 1.2; white-space: nowrap; transition: .16s ease;
}
.button svg { width: 1rem; height: 1rem; }
.button-primary { border-color: var(--green-800); background: var(--green-800); color: white; box-shadow: 0 4px 11px rgb(23 63 58 / .16); }
.button-primary:hover { border-color: var(--green-900); background: var(--green-900); transform: translateY(-1px); }
.button-secondary { border-color: var(--ink-200); background: white; color: var(--ink-800); box-shadow: var(--shadow-xs); }
.button-secondary:hover { border-color: var(--ink-300); background: var(--ink-50); }
.button-danger { border-color: var(--red-100); background: var(--red-50); color: var(--red-800); }
.button-danger:hover { border-color: #efbcbc; background: #fde7e5; }
.button-ghost { border-color: transparent; background: transparent; color: var(--ink-700); }
.button-ghost:hover { background: var(--ink-100); color: var(--ink-950); }
.button-small { min-height: 2.15rem; padding: .45rem .72rem; font-size: .75rem; }
.button-small svg { width: .85rem; height: .85rem; }
.button[disabled], .button.is-disabled { pointer-events: none; opacity: .48; }
.icon-button {
  display: inline-grid; width: 2.35rem; height: 2.35rem; padding: 0; place-items: center;
  border: 1px solid var(--ink-200); border-radius: .65rem; background: white; color: var(--ink-700);
}
.icon-button:hover { border-color: var(--ink-300); background: var(--ink-50); color: var(--ink-950); }
.icon-button svg { width: 1.1rem; height: 1.1rem; }
.badge { display: inline-flex; align-items: center; gap: .38rem; padding: .26rem .55rem; border-radius: 999px; font-size: .68rem; font-weight: 720; letter-spacing: .015em; white-space: nowrap; }
.badge-dot { width: .38rem; height: .38rem; border-radius: 99px; background: currentColor; }
.badge-success { background: var(--green-100); color: var(--green-800); }
.badge-info { background: var(--blue-100); color: var(--blue-800); }
.badge-warning { background: var(--amber-100); color: var(--amber-800); }
.badge-danger { background: var(--red-100); color: var(--red-800); }
.badge-purple { background: var(--purple-100); color: var(--purple-800); }
.badge-muted { background: var(--ink-100); color: var(--ink-600); }

/* Cartões e métricas */
.card { border: 1px solid var(--ink-150); border-radius: var(--radius-lg); background: var(--paper); box-shadow: var(--shadow-xs); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.2rem; border-bottom: 1px solid var(--ink-150); }
.card-header h2, .card-header h3 { margin: 0; font-size: .92rem; font-weight: 720; }
.card-header p { margin: .24rem 0 0; color: var(--ink-600); font-size: .76rem; }
.card-body { padding: 1.2rem; }
.card-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--ink-150); background: var(--ink-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.metric-card { position: relative; min-height: 8.4rem; padding: 1.05rem 1.1rem; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 5.8rem; height: 5.8rem; right: -2.2rem; bottom: -2.8rem; border-radius: 50%; background: var(--ink-100); }
.metric-card-accent { border-color: #bad8ce; background: linear-gradient(145deg, var(--green-50), var(--paper) 68%); }
.metric-card-accent::after { background: var(--green-100); }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ink-600); font-size: .72rem; font-weight: 650; }
.metric-icon { display: grid; width: 1.9rem; height: 1.9rem; place-items: center; border-radius: .55rem; background: var(--ink-100); color: var(--ink-700); }
.metric-icon svg { width: .95rem; }
.metric-card-accent .metric-icon { background: var(--green-100); color: var(--green-800); }
.metric-value { position: relative; z-index: 1; margin: .7rem 0 .25rem; font-size: clamp(1.25rem, 2vw, 1.55rem); font-weight: 740; letter-spacing: -.035em; }
.metric-detail { position: relative; z-index: 1; margin: 0; color: var(--ink-500); font-size: .7rem; }
.metric-detail strong { color: var(--ink-700); font-weight: 650; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(18rem, .8fr); gap: .95rem; align-items: start; }
.stack { display: grid; gap: .95rem; }

/* Rateio */
.split-card { padding: 1.15rem 1.2rem; }
.split-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.split-head h2 { margin: 0; font-size: .92rem; }
.split-head p { margin: .25rem 0 0; color: var(--ink-600); font-size: .75rem; }
.split-total { color: var(--ink-600); font-size: .72rem; text-align: right; }
.split-total strong { display: block; color: var(--ink-950); font-size: .9rem; }
.people-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.person-share:not(.metric-card) { padding: .9rem; border: 1px solid var(--ink-150); border-radius: var(--radius-md); background: white; }
.person-row { display: flex; align-items: center; gap: .7rem; }
.person-share.metric-card > * { position: relative; z-index: 1; }
.avatar.division-person-avatar { width: 1.9rem; height: 1.9rem; font-size: .68rem; }
.expense-summary { display: grid; grid-template-columns: repeat(3, max-content); gap: .7rem; align-items: center; }
.expense-summary-item { display: grid; gap: .12rem; min-width: 3.8rem; color: var(--ink-600); font-size: .66rem; text-align: right; }
.expense-summary-item + .expense-summary-item { padding-left: .7rem; border-left: 1px solid var(--ink-200); }
.expense-summary-item strong { color: var(--ink-900); font-size: .78rem; font-variant-numeric: tabular-nums; }
.expense-summary-item-success strong { color: var(--green-800); }
.expense-summary-item-danger strong { color: var(--red-700); }
.avatar { display: grid; width: 2.15rem; height: 2.15rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--green-100); color: var(--green-800); font-size: .75rem; font-weight: 750; }
.avatar-alt { background: var(--amber-100); color: var(--amber-800); }
.person-name { min-width: 0; flex: 1; }
.person-name strong { display: block; font-size: .82rem; }
.person-name span { display: block; color: var(--ink-500); font-size: .68rem; }
.person-amount { text-align: right; }
.person-amount strong { display: block; font-size: .88rem; }
.person-amount span { color: var(--green-700); font-size: .68rem; font-weight: 700; }
.progress { height: .4rem; margin-top: .7rem; overflow: hidden; border-radius: 99px; background: var(--ink-100); }
.progress > span { display: block; height: 100%; min-width: .2rem; border-radius: inherit; background: var(--green-600); }
.progress-alt > span { background: #c08535; }

/* Tabelas */
.table-card { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .79rem; }
.data-table th { padding: .72rem 1rem; border-bottom: 1px solid var(--ink-150); background: var(--ink-50); color: var(--ink-600); font-size: .65rem; font-weight: 720; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: .82rem 1rem; border-bottom: 1px solid var(--ink-150); color: var(--ink-700); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcf9; }
.data-table .cell-title { color: var(--ink-950); font-weight: 660; }
.data-table .cell-subtitle { display: block; margin-top: .15rem; color: var(--ink-500); font-size: .68rem; }
.data-table .numeric { color: var(--ink-950); font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; white-space: nowrap; }
.data-table th.numeric { color: var(--ink-600); }
.data-table .actions { width: 1%; text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: .2rem; }
.row-action { display: inline-flex; align-items: center; min-height: 1.9rem; padding: .35rem .5rem; border: 0; border-radius: .45rem; background: transparent; color: var(--ink-600); font-size: .7rem; font-weight: 650; }
.row-action:hover { background: var(--ink-100); color: var(--ink-950); }
.row-action-danger:hover { background: var(--red-50); color: var(--red-800); }
.row-actions form { display: inline-flex; margin: 0; padding: 0; vertical-align: middle; }

/* Botões de Ação com Ícone Padronizados */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  min-height: 1.85rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  line-height: 1;
  text-decoration: none;
  box-sizing: border-box;
  vertical-align: middle;
}
.icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--ink-100);
  color: var(--ink-950);
}
.icon-btn-danger:hover {
  background: var(--red-50);
  color: var(--red-800);
}
.icon-btn-success {
  color: var(--green-800);
}
.icon-btn-success:hover {
  background: var(--green-50);
  color: var(--green-900);
}

/* Formulários */
.form-shell { max-width: 56rem; margin: 0 auto; }
.form-card { overflow: hidden; }
.form-section { padding: 1.35rem 1.4rem; border-bottom: 1px solid var(--ink-150); }
.form-section:last-child { border-bottom: 0; }
.form-section-heading { margin-bottom: 1rem; }
.form-section-heading h2 { margin: 0; font-size: .92rem; }
.form-section-heading p { margin: .2rem 0 0; color: var(--ink-600); font-size: .75rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field-span-2 { grid-column: span 2; }
.field label, .field-label { display: block; margin-bottom: .38rem; color: var(--ink-800); font-size: .74rem; font-weight: 680; }
.required::after { content: " *"; color: var(--red-700); }
.input, .select, .textarea {
  width: 100%; min-height: 2.65rem; padding: .62rem .76rem; border: 1px solid var(--ink-200);
  border-radius: var(--radius-md); outline: none; background: white; color: var(--ink-950); font-size: .82rem;
  box-shadow: inset 0 1px 1px rgb(23 32 31 / .02); transition: border-color .14s, box-shadow .14s;
}
.textarea { min-height: 6rem; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--green-600); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: #9ba3a1; }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--ink-100); color: var(--ink-500); cursor: not-allowed; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; top: 50%; left: .76rem; color: var(--ink-500); font-size: .78rem; transform: translateY(-50%); }
.input-prefix .input { padding-left: 2.55rem; }
.field-help { margin: .3rem 0 0; color: var(--ink-500); font-size: .68rem; }
.field-error { margin: .3rem 0 0; color: var(--red-700); font-size: .68rem; }
.check-card { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem; border: 1px solid var(--ink-150); border-radius: var(--radius-md); background: var(--ink-50); }
.check-card input { width: 1rem; height: 1rem; flex: 0 0 auto; margin: .17rem 0 0; accent-color: var(--green-700); }
.check-card label { margin: 0; cursor: pointer; }
.check-card strong { display: block; color: var(--ink-800); font-size: .77rem; }
.check-card span { display: block; margin-top: .08rem; color: var(--ink-500); font-size: .68rem; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: .65rem; padding: 1rem 1.4rem; background: var(--ink-50); }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; min-height: 2.65rem; align-items: center; justify-content: center; padding: .5rem; border: 1px solid var(--ink-200); border-radius: var(--radius-md); background: white; color: var(--ink-600); font-size: .75rem; font-weight: 650; cursor: pointer; }
.segmented input:checked + span { border-color: var(--green-600); background: var(--green-50); color: var(--green-800); box-shadow: var(--focus); }
.segmented input:focus-visible + span { outline: 2px solid var(--green-600); outline-offset: 2px; }

/* Avisos e estados vazios */
.flash-stack { display: grid; gap: .55rem; margin-bottom: 1rem; }
.alert { display: flex; align-items: flex-start; gap: .7rem; min-height: 2.8rem; padding: .7rem .8rem; border: 1px solid; border-radius: var(--radius-md); font-size: .78rem; transition: .18s ease; }
.alert p { flex: 1; margin: .08rem 0 0; }
.alert button { padding: 0 .2rem; border: 0; background: transparent; color: currentColor; font-size: 1.15rem; line-height: 1; opacity: .55; }
.alert-icon { display: grid; width: 1.25rem; height: 1.25rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: currentColor; color: white; font-size: .65rem; font-weight: 800; }
.alert-success { border-color: #b9dacf; background: var(--green-50); color: var(--green-800); }
.alert-info { border-color: #c7dee9; background: var(--blue-50); color: var(--blue-800); }
.alert-warning { border-color: #efd9ad; background: var(--amber-50); color: var(--amber-800); }
.alert-danger { border-color: #f0c6c3; background: var(--red-50); color: var(--red-800); }
.alert.is-leaving { opacity: 0; transform: translateY(-.35rem); }
.notice-list { display: grid; gap: .55rem; }
.notice-item { display: flex; align-items: flex-start; gap: .65rem; padding: .72rem; border-radius: var(--radius-md); background: var(--ink-50); }
.notice-item > span:first-child { display: grid; width: 1.5rem; height: 1.5rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--amber-100); color: var(--amber-800); font-size: .7rem; font-weight: 800; }
.notice-item strong { display: block; font-size: .75rem; }
.notice-item p { margin: .12rem 0 0; color: var(--ink-600); font-size: .68rem; }
.empty-state { display: grid; min-height: 17rem; padding: 2.5rem 1.25rem; place-items: center; text-align: center; }
.empty-state-compact { min-height: 11rem; padding: 1.5rem 1rem; }
.empty-state-icon { display: grid; width: 3.2rem; height: 3.2rem; margin: 0 auto .9rem; place-items: center; border-radius: 1rem; background: var(--green-50); color: var(--green-700); }
.empty-state-icon svg { width: 1.55rem; }
.empty-state h2, .empty-state h3 { margin: 0; font-size: .95rem; }
.empty-state p { max-width: 24rem; margin: .35rem auto 1rem; color: var(--ink-600); font-size: .76rem; }

/* Uploads e documentos */
.upload-layout { display: grid; grid-template-columns: minmax(18rem, .7fr) minmax(0, 1.3fr); gap: .95rem; align-items: start; }
.dropzone { position: relative; display: grid; min-height: 11.5rem; padding: 1.25rem; place-items: center; border: 1.5px dashed var(--ink-300); border-radius: var(--radius-lg); background: var(--ink-50); text-align: center; transition: .16s ease; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--green-600); background: var(--green-50); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-icon { display: grid; width: 2.8rem; height: 2.8rem; margin: 0 auto .7rem; place-items: center; border-radius: .85rem; background: white; color: var(--green-700); box-shadow: var(--shadow-sm); }
.dropzone-icon svg { width: 1.3rem; }
.dropzone strong { display: block; font-size: .8rem; }
.dropzone span { display: block; margin-top: .25rem; color: var(--ink-500); font-size: .68rem; }
.file-list { display: grid; gap: .6rem; }
.file-card { display: flex; align-items: center; gap: .8rem; padding: .8rem; border: 1px solid var(--ink-150); border-radius: var(--radius-md); background: white; }
.file-type { display: grid; width: 2.4rem; height: 2.7rem; flex: 0 0 auto; place-items: center; border-radius: .55rem; background: var(--red-50); color: var(--red-800); font-size: .62rem; font-weight: 800; }
.file-type svg { width: 1.15rem; height: 1.15rem; }
.file-type-image { background: var(--blue-50); color: var(--blue-800); }
.file-meta { min-width: 0; flex: 1; }
.file-meta strong { display: block; overflow: hidden; color: var(--ink-950); font-size: .77rem; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { display: block; margin-top: .12rem; color: var(--ink-500); font-size: .66rem; }

/* Filtros, listas e outros */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; padding: .75rem; border-bottom: 1px solid var(--ink-150); background: var(--ink-50); }
.filter-bar .input, .filter-bar .select { min-height: 2.25rem; width: auto; min-width: 9rem; padding-top: .45rem; padding-bottom: .45rem; font-size: .74rem; }
.filter-search { position: relative; min-width: min(100%, 15rem); flex: 1; }
.filter-search svg { position: absolute; top: 50%; left: .7rem; width: .9rem; color: var(--ink-500); transform: translateY(-50%); }
.filter-search .input { width: 100%; padding-left: 2.05rem; }
.summary-strip { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: .8rem 1rem; border-top: 1px solid var(--ink-150); background: var(--ink-50); }
.summary-strip span { color: var(--ink-500); font-size: .7rem; }
.summary-strip strong { margin-left: .25rem; color: var(--ink-800); font-variant-numeric: tabular-nums; }
.pill-tabs { display: inline-flex; gap: .2rem; padding: .23rem; border: 1px solid var(--ink-150); border-radius: var(--radius-md); background: var(--ink-100); }
.pill-tabs a { padding: .38rem .65rem; border-radius: .52rem; color: var(--ink-600); font-size: .7rem; font-weight: 650; }
.pill-tabs a.is-active { background: white; color: var(--ink-950); box-shadow: var(--shadow-xs); }
.definition-list { margin: 0; }
.definition-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--ink-150); }
.definition-list > div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--ink-600); font-size: .72rem; }
.definition-list dd { margin: 0; font-size: .78rem; font-weight: 650; text-align: right; }
.callout { padding: 1rem; border: 1px solid #c6ddd5; border-radius: var(--radius-md); background: var(--green-50); }
.callout h3 { margin: 0 0 .2rem; color: var(--green-900); font-size: .82rem; }
.callout p { margin: 0; color: var(--green-800); font-size: .72rem; }
.danger-zone { border-color: #efcfcc; }
.danger-zone .card-header { background: var(--red-50); }
.danger-zone .card-header h2 { color: var(--red-800); }
.error-page { display: grid; min-height: calc(100vh - var(--topbar-height) - 10rem); place-items: center; text-align: center; }
.error-code { color: var(--green-700); font-size: clamp(4rem, 12vw, 8rem); font-weight: 800; letter-spacing: -.08em; line-height: .9; opacity: .18; }
.error-page h1 { margin: -1rem 0 .5rem; font-size: 1.5rem; }
.error-page p { max-width: 28rem; margin: 0 auto 1.25rem; color: var(--ink-600); }

/* Responsividade */
@media (min-width: 62.01rem) {
  .app-shell.is-sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
  }
  .app-shell.is-sidebar-collapsed .sidebar {
    padding: 1.15rem 0.15rem .8rem;
    align-items: center;
  }
  .app-shell.is-sidebar-collapsed .sidebar-head {
    flex-direction: row;
    justify-content: space-between;
    gap: .15rem;
  }
  .app-shell.is-sidebar-collapsed .brand {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .brand-text {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
  }
  .app-shell.is-sidebar-collapsed .sidebar-toggle:hover svg {
    transform: rotate(180deg) scale(1.15);
  }
  .app-shell.is-sidebar-collapsed .nav-list {
    margin-top: 1.25rem;
    width: 100%;
  }
  .app-shell.is-sidebar-collapsed .nav-label {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .nav-label-spaced {
    display: block;
    height: 1px;
    margin: 0.75rem 0.35rem;
    background: rgb(255 255 255 / .1);
    font-size: 0;
    padding: 0;
    border: 0;
  }
  .app-shell.is-sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.65rem 0;
    gap: 0;
  }
  .app-shell.is-sidebar-collapsed .nav-item span {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .nav-item.is-active {
    box-shadow: none;
    border-color: var(--mint, #7fc4a9);
    background: rgb(255 255 255 / .14);
  }
  .app-shell.is-sidebar-collapsed .sidebar-foot {
    padding: 0.75rem 0.2rem 0.2rem;
    align-items: center;
    width: 100%;
  }
  .app-shell.is-sidebar-collapsed .sidebar-status-text {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .sidebar-status-wrap {
    justify-content: center;
    margin-bottom: 0.2rem;
  }
  .app-shell.is-sidebar-collapsed .logout-text {
    display: none;
  }
  .app-shell.is-sidebar-collapsed .sidebar-logout-btn {
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    margin: 0 auto;
    border-radius: 0.55rem;
  }
}

@media (max-width: 74rem) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1.35fr) minmax(16rem, .8fr); }
}

@media (max-width: 62rem) {
  .sidebar-toggle { display: none !important; }
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-md); transition: transform .2s ease; }
  .menu-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 35; inset: 0; display: block; pointer-events: none; background: rgb(10 20 18 / .45); opacity: 0; transition: opacity .2s; }
  .menu-open + .sidebar-scrim, .menu-open ~ .sidebar-scrim { pointer-events: auto; opacity: 1; }
  .app-main { margin-left: 0; }
  .mobile-menu-button { display: inline-grid !important; }
  .dashboard-grid, .upload-layout { grid-template-columns: 1fr; }
}

@media (max-width: 46rem) {
  :root { --topbar-height: 4.25rem; }
  body { padding-bottom: 4.65rem; }
  .topbar { padding: 0 .85rem; }
  .period-label { display: none; }
  .period-field { min-width: 9.75rem; height: 2.45rem; }
  .topbar-status { margin-left: .55rem; }
  .topbar-status .badge { max-width: 5.6rem; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 1.35rem .9rem 2rem; }
  .page-header { align-items: stretch; flex-direction: column; gap: .9rem; }
  .page-title { font-size: 1.55rem; }
  .page-actions { justify-content: flex-start; }
  .page-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .metric-card { min-height: 7.7rem; padding: .85rem; }
  .metric-value { font-size: 1.12rem; }
  .metric-label { align-items: flex-start; font-size: .67rem; }
  .metric-icon { width: 1.65rem; height: 1.65rem; }
  #painel-despesas-fixos .card-header { flex-direction: column; }
  .expense-summary { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .expense-summary-item { min-width: 0; }
  .people-split { grid-template-columns: 1fr; gap: .6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .form-section { padding: 1.1rem 1rem; }
  .form-actions { position: sticky; z-index: 10; bottom: 4.55rem; padding: .8rem 1rem; border-top: 1px solid var(--ink-150); box-shadow: 0 -8px 24px rgb(23 32 31 / .06); }
  .form-actions .button { flex: 1; }
  .segmented { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; }
  .filter-bar .input, .filter-bar .select { width: 100%; }
  .filter-search { min-width: 100%; }
  .data-table-responsive thead { display: none; }
  .data-table-responsive, .data-table-responsive tbody, .data-table-responsive tr, .data-table-responsive td { display: block; width: 100%; }
  .data-table-responsive tr { padding: .8rem .9rem; border-bottom: 1px solid var(--ink-150); }
  .data-table-responsive tbody tr:last-child { border-bottom: 0; }
  .data-table-responsive td { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; padding: .22rem 0; border: 0; text-align: right; }
  .data-table-responsive td::before { content: attr(data-label); flex: 0 0 auto; color: var(--ink-500); font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
  .data-table-responsive td:first-child { display: block; margin-bottom: .32rem; text-align: left; }
  .data-table-responsive td:first-child::before { display: none; }
  .data-table-responsive .actions { width: 100%; margin-top: .45rem; padding-top: .55rem; border-top: 1px dashed var(--ink-200); }
  .data-table-responsive .actions::before { display: none; }
  .row-actions { width: 100%; }
  .row-action { min-height: 2.25rem; flex: 1; justify-content: center; background: var(--ink-50); }
  .mobile-nav {
    position: fixed; z-index: 32; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, 1fr);
    height: 4.5rem; padding: .35rem .4rem max(.35rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--ink-150); background: rgb(255 254 251 / .96); box-shadow: 0 -8px 25px rgb(23 32 31 / .07);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .mobile-nav > a { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: .18rem; color: var(--ink-500); font-size: .58rem; font-weight: 650; }
  .mobile-nav > a > svg { width: 1.25rem; height: 1.25rem; }
  .mobile-nav > a.is-active { color: var(--green-800); }
  .mobile-nav-add { transform: translateY(-.65rem); }
  .mobile-nav-add > span { display: grid; width: 2.8rem; height: 2.8rem; place-items: center; border: 3px solid var(--paper); border-radius: 50%; background: var(--green-800); color: white; box-shadow: 0 5px 14px rgb(23 63 58 / .24); }
  .mobile-nav-add > span svg { width: 1.25rem; }
  .mobile-nav-add small { color: var(--green-800); font-size: .58rem; font-weight: 700; }
  .app-footer { display: none; }
}

@media (max-width: 24rem) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar-status { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .mobile-nav, .app-footer, .page-actions, .row-actions, .filter-bar { display: none !important; }
  .app-main { margin: 0; }
  .page { max-width: none; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* Estilos para o Scanner OCR e Modal de Confirmação */
.ocr-status-scanner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--green-50);
  border: 1px solid var(--mint);
  color: var(--green-900);
  font-size: 0.85rem;
}
.ocr-status-scanner .spinner-icon {
  animation: pulse-spin 1.2s infinite ease-in-out;
}
@keyframes pulse-spin {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}
.modal-ocr-dialog {
  width: min(44rem, calc(100% - 2rem));
  margin: auto;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgb(16 31 28 / .25);
}

/* ==========================================================================
   Classes Utilitárias (APE 303 Layout Utilities)
   ========================================================================== */

/* Alinhamento de Texto */
.u-text-center { text-align: center !important; }
.u-text-right  { text-align: right !important; }
.u-text-left   { text-align: left !important; }

/* Flexbox */
.u-flex               { display: flex !important; }
.u-inline-flex        { display: inline-flex !important; }
.u-flex-center        { display: flex !important; align-items: center !important; }
.u-inline-flex-center { display: inline-flex !important; align-items: center !important; }
.u-flex-between       { display: flex !important; align-items: center !important; justify-content: space-between !important; }
.u-justify-center     { justify-content: center !important; }
.u-justify-between    { justify-content: space-between !important; }
.u-justify-end        { justify-content: flex-end !important; }
.u-items-center       { align-items: center !important; }

/* Espaçamento: Gap (escala existente: .35rem, .5rem, .75rem, 1rem) */
.u-gap-xs { gap: .35rem !important; }
.u-gap-sm { gap: .5rem !important; }
.u-gap-md { gap: .75rem !important; }
.u-gap-lg { gap: 1rem !important; }

/* Espaçamento: Margin-Bottom (escala existente: .5rem, 1rem, 1.5rem) */
.u-mb-0 { margin-bottom: 0 !important; }
.u-mb-1 { margin-bottom: .5rem !important; }
.u-mb-2 { margin-bottom: 1rem !important; }
.u-mb-3 { margin-bottom: 1.5rem !important; }

/* Margem geral */
.u-m-0 { margin: 0 !important; }

/* ==========================================================================
   Refinamento visual — sistema compacto e consistente
   ========================================================================== */
:root {
  --sidebar-width: 15.5rem;
  --topbar-height: 4.4rem;
  --radius-sm: .45rem;
  --radius-md: .65rem;
  --radius-lg: .85rem;
  --radius-xl: 1.05rem;
  --shadow-xs: 0 1px 2px rgb(23 32 31 / .04);
  --shadow-sm: 0 5px 14px rgb(23 32 31 / .055);
  --shadow-md: 0 14px 32px rgb(23 32 31 / .10);
}

body { background: #f5f6f3; font-size: .9rem; }
.sidebar { padding: 1.15rem .85rem .8rem; }
.nav-list { margin-top: 1.55rem; }
.nav-label { margin-bottom: .4rem; font-size: .64rem; }
.nav-label-spaced { margin-top: 1.2rem; }
.nav-item { min-height: 2.55rem; margin: .12rem 0; padding: .48rem .62rem; border-radius: .62rem; font-size: .82rem; }
.nav-item svg { width: 1.1rem; height: 1.1rem; }
.nav-item.is-active { background: rgb(255 255 255 / .13); box-shadow: inset 2px 0 var(--mint); }
.sidebar-foot { padding: .7rem .55rem .1rem; font-size: .68rem; }

.topbar { padding: 0 clamp(1rem, 2.6vw, 2rem); background: rgb(255 254 251 / .88); }
.period-field { height: 2.2rem; min-width: 10.25rem; border-radius: .6rem; }
.period-label { font-size: .62rem; }
.topbar-status .badge { padding: .3rem .6rem; }
.page { max-width: 94rem; padding: 1.45rem clamp(1rem, 2.6vw, 2rem) 2.25rem; }
.app-footer { padding-bottom: 1rem; font-size: .67rem; }

.page-header { gap: 1rem; margin-bottom: 1.15rem; }
.page-kicker { margin-bottom: .22rem; font-size: .64rem; letter-spacing: .09em; }
.page-title { font-size: clamp(1.45rem, 2.7vw, 1.9rem); }
.page-description { margin-top: .3rem; font-size: .82rem; }
.section-heading { margin: 1.35rem 0 .7rem; }

.button { min-height: 2.35rem; padding: .52rem .82rem; border-radius: .6rem; font-size: .78rem; }
.button-primary { box-shadow: 0 3px 8px rgb(23 63 58 / .12); }
.button-primary:hover { transform: none; box-shadow: 0 4px 10px rgb(23 63 58 / .16); }
.button-secondary { box-shadow: none; }
.button-small { min-height: 2rem; padding: .38rem .62rem; font-size: .71rem; }
.icon-button { width: 2.15rem; height: 2.15rem; border-radius: .55rem; box-shadow: none; }
.badge { padding: .23rem .48rem; font-size: .64rem; }

.card { border-color: #e3e7e2; border-radius: .85rem; box-shadow: none; }
.card-header { padding: .9rem 1rem; gap: .8rem; }
.card-header h2, .card-header h3 { font-size: .88rem; }
.card-header p { margin-top: .16rem; font-size: .71rem; }
.card-body { padding: 1rem; }
.card-footer { padding: .72rem 1rem; }
.u-mb-3 { margin-bottom: 1rem !important; }

.metric-card { min-height: 7.3rem; padding: .9rem 1rem; }
.metric-value { margin: .52rem 0 .16rem; font-size: clamp(1.15rem, 1.8vw, 1.42rem); }
.metric-detail, .metric-label { font-size: .68rem; }
.metric-icon { width: 1.75rem; height: 1.75rem; border-radius: .5rem; }
.people-split { gap: .75rem; }
.person-share:not(.metric-card) { padding: .75rem; }

@media (min-width: 46.01rem) {
  .data-table { font-size: .75rem; }
  .data-table th { padding: .58rem .85rem; font-size: .61rem; }
  .data-table td { padding: .68rem .85rem; }
}
.data-table .cell-subtitle { margin-top: .08rem; font-size: .65rem; }
.data-table tbody tr:hover { background: #f8faf7; }
.icon-btn { width: 1.72rem; height: 1.72rem; min-height: 1.72rem; border-radius: .48rem; }
.icon-btn svg { width: .98rem; height: .98rem; }
.row-actions { gap: .1rem; }
.filter-bar { gap: .5rem; padding: .6rem .75rem; }
.filter-bar .input, .filter-bar .select { min-height: 2.1rem; font-size: .71rem; }
.summary-strip { gap: .35rem 1rem; padding: .65rem .85rem; }

.form-shell { max-width: 52rem; }
.form-section { padding: 1rem 1.1rem; }
.form-section-heading { margin-bottom: .75rem; }
.form-grid { gap: .75rem; }
.field label, .field-label { margin-bottom: .28rem; font-size: .7rem; }
.input, .select, .textarea { min-height: 2.4rem; padding: .52rem .65rem; border-radius: .6rem; font-size: .78rem; }
.textarea { min-height: 5rem; }
.field-help, .field-error { margin-top: .22rem; font-size: .64rem; }
.check-card { gap: .55rem; padding: .65rem .7rem; border-radius: .6rem; }
.check-card strong { font-size: .73rem; }
.check-card span { font-size: .64rem; }
.form-actions { gap: .5rem; padding: .75rem 1.1rem; }
.dropzone { min-height: 9rem; padding: 1rem; }
.empty-state { min-height: 13rem; padding: 1.75rem 1rem; }
.empty-state-compact { min-height: 7.5rem; padding: 1rem; }
.empty-state-icon { width: 2.65rem; height: 2.65rem; margin-bottom: .65rem; border-radius: .75rem; }

.entry-tabs { display: flex; align-items: center; gap: .15rem; overflow-x: auto; margin-bottom: 1rem; padding: .45rem .55rem 0; border-bottom: 1px solid var(--ink-150); background: var(--ink-50); scrollbar-width: thin; }
.entry-tab { display: inline-flex; min-height: 2.35rem; align-items: center; gap: .42rem; padding: .44rem .72rem; border-bottom: 2px solid transparent; color: var(--ink-600); font-size: .78rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.entry-tab svg { width: 1rem !important; height: 1rem !important; }
.entry-tab:hover { color: var(--green-800); }
.entry-tab.is-active { border-bottom-color: var(--green-700); background: var(--paper); color: var(--green-800); }

.admin-tabs { display: flex; align-items: center; gap: .15rem; overflow-x: auto; padding: .45rem .55rem 0; border-bottom: 1px solid var(--ink-150); background: var(--ink-50); scrollbar-width: thin; }
.admin-tab { display: inline-flex; min-height: 2.25rem; align-items: center; gap: .38rem; padding: .42rem .62rem; border-bottom: 2px solid transparent; color: var(--ink-600); font-size: .72rem; font-weight: 680; text-decoration: none; white-space: nowrap; }
.admin-tab svg { width: .92rem; height: .92rem; }
.admin-tab:hover { color: var(--green-800); }
.admin-tab.is-active { border-bottom-color: var(--green-700); background: var(--paper); color: var(--green-800); }
.admin-tabs + section { padding: 0 .95rem 1rem; }
.admin-tabs + section .card-header { padding: .85rem 0 !important; }
.admin-tabs + section .form-section { padding: .85rem 0 0; border: 0; }
.business-rules { padding: 1rem !important; }
.admin-section-heading { margin-bottom: .9rem; }
.admin-section-heading h2 { margin: 0; font-size: 1.05rem; }
.admin-section-heading p:not(.page-kicker) { margin: .25rem 0 0; color: var(--ink-600); font-size: .78rem; line-height: 1.55; }
.business-rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.business-rule-card { display: flex; gap: .65rem; padding: .8rem; border: 1px solid var(--ink-150); border-radius: .65rem; background: var(--paper); }
.business-rule-number { display: grid; width: 1.8rem; height: 1.8rem; flex: 0 0 auto; place-items: center; border-radius: .5rem; background: var(--green-50); color: var(--green-800); font-size: .62rem; font-weight: 800; }
.business-rule-card h3 { margin: .05rem 0 .22rem; color: var(--ink-900); font-size: .79rem; }
.business-rule-card p { margin: 0; color: var(--ink-600); font-size: .72rem; line-height: 1.52; }

.page-header-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-header-actions .button { flex: 0 0 auto; }
.report-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; margin-bottom: 1rem; }
.report-stat { min-height: 7.15rem; padding: .9rem; border: 1px solid var(--ink-150); border-radius: .75rem; background: var(--paper); box-shadow: 0 1px 2px rgb(23 32 31 / .03); }
.report-stat > span { display: block; color: var(--ink-600); font-size: .72rem; font-weight: 700; }
.report-stat strong { display: block; margin: .42rem 0 .2rem; color: var(--ink-950); font-size: 1.08rem; letter-spacing: -.035em; }
.report-stat small { display: block; color: var(--ink-500); font-size: .66rem; line-height: 1.35; }
.report-section { margin-bottom: .85rem; overflow: hidden; }
.report-section .card-header { align-items: flex-start; }
.report-section .card-header h2 { margin: .1rem 0; }
.report-section .card-header p:not(.page-kicker) { margin: 0; color: var(--ink-600); font-size: .74rem; }
.report-empty { padding: 1.15rem 1rem; color: var(--ink-600); font-size: .78rem; text-align: center; }

@media (max-width: 46rem) {
  :root { --topbar-height: 4rem; }
  .page { padding: 1rem .8rem 1.5rem; }
  .page-header { margin-bottom: 1rem; }
  .entry-tabs { padding-left: .35rem; padding-right: .35rem; }
  .entry-tab { flex: 0 0 auto; }
  .card-header, .card-body { padding-left: .85rem; padding-right: .85rem; }
  .form-section { padding: .9rem .85rem; }
  .admin-tabs { padding-left: .35rem; padding-right: .35rem; }
  .admin-tab { flex: 0 0 auto; }
  .business-rules-grid { grid-template-columns: 1fr; }
  .page-header-actions { align-items: flex-start; flex-direction: column; }
  .report-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 28rem) {
  .report-summary-grid { grid-template-columns: 1fr; }
}


/* Faturas e pendências: texto legível e imagem integral em telas estreitas. */
.document-preview { width: min(94vw, 960px); height: 88dvh; padding: 0; border: 1px solid var(--ink-200); border-radius: .75rem; }
.document-preview-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.document-preview-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem; border-bottom: 1px solid var(--ink-200); }
.document-preview-header h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.document-preview-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.barcode-area { padding: .75rem 1rem; text-align: center; background: white; color: #111; }
.barcode-image-wrap { overflow-x: auto; }
.barcode-image-wrap img { display: block; width: 100%; height: auto; margin: 0 auto; }
.document-preview.barcode-only { height: fit-content; max-height: 88dvh; }
.document-preview.barcode-only .document-preview-content { height: auto; }
.barcode-image-wrap img[hidden] { display: none; }
.barcode-number { font-family: monospace; font-size: 1rem; overflow-wrap: anywhere; user-select: all; }
.barcode-status { margin: 0; padding: .75rem 1rem; overflow-wrap: anywhere; }
.barcode-status:empty { display: none; }
#modal-preview-iframe { flex: 1; min-height: 160px; width: 100%; border: 0; }
.email-pending { border-left: 4px solid var(--red-600, #b42318); }
.email-pending-list { list-style: none; margin: 0; padding: 0 1.25rem; }
.email-pending-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--ink-200); }
.email-pending-list li > div { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.email-pending-list p { margin: .35rem 0; }
.cpf-person-form { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.cpf-person-form .input { width: 180px; }
