/* Acabamento compartilhado para todas as telas. */
html { scroll-behavior: smooth; }

/* Barras nativas com acabamento do site: arraste, teclado e toque continuam
   a cargo do navegador, sem criar outra camada de rolagem em JavaScript. */
:root {
  color-scheme: dark;
  --scroll-track: #09090b;
  --scroll-thumb: #3f3f46;
  --scroll-thumb-hover: #10b981;
}
html[data-tema="claro"] {
  color-scheme: light;
  --scroll-track: #f6f7fb;
  --scroll-thumb: #c4c7d2;
  --scroll-thumb-hover: #10b981;
}
html { scrollbar-gutter: stable; }
html, body * {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
@supports selector(::-webkit-scrollbar) {
  html, body *, .site-nav { scrollbar-width: auto; scrollbar-color: auto; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--scroll-track); }
  ::-webkit-scrollbar-thumb {
    min-height: 36px;
    border: 2px solid var(--scroll-track);
    border-radius: 999px;
    background: var(--scroll-thumb);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
  ::-webkit-scrollbar-thumb:active { background: var(--gold, #e8b23d); }
  ::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
}
@media (forced-colors: active) {
  html, body * { scrollbar-color: auto; }
}

/* A confirmação usa a camada superior do navegador para aparecer acima de
   menus e outros painéis, com foco e interação restritos à janela aberta. */
html.ui-confirm-open { overflow: hidden; }
.ui-confirm-dialog {
  position: fixed;
  inset: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 28px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px #0006;
  font: 15px/1.5 "Inter", system-ui, sans-serif;
}
.ui-confirm-dialog[open] { animation: ui-confirm-in 200ms cubic-bezier(.22,.8,.28,1); }
.ui-confirm-dialog::backdrop { background: rgba(5, 9, 16, .7); }
.ui-confirm-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 13%, var(--surface));
  color: var(--gold);
}
.ui-confirm-icon svg { width: 23px; height: 23px; }
.ui-confirm-dialog h2 { margin: 0 0 10px; font: 600 22px/1.25 "Inter", system-ui, sans-serif; }
.ui-confirm-dialog p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.ui-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.ui-confirm-actions > button { flex: 1; }
@keyframes ui-confirm-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 480px) {
  .ui-confirm-dialog { padding: 22px; }
}

/* Campos e caixas respondem ao clique sem deslocar o layout. */
body :where(:is(input, select, textarea, .ui-select-trigger)) {
  transition: border-color var(--motion-standard,240ms) var(--motion-ease,ease),
    box-shadow var(--motion-standard,240ms) var(--motion-ease,ease),
    background-color var(--motion-standard,240ms) var(--motion-ease,ease);
}
body :where(:is(input, textarea):focus,
.ui-select-trigger:focus-visible) {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent),
    0 8px 18px rgba(0,0,0,.12);
}
body :where(:is(.card, .contas-panel, .filter-panel, .chart-card, .config-section)) {
  transition: border-color .3s ease, box-shadow .3s ease, transform .3s ease;
}
body :where(:is(.card, .contas-panel, .filter-panel, .chart-card, .config-section):focus-within) {
  border-color: color-mix(in srgb, var(--gold) 62%, var(--border));
}

button,
.btn,
.btn-gold,
.btn-secondary,
.btn-danger,
.btn-cancel,
.contas-btn,
.contas-link {
  -webkit-tap-highlight-color: transparent;
}

body :where(:is(.btn, .btn-gold, .btn-secondary, .btn-danger, .btn-cancel,
  .contas-btn, button[type="submit"]):not(.icon-btn):not(.sidebar-foot button)) {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  box-shadow: 0 5px 14px rgba(0,0,0,.12);
}

body :where(:is(.btn-gold, .contas-btn, button[type="submit"]):not(.icon-btn):not(.sidebar-foot button)) {
  background-image: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 78%, #fff));
  border: 0;
  box-shadow: none;
  outline: none;
}

body :where(:is(.btn, .btn-gold, .btn-secondary, .btn-danger, .btn-cancel,
  .contas-btn, .contas-link, button[type="submit"]):not(.icon-btn):not(.sidebar-foot button):hover) {
  filter: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}

body :where(:is(.btn, .btn-gold, .btn-secondary, .btn-danger, .btn-cancel,
  .contas-btn, .contas-link, button[type="submit"]):not(.icon-btn):not(.sidebar-foot button):active) {
  transform: none;
}

body :where(:is(.btn-gold, .contas-btn, button[type="submit"]):not(.icon-btn):not(.sidebar-foot button):focus-visible) {
  outline: 2px solid color-mix(in srgb, var(--gold) 72%, #fff);
  outline-offset: 2px;
}

/* Selectores personalizados: o select original continua no formulário para
   preservar validação, acessibilidade e envio dos dados. */
.ui-select-source {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
}
.ui-select-menu .ui-select-option[hidden] { display: none; }

.ui-select-shell { position: relative; width: 100%; min-width: 0; margin-bottom: 12px; }
.ui-select-shell.is-open { z-index: 1000; }
.contas-inline .ui-select-shell { width: auto; min-width: 210px; flex: 1; margin: 0; }
.ui-select-shell .ui-select-trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--sr);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.ui-select-trigger::after {
  content: '';
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .75;
  transition: transform var(--motion-standard,240ms) var(--motion-ease,ease), opacity var(--motion-fast,150ms) ease;
}
.ui-select-shell.is-open .ui-select-trigger::after { transform: rotate(225deg) translate(-1px,-1px); opacity: 1; }
.ui-select-shell.is-open .ui-select-trigger,
.ui-select-trigger:focus-visible {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent);
}
.ui-select-trigger:disabled { opacity: .5; cursor: not-allowed; }
.ui-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 1600;
  display: grid;
  gap: 2px;
  max-height: min(360px, 50vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(0,0,0,.32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-7px) scale(.99);
  transform-origin: top center;
  transition: opacity 180ms ease, transform var(--motion-standard,240ms) var(--motion-ease,ease),
    visibility 0s linear var(--motion-standard,240ms);
}
.ui-select-shell.is-open .ui-select-menu { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition-delay: 0s; }
.ui-select-option {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ui-select-option:hover,
.ui-select-option:focus-visible { background: var(--sr); border-color: var(--border); outline: none; }
.ui-select-option.is-selected { background: var(--sr); border-color: var(--border); }
.ui-select-option:disabled { opacity: .45; cursor: not-allowed; }

/* O motion.css usa transform para a entrada dos blocos, criando camadas
   separadas. O :has eleva exatamente o formulário que contém o seletor aberto
   para que as opções nunca fiquem atrás do bloco seguinte. */
body :where(:is(.card, .contas-panel, .filter-panel, .contas-barra,
  .period, .dashboard-bank-selector, .north-dashboard-toolbar,
  .north-dashboard-filters):has(.ui-select-shell.is-open)) {
  position: relative;
  z-index: 1500;
  overflow: visible;
}

/* O dashboard possui cards com transform/backdrop-filter logo abaixo dos
   filtros. Mantemos a toolbar em uma camada superior para que o menu inteiro
   apareca acima do saldo disponivel e continue clicavel. */
.north-dashboard-toolbar{
  position:relative;
  z-index:30;
  overflow:visible;
}
.north-dashboard-toolbar:has(.ui-select-shell.is-open){z-index:1500}
.north-dashboard-filters{overflow:visible}
.north-dashboard-hero{position:relative;z-index:1}

@media (max-width: 800px) {
  .contas-inline .ui-select-shell { width: 100%; min-width: 0; }
  .ui-select-menu { max-height: min(360px, 55vh); overflow-x: hidden; overflow-y: auto; }
  .ui-select-shell .ui-select-trigger { min-height: 48px; font-size: 16px; }
  .ui-select-option { min-height: 44px; padding: 11px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Base visual único: evita que cada tela trate botões e cartões de uma forma
   diferente. A referência é o botão "Aplicar período" do painel. */
:root {
  --ui-control-height: 44px;
  --ui-control-radius: 10px;
  --ui-control-font: 600 14px/1.15 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-shadow-rest: 0 7px 20px rgba(4, 120, 87, .18), 0 0 14px rgba(16, 185, 129, .10);
  --ui-shadow-hover: 0 10px 28px rgba(4, 120, 87, .26), 0 0 18px rgba(34, 197, 94, .28), 0 0 36px rgba(5, 150, 105, .12);
}

html {
  scroll-behavior: smooth;
  scroll-padding-block: 20px;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ações principais: mesma altura, fonte, curvatura e resposta tátil em todas
   as páginas, inclusive login, conta, dados e telas que usam estilos antigos. */
body :where(:is(button[type="submit"], .btn, .btn-gold, .contas-btn, .button):not(.icon-btn):not(.sidebar-foot button):not(.btn-secondary):not(.btn-danger):not(.btn-cancel):not(.contas-link):not(.contas-danger):not(.secondary)) {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ui-control-height);
  padding: 11px 16px;
  border: 0;
  border-radius: var(--ui-control-radius);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font: var(--ui-control-font);
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--ui-shadow-rest);
  transition: transform 180ms var(--motion-ease, cubic-bezier(.22,.8,.28,1)),
    box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

/* Ações secundárias mantêm sua hierarquia, mas usam o mesmo desenho e a mesma
   tipografia para não parecerem controles de outro sistema. */
body :where(:is(.btn-secondary, .btn-cancel, .contas-link, .button.secondary):not(.icon-btn):not(.sidebar-foot button)) {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ui-control-height);
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: var(--ui-control-radius);
  background: color-mix(in srgb, var(--surface) 82%, var(--sr));
  color: var(--text);
  font: var(--ui-control-font);
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition: transform 160ms var(--motion-ease, cubic-bezier(.22,.8,.28,1)), box-shadow 160ms ease,
    border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

body :where(:is(.btn-danger, .contas-danger):not(.icon-btn):not(.sidebar-foot button)) {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ui-control-height);
  padding: 10px 15px;
  border: 1px solid color-mix(in srgb, var(--red, #e1584a) 54%, var(--border));
  border-radius: var(--ui-control-radius);
  background: color-mix(in srgb, var(--red, #e1584a) 9%, var(--surface));
  color: var(--red, #e1584a);
  font: var(--ui-control-font);
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition: transform 160ms var(--motion-ease, cubic-bezier(.22,.8,.28,1)), box-shadow 160ms ease,
    border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

body :where(:is(button[type="submit"], .btn, .btn-gold, .contas-btn, .button,
  .btn-secondary, .btn-cancel, .contas-link, .btn-danger, .contas-danger):not(.icon-btn):not(.sidebar-foot button):focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--gold) 38%, transparent);
  outline-offset: 3px;
}

body :where(:is(button[type="submit"], .btn, .btn-gold, .contas-btn, .button,
  .btn-secondary, .btn-cancel, .contas-link, .btn-danger, .contas-danger):not(.icon-btn):not(.sidebar-foot button):disabled) {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

@media (hover: hover) {
  body :where(:is(button[type="submit"], .btn, .btn-gold, .contas-btn, .button):not(.icon-btn):not(.sidebar-foot button):not(.btn-secondary):not(.btn-danger):not(.btn-cancel):not(.contas-link):not(.contas-danger):not(.secondary):hover) {
    box-shadow: var(--ui-shadow-hover);
    transform: translateY(-1px);
  }

  body :where(:is(.btn-secondary, .btn-cancel, .contas-link, .button.secondary,
    .btn-danger, .contas-danger):not(.icon-btn):not(.sidebar-foot button):hover) {
    border-color: color-mix(in srgb, var(--gold) 52%, var(--border));
    box-shadow: 0 7px 18px rgba(0, 0, 0, .14);
    transform: translateY(-1px);
  }
}

body :where(:is(button[type="submit"], .btn, .btn-gold, .contas-btn, .button,
  .btn-secondary, .btn-cancel, .contas-link, .btn-danger, .contas-danger):not(.icon-btn):not(.sidebar-foot button):active) {
  transform: translateY(0) scale(.985);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* Feedback uniforme para operações POST. O botão acionado permanece um
   submitter válido até o navegador montar o corpo da requisição, mas novos
   cliques e envios por teclado são bloqueados pelo controlador em ui.js. */
form:is(.is-submitting,.is-routing) :is(button[type="submit"], input[type="submit"]) { cursor: wait; }
form:is(.is-submitting,.is-routing) [data-loading-active="true"] {
  pointer-events: none;
  opacity: .78;
}
form:is(.is-submitting,.is-routing) button[data-loading-active="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 9px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: north-submit-spin .7s linear infinite;
}
@keyframes north-submit-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  form:is(.is-submitting,.is-routing) button[data-loading-active="true"]::before { animation: none; }
}

/* Password controls share the input height, independently of its label. */
body .north-password-field { position: relative; margin-bottom: 13px; }
body .north-password-field > input { display: block; width: 100%; margin-bottom: 0; padding-right: 52px; }
body .north-password-field > .north-password-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 40px; min-height: 0;
  margin: 0; padding: 0; border: 0; border-radius: 6px;
  background: transparent; background-image: none; color: var(--muted); box-shadow: none; cursor: pointer;
}
body .north-password-toggle:hover { color: var(--text); }
body .north-password-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.north-password-toggle svg { width: 21px; height: 21px; pointer-events: none; }
.north-password-toggle[aria-pressed="false"] .north-eye-slash { display: none; }
.north-password-field > input::-ms-reveal { display: none; }
.north-start-banner { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; margin-bottom: 24px; border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 12px; background: var(--surface); }
.north-start-banner h2 { margin: 0 0 6px; font: 600 18px 'Inter', sans-serif; }
.north-start-banner p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.north-start-banner a { flex-shrink: 0; padding: 12px 0; color: var(--gold); font-weight: 600; font-size: 13px; }
@media(max-width:600px) { .north-start-banner { flex-direction: column; align-items: flex-start; gap: 6px; } }
