@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Montserrat:wght@700;800&display=swap');

/* ============ Temas ============ */
:root, [data-theme="light"] {
  --bg: #f6f8f6;
  --surface: #ffffff;
  --surface-2: #eef3ee;
  --border: #e3eae3;
  --text: #182119;
  --muted: #68786c;
  --primary: #16a34a;
  --primary-strong: #128040;
  --primary-soft: #e6f6ec;
  --primary-contrast: #ffffff;
  --hero-grad: linear-gradient(135deg, #128040 0%, #16a34a 55%, #3cb85e 100%);
  --red: #d94436;
  --red-soft: #fdedeb;
  --yellow: #a16207;
  --yellow-soft: #fdf3dd;
  --blue: #2273b8;
  --blue-soft: #e8f2fa;
  --shadow: 0 1px 2px rgba(20, 32, 22, .05), 0 4px 16px rgba(20, 32, 22, .04);
  --shadow-lift: 0 8px 30px rgba(20, 32, 22, .10);
  --radius: 16px;
  --nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #0d1310;
  --surface: #151d17;
  --surface-2: #1d271f;
  --border: #26322a;
  --text: #e9f1eb;
  --muted: #93a598;
  --primary: #2fbd63;
  --primary-strong: #27a556;
  --primary-soft: rgba(47, 189, 99, .13);
  --primary-contrast: #06130a;
  --hero-grad: linear-gradient(135deg, #128040 0%, #189b4c 55%, #2fbd63 100%);
  --red: #ef6a5c;
  --red-soft: rgba(239, 106, 92, .13);
  --yellow: #e2b53e;
  --yellow-soft: rgba(226, 181, 62, .12);
  --blue: #5aa7dd;
  --blue-soft: rgba(90, 167, 221, .13);
  --shadow: none;
  --shadow-lift: 0 8px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background .2s, color .2s;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: var(--primary); }

/* ============ Logo ============ */
.logo { display: flex; align-items: center; gap: 10px; font-family: 'Montserrat', 'Inter', sans-serif; font-weight: 800; letter-spacing: .3px; font-size: 20px; color: var(--text); }
.logo svg { width: 28px; height: 28px; }

/* ============ Login ============ */
#login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 85% -5%, var(--primary-soft), transparent 65%),
    radial-gradient(700px 420px at -5% 105%, var(--primary-soft), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 30px;
  box-shadow: var(--shadow-lift);
}
.login-card .logo { justify-content: center; margin-bottom: 6px; font-size: 26px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.login-tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.login-tabs button { flex: 1; padding: 9px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.login-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Selo "3 dias grátis" na aba de cadastro */
.trial-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--primary-strong);
  border-radius: 12px; padding: 10px 13px; margin-bottom: 18px;
  font-size: 13px; font-weight: 600; line-height: 1.4;
}
[data-theme="dark"] .trial-pill { color: var(--primary); }
.trial-pill b { font-weight: 800; }

/* Faixa de contagem regressiva do teste, no topo do app */
.trial-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  background: var(--primary); color: var(--primary-contrast);
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; text-align: center;
}
.trial-bar.urgente { background: #d97706; color: #fff; }
.trial-bar a {
  color: inherit; background: rgba(255, 255, 255, .22);
  padding: 5px 13px; border-radius: 99px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.trial-bar a:hover { background: rgba(255, 255, 255, .34); }

/* ============ Formulários ============ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 11px 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type="date"] { color-scheme: light; }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--primary); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 13px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .6; cursor: wait; }

/* ============ Layout ============ */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 14px 18px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh;
}
#sidebar .logo { padding: 0 10px 20px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px;
  border: none; background: transparent; text-align: left;
  color: var(--muted); font-weight: 600; font-size: 14.5px; width: 100%;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
#sidebar .spacer { flex: 1; }
.side-user { padding: 14px 12px 0; border-top: 1px solid var(--border); font-size: 13px; }
.side-user .name { font-weight: 700; display: block; }
.side-user .prof { color: var(--muted); font-size: 12px; display: block; }
.side-user .actions { display: flex; gap: 8px; }
.side-user-link {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--text);
  padding: 6px 8px; margin: -6px -8px 10px; border-radius: 9px;
}
.side-user-link:hover { background: var(--surface-2); }

#main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
#topbar .logo { font-size: 19px; }
#topbar .logo svg { width: 24px; height: 24px; }
#topbar .actions { display: flex; gap: 4px; }

#view { padding: 28px 30px 48px; max-width: 1040px; width: 100%; margin: 0 auto; }

#bottomnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#bottomnav .items { display: flex; }
#bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: none; background: transparent; color: var(--muted);
  font-size: 10.5px; font-weight: 600; padding: 6px 2px;
}
#bottomnav button svg { width: 22px; height: 22px; }
#bottomnav button.active { color: var(--primary); }

@media (max-width: 899px) {
  #sidebar { display: none; }
  #topbar { display: flex; }
  #bottomnav { display: block; }
  #view { padding: 20px 16px calc(var(--nav-h) + 36px); }
}

/* ============ Componentes ============ */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; font-weight: 800; letter-spacing: -.3px; }
.brand-line { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 11.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--primary); margin-bottom: 3px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card .label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.card .value { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 5px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.pos { color: var(--primary); }
.neg { color: var(--red); }
.warn { color: var(--yellow); }

/* Hero (dashboard) */
.hero {
  background: var(--hero-grad);
  border-radius: 22px;
  padding: 26px 26px 22px;
  color: #fff;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lift);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; right: -40px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.hero .h-label { font-size: 13px; font-weight: 600; opacity: .85; }
.hero .h-value { font-size: 38px; font-weight: 800; letter-spacing: -1px; margin: 2px 0 2px; }
/* Explica o número grande em uma linha, para ele nunca ficar ambíguo */
.hero .h-sub { font-size: 12.5px; opacity: .8; margin-bottom: 14px; }
/* Faixas de dados: colunas de mesma largura, rótulo em cima e valor embaixo.
   O recuo do valor casa com a largura do ícone (20px) + o gap (8px), então
   rótulos e números ficam no mesmo eixo vertical em todas as colunas. */
.hero .h-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .16);
}
.hero .h-cell-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; opacity: .86;
  white-space: nowrap;
}
.hero .h-cell-value {
  font-size: 17px; font-weight: 800; letter-spacing: -.3px;
  margin-top: 5px; padding-left: 28px;
}
.hero .h-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 7px; flex-shrink: 0;
  background: rgba(255, 255, 255, .18); font-size: 11px; line-height: 1;
}
@media (max-width: 660px) {
  .hero .h-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
}
@media (max-width: 400px) {
  .hero .h-grid { grid-template-columns: 1fr; }
  .hero .h-cell-value { font-size: 16px; }
}

.section { margin-bottom: 26px; }
.section > h2 { font-size: 15.5px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section > h2 .see-all { font-size: 12.5px; color: var(--primary); font-weight: 600; cursor: pointer; background: none; border: none; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 14.5px; }
.row .meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row .amount { font-weight: 700; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; align-items: center; }

/* ---- Linhas com botões de texto no celular (agenda, fixos, cobranças) ----
   Nessas listas as ações são botões escritos ("Realizado", "Marcar pago"…) e
   não cabem ao lado do nome numa tela estreita: o nome era espremido até
   quase zero e o texto passava por baixo dos botões. No celular a linha vira
   um bloco — nome e valor em cima, ações numa faixa própria embaixo, com a
   largura inteira do cartão. No computador nada muda. */
@media (max-width: 719px) {
  .row-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "info valor"
      "acoes acoes";
    align-items: start;
    gap: 11px 12px;
    padding: 14px 16px;
  }
  /* Agenda: o horário vira a coluna da esquerda; não há valor nessa lista */
  .row-stack-ag {
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas:
      "hora info"
      "acoes acoes";
  }
  .row-stack .ag-hora { grid-area: hora; }
  .row-stack > .grow { grid-area: info; }
  .row-stack > .amount { grid-area: valor; align-self: start; font-size: 15.5px; }
  .row-stack > .row-actions { grid-area: acoes; }

  .row-stack .title { line-height: 1.35; }
  .row-stack .title .badge { vertical-align: 1px; }
  .row-stack .meta { margin-top: 3px; line-height: 1.4; }

  /* Faixa de ações: quebra sozinha se faltar espaço e tem alvo de toque maior */
  .row-stack .row-actions { flex-wrap: wrap; gap: 6px; width: 100%; }
  .row-stack .row-actions .btn-sm { padding: 9px 13px; border-radius: 10px; }
  .row-stack .row-actions .icon-btn { padding: 7px; }
}

/* Telas bem estreitas (iPhone SE e afins): aperta um pouco a faixa de ações
   para os dois botões e os ícones ainda caberem na mesma linha. */
@media (max-width: 374px) {
  .row-stack { padding: 14px 14px; }
  .row-stack .row-actions { gap: 4px; }
  .row-stack .row-actions .btn-sm { padding: 9px 10px; font-size: 12.5px; }
  .row-stack .row-actions .icon-btn { padding: 5px; }
}

.icon-btn { border: none; background: transparent; color: var(--muted); padding: 7px; border-radius: 9px; line-height: 0; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }
.wa-btn { color: #25d366; }
.wa-btn:hover { color: #1eb355; background: rgba(37, 211, 102, .12); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--primary-soft); color: var(--primary); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--surface-2); color: var(--muted); }

.empty { padding: 32px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* Insights */
.insight { display: flex; gap: 13px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.insight:last-child { border-bottom: none; }
.insight .dot { width: 9px; height: 9px; border-radius: 99px; margin-top: 7px; flex-shrink: 0; }
.insight .t { font-weight: 700; font-size: 14.5px; }
.insight .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dot-positivo { background: var(--primary); }
.dot-alerta { background: var(--red); }
.dot-atencao { background: var(--yellow); }
.dot-info { background: var(--blue); }

.tip {
  background: var(--primary-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px 18px; font-size: 13.5px;
}
.tip .who { color: var(--primary); font-weight: 700; font-size: 12px; margin-bottom: 4px; }
/* Dica com botão: texto de um lado, ação do outro (empilha no celular) */
.tip-acao { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; line-height: 1.5; }
.tip-acao .tip-txt { flex: 1; min-width: 220px; }
.tip-acao .btn { white-space: nowrap; }
@media (max-width: 480px) { .tip-acao .btn { width: 100%; justify-content: center; } }

/* Reserva de impostos: título + dois botões, que descem de linha no celular */
.sec-reserva > h2 { flex-wrap: wrap; }
.sec-reserva .sec-acoes { display: flex; gap: 6px; }
.sec-reserva .sec-acoes .btn { white-space: nowrap; }
.tips { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

/* Semana */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 10px; cursor: pointer; min-width: 0;
  box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
.day-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.day-card.today { border-color: var(--primary); background: var(--primary-soft); }
.day-card .dow { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.day-card .dnum { font-size: 18px; font-weight: 800; margin-bottom: 7px; }
.day-card .ln { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-card .prev-tag { font-size: 10.5px; color: var(--yellow); font-weight: 600; }
@media (max-width: 899px) {
  .week-grid { grid-template-columns: 1fr; }
  .day-card { display: flex; align-items: center; gap: 14px; padding: 13px 16px; }
  .day-card .dhead { width: 74px; flex-shrink: 0; }
  .day-card .dnum { margin-bottom: 0; }
  .day-card .dvals { flex: 1; display: flex; flex-wrap: wrap; gap: 2px 16px; }
}
@media (min-width: 900px) { .day-card .dvals { display: block; } }

/* Metas */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary-strong), var(--primary)); border-radius: 99px; }
.goal-card { padding: 18px; }
.goal-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.goal-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.goal-nums { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.daily-highlight {
  margin-top: 10px; padding: 11px 13px; border-radius: 11px;
  background: var(--primary-soft);
  font-size: 13px;
}
.daily-highlight strong { color: var(--primary); }

/* Toggle imposto */
.tax-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 13px; border-radius: 12px;
  background: var(--surface-2); border: 1.5px solid var(--border);
  cursor: pointer; user-select: none; margin-bottom: 14px;
}
.tax-toggle .sw { width: 40px; height: 23px; border-radius: 99px; background: var(--border); position: relative; transition: background .15s; flex-shrink: 0; }
.tax-toggle .sw::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 99px; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s;
}
.tax-toggle.on { border-color: var(--primary); }
.tax-toggle.on .sw { background: var(--primary); }
.tax-toggle.on .sw::after { transform: translateX(17px); }
.tax-toggle .tt { font-size: 13.5px; font-weight: 600; }
.tax-toggle .td { font-size: 12px; color: var(--muted); }

/* Segment */
.segment { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segment button { border: none; border-radius: 9px; background: transparent; color: var(--muted); padding: 7px 15px; font-weight: 600; font-size: 13px; }
.segment button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Seletor de meses (gastos/receitas fixas com prazo) */
.months-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 8px; }
.month-chip {
  padding: 9px 0; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--muted);
  font-weight: 600; font-size: 12.5px; cursor: pointer; text-align: center;
  transition: background .12s, border-color .12s, color .12s;
}
.month-chip:hover { border-color: var(--primary); }
.month-chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.months-actions { display: flex; gap: 10px; margin-bottom: 6px; }
.months-actions a { font-size: 12.5px; color: var(--primary); text-decoration: none; font-weight: 600; }
.months-actions a:hover { text-decoration: underline; }
@media (max-width: 480px) { .months-grid { grid-template-columns: repeat(4, 1fr); } }

/* Gráficos */
.chart-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-card { padding: 20px; }
.chart-card h3 { font-size: 14.5px; margin-bottom: 4px; }
.chart-card .total-line { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.chart-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; width: 170px; height: 170px; flex-shrink: 0; margin: 0 auto; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut .center .cv { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.donut .center .cl { font-size: 11px; color: var(--muted); font-weight: 600; }
.legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 8px; }
.legend .li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend .sw { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }
.legend .ln-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .ln-val { font-weight: 700; white-space: nowrap; }
.legend .ln-pct { color: var(--muted); font-size: 12px; width: 42px; text-align: right; }
.period-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.custom-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.custom-range input { padding: 8px 10px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 9px; color: var(--text); }

/* Drill-down dos gráficos */
.legend .li-click { cursor: pointer; padding: 3px 6px; margin: -3px -6px; border-radius: 8px; transition: background .12s; }
.legend .li-click:hover { background: var(--surface-2); }
.legend .li-click.active { background: var(--primary-soft); }
.drill { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.drill .dr { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 2px; font-size: 13px; border-bottom: 1px dashed var(--border); }
.drill .dr:last-child { border-bottom: none; }
.drill .dmeta { color: var(--muted); font-size: 12px; }

/* Detalhe expansível do paciente */
.chev svg { transition: transform .18s; }
.chev.open svg { transform: rotate(180deg); }
.pat-detail { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 4px 18px 16px; }
.pat-detail h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 14px 0 4px; font-weight: 700; }
.pat-detail .dr { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.pat-detail .dr:last-child { border-bottom: none; }
.pat-detail .dmeta { color: var(--muted); font-size: 12px; }
.pat-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* Evolução mensal (linha do tempo contínua, sem sair da tela) */
.evo-card { padding: 0; overflow: hidden; }
.evo { position: relative; }

/* Bloco de continuidade: o que o mês atual herdou e onde ele está agora */
.evo-carry { padding: 16px 18px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.evo-carry.pos { background: var(--primary-soft); }
.evo-carry.neg { background: var(--red-soft); }
.evo-carry-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin-bottom: 6px;
}
.evo-carry-row {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px;
  font-size: 13.5px; color: var(--muted); padding: 4px 0;
}
.evo-carry-row b { font-size: 15px; font-weight: 800; letter-spacing: -.2px; margin-left: auto; white-space: nowrap; }
.evo-carry-row.total {
  margin-top: 6px; padding-top: 9px; border-top: 1px solid var(--border);
  color: var(--text); font-weight: 700;
}
.evo-carry-row.total b { font-size: 18px; }
.evo-hint { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.evo-hint b { color: var(--text); font-weight: 700; }

/* Lista de meses */
.evo-item { border-bottom: 1px solid var(--border); }
.evo-item:last-child { border-bottom: none; }
.evo-item.atual { background: linear-gradient(90deg, var(--primary-soft), transparent 65%); }

.evo-row {
  width: 100%; border: none; background: transparent; color: inherit; cursor: pointer;
  text-align: left; font: inherit; padding: 14px 16px;
  display: grid; gap: 8px 10px;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  grid-template-areas: "when num chev" "bars bars chev" "acc acc chev";
  align-items: center; transition: background .12s;
}
.evo-row:hover { background: var(--surface-2); }

.evo-when { grid-area: when; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.evo-name { font-size: 15px; font-weight: 700; text-transform: capitalize; letter-spacing: -.2px; }
.evo-ano { font-size: 12px; color: var(--muted); font-weight: 600; }
.evo-tag {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--primary); background: var(--primary-soft); border-radius: 99px; padding: 2px 7px;
}
.evo-tag.vazio { color: var(--muted); background: var(--surface-2); }

.evo-num { grid-area: num; text-align: right; }
.evo-num b { font-size: 16px; font-weight: 800; letter-spacing: -.3px; white-space: nowrap; }
.evo-num b.vazio { color: var(--muted); }

/* Corrente entre os meses, visível sem precisar abrir o detalhe */
.evo-acc { grid-area: acc; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.evo-acc b { font-weight: 800; white-space: nowrap; }

.evo-bars { grid-area: bars; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.evo-bar-row { display: flex; align-items: center; gap: 8px; }
.evo-bar { flex: 1; min-width: 0; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.evo-item.atual .evo-bar { background: var(--border); }
.evo-fill { display: block; height: 100%; border-radius: 99px; transition: width .3s ease; }
.evo-fill.in { background: var(--primary); }
.evo-fill.out { background: var(--red); opacity: .8; }
.evo-bar-val { font-size: 11px; font-weight: 700; white-space: nowrap; text-align: right; }

.evo-chev { grid-area: chev; color: var(--muted); display: flex; align-items: center; }
.evo-chev svg { width: 16px; height: 16px; transition: transform .2s; }
.evo-item.open .evo-chev svg { transform: rotate(180deg); }

/* Detalhe do mês: abre no lugar, nunca navega para outra aba */
.evo-detail { display: none; padding: 0 16px 16px; }
.evo-item.open .evo-detail { display: block; animation: evoOpen .18s ease; }
@keyframes evoOpen { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.evo-dr {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px;
  font-size: 13px; color: var(--muted); padding: 7px 0; border-bottom: 1px dashed var(--border);
}
.evo-dv { text-align: right; margin-left: auto; }
.evo-dv b { color: var(--text); font-weight: 700; }
.evo-dv b.pos { color: var(--primary); }
.evo-dv b.neg { color: var(--red); }
.evo-var { font-size: 11px; font-weight: 700; margin-left: 6px; }
.evo-var.sobe { color: var(--primary); }
.evo-var.desce { color: var(--red); }
.evo-var.neutro { color: var(--muted); }

.evo-chain {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
.evo-chain b { font-weight: 800; white-space: nowrap; }
.evo-arrow { color: var(--primary); font-weight: 800; }

.evo-foot {
  display: flex; flex-wrap: wrap; gap: 4px 18px; justify-content: center; text-align: center;
  padding: 12px 16px 14px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
}
.evo-foot b { color: var(--text); font-weight: 700; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px); z-index: 25;
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--primary); color: var(--primary-contrast); border: none;
  font-size: 28px; font-weight: 700; line-height: 0;
  box-shadow: 0 8px 24px rgba(22, 163, 74, .38);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.fab:hover { transform: scale(1.06); }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 18, 12, .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  animation: slideUp .18s ease-out;
  box-shadow: var(--shadow-lift);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ============ Toast ============ */
#toast-root { position: fixed; top: 14px; left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 20px; font-size: 14px; font-weight: 600;
  max-width: 90%; box-shadow: var(--shadow-lift);
  animation: slideUp .18s ease-out;
}
.toast-ok { border-color: var(--primary); color: var(--primary); }
.toast-err { border-color: var(--red); color: var(--red); }

.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ============ Suporte ============ */
.sup-card { padding: 20px; }
.sup-lead { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin-bottom: 16px; }

.sup-video {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.sup-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.sup-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; font-size: 13.5px; font-weight: 600; text-decoration: none; }
.sup-link:hover { text-decoration: underline; }
.sup-link svg { width: 18px; height: 18px; }

.sup-wa { display: flex; align-items: center; gap: 16px; padding: 18px 20px; flex-wrap: wrap; }
.sup-wa-ico {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(37, 211, 102, .13); color: #25d366;
}
.sup-wa-ico svg { width: 26px; height: 26px; }
.sup-wa-body { flex: 1; min-width: 190px; }
.sup-wa-num { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.sup-wa-body .hint { margin-top: 3px; line-height: 1.5; }
.sup-wa-btn { text-decoration: none; white-space: nowrap; }
.sup-wa-prev { margin-top: 10px; line-height: 1.5; }
.sup-wa-prev b { color: var(--text); font-weight: 600; }

.sup-url {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--primary-soft); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px;
}
.sup-url span { font-weight: 700; font-size: 14.5px; color: var(--primary); word-break: break-all; }
.sup-seg { margin-bottom: 20px; }
.sup-seg button { display: inline-flex; align-items: center; gap: 7px; }
.sup-seg button svg { width: 16px; height: 16px; }
.sup-nota {
  font-size: 13px; line-height: 1.5; color: var(--muted);
  background: var(--surface-2); border-radius: 12px; padding: 11px 14px; margin-bottom: 18px;
}
.sup-nota b { color: var(--text); font-weight: 700; }

.steps { list-style: none; display: grid; gap: 18px; }
.step { display: flex; gap: 13px; align-items: flex-start; }
.step-num {
  width: 26px; height: 26px; border-radius: 99px; flex-shrink: 0;
  background: var(--primary); color: var(--primary-contrast);
  font-size: 13px; font-weight: 800; line-height: 26px; text-align: center;
}
.step-body { flex: 1; min-width: 0; }
.step-txt { font-size: 14px; line-height: 1.55; padding-top: 2px; }
.step-txt b { font-weight: 700; }
.step-img {
  display: block; margin-top: 12px; width: 100%; max-width: 260px;
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
/* Prints de tela cheia (computador) pedem toda a largura para dar pra enxergar */
.step-img.ampla { max-width: 100%; border-radius: 10px; }
@media (max-width: 480px) {
  .sup-wa-btn { width: 100%; justify-content: center; }
  /* Sem os ícones os três rótulos cabem lado a lado até nas telas mais estreitas */
  .sup-seg { display: flex; width: 100%; }
  .sup-seg button { flex: 1; justify-content: center; padding: 8px 4px; font-size: 12.5px; }
  .sup-seg button svg { display: none; }
}
