/* Camada premium (projeto 8A, 13/10/2026) — spec
   docs/superpowers/specs/2026-10-13-design-base-design.md.
   Escopo: .workspace, .sidebar, #modal:not(.document-modal), #navigation-modal, .toast.
   Não redefine :root (a reentrada herda os tokens globais) e não toca a tela de PIN
   nem a prévia de documentos. Prefixo "html body" só para vencer a cascata antiga
   sem !important. Desfazer = remover este arquivo do index.html e do sw.js. */

/* ---------- Tokens ---------- */
html body,
html body :is(.workspace, .sidebar, #modal, #navigation-modal, .toast) {
  --p-canvas: #f4f7f5;
  --p-surface: #ffffff;
  --p-surface-2: #f7faf8;
  --p-line-soft: #e8eeea;
  --p-ink-2: #3c4a43;
  --p-focus: #286443;
  --p-s1: 0.25rem;
  --p-s2: 0.5rem;
  --p-s3: 0.75rem;
  --p-s4: 1rem;
  --p-s5: 1.25rem;
  --p-s6: 1.5rem;
  --p-s7: 2rem;
  --p-s8: 2.5rem;
  --p-s9: 3.5rem;
  --p-r-control: 10px;
  --p-r-card: 16px;
  --p-r-sheet: 22px;
  --p-shadow-1: 0 1px 2px color-mix(in srgb, var(--forest) 6%, transparent),
    0 1px 1px color-mix(in srgb, var(--forest) 3%, transparent);
  --p-shadow-2: 0 10px 30px color-mix(in srgb, var(--forest) 8%, transparent),
    0 2px 6px color-mix(in srgb, var(--forest) 5%, transparent);
  /* Springs (8C): amortecimento 1 / resposta 0,35 s (≈ 520 ms) e folha 0,86 / 0,32 s (≈ 450 ms),
     calculados por TerraMotion.spring (motion.js). */
  --p-spring: linear(0, 0.035, 0.116, 0.218, 0.325, 0.428, 0.522, 0.605, 0.677, 0.737, 0.788, 0.83, 0.864, 0.892, 0.914, 0.932, 0.947, 0.958, 0.967, 0.974, 0.98, 0.984, 0.988, 0.991, 0.993, 0.994, 0.996, 0.997, 0.997, 0.998, 0.998, 0.999, 1);
  --p-spring-sheet: linear(0, 0.033, 0.111, 0.214, 0.325, 0.435, 0.537, 0.629, 0.708, 0.775, 0.83, 0.875, 0.91, 0.937, 0.958, 0.974, 0.985, 0.993, 0.998, 1.002, 1.004, 1.005, 1.005, 1.005, 1.005, 1.004, 1.004, 1.003, 1.002, 1.002, 1.002, 1.001, 1);
  /* Régua de escala das plantas topográficas: 0 — 50 — 100 m. */
  --p-scale: linear-gradient(
    90deg,
    var(--forest) 0 25%,
    var(--survey) 25% 50%,
    var(--forest) 50% 75%,
    var(--survey) 75% 100%
  );
}
html body {
  background: var(--p-canvas);
}

/* ---------- Página ---------- */
html body .workspace main#content {
  max-width: 1280px;
  padding: var(--p-s7) var(--p-s7) var(--p-s9);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.55;
}
html body .workspace .page-heading {
  gap: var(--p-s5);
  margin-bottom: var(--p-s7);
}
html body .workspace .page-heading h1 {
  position: relative;
  font-size: 1.875rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--forest);
  padding-bottom: var(--p-s4);
  margin: 0;
}
/* Assinatura: régua de escala sob o título (único elemento decorativo). */
html body .workspace .page-heading h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 56px;
  height: 4px;
  border-radius: 1px;
  background-image: var(--p-scale);
}
html body .workspace .page-heading p {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--p-ink-2);
  margin-top: var(--p-s3);
  max-width: 46rem;
}
html body .workspace :is(h2, h3) {
  letter-spacing: -0.01em;
  line-height: 1.25;
}
html body .workspace .report-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--forest);
  margin: var(--p-s8) 0 var(--p-s4);
}

/* ---------- Menu lateral (computador) ---------- */
@media (min-width: 651px) {
  html body .sidebar {
    width: 15.5rem;
    background: var(--forest);
    background-image: none;
    border-radius: var(--p-r-sheet);
    padding: var(--p-s6) var(--p-s3);
    box-shadow: var(--p-shadow-2);
  }
  html body .sidebar .brand {
    margin: 0 var(--p-s3) var(--p-s7);
  }
  html body .sidebar .brand > span {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: #b9deb9cc;
  }
  html body .sidebar nav {
    gap: 2px;
  }
  html body .sidebar .nav-button {
    position: relative;
    min-height: 44px;
    padding: 0.6rem 0.85rem;
    border-radius: var(--p-r-control);
    color: #dbe7df;
    font-size: 0.875rem;
    font-weight: 500;
    background: transparent;
    box-shadow: none;
  }
  html body .sidebar .nav-button:hover:not(.active) {
    background: #ffffff0f;
    color: #ffffff;
  }
  html body .sidebar .nav-button.active {
    background: #ffffff17;
    color: #ffffff;
    font-weight: 600;
    box-shadow: none;
  }
  html body .sidebar .nav-button.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--signal);
  }
  html body .workspace {
    margin-left: 17.5rem;
  }
}

/* ---------- Topo ---------- */
html body .workspace .topbar {
  min-height: 64px;
  padding: var(--p-s3) var(--p-s7);
  background: #f4f7f5d9;
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--forest) 6%, transparent);
}
html body .workspace .breadcrumb {
  font-size: 0.8125rem;
  color: var(--muted);
}
html body .workspace .breadcrumb strong {
  color: var(--forest);
  font-weight: 600;
}
html body .workspace .top-actions {
  gap: var(--p-s2);
}
html body .workspace .local-label {
  font-size: 0.8125rem;
  color: var(--muted);
}
html body .workspace .backup-chip {
  display: inline-block;
  min-height: 40px;
  line-height: 38px;
  white-space: nowrap;
  padding: 0 0.95rem;
  border: 1px solid #6b332a59;
  border-radius: 999px;
  background: #fbf3f1;
  color: var(--earth);
  font-size: 0.8125rem;
  font-weight: 600;
}
html body .workspace .backup-chip::before {
  content: "";
  display: inline-block;
  vertical-align: middle;
  margin: -2px 0.45rem 0 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--earth);
}
html body .workspace .backup-chip[hidden] {
  display: none;
}

/* ---------- Abas: controle segmentado único ---------- */
html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tabs, [data-wf-tabs]) {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
  margin-bottom: var(--p-s6);
  border: 1px solid var(--p-line-soft);
  border-radius: 999px;
  background: var(--p-surface-2);
  scrollbar-width: none;
}
html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tab, [data-wf-tabs] [role="tab"]) {
  flex: none;
  min-height: 40px;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--p-ink-2);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: none;
}
html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tab.active, [data-wf-tabs] [role="tab"][aria-selected="true"]) {
  background: var(--p-surface);
  color: var(--forest);
  font-weight: 600;
  box-shadow: var(--p-shadow-1), 0 0 0 1px var(--p-line-soft);
}
/* O trilho rola na horizontal: o contorno de foco fica por dentro para não ser cortado. */
html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tab, [data-wf-tabs] [role="tab"]):focus-visible {
  outline-offset: -2px;
}
@media (forced-colors: active) {
  html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tab.active, [data-wf-tabs] [role="tab"][aria-selected="true"]) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

/* ---------- Indicadores ---------- */
html body .workspace :is(.status-cards, .ov-strip, .report-kpis, .metrics) {
  gap: var(--p-s3);
}
html body .workspace :is(.ov-kpi, .status-card, .report-kpi, .metric) {
  min-height: 0;
  padding: var(--p-s4) 1.125rem;
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-card);
  background: var(--p-surface);
  box-shadow: var(--p-shadow-1);
  text-align: left;
}
html body .workspace :is(.ov-kpi, .status-card, .report-kpi, .metric) :is(span, .label) {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--p-ink-2);
}
html body .workspace :is(.ov-kpi, .status-card, .report-kpi, .metric) :is(strong, .value) {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.625rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}
html body .workspace :is(.ov-kpi, .status-card, .report-kpi, .metric) small {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted);
}
/* Atenção: borda terra à esquerda, sem fundo rosado. */
html body .workspace :is(.ov-kpi.alerta, .status-card.attention) {
  background: var(--p-surface);
  border-color: var(--p-line-soft);
  box-shadow: inset 3px 0 0 var(--earth), var(--p-shadow-1);
}
html body .workspace :is(.ov-kpi.alerta, .status-card.attention) strong {
  color: var(--earth);
}
html body .workspace .metric.emphasis {
  background: var(--forest);
  border-color: var(--forest);
}
html body .workspace .metric.emphasis :is(span, .label, strong, .value, small) {
  color: #ffffff;
}
html body .workspace button:is(.ov-kpi, .status-card):hover {
  border-color: #28644340;
}

/* Indicadores dentro de um painel ficam planos (sem caixa dentro de caixa). */
html body .workspace :is(.panel, .financial-entry) :is(.metric:not(.emphasis), .report-kpi) {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: var(--p-s3) var(--p-s4);
}
/* Destaque dentro de painel (Cobranças): só o preenchimento floresta, sem cartão dentro de cartão. */
html body .workspace :is(.panel, .financial-entry) .metric.emphasis {
  border: 0;
  border-radius: var(--p-r-control);
  box-shadow: none;
  padding: var(--p-s3) var(--p-s4);
}
html body .workspace :is(.panel, .financial-entry) .metric + .metric {
  border-left: 1px solid var(--p-line-soft);
}

/* ---------- Painéis ---------- */
html body .workspace .panel {
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-card);
  background: var(--p-surface);
  box-shadow: var(--p-shadow-1);
}
html body .workspace .panel-header {
  border-bottom: 1px solid var(--p-line-soft);
}
html body .workspace .panel-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--forest);
}
html body .workspace .panel-header small {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- Tabelas ---------- */
html body :is(.workspace, #modal:not(.document-modal)) table th {
  background: var(--p-surface-2);
  color: var(--p-ink-2);
  font-family: var(--font-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--p-line-soft);
}
html body :is(.workspace, #modal:not(.document-modal)) table td {
  border-bottom: 1px solid var(--p-line-soft);
  line-height: 1.35;
}
html body .workspace :is(.services-table, .quote-table) td {
  padding-block: 0.85rem;
}
html body .workspace table tbody tr:hover {
  background: var(--p-surface-2);
}
html body :is(.workspace, #modal:not(.document-modal)) :is(td.money, .money) {
  font-variant-numeric: tabular-nums;
}

/* ---------- Botões ---------- */
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .button {
  min-height: 40px;
  padding: 0.45rem 1.05rem;
  line-height: 1.25;
  border-radius: var(--p-r-control);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--p-surface);
  color: var(--forest);
  box-shadow: var(--p-shadow-1);
}
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .button:hover {
  border-color: #28644366;
}
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .button.primary {
  background: var(--forest);
  border-color: var(--forest);
  color: #ffffff;
}
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .button.primary:hover {
  background: color-mix(in srgb, var(--forest) 86%, #000);
}
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .button.danger-text {
  color: #a3342a;
  border-color: color-mix(in srgb, #a3342a 35%, var(--line));
}
html body :is(.workspace, #modal:not(.document-modal)) .quote-section-nav .button {
  font-size: 0.75rem;
}
html body :is(.workspace, #modal:not(.document-modal)) .template-row .button {
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0.5rem;
}
html body :is(.workspace, #modal:not(.document-modal)) .text-button {
  color: var(--green);
  font-weight: 600;
}
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .icon-button {
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--p-r-control);
  border: 1px solid var(--line);
  background: var(--p-surface);
}

/* ---------- Campos ---------- */
html body :is(.workspace, #modal:not(.document-modal)) .field {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--p-ink-2);
}
/* A busca tem a borda no rótulo .search; o campo interno fica sem moldura. */
html body .workspace .search input {
  border: 0;
  min-height: 0;
  background: transparent;
  box-shadow: none;
}
html body .workspace .search {
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: var(--p-r-control);
  background: var(--p-surface);
}
html body :is(.workspace, #modal:not(.document-modal)) :is(.field, .toolbar, .finance-picker) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.search input), select, textarea) {
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: var(--p-r-control);
  background: var(--p-surface);
  color: var(--ink);
  font-weight: 400;
}
html body :is(.workspace, #modal:not(.document-modal)) [aria-invalid="true"],
html body :is(.workspace, #modal:not(.document-modal)) :is(.field, .toolbar, .finance-picker) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.search input), select, textarea)[aria-invalid="true"] {
  border-color: var(--earth);
}
html body :is(.workspace, #modal:not(.document-modal)) .form-error {
  color: var(--earth);
}

/* ---------- Selos ---------- */
html body .workspace .badge,
html body #modal:not(.document-modal) .badge {
  min-height: 24px;
  padding: 0 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 24px;
}

/* ---------- Avisos e estados vazios ---------- */
html body :is(.workspace, #modal:not(.document-modal)) .notice {
  border: 0;
  border-left: 3px solid var(--green);
  border-radius: var(--p-r-control);
  background: var(--p-surface-2);
  color: var(--p-ink-2);
  font-size: 0.875rem;
  line-height: 1.5;
}
html body :is(.workspace, #modal:not(.document-modal)) .notice.pending {
  border-left-color: var(--survey);
}
html body :is(.workspace, #modal:not(.document-modal)) .notice.blue {
  color: var(--navy);
}
/* 14/10/2026 (spec §2.5): o aviso de "Definir valor" sozinha entra com leveza; sem movimento sob reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  html body #modal .notice[data-contract-alone]:not([hidden]) {
    animation: contract-alone-in 220ms ease-out both;
  }
}
@keyframes contract-alone-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
html body :is(.workspace, #modal:not(.document-modal)) .context-note {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}
html body :is(.workspace, #modal:not(.document-modal)) .empty {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- Ficha (diálogo) ---------- */
html body #modal:not(.document-modal) {
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-sheet);
  background: var(--p-surface);
  box-shadow: var(--p-shadow-2);
}
html body #modal:not(.document-modal)::backdrop {
  background: color-mix(in srgb, var(--forest) 32%, transparent);
}
/* Régua de escala menor (32 × 3 px) no topo do cabeçalho da ficha. */
html body #modal:not(.document-modal) .modal-top > div::before {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  margin-bottom: var(--p-s2);
  border-radius: 1px;
  background-image: var(--p-scale);
}
html body #modal:not(.document-modal) .modal-top {
  background: var(--p-surface);
}
html body #modal:not(.document-modal) #modal-title {
  font-size: 1.375rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--forest);
}
@media (max-width: 640px) {
  /* Folha inferior de largura total no celular. */
  html body #modal:not(.document-modal) {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    inset-inline: 0;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--p-r-sheet) var(--p-r-sheet) 0 0;
    border-bottom: 0;
    padding-bottom: calc(var(--p-s6) + env(safe-area-inset-bottom));
  }
}

/* ---------- Aviso rápido ---------- */
html body .toast {
  border-radius: 12px;
  background: var(--forest);
  color: #ffffff;
  font-size: 0.875rem;
  box-shadow: var(--p-shadow-2);
}

/* ---------- Dock do celular ---------- */
@media (max-width: 650px) {
  html body .workspace main#content {
    padding: var(--p-s6) var(--p-s4) var(--p-s9);
  }
  html body .workspace .page-heading h1 {
    font-size: 1.5rem;
  }
  html body .workspace .topbar {
    padding: var(--p-s3) var(--p-s4);
  }
  html body .sidebar .nav-button {
    min-height: 52px;
    padding-inline: 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
  }
  html body .workspace .top-actions {
    flex-wrap: wrap;
    row-gap: var(--p-s2);
  }
  html body .workspace .backup-chip-extra {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  html body .workspace .backup-chip {
    padding: 0 0.75rem;
  }
  /* O rótulo "Pessoa ativa" fica oculto no celular; sem o vão, o seletor cabe na linha. */
  html body .workspace .role-label {
    gap: 0;
  }
  /* Rótulo curto só no dock; o nome da página (labels) não muda. */
  html body .sidebar .nav-button[data-short-label] .nav-label {
    display: none;
  }
  html body .sidebar .nav-button[data-short-label]::after {
    content: attr(data-short-label);
  }
  html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) :is(.button, .icon-button),
  html body :is(.workspace, #modal:not(.document-modal)) :is(.module-tab, [data-wf-tabs] [role="tab"]) {
    min-height: 44px;
  }
  html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) .icon-button {
    min-width: 44px;
  }
  html body :is(.workspace, #modal:not(.document-modal)) .quote-section-nav .button {
    min-width: 0;
    padding: 0.5rem 0.2rem;
  }
  html body .workspace .backup-chip {
    min-height: 44px;
  }
}

/* Dock em telas de 360px ou menos: cada coluna tem pelo menos a largura do nome,
   para "Planejamento" caber inteiro sem diminuir a letra. */
@media (max-width: 360px) {
  html body .sidebar {
    inset-inline: 0.25rem;
    padding-inline: 0.2rem;
  }
  html body .sidebar nav {
    grid-template-columns: repeat(5, minmax(max-content, 1fr));
    gap: 0;
  }
  html body .sidebar .nav-button {
    padding-inline: 0;
  }
}

/* ---------- Relatórios e painéis (projeto 8B, 13/10/2026) ----------
   Spec docs/superpowers/specs/2026-10-13-relatorios-paineis-design.md. Cores dos gráficos
   validadas com dataviz/scripts/validate_palette.js: floresta #1f6b40 e areia #bd8743. */

/* Faixa de indicadores: um painel; cada célula ocupa 3 linhas da grade (rótulo, valor, nota). */
html body .workspace .kpi-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0;
  margin-bottom: var(--p-s6);
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-card);
  background: var(--p-surface);
  box-shadow: var(--p-shadow-1);
  overflow: hidden;
}
html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0.3rem;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: var(--p-s4) 1.125rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  /* Linhas finas entre células; a faixa corta as da borda (overflow). */
  box-shadow: -1px 0 0 var(--p-line-soft), 0 -1px 0 var(--p-line-soft);
  /* Sem container-type: a contenção de layout desligaria o subgrid. */
  text-align: left;
}
html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) > span {
  align-self: start;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--p-ink-2);
}
html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) > strong {
  margin: 0;
  /* Valor solto: algarismos proporcionais (tabular só em colunas). */
  font-variant-numeric: normal;
  font-size: 1.5rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
/* Faixa com valores em reais: colunas mais largas para o valor caber numa linha. */
html body .workspace .kpi-band.has-money {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
}
/* Sete indicadores: 4 + 3 em vez de 5 + 2 (sem célula órfã). */
html body .workspace .kpi-band[data-n="7"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}
html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) > small {
  align-self: start;
  margin: 0;
}
html body .workspace .kpi-band > :is(.report-kpi.attention, .ov-kpi.alerta) > strong {
  color: var(--earth);
}
html body .workspace .kpi-band > button.ov-kpi:hover {
  background: var(--p-surface-2);
}

/* Barras de ranking: sem trilho, nome inteiro, cor única. */
html body .workspace .report-card {
  gap: 0.15rem;
}
html body .workspace .report-card h3 {
  margin: 0 0 var(--p-s2);
  font-size: 1rem;
  font-weight: 700;
  color: var(--forest);
}
/* As barras de um painel compartilham as colunas (subgrid): todas começam no mesmo ponto. */
html body .workspace :is(.report-card, .report-card-bars):has(> .report-bar) {
  display: grid;
  grid-template-columns: fit-content(15rem) minmax(2.5rem, 1fr) auto;
  column-gap: var(--p-s3);
  align-content: start;
}
html body .workspace :is(.report-card, .report-card-bars):has(> .report-bar) > :not(.report-bar) {
  grid-column: 1 / -1;
}
html body .workspace .report-bar {
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  gap: var(--p-s3);
  align-items: center;
  padding-block: 0.3rem;
  font-size: 0.8125rem;
}
html body .workspace .report-bar > span {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  /* Quebra só entre palavras (sem cortar "Georreferenciamento"). */
  overflow-wrap: normal;
  hyphens: manual;
  line-height: 1.3;
  color: var(--p-ink-2);
}
html body .workspace .report-bar-track {
  height: 8px;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
html body .workspace .report-bar-track i {
  height: 8px;
  border-radius: 0 4px 4px 0;
  background: #1f6b40;
}
html body .workspace .report-bar > strong {
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
html body .workspace .report-card-bars {
  max-width: 44rem;
  padding: var(--p-s2) var(--p-s5) var(--p-s4);
}

/* Gráfico mensal: grade fina sólida, rótulos de 12px, alvo por mês. */
html body .workspace .report-chart {
  width: 100%;
  height: auto;
  overflow: visible;
  print-color-adjust: exact;
}
html body .workspace .report-chart .chart-ticks line {
  stroke: var(--p-line-soft);
  stroke-width: 1;
}
html body .workspace .report-chart .chart-labels text,
html body .workspace .report-chart .chart-month-label {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
html body .workspace .report-chart .chart-labels text {
  paint-order: stroke;
  stroke: var(--p-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
html body .workspace .report-chart .chart-month-label.atual {
  fill: var(--ink);
  font-weight: 700;
}
html body .workspace .report-chart .chart-hit {
  fill: transparent;
}
html body .workspace .report-chart .chart-month {
  cursor: pointer;
  outline: none;
}
html body .workspace .report-chart .chart-month:is(:hover, :focus-visible) .chart-hit {
  fill: color-mix(in srgb, var(--forest) 5%, transparent);
}
/* Mês filtrado no detalhe do período: fundo suave fixo. */
html body .workspace .report-chart .chart-month.selecionado .chart-hit {
  fill: color-mix(in srgb, var(--forest) 8%, transparent);
}
html body .workspace .report-chart .chart-month:focus-visible .chart-hit {
  stroke: var(--p-focus);
  stroke-width: 2;
}
html body .workspace .chart-wrap:hover .chart-bar-mark {
  opacity: 1;
}
html body .workspace .chart-wrap:has(.chart-month:hover) .chart-month:not(:hover) .chart-bar-mark {
  opacity: 0.45;
}
html body .workspace .chart-tip {
  display: grid;
  gap: 0.2rem;
  z-index: 2;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-control);
  background: var(--p-surface);
  color: var(--ink);
  box-shadow: var(--p-shadow-2);
  font-size: 0.8125rem;
  white-space: nowrap;
}
html body .workspace .chart-tip[hidden] {
  display: none;
}
html body .workspace .chart-tip-head {
  color: var(--muted);
  font-size: 0.75rem;
}
html body .workspace .chart-tip-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
/* Traço da cor da série (não caixa cheia). */
html body .workspace .chart-tip-row i {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}
html body .workspace .chart-tip-row strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
html body .workspace .chart-tip-row span {
  color: var(--muted);
}
html body .workspace .chart-legend {
  margin-top: var(--p-s3);
  color: var(--p-ink-2);
}
html body .workspace .chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
/* Seção do período: título e seletores na mesma linha (a impressão esconde só os seletores). */
html body .workspace .report-period-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--p-s3) var(--p-s5);
  margin: var(--p-s8) 0 var(--p-s5);
}
html body .workspace .report-period-head .report-period-title {
  margin: 0;
  font-size: 1.375rem;
}
html body .workspace .report-period-head .toolbar {
  margin: 0;
}
/* Saldo do período: divisórias de altura inteira, como a faixa. */
html body .workspace .financial-entry .metrics {
  gap: 0;
  margin-bottom: 0;
  align-items: stretch;
}
/* Sete indicadores: o último completa a linha (sem célula vazia). */
html body .workspace .kpi-band[data-n="7"] > :last-child {
  grid-column: span 2;
}
/* Foco dos indicadores por dentro da faixa (a faixa corta o que passa da borda). */
html body :is(.workspace, #modal:not(.document-modal)) .kpi-band > :is(.report-kpi, .ov-kpi):focus-visible {
  outline-offset: -3px;
}
/* Mês do gráfico: o traço do retângulo de acerto é o foco; sem segundo contorno. */
html body :is(.workspace, #modal:not(.document-modal)) .report-chart .chart-month:focus-visible {
  outline: none;
}

/* Tabelas com ações (Acompanhamento, Cobranças) e recebimentos: rolam na horizontal em vez
   de partir palavras e botões. */
@media (min-width: 721px) {
  html body .workspace .billing-panel table {
    min-width: 62rem;
  }
  /* Datas, valor e ações numa linha; nomes, código e prazos podem quebrar entre palavras. */
  html body .workspace .funnel-panel td:is([data-label="Orçamento"], [data-label="Valor"]),
  html body .workspace .billing-panel td:is([data-label="Parcela"], [data-label="Vencimento"], [data-label="Atraso"], [data-label="Em aberto"]) {
    white-space: nowrap;
  }
}
html body .workspace :is(.funnel-panel, .billing-panel, .receipt-panel) td {
  overflow-wrap: normal;
  hyphens: manual;
}
html body .workspace :is(.funnel-actions, .billing-actions) .button {
  white-space: nowrap;
}
html body .workspace .funnel-actions {
  flex-direction: column;
  align-items: stretch;
}
html body .workspace .funnel-panel td small {
  display: block;
  color: var(--muted);
}
/* A coluna de ações fica fixa à direita quando a tabela rola na horizontal. */
@media (min-width: 721px) {
  html body .workspace :is(.funnel-panel, .billing-panel) :is(th, td):last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: var(--p-surface);
    box-shadow: -1px 0 0 var(--p-line-soft);
  }
  html body .workspace :is(.funnel-panel, .billing-panel) th:last-child {
    background: var(--p-surface-2);
  }
}
html body .workspace .receipt-panel table {
  min-width: 34rem;
}
html body .workspace .receipt-panel td:first-child,
html body .workspace .receipt-panel td.money {
  white-space: nowrap;
}
html body .workspace .receipt-panel .panel-header .badge {
  flex: none;
}

/* Funil sem propostas no período. */
html body .workspace .funnel-empty {
  padding: var(--p-s6) var(--p-s5);
  margin-bottom: var(--p-s6);
}
html body .workspace .funnel-empty h3 {
  margin: 0 0 var(--p-s2);
  font-size: 1rem;
  font-weight: 700;
  color: var(--forest);
}
html body .workspace .funnel-empty p {
  margin: 0;
  max-width: 60ch;
  color: var(--p-ink-2);
  font-size: 0.875rem;
}

/* Tempo: blocos em painéis e títulos na escala de seção. */
html body .workspace .time-summary {
  gap: var(--p-s4);
  align-items: start;
}
html body .workspace :is(.time-summary, .time-summary + .operation-panel) :is(th, td):not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
html body .workspace :is(.time-summary > div, .time-summary ~ .operation-panel) {
  min-width: 0;
  padding: var(--p-s5);
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-card);
  background: var(--p-surface);
  box-shadow: var(--p-shadow-1);
}
html body .workspace .time-summary ~ .operation-panel {
  margin-top: var(--p-s4);
}
html body .workspace :is(.time-summary, .time-summary ~ .operation-panel) h2 {
  margin: 0 0 var(--p-s1);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--forest);
}
html body .workspace .time-summary p {
  margin: 0 0 var(--p-s3);
  font-size: 0.8125rem;
  color: var(--p-ink-2);
}

/* Visão geral: "Conferir notificações" cabe numa linha. */
@media (min-width: 1051px) {
  html body .workspace .personal-columns {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(14rem, 0.6fr);
  }
}
html body .workspace [data-notifications] {
  white-space: nowrap;
}

@media (max-width: 650px) {
  html body .workspace .kpi-band,
  html body .workspace .kpi-band.has-money {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) {
    padding: var(--p-s3) var(--p-s4);
  }
  html body .workspace .kpi-band > :is(.report-kpi, .ov-kpi) > strong {
    font-size: 1.25rem;
  }
  html body .workspace :is(.report-card, .report-card-bars):has(> .report-bar) {
    grid-template-columns: fit-content(11rem) minmax(2rem, 1fr) auto;
  }
  html body .workspace .time-summary {
    grid-template-columns: 1fr;
  }
}

/* ---------- Movimento (projeto 8C, 13/10/2026) ----------
   Spec docs/superpowers/specs/2026-10-13-movimento-design.md; animações em motion.js. */
/* Indicador da aba ativa que desliza entre abas. */
html body :is(.workspace, #modal:not(.document-modal)) .module-tabs {
  position: relative;
}
html body :is(.workspace, #modal:not(.document-modal)) .module-tabs > .module-tab {
  position: relative;
  z-index: 1;
}
html body .workspace .tab-glide {
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  background: var(--p-surface);
  box-shadow: var(--p-shadow-1), 0 0 0 1px var(--p-line-soft);
  transform-origin: 0 50%;
  pointer-events: none;
}
html body .workspace .module-tabs.is-gliding > .module-tab.active {
  background: transparent;
  box-shadow: none;
}
/* Barra do menu lateral que desliza até o novo item (computador). */
@media (min-width: 651px) {
  html body .sidebar nav {
    position: relative;
  }
  html body .sidebar .nav-glide {
    position: absolute;
    left: 0;
    z-index: 1;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--signal);
    pointer-events: none;
  }
  html body .sidebar nav.is-gliding .nav-button.active::before {
    opacity: 0;
  }
}
/* Barras crescem a partir da base. */
html body .workspace .report-chart .chart-bar-mark {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
html body .workspace .report-bar-track i {
  transform-origin: 0 50%;
}
/* Aviso rápido: sobe com spring e sai pelo mesmo caminho. */
html body .toast {
  transition:
    opacity 180ms ease-out,
    transform 520ms var(--p-spring);
}
/* Selo de backup: aparece com escala, a partir do próprio selo. */
html body .workspace .backup-chip:not([hidden]) {
  transition:
    opacity 180ms ease-out,
    transform 370ms var(--p-spring);
}
@starting-style {
  html body .workspace .backup-chip:not([hidden]) {
    opacity: 0;
    transform: scale(0.92);
  }
}
/* Folha inferior (celular): entra de baixo, sai para baixo, arrasta pelo cabeçalho.
   Com movimento reduzido valem as regras gerais do diálogo (só esmaecimento). */
@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  html body #modal:not(.document-modal) {
    opacity: 1;
    transform: translateY(100%);
    transition:
      transform 450ms var(--p-spring-sheet),
      overlay 450ms allow-discrete,
      display 450ms allow-discrete;
  }
  html body #modal:not(.document-modal)[open] {
    transform: none;
  }
  @starting-style {
    html body #modal:not(.document-modal)[open] {
      transform: translateY(100%);
    }
  }
  html body #modal:not(.document-modal)[open]::backdrop {
    opacity: var(--sheet-dim, 1);
  }
  @starting-style {
    html body #modal:not(.document-modal)[open]::backdrop {
      opacity: 0;
    }
  }
}
@media (max-width: 640px) {
  html body #modal:not(.document-modal) .modal-top {
    padding-top: 0.9rem;
    cursor: grab;
    touch-action: none;
  }
  /* Alça: mesma da folha do menu "Mais". */
  html body #modal:not(.document-modal) .modal-top::before {
    content: "";
    position: absolute;
    top: 0.35rem;
    left: 50%;
    width: 2.5rem;
    height: 0.3rem;
    margin-left: -1.25rem;
    border-radius: 1rem;
    background: var(--line);
  }
}

/* ---------- Resposta ao toque ---------- */
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal, .sidebar) :is(.button, .module-tab, [role="tab"], .nav-button, .icon-button):active {
  transform: scale(0.97);
  transition: transform 100ms ease-out;
}

/* ---------- Foco visível ---------- */
html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) :focus-visible {
  outline: 2px solid var(--p-focus);
  outline-offset: 2px;
}
/* Menu floresta no computador: foco claro. No celular o dock é claro: foco floresta. */
html body .sidebar :focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
@media (max-width: 650px) {
  html body .sidebar :focus-visible {
    outline-color: var(--forest);
  }
}

/* ---------- Preferências de acessibilidade ---------- */
@media (prefers-reduced-motion: reduce) {
  html body :is(.workspace, #modal:not(.document-modal), #navigation-modal, .sidebar) :is(.button, .module-tab, [role="tab"], .nav-button, .icon-button):active {
    transform: none;
    transition: none;
  }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  html body .workspace .topbar {
    background: var(--p-canvas);
    backdrop-filter: none;
  }
}
@media (prefers-contrast: more) {
  html body :is(.workspace, #modal:not(.document-modal)) :is(.panel, .ov-kpi, .status-card, .report-kpi, .metric, .module-tabs) {
    border-color: var(--control-border);
  }
  html body :is(.workspace, #modal:not(.document-modal), #navigation-modal) :is(.button, .icon-button) {
    border-color: var(--control-border);
  }
}
@media print {
  html body .workspace .page-heading h1::after {
    display: none;
  }
  html body .workspace {
    margin-left: 0;
  }
  html body .workspace main#content {
    max-width: none;
    padding: 0;
  }
  html body .workspace .metric.emphasis {
    background: #ffffff;
    border-color: var(--line);
  }
  html body .workspace .metric.emphasis :is(strong, .value) {
    color: var(--ink);
  }
  html body .workspace .metric.emphasis :is(span, .label, small) {
    color: var(--muted);
  }
}

/* Código de ativação do PIN em Acessos (13/10/2026, 9A). */
.pin-invite-panel {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  justify-items: start;
}
.pin-invite-code {
  margin: 8px 0;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

/* Campos opcionais da forma de pagamento (14/10/2026, 9B 2.1): conta em Pix e Transferência,
   cheque em Cheque. Entram e saem sem deslocar o formulário de forma brusca. */
.payment-field[hidden] {
  display: none;
}
.payment-field:not([hidden]) {
  animation: payment-field-in 180ms ease-out both;
}
@keyframes payment-field-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .payment-field:not([hidden]) {
    animation: none;
  }
}

/* Acabamento 9B (14/10/2026): hierarquia da pergunta "Enviou a mensagem?" e selo "Nova versão em rascunho"
   que pode quebrar linha sem esmagar o ponto nem a altura do selo. */
html body #modal .whatsapp-confirm .context-note {
  margin: 0 0 0.875rem;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--p-ink, var(--text));
}
html body #modal .whatsapp-confirm .form-actions {
  margin-top: 0;
  justify-content: flex-start;
}
html body .workspace .funnel-panel td .badge {
  align-items: flex-start;
  margin-top: 0.375rem;
  padding-block: 0.25rem;
  border-radius: 12px;
  white-space: normal;
  line-height: 1.35;
}
html body .workspace .funnel-panel td .badge::before {
  flex: none;
  margin-top: 0.4em;
}
html body #modal [data-backup-form] .form-grid {
  align-items: end;
}
html body #modal [data-backup-progress]:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
html body #modal [data-backup-progress]:not([hidden])::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: backup-spin 800ms linear infinite;
}
@keyframes backup-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  html body #modal [data-backup-progress]:not([hidden])::before {
    animation: none;
    border-top-color: var(--border);
    background: var(--primary);
    opacity: 0.6;
  }
}

/* 10A (19/10/2026): menos espaço em branco, pedido de Samuel.
   Só em tela (não impressão) e em telas largas (651px ou mais); o celular mantém as medidas acima. Sem novos tokens. */
@media screen and (min-width: 651px) {
  /* Topo e laterais: 2rem para 1.5rem (-25%); rodapé: 3.5rem para 2.5rem. */
  html body .workspace main#content {
    padding: var(--p-s6) var(--p-s6) var(--p-s8);
  }
  /* Título para o conteúdo: 2rem para 1.25rem. */
  html body .workspace .page-heading {
    margin-bottom: var(--p-s5);
  }
  /* Cabeçalho do painel: 0.9rem para 0.75rem na vertical (altura mínima de 44px não muda: botões são os mesmos). */
  html body .workspace .panel-header {
    padding-block: var(--p-s3);
  }
  /* Cartões de relatório: 1.1rem para 1rem na vertical. */
  html body .workspace .report-card {
    padding-block: var(--p-s4);
  }
  /* Grades de painéis: 1rem para 0.75rem entre cartões. */
  html body .workspace .report-grid {
    gap: var(--p-s3);
  }
  /* Linhas de tabela: 0.85rem a 1.06rem na vertical para 0.75rem. */
  html body :is(.workspace, #modal:not(.document-modal)) table td {
    padding-block: var(--p-s3);
  }
  html body .workspace :is(.services-table, .quote-table) td {
    padding-block: var(--p-s3);
  }
}

/* 19/10/2026 (10B): diálogo de vias do recibo, aberto sobre a ficha do trabalho. */
html body #modal .wf-vias-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgb(16 24 20 / 0.38);
}
html body #modal .wf-vias-dialog form {
  display: grid;
  gap: 12px;
  min-width: 260px;
  max-width: 92vw;
  padding: 24px;
  background: var(--p-surface);
  border: 1px solid var(--p-line-soft);
  border-radius: var(--p-r-card);
}
html body #modal .wf-vias-dialog fieldset {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}
html body #modal .wf-vias-dialog .wf-vias-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Acabamento final (Projeto 10, 20/10/2026) ---------- */
/* Notas soltas no formulário e na página: o recuo de 20px vinha do uso dentro de painel; fora dele desalinhava do texto ao redor. */
html body #modal :is(form, [data-wf-panel]) > .context-note,
html body .workspace main > .context-note,
html body .operation-report-heading .context-note {
  padding-inline: 0;
}
/* Lembretes: títulos de grupo com respiro e cartões com o mesmo raio dos demais. */
html body .workspace main > h3:has(+ .reminder-list) {
  margin: var(--p-s6) 0 var(--p-s3);
}
html body .workspace .reminder-card {
  border-radius: var(--p-r-card);
}
/* "Quem recebe": caixa de escolha no mesmo traço do campo, com opções em grade legível. */
html body #modal #audience-people {
  min-width: 0;
  margin: 0;
  padding: var(--p-s2) var(--p-s4) var(--p-s3);
  border: 1px solid var(--control-border);
  border-radius: var(--p-r-control);
}
html body #modal #audience-people legend {
  padding: 0 var(--p-s1);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}
html body #modal #audience-people .check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0 var(--p-s4);
}
html body #modal #audience-people .check-label {
  align-items: center;
  padding: var(--p-s2) 0;
  font-size: 0.875rem;
}
html body #modal .pro-fieldset {
  border-radius: var(--p-r-control);
}
/* Recibo: os blocos do formulário eram empilhados sem espaço entre si. */
html body #modal .document-receipt-form > :not([hidden]) + :not([hidden]),
html body #modal .document-receipt-form [data-receipt-unlinked] > :not([hidden]) + :not([hidden]) {
  margin-top: var(--p-s3);
}
/* Campo de busca: texto longo termina em reticências em vez de ser cortado. */
html body .workspace .search input {
  text-overflow: ellipsis;
}
@media (max-width: 650px) {
  /* Lista do Planejamento no celular: cada linha é um cartão; sem as linhas e o respiro verticais da tabela. */
  html body :is(.workspace, #modal:not(.document-modal)) .services-table td {
    padding-block: 0;
    border-bottom: 0;
  }
  /* Ficha do trabalho, Financeiro: o botão Recibo ocupa sempre a linha inteira, em todos os pagamentos. */
  html body #modal .wf-payments .button {
    flex: 1 0 100%;
    margin-left: 0;
    min-height: 44px;
  }
}

/* 20/10/2026 (Planejamento, modelo Vidro): Profissional e ficha com respiro lateral menor; a tabela cabe em 1024px. */
@media (min-width: 651px) {
  html body :is(.workspace, #modal:not(.document-modal)) .services-table :is(td, th):nth-child(n + 4) {
    padding-inline: 0.5rem;
  }
}
