/* Insightor · componentes. Base: design/components/bundle.css (sem o escopo .ins) e os READMEs de
   design/components/. Toda cor, medida de cor, raio, sombra, fonte e duração vem de tokens.css. */

/* ---- Cabeçalhos de página e seção ---------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-10); }
.page-head .eyebrow { margin-bottom: var(--space-3); }
.page-head p { margin-top: var(--space-2); max-width: var(--reading-max); color: var(--ink-2); }
.page-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.page-head + .tabs { margin-top: calc(-1 * var(--space-6)); margin-bottom: var(--space-10); }
/* A seção (DESIGN.md, "Contêineres e hierarquia"): sem fundo, título e subtítulo, divisória line em cima, em qualquer
   nível. Sem a divisória: a primeira seção da página (logo após o cabeçalho, as abas ou o "voltar") e a seção que vive
   dentro de um cartão, de um diálogo ou de uma folha (o contorno deles já a delimita). */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); }
:is(.page-head, .tabs, .back, .pending-banner, .fin-banner) + * > .section-head:first-child,
:is(.panel, .viz, .dialog, .sheet, .ocard, .icard, .fold, .choice, .empty) .section-head { padding-top: 0; border-top: 0; }
.section-head p { margin-top: var(--space-1); color: var(--ink-2); }
.section-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; max-width: 100%; }
.section-head-actions > .segmented { max-width: 100%; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
/* Link de volta acima do título ("← Decisões") */
.back { display: flex; width: fit-content; align-items: center; gap: var(--space-2); color: var(--ink-2); font-weight: 500; font-size: calc(13px * var(--type-scale)); margin-bottom: var(--space-3); min-height: var(--space-8); }
.back:hover { color: var(--ink); }
.is-disabled { opacity: 0.45; pointer-events: none; }
.skip-link { position: absolute; left: var(--space-4); top: calc(-1 * var(--space-16)); z-index: var(--z-toast); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); background: var(--surface-float); color: var(--ink); box-shadow: var(--shadow-2); }
.skip-link:focus { top: var(--space-2); }
@media (max-width: 720px) {
  .page-head, .section-head { flex-direction: column; align-items: flex-start; }
  .page-head { margin-bottom: var(--space-8); }
}

/* ---- Duas colunas (TwoColumn) -------------------------------------------- */
/* O conteúdo e, a partir de 1024 px (1180 com `from-1180`), a lateral de aside-narrow à direita, fixa ao rolar
   (DESIGN.md, "A segunda coluna útil"). Abaixo disso a lateral vai para baixo do conteúdo, com a divisória de seção
   (ou, pelo componente, vira folha). A lateral rola sozinha quando é mais alta que a janela. */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-10); align-items: start; }
.two-col.has-aside { grid-template-columns: minmax(0, 1fr) var(--aside-narrow); }
.tc-main { min-width: 0; }
.tc-aside { position: sticky; top: calc(var(--nav-h) + var(--space-6)); min-width: 0; max-height: calc(100vh - var(--nav-h) - var(--space-10)); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--space-6); padding: 2px; margin: -2px; }
.tc-open { margin-bottom: var(--space-4); }
.tc-block > .eyebrow { display: block; margin-bottom: var(--space-2); }
.tc-block > p { color: var(--ink-2); }
.tc-block > p + p { margin-top: var(--space-1); }
.tc-block > .link { margin-top: var(--space-2); }
.tc-bullets { display: grid; gap: var(--space-2); margin: 0; padding-left: var(--space-4); list-style: disc; color: var(--ink-2); font-size: calc(14px * var(--type-scale)); line-height: 1.5; }
/* A lista lateral de opções (filtros, estados) com a contagem à direita; a escolhida como item de navegação */
.tc-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.tc-list :is(button, a) { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; min-height: var(--control-h); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid transparent; background: transparent; font-size: calc(15px * var(--type-scale)); font-weight: 500; color: var(--ink-2); text-align: left; cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.tc-list :is(button, a):hover { background: var(--surface-2); color: var(--ink); }
.tc-list :is(button[aria-pressed='true'], a[aria-current]) { background: var(--surface); color: var(--ink); font-weight: 600; border-color: var(--line); box-shadow: var(--shadow-1); }
.tc-list .count { font-size: calc(13px * var(--type-scale)); font-weight: 500; color: var(--ink-3); }
.tc-list button[aria-pressed='true'] .count { color: var(--ink-2); }
.tc-links { display: grid; gap: var(--space-1); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.tc-links .link { text-align: left; }
@media (max-width: 1023px) {
  .two-col.has-aside { grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
  .tc-aside { position: static; max-height: none; overflow: visible; padding: var(--space-6) 0 0; margin: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 1179px) {
  .two-col.from-1180.has-aside { grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
  .two-col.from-1180 .tc-aside { position: static; max-height: none; overflow: visible; padding: var(--space-6) 0 0; margin: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) { .tc-list :is(button, a) { min-height: var(--touch-min); } }

/* ---- Barra superior ------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: var(--z-topbar); height: var(--nav-h); background: var(--navy); color: var(--on-navy); }
.topbar-inner { max-width: calc(var(--page-wide) + 2 * var(--gutter)); margin: 0 auto; height: 100%; padding: 0 var(--gutter); display: flex; align-items: center; gap: var(--space-6); }
.brand { display: inline-flex; flex: none; align-items: center; gap: var(--space-2); font-weight: 600; font-size: calc(17px * var(--type-scale)); letter-spacing: -0.02em; color: var(--ink); }
.topbar .brand { color: var(--on-navy); }
.brand img { width: 28px; height: 28px; display: block; }
.nav { display: flex; gap: var(--space-1); }
.nav a { position: relative; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: calc(14.5px * var(--type-scale)); font-weight: 500; color: var(--on-navy-muted); transition: color var(--dur) var(--ease), background var(--dur) var(--ease); }
.nav a:hover { color: var(--on-navy); background: var(--on-navy-hover); }
.nav a[aria-current='page'] { color: var(--on-navy); }
.nav a[aria-current='page']::after { content: ''; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -13px; height: 2px; border-radius: 2px; background: var(--brand-grad); }
.topbar :focus-visible { outline-color: var(--on-navy); }
.topbar .menu-pop :focus-visible { outline-color: var(--focus); }
.menu-item:focus-visible { background: var(--surface-2); color: var(--ink); }
.topbar .btn-ghost[aria-current='page'] { color: var(--on-navy); background: var(--on-navy-hover); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.topbar .btn-primary { background: var(--on-navy); color: var(--navy); }
.topbar .btn-primary:hover { background-color: var(--on-navy); background-image: linear-gradient(var(--accent-wash), var(--accent-wash)); color: var(--navy); }
.topbar .btn-ghost { color: var(--on-navy-muted); }
.topbar .btn-ghost:hover { color: var(--on-navy); background: var(--on-navy-hover); }
.badge { position: absolute; top: 1px; right: -1px; min-width: 18px; height: 18px; padding: 0 var(--space-1); border-radius: var(--radius-round); background: var(--accent); color: var(--on-accent); font-size: calc(12px * var(--type-scale)); font-weight: 700; display: grid; place-items: center; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
/* sobre o navy, um anel em on-navy separa o contador do fundo (accent sobre navy fica abaixo de 3:1 no claro) */
.topbar .badge { box-shadow: 0 0 0 2px var(--on-navy); }
.avatar { width: 34px; height: 34px; border-radius: var(--radius-round); display: inline-grid; place-items: center; background: var(--surface-3); color: var(--ink); font-size: calc(12.5px * var(--type-scale)); font-weight: 600; letter-spacing: 0.02em; }
.topbar .avatar { background: var(--on-navy-soft); color: var(--on-navy); }
.space-banner { background: var(--accent-soft); color: var(--accent-ink); font-size: calc(13.5px * var(--type-scale)); font-weight: 500; }
.space-banner-inner { max-width: calc(var(--page-wide) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-2) var(--gutter); display: flex; justify-content: center; gap: var(--space-3); align-items: center; }
.space-banner strong { font-weight: 600; }
.space-banner .btn-secondary { border-color: var(--accent-ink); }

/* Menu flutuante */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: var(--z-menu); min-width: 240px; background: var(--surface-float); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 6px; animation: pop-in var(--dur) var(--ease); }
.menu-pop.left { right: auto; left: 0; }
.menu-head { padding: 10px var(--space-3) var(--space-3); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px var(--space-3); min-height: 40px; border-radius: var(--radius-md); font-size: calc(14px * var(--type-scale)); color: var(--ink-2); }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.strong { color: var(--ink); font-weight: 600; }
.menu-item.danger { color: var(--neg); }
.menu-item.danger:hover { background: var(--neg-soft); color: var(--neg); }
.menu-item:disabled { opacity: 0.45; pointer-events: none; }
.menu-sep { height: 1px; background: var(--line); margin: 6px var(--space-1); }
.menu-veil { position: fixed; inset: 0; z-index: calc(var(--z-menu) - 1); }

/* ---- Barra inferior (celular) ------------------------------------------- */
.tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar); background: var(--surface-float); border-top: 1px solid var(--line); padding: 6px var(--space-2) calc(6px + env(safe-area-inset-bottom)); }
.tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 0; min-height: var(--touch-min); font-size: calc(12px * var(--type-scale)); font-weight: 600; color: var(--ink-2); border-radius: var(--radius-md); }
.tabbar a[aria-current='page'], .tabbar button[aria-current='page'], .tabbar button[aria-expanded='true'] { color: var(--ink); }
.tabbar [aria-current='page'] svg { stroke-width: 2.2; }
.tabbar [aria-current='page'] { font-weight: 700; }
.more-list { display: flex; flex-direction: column; }
.more-count { min-width: 22px; height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-round); background: var(--accent); color: var(--on-accent); font-size: calc(12px * var(--type-scale)); font-weight: 700; display: grid; place-items: center; font-family: var(--font-num); }
@media (max-width: 860px) {
  .nav, .topbar-actions .btn-new, .topbar-actions .hide-mobile { display: none; }
  .tabbar { display: flex; }
}

/* ---- Botões -------------------------------------------------------------- */
.btn { --h: var(--control-h); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--h); padding: 0 var(--space-4); border-radius: var(--radius-md); font-size: calc(14.5px * var(--type-scale)); font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; border: 1px solid transparent; transition: background var(--dur) var(--ease), border-color var(--dur), color var(--dur), transform var(--dur-fast) var(--ease), box-shadow var(--dur); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; pointer-events: none; }
.btn-primary, .btn-accent { background: var(--primary); color: var(--on-accent); }
.btn-primary:hover, .btn-accent:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-field); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-ghost { color: var(--ink-2); padding: 0 var(--space-3); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--neg-soft); color: var(--neg); }
.btn-danger:hover { background: var(--neg); color: var(--ink-inverse); }
.btn-sm { --h: 32px; padding: 0 var(--space-3); font-size: calc(13.5px * var(--type-scale)); }
.btn-lg { --h: 48px; padding: 0 22px; font-size: calc(15.5px * var(--type-scale)); }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }
.btn .badge { top: -4px; right: -4px; }
/* No celular e no tablet com a barra inferior (toque), todo controle tem ao menos touch-min (44 px) de alvo */
@media (max-width: 860px) {
  .btn, .btn-sm { min-height: var(--touch-min); }
  .btn-icon { min-width: var(--touch-min); }
}

/* ---- Campos -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: calc(13px * var(--type-scale)); font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: calc(12.5px * var(--type-scale)); color: var(--ink-2); }
.field-error { font-size: calc(12.5px * var(--type-scale)); color: var(--neg); display: inline-flex; align-items: center; gap: var(--space-1); }
.input, .select { height: 42px; width: 100%; padding: 0 var(--space-3); background: var(--surface); color: var(--ink); border: 1px solid var(--line-field); border-radius: var(--radius-md); font-size: calc(15px * var(--type-scale)); transition: border-color var(--dur), box-shadow var(--dur); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.input::placeholder { color: var(--ink-3); }
.input:disabled, .select:disabled { opacity: 0.45; }
.field.invalid .input, .field.invalid .select, .input[aria-invalid='true'] { border-color: var(--neg); }
.input-money, .input-suffix { position: relative; }
/* Valor em reais ou percentual: a escolha (R$ | %), o campo e a equivalência só de leitura, que quebra para baixo no celular */
.aop { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); align-items: center; }
.aop-eq { grid-column: 1 / -1; font-family: var(--font-num); font-variant-numeric: tabular-nums; min-height: 1.4em; }
.input-money > span { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: calc(14px * var(--type-scale)); pointer-events: none; }
.input-money .input { padding-left: 36px; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.input-suffix { display: flex; align-items: center; }
.input-suffix .input { padding-right: 48px; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.input-suffix > span { position: absolute; right: var(--space-3); color: var(--ink-3); font-size: calc(13px * var(--type-scale)); pointer-events: none; }
textarea.input { height: auto; min-height: 96px; padding: 10px var(--space-3); resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.check-inline { display: inline-flex; align-items: center; gap: var(--space-2); font-size: calc(14px * var(--type-scale)); color: var(--ink-2); cursor: pointer; min-height: 24px; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
/* o valor e o quando de uma compra, lado a lado (metade cada), alinhados pelo rótulo */
.form-grid.amount-when { align-items: start; }

/* Slider */
.slider { display: flex; flex-direction: column; gap: 6px; }
.slider-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px var(--space-3); }
.slider-head .label { font-size: calc(13.5px * var(--type-scale)); font-weight: 500; color: var(--ink-2); }
.slider-head .value { font-family: var(--font-num); font-size: calc(14px * var(--type-scale)); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); margin-left: auto; text-align: right; }
.slider-head .value.changed { color: var(--accent-ink); }
.slider-head .value-edit { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 1px 6px; margin: -1px -6px -1px 0; border: 1px dashed transparent; border-radius: var(--radius-sm); background: none; cursor: text; }
.slider-head .value-edit .icon { color: var(--ink-3); }
.slider-head .value-edit:hover, .slider-head .value-edit:focus-visible { border-color: var(--line-2); background: var(--surface-2); }
.slider-head .slider-type { width: 128px; padding: 2px var(--space-2); font-family: var(--font-num); font-size: calc(14px * var(--type-scale)); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius-sm); outline: none; box-shadow: var(--ring); }
.slider-note { font-size: calc(12px * var(--type-scale)); color: var(--ink-2); display: flex; justify-content: space-between; gap: var(--space-3); }
.slider-track { position: relative; height: 28px; }
.slider-baseline { position: absolute; top: 8px; width: 2px; height: 12px; background: var(--ink-3); border-radius: 1px; transform: translateX(-1px); pointer-events: none; }

/* Mês e data (MonthField, DateField): o campo com o botão do calendário dentro; a grade abre logo abaixo, no fluxo
   da página (dentro de diálogos e folhas não há o que cortar). No toque, células e setas com touch-min de altura. */
.date-field .df-control { position: relative; }
.date-field .df-input { padding-right: 48px; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.df-cal { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 44px; display: grid; place-items: center; border-radius: var(--radius-md); color: var(--ink-2); }
.df-cal:hover { background: var(--surface-2); color: var(--ink); }
.df-cal[aria-expanded='true'] { color: var(--accent-ink); }
.df-cal:disabled { opacity: 0.45; pointer-events: none; }
.df-past { display: flex; align-items: flex-start; gap: var(--space-1); font-size: calc(12.5px * var(--type-scale)); color: var(--ink-2); }
.df-past .icon { margin-top: 2px; color: var(--ink-3); }
.date-field > .field-error { margin-top: 0; }
.df-panel { width: 100%; min-width: 240px; max-width: 340px; padding: var(--space-3); background: var(--surface-float); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.df-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.df-title { font-size: calc(14px * var(--type-scale)); font-weight: 600; color: var(--ink); white-space: nowrap; }
.df-panel.days { min-width: 288px; }
.df-nav { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-md); color: var(--ink-2); }
.df-nav:hover { background: var(--surface-2); color: var(--ink); }
.df-nav:disabled { opacity: 0.35; pointer-events: none; }
.df-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); }
.df-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.df-wd { text-align: center; text-decoration: none; font-size: calc(12px * var(--type-scale)); color: var(--ink-2); padding: 2px 0; }
.df-cell { min-height: 38px; border-radius: var(--radius-md); font-size: calc(14px * var(--type-scale)); color: var(--ink); }
.df-cell:hover { background: var(--surface-2); }
.df-cell.now { box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; }
.df-cell.on, .df-cell.on:hover { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.df-cell:disabled { color: var(--ink-3); opacity: 0.5; pointer-events: none; }
@media (max-width: 860px) {
  .df-cell, .df-nav { min-height: var(--touch-min); }
  .df-nav { width: var(--touch-min); }
}
input[type='range'] { --p: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; display: block; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) 0 var(--p), var(--line-2) var(--p) 100%); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: var(--radius-round); background: var(--surface-float); border: 1px solid var(--accent); box-shadow: var(--shadow-1); transition: transform var(--dur-fast) var(--ease); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: var(--radius-round); background: var(--surface-float); border: 1px solid var(--accent); }
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type='range']:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
input[type='range']:focus-visible::-moz-range-thumb { box-shadow: var(--ring); }
input[type='range']:disabled { opacity: 0.45; cursor: default; }

/* Segmentado */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { padding: 6px var(--space-3); min-height: 30px; border-radius: 6px; font-size: calc(13.5px * var(--type-scale)); font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.segmented button:hover { color: var(--ink); }
.segmented button:focus-visible { outline-offset: -2px; }
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line-field); }
.segmented button .count { color: var(--ink-3); font-weight: 500; margin-left: var(--space-1); font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.segmented.small button { padding: var(--space-1) 10px; min-height: 26px; font-size: calc(12.5px * var(--type-scale)); }
.segmented.block { display: flex; }
.segmented.block button { flex: 1; }
@media (max-width: 860px) { .segmented button, .segmented.small button { min-height: var(--touch-min); } }

/* Interruptor */
.switch { position: relative; display: inline-flex; width: 36px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: -4px; margin: 0; cursor: pointer; width: calc(100% + 8px); height: calc(100% + 8px); }
.switch span { position: absolute; inset: 0; border-radius: var(--radius-round); background: var(--line-field); transition: background var(--dur); pointer-events: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: var(--radius-round); background: var(--surface); box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: var(--ring); outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.45; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row .label { font-weight: 500; color: var(--ink); }
.switch-row .hint { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); }

/* Chips e status: etiqueta retangular sem contorno; nunca um ícone dentro de uma pílula com borda */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: var(--radius-sm); font-size: calc(12.5px * var(--type-scale)); font-weight: 500; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.chip.plain { background: transparent; padding: 0 2px; }
.chip.on { background: var(--accent-soft); color: var(--accent-ink); }
button.chip { cursor: pointer; }
button.chip:hover { color: var(--ink); }
button.chip.on:hover { color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 860px) { button.chip { height: var(--touch-min); } }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: calc(12.5px * var(--type-scale)); font-weight: 600; padding: 3px 9px 3px 7px; border-radius: var(--radius-round); white-space: nowrap; }
.status.ok, .status.done { color: var(--pos); background: var(--pos-soft); }
.status.tight, .status.attention { color: var(--warn); background: var(--warn-soft); }
.status.fail { color: var(--neg); background: var(--neg-soft); }
.status.info, .status.planned, .status.later { color: var(--accent-ink); background: var(--accent-soft); }
.status.neutral, .status.deciding { color: var(--ink-2); background: var(--surface-2); }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; vertical-align: middle; background: currentColor; }
.key.dot { width: 9px; height: 9px; border-radius: var(--radius-round); }
.key.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }
.key.area { width: 12px; height: 10px; border-radius: 2px; opacity: 0.35; }
.key.bar { width: 10px; height: 10px; border-radius: 2px; }

/* ---- Painéis e números --------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-pad { padding: var(--space-6); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.inset { background: var(--surface-2); border-radius: var(--radius-lg); padding: var(--space-4); }
@media (max-width: 720px) { .panel-pad { padding: var(--space-5) var(--space-4); } }
/* .figure é também um estilo de texto em tokens.css: o contêiner volta ao corpo, e só .value usa figure */
.figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-family: var(--font-sans); font-size: calc(15px * var(--type-scale)); font-weight: 400; line-height: 1.55; letter-spacing: 0; }
.figure .label { font-size: calc(13px * var(--type-scale)); line-height: 1.5; color: var(--ink-3); font-weight: 500; }
.figure .value { font-family: var(--font-num); font-size: calc(26px * var(--type-scale)); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--ink); }
.figure .value.lg { font-size: calc(34px * var(--type-scale)); }
.figure .sub { font-size: calc(13px * var(--type-scale)); line-height: 1.5; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.figures { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
.figures > * { padding: var(--space-1) var(--space-6); border-left: 1px solid var(--line); }
.figures > *:first-child { padding-left: 0; border-left: 0; }
@media (max-width: 860px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-5); }
  .figures > * { padding: 0 var(--space-4); }
  .figures > *:nth-child(odd) { padding-left: 0; border-left: 0; }
  .figure .value { font-size: calc(22px * var(--type-scale)); }
  .figure .value.lg { font-size: calc(28px * var(--type-scale)); }
}
.delta { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-num); font-size: calc(12.5px * var(--type-scale)); font-weight: 600; font-variant-numeric: tabular-nums; padding: 1px 7px; border-radius: var(--radius-round); white-space: nowrap; }
.delta.up { color: var(--pos); background: var(--pos-soft); }
.delta.down { color: var(--neg); background: var(--neg-soft); }
.delta.flat { color: var(--ink-2); background: var(--surface-2); }

/* Meter e anel */
.meter { display: block; height: 6px; border-radius: var(--radius-round); background: var(--surface-3); position: relative; overflow: hidden; }
.meter.thick { height: 10px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--radius-round); background: var(--s1); transition: width var(--dur-chart) var(--ease); }
.meter.warn > i { background: var(--warn); }
.meter.neg > i { background: var(--neg); }
.meter.pos > i { background: var(--pos); }
.meter > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.meter-row { display: flex; align-items: center; gap: var(--space-3); }
.meter-row .meter { flex: 1; }
.ring { position: relative; width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.ring svg.ring-svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--s1); stroke-linecap: round; transition: stroke-dashoffset var(--dur-chart) var(--ease); }
.ring.today .fill { stroke: url(#ins-brand-grad); }
.ring.done .fill { stroke: var(--pos); }
.ring.tight .fill { stroke: var(--warn); }
.ring.fail .fill { stroke: var(--neg); }
.ring > .icon { color: var(--ink-2); position: relative; }

/* ---- Listas, tabelas, abas ---------------------------------------------- */
.list { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }
.list-row.clickable { cursor: pointer; transition: background var(--dur); padding-left: var(--space-3); padding-right: var(--space-3); border-radius: var(--radius-md); }
.list-row.clickable:hover { background: var(--surface-2); }
.icon-badge { width: 38px; height: 38px; border-radius: var(--radius-lg); display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.icon-badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { position: relative; padding: 10px 0 var(--space-3); min-height: var(--touch-min); font-size: calc(14px * var(--type-scale)); font-weight: 600; color: var(--ink-3); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover, .tabs a:hover { color: var(--ink-2); }
.tabs [aria-selected='true'], .tabs [aria-current='page'] { color: var(--ink); }
/* a faixa das abas rola na horizontal: o contorno de foco fica por dentro para não ser recortado */
.tabs a:focus-visible, .tabs button:focus-visible { outline-offset: -2px; }
/* no celular, as abas que não cabem somem aos poucos na borda: há mais para rolar */
@media (max-width: 720px) { .tabs { padding-right: var(--space-8); -webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - var(--space-10)), transparent); mask-image: linear-gradient(to right, var(--ink) calc(100% - var(--space-10)), transparent); } }
.tabs [aria-current='page']::after, .tabs [aria-selected='true']::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tabs .chip { height: 20px; font-size: calc(12px * var(--type-scale)); padding: 0 6px; }
.table { width: 100%; border-collapse: collapse; font-size: calc(14px * var(--type-scale)); }
.table th { text-align: left; font-size: calc(12.5px * var(--type-scale)); font-weight: 600; color: var(--ink-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.table td.n, .table th.n, .table td.r, .table th.r { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.table tr.ref :is(td, th) { color: var(--ink-3); font-style: italic; }
.table tr.pick :is(td, th) { background: var(--accent-wash); }
.table tr.pick > :first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table tfoot td { font-weight: 600; color: var(--ink); border-bottom: 0; border-top: 1px solid var(--line-2); }
.table-wrap { overflow-x: auto; position: relative; }
.paths-table th[scope='row'] { font-weight: 600; color: var(--ink); text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--line); white-space: nowrap; font-size: calc(14px * var(--type-scale)); }
.path-name { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ---- Cartões do domínio ------------------------------------------------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
@media (max-width: 1100px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .card-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); } }
/* O cartão de um objeto (ObjectCard): o mesmo no Início, em Objetivos e em Decisões. Cartões da mesma altura na
   grade, com as etapas (ou a data da edição) sempre no pé. */
.ocard { display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left; padding: var(--space-5); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); transition: border-color var(--dur), box-shadow var(--dur); color: inherit; }
.ocard:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.ocard.archived { background: transparent; border-style: dashed; border-color: var(--line-2); }
.ocard.archived .oc-title { color: var(--ink-2); }
.oc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.ocard.has-actions .oc-top { padding-right: var(--space-12); }   /* o menu fica no canto, fora do link */
.oc-icon { width: 40px; height: 40px; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); flex: none; }
.oc-icon.ok, .oc-icon.done { background: var(--pos-soft); color: var(--pos); }
.oc-icon.tight { background: var(--warn-soft); color: var(--warn); }
.oc-icon.fail { background: var(--neg-soft); color: var(--neg); }
.oc-icon.planned, .oc-icon.later { background: var(--accent-soft); color: var(--accent-ink); }
.oc-kind { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.oc-title { display: block; font-size: calc(17px * var(--type-scale)); font-weight: 600; letter-spacing: -0.01em; margin-top: var(--space-2); }
.oc-head { display: block; margin-top: var(--space-1); color: var(--ink-2); font-size: calc(14px * var(--type-scale)); }
.oc-text { display: block; margin-top: var(--space-3); color: var(--ink-2); font-size: calc(13px * var(--type-scale)); line-height: 1.5; }
.oc-text strong { color: var(--ink); font-weight: 600; }
.oc-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-top: var(--space-2); font-size: calc(13px * var(--type-scale)); color: var(--ink-2); }
.oc-line > .icon { color: var(--ink-3); flex: none; }
.oc-line.warn { color: var(--warn); }
.oc-line.warn > .icon { color: var(--warn); }
.oc-steps { display: flex; gap: var(--space-1); margin-top: auto; padding-top: var(--space-4); }
.oc-steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.oc-steps i.done { background: var(--s1); }
.oc-next { display: block; margin-top: var(--space-2); font-size: calc(13px * var(--type-scale)); color: var(--ink-3); }
.oc-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: auto; padding-top: var(--space-4); }
.oc-next + .oc-foot { margin-top: var(--space-2); padding-top: 0; }
.ocard-wrap { position: relative; height: 100%; }
.oc-actions { position: absolute; top: var(--space-4); right: var(--space-3); }
/* O par status e veredito (StatusPair): as duas pílulas lado a lado, que quebram juntas quando falta largura */
.status-pair { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.oc-top .status-pair { justify-content: flex-end; }
/* Novo objetivo com um do mesmo tipo já no plano: as opções são frases inteiras ("Continuar a decisão de…"), que quebram */
.nt-choice .btn { white-space: normal; height: auto; min-height: var(--h); padding-block: var(--space-2); text-align: left; justify-content: flex-start; line-height: 1.35; }
.kind-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 860px) { .kind-grid { grid-template-columns: minmax(0, 1fr); } }
.kind { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: var(--space-6); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); transition: border-color var(--dur), box-shadow var(--dur); color: inherit; }
.kind:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.kind.on, .kind[aria-expanded='true'] { border-color: var(--accent); box-shadow: var(--ring); }
.kind-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface-2); color: var(--ink); margin-bottom: 6px; }
.kind.on .kind-icon, .kind[aria-expanded='true'] .kind-icon { background: var(--accent); color: var(--on-accent); }
.kind .title { font-size: calc(17px * var(--type-scale)); font-weight: 600; }
.kind p { color: var(--ink-2); font-size: calc(14px * var(--type-scale)); }
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .presets { grid-template-columns: minmax(0, 1fr); } }
.preset { display: flex; align-items: center; gap: 14px; text-align: left; padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); transition: border-color var(--dur), box-shadow var(--dur); color: inherit; width: 100%; }
.preset > svg:first-child { color: var(--ink-2); }
.preset:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.preset .t { font-weight: 600; font-size: calc(14.5px * var(--type-scale)); display: block; }
.preset .s { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); display: block; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice { text-align: left; padding: 14px var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--line-field); background: var(--surface); color: inherit; display: flex; flex-direction: column; gap: var(--space-1); transition: border-color var(--dur), box-shadow var(--dur); }
.choice:hover { border-color: var(--ink-3); }
.choice.on, .choice[aria-checked='true'] { border-color: var(--accent); box-shadow: var(--ring); }
.choice .t { font-weight: 600; font-size: calc(14.5px * var(--type-scale)); color: var(--ink); }
.choice .s { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); }
.choice > .icon { color: var(--ink-2); }

/* Veredito */
.verdict { max-width: 900px; }
.verdict-text { margin-top: 14px; max-width: var(--reading-max); color: var(--ink-2); font-size: calc(17px * var(--type-scale)); line-height: 1.55; }
.verdict-why { margin-top: var(--space-3); color: var(--ink-2); max-width: var(--reading-max); }
.verdict-figures { margin-top: var(--space-8); padding: var(--space-5) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.verdict-state { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: 14px; font-weight: 600; }
.verdict-actions { margin-top: var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Percepção */
.icard { padding: var(--space-5); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.icard-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: calc(12.5px * var(--type-scale)); font-weight: 600; padding: 3px 9px 3px 7px; border-radius: var(--radius-round); }
.sev.critical { color: var(--neg); background: var(--neg-soft); }
.sev.attention { color: var(--warn); background: var(--warn-soft); }
.sev.positive { color: var(--pos); background: var(--pos-soft); }
.sev.info { color: var(--accent-ink); background: var(--accent-soft); }
.icard-trigger { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); }
.icard-x { margin-left: auto; color: var(--ink-3); width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; }
.icard-x:hover { background: var(--surface-2); color: var(--ink); }
.icard-title { font-size: calc(17px * var(--type-scale)); font-weight: 600; letter-spacing: -0.01em; margin-top: var(--space-3); }
.icard-obs { margin-top: 6px; color: var(--ink-2); }
.icard-cons { margin-top: var(--space-1); display: flex; gap: 6px; align-items: flex-start; color: var(--ink); }
.icard-cons svg { color: var(--ink-3); margin-top: 3px; }
.icard-goals { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.icard-alts { margin-top: 14px; border-top: 1px solid var(--line); padding-top: var(--space-3); display: flex; flex-direction: column; gap: 10px; }
.icard-alts .h { font-size: calc(12px * var(--type-scale)); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.alt { display: flex; gap: var(--space-3); align-items: flex-start; }
.alt .grow p { font-size: calc(14.5px * var(--type-scale)); }
.ichips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ichip { font-size: calc(12px * var(--type-scale)); font-weight: 500; padding: 2px 7px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); }
.ichip.good { background: var(--pos-soft); color: var(--pos); }
.icard details { margin-top: var(--space-3); font-size: calc(13.5px * var(--type-scale)); color: var(--ink-2); }
.icard summary { cursor: pointer; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: var(--space-2); min-height: 24px; }
/* a confiança à vista, fora do "Por que o Insightor diz isso", e o que uma ação faz, dito antes do clique */
.icard-conf { margin-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; }
.icard-conf .chip { flex: none; height: auto; padding: 0 var(--space-2); border: 1px solid var(--line-2); }   /* a borda existe no tema escuro, onde surface-2 some */
.alt-act { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); max-width: 15rem; }
.alt-note { margin: 0; text-align: right; }
@media (max-width: 720px) { .alt { flex-direction: column; } .alt-act { align-items: flex-start; max-width: none; } .alt-note { text-align: left; } }

/* Trilha do Início */
.trail { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: var(--space-4); padding: var(--space-6) 0; overflow-x: auto; scroll-snap-type: x proximity; }
.trail::before { content: ''; position: absolute; left: 22px; right: 22px; top: calc(var(--space-6) + 22px); height: 2px; background: var(--line-2); }
.stop { position: relative; display: flex; flex-direction: column; gap: 6px; scroll-snap-align: start; text-align: left; color: inherit; }
.stop .ring { background: var(--paper); border-radius: var(--radius-round); }
.stop .t { font-weight: 600; font-size: calc(14.5px * var(--type-scale)); margin-top: var(--space-1); }
.stop .s { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); }
.stop.today .t { color: var(--ink); }
.stop-link { display: flex; flex-direction: column; gap: 6px; text-align: left; color: inherit; border-radius: var(--radius-md); }
.stop-link:hover .t { color: var(--accent-ink); }
@media (max-width: 860px) { .trail { grid-auto-columns: minmax(160px, 70%); } }

/* Stepper e etapa */
.stepper { display: flex; flex-direction: column; gap: 2px; position: relative; }   /* o texto só para leitor de tela das etapas fica preso aqui dentro, sem alargar a página */
.stepper button { display: flex; align-items: center; gap: 10px; padding: var(--space-2) 10px; min-height: 40px; border-radius: var(--radius-md); font-size: calc(14px * var(--type-scale)); color: var(--ink-2); text-align: left; width: 100%; }
.stepper button:hover { background: var(--surface-2); }
.stepper button[aria-current='step'] { color: var(--ink); font-weight: 600; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.stepper button:disabled { opacity: 0.45; pointer-events: none; }
/* a etapa ainda fora de alcance: o mesmo desenho do item, esmaecido, sem ser um botão */
.stepper .stepper-locked { display: flex; align-items: center; gap: 10px; padding: var(--space-2) 10px; min-height: 40px; border-radius: var(--radius-md); font-size: calc(14px * var(--type-scale)); color: var(--ink-2); opacity: 0.45; }
.stepper.horizontal .stepper-locked { flex: none; white-space: nowrap; }
@media (max-width: 860px) { .stepper .stepper-locked { min-height: var(--touch-min); } }
.stepper .n { width: 24px; height: 24px; border-radius: var(--radius-round); display: grid; place-items: center; font-size: calc(12px * var(--type-scale)); font-weight: 600; background: var(--surface-3); color: var(--ink-2); flex: none; font-family: var(--font-num); }
.stepper .n.done { background: var(--pos-soft); color: var(--pos); }
.stepper button[aria-current='step'] .n { background: var(--accent); color: var(--on-accent); }
.stepper.horizontal { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
.stepper.horizontal button { width: auto; flex: none; white-space: nowrap; }
.stepper.horizontal button:focus-visible { outline-offset: -2px; }
.step-card { padding: var(--space-6); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.step-card .lead { margin-top: var(--space-2); color: var(--ink-2); font-size: calc(16px * var(--type-scale)); }
.step-body { margin-top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
/* O motivo de um botão desabilitado (DisabledReason, DESIGN.md regra 6): curto, em ink-3, colado ao botão */
.disabled-reason { font-size: calc(12.5px * var(--type-scale)); line-height: 1.4; color: var(--ink-3); max-width: 38ch; }
.step-foot .disabled-reason, .dialog-foot .disabled-reason, .sheet-foot .disabled-reason { align-self: center; text-align: right; }
.step-foot .disabled-reason { margin-left: auto; }
@media (max-width: 720px) {
  .step-foot .disabled-reason, .dialog-foot .disabled-reason, .sheet-foot .disabled-reason { flex: 1 0 100%; max-width: none; }
}
.step-foot { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
@media (max-width: 720px) { .step-card { padding: var(--space-5) var(--space-4); } }
.fact { display: flex; justify-content: space-between; gap: var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: calc(14px * var(--type-scale)); }
.fact .k { color: var(--ink-2); }
.fact .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; color: var(--ink); }

/* Planejado × realizado: o rótulo, a barra de pílula (PlanMeter, months.css), o valor e o resultado em palavras */
.planbar { display: grid; grid-template-columns: 140px 1fr 110px; align-items: center; gap: var(--space-1) var(--space-3); padding: var(--space-2) 0; font-size: calc(14px * var(--type-scale)); }
.planbar .k { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink-2); min-width: 0; }
.planbar .bar { display: block; min-width: 0; }
.planbar .v { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.planbar .v small { display: block; color: var(--ink-2); font-size: calc(12px * var(--type-scale)); }
.planbar .pb-result { grid-column: 2; display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; }
.planbar .pb-result.pos { color: var(--pos); }
.planbar .pb-result.neg { color: var(--neg); }
@media (max-width: 720px) {
  .planbar { grid-template-columns: minmax(0, 1fr) auto; }
  .planbar .bar { grid-column: 1 / -1; grid-row: 2; }
  .planbar .pb-result { grid-column: 1 / -1; grid-row: 3; }
}

/* Cascata de contribuições */
.contrib { display: flex; flex-direction: column; gap: 6px; }
.contrib-row { display: grid; grid-template-columns: 170px 1fr 110px; gap: var(--space-3); align-items: center; font-size: calc(13.5px * var(--type-scale)); }
.contrib-row .k { color: var(--ink-2); }
.contrib-row .bar { position: relative; height: 16px; }
.contrib-row .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.contrib-row .bar i.pos { background: var(--div-pos); }
.contrib-row .bar i.neg { background: var(--div-neg); }
.contrib-row .bar i.total { background: var(--ink); }
.contrib-row .v { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; }
.contrib-row.total { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 600; }
@media (max-width: 720px) { .contrib-row { grid-template-columns: minmax(0, 1fr) auto; } .contrib-row .bar { grid-column: 1 / -1; grid-row: 2; } }

/* Dica de gráfico (a moldura e as formas ficam em charts.css) */
.tip { position: absolute; z-index: var(--z-menu); pointer-events: none; min-width: 180px; max-width: 280px; padding: 10px var(--space-3); background: var(--surface-float); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); font-size: calc(12.5px * var(--type-scale)); line-height: 1.45; }
.tip-title { font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: var(--space-2); justify-content: space-between; }
.tip-row + .tip-row { margin-top: 3px; }
.tip-row .v { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.tip-row .n { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.sparkline { display: block; overflow: visible; }
.sparkline .line { stroke: var(--s1); fill: none; stroke-width: 1.5; }
.sparkline .ref { stroke: var(--s-ref); stroke-dasharray: 3 3; fill: none; }

/* ---- Sobreposições ------------------------------------------------------ */
.backdrop, .sheet-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-overlay); animation: fade-in var(--dur-slow) var(--ease); }
.sheet { position: fixed; z-index: var(--z-sheet); top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface-float); color: var(--ink); border-left: 1px solid var(--line); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slide-in var(--dur-slow) var(--ease); }
.sheet.wide { width: min(560px, 100vw); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 18px var(--space-5); border-bottom: 1px solid var(--line); }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--space-5); overscroll-behavior: contain; }
.sheet-foot { padding: 14px var(--space-5) calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.sheet.bottom { top: auto; left: 0; width: 100%; max-height: 88vh; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: slide-up var(--dur-slow) var(--ease); }
.sheet.bottom::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: var(--space-2) auto 0; flex: none; }
@media (max-width: 720px) {
  .sheet, .sheet.wide { top: auto; left: 0; width: 100%; max-height: 88vh; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: slide-up var(--dur-slow) var(--ease); }
  .sheet::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: var(--space-2) auto 0; flex: none; }
}
.dialog { position: fixed; z-index: var(--z-sheet); left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface-float); color: var(--ink); border-radius: var(--radius-xl); box-shadow: var(--shadow-3); border: 1px solid var(--line); animation: dialog-in var(--dur-slow) var(--ease); }
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog-head { padding: var(--space-5) var(--space-6) 0; display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.dialog-body { padding: var(--space-4) var(--space-6); color: var(--ink-2); }
.dialog-foot { padding: 0 var(--space-6) var(--space-6); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .dialog-head { padding: var(--space-5) var(--space-4) 0; }
  .dialog-body { padding: var(--space-4); }
  .dialog-foot { padding: 0 var(--space-4) var(--space-5); }
}
.toasts { position: fixed; z-index: var(--z-toast); left: 50%; bottom: var(--space-8); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--space-2); align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
/* um toast anterior não encobre os botões de um diálogo recém-aberto; sobre folhas, fica visível */
body:has(.dialog) .toasts { z-index: var(--z-overlay); }
.toast { pointer-events: auto; display: inline-flex; align-items: center; gap: var(--space-3); padding: 11px 14px 11px var(--space-4); border-radius: var(--radius-lg); background: var(--ink); color: var(--ink-inverse); box-shadow: var(--shadow-2); font-size: calc(14px * var(--type-scale)); font-weight: 500; max-width: min(560px, 100%); animation: toast-in var(--dur-slow) var(--ease); }
.toast button { color: var(--ink-inverse); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 24px; }
.toast-error { pointer-events: auto; box-shadow: var(--shadow-2); max-width: min(560px, 100%); animation: toast-in var(--dur-slow) var(--ease); }
.toast-error .btn { margin-left: var(--space-2); }
.toast :focus-visible { outline-color: var(--ink-inverse); }
@media (max-width: 860px) { .toasts { bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom)); } }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-md); font-size: calc(14px * var(--type-scale)); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent-ink); }
.banner.neg { background: var(--neg-soft); color: var(--neg); }
.banner .grow { color: inherit; }
.banner .btn { margin-left: auto; }
@media (max-width: 720px) { .banner { flex-wrap: wrap; } .banner .btn { margin-left: 0; } }

/* ---- Estados ------------------------------------------------------------ */
.empty { text-align: center; padding: 56px var(--space-6); border: 1px dashed var(--line-2); border-radius: var(--radius-lg); color: var(--ink-2); }
.empty .icon { color: var(--ink-3); margin: 0 auto var(--space-3); }
.empty .t { font-weight: 600; color: var(--ink); }
.empty p { margin-top: 6px; }
.empty .btn { margin-top: 14px; }
.empty.compact { padding: var(--space-8) var(--space-5); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius-md); }
.skeleton.round { border-radius: var(--radius-round); }
.skeleton-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-2); border-top-color: var(--ink); animation: spin 700ms linear infinite; flex: none; }
.errbox { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border-radius: var(--radius-lg); background: var(--neg-soft); color: var(--neg); }
.errbox .t { font-weight: 600; }
.errbox p { color: var(--neg); }
.errbox .btn { margin-left: auto; flex: none; }
@media (max-width: 720px) { .errbox { flex-wrap: wrap; } .errbox .btn { margin-left: 0; } }
.save-state { font-size: calc(13px * var(--type-scale)); color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.busy { position: relative; }
.busy::after { content: ''; position: absolute; inset: 0; background: var(--paper); opacity: 0.4; pointer-events: none; animation: fade-in var(--dur-slow) var(--ease) var(--dur-fast) both; }

/* ---- Hero do Início ----------------------------------------------------- */
.hero-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside-w); gap: var(--space-10); align-items: end; }
.hero-row:not(:has(.hero-aside)) { grid-template-columns: minmax(0, 1fr); }
.hero-aside { display: flex; flex-direction: column; gap: var(--space-3); }
@media (max-width: 1100px) { .hero-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); } }
.hero { max-width: 980px; }
.hero-title { margin-top: var(--space-4); text-wrap: pretty; }
.hero-title .hl { white-space: nowrap; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hero-sub { margin-top: 18px; max-width: 760px; color: var(--ink-2); font-size: calc(17px * var(--type-scale)); line-height: 1.55; }
.hero-sub strong { color: var(--ink); font-weight: 600; }

/* ---- Movimento ---------------------------------------------------------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
/* backwards: depois de entrar, o elemento não guarda transform (que prenderia diálogos e folhas fixos dentro dele) */
/* A saída de diálogo e folha espelha a entrada em dur-fast (lib/motion.js, leave(): uma cópia inerte com a classe
   leaving fica no lugar enquanto a animação roda) */
.leaving { pointer-events: none; }
.leaving .backdrop, .leaving .sheet-backdrop { animation: fade-out var(--dur-fast) var(--ease) forwards; }
.leaving .dialog { animation: dialog-out var(--dur-fast) var(--ease) forwards; }
.leaving .sheet { animation: slide-out var(--dur-fast) var(--ease) forwards; }
.leaving .sheet.bottom { animation: slide-down var(--dur-fast) var(--ease) forwards; }
@media (max-width: 720px) { .leaving .sheet, .leaving .sheet.wide { animation: slide-down var(--dur-fast) var(--ease) forwards; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes dialog-out { to { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } }
@keyframes slide-out { to { transform: translateX(24px); opacity: 0; } }
@keyframes slide-down { to { transform: translateY(40px); opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise var(--dur-slow) var(--ease) backwards; }
/* O conteúdo principal (app.js): a troca de rota entra com rise; a troca de aba da mesma área, só com o fade em dur */
.page-in { min-width: 0; }
.page-in.tab-in { animation: fade-in var(--dur) var(--ease) backwards; }
.rise-2 { animation: rise var(--dur-slow) var(--ease) calc(var(--dur-fast) / 2) backwards; }
.rise-3 { animation: rise var(--dur-slow) var(--ease) var(--dur-fast) backwards; }
.rise-4 { animation: rise var(--dur-slow) var(--ease) calc(var(--dur-fast) * 1.5) backwards; }
/* no toque: links soltos (fora de frases), voltar, campos e etapas também com 44 px */
@media (max-width: 860px) { .link { min-height: var(--touch-min); } :is(p, li, dd, .field-hint) .link { min-height: 0; } .back { min-height: var(--touch-min); } .input, .select { height: var(--touch-min); } .stepper button { min-height: var(--touch-min); } }
@media (max-width: 860px) { .menu-item { min-height: var(--touch-min); } .icard-x { width: var(--touch-min); height: var(--touch-min); } .avatar { width: var(--touch-min); height: var(--touch-min); } .toast button { min-height: var(--touch-min); } }
