/* ====================================================================
   MÁQUINA ÓTICA CRM — estilos da aplicação
   ====================================================================
   Consome brand.css e tokens.css. Nenhuma cor literal aqui: tudo vem
   de token. Se aparecer um #hex neste arquivo, é bug de disciplina.
   ==================================================================== */

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center;
  gap: var(--space-4); color: var(--text-tertiary); }
.boot-mark { width: 74px; height: 50px; color: var(--text-primary); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4);
  background: var(--surface-base); }
.login-card { width: 100%; max-width: 380px; background: var(--surface-raised);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: var(--space-8); box-shadow: var(--shadow-lg); display: grid; gap: var(--space-3); }
.login-mark { width: 74px; height: 50px; color: var(--text-primary); margin: 0 auto var(--space-2); }
.login-card h1 { font-size: var(--text-lg); text-align: center; margin: 0;
  font-family: var(--font-display); text-transform: uppercase; }
.login-tag { text-align: center; margin: 0 0 var(--space-4); font-size: var(--text-2xs);
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: var(--mo-label-tracking); }
.login-error { background: var(--danger-bg); border: 1px solid var(--danger-border);
  color: var(--danger-text); padding: var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-xs); }
.login-demo { margin-top: var(--space-4); padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle); display: grid; gap: var(--space-2);
  justify-items: center; text-align: center; font-size: var(--text-xs); color: var(--text-tertiary); }
.login-demo strong { color: var(--text-secondary); font-size: var(--text-2xs);
  text-transform: uppercase; letter-spacing: var(--mo-label-tracking); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }

.sidebar { background: var(--brand-charcoal); color: var(--text-inverse);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4);
  height: var(--topbar-height); border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 34px; height: 23px; flex-shrink: 0; color: #e8e8e2; }
.brand-mark--topbar { display: none; color: var(--text-primary); }
.brand-name { font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: 1.15;
  text-transform: uppercase; font-family: var(--font-display); }
.brand-name small { display: block; margin-top: 2px; font-size: 8px; font-weight: var(--weight-medium);
  letter-spacing: var(--mo-label-tracking); color: #8a8a82; text-transform: uppercase;
  font-family: var(--font-sans); }
.brand-tenant { display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: var(--text-xs); color: #cfcfc7; }
.brand-tenant .mo-rule { width: 14px; }

.nav { padding: var(--space-3) var(--space-2); flex: 1; }
.nav-foot { padding: var(--space-2) var(--space-2) var(--space-4); }
.nav-group { margin-bottom: var(--space-4); }
.nav-label { font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--mo-label-tracking); color: #6f6f68; padding: 0 var(--space-3);
  margin-bottom: var(--space-1); font-weight: var(--weight-semibold); }
.nav-item { display: flex; align-items: center; gap: var(--space-2); width: 100%;
  padding: 0 var(--space-3); height: 30px; border-radius: var(--radius-sm);
  color: #cfcfc7; text-decoration: none; font-size: var(--text-sm);
  background: none; border: none; font-family: inherit; cursor: pointer; text-align: left;
  transition: background var(--duration-fast) var(--ease-out); }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item[aria-current="page"] { background: rgba(255,196,0,.12); color: var(--brand-gold);
  font-weight: var(--weight-medium); box-shadow: inset 2px 0 0 var(--brand-gold); }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.nav-badge { margin-left: auto; background: var(--danger-solid); color: #fff;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); padding: 1px 5px;
  border-radius: var(--radius-full); min-width: 17px; text-align: center;
  font-variant-numeric: tabular-nums; }

.main { display: flex; flex-direction: column; min-width: 0; }
.demo-banner { display: flex; align-items: center; gap: var(--space-2);
  background: var(--warning-bg); border-bottom: 1px solid var(--warning-border);
  color: var(--warning-text); font-size: var(--text-xs); padding: var(--space-2) var(--space-6); }

.topbar { height: var(--topbar-height); display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6); background: var(--surface-raised);
  border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; z-index: var(--z-sticky); }
.search { flex: 1 1 auto; min-width: 0; max-width: 420px; display: flex; align-items: center;
  gap: var(--space-2); background: var(--surface-sunken); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 0 var(--space-3); height: 30px;
  color: var(--text-tertiary); font-size: var(--text-sm); font-family: inherit;
  text-align: left; cursor: pointer; transition: border-color var(--duration-normal) var(--ease-out); }
.search:hover { border-color: var(--border-default); }
.search-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbd { margin-left: auto; flex-shrink: 0; white-space: nowrap; font-family: var(--font-mono);
  font-size: var(--text-2xs); background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); padding: 1px 4px; color: var(--text-tertiary); }
.topbar-spacer { flex: 1; }
.branch-pill { display: flex; align-items: center; gap: var(--space-2);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 0 var(--space-3); height: 30px; font-size: var(--text-sm);
  background: var(--surface-raised); color: var(--text-secondary);
  white-space: nowrap; flex-shrink: 0; }
.avatar { width: 26px; height: 26px; border-radius: var(--radius-full);
  background: var(--brand-charcoal); color: var(--brand-off-white); display: grid;
  place-items: center; font-size: var(--text-xs); font-weight: var(--weight-semibold); flex-shrink: 0; }

.content { padding: var(--space-6); max-width: 1440px; width: 100%; }

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; align-items: flex-end; gap: var(--space-4);
  margin-bottom: var(--space-5); flex-wrap: wrap; }
h1 { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin: 0;
  letter-spacing: -.01em; }
.page-sub { color: var(--text-tertiary); font-size: var(--text-xs); margin: 2px 0 0; }
.head-actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
section { margin-bottom: var(--space-8); }
.section-head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
h2 { font-size: var(--text-md); font-weight: var(--weight-semibold); margin: 0; }
.section-note { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 30px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium); border: 1px solid transparent;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-sm { height: 26px; font-size: var(--text-xs); padding: 0 var(--space-2); }
.btn-block { width: 100%; height: 36px; margin-top: var(--space-2); }
.btn-primary { background: var(--action-primary-bg); color: var(--action-primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--action-primary-bg-hover); }
.btn-secondary { background: var(--action-secondary-bg); color: var(--action-secondary-text);
  border-color: var(--action-secondary-border); }
.btn-secondary:hover:not(:disabled) { background: var(--action-secondary-bg-hover); }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-tertiary);
  padding: var(--space-1); display: grid; place-items: center; border-radius: var(--radius-sm); }
.icon-btn:hover { color: var(--text-primary); background: var(--surface-sunken); }

.input { width: 100%; height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm);
  font-family: inherit; color: var(--text-primary); background: var(--surface-raised);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); }
textarea.input { height: auto; padding: var(--space-2) var(--space-3); resize: vertical; }
.field { display: grid; gap: 4px; margin-bottom: var(--space-3); }
.field > span { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-secondary); }
.field small { font-size: var(--text-2xs); color: var(--text-tertiary); line-height: var(--leading-tight); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm);
  margin-bottom: var(--space-3); cursor: pointer; }

/* ---------- Estados (§94) ---------- */
.state { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-12) var(--space-4);
  text-align: center; background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); color: var(--text-tertiary); }
.state h3 { margin: 0; font-size: var(--text-md); color: var(--text-primary); }
.state p { margin: 0; font-size: var(--text-sm); max-width: 46ch; }
.state code { font-family: var(--font-mono); font-size: var(--text-2xs);
  background: var(--surface-sunken); padding: 2px 6px; border-radius: var(--radius-sm); }
.state-icon { width: 28px; height: 28px; color: var(--danger-solid); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border-default);
  border-top-color: var(--brand-gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Command Center ---------- */
.exceptions { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: var(--space-3); }
.exception { display: flex; align-items: center; gap: var(--space-3); background: var(--surface-raised);
  border: 1px solid var(--border-subtle); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
.exception:hover { box-shadow: var(--shadow-md); border-color: var(--border-default); }
.exception[data-severity="critical"] { border-left-color: var(--danger-solid); }
.exception[data-severity="warning"] { border-left-color: var(--warning-solid); }
.exception-count { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: 1;
  font-variant-numeric: tabular-nums; min-width: 2ch; font-family: var(--font-display); }
.exception[data-severity="critical"] .exception-count { color: var(--danger-solid); }
.exception[data-severity="warning"] .exception-count { color: var(--warning-solid); }
.exception-label { font-size: var(--text-sm); line-height: var(--leading-tight); }
.exception-arrow { margin-left: auto; color: var(--text-tertiary); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: var(--space-3); }
.kpi { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column;
  gap: var(--space-2); }
.kpi-label { font-size: var(--text-xs); color: var(--text-secondary); font-weight: var(--weight-medium); }
.kpi-value { font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: 1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; font-family: var(--font-display); }
.kpi-value[data-absent="true"] { color: var(--text-tertiary); font-weight: var(--weight-normal); }
.kpi-foot { display: flex; align-items: center; gap: var(--space-2); margin-top: auto; flex-wrap: wrap; }
.kpi-reason { font-size: var(--text-2xs); color: var(--text-tertiary); line-height: var(--leading-tight); }

.quality { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-2xs);
  font-weight: var(--weight-medium); padding: 1px 6px; border-radius: var(--radius-full);
  border: 1px solid currentColor; white-space: nowrap; }
.quality::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.quality[data-q="REAL"] { color: var(--quality-real); }
.quality[data-q="ATTRIBUTED"] { color: var(--quality-attributed); }
.quality[data-q="DECLARED"] { color: var(--quality-declared); }
.quality[data-q="ESTIMATED"] { color: var(--quality-estimated); }
.quality[data-q="ABSENT"] { color: var(--quality-absent); }

/* ---------- Funil ---------- */
.funnel { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); overflow: hidden; container-type: inline-size; }
.funnel-row { display: grid; grid-template-columns: minmax(84px, 148px) minmax(0, 1fr) 62px 68px;
  align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle); }
.funnel-row:last-child { border-bottom: none; }
.funnel-stage { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.funnel-bar { height: 22px; background: var(--surface-sunken); border-radius: var(--radius-sm); overflow: hidden; }
.funnel-fill { height: 100%; background: var(--brand-charcoal); border-radius: var(--radius-sm); }
.funnel-row:last-child .funnel-fill { background: var(--success-solid); }
.funnel-count { font-size: var(--text-base); font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums; text-align: right; }
.funnel-rate { font-size: var(--text-xs); color: var(--text-secondary);
  font-variant-numeric: tabular-nums; text-align: right; }
.funnel-rate[data-absent="true"] { color: var(--text-tertiary); }
@container (max-width: 380px) {
  .funnel-row { grid-template-columns: minmax(0, 1fr) 62px 68px; }
  .funnel-bar { display: none; }
}

/* ---------- Tabelas ---------- */
.table-wrap { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th { text-align: left; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-tertiary); font-weight: var(--weight-semibold);
  padding: var(--space-2) var(--space-4); background: var(--surface-sunken);
  border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
td { padding: var(--space-2) var(--space-4); height: var(--row-height); font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle); }
tbody tr:last-child td { border-bottom: none; }
tbody tr[data-action] { cursor: pointer; }
tbody tr:hover { background: var(--surface-sunken); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { display: block; font-weight: var(--weight-medium); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.cell-muted { display: block; color: var(--text-tertiary); font-size: var(--text-xs);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-danger { color: var(--danger-text); font-weight: var(--weight-medium); }

.badge { display: inline-flex; align-items: center; font-size: var(--text-2xs);
  font-weight: var(--weight-medium); padding: 2px 7px; border-radius: var(--radius-full);
  border: 1px solid; white-space: nowrap; }
.badge-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.badge-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.badge-neutral { background: var(--surface-sunken); border-color: var(--border-default); color: var(--text-secondary); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-4); }
.kanban-col { flex: 0 0 236px; background: var(--surface-sunken);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); display: flex; flex-direction: column; }
.kanban-col header { padding: var(--space-3); border-bottom: 1px solid var(--border-subtle);
  display: grid; grid-template-columns: 1fr auto; gap: 2px; font-size: var(--text-sm); }
.kanban-count { background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-full); padding: 0 6px; font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums; }
.kanban-total { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--text-tertiary); }
.kanban-body { padding: var(--space-2); display: grid; gap: var(--space-2); }
.kanban-empty { margin: 0; padding: var(--space-4) 0; text-align: center;
  color: var(--text-tertiary); font-size: var(--text-xs); }
.opp-card { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: var(--space-3); display: grid; gap: var(--space-1);
  font-size: var(--text-sm); }
.opp-card--stale { border-left: 3px solid var(--warning-solid); }
.opp-card footer { display: flex; align-items: center; gap: var(--space-2); justify-content: space-between; }
.stage-select { width: 100%; height: 26px; margin-top: var(--space-1); font-size: var(--text-2xs);
  font-family: inherit; border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--text-secondary); }

/* ---------- Timeline ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--space-5); align-items: start; }
.two-col > section { min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0; background: var(--surface-raised);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.timeline-item { display: grid; grid-template-columns: 16px 1fr; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%;
  background: var(--border-strong); }
.timeline-dot[data-type="SALE_COMPLETED"] { background: var(--success-solid); }
.timeline-dot[data-type="CONTACT_CREATED"] { background: var(--info-solid); }
.timeline-dot[data-type="STAGE_CHANGED"] { background: var(--brand-gold); }
.timeline-item strong { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.timeline-item time { display: block; font-size: var(--text-2xs); color: var(--text-tertiary); margin-top: 2px; }

.cards { display: grid; gap: var(--space-2); }
.mini-card { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: var(--space-3); display: grid; gap: 4px; font-size: var(--text-sm); }

/* ---------- Inbox ---------- */
.conv-list { display: grid; gap: var(--space-2); }
.conv { background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); cursor: pointer;
  display: grid; gap: var(--space-2); }
.conv:hover { border-color: var(--border-default); box-shadow: var(--shadow-sm); }
.conv-head { display: flex; align-items: center; gap: var(--space-2); }
.conv-head .cell-muted { margin-left: auto; display: inline; }
.conv-preview { margin: 0; font-size: var(--text-sm); color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv footer { display: flex; align-items: center; gap: var(--space-2); }
.conv footer .cell-muted { margin-left: auto; display: inline; }

.chat { display: grid; gap: var(--space-2); max-height: 42vh; overflow-y: auto;
  padding: var(--space-2); background: var(--surface-sunken);
  border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.msg { max-width: 78%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); }
.msg p { margin: 0; }
.msg time { display: block; font-size: var(--text-2xs); opacity: .7; margin-top: 3px; }
.msg--in { background: var(--surface-raised); border: 1px solid var(--border-subtle); justify-self: start; }
.msg--out { background: var(--brand-gold); color: var(--text-on-gold); justify-self: end; }

/* ---------- Modal ---------- */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,17,17,.45);
  display: grid; place-items: center; padding: var(--space-4); z-index: var(--z-modal); }
/* min-width: 0 é o que permite o modal encolher abaixo da largura
   mínima do próprio conteúdo. Sem isso, três botões com `nowrap` no
   rodapé esticavam o modal para 407px numa tela de 375 — e o botão
   principal ficava fora da tela, no celular, que é onde o vendedor
   está. Item de grid tem `min-width: auto` por padrão; essa é a
   causa da maioria dos transbordamentos horizontais em modal. */
.modal { width: 100%; min-width: 0; max-width: 440px; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface-overlay); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal--wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.modal-head h2 { flex: 1; font-size: var(--text-md); }
.modal-body { padding: var(--space-4); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-4); border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
/* No celular os botões empilham em largura total. A ação principal
   sobe para o topo da pilha: é a que o polegar alcança primeiro e a
   que o vendedor usa em 90% das vezes. */
@media (max-width: 560px) {
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; height: 36px; }
}
.modal-lead { margin: 0 0 var(--space-4); font-size: var(--text-sm); }

.sale-line { margin-bottom: var(--space-2); }
.sale-item { display: grid; grid-template-columns: minmax(0,1fr) 72px 28px; gap: var(--space-2);
  align-items: center; }
.input-qty { text-align: right; font-variant-numeric: tabular-nums; }
.sale-total { text-align: right; font-size: var(--text-md); padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.sale-hint { margin: var(--space-2) 0 0; font-size: var(--text-2xs);
  color: var(--text-tertiary); line-height: var(--leading-normal); }
.sale-hint strong { color: var(--text-secondary); }

/* Controle segmentado: escolher entre dois caminhos sem parecer um
   formulário dentro de outro. O rádio some, o rótulo vira o botão. */
.segmented { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-md);
  background: var(--surface-sunken); border: 1px solid var(--border-subtle); }
.segmented label { position: relative; padding: 4px var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-xs); cursor: pointer; color: var(--text-secondary);
  transition: background var(--duration-fast) var(--ease-out); white-space: nowrap; }
.segmented label:has(input:checked) { background: var(--surface-raised);
  color: var(--text-primary); font-weight: var(--weight-medium); box-shadow: var(--shadow-sm); }
.segmented label[data-disabled="true"] { opacity: .45; cursor: not-allowed; }
/* O rádio continua no DOM e focável — só não é desenhado. Removê-lo
   quebraria navegação por teclado e leitor de tela. */
.segmented input { position: absolute; opacity: 0; width: 100%; height: 100%;
  left: 0; top: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* Painel que se abre dentro do formulário (cliente novo, produto novo).
   O recuo à esquerda com o fio dourado sinaliza "isto pertence à linha
   de cima" sem precisar de moldura fechada, que pesaria a tela. */
.inline-panel { margin-top: var(--space-2); padding: var(--space-3);
  background: var(--surface-sunken); border-radius: var(--radius-md);
  border-left: 2px solid var(--brand-gold); }
.inline-panel .field:last-of-type { margin-bottom: 0; }
.inline-panel > small { display: block; font-size: var(--text-2xs);
  color: var(--text-tertiary); line-height: var(--leading-tight); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
@media (max-width: 560px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Rótulo só para leitor de tela. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: var(--space-4); right: var(--space-4); display: grid;
  gap: var(--space-2); z-index: var(--z-toast); max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: var(--space-2);
  background: var(--surface-overlay); border: 1px solid var(--border-default);
  border-left: 3px solid var(--border-strong); border-radius: var(--radius-md);
  padding: var(--space-3); box-shadow: var(--shadow-lg); font-size: var(--text-sm);
  animation: toast-in var(--duration-normal) var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.toast--success { border-left-color: var(--success-solid); }
.toast--error { border-left-color: var(--danger-solid); }
.toast--warning { border-left-color: var(--warning-solid); }
.toast--info { border-left-color: var(--info-solid); }
.toast-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.toast-body span { font-size: var(--text-xs); color: var(--text-tertiary); }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-tertiary); padding: 0; }

/* ---------- Command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; background: rgba(17,17,17,.4);
  display: grid; justify-items: center; align-items: start; padding-top: 12vh;
  z-index: var(--z-modal); }
.palette { width: min(560px, calc(100vw - 32px)); background: var(--surface-overlay);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { width: 100%; height: 46px; padding: 0 var(--space-4); border: none;
  border-bottom: 1px solid var(--border-subtle); font-size: var(--text-md);
  font-family: inherit; background: var(--surface-overlay); color: var(--text-primary); }
.palette-input:focus { outline: none; }
.palette-results { max-height: 46vh; overflow-y: auto; }
.palette-hint { margin: 0; padding: var(--space-4); font-size: var(--text-xs); color: var(--text-tertiary); }
.palette-item { display: flex; align-items: center; gap: var(--space-3); width: 100%;
  padding: var(--space-3) var(--space-4); background: none; border: none; cursor: pointer;
  text-align: left; font-family: inherit; font-size: var(--text-sm); color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle); }
.palette-item:hover { background: var(--surface-sunken); }
.palette-item .cell-muted { margin-left: auto; display: inline; }

/* ---------- Mobile (§91) ---------- */
.mobile-nav { display: none; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: var(--space-4) var(--space-4) 76px; }
  .topbar { padding: 0 var(--space-4); }
  .brand-mark--topbar { display: block; }
  .branch-pill, .kbd { display: none; }
  .demo-banner { padding: var(--space-2) var(--space-4); }
  .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 58px;
    background: var(--brand-charcoal); display: flex; z-index: var(--z-sticky);
    padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; color: #a9a9a2; text-decoration: none;
    font-size: var(--text-2xs); }
  .mobile-nav a[aria-current="page"] { color: var(--brand-gold); }
  .mi { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round; }
  .toasts { bottom: 68px; left: var(--space-4); right: var(--space-4); max-width: none; }
}
