/* ==================================================================
   Financeiro — design tokens + base
   ================================================================== */
:root {
  --bg:            #f8fafc;   /* slate-50 */
  --bg-soft:       #f1f5f9;   /* slate-100 */
  --card:          #ffffff;
  --text:          #0f172a;   /* slate-900 */
  --text-muted:    #64748b;   /* slate-500 */
  --text-soft:     #94a3b8;   /* slate-400 */
  --border:        #e2e8f0;   /* slate-200 */
  --border-strong: #cbd5e1;   /* slate-300 */

  --primary:       #2563eb;   /* blue-600 */
  --primary-hover: #1d4ed8;   /* blue-700 */
  --primary-soft:  #dbeafe;   /* blue-100 */

  --success:       #16a34a;   /* green-600 */
  --success-soft:  #dcfce7;   /* green-100 */
  --warning:       #f59e0b;   /* amber-500 */
  --warning-soft:  #fef3c7;   /* amber-100 */
  --danger:        #dc2626;   /* red-600 */
  --danger-soft:   #fee2e2;   /* red-100 */

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md:     0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tap-min:       44px;       /* tamanho mínimo de toque */
  --header-h:      60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

button { font-family: inherit; }

/* ==================================================================
   Layout
   ================================================================== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 12px 64px;
}

@media (min-width: 720px) {
  .container { padding: 32px 24px 80px; }
}

/* ==================================================================
   Topbar
   ================================================================== */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
  background: rgba(255, 255, 255, 0.85);
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 8px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
@media (min-width: 720px) {
  .topbar-inner { padding: 0 24px; gap: 16px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
@media (min-width: 720px) {
  .brand { gap: 10px; font-size: 17px; }
}
.brand:hover { color: var(--text); }
.brand-name { display: none; }
.brand-mark { display: none; }
@media (min-width: 720px) {
  .brand-name { display: inline; font-weight: 600; }
  .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex-shrink: 0;
  }
}

.topnav { display: flex; gap: 2px; }
@media (min-width: 720px) { .topnav { gap: 4px; } }
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  width: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.nav-link svg { display: block; width: 18px; height: 18px; }
.nav-label { display: none; }
@media (min-width: 720px) {
  .nav-link { height: var(--tap-min); width: auto; padding: 0 14px; gap: 6px; }
  .nav-link svg { width: 20px; height: 20px; }
  .nav-label { display: inline; }
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ==================================================================
   Cards
   ================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
@media (min-width: 720px) { .card { padding: 20px; } }

/* ==================================================================
   Page head
   ================================================================== */
.page-head { margin-bottom: 20px; }
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
@media (min-width: 720px) { .page-title { font-size: 26px; } }
.page-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* ==================================================================
   Month bar
   ================================================================== */
.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  text-transform: capitalize;
  min-width: 180px;
  text-align: center;
}
@media (min-width: 720px) { .month-title { font-size: 28px; } }
.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-arrow:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft);
}

/* ==================================================================
   Totals
.totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
@media (min-width: 720px) {
  .totals-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}
.card-totals { padding: 12px 14px; }
@media (min-width: 720px) { .card-totals { padding: 16px; } }
.card-totals .card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.card-totals .card-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 720px) {
  .card-totals .card-value { font-size: 28px; }
}
.card-totals .card-meta {
  font-size: 11px;
  color: var(--text-soft);
}
.card-pending { border-left: 3px solid var(--warning); }
.card-paid    { border-left: 3px solid var(--success); }
.card-total   { border-left: 3px solid var(--primary); }
.card-pending .card-value { color: var(--warning); }
.card-paid .card-value    { color: var(--success); }
.card-total .card-value   { color: var(--primary); }

/* ==================================================================
   Summary card (relatório do mês)
   ================================================================== */
.summary-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 16px;
  border-left: 3px solid var(--primary);
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--card) 60%);
}
@media (min-width: 720px) {
  .summary-card {
    grid-template-columns: 1fr 1.2fr;
    gap: 28px;
    padding: 20px 22px;
    align-items: center;
  }
}

.summary-main { min-width: 0; }
.summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.summary-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
@media (min-width: 720px) {
  .summary-value { font-size: 36px; }
}
.summary-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* Indicador de tendência vs. mês passado */
.summary-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-muted);
  max-width: 100%;
}
.summary-trend-arrow {
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}
.summary-trend-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.summary-trend--up {
  background: var(--danger-soft);
  color: var(--danger);
}
.summary-trend--down {
  background: var(--success-soft);
  color: var(--success);
}
.summary-trend--neutral {
  background: var(--bg-soft);
  color: var(--text-muted);
}

/* Top despesas (lado direito no desktop, abaixo no mobile) */
.summary-top { min-width: 0; }
.summary-top-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.top-expenses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.top-expense {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.top-expense-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  text-align: center;
  background: var(--bg-soft);
  border-radius: 999px;
  height: 20px;
  line-height: 20px;
}
.top-expense-name {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.top-expense-amount {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

/* ==================================================================
   Banner
   ================================================================== */
.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner-info {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: var(--primary-soft);
}
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* ==================================================================
   Forms
   ================================================================== */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { padding: 10px 12px; height: auto; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(4, 1fr); } }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ==================================================================
   Buttons
   ================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ==================================================================
   Tables
   ================================================================== */
.table-wrap { overflow-x: auto; }
@media (min-width: 720px) {
  .table-wrap { overflow: visible; }
}
table.bills-table, table.rec-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
@media (min-width: 720px) {
  table.bills-table, table.rec-table { table-layout: fixed; }
}
@media (max-width: 719px) {
  table.bills-table, table.rec-table {
    table-layout: fixed !important;
    width: 100% !important;
  }
}
table.bills-table th, table.rec-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 600;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--border);
}
table.bills-table td, table.rec-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bill-row td { background: var(--card); transition: background 0.15s; }
.bill-row:hover td { background: var(--bg-soft); }
.bill-row.is-paid td { opacity: 0.65; }
.bill-row.is-paid .cell-amount { text-decoration: line-through; }
.bill-row.is-overdue .cell-date .date-main { color: var(--danger); font-weight: 600; }
.bill-row.is-editing td { background: var(--primary-soft); padding: 0; }

/* col widths */
.col-check  { width: 48px; }
.col-day    { width: 80px; }
.col-date   { width: 130px; }
.col-status { width: 100px; }
.col-amount { width: 130px; text-align: right; }
.col-actions{ width: 90px; text-align: right; }

.cell-check { padding-right: 0 !important; }
.cell-date .date-main { font-weight: 500; }
.cell-date .date-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.cell-date .date-overdue { color: var(--danger); font-weight: 500; }
.cell-desc .desc-main { font-weight: 500; }
.cell-desc .desc-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.cell-desc .desc-meta { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.cell-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.amount-paid { color: var(--text-muted); }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-day .day-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ==================================================================
   Tabela responsiva — vira card no mobile
   ================================================================== */
@media (max-width: 719px) {
  .bills-table thead, .rec-table thead { display: none; }

  /* Reset agressivo pra tabela virar cards limpos */
  .bills-table, .rec-table,
  .bills-table tbody, .rec-table tbody,
  .bills-table tr, .rec-table tr,
  .bills-table td, .rec-table td {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  /* Reseta larguras de coluna herdadas do desktop */
  .bills-table .col-check, .bills-table .col-day,
  .bills-table .col-date, .bills-table .col-status,
  .bills-table .col-amount, .bills-table .col-actions,
  .rec-table .col-day, .rec-table .col-desc,
  .rec-table .col-amount, .rec-table .col-status,
  .rec-table .col-actions {
    width: auto !important;
    text-align: left !important;
  }

  .bills-table tr.bill-row {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--card);
    position: relative;
  }
  .bills-table tr.bill-row.is-overdue {
    border-left: 3px solid var(--danger);
  }
  .bills-table tr.bill-row.is-paid {
    border-left: 3px solid var(--success);
    background: var(--card);
  }

  .bills-table td {
    padding: 0;
    border: none;
  }
  .bills-table td + td { margin-top: 6px; }

  /* Layout do card mobile:
     - Topo: vencimento (esquerda) + botão pagar (direita, absoluto)
     - Meio: descrição em destaque
     - Rodapé: valor (esquerda) + ações (direita) */
  .bills-table .cell-date {
    border-bottom: 1px solid var(--border);
    padding: 4px 50px 8px 0 !important; /* espaço pra botão pagar à direita */
    margin-bottom: 8px !important;
  }
  .bills-table .cell-date::before { display: none; }
  .bills-table .cell-date .date-main { font-size: 14px; }
  .bills-table .cell-date .date-sub { font-size: 12px; margin-top: 2px; }

  /* Botão de pagar no canto superior direito */
  .bills-table .cell-check {
    position: absolute;
    top: 10px;
    right: 14px;
    padding: 0 !important;
  }
  .bills-table .cell-check::before { display: none; }

  /* Descrição em destaque */
  .bills-table .cell-desc { padding: 0 !important; }
  .bills-table .cell-desc::before { display: none; }
  .bills-table .cell-desc .desc-main { font-size: 15px; font-weight: 600; }

  /* Rodapé: valor e ações */
  .bills-table .cell-amount {
    font-size: 17px;
    font-weight: 700;
    text-align: left !important;
    padding-top: 4px !important;
  }
  .bills-table .cell-amount::before { display: none; }

  .bills-table .cell-actions {
    padding: 0 !important;
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .bills-table .cell-actions::before { display: none; }
  .bills-table .cell-actions .icon-btn { width: 28px; height: 28px; }

  /* Edit mode mantém layout tabela */
  .bills-table tr.bill-row.is-editing {
    display: table-row;
    width: auto;
  }
  .bills-table tr.bill-row.is-editing td {
    display: table-cell;
  }

  /* Recurring table vira card no mobile */
  .rec-table tr.rec-row {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--card);
    position: relative;
  }
  .rec-table tr.rec-row.is-inactive {
    opacity: 0.55;
    border-left: 3px solid var(--text-soft);
  }
  .rec-table tr.rec-row.is-active {
    border-left: 3px solid var(--success);
  }
  .rec-table td {
    padding: 0;
    border: none;
  }
  .rec-table td + td { margin-top: 8px; }

  /* Topo: dia + status + ações (direita) */
  .rec-table .cell-day {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .rec-table .cell-status {
    margin-top: 0 !important;
  }

  /* Descrição em destaque */
  .rec-table .cell-desc {
    margin-top: 4px;
  }
  .rec-table .cell-desc .desc-main { font-size: 16px; font-weight: 600; }
  .rec-table .cell-desc .desc-meta { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

  /* Valor + ações (rodapé) */
  .rec-table .cell-amount {
    font-size: 18px;
    font-weight: 700;
    text-align: left !important;
    margin-top: 4px;
  }
  .rec-table .cell-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .rec-table .cell-actions .icon-btn { width: 28px; height: 28px; }
}

/* checkbox-style pay button */
.btn-pay, .btn-unpay {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--card);
  color: var(--text-soft);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-pay:hover {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}
.btn-unpay {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}
.btn-unpay:hover {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-soft);
}

/* No mobile, botão de pagar vira maior e rotulado */
@media (max-width: 719px) {
  .btn-pay, .btn-unpay {
    width: 36px;
    height: 36px;
    border-width: 2px;
  }
  .cell-check { padding: 0 !important; }
  .cell-actions { padding: 0 !important; }
}

/* icon buttons */
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  margin-left: 2px;
}
.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.icon-btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==================================================================
   Status pills
   ================================================================== */
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-active   { background: var(--success-soft); color: var(--success); }
.status-inactive { background: var(--bg-soft); color: var(--text-muted); }

.rec-row.is-inactive { opacity: 0.55; }

/* ==================================================================
   Logout (botão no header)
   ================================================================== */
.logout-form { margin: 0; padding: 0; display: inline-flex; }
.nav-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-soft);
  padding: 0;
}
.nav-logout:hover { color: var(--danger); }

/* ==================================================================
   Empty state
   ================================================================== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
.empty-state p { margin: 4px 0; }
.empty-hint { font-size: 13px; }
.empty-hint a { font-weight: 500; }

/* Empty row dentro do tbody (alvo do HTMX sempre presente) */
.empty-row > td {
  padding: 0;
  border: none;
  background: transparent;
}

/* ==================================================================
   Add bill / recurring (collapsible)
   ================================================================== */
.add-bill-card details, .add-recurring-card details { }
.add-bill-toggle, .add-recurring-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  list-style: none;
  user-select: none;
  padding: 4px 0;
}
.add-bill-toggle::-webkit-details-marker, .add-recurring-toggle::-webkit-details-marker { display: none; }
.add-bill-toggle::before, .add-recurring-toggle::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
}
.add-bill-toggle[aria-expanded], .add-recurring-toggle[aria-expanded] { /* n/a */ }
details[open] > .add-bill-toggle::before, details[open] > .add-recurring-toggle::before {
  transform: rotate(90deg);
}

/* ==================================================================
   Edit form (in-row)
   ================================================================== */
.edit-form { padding: 12px 16px; }
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (min-width: 720px) {
  .edit-grid { grid-template-columns: 2fr 1fr 1fr 3fr; }
}

/* ==================================================================
   Bills header (in cards)
   ================================================================== */
.bills-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.bills-title { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.bills-count {
  font-size: 12px;
  color: var(--text-soft);
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* ==================================================================
   History
   ================================================================== */
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.history-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  text-transform: capitalize;
}
.history-totals { display: flex; gap: 6px; flex-wrap: wrap; }
.tot-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.tot-pending { background: var(--warning-soft); color: var(--warning); }
.tot-paid    { background: var(--success-soft); color: var(--success); }

/* ==================================================================
   Footer
   ================================================================== */
.appfooter {
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  padding: 16px 0 32px;
}

/* ==================================================================
   Acessibilidade
   ================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================================================================
   HTMX feedback (animação + toast)
   ================================================================== */
@keyframes htmx-pulse {
  0%   { background-color: var(--primary-soft); }
  100% { background-color: transparent; }
}
.htmx-swapped {
  animation: htmx-pulse 0.8s ease-out;
}

/* Toast container (canto inferior direito) */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out, toast-out 0.3s ease-in 1.5s forwards;
  pointer-events: auto;
  max-width: 320px;
}
.toast.toast-success { background: var(--success); }
.toast.toast-error   { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px); }
}

::selection { background: var(--primary-soft); color: var(--primary-hover); }
