/* ============================================================
   KITADI — Design System (premium fintech, PT-AO)
   ============================================================ */
@font-face {
  font-family: 'Inter';
  src: url('../assets/vendor/inter-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}

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

:root {
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(8, 40, 28, .04), 0 8px 24px -6px rgba(8, 40, 28, .10);
  --shadow-lg: 0 2px 6px rgba(8, 40, 28, .06), 0 20px 48px -12px rgba(8, 40, 28, .22);
  --ease-spring: cubic-bezier(.34, 1.4, .44, 1);
  --sidebar-w: 264px;

  /* Light theme — esmeralda (dinheiro) + dourado (kwanza) */
  --bg: #F1F7F3;
  --surface: #FFFFFF;
  --surface-2: #F4FAF6;
  --text: #12241B;
  --text-2: #5C7267;
  --border: #DFEDE4;
  --primary: #047857;
  --primary-2: #10B981;
  --primary-soft: #D9F2E6;
  --success: #0E9F6E;
  --success-soft: #E1F5EC;
  --danger: #E02D3C;
  --danger-soft: #FDE8EA;
  --warning: #B45309;
  --warning-soft: #FEF3D8;
  --info: #1D4ED8;
  --info-soft: #E3EBFD;
  --gold: #F5B841;
  --chart-grid: #E6F1EA;
}

[data-theme="dark"] {
  --bg: #08120D;
  --surface: #0F1F18;
  --surface-2: #152A20;
  --text: #ECF7F0;
  --text-2: #93AC9E;
  --border: #1F3A2C;
  --primary: #34D399;
  --primary-2: #10B981;
  --primary-soft: #123B2E;
  --success: #34D399;
  --success-soft: #123B2E;
  --danger: #F87171;
  --danger-soft: #43181D;
  --warning: #FBBF24;
  --warning-soft: #3D2E0D;
  --info: #93B4F8;
  --info-soft: #172448;
  --gold: #F5B841;
  --chart-grid: #1C3629;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 28px -8px rgba(0, 0, 0, .45);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 24px 56px -12px rgba(0, 0, 0, .6);
}

::selection { background: var(--primary-soft); color: var(--primary); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

#app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .28s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff; font-weight: 800; font-size: 1.4rem;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(5, 150, 105, .35);
}
.brand-text strong { font-size: 1.15rem; display: block; letter-spacing: -.02em; }
.brand-text span { font-size: .72rem; color: var(--text-2); }

.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 14px; margin-bottom: 2px;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 500;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item { position: relative; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.sidebar .nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 20%; bottom: 20%;
  width: 4px; border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
}
.nav-item .ico { font-size: 1.15rem; width: 24px; text-align: center; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip strong { display: block; font-size: .9rem; }
.user-chip span { font-size: .74rem; color: var(--text-2); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #E8912D);
  color: #3A2503; font-weight: 800; display: grid; place-items: center;
  overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.5rem; border: 2px solid rgba(255,255,255,.5); }
.avatar-btn { position: relative; cursor: pointer; border: 2px solid rgba(255,255,255,.5); padding: 0; }
.btn-sair { background: #E02D3C; color: #fff; box-shadow: 0 4px 12px rgba(224, 45, 60, .4); }
.btn-sair:hover { background: #C81E2C; }
.btn-exit { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.sidebar-footer { display: flex; align-items: center; gap: 6px; }
.sidebar-footer .user-chip { flex: 1; min-width: 0; }
.btn-exit {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  font-size: 1.05rem; display: grid; place-items: center;
}
.btn-exit:hover { background: var(--danger-soft); color: var(--danger); }

/* ===== Main ===== */
.main-wrap { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.35rem; letter-spacing: -.02em; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.points-badge {
  background: var(--warning-soft); color: var(--warning);
  font-weight: 700; font-size: .85rem; padding: 6px 12px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.sync-badge {
  font-size: 1rem; width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 50%;
  transition: opacity .3s;
  opacity: .7;
  cursor: default;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 1.1rem; color: var(--text);
  display: grid; place-items: center;
  transition: transform .12s;
}
.icon-btn:hover { transform: translateY(-1px); }

.view { padding: 8px 28px 96px; max-width: 1240px; width: 100%; margin: 0 auto; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ===== Buttons ===== */
.btn {
  border: none; border-radius: 12px; padding: 10px 18px;
  font-weight: 700; font-size: .92rem;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff; box-shadow: 0 6px 16px rgba(5, 150, 105, .3);
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform .5s ease;
}
.btn-primary:hover::after { transform: translateX(120%); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 9px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Cards / grids ===== */
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .22s var(--ease-spring), box-shadow .22s, border-color .22s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* entrada em cascata dos blocos de cada ecrã */
.view > * { animation: rise .45s var(--ease-spring) backwards; }
.view > *:nth-child(2) { animation-delay: .06s; }
.view > *:nth-child(3) { animation-delay: .12s; }
.view > *:nth-child(4) { animation-delay: .18s; }
.view > *:nth-child(n+5) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; } }
.card h3 { font-size: 1rem; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 .muted { font-weight: 500; }

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: .8rem; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value {
  font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-sub { font-size: .78rem; color: var(--text-2); margin-top: 4px; }
.kpi-hero {
  background: linear-gradient(120deg, #059669, #047857 55%, #064E3B 90%, #10B981);
  background-size: 220% 220%;
  animation: hero-shift 14s ease-in-out 2;   /* 2 ciclos: efeito vivo sem gastar bateria */
  color: #fff; border: none;
}
.kpi-hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(420px 180px at 88% -20%, rgba(255,255,255,.22), transparent 65%);
  pointer-events: none;
}
@keyframes hero-shift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: rgba(255,255,255,.78); }
.tx-amount, .tbl td { font-variant-numeric: tabular-nums; }

/* chip de tendência (↑/↓ vs mês anterior) */
.delta-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 800; white-space: nowrap;
}
.delta-chip.up { background: var(--success-soft); color: var(--success); }
.delta-chip.down { background: var(--danger-soft); color: var(--danger); }
.kpi-hero .delta-chip.up { background: rgba(255,255,255,.18); color: #fff; }

/* logótipo SVG dentro do quadrado da marca */
.brand-logo svg { width: 68%; height: 68%; display: block; }

.muted { color: var(--text-2); font-size: .84rem; }
.pos { color: var(--success); }
.neg { color: var(--danger); }

/* ===== Progress ===== */
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > div {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  transition: width .5s ease;
}
.progress.green > div { background: linear-gradient(90deg, #34D399, #0E9F6E); }
.progress.gold > div { background: linear-gradient(90deg, #FCD34D, #E8912D); }

/* ===== Lists / table ===== */
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 6px; border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-ico {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--surface-2);
}
.tx-body { flex: 1; min-width: 0; }
.tx-body strong { display: block; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { display: block; font-size: .77rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta .chip { vertical-align: middle; }
.tx-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tx-amount { font-weight: 800; font-size: .95rem; white-space: nowrap; }
.tx-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tx-row:hover .tx-actions { opacity: 1; }
@media (hover: none) { .tx-actions { opacity: 1; } }
.tx-right .chip { flex-shrink: 0; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
}
.chip.green { background: var(--success-soft); color: var(--success); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.violet { background: var(--primary-soft); color: var(--primary); }
.chip.amber { background: var(--warning-soft); color: var(--warning); }
.chip.blue { background: var(--info-soft); color: var(--info); }

/* ===== Filters bar ===== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.filters input[type="search"], .filters select, .filters input[type="month"] {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 9px 14px; font-size: .9rem;
}
.filters input[type="search"] { flex: 1; min-width: 180px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 10px 13px; font-size: .95rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary-2); border-color: transparent;
}
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--text-2);
  padding: 8px 6px; border-radius: 9px; font-weight: 700; font-size: .85rem;
}
.seg button.active.receita { background: var(--success-soft); color: var(--success); }
.seg button.active.despesa { background: var(--danger-soft); color: var(--danger); }
.seg button.active.investimento { background: var(--primary-soft); color: var(--primary); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 5, 25, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  padding: 24px; animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; } }
.modal h2 { font-size: 1.15rem; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== Dock (mobile) — adaptado do DockTabs do 21st.dev ===== */
.bottom-nav {
  display: none;
  position: fixed; bottom: calc(10px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 8px 10px;
  gap: 4px;
  align-items: flex-end;
  animation: dock-in .5s var(--ease-spring) backwards;
}
@keyframes dock-in { from { transform: translateX(-50%) translateY(90px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.bottom-nav .nav-item {
  position: relative;
  width: 48px; height: 48px; padding: 0; margin: 0;
  border-radius: 15px;
  display: grid; place-items: center;
  transform: translateY(var(--lift, 0px)) scale(var(--mag, 1));
  transform-origin: bottom center;
  transition: transform .18s var(--ease-spring), background .18s, box-shadow .18s;
}
.bottom-nav .nav-item .ico { font-size: 1.45rem; width: auto; }
.bottom-nav .nav-item:hover { background: var(--surface-2); }
.bottom-nav .nav-item:active { transform: translateY(2px) scale(.92); }
.bottom-nav .nav-item.active {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: 0 6px 14px rgba(5, 150, 105, .35);
}
.bottom-nav .nav-item.active .ico { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .3)); }
.dock-label {
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%) translateY(6px) scale(.85);
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  font-size: .68rem; font-weight: 700; padding: 4px 10px; border-radius: 8px;
  opacity: 0; pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(6px);
  transition: opacity .18s, transform .18s var(--ease-spring);
}
.bottom-nav .nav-item:hover .dock-label { opacity: 1; transform: translateX(-50%) scale(1); }
.dock-dot {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: #fff; opacity: 0; transition: opacity .2s;
}
.bottom-nav .nav-item.active .dock-dot { opacity: .95; }
.fab {
  position: fixed; right: 18px; z-index: 55;
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  border: none; padding: 0; color: #fff;
  display: grid; place-items: center;      /* + sempre centrado na bola */
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: 0 8px 24px rgba(5, 150, 105, .45);
  transition: transform .15s var(--ease-spring);
}
.fab:active { transform: scale(.92); }
.fab svg { display: block; }
.only-mobile { display: none; }

/* ===== Toasts ===== */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: slidein .25s ease;
  max-width: 320px;
}
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; } }

/* ===== Challenge grid ===== */
.challenge-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.day-cell {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: .7rem;
  cursor: pointer; transition: transform .12s;
  color: var(--text-2);
}
.day-cell strong { font-size: .82rem; color: var(--text); }
.day-cell:hover { transform: scale(1.05); }
.day-cell.done {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  border-color: transparent; color: rgba(255,255,255,.8);
}
.day-cell.done strong { color: #fff; }

/* ===== Assistant chat ===== */
.chat-box { display: flex; flex-direction: column; height: 480px; }
.chat-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.msg { max-width: 84%; padding: 11px 15px; border-radius: 16px; font-size: .9rem; white-space: pre-wrap; }
.msg.bot { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.typing-dots { display: inline-flex; gap: 5px; padding: 3px 2px; }
.typing-dots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-2);
  animation: tdot 1.2s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes tdot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.msg.user { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input input { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 12px; padding: 11px 14px; }
.suggest-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest-chips button {
  background: var(--primary-soft); color: var(--primary); border: none;
  border-radius: 999px; padding: 6px 12px; font-size: .78rem; font-weight: 600;
}

/* ===== Insight cards ===== */
.insight {
  display: flex; gap: 12px; padding: 13px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 10px;
  font-size: .88rem;
}
.insight .ico { font-size: 1.3rem; }

/* ===== Medals ===== */
.medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.medal {
  text-align: center; padding: 16px 8px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.medal .ico { font-size: 2rem; display: block; margin-bottom: 6px; }
.medal.locked { opacity: .35; filter: grayscale(1); }
.medal strong { font-size: .78rem; display: block; }
.medal span { font-size: .68rem; color: var(--text-2); }

/* ===== Education ===== */
.lesson { cursor: pointer; }
.lesson .tag { font-size: .68rem; }
.lesson h4 { margin: 8px 0 4px; font-size: .95rem; }
.lesson p { font-size: .82rem; color: var(--text-2); }

/* ===== Charts ===== */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall { height: 320px; }

/* ===== Tables ===== */
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; color: var(--text-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }

/* ===== Section headers ===== */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 1.12rem; letter-spacing: -.01em; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty .ico { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* ===== Ecrã inicial (login) ===== */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(16, 185, 129, .30), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(245, 184, 65, .18), transparent 55%),
    linear-gradient(160deg, #06130E 20%, #0C271C 70%, #0E4D36);
  overflow: hidden auto;
}
.auth-screen::before, .auth-screen::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(70px);
  pointer-events: none; z-index: 0;
}
.auth-screen::before {
  width: 420px; height: 420px; top: -120px; right: -100px;
  background: rgba(16, 185, 129, .34);
  animation: blob-a 16s ease-in-out 2;
}
.auth-screen::after {
  width: 360px; height: 360px; bottom: -140px; left: -90px;
  background: rgba(245, 184, 65, .22);
  animation: blob-b 19s ease-in-out 2;
}
@keyframes blob-a { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-60px, 50px) scale(1.15); } }
@keyframes blob-b { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(70px, -40px) scale(1.1); } }
.auth-card { position: relative; z-index: 1; }
.auth-card {
  width: 100%; max-width: 430px;
  background: var(--surface); border-radius: 26px;
  padding: 30px 28px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
  animation: pop .3s ease;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.auth-brand .brand-logo { width: 54px; height: 54px; font-size: 1.7rem; border-radius: 17px; }
.auth-brand strong { font-size: 1.6rem; letter-spacing: -.03em; display: block; line-height: 1.1; }
.auth-brand span { font-size: .82rem; color: var(--text-2); }
.auth-feats { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 20px; }
.auth-feats span {
  font-size: .72rem; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px; padding: 5px 11px;
}
.auth-card .field { margin-bottom: 12px; }
.auth-alt { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--text-2); font-size: .78rem; }
.auth-alt::before, .auth-alt::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-local {
  width: 100%; background: transparent; border: none; color: var(--text-2);
  font-size: .88rem; font-weight: 600; padding: 10px; border-radius: 10px;
}
.auth-local:hover { color: var(--text); background: var(--surface-2); }
.auth-demo { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-2); margin-top: 6px; justify-content: center; }
.auth-demo input { width: 16px; height: 16px; accent-color: var(--primary); }
.auth-msg { font-size: .82rem; margin-top: 10px; color: var(--text-2); text-align: center; min-height: 1.2em; }
.btn-google {
  width: 100%; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-weight: 700;
}
.btn-google .g { font-weight: 800; background: linear-gradient(90deg, #4285F4, #EA4335, #FBBC05, #34A853); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 1.05rem; }
.auth-forgot { display: block; text-align: center; margin-top: 10px; background: none; border: none; color: var(--primary); font-size: .82rem; font-weight: 600; width: 100%; }

/* ===== Onboarding ===== */
.ob-card { max-width: 520px; }
.ob-progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.ob-progress > div { height: 100%; background: linear-gradient(90deg, var(--primary-2), var(--primary)); border-radius: 999px; transition: width .4s ease; }
.ob-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; }
.ob-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-chip {
  border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: .84rem; font-weight: 600;
  transition: all .15s;
}
.ob-chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.form-grid .auth-demo.full { grid-column: 1 / -1; }

/* ===== Drawer / responsive ===== */
.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(10,5,25,.5); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .bottom-nav { display: flex; justify-content: center; }
  .only-mobile { display: grid; }
  .btn-fab-desktop { display: none; }
  .view { padding: 4px 16px calc(120px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .challenge-grid { grid-template-columns: repeat(5, 1fr); }
  .chat-box { height: 420px; }

  /* Linhas de lançamento em telas estreitas: valor por cima, ações compactas */
  .tx-row { gap: 10px; padding: 12px 2px; }
  .tx-ico { width: 38px; height: 38px; font-size: 1.1rem; }
  .tx-right { flex-direction: column; align-items: flex-end; gap: 4px; }
  .tx-actions { opacity: 1; }
  .tx-actions .btn-sm { padding: 5px 8px; }

  /* Filtros: cada controlo ocupa a largura toda e o campo de mês ganha rótulo */
  .filters { gap: 8px; }
  .filters input[type="search"], .filters select, .filters input[type="month"] { width: 100%; flex: 1 1 100%; min-width: 0; }
  .filters .btn { flex: 1; justify-content: center; }
  .filters .field-month { flex: 1 1 100%; }
}

/* Filtro de mês com rótulo (evita a "caixa vazia" no iOS quando sem mês escolhido) */
.filters .field-month {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 8px 0 12px; min-width: 150px;
}
.filters .field-month span { font-size: .9rem; color: var(--text-2); white-space: nowrap; }
.filters .field-month input[type="month"] { border: none; background: transparent; padding: 9px 4px; flex: 1; min-width: 0; }

@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .filters, .tx-actions, .btn { display: none !important; }
  .main-wrap { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
