/* =============================================
   Gestor Pessoal - Estilos
   Layout responsivo e moderno
   ============================================= */

:root {
  /* Superfícies (escuro) */
  --bg: #0f0f12;
  --bg-elevated: #18181c;
  --bg-card: #1c1c21;
  --surface-1: #1c1c21;
  --surface-2: #14141a;
  --surface-3: #0f0f14;

  /* Texto */
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-1: #f4f4f5;
  --text-2: #c4c4c8;
  --text-3: #8a8a93;

  /* Acentos e estados */
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --state-positive: #4ade80;
  --state-positive-bg: rgba(34, 197, 94, 0.15);
  --state-negative: #f87171;
  --state-negative-bg: rgba(239, 68, 68, 0.15);
  --state-neutral: #a1a1aa;
  --state-neutral-bg: rgba(161, 161, 170, 0.15);
  --state-warning-bg: rgba(234, 179, 8, 0.15);
  --state-warning: #fde047;

  /* Tipografia */
  --font-sans: 'Outfit', 'DM Sans', system-ui, sans-serif;
  --font-size-display: clamp(1.75rem, 2.5vw, 2.25rem);
  --font-size-kpi: clamp(1.5rem, 2vw, 1.85rem);
  --font-size-label: 0.6875rem; /* 11px */
  --letter-spacing-label: 0.05em;

  /* Geometria e elevação */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-card: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-card-hover: 0 8px 28px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-w-rail: 72px;
  --sidebar-w-expanded: 240px;
  --topbar-h: 60px;
  --header-h: 56px;
}

/* ---------- Tema claro ---------- */
body.tema-claro {
  --bg: #f4f4f5;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f5;

  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --text-1: #18181b;
  --text-2: #404049;
  --text-3: #71717a;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --state-positive: #16a34a;
  --state-positive-bg: rgba(34, 197, 94, 0.14);
  --state-negative: #dc2626;
  --state-negative-bg: rgba(239, 68, 68, 0.12);
  --state-neutral: #71717a;
  --state-neutral-bg: rgba(113, 113, 122, 0.12);
  --state-warning: #b45309;
  --state-warning-bg: rgba(234, 179, 8, 0.14);

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 2px rgba(15, 15, 18, 0.06), 0 1px 1px rgba(15, 15, 18, 0.04);
  --shadow-card-hover: 0 6px 18px rgba(15, 15, 18, 0.10);
}
body.tema-claro .stat-card:hover {
  border-color: var(--accent);
}
body.tema-claro .note-card {
  border-left-color: var(--note-color);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ---------- Layout Auth (login/registro) ---------- */
.layout-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(145deg, var(--bg) 0%, #16161a 50%, var(--bg-elevated) 100%);
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo {
  display: inline-block;
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.auth-brand h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}
.auth-brand p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.auth-tagline {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.2rem;
}
.auth-brand p:last-of-type { margin-top: 0.5rem; }

.auth-form label {
  display: block;
  margin-bottom: 1rem;
}
.auth-form label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.auth-form input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.alert-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}
.alert-success a {
  color: #86efac;
  font-weight: 500;
}

.auth-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.auth-link a {
  font-weight: 500;
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover {
  background: var(--border);
  color: var(--text);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}
.btn-block {
  width: 100%;
}
.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text-1);
}
.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--text-3);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.btn-strong {
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.28);
}
body.tema-claro .btn-strong { box-shadow: 0 6px 18px rgba(79, 70, 229, 0.18); }
.btn-danger {
  color: var(--state-negative);
  border-color: var(--state-negative-bg);
}
.btn-danger:hover {
  background: var(--state-negative-bg);
  color: var(--state-negative);
  border-color: var(--state-negative);
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text);
}
.btn-edit:hover { color: var(--accent); }
.btn-delete:hover { color: var(--danger); }

/* ---------- Layout App (sidebar + main) ---------- */
.layout-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar rail/expanded: largura controlada pelo atributo data-sidebar do body */
body[data-sidebar="rail"] { --sidebar-current: var(--sidebar-w-rail); }
body[data-sidebar="expanded"] { --sidebar-current: var(--sidebar-w-expanded); }
body:not([data-sidebar]) { --sidebar-current: var(--sidebar-w); }

.sidebar {
  width: var(--sidebar-current, var(--sidebar-w));
  min-width: var(--sidebar-current, var(--sidebar-w));
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.2s ease, min-width 0.2s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-brand-btn {
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}
.sidebar-brand-btn:hover { background: rgba(255,255,255,0.03); }
body.tema-claro .sidebar-brand-btn:hover { background: rgba(0,0,0,0.03); }
.sidebar-logo {
  font-size: 1.5rem;
  color: var(--accent);
}
.sidebar-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  margin-bottom: 0.25rem;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
.nav-separator {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 1rem 0.35rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.nav-icon {
  font-size: 1.1rem;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 1rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.export-links {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.export-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.export-btn {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  margin-right: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.export-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
}
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
}
.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.user-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  display: block;
  width: 100%;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}
.btn-logout:hover {
  background: var(--bg-card);
  color: var(--danger);
  text-decoration: none;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 101;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s;
}
.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.sidebar-toggle:hover {
  background: var(--bg-elevated);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-current, var(--sidebar-w));
  min-height: 100vh;
  padding: 1.5rem;
  padding-top: calc(var(--topbar-h) + 1.25rem);
  padding-bottom: 3rem;
  transition: margin-left 0.2s ease;
}

/* ---------- Page header ---------- */
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
}
.page-subtitle {
  font-size: 0.95rem;
  color: var(--text-2);
  margin-top: 0.25rem;
}

/* ---------- Stats grid (dashboard) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}
.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.dashboard-financeiro { margin-bottom: 1.5rem; }
.dashboard-financeiro .section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.stat-receita { color: var(--success) !important; }
.stat-gasto { color: var(--danger) !important; }
.stat-saldo { color: var(--success) !important; }
.dashboard-financeiro-link { margin-top: 0.5rem; }
.dashboard-financeiro-link a { font-weight: 500; }
.stats-secundarios .stat-value { color: var(--accent); }
.card-cta {
  margin-bottom: 1.5rem;
  background: var(--accent-soft);
  border-color: var(--accent);
}
.card-cta p { margin: 0; }
.card-cta a { font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.list-tasks, .list-events {
  list-style: none;
}
.list-tasks li, .list-events li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.list-tasks li:last-child, .list-events li:last-child {
  border-bottom: none;
}
.list-tasks a, .list-events a {
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.list-tasks a:hover, .list-events a:hover {
  color: var(--accent);
}
.date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  text-transform: capitalize;
}
.badge-baixa { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-media { background: rgba(234, 179, 8, 0.2); color: #fde047; }
.badge-alta { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
.badge-urgente { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-pendente { background: var(--accent-soft); color: var(--accent); }
.badge-em_andamento { background: rgba(234, 179, 8, 0.2); color: #fde047; }
.badge-concluida { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-cancelada { background: rgba(113, 113, 122, 0.2); color: #a1a1aa; }
.badge-ativa { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-concluida, .badge-pausada { background: rgba(113, 113, 122, 0.2); color: #a1a1aa; }

.link-more {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.empty-state {
  color: var(--text-3);
  font-size: 0.92rem;
  padding: 1rem 0;
  display: block;
}
.empty-state a {
  font-weight: 500;
  color: var(--accent);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.filter-btn:hover {
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}
.filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.calendar-title {
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
}
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item.done .task-body strong { text-decoration: line-through; color: var(--text-muted); }
.task-check {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.task-item.done .task-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.task-check:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.task-body {
  flex: 1;
  min-width: 0;
}
.task-body strong { display: block; }
.task-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  margin-bottom: 0.35rem;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.task-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.task-row {
  flex-shrink: 0;
}

/* ---------- Notes grid ---------- */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--note-color, #fef08a);
  transition: transform 0.2s, box-shadow 0.2s;
}
.note-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.note-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.note-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.note-fav {
  color: var(--warning);
  font-size: 0.9rem;
}
.note-content {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.note-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.color-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.color-option {
  cursor: pointer;
  display: block;
}
.color-option input { display: none; }
.color-option span {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
}
.color-option input:checked + span {
  border-color: var(--text);
  transform: scale(1.15);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 1rem;
}
.checkbox-label input {
  width: auto;
}

/* ---------- Calendar ---------- */
.calendar-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-width: 320px;
  gap: 2px;
}
.cal-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem;
}
.cal-day {
  min-height: 80px;
  padding: 0.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.cal-day.empty {
  background: transparent;
  visibility: hidden;
}
.cal-day.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.cal-num {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}
.cal-event {
  display: block;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: var(--ev-color, var(--accent));
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.2rem;
  text-decoration: none;
}
.cal-event:hover {
  opacity: 0.9;
  text-decoration: none;
  color: #fff;
}

.event-list-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.event-list {
  list-style: none;
}
.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--accent);
}
.event-item:last-child { border-bottom: none; }
.event-item .date, .event-item .location {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.event-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ---------- Goals / Metas ---------- */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  transition: transform 0.2s;
}
.goal-card:hover {
  transform: translateY(-2px);
}
.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.goal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.goal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}
.goal-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2.5rem;
}
.goal-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.goal-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
}
.goal-card.status-concluida { opacity: 0.85; }
.goal-card.status-pausada { opacity: 0.75; }

/* ---------- Contact list ---------- */
.contact-list {
  list-style: none;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.contact-item:last-child { border-bottom: none; }
.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.contact-info {
  flex: 1;
  min-width: 0;
}
.contact-info strong {
  display: block;
  margin-bottom: 0.2rem;
}
.contact-company {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.2rem;
}
.contact-info a {
  font-size: 0.85rem;
  display: block;
  margin-top: 0.15rem;
}
.contact-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal.open {
  opacity: 1;
  visibility: visible;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.modal-box h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--text);
}
.modal-box label {
  display: block;
  margin-bottom: 1rem;
}
.modal-box label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.modal-box input[type="text"],
.modal-box input[type="email"],
.modal-box input[type="tel"],
.modal-box input[type="date"],
.modal-box input[type="datetime-local"],
.modal-box input[type="number"],
.modal-box input[type="color"],
.modal-box select,
.modal-box textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.modal-box input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}
.modal-box input:focus,
.modal-box select:focus,
.modal-box textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
    min-width: 240px;
  }
  body[data-sidebar] .sidebar { width: 240px; min-width: 240px; }
  body[data-sidebar="rail"] .sidebar-name,
  body[data-sidebar="rail"] .nav-item .nav-label {
    display: block;
  }
  body[data-sidebar="rail"] .nav-item {
    padding: 0.7rem 1rem;
    justify-content: flex-start;
  }
  body[data-sidebar="rail"] .nav-item[data-tooltip]::after { display: none; }
  body[data-sidebar="rail"] .sidebar-brand { padding: 1rem 1.25rem; justify-content: flex-start; }
  body[data-sidebar="rail"] .nav-separator { font-size: 0.7rem; }
  body[data-sidebar="rail"] .nav-separator::before { display: none; }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
  }
  .main-content {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + 0.75rem);
  }
  .sidebar-toggle {
    display: flex;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  :root {
    --sidebar-w: 100%;
  }
  .main-content {
    padding: 1rem;
    padding-top: 4.5rem;
  }
  .page-header h1 {
    font-size: 1.4rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filters {
    justify-content: center;
  }
  .task-item {
    flex-wrap: wrap;
  }
  .task-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .notes-grid {
    grid-template-columns: 1fr;
  }
  .goals-grid {
    grid-template-columns: 1fr;
  }
  .calendar-grid {
    min-width: 280px;
  }
  .cal-day {
    min-height: 60px;
    font-size: 0.75rem;
  }
  .cal-event {
    font-size: 0.65rem;
  }
  .contact-item {
    flex-wrap: wrap;
  }
  .contact-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .auth-card {
    padding: 1.5rem;
  }
}

/* ---------- Configurações ---------- */
.settings-section {
  margin-bottom: 1.5rem;
}
.settings-section h2 {
  margin-bottom: 0.5rem;
}
.settings-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.settings-form label {
  display: block;
  margin-bottom: 1rem;
}
.settings-form label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"] {
  width: 100%;
  max-width: 360px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.settings-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.theme-toggle {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.theme-option {
  cursor: pointer;
  display: block;
}
.theme-option input { display: none; }
.theme-preview {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s;
}
.theme-option input:checked + .theme-preview {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.theme-escuro { background: #1c1c21; color: #e4e4e7; }
.theme-claro { background: #f4f4f5; color: #18181b; }
body.tema-claro .theme-claro { background: #e4e4e7; color: #18181b; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.toggle-label input { display: none; }
.toggle-slider {
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}
.toggle-label input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(22px);
}
.toggle-text {
  font-weight: 500;
}

.senha-forca {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
.senha-requisitos {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.senha-requisitos .req {
  color: var(--text-muted);
  transition: color 0.2s;
}
.senha-requisitos .req.ok {
  color: var(--success);
}
.senha-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  max-width: 200px;
}
.senha-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.2s;
}
.senha-coincide {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}
.senha-coincide.ok { color: var(--success); }
.senha-coincide.erro { color: var(--danger); }

/* ---------- Analytics ---------- */
.analytics-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.analytics-tabs .tab {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.analytics-tabs .tab:hover {
  color: var(--text);
  text-decoration: none;
}
.analytics-tabs .tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}
.analytics-stats .stat-gastos .stat-value { color: var(--danger); }
.stat-saldo-negativo .stat-value { color: var(--danger) !important; }
.stat-saldo-positivo .stat-value { color: var(--success) !important; }

/* ---------- Simulação ---------- */
.simulacao-aviso { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.simulacao-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}
.simulacao-form label {
  display: block;
  margin-bottom: 1rem;
}
.simulacao-form label span {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.simulacao-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 44px;
  box-sizing: border-box;
}
.simulacao-form input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}
.simulacao-form input:hover {
  border-color: var(--text-muted);
}
.simulacao-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.simulacao-form button[type="submit"] {
  margin-top: 0.5rem;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
}
.lista-simulacao { list-style: none; margin: 1rem 0 0 0; padding: 0; }
.item-simulacao {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.item-simulacao:last-child { border-bottom: none; }
.item-simulacao .desc { flex: 1; min-width: 0; }
.item-simulacao .valor { font-weight: 600; white-space: nowrap; }
.sim-total { margin-top: 0.75rem; font-weight: 600; font-size: 1rem; }
.simulacao-resumo { margin-top: 1.5rem; }
.simulacao-resumo .simulacao-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.simulacao-resumo #btn-limpar-simulacao { margin-top: 0.5rem; }

.alert-saldo-negativo {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  font-size: 0.95rem;
}
.card-comparativo .comparativo-resumo { margin: 0.5rem 0; font-size: 0.9rem; }
.comparativo-resumo-dash { font-size: 0.9rem; color: var(--text-muted); margin: 0.75rem 0; }
.listas-mes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.lista-financeira {
  list-style: none;
}
.lista-financeira li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.lista-financeira li:last-child { border-bottom: none; }
.lista-financeira .date { color: var(--text-muted); margin-right: 0.5rem; }
.analytics-intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.analytics-intro strong { color: var(--text); }
.analytics-stats .stat-saldo .stat-value { color: var(--success); }
.chart-card { margin-top: 1rem; }
.chart-wrap {
  position: relative;
  height: 280px;
  margin-top: 0.5rem;
}
.chart-wrap canvas { max-height: 280px; }

.meses-barras { display: flex; flex-direction: column; gap: 0.5rem; }
.mes-bar-link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.35rem 0;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.mes-bar-link:hover {
  background: var(--bg-elevated);
  text-decoration: none;
  color: inherit;
}
.mes-bar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.mes-bar-label { min-width: 70px; font-size: 0.9rem; }
.mes-bar-track {
  flex: 1;
  min-width: 100px;
  height: 24px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}
.mes-bar-arrec {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.mes-bar-valor {
  font-weight: 600;
  min-width: 100px;
  text-align: right;
}
.gasto-form label { display: block; margin-bottom: 1rem; }
.gasto-form label span { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.gasto-form input,
.gasto-form select {
  width: 100%;
  max-width: 360px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.parcelas-wrap small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.analytics-manage-link {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.analytics-manage-link a {
  color: var(--accent);
}
.analytics-manage-hint {
  margin-top: 1rem;
  font-size: 0.9rem;
}
.analytics-manage-hint a {
  color: var(--accent);
}
.analytics-gerenciar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.gerenciar-periodo-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}
.gerenciar-periodo-form label span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.gerenciar-periodo-form select,
.gerenciar-periodo-form input[type="number"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  min-width: 110px;
}
.gerenciar-nav-mes {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.gerenciar-mes-atual {
  font-weight: 600;
  color: var(--text);
}
.analytics-edit-card {
  margin-bottom: 1.25rem;
}
.analytics-edit-card h2 {
  margin-top: 0;
}
.form-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}
.form-inline-acao {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}
.lancamento-item a.btn-edit {
  text-decoration: none;
  flex-shrink: 0;
  align-self: center;
}
.modal-detalhe-mes .detalhe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}
.detalhe-bloco h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}
.detalhe-lista {
  list-style: none;
}
.detalhe-lista li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.detalhe-lista li:last-child { border-bottom: none; }

/* ---------- Prestar contas ---------- */
.prestar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.form-inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.form-inline input[type="text"] {
  flex: 1;
  min-width: 140px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.list-negocios {
  list-style: none;
}
.negocio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.negocio-item:last-child { border-bottom: none; }
.negocio-actions {
  display: flex;
  gap: 0.25rem;
}
.prestar-form label {
  display: block;
  margin-bottom: 1rem;
}
.prestar-form label span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.prestar-form input,
.prestar-form select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.prestar-total .total-valor {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.5rem;
}
.list-lancamentos {
  list-style: none;
}
.lancamento-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.lancamento-item:last-child { border-bottom: none; }
.lancamento-item > div:first-child {
  flex: 1;
  min-width: 0;
}
.lancamento-item .date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.lanc-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.lancamento-valor {
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 520px) {
  .lancamento-item {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
  }
  .lancamento-item .lancamento-valor {
    flex: 1 1 auto;
    min-width: 50%;
  }
}

.receitas-simples .prestar-form { max-width: 400px; }
.form-hint { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.label-nome-receita { display: block !important; visibility: visible !important; }
.label-nome-receita span { display: block !important; }
.label-nome-receita input { display: block !important; width: 100% !important; }
.total-valor-inline { margin-bottom: 1rem; font-size: 1rem; }
.prestar-toolbar-single {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.prestar-toolbar-single .prestar-periodo-label { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.prestar-toolbar-single .back-link { font-size: 0.95rem; }
.prestar-toolbar-single .filters { display: flex; gap: 0.5rem; }
.carteiras-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.carteira-card { padding: 1.25rem; }
.carteira-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.carteira-header h2 { margin: 0; font-size: 1.1rem; }
.carteira-header h2 a { text-decoration: none; }
.carteira-header h2 a:hover { text-decoration: underline; }
.carteira-actions { display: flex; gap: 0.25rem; }
.carteira-saldo { margin: 0.5rem 0; font-size: 0.95rem; }
.carteira-saldo.grande { font-size: 1.1rem; margin: 0.75rem 0; }
.carteira-saldo .positivo { color: var(--success); }
.carteira-saldo .negativo { color: var(--danger); }
.carteira-export-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.carteira-export-label { font-size: 0.9rem; color: var(--text-muted); margin-right: 0.25rem; }
.btn-export {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.btn-export-pdf {
  background: var(--danger);
  color: #fff;
  border: 1px solid transparent;
}
.btn-export-pdf:hover { background: #dc2626; color: #fff; text-decoration: none; }
.btn-export-csv {
  background: var(--success);
  color: #fff;
  border: 1px solid transparent;
}
.btn-export-csv:hover { background: #16a34a; color: #fff; text-decoration: none; }
.btn-export-xml {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
.btn-export-xml:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.prestar-2col { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.historico-meses {
  list-style: none;
  font-size: 0.9rem;
}
.historico-meses li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.historico-meses li:last-child { border-bottom: none; }
.historico-meses .date { color: var(--text-muted); margin-right: 0.5rem; }
.positivo { color: var(--success); }
.negativo { color: var(--danger); }

/* —— Dashboard patrimonial, metas avançadas, carteira, toast —— */
.btn:not(.btn-icon):active {
  transform: scale(0.97);
}
.toast-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  pointer-events: none;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(360px, 92vw);
  font-size: 0.95rem;
}
.toast-visible {
  opacity: 1;
  transform: translateY(0);
}
.toast-success {
  border-color: var(--success);
}

.dashboard-patrimonio {
  margin-bottom: 2rem;
}
.dashboard-patrimonio .section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.dash-metric-cards {
  gap: 1rem;
}

/* Refina hover sem “dupla borda” com .stat-card */
.stat-card.dash-card-interactive {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card.dash-card-interactive:hover {
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.12);
}
body:not(.tema-claro) .stat-card.dash-card-interactive:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
}
.stat-meta-pill {
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stat-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-weight: 400;
}
.distribuicao-renda-card {
  margin-top: 1.5rem;
}
.distribuicao-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.distribuicao-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.distribuicao-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-label);
  color: var(--text-3);
  font-weight: 600;
}
.distribuicao-bar {
  display: flex;
  height: 1.1rem;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}
.distribuicao-bar .empty {
  flex: 1;
}
.distribuicao-bar .seg-inv {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}
.distribuicao-bar .seg-met {
  background: linear-gradient(90deg, #a855f7, #c084fc);
}
.distribuicao-bar .seg-laz {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.distribuicao-bar .seg-res {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}
.distribuicao-bar .seg-empty {
  background: var(--text-muted);
  opacity: 0.35;
}
.distribuicao-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.distribuicao-legend .val {
  color: var(--accent);
  font-weight: 600;
}
.projecao-chart-card {
  margin-top: 1.5rem;
}
.projecao-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.projecao-label span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.projecao-label input[type="range"] {
  width: 100%;
  max-width: 280px;
}
.projecao-num {
  margin-top: 0.35rem;
  width: 100%;
  max-width: 160px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.projecao-wrap {
  height: 300px;
  min-height: 260px;
  position: relative;
}
.projecao-wrap canvas {
  max-height: 100% !important;
}
.projecao-destaque {
  margin-top: 1rem;
  font-size: 1.1rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  line-height: 1.55;
}
.projecao-destaque .proj-sum-linha {
  display: inline-block;
  min-width: 13rem;
  margin-right: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.projecao-destaque .proj-sum-ver {
  color: rgb(34, 197, 94);
}
.projecao-destaque .proj-sum-amb {
  color: rgb(245, 158, 11);
}
.projecao-destaque .proj-sum-cin {
  color: rgb(148, 163, 184);
}
.card-renda-disponivel {
  margin-bottom: 1.25rem;
}
.card-renda-disponivel h3 {
  margin-top: 0;
}
.renda-auto-resumo {
  display: grid;
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.95rem;
}
.renda-auto-resumo dd {
  margin: 0 0 0.15rem 0;
  font-weight: 500;
}
.renda-auto-resumo dt {
  margin: 0 0 0.35rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.renda-auto-resumo .renda-resumo-linha {
  padding-bottom: 0.75rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.renda-auto-resumo .renda-resumo-linha:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}
.renda-auto-resumo .renda-resumo-muted {
  opacity: 0.82;
}
.form-renda-disponivel .renda-radio-grupo {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0.85rem 0;
  padding: 0;
  border: 0;
}
.form-renda-disponivel .renda-radio {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  cursor: pointer;
}
.form-renda-disponivel .form-hint {
  display: block;
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.badge-manual {
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.2);
  color: var(--text);
}
.simulacao-toolbar.gerenciar-nav-mes,
.simulacao-toolbar .gerenciar-nav-mes {
  align-self: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}
.modal-scale-in {
  animation: modalScaleIn 0.22s ease-out;
}
@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.modal-backdrop-static {
  cursor: default;
}

/* Metas — página e cards */
.page-metas {
  max-width: 100%;
}
.page-metas > .metas-toolbar {
  margin-bottom: 1.25rem;
}
.page-metas > .goals-grid-new {
  margin-bottom: 1.75rem;
}
.page-metas > .card.section-aportes {
  margin-bottom: 2rem;
}

.goals-grid-new {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1.75rem;
  row-gap: 1.75rem;
}
.goal-card.goal-card-rich {
  position: relative;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 1.35rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.goal-header-text {
  flex: 1;
  min-width: 0;
}
.goal-icon-placeholder {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  align-self: flex-start;
}
.goal-header-rich h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.goal-icon-big {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}
.goal-values-line {
  font-weight: 600;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.4;
}
.goal-progress.goal-progress-anim {
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.goal-progress-anim .progress-bar {
  min-width: 0;
  flex: 1 1 140px;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.goal-estimativa {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.goal-notas {
  max-height: 7.5rem;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding-right: 0.35rem;
}
.goal-card-rich .goal-actions {
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.5rem;
  gap: 0.35rem;
}
.goal-quick-add {
  margin-top: 0.25rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.goal-quick-add-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.goal-quick-add-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}
.goal-card-rich .goal-quick-add .goal-quick-add-input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
}
.goal-quick-add-btn {
  flex-shrink: 0;
  align-self: stretch;
  min-width: 2.6rem;
  padding: 0.35rem 0.55rem;
  font-size: 1.15rem;
  line-height: 1;
}

.marker-dot-empty {
  min-height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-dot-empty::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.55;
}

.page-metas .form-metas-fields input[type="text"],
.page-metas .form-metas-fields input[type="number"],
.page-metas .form-metas-fields input[type="date"],
.page-metas .form-metas-fields select,
.page-metas .form-metas-fields textarea,
.modal-box .form-metas-fields input[type="text"],
.modal-box .form-metas-fields input[type="number"],
.modal-box .form-metas-fields input[type="date"],
.modal-box .form-metas-fields select,
.modal-box .form-metas-fields textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.page-metas .form-metas-fields textarea,
.modal-box .form-metas-fields textarea {
  min-height: 88px;
  resize: vertical;
}
.page-metas .form-metas-fields select,
.modal-box .form-metas-fields select {
  cursor: pointer;
}
.page-metas .form-metas-fields input:focus,
.page-metas .form-metas-fields select:focus,
.page-metas .form-metas-fields textarea:focus,
.modal-box .form-metas-fields input:focus,
.modal-box .form-metas-fields select:focus,
.modal-box .form-metas-fields textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.section-timeline-metas .settings-desc {
  overflow-wrap: anywhere;
}

.goal-card-rich:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.1);
}
body:not(.tema-claro) .goal-card-rich:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
}
.goal-card.meta-conquistada {
  opacity: 1;
}
.goal-header-rich {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.goal-progress-anim .progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 4px;
  transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}
.meta-conquistada .progress-fill {
  background: linear-gradient(90deg, var(--success), #4ade80);
}
.badge.badge-cat {
  font-size: 0.72rem;
  margin-top: 0.35rem;
  display: inline-block;
  text-transform: none;
  line-height: 1.3;
}
.cat-patrimonio {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}
.cat-compra {
  background: rgba(168, 85, 247, 0.25);
  color: #d8b4fe;
}
.cat-experiencia {
  background: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}
.cat-investimento {
  background: rgba(34, 197, 94, 0.25);
  color: #86efac;
}
.tema-claro .cat-patrimonio {
  color: #4338ca;
}
.tema-claro .cat-compra {
  color: #7e22ce;
}
.tema-claro .cat-experiencia {
  color: #b45309;
}
.tema-claro .cat-investimento {
  color: #15803d;
}
.confetti-css {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}
.confetti-css::before,
.confetti-css::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: -12px;
  animation: confettiFall 2.2s ease-out infinite;
  border-radius: 1px;
}
.confetti-css::before {
  left: 20%;
  background: #f472b6;
  animation-delay: 0s;
}
.confetti-css::after {
  left: 70%;
  background: #fbbf24;
  animation-delay: 0.35s;
  width: 6px;
  height: 12px;
}
@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120px) rotate(360deg);
    opacity: 0;
  }
}
.goal-notas {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.modal-wide {
  max-width: min(520px, calc(100vw - 2rem));
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 520px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}
.grid-aportes-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}
.aportes-obs {
  grid-column: span 2;
}
@media (max-width: 640px) {
  .aportes-obs {
    grid-column: span 1;
  }
}
.aportes-totais-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.aporte-total-item {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.table-aportes {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-aportes th,
.table-aportes td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.meta-timeline {
  position: relative;
  padding: 3.5rem 0.25rem 4.5rem;
  margin-top: 1rem;
  min-height: 140px;
}
.meta-timeline-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--border);
  border-radius: 2px;
  pointer-events: none;
}
.meta-timeline-now {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
  max-width: min(140px, 28vw);
}
.meta-timeline-now .now-pin {
  color: var(--accent);
  font-size: 0.65rem;
  display: block;
  line-height: 1;
  margin-bottom: 0.15rem;
}
.meta-timeline-now .now-label {
  font-size: 0.7rem;
  color: var(--accent);
  line-height: 1.25;
  display: block;
  white-space: normal;
}
.meta-timeline-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  min-width: 72px;
  max-width: 120px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.meta-timeline-marker .marker-dot {
  font-size: 1.2rem;
  line-height: 1;
}
.meta-timeline-marker .marker-title {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  display: block;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.meta-timeline-marker .marker-val {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.meta-timeline-marker .marker-ano {
  font-size: 0.65rem;
  color: var(--accent);
}

@media (max-width: 700px) {
  .meta-timeline {
    padding: 0 0 0 0;
    margin-top: 1.25rem;
    min-height: 0;
  }
  .meta-timeline-track {
    left: 1.25rem;
    right: auto;
    top: 0;
    bottom: 0;
    width: 4px;
    height: auto;
    margin-top: 0;
    border-radius: 2px;
  }
  .meta-timeline-now,
  .meta-timeline-marker {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    margin-left: 3rem;
    margin-bottom: 1.75rem;
    align-items: flex-start;
    text-align: left;
    max-width: none;
  }
  .meta-timeline-marker .marker-title {
    max-width: none;
  }
}
.metas-nav-quick {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.metas-nav-quick a {
  color: var(--accent);
}

/* Carteira */
.carteira-valor-base {
  margin-bottom: 1.25rem;
  font-size: 1rem;
}
.carteira-valor-base .hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}
.table-carteira .input-inline-cart {
  width: 100%;
  min-width: 120px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}
.table-carteira .input-pct-cart {
  width: 4.5rem;
  padding: 0.35rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}
.carteira-bars-title {
  margin: 1.5rem 0 0.75rem;
}
.carteira-bars-h {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.carteira-bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(120px, 3fr) 48px;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}
.carteira-bar-track {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.carteira-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 5px;
  transition: width 0.35s ease;
}
.carteira-bar-pct {
  text-align: right;
  font-weight: 600;
  font-size: 0.85rem;
}
.insights-content ul.insights-dicas {
  margin: 0 0 1rem 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.insights-content {
  word-wrap: break-word;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.table-wrap .table-aportes,
.table-wrap .table-carteira {
  margin: 0;
}
.table-wrap .table-aportes th,
.table-wrap .table-aportes td {
  white-space: nowrap;
}
.table-wrap .table-aportes td:nth-child(4) {
  white-space: normal;
  max-width: 200px;
}

@media (max-width: 640px) {
  .carteira-bar-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .carteira-bar-track {
    order: 2;
    max-width: 100%;
  }
  .carteira-bar-pct {
    text-align: left;
    order: 3;
  }
}

@media (max-width: 380px) {
  .calendar-grid {
    gap: 1px;
  }
  .cal-day {
    min-height: 52px;
    padding: 0.25rem;
  }
}

/* =============================================
   UI v2 — Tokens visuais, tipografia, elevação
   ============================================= */

/* Ajustes finos para tema claro: backgrounds da app */
body.tema-claro {
  background: var(--bg);
  color: var(--text-1);
}
body.tema-claro .sidebar { background: #ffffff; }
body.tema-claro .topbar { background: #ffffff; border-bottom-color: var(--border); }
body.tema-claro .topbar-search-input {
  background: var(--surface-2);
  color: var(--text-1);
}
body.tema-claro .topbar-search-input:focus { background: #ffffff; }
body.tema-claro .topbar-dropdown { background: #ffffff; }
body.tema-claro .ui-card,
body.tema-claro .card.ui-card,
body.tema-claro .stat-card.ui-card,
body.tema-claro .kpi-card { background: #ffffff; }
body.tema-claro .ui-card--quiet,
body.tema-claro .highlight-card { background: var(--surface-2); }
body.tema-claro .nav-item.active { background: var(--accent-soft); color: var(--accent); }
body.tema-claro .alerta-item { background: rgba(0,0,0,0.025); }
body.tema-claro .ui-empty-state-icon { background: var(--surface-2); }
body.tema-claro .kpi-icon { background: var(--surface-2); color: var(--text-2); }
body.tema-claro .ui-badge--up { background: var(--state-positive-bg); color: var(--state-positive); }
body.tema-claro .ui-badge--down { background: var(--state-negative-bg); color: var(--state-negative); }
body.tema-claro .gastos-recentes-table .valor-cell { color: var(--state-negative); }
body.tema-claro .ui-alert { background: var(--surface-2); }
body.tema-claro .topbar-sidebar-btn:hover,
body.tema-claro .topbar-icon-btn:hover { background: var(--surface-2); }
body.tema-claro .topbar-user-btn:hover { background: var(--surface-2); }
body.tema-claro .topbar-dropdown a:hover { background: var(--surface-2); }
body.tema-claro .sparkline-tick .t-val { color: var(--text-2); }

/* Tooltip da sidebar funciona em claro também */
body.tema-claro[data-sidebar="rail"] .nav-item[data-tooltip]::after {
  background: #1c1c21;
  color: #f4f4f5;
}


/* Página: subtítulo mais legível */
.page-subtitle {
  color: var(--text-2);
  font-weight: 400;
}
.page-header h1 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Cards com elevação (substitui borda por sombra) */
.ui-card,
.card.ui-card,
.stat-card.ui-card {
  background: var(--surface-1);
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.ui-card:hover,
.card.ui-card:hover,
.stat-card.ui-card:hover {
  box-shadow: var(--shadow-card-hover);
}
.ui-card--quiet {
  background: var(--surface-2);
}
.ui-card--inset {
  background: var(--surface-3);
}

/* Tipografia de card padronizada */
.ui-card-label,
.kpi-label {
  display: block;
  font-size: var(--font-size-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-label);
  color: var(--text-3);
}
.ui-card-value,
.kpi-value {
  display: block;
  font-size: var(--font-size-kpi);
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.ui-card-hint,
.kpi-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 0.4rem;
}

/* Cores semânticas — usar com parcimônia (saldo) */
.value-positive { color: var(--state-positive) !important; }
.value-negative { color: var(--state-negative) !important; }
.value-neutral  { color: var(--text-1) !important; }

/* Badges semânticas (variação +/-, status) */
.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.ui-badge--up { background: var(--state-positive-bg); color: var(--state-positive); }
.ui-badge--down { background: var(--state-negative-bg); color: var(--state-negative); }
.ui-badge--flat { background: var(--state-neutral-bg); color: var(--state-neutral); }
.ui-badge--warn { background: var(--state-warning-bg); color: var(--state-warning); }
.ui-badge--info { background: var(--accent-soft); color: var(--accent); }
.ui-badge .arrow {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
}

/* =============================================
   KPI Card v2
   ============================================= */
.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 1.35rem;
  background: var(--surface-1);
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  min-width: 0;
}
.kpi-card.kpi-card--link { cursor: pointer; }
.kpi-card.kpi-card--link:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.kpi-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.kpi-card-body {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.kpi-card-arrow {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  color: var(--text-3);
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.kpi-card.kpi-card--link:hover .kpi-card-arrow {
  opacity: 1;
  transform: translateX(2px);
}
/* Layout em grid para 4 KPIs principais */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 1080px) {
  .kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* =============================================
   Dashboard v2 — Seções, sparkline, donut, destaques, agenda
   ============================================= */
.dash-section { margin-bottom: 1.5rem; }
.dash-section:last-child { margin-bottom: 2rem; }

.dash-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.dash-block-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
}
.dash-block-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

/* Split grid: gráfico à esquerda + visão rápida à direita */
.dash-split-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .dash-split-grid { grid-template-columns: 1fr; }
}

.dash-sparkline-card { padding: 1.25rem 1.5rem 1rem; }
.sparkline-wrap {
  height: 90px;
  position: relative;
  margin: 0.25rem 0 0.5rem;
}
.sparkline-wrap canvas { width: 100% !important; height: 100% !important; }
.sparkline-legend {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.35rem;
}
.sparkline-tick {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
  text-align: center;
}
.sparkline-tick .t-lbl { color: var(--text-3); letter-spacing: 0.02em; }
.sparkline-tick .t-val { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.dash-mini-stats { display: flex; flex-direction: column; }
.mini-stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.mini-stat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border);
}
.mini-stat-list li:last-child { border-bottom: none; }
.mini-stat-label { font-size: 0.82rem; color: var(--text-3); }
.mini-stat-value { font-size: 1rem; font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; }

/* Highlight cards */
.dash-highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.highlight-card {
  position: relative;
  background: var(--surface-2);
  border-radius: var(--radius-card);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
body.tema-claro .highlight-card {
  background: var(--surface-2);
  box-shadow: var(--shadow-card);
}
.highlight-card .kpi-value {
  font-size: 1.4rem;
}
.highlight-meta-titulo {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  font-size: 1.15rem !important;
  line-height: 1.25;
}
.kpi-value-sub {
  font-size: 0.85rem;
  color: var(--text-3);
  font-weight: 500;
  margin-left: 0.25rem;
}
.progress-inline {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.35rem 0 0.25rem;
}
body.tema-claro .progress-inline { background: rgba(0,0,0,0.08); }
.progress-inline > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.4s ease;
}
.kpi-card-arrow--static {
  position: absolute;
  top: 1.1rem;
  right: 1.15rem;
  opacity: 0.6;
  color: var(--text-3);
  text-decoration: none;
}

/* Alertas */
.highlight-card--alertas .alertas-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.alerta-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
}
body.tema-claro .alerta-item { background: rgba(0,0,0,0.025); }
.alerta-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--state-warning-bg);
  color: var(--state-warning);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}
.alerta-danger .alerta-icon { background: var(--state-negative-bg); color: var(--state-negative); }
.alerta-info .alerta-icon { background: var(--accent-soft); color: var(--accent); }
.alerta-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.alerta-titulo { font-size: 0.9rem; font-weight: 600; color: var(--text-1); }
.alerta-desc { font-size: 0.82rem; color: var(--text-2); line-height: 1.4; }

/* Bottom grid: lista de gastos + donut */
.dash-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
}
@media (max-width: 1024px) {
  .dash-bottom-grid { grid-template-columns: 1fr; }
}

/* Tabela de gastos recentes */
.gastos-recentes-card { padding: 1.25rem 1.5rem; }
.gastos-recentes-table-wrap {
  overflow-x: auto;
  margin-top: 0.25rem;
}
.gastos-recentes-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}
.gastos-recentes-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-label);
  color: var(--text-3);
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.gastos-recentes-table td {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px dashed var(--border);
  color: var(--text-1);
}
.gastos-recentes-table tr:last-child td { border-bottom: none; }
.gastos-recentes-table .num,
.gastos-recentes-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.gastos-recentes-table .data-cell {
  color: var(--text-3);
  white-space: nowrap;
  width: 70px;
}
.gastos-recentes-table .desc-cell { color: var(--text-1); }
.gastos-recentes-table .desc-base { font-weight: 500; }
.gastos-recentes-table .desc-sufixo {
  display: block;
  color: var(--text-3);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}
.gastos-recentes-table .valor-cell { font-weight: 600; color: var(--state-negative); }

/* Donut */
.dash-donut-card { padding: 1.25rem 1.5rem; }
.donut-wrap {
  position: relative;
  height: 180px;
  margin: 0.5rem 0 1rem;
}
.donut-wrap canvas { width: 100% !important; height: 100% !important; }
.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.85rem;
}
.donut-legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-2);
}
.donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.donut-swatch-0 { background: #6366f1; }
.donut-swatch-1 { background: #a855f7; }
.donut-swatch-2 { background: #f59e0b; }
.donut-swatch-3 { background: #22c55e; }
.donut-swatch-4 { background: #ef4444; }
.donut-swatch-5 { background: #94a3b8; }
.donut-label { flex: 1; color: var(--text-1); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-value { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Agenda do dia */
.dash-agenda-card { padding: 1.25rem 1.5rem; }
.dash-agenda-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 720px) {
  .dash-agenda-grid { grid-template-columns: 1fr; }
}
.dash-agenda-col-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-label);
  color: var(--text-3);
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.kpi-hint--inline { display: inline; margin: 0; }

/* Alertas inline padronizados */
.ui-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-card);
  margin-bottom: 1rem;
  background: var(--surface-2);
  border-left: 3px solid var(--text-3);
}
.ui-alert-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--state-neutral-bg);
  color: var(--state-neutral);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}
.ui-alert-body { flex: 1; min-width: 0; }
.ui-alert-titulo {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 0.1rem;
}
.ui-alert-msg { font-size: 0.88rem; color: var(--text-2); line-height: 1.4; }
.ui-alert-success { border-left-color: var(--state-positive); }
.ui-alert-success .ui-alert-icon { background: var(--state-positive-bg); color: var(--state-positive); }
.ui-alert-warning { border-left-color: var(--state-warning); }
.ui-alert-warning .ui-alert-icon { background: var(--state-warning-bg); color: var(--state-warning); }
.ui-alert-error { border-left-color: var(--state-negative); }
.ui-alert-error .ui-alert-icon { background: var(--state-negative-bg); color: var(--state-negative); }
.ui-alert-info { border-left-color: var(--accent); }
.ui-alert-info .ui-alert-icon { background: var(--accent-soft); color: var(--accent); }

/* Empty state visual */
.ui-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.ui-empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.ui-empty-state-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
}
.ui-empty-state-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-3);
  max-width: 320px;
}
.ui-empty-state-cta { margin-top: 0.65rem; }

/* Dashboard reorganizado + Finanças (abas extras) + Simulação por mês */
.dashboard-central .dash-atlas-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.dash-atlas-grid .dash-atlas-icon {
  font-size: 1.35rem;
  display: block;
  margin-bottom: 0.35rem;
  opacity: 0.95;
}
.dashboard-kpis-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
  align-items: center;
}
.dash-kpi-pill {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.dash-kpi-pill a {
  color: var(--accent);
}
.analytics-tabs-wrap {
  flex-wrap: wrap;
  gap: 0.25rem;
}
.simulacao-toolbar {
  margin-bottom: 1rem;
}
.simulacao-periodo-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.simulacao-periodo-label {
  margin: 0;
}
.simulacao-acoes-salvar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}
.form-inline-sim-save {
  display: inline;
}

/* Painéis de simulação alinhados, com listas roláveis para não desalinhar */
.simulacao-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.simulacao-pane {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
.simulacao-pane-scroll {
  max-height: 50vh;
  min-height: 80px;
  overflow-y: auto;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  padding: 0.5rem 0;
}
.simulacao-pane-scroll .lista-simulacao { margin: 0; }
.simulacao-pane-scroll::-webkit-scrollbar { width: 8px; }
.simulacao-pane-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* =============================================
   Sidebar rail/expanded + topbar fixa
   ============================================= */

/* Sidebar rail (icon-only, padrão) */
body[data-sidebar="rail"] .sidebar-brand {
  padding: 1rem 0.5rem;
  justify-content: center;
}
body[data-sidebar="rail"] .sidebar-name { display: none; }
body[data-sidebar="rail"] .sidebar-nav { padding: 0.75rem 0.5rem; }
body[data-sidebar="rail"] .nav-item {
  padding: 0.7rem 0;
  justify-content: center;
  position: relative;
}
body[data-sidebar="rail"] .nav-item .nav-label { display: none; }
body[data-sidebar="rail"] .nav-icon { font-size: 1.25rem; }
body[data-sidebar="rail"] .nav-separator {
  font-size: 0;
  padding: 0.35rem 0;
  margin-top: 0.35rem;
  text-align: center;
}
body[data-sidebar="rail"] .nav-separator::before {
  content: '';
  display: block;
  height: 1px;
  width: 60%;
  margin: 0 auto;
  background: var(--border);
}

/* Tooltip ao passar o mouse no rail */
body[data-sidebar="rail"] .nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-3);
  color: var(--text-1);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 200;
  box-shadow: var(--shadow-card);
}
body[data-sidebar="rail"] .nav-item[data-tooltip]:hover::after,
body[data-sidebar="rail"] .nav-item[data-tooltip]:focus-visible::after {
  opacity: 1;
}

body[data-sidebar="expanded"] .sidebar-brand { padding: 1rem 1rem; }
body[data-sidebar="expanded"] .sidebar-nav { padding: 0.75rem 0.65rem; }

/* Active estado mais nítido */
.sidebar .nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
body[data-sidebar="rail"] .nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* =============================================
   Topbar fixa
   ============================================= */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-current, var(--sidebar-w));
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  z-index: 90;
  transition: left 0.2s ease;
}
.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.topbar-left { flex: 1 1 0; min-width: 0; }
.topbar-center {
  flex: 0 1 auto;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-3);
}
.topbar-greeting { color: var(--text-2); }
.topbar-greeting strong { color: var(--text-1); font-weight: 600; }
.topbar-date::before { content: '·'; margin: 0 0.4rem; color: var(--text-3); }
.topbar-right { flex: 1 1 0; justify-content: flex-end; }

.topbar-sidebar-btn,
.topbar-icon-btn,
.topbar-user-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.topbar-sidebar-btn,
.topbar-icon-btn {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}
.topbar-sidebar-btn:hover,
.topbar-icon-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.topbar-sidebar-btn .icon-bars {
  display: block;
  width: 16px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  position: relative;
}
.topbar-sidebar-btn .icon-bars::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%);
}

.topbar-search {
  flex: 1 1 auto;
  max-width: 380px;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search-icon {
  position: absolute;
  left: 0.65rem;
  color: var(--text-3);
  font-size: 0.95rem;
  pointer-events: none;
}
.topbar-search-input {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-1);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 2.5rem 0.5rem 2rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.topbar-search-input::placeholder { color: var(--text-3); }
.topbar-search-input:focus {
  background: var(--bg);
  border-color: var(--accent);
}
.topbar-search-kbd {
  position: absolute;
  right: 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--text-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}

.topbar-user-btn {
  padding: 0.3rem 0.55rem 0.3rem 0.35rem;
  gap: 0.45rem;
  height: 38px;
}
.topbar-user-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.topbar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.topbar-user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-1);
}
.topbar-user-caret { font-size: 0.6rem; color: var(--text-3); }

.topbar-menu { position: relative; }
.topbar-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 200px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
  padding: 0.35rem;
  z-index: 110;
  display: flex;
  flex-direction: column;
}
.topbar-dropdown[hidden] { display: none; }
.topbar-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  color: var(--text-1);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.topbar-dropdown a:hover {
  background: var(--surface-3);
  color: var(--text-1);
  text-decoration: none;
}
.topbar-dropdown-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-label);
  padding: 0.55rem 0.75rem 0.35rem;
}
.topbar-dropdown-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0 0.75rem 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}
.topbar-dropdown-icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.topbar-dropdown-danger { color: var(--state-negative) !important; }
.topbar-dropdown-danger:hover { background: var(--state-negative-bg) !important; }
.topbar-dropdown--user { min-width: 220px; }

/* Page loading bar */
.page-loading-bar {
  position: fixed;
  top: var(--topbar-h);
  left: var(--sidebar-current, var(--sidebar-w));
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
  transition: left 0.2s ease;
}
.page-loading-bar::before {
  content: '';
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  width: 30%;
  transform: translateX(-100%);
}
.page-loading-bar.active::before {
  animation: pageLoadingBar 1.2s ease-in-out infinite;
}
.page-loading-bar.done::before {
  animation: none;
  transform: translateX(101%);
  transition: transform 0.3s ease;
}
@keyframes pageLoadingBar {
  0% { transform: translateX(-100%); width: 30%; }
  50% { transform: translateX(40%); width: 50%; }
  100% { transform: translateX(220%); width: 30%; }
}

/* Responsivo topbar/sidebar */
@media (max-width: 900px) {
  .topbar {
    left: 0;
    padding-left: 4rem;
  }
  .topbar-center { display: none; }
  .topbar-search { max-width: none; }
  .topbar-user-name { display: none; }
  .page-loading-bar { left: 0; }
}
@media (max-width: 640px) {
  .topbar-search-kbd { display: none; }
  .topbar-sidebar-btn { display: none; }
}

