/* =========================================================
   Estrutura e ecrãs
   ========================================================= */

/* ----- Ecrã de carregamento ----- */
.splash{ position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; background: var(--bg); transition: opacity .35s var(--ease), visibility .35s; }
html.booting .splash, .splash.leaving{ display: grid; }
.splash.leaving{ opacity: 0; visibility: hidden; }
html.booting .auth, html.booting .shell{ display: none !important; }
.splash-inner{ display: flex; flex-direction: column; align-items: center; gap: 18px; }
.splash .logo{ width: 52px; height: 52px; color: var(--sage-dark); animation: breathe 1.6s var(--ease) infinite; }
.splash-name{ font-family: var(--serif); font-size: 34px; line-height: 1; }
.splash-bar{ width: 120px; height: 3px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.splash-bar i{ display: block; width: 40%; height: 100%; border-radius: var(--r-pill); background: var(--sage); animation: slide 1.1s var(--ease) infinite; }
@keyframes breathe{ 50%{ transform: scale(.92); opacity: .75; } }
@keyframes slide{ from{ transform: translateX(-100%); } to{ transform: translateX(250%); } }

/* ----- Entrar ----- */
.auth{ min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art{
  position: relative; overflow: hidden; color: #EAF0EA; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: radial-gradient(120% 90% at 0% 0%, #496252 0%, transparent 60%), radial-gradient(90% 80% at 100% 100%, #1A241D 0%, transparent 70%), linear-gradient(160deg, #34473A, #1C261F);
}
.brand{ display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo{ width: 30px; height: 30px; color: var(--sage-dark); flex: 0 0 auto; }
.auth-art .logo{ color: #C9DCCD; }
.auth-art .logo-stroke{ stroke: #1C261F; }
.auth-art h1{ font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 5vw, 72px); line-height: 1; letter-spacing: -.02em; max-width: 11ch; }
.auth-art h1 em{ color: #A9C6B0; }
.auth-art p{ max-width: 38ch; color: rgba(234,240,234,.75); font-size: 15px; margin: 18px 0 0; }
.auth-side{ display: grid; place-items: center; padding: 32px 24px; }
.auth-card{ width: 100%; max-width: 360px; }
.auth-card h2{ font-family: var(--serif); font-weight: 400; font-size: 40px; margin: 0 0 6px; line-height: 1.05; }
.auth-card .lead{ color: var(--ink-2); margin: 0 0 26px; }
.auth-toggle{ font-size: 13px; color: var(--ink-2); margin-top: 20px; text-align: center; }
.auth-toggle button{ background: none; border: none; color: var(--ink); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }
.auth-message{ font-size: 13px; min-height: 18px; margin: 14px 0 0; color: var(--expense); text-align: center; }
.auth-message.success{ color: var(--income); }

/* ----- Estrutura ----- */
.shell{ min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0,1fr); }
.side{ position: sticky; top: 0; height: 100dvh; padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); }
.side .brand{ padding: 4px 10px 18px; }
.nav{ display: flex; flex-direction: column; gap: 2px; }
.nav-item{
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 12px; border: none; background: none;
  color: var(--ink-2); font-size: 14px; font-weight: 500; cursor: pointer; text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover{ background: var(--surface-3); color: var(--ink); }
.nav-item.active{ background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.nav-item.active svg.i{ color: var(--sage-dark); }
.nav-item .kbd{ margin-left: auto; opacity: 0; transition: opacity var(--t-fast); }
.side:hover .nav-item .kbd{ opacity: 1; }
.side-cta{ margin: 16px 0 0; }
.side-spacer{ flex: 1; }
.side-foot{ display: flex; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.me{ display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: none; background: none; padding: 6px; border-radius: 12px; cursor: pointer; text-align: left; }
.me:hover{ background: var(--surface-3); }
.me .who{ min-width: 0; display: flex; flex-direction: column; }
.me .who b{ font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small{ font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main{ min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 64px; max-width: 1180px; width: 100%; }
.topbar{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar-text{ min-width: 0; }
.eyebrow{ font-size: 13px; color: var(--ink-3); margin: 0 0 2px; font-weight: 500; }
.eyebrow::first-letter{ text-transform: uppercase; }
.topbar h1{ font-family: var(--serif); font-weight: 400; font-size: var(--fs-title); line-height: 1.04; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar h1 em{ color: var(--sage-dark); }
.top-actions{ display: flex; align-items: center; gap: 8px; }
.mobile-only{ display: none !important; }
.offline{ display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.offline span{ flex: 1; }
.page{ animation: pageIn .3s var(--ease); }
@keyframes pageIn{ from{ opacity: 0; transform: translateY(6px); } }
.back-btn{ margin-bottom: 16px; }

.tabbar{ display: none; }
.fab{ display: none; }

/* ----- Herói (número principal) ----- */
.hero, .acc-hero{
  position: relative; overflow: hidden; border-radius: var(--r-2xl); padding: 24px 26px 18px; color: var(--on-hero);
  background: radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--hero-a) 70%, #6E8B76) 0%, transparent 55%), linear-gradient(155deg, var(--hero-a), var(--hero-b));
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.acc-hero{ background: linear-gradient(150deg, var(--a1), var(--a2)); box-shadow: 0 18px 40px -22px var(--a2); }
.hero::before, .acc-hero::before{
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 20px 20px;
  mask-image: radial-gradient(70% 70% at 85% 10%, #000, transparent); -webkit-mask-image: radial-gradient(70% 70% at 85% 10%, #000, transparent);
}
.hero > *, .acc-hero > *{ position: relative; }
.hero-top{ display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hero-label{ font-size: 13.5px; color: var(--on-hero-2); display: inline-flex; align-items: center; gap: 6px; }
.hero-label svg.i{ width: 15px; height: 15px; opacity: .8; }
.hero-value{ font-family: var(--serif); font-size: var(--fs-num); line-height: 1; letter-spacing: -.02em; margin: 10px 0 8px; display: block; }
.hero-value.sm{ font-size: clamp(30px, 3.6vw, 42px); }
.hero-value .cents{ font-family: var(--serif); opacity: .55; }
.hero-value.negative{ color: #FFC6B3; }
.hero-meta{ font-size: 13px; color: var(--on-hero-2); display: block; }
.hero-hit{ background: none; border: none; color: inherit; text-align: left; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 0; border-radius: 12px; }
.hero-hit .btn{ margin-top: 16px; }
.hero-hit:hover .hero-label{ color: #fff; }
.hero-chart{ margin-top: 18px; }
.hero-actions{ display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hero-actions .btn{ background: rgba(255,255,255,.14); color: #fff; height: 38px; }
.hero-actions .btn:hover{ background: #fff; color: #1C1E1B; }
.quick{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; max-width: 460px; }
.qa{ display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 14px; border: none; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; font-size: 13.5px; font-weight: 600; transition: background var(--t-fast) var(--ease); }
.qa:hover{ background: rgba(255,255,255,.2); }
.qa .ic{ display: grid; place-items: center; }
.qa .ic svg.i{ width: 17px; height: 17px; stroke-width: 2.2; }
.qa.expense .ic{ color: #F5B9A3; } .qa.income .ic{ color: #A9DDB5; } .qa.savings .ic{ color: #B9CDE3; }

.grid-2{ display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; margin-top: 16px; align-items: start; }
.grid-2 > .card{ margin: 0; }

/* ----- Linha de destaque (ecrãs com lista) ----- */
.headline{ display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; margin: 4px 2px 18px; }
.headline-label{ margin: 0; font-size: 13px; color: var(--ink-3); font-weight: 500; }
.headline-value{ margin: 2px 0 0; font-family: var(--serif); font-size: clamp(40px, 4.6vw, 56px); line-height: 1; letter-spacing: -.02em; }
.headline-value .cents{ font-family: var(--serif); }
.headline-side{ margin: 0; font-size: 13px; color: var(--ink-3); max-width: 52ch; }
.headline-side b{ color: var(--ink-2); font-weight: 600; }
.headline-side.wide{ display: flex; flex-direction: column; gap: 6px; min-width: 220px; flex: 0 1 320px; }

.toolbar{ display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.month-nav{ display: flex; align-items: center; gap: 4px; background: var(--surface); border-radius: var(--r-pill); padding: 4px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.month-nav .lbl{ min-width: 140px; text-align: center; font-weight: 600; font-size: 14px; }
.month-nav .icon-btn{ width: 32px; height: 32px; }
.search{ position: relative; display: flex; align-items: center; }
.search > svg.i{ position: absolute; left: 12px; color: var(--ink-3); width: 16px; height: 16px; pointer-events: none; }
.search .kbd{ position: absolute; right: 12px; pointer-events: none; }
.search input{ height: 40px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); padding: 0 34px 0 36px; font-size: 14px; width: 240px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.search input:focus{ outline: none; border-color: var(--sage); box-shadow: var(--ring); }
.search.sm input{ height: 36px; width: 220px; }
.list-card{ padding: 10px 12px 12px; }

/* ----- O que vem aí ----- */
.up-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.up-item{ display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 8px; border-radius: 16px; background: var(--surface-2); }
.up-item.urgent{ background: color-mix(in srgb, var(--expense-soft) 75%, var(--surface)); }
.up-date{ width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.up-date b{ font-size: 16px; font-weight: 700; }
.up-date span{ font-size: 10.5px; color: var(--ink-3); font-weight: 600; margin-top: 3px; text-transform: lowercase; }
.up-date.plan{ color: var(--savings); }
.up-item.urgent .up-date{ background: var(--expense); color: #fff; }
.up-item.urgent .up-date span{ color: rgba(255,255,255,.85); }
[data-theme="dark"] .up-item.urgent .up-date{ color: #1a0f0a; }
[data-theme="dark"] .up-item.urgent .up-date span{ color: rgba(26,15,10,.75); }
.up-main{ min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.up-main b{ font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-main small{ font-size: 12px; color: var(--ink-3); }
.up-item.urgent .up-main small{ color: var(--expense); font-weight: 600; }

/* ----- Gastos por categoria ----- */
.spend-total{ margin: -4px 0 12px; font-size: 13px; color: var(--ink-3); }
.spend-total b{ color: var(--ink); font-size: 15px; }
.cat-list{ display: flex; flex-direction: column; gap: 2px; }
.cat-row{ display: grid; grid-template-columns: 30px minmax(0,1fr) auto; gap: 4px 12px; align-items: center; padding: 9px 6px; border-radius: 12px; cursor: pointer; border: none; background: none; text-align: left; width: 100%; }
.cat-row:hover{ background: var(--surface-2); }
.cat-sw{ width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; grid-row: span 2; }
.cat-mid{ min-width: 0; display: flex; flex-direction: column; }
.cat-row .nm{ font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .meta{ font-size: 11.5px; color: var(--ink-3); }
.cat-row.warn .meta{ color: var(--warn); font-weight: 600; }
.cat-row.over .meta{ color: var(--expense); font-weight: 600; }
.cat-row .val{ font-weight: 600; font-size: 14px; text-align: right; }
.cat-row .bar{ grid-column: 2 / -1; height: 5px; }

/* ----- Como foi calculado ----- */
.calc-lines{ margin: 0; border-radius: 14px; background: var(--surface-2); padding: 2px 14px; }
.calc-lines div{ display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; }
.calc-lines div + div{ border-top: 1px solid var(--line); }
.calc-lines dt{ display: flex; flex-direction: column; font-size: 14px; }
.calc-lines dt small{ color: var(--ink-3); font-size: 12px; }
.calc-lines dd{ margin: 0; font-weight: 600; font-size: 15px; }
.calc-lines .total dt{ font-weight: 700; }
.calc-lines .total dd{ font-family: var(--serif); font-weight: 400; font-size: 26px; }

/* ----- Plano do mês ----- */
.plan-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.plan-item{ display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px; align-items: center; }
.plan-name{ min-width: 0; display: flex; flex-direction: column; }
.plan-name b{ font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-name small{ font-size: 12px; color: var(--ink-3); }
.plan-item .bar{ grid-column: 1 / -1; }
.plan-add{ border: none; background: var(--sage-soft); color: var(--sage-dark); font-weight: 600; font-size: 12.5px; height: 32px; padding: 0 12px; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap; }
.plan-add:hover{ background: var(--sage-dark); color: #fff; }
.plan-add:disabled{ opacity: .5; }
.plan-done{ color: var(--income); font-weight: 700; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.plan-done svg.i{ width: 14px; height: 14px; stroke-width: 2.4; }
.plan-total{ display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); gap: 10px; }
.plan-total small{ color: var(--ink-3); font-size: 12px; display: block; }
.plan-total b{ font-size: 17px; }
.plan-strip{ display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 16px; border: none; background: var(--savings-soft); color: var(--savings); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; margin-bottom: 14px; }
.plan-strip span{ flex: 1; }
.plan-strip b{ font-weight: 700; }
.plan-strip.ok{ background: var(--income-soft); color: var(--income); cursor: default; }

/* ----- Contas ----- */
.acc-list{ padding: 6px; }
.acc-row{ display: grid; grid-template-columns: 10px minmax(0,1fr) 84px auto 16px; gap: 14px; align-items: center; width: 100%; padding: 14px 12px; border: none; background: none; border-radius: 14px; cursor: pointer; text-align: left; color: inherit; }
.acc-row:hover{ background: var(--surface-2); }
.acc-sw{ width: 10px; height: 36px; border-radius: 4px; }
.acc-mid{ min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.acc-mid b{ font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-mid small{ font-size: 12px; color: var(--ink-3); }
.acc-spark{ opacity: .9; }
.acc-bal{ font-weight: 600; font-size: 15.5px; text-align: right; white-space: nowrap; }
.chev-r{ width: 16px !important; height: 16px !important; color: var(--ink-3); opacity: .6; }
.row-new{ display: flex; align-items: center; gap: 8px; width: 100%; padding: 14px 12px; border: none; background: none; color: var(--ink-3); font-weight: 600; font-size: 13.5px; cursor: pointer; border-radius: 14px; }
.row-new:hover{ color: var(--sage-dark); background: var(--surface-2); }
.row-new svg.i{ width: 16px; height: 16px; }
.detail-head{ display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); gap: 16px; align-items: start; }
.detail-side{ display: grid; gap: 16px; }
.detail-side > .card + .card{ margin: 0; }
.row-actions{ display: flex; gap: 2px; }
.inout{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inout > div{ background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.inout small{ display: block; font-size: 12px; color: var(--ink-3); }
.inout b{ font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.iban-line{ display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 8px; }
.iban-line small{ display: block; font-size: 12px; color: var(--ink-3); }
.iban-line code{ font-family: var(--font); font-size: 13.5px; font-weight: 600; letter-spacing: .04em; word-break: break-all; }
.alloc-bar{ display: flex; height: 10px; border-radius: var(--r-pill); overflow: hidden; gap: 3px; margin: 0 0 10px; background: var(--surface-3); }
.alloc-bar span{ height: 100%; border-radius: var(--r-pill); min-width: 4px; }
.alloc-row{ display: grid; grid-template-columns: 10px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 9px 4px; font-size: 13.5px; width: 100%; border: none; background: none; text-align: left; cursor: pointer; color: inherit; border-radius: 8px; }
button.alloc-row:hover{ background: var(--surface-2); }
.alloc-row + .alloc-row{ border-top: 1px dashed var(--line); }
.alloc-row i{ width: 10px; height: 10px; border-radius: 3px; }
.alloc-row .nm{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.alloc-row .nm small{ color: var(--ink-3); font-weight: 400; }
.alloc-row b{ font-weight: 600; }
.alloc-row.free{ cursor: default; }
.alloc-row.free .nm{ color: var(--ink-3); font-style: italic; }

/* ----- Objetivos ----- */
.goal-list{ padding: 6px; }
.goal-row{
  display: grid; grid-template-columns: minmax(0,1fr) minmax(80px,1.1fr) 150px 16px; gap: 20px; align-items: center;
  width: 100%; padding: 14px 12px; border: none; background: none; border-radius: 14px; text-align: left; cursor: pointer; color: inherit;
  transition: background var(--t-fast) var(--ease);
}
.goal-row:hover{ background: var(--surface-2); }
.goal-row.flash{ animation: flashRow 1.8s var(--ease); }
@keyframes flashRow{ 25%{ background: var(--sage-soft); } }
.gr-name{ min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gr-name b{ font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-name small{ font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-name .ok{ display: inline-flex; align-items: center; gap: 3px; }
.gr-name .ok svg.i{ width: 13px; height: 13px; stroke-width: 2.6; }
.goal-row .bar{ height: 8px; }
.gr-amt{ text-align: right; white-space: nowrap; }
.gr-amt b{ font-size: 15px; font-weight: 600; }
.gr-amt small{ font-size: 13px; color: var(--ink-3); margin-left: 4px; }
.goal-row.done .gr-name b, .goal-row.done .gr-amt b{ color: var(--ink-2); }
.gr-group{ padding: 14px 12px 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }
.done-sec summary, details.card > summary{ list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
details.card > summary{ padding: 0; }
.done-sec summary::-webkit-details-marker, details > summary::-webkit-details-marker{ display: none; }
.done-sec summary span{ font-weight: 600; font-size: 12px; color: var(--income); background: var(--income-soft); padding: 1px 8px; border-radius: var(--r-pill); }
.done-sec summary > svg.i{ margin-left: auto; color: var(--ink-3); transition: transform .2s var(--ease); }
.done-sec[open] summary > svg.i{ transform: rotate(180deg); }
.done-sec{ margin-top: 14px; }
.goal-detail .gd-top{ display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.gd-amt{ display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.gd-amt b{ font-family: var(--serif); font-weight: 400; font-size: 48px; line-height: 1; letter-spacing: -.02em; }
.gd-amt b .cents{ font-family: var(--serif); }
.gd-amt span{ color: var(--ink-3); font-size: 15px; }
.gd-pct{ font-size: 12.5px; color: var(--ink-3); margin: -6px 0 0; }
.gd-lines{ margin: 0; border-radius: 14px; background: var(--surface-2); padding: 2px 14px; }
.gd-lines div{ display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; font-size: 14px; }
.gd-lines div + div{ border-top: 1px solid var(--line); }
.gd-lines dt{ color: var(--ink-3); }
.gd-lines dd{ margin: 0; font-weight: 600; text-align: right; }
.gd-lines dd::first-letter{ text-transform: uppercase; }
.gd-actions{ display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gd-actions .btn{ height: 46px; }
.gd-foot{ display: flex; justify-content: center; gap: 24px; }

/* ----- Mais ----- */
.menu-list{ padding: 6px; }
.menu-row{ display: grid; grid-template-columns: 40px minmax(0,1fr) 16px; gap: 14px; align-items: center; width: 100%; padding: 14px 12px; border: none; background: none; border-radius: 14px; cursor: pointer; text-align: left; color: inherit; }
.menu-row:hover{ background: var(--surface-2); }
.menu-row + .menu-row{ border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; }
.menu-ic{ width: 40px; height: 40px; border-radius: 12px; background: var(--sage-soft); color: var(--sage-dark); display: grid; place-items: center; }
.menu-mid{ display: flex; flex-direction: column; }
.menu-mid b{ font-size: 15px; font-weight: 600; }
.menu-mid small{ font-size: 12.5px; color: var(--ink-3); }
.set-list{ list-style: none; margin: 0; padding: 0; }
.set-list li{ display: flex; align-items: center; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.set-list li:last-child{ border-bottom: none; }
.set-list .nm{ flex: 1; min-width: 0; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; }
.set-list .nm small{ font-weight: 400; color: var(--ink-3); font-size: 12px; }
.done-items{ list-style: none; margin: 12px 0 0; padding: 0; }
.done-items li{ display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.done-items li:last-child{ border-bottom: none; }
.done-items small{ color: var(--ink-3); margin-left: 4px; }

/* ----- Análise ----- */
.bars{ display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 200px; padding-top: 8px; }
.bars .m{ display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; position: relative; outline-offset: 4px; border-radius: 6px; }
.bars .pair{ display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .pair i{ width: min(12px, 30%); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.bars .m small{ font-size: 11px; color: var(--ink-3); font-weight: 500; }
.bars .m.cur small{ color: var(--ink); font-weight: 700; }
.bars .tip{ position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 11.5px; padding: 6px 9px; border-radius: 9px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 3; line-height: 1.5; }
.bars .tip.l{ left: 0; transform: none; } .bars .tip.r{ left: auto; right: 0; transform: none; }
.bars .m:hover .tip, .bars .m:focus .tip{ opacity: 1; }
.table-scroll{ overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.ytable{ width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ytable th{ font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ytable th:first-child, .ytable td:first-child{ text-align: left; }
.ytable td{ padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ytable tbody tr:hover td{ background: var(--surface-2); }
.ytable tr.cur td:first-child{ box-shadow: inset 3px 0 0 var(--sage); font-weight: 700; }
.ytable td.muted, .ytable td.zero{ color: var(--ink-3); }
.ytable .inc{ color: var(--income); } .ytable .exp{ color: var(--expense); } .ytable .sav{ color: var(--savings); } .ytable .neg{ color: var(--expense); }
.ytable tfoot td{ font-weight: 700; border-bottom: none; background: var(--surface-3); }
.ytable tfoot td:first-child{ border-radius: 12px 0 0 12px; } .ytable tfoot td:last-child{ border-radius: 0 12px 12px 0; }
.matrix td, .matrix th{ font-size: 12.5px; padding: 10px 9px; }
.matrix td:first-child{ position: sticky; left: 0; background: var(--surface); font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }

/* ----- Responsivo ----- */
@media (min-width: 1000px){
  .hero-today{ flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 24px; }
  .hero-today .quick{ margin-top: 0; width: 380px; flex: 0 0 auto; }
}
@media (max-width: 1100px){
  .detail-head{ grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px){
  .shell{ display: block; }
  .side{ display: none; }
  .main{ padding: 14px 16px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); padding-top: calc(14px + env(safe-area-inset-top)); }
  .mobile-only{ display: inline-grid !important; }
  .desktop-only{ display: none !important; }
  .topbar{ margin-bottom: 16px; align-items: center; }
  .grid-2{ grid-template-columns: minmax(0,1fr); }
  .hero, .acc-hero{ padding: 20px 20px 16px; border-radius: 24px; }
  .quick{ max-width: none; }
  .tabbar{
    display: flex; position: fixed; z-index: 50; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line);
    border-radius: 22px; padding: 6px; box-shadow: var(--shadow-lg); height: var(--tabbar-h);
  }
  .tabbar button{ flex: 1; min-width: 0; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 16px; color: var(--ink-3); font-size: 10.5px; font-weight: 600; cursor: pointer; }
  .tabbar button.active{ color: var(--ink); background: var(--surface-3); }
  .tabbar button.active svg.i{ color: var(--sage-dark); }
  .tabbar svg.i{ width: 21px; height: 21px; }
  .fab{
    display: grid; place-items: center; position: fixed; z-index: 51; right: 18px; bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom));
    width: 58px; height: 58px; border-radius: 50%; border: none; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); cursor: pointer;
  }
  .fab svg.i{ width: 24px; height: 24px; stroke-width: 2.2; }
  .tx{ grid-template-columns: 40px minmax(0,1fr) auto; }
  .tx > .tx-act:not(.always){ display: none; }
  .tx-group > .tx{ grid-template-columns: 40px minmax(0,1fr) auto; }
  .tx-group > .tx .tx-act{ grid-column: 1 / -1; justify-content: flex-end; margin-top: -6px; }
  .tx-group-rows .tx{ grid-template-columns: 32px minmax(0,1fr) auto; }
  .search, .search input, .search input:focus, .search.sm input{ width: 100%; }
  .toolbar .search{ flex: 1 1 100%; }
  .section-head .search{ flex: 1 1 100%; }
  .modal{ align-items: flex-end; padding: 0; }
  .sheet{ max-width: none !important; border-radius: 26px 26px 0 0; max-height: calc(100dvh - 24px); padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); animation: sheetUp .3s var(--ease); }
  .sheet-grip{ display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 2px; flex: 0 0 auto; }
  .sheet-foot{ position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--surface); margin: 0 -18px calc(-18px - env(safe-area-inset-bottom)); padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .sheet-foot .btn-primary{ flex: 1 1 auto; height: 46px; }
  @keyframes sheetUp{ from{ transform: translateY(40px); opacity: 0; } }
  .toasts{ bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom)); }
  .auth{ grid-template-columns: 1fr; }
  .auth-art{ padding: 28px 24px; min-height: 260px; }
  .acc-row{ grid-template-columns: 10px minmax(0,1fr) auto 16px; }
  .acc-spark{ display: none; }
  .goal-row{ grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "name amt" "bar bar"; row-gap: 10px; gap: 12px; }
  .goal-row .gr-name{ grid-area: name; } .goal-row .gr-amt{ grid-area: amt; align-self: start; } .goal-row > .bar{ grid-area: bar; }
  .goal-row > svg.i{ display: none; }
  .headline{ margin-bottom: 14px; }
  .headline-side.wide{ flex: 1 1 100%; }
}
@media (max-width: 560px){
  .field-row{ grid-template-columns: 1fr; }
  .bars{ gap: 3px; height: 170px; }
  .bars .m small{ font-size: 9.5px; }
  .ytable .hide-sm{ display: none; }
  .month-nav .lbl{ min-width: 120px; }
  .inline-form{ flex-direction: column; align-items: stretch; }
  .card{ padding: 16px; border-radius: 20px; }
  .list-card, .acc-list, .goal-list, .menu-list{ padding: 6px; }
  .qa{ flex-direction: column; height: 62px; gap: 4px; font-size: 12px; }
}

/* ===== Fases 2–8 ===== */
.col{ display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col > .card + .card{ margin-top: 0; }
.card .chart-x{ color: var(--ink-3); }
.card .chart-dot{ background: var(--surface); border-color: var(--sage-dark); box-shadow: 0 0 0 6px color-mix(in srgb, var(--sage) 18%, transparent); }
.card .chart-tip{ background: var(--ink); color: var(--bg); }
.fc-line{ margin: -4px 0 12px; font-size: 13.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: flex-start; }
.fc-line.neg{ color: var(--expense); font-weight: 500; }
.fc-line svg.i{ width: 16px; height: 16px; margin-top: 1px; }
.up-item.rec .up-date{ color: var(--savings); }
.up-item.late{ background: var(--warn-soft); }
.up-item .row-actions .icon-btn{ width: 34px; height: 34px; }
.prev-card{ margin-bottom: 16px; padding: 14px 12px 8px; }
.prev-card .card-head{ padding: 0 8px; margin-bottom: 6px; }
.tx.prev{ cursor: default; }
.more-search{ text-align: center; margin: 14px 0 0; }
.prio{ display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--expense); margin-right: 7px; vertical-align: 2px; }

/* Registo rápido */
.quick-line{ display: flex; flex-direction: column; gap: 8px; }
.quick-input{ display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 14px; background: var(--sage-soft); color: var(--sage-dark); border: 1px solid transparent; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.quick-input:focus-within{ border-color: var(--sage); box-shadow: var(--ring); }
.quick-input input{ flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-size: 15px; color: var(--ink); }
.quick-input input::placeholder{ color: color-mix(in srgb, var(--sage-dark) 70%, transparent); opacity: 1; }
.quick-read{ margin: 0; font-size: 12.5px; color: var(--ink-2); padding: 0 4px; }
.quick-read b{ font-weight: 600; color: var(--ink); }
.quick-chips{ flex-wrap: nowrap; }
.chip.sm{ height: 30px; padding: 0 11px; font-size: 12.5px; }
.more-fields{ border-top: 1px solid var(--line); padding-top: 10px; }
.more-fields > summary{ list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 4px 0; }
.more-fields > summary::-webkit-details-marker{ display: none; }
.more-fields > summary svg.i{ width: 15px; height: 15px; transition: transform .2s var(--ease); }
.more-fields[open] > summary svg.i{ transform: rotate(180deg); }
.more-fields[open]{ display: flex; flex-direction: column; gap: 12px; }
.field textarea{ width: 100%; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); padding: 10px 14px; font-size: 15px; resize: vertical; min-height: 64px; }
.field textarea:focus{ outline: none; border-color: var(--sage); box-shadow: var(--ring); }
.field-clear{ margin-left: auto; font-size: 12px; padding: 0; }
.field > .label{ display: flex; align-items: center; gap: 6px; }

/* Interruptores e caixas */
.switch{ display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; }
.switch input{ position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span{ width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background var(--t-fast); flex: 0 0 auto; }
.switch span::after{ content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + span{ background: var(--sage-dark); }
.switch input:checked + span::after{ transform: translateX(16px); }
.switch input:focus-visible + span{ outline: 2px solid var(--sage); outline-offset: 2px; }
.switch.sm{ font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.check{ display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input{ width: 18px; height: 18px; accent-color: var(--sage-dark); }
.recibo{ padding: 12px 14px; border-radius: 14px; background: var(--income-soft); display: flex; flex-direction: column; gap: 10px; }
.recibo-opts{ display: flex; flex-wrap: wrap; gap: 8px 18px; }
.recibo-opts .hint{ flex-basis: 100%; color: var(--ink-2); }

/* Contas */
.recon-btn{ margin-top: 12px; }
.inout.three{ grid-template-columns: repeat(3, minmax(0,1fr)); }
.inout b small{ font-size: 11.5px; font-weight: 600; }

/* Objetivos */
.can-drag .goal-row{ grid-template-columns: 18px minmax(0,1fr) minmax(80px,1.1fr) 150px 16px; gap: 16px; }
.drag{ color: var(--ink-3); cursor: grab; display: grid; place-items: center; touch-action: none; opacity: .5; padding: 6px 0; }
.drag svg.i{ width: 16px; height: 16px; }
.goal-row:hover .drag{ opacity: 1; }
.goal-row.dragging{ background: var(--sage-soft); box-shadow: var(--shadow); opacity: .9; }
.pace{ font-weight: 600; margin-left: 4px; }
.pace.good{ color: var(--income); } .pace.bad{ color: var(--warn); }
.arch-row{ display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 14px; }
.arch-row small{ color: var(--ink-3); margin-left: 6px; }
.done-sec summary .muted{ color: var(--ink-3); background: var(--surface-3); }
.hint.pad{ padding: 4px 12px 10px; }

/* Análise e impostos */
.obs-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.obs-list li{ padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; border-left: 3px solid var(--line-2); }
.obs-list li.good{ border-left-color: var(--income); }
.obs-list li.bad{ border-left-color: var(--warn); }
.ytable.cmp tbody tr{ cursor: pointer; }
.big-num{ font-family: var(--serif); font-size: 44px; line-height: 1; margin: 0 0 14px; letter-spacing: -.02em; }
.big-num .cents{ font-family: var(--serif); }
.alert{ margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.alert.warn{ background: var(--warn-soft); color: var(--warn); }
.alert.bad{ background: var(--expense-soft); color: var(--expense); }
.ded-list{ display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 28px; margin-bottom: 12px; }
.ded{ display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px; align-items: center; }
.ded .nm{ font-size: 13.5px; font-weight: 600; display: flex; flex-direction: column; min-width: 0; }
.ded .nm small{ font-weight: 400; color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ded .val{ font-weight: 600; font-size: 14px; white-space: nowrap; }
.ded .val small{ color: var(--ink-3); font-weight: 500; }
.ded .bar{ grid-column: 1 / -1; }

/* Recorrentes */
.rule-row{ display: grid; grid-template-columns: 40px minmax(0,1fr) auto 16px; gap: 14px; align-items: center; width: 100%; padding: 10px 8px; border: none; background: none; border-radius: 14px; cursor: pointer; text-align: left; color: inherit; }
.rule-row:hover{ background: var(--surface-2); }

/* Pesquisa e importar */
.filters{ display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.search.wide input, .search.wide{ width: 100%; }
.filter-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.field.narrow{ max-width: 360px; margin-bottom: 12px; }
.drop{ display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 36px 16px; border: 1.5px dashed var(--line-2); border-radius: 18px; cursor: pointer; color: var(--ink-2); text-align: center; margin-top: 12px; transition: border-color var(--t-fast), background var(--t-fast); }
.drop:hover, .drop.over{ border-color: var(--sage); background: var(--sage-soft); color: var(--sage-dark); }
.drop input{ position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop svg.i{ width: 26px; height: 26px; }
.drop small{ color: var(--ink-3); }
.ytable.imp td.desc{ white-space: normal; min-width: 180px; text-align: left; }
.ytable.imp th:nth-child(3), .ytable.imp th:nth-child(4), .ytable.imp td:nth-child(4){ text-align: left; }
.ytable.imp tr.dup td{ color: var(--ink-3); }
.ytable.imp input{ width: 18px; height: 18px; accent-color: var(--sage-dark); }
.tag-dup{ font-size: 11px; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }

/* Definições */
.mini-sel{ max-width: 190px; }
.mini-sel + .cs, .set-list .cs{ width: 190px; flex: 0 0 auto; }
.set-list .cs-trigger{ height: 34px; font-size: 12.5px; }
.feat-list{ list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 18px; }
.feat-list li{ display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-3); }
.feat-list li.on{ color: var(--ink); }
.feat-list li svg.i{ width: 16px; height: 16px; color: var(--warn); }
.feat-list li.on svg.i{ color: var(--income); }

@media (max-width: 900px){
  .can-drag .goal-row{ grid-template-columns: 18px minmax(0,1fr) auto; grid-template-areas: "drag name amt" "drag bar bar"; }
  .can-drag .goal-row .drag{ grid-area: drag; }
  .rule-row{ grid-template-columns: 40px minmax(0,1fr) auto; }
  .rule-row > svg.chev-r{ display: none; }
  .set-list li{ flex-wrap: wrap; }
  .set-list .cs{ order: 5; width: 100%; margin: 2px 0 4px 16px; }
  .inout.three{ grid-template-columns: 1fr 1fr; }
}
.fc-line{ display: block; }
.fc-line svg.i{ display: inline-block; vertical-align: -3px; margin-right: 4px; }
@media (max-width: 560px){ .filter-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
