/* =====================================================================
   FH Soluções — estilos
   Breakpoints (mobile first):
     base      até 767px   celular (ref. iPhone 17 Pro Max ~440px): topo + barra inferior
     md  ≥ 768px            tablet  (ref. iPad 11" ~834px): menu lateral compacto (ícones)
     lg  ≥ 1200px           laptop  (ref. MacBook 13" 1280–1440px): menu lateral completo
   Espaçamento: múltiplos de 4px (--s-*). Tipografia: rem + clamp().
   ===================================================================== */
:root {
  /* cores da marca (mesmas de antes; cinza e verde de texto levemente mais escuros para WCAG AA) */
  --dark: #272727;
  --dark-2: #333333;
  --dark-3: #444444;
  --bg: #EFF1F3;
  --card: #FFFFFF;
  --field: #FAFBFC;
  --text: #1C1C1E;
  --text-2: #3A3F45;
  --muted: #5E6572;          /* 5,2:1 sobre --bg | 5,9:1 sobre branco */
  --line: #E4E7EB;
  --faint: #A3A9B1;          /* só ícones decorativos (setas) */
  --green: #17803D;
  --green-ink: #13672F;      /* texto verde sobre --green-bg: 6,2:1 */
  --green-bg: #E6F4EA;
  --red: #C62828;
  --red-bg: #FDECEC;
  --amber: #A15C00;
  --amber-bg: #FFF4E0;
  --blue: #1D4ED8;
  --blue-bg: #E8EEFD;
  --on-dark: #FFFFFF;
  --on-dark-2: rgba(255,255,255,.74);
  --on-dark-3: rgba(255,255,255,.62);
  --profit: #7EE2A0;
  /* papéis que mudam com o tema (as superfícies --dark* continuam escuras nos dois temas) */
  --ink: #272727;                 /* texto/ícone forte e item ativo */
  --primary-bg: #272727;          /* botão principal */
  --primary-fg: #FFFFFF;
  --nav-bg: rgba(255,255,255,.96);
  --hover: rgba(0,0,0,.05);
  --focus-ring: rgba(39,39,39,.12);
  --red-solid: #C62828;
  --wa: #16803F;
  --focus: var(--ink);

  /* espaçamento (4px) */
  --s-1: .25rem;  --s-2: .5rem;  --s-3: .75rem; --s-4: 1rem;   --s-5: 1.25rem;
  --s-6: 1.5rem;  --s-8: 2rem;   --s-10: 2.5rem; --s-12: 3rem; --s-16: 4rem;

  /* tipografia fluida (mín. no celular → máx. no laptop) */
  --fs-xs:   .75rem;                                         /* 12px: rótulos pequenos */
  --fs-sm:   clamp(.8125rem, .79rem + .1vw, .875rem);        /* 13–14px */
  --fs-base: clamp(.9375rem, .91rem + .12vw, 1rem);          /* 15–16px */
  --fs-md:   clamp(1rem, .96rem + .2vw, 1.125rem);           /* 16–18px */
  --fs-lg:   clamp(1.125rem, 1.06rem + .3vw, 1.3125rem);     /* 18–21px */
  --fs-xl:   clamp(1.375rem, 1.2rem + .8vw, 1.75rem);        /* 22–28px: título da página */
  --fs-2xl:  clamp(1.75rem, 1.45rem + 1.4vw, 2.375rem);      /* 28–38px: valor em destaque */
  --fs-title: clamp(1.75rem, 1.55rem + .8vw, 2.125rem);      /* 28–34px: título grande da página (HIG Large Title) */
  --lh-tight: 1.2;
  --lh: 1.5;

  /* forma — cantos concêntricos (HIG): canto interno = canto externo − espaçamento */
  --r-sm: .625rem; --r: .875rem; --r-lg: 1.25rem; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(20,20,20,.04), 0 4px 16px rgba(20,20,20,.04);
  --shadow-hover: 0 2px 4px rgba(20,20,20,.06), 0 12px 28px rgba(20,20,20,.08);
  --tap: 2.75rem;            /* 44px: alvo mínimo de toque */

  /* movimento (curvas e durações no padrão Apple) */
  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(0, 0, .58, 1);
  --ease-spring: cubic-bezier(.175, .885, .32, 1.275);
  --t-instant: .1s; --t-fast: .2s; --t-normal: .3s;
  --press: scale(.97);       /* resposta ao toque */

  /* estrutura */
  --nav-w: 0px;              /* largura do menu lateral no breakpoint atual */
  --topbar-h: 3.5rem;
  --bottomnav-h: 4rem;
  --content-max: 72rem;      /* 1152px: largura máxima do conteúdo */
  --gutter: var(--s-4);
}
/* ---------- modo escuro (Ajustes → Aparência) ---------- */
:root[data-tema="escuro"] {
  color-scheme: dark;
  --bg: #18191A; --card: #232425; --field: #2A2B2D;
  --text: #ECEEF0; --text-2: #C9CDD2; --muted: #A3A9B2; --line: #34363A; --faint: #6B7078;
  --green-ink: #7BD49B; --green-bg: #173524;
  --red: #F28B82; --red-bg: #3A1E1E;
  --amber: #F2C063; --amber-bg: #3A2E14;
  --blue: #9DB8FF; --blue-bg: #1C2A4A;
  --ink: #ECEEF0; --primary-bg: #ECEEF0; --primary-fg: #1C1C1E;
  --nav-bg: rgba(35,36,37,.96); --hover: rgba(255,255,255,.07); --focus-ring: rgba(236,238,240,.18);
  --wa: #5BD38A;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-hover: 0 2px 4px rgba(0,0,0,.35), 0 12px 28px rgba(0,0,0,.35);
}
:root[data-tema="escuro"] .hero, :root[data-tema="escuro"] .pw-box { box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }

@media (min-width: 768px)  { :root { --nav-w: 5.5rem; --gutter: var(--s-6); } }
@media (min-width: 1200px) { :root { --nav-w: 16rem;  --gutter: var(--s-8); } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: var(--fs-base); line-height: var(--lh);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: var(--lh-tight); text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, summary, .seg button { touch-action: manipulation; } /* toque responde na hora, sem esperar o zoom de dois toques */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg.i { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.hidden { display: none !important; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.brand-mark { width: 2rem; height: 2rem; border-radius: var(--s-2); flex: none; box-shadow: 0 0 0 1px rgba(255,255,255,.16); }
.logo-img { max-height: 2.75rem; max-width: 10.5rem; object-fit: contain; display: block; }
.logo-text { font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.02em; color: var(--on-dark); white-space: nowrap; }
.logo-text b { font-weight: 500; opacity: .78; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: var(--s-6) var(--gutter);
  background: linear-gradient(180deg, var(--dark) 0 42%, var(--bg) 42% 100%);
}
.login-box { width: 100%; max-width: 25rem; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin-bottom: var(--s-8); color: var(--on-dark); text-align: center; }
.login-brand .logo-img { max-height: 4.5rem; max-width: 15rem; }
.login-mark { width: 4.5rem; height: 4.5rem; border-radius: var(--s-3); box-shadow: 0 0 0 1px rgba(255,255,255,.16); margin-bottom: var(--s-1); }
.login-brand .logo-text { font-size: var(--fs-xl); }
.login-brand p { margin: 0; color: var(--on-dark-2); font-size: var(--fs-sm); }
.login-card { background: var(--card); border-radius: var(--r-lg); padding: var(--s-8) var(--s-6); box-shadow: 0 10px 40px rgba(20,20,20,.12); }
.login-card h1 { font-size: var(--fs-lg); margin: 0 0 var(--s-1); }
.login-card .muted { margin: 0 0 var(--s-5); font-size: var(--fs-sm); }
.login-card .btn.block { height: 3rem; margin-top: var(--s-2); }

/* =====================================================================
   Estrutura (shell)
   ===================================================================== */
.shell { min-height: 100vh; min-height: 100dvh; }

/* --- celular: barra do topo + barra inferior --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  background: var(--dark); color: var(--on-dark);
}
.topbar .logo-img { max-height: 2.125rem; }
.topbar-acts { display: flex; align-items: center; gap: var(--s-1); }
.topbar .icon-btn { color: var(--on-dark); }

.sidebar { display: none; }
/* rótulos do menu: curto no celular e no tablet, completo no laptop */
.t-full { display: none; }
@media (min-width: 1200px) { .nav .t-full { display: inline; } .nav .t-curto { display: none; } }

.main {
  padding: var(--s-5) var(--gutter) calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + var(--s-8));
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: var(--s-1);
  padding: var(--s-1) var(--s-2) calc(var(--s-1) + env(safe-area-inset-bottom, 0px));
  background: var(--nav-bg); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  box-shadow: 0 -1px 0 var(--line);
}
.bottomnav a {
  flex: 1 1 0; min-width: 0; min-height: calc(var(--bottomnav-h) - var(--s-2));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1875rem;
  border-radius: var(--r-sm); color: var(--muted);
  font-size: .6875rem; font-weight: 600; letter-spacing: -.01em;
}
.bottomnav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottomnav a svg { width: 1.375rem; height: 1.375rem; }
.bottomnav a.on { color: var(--ink); }
.bottomnav a.on svg { stroke-width: 2.4; }
.bottomnav a { transition: color var(--t-fast) var(--ease), transform var(--t-instant) var(--ease-out); }
.bottomnav a:active { transform: var(--press); }
/* menus com 6 itens (admin): rótulo um pouco menor para caber */
.bottomnav a:nth-last-child(n+6), .bottomnav a:nth-last-child(n+6) ~ a { font-size: .625rem; }

/* --- tablet: menu lateral compacto --- */
@media (min-width: 768px) {
  .topbar, .bottomnav { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--nav-w);
    display: flex; flex-direction: column; align-items: center; gap: var(--s-6);
    padding: calc(var(--s-5) + env(safe-area-inset-top, 0px)) var(--s-2) calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
    background: var(--dark); color: var(--on-dark);
  }
  .sidebar .brand { justify-content: center; }
  .sidebar .brand-mark { width: 2.5rem; height: 2.5rem; }
  .sidebar .logo-img, .sidebar .logo-text { display: none; }
  .nav { display: flex; flex-direction: column; gap: var(--s-1); width: 100%; }
  .nav a {
    display: flex; flex-direction: column; align-items: center; gap: var(--s-1);
    padding: var(--s-2) var(--s-1); border-radius: var(--r);
    color: var(--on-dark-2); font-size: .6875rem; font-weight: 600; text-align: center;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-instant) var(--ease-out);
  }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a:active { transform: var(--press); }
  @media (hover: hover) { .nav a:hover:not(.on) { background: var(--dark-2); color: var(--on-dark); } }
  .nav a.on { background: var(--on-dark); color: var(--dark); }
  /* Ajustes fica no fim do menu, logo acima do usuário */
  .nav.nav-fim { margin-top: auto; }
  .side-user { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--dark-3); width: 100%; }
  .side-user .who { display: none; }
  .side-user .icon-btn { color: var(--on-dark-2); }
  .side-user .icon-btn:hover { color: var(--on-dark); }

  .main {
    margin-left: var(--nav-w);
    padding: var(--s-8) var(--gutter) var(--s-12);
  }
}

/* --- laptop: menu lateral completo + conteúdo com largura máxima --- */
@media (min-width: 1200px) {
  .sidebar { align-items: stretch; padding-inline: var(--s-4); gap: var(--s-8); }
  .sidebar .brand { justify-content: flex-start; padding: var(--s-1) var(--s-2) 0; }
  .sidebar .brand-mark { width: 2.25rem; height: 2.25rem; }
  .sidebar .logo-img, .sidebar .logo-text { display: block; }
  .nav a {
    flex-direction: row; gap: var(--s-3); padding: var(--s-3);
    font-size: var(--fs-base); font-weight: 500; text-align: left;
  }
  .side-user { flex-direction: row; gap: var(--s-3); padding: var(--s-4) var(--s-2) 0; }
  .side-user .who { display: block; flex: 1; min-width: 0; }
  .side-user .who b { display: block; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-user .who span { font-size: var(--fs-xs); color: var(--on-dark-3); }

  /* conteúdo centralizado na área livre, sem passar de --content-max */
  /* o % do padding se refere à largura da janela inteira, por isso desconta o menu */
  .main { padding-inline: max(var(--gutter), calc((100% - var(--nav-w) - var(--content-max)) / 2)); padding-top: var(--s-10); }
}

.avatar {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--dark-3); color: var(--on-dark);
  display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm); flex: none;
}
.avatar.light { background: var(--bg); color: var(--ink); }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: transparent; color: inherit;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn { transition: background var(--t-fast) var(--ease), transform var(--t-instant) var(--ease-out); }
.icon-btn:active { transform: var(--press); background: rgba(127,127,127,.15); }
@media (hover: hover) { .icon-btn:hover { background: rgba(127,127,127,.15); } }

/* =====================================================================
   Página
   ===================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-title); font-weight: 700; margin: 0; letter-spacing: -.025em; }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s-1); }
.back { display: inline-flex; align-items: center; gap: var(--s-1); min-height: var(--tap); color: var(--muted); font-size: var(--fs-sm); margin: calc(-1 * var(--s-2)) 0 var(--s-1); }
.back:hover { color: var(--text); }
.section-title { font-size: var(--fs-md); font-weight: 600; margin: var(--s-8) 0 var(--s-3); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }

.card { background: var(--card); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--s-4); }
.card h3 { margin: 0 0 var(--s-4); font-size: var(--fs-md); }
@media (min-width: 768px) { .card { padding: var(--s-6); } }

/* grades: 1 coluna no celular, 2 no tablet, completas no laptop */
.grid { display: grid; gap: var(--s-3); }
.g2, .g3 { grid-template-columns: minmax(0, 1fr); }
.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 600px) {
  .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 768px) { .grid { gap: var(--s-4); } }
@media (min-width: 1200px) { .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 359px) { .g4 { grid-template-columns: minmax(0, 1fr); } }

/* cartão escuro de destaque (saldo / resumo) */
.hero {
  background: var(--dark); color: var(--on-dark); border-radius: var(--r-lg); padding: var(--s-6);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -4rem; top: -4rem; width: 14rem; height: 14rem; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%); pointer-events: none;
}
.hero .label { font-size: var(--fs-sm); color: var(--on-dark-2); display: flex; align-items: center; gap: var(--s-2); }
.hero .big { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; line-height: var(--lh-tight); margin: var(--s-2) 0 var(--s-5); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero .row { display: flex; gap: var(--s-4) var(--s-8); flex-wrap: wrap; }
.hero .row div span { display: block; font-size: var(--fs-xs); color: var(--on-dark-3); }
.hero .row div b { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero .icon-btn { color: var(--on-dark); width: var(--s-10); height: var(--s-10); margin: calc(-1 * var(--s-2)) 0; }
.hero .icon-btn svg { width: 1.125rem; height: 1.125rem; }
body.oculto .sens { filter: blur(9px); user-select: none; }
@media (min-width: 768px) { .hero { padding: var(--s-8); } }

.stat { background: var(--card); border-radius: var(--r-lg); padding: var(--s-4); box-shadow: var(--shadow); min-width: 0; }
.stat .top { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 500; line-height: 1.3; }
.stat .top .ic { width: var(--s-8); height: var(--s-8); border-radius: var(--s-2); display: grid; place-items: center; background: var(--bg); color: var(--ink); flex: none; }
.stat .top .ic svg { width: 1.0625rem; height: 1.0625rem; }
.stat .v { font-size: var(--fs-lg); font-weight: 700; margin-top: var(--s-3); letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .s { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-1); }
a.stat.link { display: block; transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
@media (hover: hover) { a.stat.link:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); } }
a.stat.link:active { transform: scale(.98); transition-duration: var(--t-instant); }
.stat .go { margin-left: auto; color: var(--faint); display: grid; }
.stat .go svg { width: 1rem; height: 1rem; }
.stat.red .ic { background: var(--red-bg); color: var(--red); }
.stat.red .v { color: var(--red); }
.stat.green .ic { background: var(--green-bg); color: var(--green-ink); }
@media (min-width: 768px) { .stat { padding: var(--s-5); } }

.alert { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; border-radius: var(--r); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); margin-top: var(--s-4); }
.alert svg { flex: none; }
.alert span { flex: 1 1 12rem; }
.alert.red { background: var(--red-bg); color: var(--red); }
.alert.amber { background: var(--amber-bg); color: var(--amber); }
.alert.green { background: var(--green-bg); color: var(--green-ink); }
.alert a { font-weight: 600; text-decoration: underline; margin-left: auto; white-space: nowrap; min-height: var(--s-6); display: inline-flex; align-items: center; }

/* =====================================================================
   Botões
   ===================================================================== */
/* formato cápsula (HIG) e leve "afundar" ao tocar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  border-radius: var(--r-pill); border: 1px solid transparent; font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; cursor: pointer;
  background: var(--primary-bg); color: var(--primary-fg); white-space: nowrap;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-instant) var(--ease-out);
}
.btn:active:not(:disabled) { transform: var(--press); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 1.125rem; height: 1.125rem; }
.btn.light { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.green { background: var(--green); color: #FFFFFF; }
.btn.sm { min-height: 2.25rem; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.wa { color: var(--wa); }

/* celular: ações do cabeçalho ocupam a largura e ficam maiores (mais fáceis de tocar) */
@media (max-width: 767px) {
  /* o título grande fica sozinho na linha; as ações vão para a linha de baixo (o !important vence o flex:1 escrito no HTML) */
  .page-head > .btn-row { width: 100%; flex: 1 1 100% !important; }
  .page-head > .btn-row > .btn { flex: 1 1 auto; }
  .page-head > .btn-row > .search { flex: 1 1 100%; max-width: none; order: 2; }
  .btn.sm { min-height: 2.5rem; }
}
/* telas de toque: botão pequeno também com 44px (alvo mínimo do HIG) */
@media (pointer: coarse) { .btn.sm { min-height: var(--tap); } }
/* efeito de passar o mouse só onde existe mouse (no iPhone ele "grudaria" depois do toque) */
@media (hover: hover) {
  .btn:hover:not(:disabled) { opacity: .88; }
  .btn.ghost:hover { background: var(--hover); opacity: 1; }
}

/* =====================================================================
   Formulários
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); min-width: 0; }
.field label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.field label .req { color: var(--red); }
.input {
  min-height: 3rem; width: 100%; border-radius: var(--r); border: 1px solid var(--line); background: var(--field);
  padding: 0 var(--s-4); outline: none; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  font-size: 1rem; /* 16px: evita o zoom automático do iPhone ao tocar no campo */
}
textarea.input { min-height: 5rem; padding: var(--s-3) var(--s-4); resize: vertical; line-height: var(--lh); }
select.input { padding-right: var(--s-8); }
.input:focus { border-color: var(--ink); background: var(--card); box-shadow: 0 0 0 4px var(--focus-ring); }
.input.big { min-height: 3.5rem; font-size: var(--fs-lg); font-weight: 600; }
.input-pre { position: relative; }
.input-pre > span { position: absolute; left: var(--s-4); top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.input-pre > .input { padding-left: var(--s-10); }
.input-suf { position: relative; }
.input-suf > span { position: absolute; right: var(--s-4); top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--fs-sm); pointer-events: none; }
.input-suf > .input { padding-right: 4.25rem; }
.hint { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.hint a { text-decoration: underline; cursor: pointer; }
.form-err { background: var(--red-bg); color: var(--red); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); font-size: var(--fs-sm); margin-bottom: var(--s-4); }

/* opções quebram de linha em telas estreitas, para nenhuma ficar escondida */
.seg { display: flex; flex-wrap: wrap; background: var(--bg); border-radius: var(--r); padding: var(--s-1); gap: var(--s-1); }
.seg button {
  flex: 1 1 auto; min-height: 2.5rem; border: 0; background: transparent; padding: var(--s-2) var(--s-3); cursor: pointer;
  border-radius: calc(var(--r) - var(--s-1)); /* concêntrico com o fundo do controle */
  font-weight: 500; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.04); font-weight: 600; }
.seg.dark { background: var(--dark-2); }
.seg.dark button { color: var(--on-dark-2); }
.seg.dark button.on { background: var(--on-dark); color: var(--dark); }

.search { position: relative; flex: 1; min-width: 12.5rem; max-width: 22.5rem; }
.search svg { position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%); color: var(--muted); width: 1.125rem; height: 1.125rem; }
.search .input { padding-left: var(--s-10); background: var(--card); min-height: var(--tap); }

/* =====================================================================
   Listas
   ===================================================================== */
.list { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.item {
  --item-px: var(--s-4); --item-gap: var(--s-3);
  position: relative; display: flex; align-items: center; gap: var(--item-gap); min-height: 4rem; padding: var(--s-3) var(--item-px);
}
/* separador recuado (HIG): começa onde começa o texto, depois do avatar ou da data */
.item + .item::before {
  content: ""; position: absolute; top: 0; right: 0; height: 1px; background: var(--line); pointer-events: none;
  left: calc(var(--item-px) + var(--lead, 0px));
}
.item:has(> .avatar) { --lead: calc(2.5rem + var(--item-gap)); }
.item:has(> .date-chip) { --lead: calc(3rem + var(--item-gap)); }
a.item, .item.click { transition: background var(--t-fast) var(--ease); }
a.item:active, .item.click:active { background: var(--hover); }
@media (hover: hover) { a.item:hover, .item.click:hover { background: var(--field); cursor: pointer; } }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .d { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .125rem; }
.item .end { text-align: right; flex: none; }
.item .end .t { font-variant-numeric: tabular-nums; }
.item .chev { color: var(--faint); display: grid; }
.item .acts { display: flex; gap: var(--s-2); flex: none; }
/* card de empréstimo: nome e valor abrem o empréstimo; o botão Quitar fica ao lado do valor */
@media (hover: hover) { .item.loan:hover { background: var(--field); } }
.item.loan a.grow, .item.loan a.end { display: block; }
.item.loan a.chev { min-height: var(--tap); align-items: center; }
@media (max-width: 599px) {
  .item.loan { --item-gap: var(--s-2); }
  .item.loan a.chev { display: none; } /* no celular o espaço vai para o nome e o botão */
  .item.loan .acts .btn svg { display: none; }
}
@media (min-width: 768px) { .item { --item-px: var(--s-5); --item-gap: var(--s-4); } }
.empty { padding: var(--s-10) var(--s-5); text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.date-chip {
  width: 3rem; flex: none; text-align: center; background: var(--bg); border-radius: var(--r-sm); padding: var(--s-2) 0; line-height: 1.1;
}
.date-chip b { display: block; font-size: var(--fs-md); }
.date-chip span { font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.date-chip.red { background: var(--red-bg); color: var(--red); }
.date-chip.red span { color: var(--red); }
.date-chip.green { background: var(--green-bg); color: var(--green-ink); }
.date-chip.green span { color: var(--green-ink); }

.badge { display: inline-flex; align-items: center; gap: var(--s-1); padding: .1875rem .5625rem; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.35; }
.badge.green { background: var(--green-bg); color: var(--green-ink); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: var(--bg); color: var(--muted); }

.progress { height: var(--s-2); background: var(--bg); border-radius: var(--r-pill); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: var(--r-pill); }
.hero .progress { background: var(--dark-3); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s-4) var(--s-5); }
.kv div span { display: block; font-size: var(--fs-xs); color: var(--muted); margin-bottom: .125rem; }
.kv div b { font-weight: 600; overflow-wrap: anywhere; }

/* =====================================================================
   Recebimentos
   ===================================================================== */
.rec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.rec-head h3 { margin: 0; }
.rec-head .seg { flex: 1 1 22rem; max-width: 28rem; }
.rec-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-4); }
.rec-sum div { background: var(--bg); border-radius: var(--r-sm); padding: var(--s-3); min-width: 0; }
.rec-sum span { display: block; font-size: var(--fs-xs); color: var(--muted); }
.rec-sum b { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rec-sum .ok b { color: var(--green-ink); }
@media (min-width: 600px) { .rec-sum { gap: var(--s-3); } .rec-sum b { font-size: var(--fs-md); } }
.rec-range { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s-4); }
.rec-range .input { width: auto; flex: 1 1 9rem; min-height: var(--tap); }
.rec-list .item { --item-px: var(--s-1); }
@media (max-width: 599px) {
  .rec-list .item { flex-wrap: wrap; }
  .rec-list .item .grow { flex-basis: calc(100% - 7.5rem); }
  .rec-list .item .acts { width: 100%; justify-content: flex-end; }
  .rec-list .item .acts .btn { flex: 1 1 auto; }
}

/* =====================================================================
   Novo empréstimo (simulador)
   ===================================================================== */
.loan-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.loan-layout > div { min-width: 0; }
.summary .big { margin-bottom: var(--s-1); }
.sum-rows { margin-top: var(--s-4); border-top: 1px solid var(--dark-3); }
.sum-rows > div { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--dark-3); font-size: var(--fs-sm); }
.sum-rows > div span { color: var(--on-dark-2); }
.sum-rows > div b { font-variant-numeric: tabular-nums; text-align: right; }
.sum-rows .hl b { color: var(--profit); font-size: var(--fs-md); }
.pill-profit { display: inline-block; background: rgba(126,226,160,.16); color: var(--profit); border-radius: var(--r-pill); padding: .1875rem .625rem; font-size: var(--fs-sm); font-weight: 600; }
.sched { max-height: 16rem; overflow: auto; margin-top: var(--s-3); font-size: var(--fs-sm); }
.sched div { display: flex; justify-content: space-between; padding: var(--s-2) 0; border-bottom: 1px dashed var(--dark-3); color: var(--on-dark-2); }
.manual-tag { font-size: .6875rem; background: var(--amber-bg); color: var(--amber); border-radius: 6px; padding: .0625rem .375rem; margin-left: var(--s-2); font-weight: 600; }

/* celular e tablet em retrato: "Confirmar empréstimo" fica fixo embaixo, ao alcance do polegar */
@media (max-width: 1023px) {
  .loan-layout #salvar {
    position: fixed; z-index: 15; margin: 0 !important;
    left: calc(var(--nav-w) + var(--gutter)); right: var(--gutter);
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + var(--s-3));
    width: auto; min-height: 3.25rem !important; height: auto !important; border-radius: var(--r-pill);
    background: var(--primary-bg); color: var(--primary-fg); border-color: transparent;
    box-shadow: 0 8px 24px rgba(20,20,20,.28), 0 0 0 1px rgba(255,255,255,.08);
    font-size: var(--fs-base);
  }
  .main:has(.loan-layout) { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 6rem); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .loan-layout #salvar { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s-5)); max-width: 30rem; margin-left: auto !important; }
  .main:has(.loan-layout) { padding-bottom: 7rem; }
}
/* tablet: formulário e resumo lado a lado quando há espaço (paisagem) */
@media (min-width: 1024px) {
  .loan-layout { grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem); gap: var(--s-5); }
  .summary { position: sticky; top: var(--s-6); }
}
@media (min-width: 1200px) {
  .loan-layout { grid-template-columns: minmax(0, 1fr) 24rem; gap: var(--s-6); }
}

/* =====================================================================
   Tabela de parcelas
   ===================================================================== */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); }
.table td { padding: var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s-2)); padding: 0 var(--s-2); }
@media (max-width: 639px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { padding: 0; border: 0; }
  .table.stack td.r { text-align: right; }
  .table.stack td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: var(--fs-xs); }
  .table.stack td.acts-cell { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
  .table.stack td.acts-cell .btn-row { width: 100%; justify-content: flex-end !important; }
}

/* =====================================================================
   Janelas (modal) — no celular abrem de baixo, como uma "folha"
   ===================================================================== */
.modal-bg {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: end stretch; padding: 0;
  background: rgba(20,20,20,.4); animation: fade var(--t-fast) var(--ease);
}
.modal {
  position: relative; background: var(--card); width: 100%; max-height: 92vh; max-height: 92dvh; overflow: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: sheet var(--t-normal) var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* "puxador" no topo da folha (celular), como nas folhas do iOS */
.modal::before {
  content: ""; position: sticky; top: 0; display: block; width: 2.25rem; height: .3125rem; margin: var(--s-2) auto 0;
  border-radius: var(--r-pill); background: var(--line);
}
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-1); }
.modal-h h2 { margin: 0; font-size: var(--fs-lg); }
.modal-b { padding: var(--s-3) var(--s-5) var(--s-1); }
.modal-f { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-5) var(--s-5); }
.modal-f .btn { flex: 1; min-height: 3rem; }
@media (min-width: 600px) {
  .modal-bg { place-items: center; padding: var(--s-4); }
  .modal { max-width: 33rem; max-height: calc(100vh - 2rem); border-radius: var(--r-lg); animation: pop var(--t-fast) var(--ease-out); padding-bottom: 0; }
  .modal::before { display: none; }
  .modal-f { justify-content: flex-end; }
  .modal-f .btn { flex: 0 0 auto; min-height: var(--tap); }
}
/* =====================================================================
   Painel do intermediário: ganhos futuros por mês
   ===================================================================== */
.meses { display: grid; gap: var(--s-4); }
@media (min-width: 768px) { .meses { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-8); } }
.mes-top { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.mes-top > span.num { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.mes .s { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-1); }
.mes.atrasado .progress > div { background: var(--red-solid); }

/* =====================================================================
   Ajustes e regra de senha
   ===================================================================== */
/* linha de preferência: descrição à esquerda, controle à direita (empilha no celular) */
.ajuste { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5); flex-wrap: wrap; }
.ajuste .grow { flex: 1 1 16rem; min-width: 0; }
.ajuste .seg { flex: 0 1 18rem; }
.seg button svg.i { width: 1rem; height: 1rem; vertical-align: -.1875rem; margin-right: var(--s-1); }
/* requisitos da senha: cada item fica verde quando é cumprido */
.regras-senha { list-style: none; margin: var(--s-1) 0 0; padding: 0; display: grid; gap: var(--s-1); font-size: var(--fs-sm); color: var(--muted); }
.regras-senha li { display: flex; align-items: center; gap: var(--s-2); }
.regras-senha svg.i { width: 1rem; height: 1rem; padding: .125rem; border-radius: 50%; background: var(--bg); color: transparent; }
.regras-senha li.ok { color: var(--green-ink); }
.regras-senha li.ok svg.i { background: var(--green-bg); color: var(--green-ink); stroke-width: 3; }

/* campos opcionais recolhidos dentro de uma janela ("Ajustar data ou valor") */
details.ajustar { margin-bottom: var(--s-2); }
details.ajustar > summary { display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: underline; list-style: none; }
details.ajustar > summary::-webkit-details-marker { display: none; }
details.ajustar[open] > summary { margin-bottom: var(--s-2); color: var(--text); }
.pw-box { background: var(--dark); color: var(--on-dark); border-radius: var(--r); padding: var(--s-4); text-align: center; margin: var(--s-2) 0 var(--s-3); }
.pw-box b { font-size: var(--fs-xl); letter-spacing: .12em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* =====================================================================
   Avisos rápidos (toasts)
   ===================================================================== */
#toasts {
  position: fixed; z-index: 200; display: flex; flex-direction: column; gap: var(--s-2);
  left: var(--gutter); right: var(--gutter); top: calc(env(safe-area-inset-top, 0px) + var(--s-3));
}
/* aviso em cápsula no topo, como os avisos do iOS */
.toast {
  align-self: center; max-width: 100%; text-align: center; font-weight: 500;
  background: var(--primary-bg); color: var(--primary-fg); padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); font-size: var(--fs-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: drop var(--t-normal) var(--ease-spring);
}
.toast.err { background: var(--red-solid); color: #FFFFFF; }
@media (min-width: 600px) { #toasts { left: auto; right: var(--s-4); max-width: 24rem; } .toast { align-self: flex-end; text-align: left; } }

@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

.loading { padding: var(--s-16) 0; text-align: center; color: var(--muted); }
