/* ============================================================
   Gestão Financeira — Design System
   ============================================================ */

:root {
  --bg: #f2f5fa;
  --surface: #ffffff;
  --text: #182136;
  --muted: #68738d;
  --border: #e4e9f2;
  --primary: #4f6df5;
  --primary-dark: #3b56d9;
  --primary-soft: #eef1fe;
  --green: #0fa958;
  --green-soft: #e6f7ee;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #e8930c;
  --amber-soft: #fdf3e2;
  --empresa: #7c58f0;
  --empresa-soft: #f0ebfe;
  --sidebar-bg: #0f1526;
  --sidebar-text: #aab2c8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ============================================================
   LOGIN
   ============================================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(79, 109, 245, .45), transparent 60%),
    radial-gradient(800px 400px at 0% 110%, rgba(18, 169, 80, .25), transparent 55%),
    #0c1222;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 24px;
  padding: 36px 32px;
  color: #eef1f8;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-logo strong { font-size: 22px; letter-spacing: -.3px; }

.auth-sub { color: #9aa4bf; font-size: 14px; margin-bottom: 26px; }

.auth-card .field span { color: #b7bfd4; }

.auth-card input {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
}

.auth-card input::placeholder { color: #7d87a3; }

.auth-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 109, 245, .25);
  outline: none;
}

.auth-error {
  display: none;
  background: rgba(229, 72, 77, .15);
  border: 1px solid rgba(229, 72, 77, .4);
  color: #ffb3b5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.auth-error.show { display: block; }

.auth-btn {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, #4f6df5, #7c5cf0);
  transition: transform .12s ease, box-shadow .12s ease;
}

.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(79, 109, 245, .45); }
.auth-btn:disabled { opacity: .6; cursor: wait; transform: none; box-shadow: none; }

.auth-foot { margin-top: 18px; text-align: center; font-size: 13px; color: #7d87a3; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */

.field { display: block; margin-bottom: 16px; }

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 109, 245, .15);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Inputs do card de login mantêm o tema escuro (sobrepõe .field input) */
.auth-card .field input {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
}

.auth-card .field input::placeholder { color: #7d87a3; }

.auth-card .field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 109, 245, .25);
}

/* ============================================================
   BOTÕES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  transition: background .12s, transform .12s;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost { background: var(--bg); color: var(--text); }
.btn-ghost:hover { background: #e8edf6; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c93338; }

.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--muted);
  transition: background .12s, color .12s;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn.success:hover { background: var(--green-soft); color: var(--green); }

/* ============================================================
   LAYOUT DO APP
   ============================================================ */

.layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14.5px;
  transition: background .12s, color .12s;
}

.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 14px 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 13.5px;
}

.sidebar-footer #userName {
  color: #fff;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.sidebar-footer .icon-btn { color: var(--sidebar-text); }
.sidebar-footer .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.content {
  margin-left: var(--sidebar-w);
  padding: 28px 32px 48px;
  max-width: 1180px;
}

/* ---------- Menu inferior (mobile) ---------- */

.bottomnav { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 18px 16px 96px; }

  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 40;
  }

  .bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--muted);
    border-radius: 10px;
  }

  .bottomnav a svg { width: 21px; height: 21px; }
  .bottomnav a.active { color: var(--primary); }
}

/* ---------- Alternador de perfil (CPF x CNPJ) ---------- */

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.perfil-switch {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.perfil-switch button {
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .12s, color .12s;
}

.perfil-switch button:hover { color: var(--text); }
.perfil-switch button.active { color: #fff; background: var(--text); }
.perfil-switch button.active[data-perfil="pessoal"] { background: var(--primary); }
.perfil-switch button.active[data-perfil="empresa"] { background: var(--empresa); }

@media (max-width: 860px) {
  .perfil-switch { width: 100%; }
  .perfil-switch button { flex: 1; padding: 8px 4px; }

  /* Ao rolar, só as pílulas acompanham — sem barra de fundo. A própria pílula
     já é opaca, então continua legível flutuando sobre a lista. */
  .topbar {
    position: sticky;
    top: 10px;
    z-index: 30;
    margin-bottom: 16px;
  }

  .perfil-switch { box-shadow: 0 8px 22px -6px rgba(16, 24, 40, .28); }
}

/* ============================================================
   COMPONENTES
   ============================================================ */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 { font-size: 22px; letter-spacing: -.4px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.filters input[type="month"], .filters select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* ---------- Cards de estatística ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat .label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.stat .label svg { width: 16px; height: 16px; }
.stat .value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; margin-top: 8px; }
.stat .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.stat .value.neg { color: var(--red); }
.stat .value.pos { color: var(--green); }

.stat.accent-red .label { color: var(--red); }
.stat.accent-green .label { color: var(--green); }
.stat.accent-blue .label { color: var(--primary); }
.stat.accent-amber .label { color: var(--amber); }

/* ---------- Painéis ---------- */

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 { font-size: 16.5px; letter-spacing: -.2px; }

/* ---------- Lista de lançamentos ---------- */

.tx-list { display: flex; flex-direction: column; }

.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 6px;
  border-bottom: 1px solid var(--border);
}

.tx-row:last-child { border-bottom: none; }

.tx-ico {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}

.tx-ico svg { width: 18px; height: 18px; }
.tx-ico.pagar { background: var(--red-soft); color: var(--red); }
.tx-ico.receber { background: var(--green-soft); color: var(--green); }

.tx-main { flex: 1; min-width: 0; }
.tx-main .desc { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.tx-main .desc > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main .meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.tx-right { text-align: right; flex-shrink: 0; }
.tx-right .amount { font-weight: 700; white-space: nowrap; }
.tx-right .amount.pagar { color: var(--red); }
.tx-right .amount.receber { color: var(--green); }

.tx-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Botão de ação com ícone + texto. O rótulo some no celular (só o ícone),
   senão três palavras por linha estouram a largura da tela. */
.act-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .12s, color .12s;
}

.act-btn svg { width: 17px; height: 17px; display: block; }
.act-btn:hover { background: var(--bg); color: var(--text); }
.act-btn.success:hover { background: var(--green-soft); color: var(--green); }
.act-btn.danger:hover { background: var(--red-soft); color: var(--red); }

@media (max-width: 860px) {
  .act-btn { padding: 0; width: 34px; justify-content: center; }
  .act-btn .rotulo { display: none; }
}

/* ---------- Lançamento no celular ----------
   Numa tela estreita não cabem descrição, valor e ações na mesma linha: a
   descrição era espremida até sumir e o valor montava sobre o texto. Aqui a
   linha vira duas — dados em cima, valor e ações embaixo. */
@media (max-width: 700px) {
  .tx-row { flex-wrap: wrap; row-gap: 10px; align-items: flex-start; padding: 14px 4px; }

  .tx-ico { width: 34px; height: 34px; border-radius: 10px; }
  .tx-ico svg { width: 16px; height: 16px; }

  .tx-main { flex: 1 1 60%; }
  /* deixa a descrição inteira aparecer, em vez de cortar com reticências */
  .tx-main .desc { flex-wrap: wrap; gap: 6px; }
  .tx-main .desc > span:first-child { white-space: normal; overflow: visible; }
  .tx-main .meta { line-height: 1.35; }

  .tx-right {
    order: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding-left: 46px; /* alinha com o texto, abaixo do ícone */
  }

  /* As ações ganham uma linha só delas, e aí os rótulos cabem no celular
     também — que é onde o cliente mais precisa de texto em vez de ícone. */
  .tx-actions {
    order: 4;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 5px;
    /* sem recuo: as três ações precisam caber numa linha só até em 360px */
  }

  .tx-actions .act-btn {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 32px;
    padding: 0 8px;
    justify-content: center;
    font-size: 12px;
    background: var(--bg);
  }

  .tx-actions .act-btn svg { width: 15px; height: 15px; }
  .tx-actions .act-btn .rotulo { white-space: nowrap; }

  .tx-actions .act-btn .rotulo { display: inline; }

  .fatura-row .tx-right { padding-left: 46px; }
}

/* Telas bem estreitas (iPhone SE e afins): aperta mais para "Marcar recebido"
   continuar na mesma linha que Editar e Excluir. */
@media (max-width: 389px) {
  .tx-actions { gap: 4px; }
  .tx-actions .act-btn { font-size: 11px; padding: 0 6px; gap: 4px; }
  .tx-actions .act-btn svg { width: 14px; height: 14px; }
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--bg); color: var(--muted); }
.badge.serie { background: var(--amber-soft); color: var(--amber); }
.badge.pf-pessoal { background: var(--primary-soft); color: var(--primary); }
.badge.pf-empresa { background: var(--empresa-soft); color: var(--empresa); }

/* ---------- Transferências entre perfis ---------- */

.note-transfer {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: -8px 0 18px;
  padding: 12px 15px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  color: #3f4c74;
  font-size: 13px;
  line-height: 1.45;
}

.note-transfer svg, .transfer-hint svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }

.transfer-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 16px;
}

/* Caixa de seleção com rótulo, dentro de formulário */
.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.check-line input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* Botões empilhados (escolha de alcance na exclusão de série) */
.modal-actions.coluna { flex-direction: column; align-items: stretch; gap: 8px; }
.modal-actions.coluna .btn { justify-content: center; }

.link-btn {
  padding: 0;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.link-btn:hover { color: var(--primary-dark); }

/* ---------- Comparativo Pessoal x Empresa ---------- */

.cmp-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}

.cmp-row:last-child { border-bottom: none; }
.cmp-row .k { color: var(--muted); font-size: 13.5px; }
.cmp-row .v { text-align: right; font-weight: 700; white-space: nowrap; }
.cmp-row .v.pos { color: var(--green); }
.cmp-row .v.neg { color: var(--red); }
.cmp-row.cmp-head { padding-bottom: 8px; }
.cmp-row.total .k, .cmp-row.total .v { font-size: 16.5px; }
.cmp-row.total .k { color: var(--text); font-weight: 600; }

/* ---------- Grade do dashboard ---------- */

.dash-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ---------- Gráfico de barras ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  height: 190px;
  padding-top: 10px;
}

.chart .col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  min-width: 0;
}

.chart .bars {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

.chart .bar {
  width: 26%;
  max-width: 30px;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  transition: height .3s ease;
}

.chart .bar.in { background: linear-gradient(180deg, #2fd08a, #0fa958); }
.chart .bar.out { background: linear-gradient(180deg, #f7727a, #e5484d); }

.chart .mlabel { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: capitalize; }

.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend i.in { background: #0fa958; }
.chart-legend i.out { background: #e5484d; }

/* ---------- Cartões de crédito ---------- */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.cc {
  border-radius: 18px;
  padding: 20px;
  color: #fff;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(16, 24, 40, .18);
  transition: transform .12s ease;
  position: relative;
  overflow: hidden;
}

.cc::after {
  content: "";
  position: absolute;
  width: 190px; height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  top: -80px; right: -60px;
}

.cc:hover { transform: translateY(-3px); }
.cc.selected { outline: 3px solid rgba(79, 109, 245, .5); }

.cc .cc-top { display: flex; align-items: center; gap: 8px; }
.cc .cc-name { font-weight: 700; font-size: 16px; }

.cc .cc-tag {
  background: rgba(255, 255, 255, .22);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cc .cc-num { font-size: 13px; letter-spacing: 1.5px; opacity: .92; margin-top: 3px; font-variant-numeric: tabular-nums; }
.cc .cc-due { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.cc .cc-label { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .6px; }
.cc .cc-value { font-size: 23px; font-weight: 700; }
.cc .cc-limit { font-size: 12px; opacity: .8; margin-top: 2px; }

.cc-add {
  border: 2px dashed var(--border);
  border-radius: 18px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  transition: border-color .12s, color .12s;
}

.cc-add svg { width: 26px; height: 26px; }
.cc-add:hover { border-color: var(--primary); color: var(--primary); }

/* No celular os cartões viram carrossel horizontal: empilhados, empurravam a
   fatura para muito longe da dobra. As margens negativas deixam o cartão
   sangrar até a borda da tela, com o próximo espiando na lateral. */
@media (max-width: 700px) {
  .cards-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px 20px;
    padding: 4px 16px 8px;
    scrollbar-width: none;
  }

  .cards-grid::-webkit-scrollbar { display: none; }

  .cards-grid > * {
    flex: 0 0 84%;
    scroll-snap-align: center;
    min-height: 140px;
  }

  .cc:hover { transform: none; }

  /* Cabeçalho de painel (ex.: a fatura do cartão): no celular o título ficava
     espremido numa coluna estreita ao lado dos botões. Passa a empilhar. */
  .panel-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .panel-head h2 { font-size: 15.5px; }
  .panel-head .filters { width: 100%; }
  .panel-head .filters input[type="month"] { flex: 1 1 100%; }
  .panel-head .filters .btn { flex: 1 1 auto; justify-content: center; }

  /* Gasto da fatura tem uma ação só: alinha com o texto e não estica na
     largura toda, senão um "Excluir" gigante rouba a atenção da linha. */
  .gasto-row .tx-actions { padding-left: 46px; }
  .gasto-row .tx-actions .act-btn { flex: 0 0 auto; }

  /* Totais: o rótulo longo ("Total da fatura (vence 23/08/2026)") quebrava
     desencontrado do valor. Agora ocupa a linha e o valor fica embaixo. */
  .total-line { flex-wrap: wrap; row-gap: 2px; }
  .total-line > span:first-child { flex: 1 1 100%; }
  .total-line > span:last-child { flex: 1 1 100%; text-align: right; }

  /* Cabeçalho da tela: mês em cima, os dois filtros dividindo a linha e os
     botões juntos na última — "Aporte empresa" e "Nova conta" lado a lado. */
  .page-head .filters { width: 100%; }
  .page-head .filters > input[type="month"] { flex: 1 1 100%; }
  .page-head .filters > select { flex: 1 1 45%; min-width: 0; }
  .page-head .filters > .btn {
    flex: 1 1 auto;
    justify-content: center;
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Formulários: duas colunas espremiam os campos em 151px e faziam rótulos
     longos quebrarem em duas linhas, desencontrando as colunas. Uma por vez. */
  .field-row { grid-template-columns: 1fr; gap: 0; }

  /* Botão de formulário em painel ocupa a linha (Salvar, Alterar senha) */
  .panel form > .btn { width: 100%; justify-content: center; }
}

/* ---------- Estado vazio ---------- */

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
}

.empty svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }
.empty p { font-size: 14px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 34, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
  animation: slideUp .18s ease;
}

.modal-sm { max-width: 380px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}

.modal-head h3 { font-size: 17px; letter-spacing: -.2px; }

.modal-body { padding: 16px 22px 22px; }
.modal-body h3 { font-size: 17px; margin-bottom: 6px; }
.modal-body p { margin-bottom: 18px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Toasts ---------- */

#toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #182136;
  color: #fff;
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
  animation: slideUp .18s ease;
  transition: opacity .3s;
  max-width: 90vw;
}

.toast-error { background: var(--red); }
.toast.hide { opacity: 0; }

@media (max-width: 860px) {
  #toasts { bottom: 96px; }
}

/* ---------- Diversos ---------- */

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 22px 0 10px; }

.total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 6px 4px;
  font-weight: 700;
  font-size: 16px;
}

/* ---------- Tabela do relatório ---------- */

.tabela-wrap { overflow-x: auto; margin: 0 -6px; }

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}

.tabela th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

.tabela td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover { background: var(--bg); }
.tabela th.num, .tabela td.num { text-align: right; }
.tabela td .amount { font-weight: 700; }
.tabela td:nth-child(2) { max-width: 280px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }

/* ---------- Baixa em lote ---------- */

.tx-check { width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }

.bulk-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 10px;
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 600;
}

.bulk-head input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.bulk-head label { cursor: pointer; }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: #3f4c74;
}

.bulk-actions { display: flex; gap: 8px; }

/* Linha secundária do rodapé (ex.: já pago no mês) */
.total-line.sub { padding: 2px 6px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* Total geral: contas + faturas de cartão */
.total-line.grand {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 17px;
}

/* Linha da fatura dentro de Contas a Pagar — clicável, leva para o cartão */
.fatura-row { cursor: pointer; border-radius: var(--radius-sm); transition: background .12s; }
.fatura-row:hover { background: var(--bg); }
.fatura-row .tx-actions .icon-btn { pointer-events: none; }

.loading { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
