/* ============ Fin360 — Design Tokens ============ */
:root[data-theme="dark"] {
  --bg: #0a0e1f;
  --bg-elevated: #11162b;
  --bg-card: #131a36;
  --bg-card-hover: #161e3f;
  --bg-input: #0d1226;
  --border: #232a4d;
  --border-soft: #1a2140;
  --border-strong: #34406e;
  --text: #f5f7fa;
  --text-muted: #8b93ac;
  --text-faint: #5b6489;

  --primary: #3866ff;
  --primary-dark: #1e3fcc;
  --primary-soft: rgba(56, 102, 255, 0.16);
  --primary-contrast: #ffffff;

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --danger: #f04848;
  --danger-soft: rgba(240, 72, 72, 0.14);
  --warning: #f5a623;
  --warning-soft: rgba(245, 166, 35, 0.14);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.14);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);

  --sidebar-start: #2747e0;
  --sidebar-end: #0e1c6e;
  --sidebar-text: #dbe2ff;
  --sidebar-text-active: #1e3fcc;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 9px;
}

:root[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f9ff;
  --bg-input: #f3f5fb;
  --border: #e3e7f4;
  --border-soft: #ebeef8;
  --border-strong: #c7cfe8;
  --text: #131933;
  --text-muted: #697091;
  --text-faint: #9aa1c2;

  --primary: #3866ff;
  --primary-dark: #1e3fcc;
  --primary-soft: rgba(56, 102, 255, 0.1);
  --primary-contrast: #ffffff;

  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --purple: #9333ea;
  --purple-soft: rgba(147, 51, 234, 0.1);
  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, 0.1);

  --sidebar-start: #3866ff;
  --sidebar-end: #1530a8;
  --sidebar-text: #e7ecff;
  --sidebar-text-active: #1e3fcc;

  --shadow-card: 0 1px 3px rgba(20, 30, 70, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', Inter, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }
::selection { background: var(--primary-soft); }

.svg-icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

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

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-start), var(--sidebar-end));
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.18s ease, padding 0.18s ease;
}
.app-shell.collapsed .sidebar { width: 84px; padding: 18px 10px; }
.app-shell.collapsed .brand-text,
.app-shell.collapsed .context-toggle,
.app-shell.collapsed .nav-label,
.app-shell.collapsed .sidebar-version { display: none; }
.app-shell.collapsed .nav-item { justify-content: center; }
.app-shell.collapsed .collapse-btn { transform: rotate(180deg); }

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 18px; }
/* margin-left compensa a largura da seta pra logo ficar centralizada na sidebar inteira */
.brand { display: flex; align-items: center; justify-content: center; overflow: hidden; flex: 1; margin-left: 26px; }
.brand-logo-img { width: 156px; display: block; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.35)); }
.brand-logo-mini { display: none; width: 40px; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.35)); }
.app-shell.collapsed .sidebar-top { flex-direction: column; gap: 10px; }
.app-shell.collapsed .brand { flex: initial; margin-left: 0; }
.app-shell.collapsed .brand-logo-img { display: none; }
.app-shell.collapsed .brand-logo-mini { display: block; }

.collapse-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 8px;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.18s;
}
.collapse-btn:hover { background: rgba(255,255,255,0.22); }


.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.nav-item .svg-icon { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: #fff; color: var(--sidebar-text-active); font-weight: 700; }
.nav-item.active .svg-icon { opacity: 1; }

.nav-divider { display: flex; align-items: center; gap: 8px; margin: 12px 10px 6px; }
.nav-divider span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.45); font-weight: 700; white-space: nowrap; }
.app-shell.collapsed .nav-divider span { display: none; }
.nav-ia-badge { margin-left: auto; font-size: 9px; font-weight: 800; letter-spacing: 0.04em; background: rgba(255,255,255,0.18); color: #fff; padding: 2px 6px; border-radius: 999px; }
.nav-item.active .nav-ia-badge { background: var(--primary-soft); color: var(--primary); }
.app-shell.collapsed .nav-ia-badge { display: none; }

.sidebar-footer { padding: 10px 6px 0; }
.sidebar-version { color: rgba(255,255,255,0.45); font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h1 { font-size: 19px; font-weight: 700; }
.topbar-left p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* no desktop a seta da sidebar já recolhe/expande o menu; o hambúrguer só é útil no celular */
#menu-btn { display: none; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.icon-btn.active { color: var(--primary); border-color: var(--primary-soft); background: var(--primary-soft); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.page-content { padding: 26px 28px 60px; max-width: 1800px; width: 100%; margin: 0 auto; }

/* ============ Cards / stat grid ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-card .stat-label { font-size: 11px; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.stat-card .stat-icon {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon .svg-icon { width: 15px; height: 15px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.dash-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.dash-stats-title { grid-column: span 3; font-size: 11px; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.dash-stats .stat-card .stat-value { font-size: clamp(15px, 1.6vw, 22px); white-space: nowrap; }
@media (max-width: 900px) { .dash-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dash-stats-title { grid-column: span 3; } }
/* numa coluna só os dois títulos cairiam juntos no topo, longe dos cards deles — o `order` recoloca
   cada título na frente do seu próprio grupo de 3 */
@media (max-width: 560px) {
  .dash-stats { grid-template-columns: 1fr; }
  .dash-stats-title { grid-column: span 1; }
  .dash-stats > *:nth-child(1) { order: 1; }
  .dash-stats > *:nth-child(n+3):nth-child(-n+5) { order: 2; }
  .dash-stats > *:nth-child(2) { order: 3; margin-top: 10px; }
  .dash-stats > *:nth-child(n+6) { order: 4; }
}

.stat-grid-tight { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat-grid-tight .stat-card { padding: 12px 12px 10px; }
.stat-grid-tight .stat-card .stat-icon { width: 26px; height: 26px; }
.stat-grid-tight .stat-card .stat-icon .svg-icon { width: 13px; height: 13px; }
.stat-grid-tight .stat-card .stat-value { font-size: 19px; }
.stat-grid-tight .stat-card .stat-label { font-size: 10.5px; }
.stat-grid-tight .stat-card .stat-sub { font-size: 11px; }

.tone-red .stat-icon { background: var(--danger-soft); color: var(--danger); }
.tone-green .stat-icon { background: var(--success-soft); color: var(--success); }
.tone-blue .stat-icon { background: var(--primary-soft); color: var(--primary); }
.tone-purple .stat-icon { background: var(--purple-soft); color: var(--purple); }
.tone-orange .stat-icon { background: var(--warning-soft); color: var(--warning); }
.tone-cyan .stat-icon { background: var(--cyan-soft); color: var(--cyan); }

.tone-red .stat-value { color: var(--danger); }
.tone-green .stat-value { color: var(--success); }
.tone-blue .stat-value { color: var(--primary); }
.tone-purple .stat-value { color: var(--purple); }
.tone-orange .stat-value { color: var(--warning); }
.tone-cyan .stat-value { color: var(--cyan); }

/* ============ Generic panel/card ============ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  min-width: 0;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-header .panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 400; }
.panel-header-text h3 + .panel-sub { margin-left: 0; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 36px 16px; color: var(--text-muted); gap: 10px; }
.empty-state .svg-icon { width: 30px; height: 30px; color: var(--text-faint); }
.empty-state strong { color: var(--text); font-size: 14.5px; }
.empty-state span { font-size: 13px; max-width: 320px; }

/* minmax(0, …) é obrigatório: com `1fr` puro a coluna nunca encolhe abaixo do conteúdo,
   e uma tabela larga estica o grid inteiro, empurrando a página pra fora da tela no celular */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-form-list { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) {
  .grid-2, .grid-form-list { grid-template-columns: minmax(0, 1fr); }
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; border: 1px solid transparent;
  padding: 10px 16px; font-size: 13.5px; font-weight: 700;
  transition: filter 0.12s, background 0.12s;
}
.btn:active { filter: brightness(0.92); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-card-hover); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }
.btn-success .svg-icon { width: 14px; height: 14px; }
.btn-pay {
  display: inline-flex; align-items: center; gap: 5px; border: none;
  background: var(--success); color: #fff;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
}
.btn-pay:hover { filter: brightness(0.92); }
.btn-pay .svg-icon { width: 12px; height: 12px; }
.btn-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-muted); }
.btn-toggle-label { display: inline-flex; align-items: center; gap: 8px; }
.btn-icon:hover { color: var(--text); background: var(--bg-card-hover); }

.pill-group { display: flex; gap: 6px; background: var(--bg-input); padding: 4px; border-radius: 10px; border: 1px solid var(--border-soft); flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center;
  border: none; background: transparent; color: var(--text-muted);
  padding: 7px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
}
.pill.active { background: var(--primary); color: #fff; }
.pill:not(.active):hover { background: var(--bg-card-hover); color: var(--text); }
.pill .svg-icon { width: 14px; height: 14px; margin-right: 5px; }

.pill-group-forma { flex-wrap: nowrap; }
.pill-group-forma .pill { flex: 1; justify-content: center; padding: 7px 6px; font-size: 12px; white-space: nowrap; }

.type-box-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-muted); font-size: 13px; font-weight: 700;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.type-box:hover { background: var(--bg-card-hover); color: var(--text); }
.type-box .svg-icon { width: 20px; height: 20px; }
.type-box.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ============ Period / bank toolbar (dropdowns) ============ */
.period-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.dropdown { position: relative; }
.dropdown-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 9px 13px; border-radius: 9px; font-size: 12.5px; font-weight: 600;
}
.dropdown-trigger:hover { background: var(--bg-card-hover); }
.dropdown-trigger .svg-icon { width: 14px; height: 14px; }
.dropdown-trigger .chevron { width: 12px; height: 12px; margin-left: 2px; color: var(--text-muted); transition: transform 0.15s; }
.dropdown.open .dropdown-trigger { border-color: var(--primary); }
.dropdown.open .dropdown-trigger .chevron { transform: rotate(180deg); }
.dropdown.open .pill.dropdown-trigger { background: var(--primary); color: #fff; }

.dropdown-panel {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 20px 44px rgba(0,0,0,0.35); padding: 8px;
}
.dropdown.open .dropdown-panel { display: block; }

.bank-panel { min-width: 200px; }
.bank-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; color: var(--text);
  padding: 9px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; text-align: left;
}
.bank-option:hover { background: var(--bg-card-hover); }
.bank-option.active { background: var(--primary); color: #fff; }
.bank-option .svg-icon { width: 15px; height: 15px; }

.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; gap: 8px; }
.picker-head strong { font-size: 13.5px; }
.picker-title { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }
.picker-nav {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.picker-nav:hover { background: var(--bg-card-hover); color: var(--text); }
.picker-nav .svg-icon { width: 13px; height: 13px; }
.chevron-prev { transform: rotate(90deg); }
.chevron-next { transform: rotate(-90deg); }

.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 190px; }
.year-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; width: 170px; }
.month-cell, .year-cell {
  border: none; background: var(--bg-input); color: var(--text);
  padding: 9px 6px; border-radius: 8px; font-size: 12.5px; font-weight: 600; text-align: center;
}
.month-cell:hover, .year-cell:hover { background: var(--bg-card-hover); }
.month-cell.active, .year-cell.active { background: var(--primary); color: #fff; }

.emoji-trigger { padding: 6px 10px; }
.emoji-preview { font-size: 18px; line-height: 1; }
.emoji-panel { min-width: 220px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; width: 228px; max-height: 220px; overflow-y: auto; }
.emoji-cell { border: none; background: var(--bg-input); border-radius: 8px; font-size: 18px; padding: 6px 0; line-height: 1; }
.emoji-cell:hover { background: var(--bg-card-hover); }
.emoji-cell.active { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted);
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0;
}
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ============ Forms ============ */
.field { margin-bottom: 13px; }
.field label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.field label .req { color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1.3fr 0.7fr 1fr; gap: 10px; }
input[type="text"], input[type="number"], input[type="date"], input[type="month"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; outline: none;
  transition: border-color 0.12s;
}
/* espaço reservado pra seta nativa não sobrepor o texto quando a opção é longa */
select { padding-right: 30px; text-overflow: ellipsis; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }
.input-with-btn { display: flex; gap: 8px; }
.money-input-wrap { position: relative; }
.money-input-wrap .money-prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13.5px; pointer-events: none; }
.money-input-wrap input { padding-left: 34px; }
.input-with-btn select { flex: 1; }
.btn-add-new {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 14px; border-radius: 10px;
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.btn-add-new:hover { color: var(--text); background: var(--bg-card-hover); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.checkbox-row input { width: auto; }

/* ============ Table / list ============ */
/* toda tabela larga rola dentro do próprio card em vez de esticar a página */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 0 12px 10px; font-weight: 700; }
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--text); }
.sortable-th .svg-icon { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; transition: transform 0.15s ease, opacity 0.15s ease; }
.list-table td { padding: 12px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.list-table tr:hover td { background: var(--bg-card-hover); }
.row-title { font-weight: 700; }
.cat-list-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 700; margin: 14px 0 8px; }
.cat-list-scroll { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.cat-list-row { display: flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px 8px 8px; font-size: 13px; font-weight: 600; transition: opacity 0.12s, border-color 0.12s; }
.cat-list-row.dragging { opacity: 0.4; }
.cat-list-row.drag-over { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cat-drag-handle { display: flex; flex-shrink: 0; color: var(--text-faint); cursor: grab; }
.cat-drag-handle .svg-icon { width: 15px; height: 15px; }
.cat-list-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.amount-pos { color: var(--success); font-weight: 700; }
.amount-neg { color: var(--danger); font-weight: 700; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; flex-shrink: 0; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg-input); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.category-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 7px; white-space: nowrap; flex-shrink: 0; }

/* progress bar */
.progress-track { width: 100%; height: 7px; border-radius: 999px; background: var(--bg-input); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.2s; }

/* ============ Modal / Toast ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,8,20,0.6); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.4); max-height: 88vh; overflow-y: auto; }
.modal-box.modal-box-lg { max-width: 640px; }
.modal-box h3 { font-size: 16px; margin-bottom: 8px; }
.modal-box p { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.choice-card { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input); cursor: pointer; margin-bottom: 10px; transition: filter 0.12s; }
.choice-card:hover { filter: brightness(1.1); }
.choice-card strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.choice-card span { display: block; font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.choice-card.danger { border-color: var(--danger); background: var(--danger-soft); }
.choice-card.danger strong { color: var(--danger); }
.choice-card.danger span { color: var(--danger); opacity: 0.85; }

.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: flex; align-items: center; gap: 8px; min-width: 220px;
  animation: toast-in 0.18s ease;
}
.toast.success { border-color: var(--success); }
.toast.danger { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }

/* ============ Misc ============ */
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.placeholder-page { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 90px 20px; color: var(--text-muted); }
.placeholder-page .svg-icon { width: 42px; height: 42px; color: var(--primary); margin-bottom: 16px; }
.placeholder-page h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.placeholder-page p { font-size: 13.5px; max-width: 360px; line-height: 1.6; }

.month-table-wrap { overflow-x: auto; }
.month-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.month-table th { text-align: left; padding: 0 12px 10px; font-size: 11px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.month-table td { padding: 11px 12px; border-top: 1px solid var(--border-soft); }
.month-table td:nth-child(n+3), .month-table th:nth-child(n+3) { text-align: center; }
.month-table tr.is-current td { background: var(--primary-soft); }
.month-table tfoot td { border-top: 2px solid var(--border); font-weight: 800; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

.sidebar-backdrop { display: none; }

@media (max-width: 720px) {
  .sidebar { position: fixed; left: -280px; z-index: 40; box-shadow: 0 0 40px rgba(0,0,0,0.4); transition: left 0.2s; }
  .app-shell.mobile-open .sidebar { left: 0; }
  #menu-btn { display: flex; }
  .page-content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .field-row-3 { grid-template-columns: 1fr; }

  /* no celular a seta de recolher não faz sentido — quem abre/fecha é o botão de menu */
  .collapse-btn { display: none; }

  /* mesmo se o app foi recolhido no desktop, no celular a lateral abre sempre completa (com textos),
     senão fica só ícones e confunde */
  .app-shell.collapsed .sidebar { width: 256px; padding: 18px 14px; }
  .app-shell.collapsed .brand-text,
  .app-shell.collapsed .nav-label,
  .app-shell.collapsed .nav-divider span,
  .app-shell.collapsed .nav-ia-badge,
  .app-shell.collapsed .sidebar-version { display: revert; }
  .app-shell.collapsed .nav-item { justify-content: flex-start; }
  .app-shell.collapsed .sidebar-top { flex-direction: row; }
  .app-shell.collapsed .brand { flex: 1; margin-left: 0; }
  .app-shell.collapsed .brand-logo-img { display: block; }
  .app-shell.collapsed .brand-logo-mini { display: none; }

  /* fundo escuro: tocar fecha a lateral */
  .app-shell.mobile-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 39;
    background: rgba(0,0,0,0.55);
  }

  /* tabelas no celular: só as colunas essenciais, o resto sai (continua tudo na edição do item) */
  .list-table .col-opt { display: none; }
  .list-table { font-size: 12.5px; }
  .list-table th { padding: 0 6px 8px; }
  .list-table td { padding: 10px 6px; }
  .list-table .col-year { display: none; }   /* 22/07/2026 vira 22/07 */
  .row-actions { gap: 2px; }
  .row-actions .btn-icon { width: 28px; height: 28px; }
  /* títulos e etiquetas quebram em duas linhas em vez de esticar a coluna */
  .list-table th, .list-table .sortable-th { white-space: normal; font-size: 10px; }
  .list-table .badge { padding: 3px 7px; font-size: 10px; white-space: normal; }
  /* status: etiqueta em cima, botão embaixo — lado a lado a coluna fica larga demais */
  .status-cell { flex-direction: column; align-items: flex-start !important; gap: 4px !important; }

  .panel { padding: 14px; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .month-table { min-width: 620px; }

  /* filtros e cabeçalhos de card empilham em vez de espremer */
  .panel-header { flex-direction: column; align-items: stretch; }
  .panel-header > div { min-width: 0; flex-wrap: wrap; }
  .period-toolbar { flex-wrap: wrap; }
  input, select, textarea { max-width: 100%; }
}

/* ============ Tela de login / cadastro ============ */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, var(--sidebar-start), var(--sidebar-end) 70%);
  padding: 24px;
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 28px 34px; box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  margin: auto;
}
.auth-logo-full { display: block; width: 82%; max-width: 270px; margin: 0 auto 18px; }
[data-theme='light'] .auth-logo-escuro { display: none; }
html:not([data-theme='light']) .auth-logo-claro { display: none; }
.auth-tabs { display: flex; background: var(--bg-input); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; border: none; background: transparent; color: var(--text-muted); padding: 9px; border-radius: 7px; font-size: 13px; font-weight: 700; }
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-form { text-align: left; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-error { color: var(--danger); font-size: 12.5px; margin: -4px 0 12px; text-align: left; }
.auth-ok { color: var(--success); font-size: 12.5px; line-height: 1.5; margin: -4px 0 12px; text-align: left; }
.auth-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 16px; }
.auth-hint a { color: var(--primary); text-decoration: none; }
.auth-hint a:hover { text-decoration: underline; }
.auth-titulo { font-size: 17px; font-weight: 800; margin-bottom: 18px; }

/* Aviso ao lado do campo de e-mail no cadastro. Fica aqui, e não numa página
   anterior, porque a pessoa precisa ler no instante em que digita o e-mail —
   cadastrar com e-mail diferente do da compra é o erro nº 1 de quem já pagou. */
.field-aviso {
  font-size: 11.5px; line-height: 1.45; margin: 6px 0 0;
  color: var(--warning); background: var(--warning-soft);
  border-left: 2px solid var(--warning); border-radius: 0 6px 6px 0;
  padding: 7px 9px;
}

/* Aviso de que as alterações não estão subindo pro servidor. Fica na tela enquanto o
   problema existir — toast desaparece e a pessoa continuaria lançando sem saber. */
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 5px 11px; font-size: 11.5px; font-weight: 700;
  cursor: pointer; max-width: 200px;
}
.sync-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.sync-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-badge.aviso { color: var(--warning, #f5a623); background: rgba(245, 166, 35, 0.13); border-color: rgba(245, 166, 35, 0.35); }
.sync-badge.erro { color: var(--danger); background: var(--danger-soft, rgba(240, 72, 72, 0.14)); border-color: rgba(240, 72, 72, 0.4); }
@media (max-width: 720px) { .sync-badge span { display: none; } .sync-badge { padding: 7px; } }
