/* ==========================================================
   COMPONENTES
   Cada peça tem todos os estados: normal, hover, foco,
   pressionado, desabilitado (e carregando/erro quando cabe).
   ========================================================== */

/* ---------- Botões ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--h-controle); padding: 0 var(--s4);
  border-radius: var(--r-controle);
  font-size: 14px; font-weight: var(--peso-titulo); white-space: nowrap;
  transition: transform 160ms var(--ease), background-color 160ms var(--ease), box-shadow 160ms var(--ease), color 160ms var(--ease);
}
.btn .icone { width: 16px; height: 16px; stroke-width: 2; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { cursor: not-allowed; opacity: 0.45; }

.btn-primario { background: var(--accent-solid); color: var(--on-accent); }
.btn-secundario { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-fantasma { color: var(--ink-2); }
.btn-perigo { background: var(--err); color: #fff; }
[data-tema="escuro"] .btn-perigo { color: #1A0F0D; }
@media (hover: hover) {
  .btn-primario:hover:not(:disabled) { background: var(--accent-solid-hover); }
  .btn-secundario:hover:not(:disabled) { background: var(--surface-2); }
  .btn-fantasma:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
  .btn-perigo:hover:not(:disabled) { background: color-mix(in oklab, var(--err) 88%, #000); }
}

.btn-sm { height: var(--h-controle-sm); padding: 0 var(--s3); font-size: var(--fs-13); border-radius: calc(var(--r-controle) - 2px); }
.btn-lg { height: var(--h-controle-lg); padding: 0 var(--s5); font-size: 15px; }
.btn-bloco { width: 100%; }

/* Carregando: o texto some, o tamanho fica (nada pula de lugar) */
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--carregando, currentColor); border-right-color: transparent;
  animation: girar 700ms linear infinite;
}
.btn-primario[aria-busy="true"]::after { --carregando: var(--on-accent); }
.btn-secundario[aria-busy="true"]::after, .btn-fantasma[aria-busy="true"]::after { --carregando: var(--ink-2); }

.btn-icone {
  position: relative; display: inline-grid; place-items: center;
  width: var(--h-controle); height: var(--h-controle);
  border-radius: var(--r-controle); color: var(--ink-2);
  transition: background-color var(--t-rapido) var(--ease), color var(--t-rapido) var(--ease), transform var(--t-rapido) var(--ease);
}
.btn-icone.btn-sm { width: var(--h-controle-sm); height: var(--h-controle-sm); padding: 0; } /* sem o recuo do .btn-sm, que espremia o ícone */
.btn-icone:active { transform: scale(0.94); }
@media (hover: hover) { .btn-icone:hover { background: var(--hover); color: var(--ink); } }
.btn-icone .ponto { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }

.link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-13); font-weight: var(--peso-rotulo); color: var(--ink-3); transition: color var(--t-rapido) var(--ease); }
.link .icone { width: 14px; height: 14px; transition: transform 200ms var(--ease); }
.link-destaque { color: var(--accent-ink); }
@media (hover: hover) { .link:hover { color: var(--ink); } .link:hover .icone { transform: translateX(2px); } }

.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: 11.5px; font-weight: var(--peso-rotulo); color: var(--ink-3); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft), 0 1px 0 var(--line-soft); }

/* ---------- Campos de formulário ---------- */
.campo { display: grid; gap: 6px; }
.campo-rotulo { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); font-size: var(--fs-13); font-weight: var(--peso-rotulo); color: var(--ink-2); }
.campo-rotulo small { font-size: var(--fs-12); font-weight: var(--peso-texto); color: var(--ink-4); }
.campo-ajuda { font-size: var(--fs-12); color: var(--ink-3); }
.campo-erro { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); font-weight: var(--peso-rotulo); color: var(--err-ink); }
.campo-erro .icone { width: 14px; height: 14px; stroke-width: 2; }

.controle {
  width: 100%; min-width: 0; height: var(--h-controle);
  padding: 0 var(--s3);
  border: 0; border-radius: var(--r-controle);
  background: var(--inset); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  font-size: 14.5px; outline: none;
  transition: box-shadow var(--t-rapido) var(--ease), background-color var(--t-rapido) var(--ease);
}
.controle::placeholder { color: var(--ink-4); }
@media (hover: hover) { .controle:hover:not(:disabled):not(:focus) { box-shadow: inset 0 0 0 1px var(--line); } }
.controle:focus { box-shadow: inset 0 0 0 1px var(--ink-3), 0 0 0 3px var(--accent-wash); }
.controle[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--err), 0 0 0 3px var(--err-wash); }
.controle:disabled { opacity: 0.55; cursor: not-allowed; }
/* iPhone dá zoom em campo com letra < 16px: nos aparelhos de toque, 16px */
@media (pointer: coarse) { .controle { font-size: 16px; } }
textarea.controle { height: auto; min-height: 104px; padding: 10px var(--s3); line-height: 1.5; resize: vertical; }

/* Campo com ícone à esquerda (busca, valor) */
.controle-grupo { position: relative; display: flex; align-items: center; }
.controle-grupo > .icone, .controle-grupo > .prefixo { position: absolute; left: var(--s3); color: var(--ink-3); pointer-events: none; }
.controle-grupo > .prefixo { font-size: 14.5px; }
.controle-grupo > .controle { padding-left: 40px; }
.controle-grupo > .kbd { position: absolute; right: 8px; }

/* Seletor nativo com seta desenhada (o menu continua nativo: melhor no celular) */
.seletor { position: relative; }
.seletor .controle { appearance: none; padding-right: 36px; cursor: pointer; }
.seletor::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; pointer-events: none;
  background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Caixa de seleção, opção única e interruptor */
.opcao { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-14); line-height: 1.4; }
.opcao small { display: block; font-size: var(--fs-12); color: var(--ink-3); }
.opcao:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.check, .radio {
  appearance: none; flex-shrink: 0; position: relative;
  width: 18px; height: 18px; margin-top: 1px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--ink-4);
  cursor: inherit;
  transition: background-color var(--t-rapido) var(--ease), box-shadow var(--t-rapido) var(--ease), transform var(--t-rapido) var(--ease);
}
.check { border-radius: 5px; }
.radio { border-radius: 50%; }
.check::before { content: ""; position: absolute; inset: -13px; } /* alvo de toque de 44px */
.check::after {
  content: ""; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 10px;
  border: solid var(--on-accent); border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0); transition: transform 180ms var(--ease);
}
.check:checked, .radio:checked { background: var(--accent-solid); box-shadow: none; }
.check:checked::after { transform: rotate(45deg) scale(1); }
.radio:checked { box-shadow: inset 0 0 0 5px var(--accent-solid); background: var(--on-accent); }
.check:active, .radio:active { transform: scale(0.9); }
@media (hover: hover) { .opcao:hover .check:not(:checked), .opcao:hover .radio:not(:checked) { box-shadow: inset 0 0 0 1.5px var(--ink-3); } }

.interruptor {
  appearance: none; flex-shrink: 0; position: relative; cursor: pointer;
  width: 36px; height: 22px; border-radius: 11px;
  background: var(--inset); box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color var(--t-medio) var(--ease);
}
.interruptor::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--t-medio) var(--ease);
}
.interruptor:checked { background: var(--ok); box-shadow: none; }
.interruptor:checked::before { transform: translateX(14px); }
.interruptor:active::before { width: 19px; }
.interruptor:checked:active::before { transform: translateX(11px); }

/* ---------- Abas ---------- */
.abas { display: inline-flex; gap: 2px; padding: 3px; max-width: 100%; background: var(--inset); border-radius: calc(var(--r-controle) + 3px); overflow-x: auto; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.aba { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--s3); border-radius: var(--r-controle); font-size: var(--fs-13); font-weight: var(--peso-rotulo); color: var(--ink-3); white-space: nowrap; transition: color var(--t-rapido) var(--ease), background-color var(--t-rapido) var(--ease); }
.aba .n { font-size: 11.5px; color: var(--ink-4); }
.aba[aria-selected="true"], .aba[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-soft), 0 1px 2px rgba(0, 0, 0, 0.05); }
.aba[aria-selected="true"] .n, .aba[aria-pressed="true"] .n { color: var(--ink-3); }
@media (hover: hover) { .aba:hover { color: var(--ink); } }

/* Abas de página (sublinhadas), para navegação dentro de uma ficha */
.abas-linha { display: flex; gap: var(--s5); box-shadow: inset 0 -1px 0 var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.abas-linha .aba { height: 40px; padding: 0; border-radius: 0; background: none; box-shadow: none; }
.abas-linha .aba[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--accent); background: none; }

/* ---------- Etiquetas e status (sempre cor + texto) ---------- */
.etiqueta {
  --tom: var(--ink-3); --tom-ink: var(--ink-2); --tom-wash: var(--surface-2);
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 var(--s2);
  border-radius: var(--r-etiqueta);
  font-size: var(--fs-12); font-weight: var(--peso-rotulo); white-space: nowrap;
  background: var(--tom-wash); color: var(--tom-ink);
}
.etiqueta::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tom); }
.etiqueta.sem-ponto::before { display: none; }
.etiqueta.contorno { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.tom-neutro  { --tom: var(--ink-4);  --tom-ink: var(--ink-2);        --tom-wash: var(--surface-2); }
.tom-info    { --tom: var(--info);   --tom-ink: var(--info-ink);     --tom-wash: var(--info-wash); }
.tom-marca   { --tom: var(--accent); --tom-ink: var(--accent-ink);   --tom-wash: var(--accent-wash); }
.tom-violeta { --tom: var(--violeta);--tom-ink: var(--violeta-ink);  --tom-wash: var(--violeta-wash); }
.tom-atencao { --tom: var(--warn);   --tom-ink: var(--warn-ink);     --tom-wash: var(--warn-wash); }
.tom-erro    { --tom: var(--err);    --tom-ink: var(--err-ink);      --tom-wash: var(--err-wash); }
.tom-ok      { --tom: var(--ok);     --tom-ink: var(--ok-ink);       --tom-wash: var(--ok-wash); }
.etiqueta.tom-neutro::before { background: none; box-shadow: inset 0 0 0 1.5px var(--ink-4); }

.contador { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: var(--peso-titulo); background: var(--accent-wash); color: var(--accent-ink); }

/* ---------- Avatares ---------- */
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--cor, var(--ink-3)); color: #fff;
  font-size: 12px; font-weight: var(--peso-titulo); letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; outline: 1px solid rgba(0, 0, 0, 0.1); outline-offset: -1px; }
.avatar-xs { width: 20px; height: 20px; font-size: 8.5px; }
.avatar-sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatares { display: inline-flex; }
.avatares .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatares .avatar + .avatar { margin-left: -8px; }

/* ---------- Painéis e cartões ---------- */
.painel { background: var(--surface); border-radius: var(--r-container); box-shadow: var(--shadow-card); padding: var(--s6); min-width: 0; }
.painel-cabeca { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.painel-cabeca p { font-size: var(--fs-13); color: var(--ink-3); }

.cartao {
  display: grid; gap: var(--s3); align-content: start;
  padding: var(--s5); background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  transition: transform var(--t-medio) var(--ease), box-shadow var(--t-medio) var(--ease);
}
a.cartao:active, button.cartao:active { transform: scale(0.99); }
@media (hover: hover) { a.cartao:hover, button.cartao:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); } }

/* ---------- Lista com barrinha lateral de status ---------- */
.lista { display: grid; gap: 2px; }
.lista-item {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s3) var(--s3) var(--s5); border-radius: var(--r-card);
  transition: background-color var(--t-rapido) var(--ease);
}
.lista-item::before { content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--tom, transparent); }
@media (hover: hover) { .lista-item:hover { background: var(--hover); } }
.lista-item strong { display: block; font-size: var(--fs-14); font-weight: var(--peso-titulo); line-height: 1.35; }
.lista-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: var(--fs-13); color: var(--ink-3); }

/* ---------- Tabela ---------- */
.tabela-caixa { overflow-x: auto; border-radius: var(--r-card); box-shadow: var(--shadow-card); background: var(--surface); }
.tabela { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.tabela th {
  position: sticky; top: 0; z-index: 1;
  padding: 0 var(--s4); height: 40px; text-align: left; white-space: nowrap;
  font-size: var(--fs-12); font-weight: var(--peso-rotulo); color: var(--ink-3);
  background: var(--surface); box-shadow: inset 0 -1px 0 var(--line-soft);
}
.tabela td { padding: 0 var(--s4); height: 52px; border-top: 1px solid var(--line-soft); white-space: nowrap; }
.tabela tbody tr:first-child td { border-top: 0; }
.tabela tbody tr { transition: background-color var(--t-rapido) var(--ease); }
@media (hover: hover) { .tabela tbody tr:hover { background: var(--hover); } }
.tabela .num { text-align: right; }
.tabela .sutil { color: var(--ink-3); }
.tabela td .celula-cliente { display: flex; align-items: center; gap: 10px; font-weight: var(--peso-rotulo); }
.ordenar { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; border-radius: 4px; }
.ordenar .icone { width: 13px; height: 13px; opacity: 0; transition: opacity var(--t-rapido) var(--ease), transform var(--t-medio) var(--ease); }
.ordenar:hover .icone, [aria-sort] .ordenar .icone { opacity: 1; }
[aria-sort="descending"] .ordenar .icone { transform: rotate(180deg); }
[aria-sort] .ordenar { color: var(--ink); }

/* ---------- Progresso ---------- */
.barra { height: 6px; border-radius: 3px; background: var(--inset); overflow: hidden; }
.barra > i { display: block; height: 100%; width: var(--valor, 0%); border-radius: inherit; background: var(--tom, var(--accent)); transition: width 500ms var(--ease); }
.pilha { display: flex; gap: 3px; height: 8px; }
.pilha > i { flex: var(--n) 1 0; border-radius: 4px; background: var(--tom); }
.segmentos { display: grid; grid-template-columns: repeat(var(--total), 1fr); gap: 4px; }
.segmentos > i { height: 8px; border-radius: 4px; background: var(--inset); }
.segmentos > i.feito { background: var(--tom, var(--accent)); }
.segmentos > i.pendente { background: repeating-linear-gradient(135deg, var(--tom, var(--accent)) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--tom, var(--accent)); }
.chaves { display: flex; flex-wrap: wrap; gap: 4px var(--s4); font-size: var(--fs-12); color: var(--ink-3); }
.chaves > span { display: inline-flex; align-items: center; gap: 6px; }
.chaves i { width: 8px; height: 8px; border-radius: 2px; background: var(--tom); }

.anel { --tamanho: 96px; position: relative; width: var(--tamanho); height: var(--tamanho); }
.anel svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anel circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.anel .trilho { stroke: var(--inset); }
.anel .valor { stroke: var(--tom, var(--accent)); transition: stroke-dashoffset 900ms var(--ease); }
.anel-rotulo { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-size: 22px; font-weight: var(--peso-titulo); letter-spacing: var(--tr-numero); line-height: 1; }
.anel-rotulo small { display: block; margin-top: 4px; font-size: 11px; font-weight: var(--peso-texto); letter-spacing: 0; color: var(--ink-3); }

.giro { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink-2); animation: girar 700ms linear infinite; }

/* ---------- Etapas (passo a passo) ---------- */
.etapas { display: grid; grid-template-columns: repeat(var(--total, 3), minmax(0, 1fr)); gap: var(--s4); }
.etapa { position: relative; display: grid; gap: 6px; min-width: 0; }
.etapa::after { content: ""; position: absolute; left: 22px; right: calc(var(--s4) * -1); top: 10px; height: 2px; border-radius: 2px; background: var(--line-soft); }
.etapa:last-child::after { display: none; }
.etapa.feito::after { background: var(--ok); opacity: 0.45; }
.etapa-icone { position: relative; z-index: 1; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 12px; font-weight: 700; color: #fff; }
.etapa-icone .icone { width: 12px; height: 12px; stroke-width: 3; }
.etapa.feito .etapa-icone { background: var(--ok); box-shadow: none; }
.etapa.atual .etapa-icone { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 5px var(--accent-wash); }
.etapa.atual .etapa-icone::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.etapa.erro .etapa-icone { background: var(--err); box-shadow: 0 0 0 4px var(--err-wash); }
.etapa strong { display: block; font-size: var(--fs-13); font-weight: var(--peso-rotulo); color: var(--ink-3); line-height: 1.3; }
.etapa > span:not(.etapa-icone) { display: block; font-size: var(--fs-12); color: var(--ink-4); }
.etapa.feito strong { color: var(--ink-2); }
.etapa.atual strong { color: var(--ink); font-weight: var(--peso-titulo); }
.etapa.atual > span:not(.etapa-icone) { color: var(--accent-ink); font-weight: var(--peso-rotulo); }
.etapa.erro strong, .etapa.erro > span:not(.etapa-icone) { color: var(--err-ink); }
.etapa.erro strong { font-weight: var(--peso-titulo); }

/* ---------- Dica (tooltip): aparece com leve atraso, some rápido ---------- */
[data-dica] { position: relative; }
[data-dica]::after {
  content: attr(data-dica); position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 8px);
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--ink); color: var(--bg); font-size: var(--fs-12); font-weight: var(--peso-rotulo); letter-spacing: 0;
  opacity: 0; transform: translate(-50%, 4px);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}
[data-dica]:hover::after, [data-dica]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 350ms; }

/* ---------- Menu suspenso (popover nativo: fecha com Esc e clique fora) ---------- */
.menu {
  position: fixed; inset: auto; margin: 0; min-width: 220px; max-width: calc(100vw - 16px);
  padding: 6px; border: 0; border-radius: var(--r-card);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float);
  opacity: 0; transform: scale(0.96) translateY(-4px); transform-origin: top left;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease), overlay 150ms allow-discrete, display 150ms allow-discrete;
}
[data-tema="escuro"] .menu { background: var(--surface-2); }
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 36px; padding: 0 10px; border-radius: 8px;
  font-size: var(--fs-14); text-align: left; color: var(--ink-2);
}
.menu-item .icone { width: 16px; height: 16px; color: var(--ink-3); }
.menu-item .kbd { margin-left: auto; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); color: var(--ink); outline: none; }
.menu-item.perigo, .menu-item.perigo .icone { color: var(--err-ink); }
.menu-item.perigo:hover, .menu-item.perigo:focus-visible { background: var(--err-wash); }
.menu-separador { height: 1px; margin: 6px 4px; background: var(--line-soft); }
.menu-titulo { padding: 6px 10px 4px; font-size: var(--fs-11); font-weight: var(--peso-titulo); letter-spacing: var(--tr-caixa-alta); text-transform: uppercase; color: var(--ink-4); }

/* ---------- Modal e gaveta (dialog nativo: foco preso e Esc de graça) ---------- */
.modal:focus, .gaveta:focus { outline: none; }
.modal, .gaveta {
  border: 0; padding: 0; color: var(--ink); background: var(--surface);
  box-shadow: var(--shadow-float);
  opacity: 0;
  transition: opacity var(--t-medio) var(--ease), transform var(--t-medio) var(--ease), overlay var(--t-medio) allow-discrete, display var(--t-medio) allow-discrete;
}
.modal::backdrop, .gaveta::backdrop {
  background: var(--veu); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--t-medio) var(--ease), overlay var(--t-medio) allow-discrete, display var(--t-medio) allow-discrete;
}
.modal[open], .gaveta[open] { opacity: 1; transform: none; }
.modal[open]::backdrop, .gaveta[open]::backdrop { opacity: 1; }
@starting-style {
  .modal[open] { opacity: 0; transform: scale(0.96); }
  .gaveta[open] { opacity: 0; transform: translateX(24px); }
  .modal[open]::backdrop, .gaveta[open]::backdrop { opacity: 0; }
}
.modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 64px); margin: auto; border-radius: var(--r-container); transform: scale(0.96); }
.gaveta { width: min(480px, 100vw); height: 100dvh; max-height: none; margin: 0 0 0 auto; border-radius: var(--r-container) 0 0 var(--r-container); transform: translateX(24px); }
.modal-cabeca { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s6) var(--s6) 0; }
.modal-cabeca h2 { font-size: var(--fs-18); letter-spacing: -0.015em; }
.modal-cabeca p { margin-top: 4px; font-size: var(--fs-13); color: var(--ink-3); }
.modal-cabeca .btn-icone { margin: -8px -8px 0 0; }
.modal-corpo { padding: var(--s5) var(--s6); display: grid; align-content: start; gap: var(--s4); }
.modal-rodape { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s6); border-top: 1px solid var(--line-soft); }
.gaveta { display: none; }
.gaveta[open] { display: flex; flex-direction: column; }
.gaveta .modal-corpo { flex: 1; overflow-y: auto; }

/* No celular, o modal vira folha que sobe de baixo */
@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-container) var(--r-container) 0 0; transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom); }
  @starting-style { .modal[open] { opacity: 0; transform: translateY(24px); } }
  .modal-rodape .btn { flex: 1; }
}

/* ---------- Avisos (faixas dentro da página) ---------- */
.aviso {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4); border-radius: var(--r-card);
  background: var(--tom-wash, var(--surface-2)); color: var(--ink-2); font-size: var(--fs-13);
}
.aviso > .icone { width: 18px; height: 18px; margin-top: 1px; color: var(--tom-ink, var(--ink-3)); }
.aviso-texto { flex: 1; min-width: 0; }
.aviso-texto strong { display: block; color: var(--ink); font-size: var(--fs-14); font-weight: var(--peso-titulo); margin-bottom: 2px; }
.aviso .btn { align-self: center; }

/* ---------- Toasts (confirmação rápida) ---------- */
.toasts { position: fixed; z-index: 60; right: var(--s5); bottom: var(--s5); display: grid; gap: var(--s2); justify-items: end; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s3);
  min-width: 280px; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 10px 10px var(--s4); border-radius: var(--r-card);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-float);
  font-size: var(--fs-13); font-weight: var(--peso-rotulo);
  pointer-events: auto;
  animation: toast-entrar 320ms var(--ease) both;
}
.toast.saindo { animation: toast-sair 180ms var(--ease) both; }
.toast > .icone { width: 16px; height: 16px; stroke-width: 2.25; color: var(--tom, var(--bg)); }
.toast .toast-texto { flex: 1; }
.toast .btn { height: 28px; padding: 0 10px; font-size: var(--fs-12); color: var(--bg); background: rgba(127, 127, 127, 0.2); }
.toast .btn-icone { width: 28px; height: 28px; color: var(--bg); opacity: 0.6; }
.toast.tom-ok { --tom: #7FD0A2; }
.toast.tom-erro { --tom: #F58C80; }
[data-tema="escuro"] .toast.tom-ok { --tom: var(--ok); }
[data-tema="escuro"] .toast.tom-erro { --tom: var(--err); }
@keyframes toast-entrar { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-sair { to { opacity: 0; transform: translateY(6px) scale(0.98); } }
@media (max-width: 560px) { .toasts { left: var(--s4); right: var(--s4); bottom: calc(var(--s4) + env(safe-area-inset-bottom)); justify-items: stretch; } .toast { max-width: none; } }

/* ---------- Estados de tela: vazio, carregando, erro, sem resultado ---------- */
.estado { display: grid; justify-items: center; gap: var(--s2); padding: var(--s8) var(--s5); text-align: center; color: var(--ink-3); font-size: var(--fs-13); }
.estado-selo { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: var(--s2); border-radius: 50%; background: var(--tom-wash, var(--surface-2)); color: var(--tom-ink, var(--ink-3)); }
.estado-selo .icone { width: 22px; height: 22px; }
.estado strong { color: var(--ink); font-size: var(--fs-16); font-weight: var(--peso-titulo); letter-spacing: -0.01em; }
.estado p { max-width: 36ch; }
.estado .btn { margin-top: var(--s3); }

.esqueleto {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--inset) 30%, var(--surface-2) 50%, var(--inset) 70%) 0 0 / 300% 100%;
  animation: brilho 1.4s linear infinite;
}
.esqueleto.circulo { width: 36px; height: 36px; border-radius: 50%; }
.esqueleto.titulo { height: 16px; }

/* ==========================================================
   PERSONALIZAÇÃO
   A equipe escolhe UMA cor (hex) e o sistema deriva o resto,
   legível no diurno e no noturno.
   ========================================================== */

/* Cor livre: <span class="etiqueta tom-livre" style="--cor:#E5C23A"> */
.tom-livre {
  --tom: var(--cor);
  --tom-ink: oklch(from var(--cor) min(l, 0.46) c h);          /* escurece só se precisar */
  --tom-wash: oklch(from var(--cor) 0.95 min(c, 0.045) h);
}
[data-tema="escuro"] .tom-livre {
  --tom-ink: oklch(from var(--cor) max(l, 0.82) min(c, 0.13) h); /* clareia só se precisar */
  --tom-wash: oklch(from var(--cor) 0.3 min(c, 0.06) h);
}

/* Avatar: letra branca ou escura escolhida pela luminosidade do fundo (ou a cor definida) */
.avatar { color: var(--cor-texto, oklch(from var(--cor, #8A8580) clamp(0.2, (0.7 - l) * 1000, 1) 0 0)); }
.avatar.emoji { font-size: 1.15em; letter-spacing: 0; }

/* ---------- Seletor de cor ---------- */
.seletor-cor { display: grid; gap: var(--s3); }
.paleta-cores { display: grid; grid-template-columns: repeat(7, 28px); gap: 8px; }
.amostra-cor {
  position: relative; width: 28px; height: 28px; border-radius: 8px;
  background: var(--cor); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 16%, transparent);
  transition: transform var(--t-rapido) var(--ease);
}
.amostra-cor::before { content: ""; position: absolute; inset: -8px; } /* alvo de toque */
.amostra-cor:active { transform: scale(0.9); }
.amostra-cor[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--cor); }
.amostra-cor[aria-checked="true"]::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 10px; margin: -7px 0 0 -3px;
  border: solid oklch(from var(--cor) clamp(0.2, (0.7 - l) * 1000, 1) 0 0); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
@media (hover: hover) { .amostra-cor:hover { transform: scale(1.1); } }
.hex-linha { display: flex; gap: var(--s2); }
.hex-conta-gotas {
  position: relative; flex-shrink: 0; width: var(--h-controle); height: var(--h-controle); border-radius: var(--r-controle);
  background: var(--cor); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); cursor: pointer; overflow: hidden;
}
.hex-conta-gotas input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.hex-campo { flex: 1; }
.hex-campo .controle { padding-left: 28px; font-variant-numeric: tabular-nums; text-transform: uppercase; letter-spacing: 0.04em; }
.hex-campo .prefixo { left: 12px; }

/* Campo de cor compacto (abre o seletor num popover) */
.campo-cor {
  display: inline-flex; align-items: center; gap: var(--s2); height: var(--h-controle); padding: 0 var(--s3) 0 6px;
  border-radius: var(--r-controle); background: var(--inset); box-shadow: inset 0 0 0 1px var(--line-soft);
  font-size: var(--fs-13); font-variant-numeric: tabular-nums; letter-spacing: 0.03em; color: var(--ink-2);
  transition: box-shadow var(--t-rapido) var(--ease);
}
.campo-cor i { width: 28px; height: 28px; border-radius: 7px; background: var(--cor); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
@media (hover: hover) { .campo-cor:hover { box-shadow: inset 0 0 0 1px var(--line); } }
.popover-cor { padding: var(--s4); min-width: 0; }

/* Selo de legibilidade */
.selo-contraste { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: var(--fs-12); font-weight: var(--peso-rotulo); }
.selo-contraste .icone { width: 14px; height: 14px; stroke-width: 2.25; }
.selo-contraste.passa { color: var(--ok-ink); }
.selo-contraste.falha { color: var(--warn-ink); }
.selo-contraste .btn { height: 28px; font-size: var(--fs-12); }
.amostra-mini { width: 12px; height: 12px; border-radius: 3px; background: var(--cor); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* ---------- Editor de opções (status e listas, como no Notion) ---------- */
.opcoes { display: grid; gap: var(--s4); }
.opcoes-grupo { display: grid; gap: 2px; }
.opcoes-grupo-cabeca { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 0 var(--s2) var(--s1); }
.opcoes-grupo-cabeca span { font-size: var(--fs-12); font-weight: var(--peso-titulo); color: var(--ink-3); }
.opcoes-grupo-cabeca small { font-size: var(--fs-12); color: var(--ink-4); }
.opcoes-lista { display: grid; gap: 2px; min-height: 8px; border-radius: var(--r-card); transition: background-color var(--t-rapido) var(--ease); }
.opcoes-lista.alvo { background: var(--accent-wash); }
.opcao-linha {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: var(--s2);
  padding: 4px 4px 4px 2px; border-radius: 8px; background: var(--surface);
  transition: background-color var(--t-rapido) var(--ease), box-shadow var(--t-rapido) var(--ease);
}
@media (hover: hover) { .opcao-linha:hover { background: var(--hover); } }
.opcao-linha.arrastando { position: relative; z-index: 5; background: var(--surface); box-shadow: var(--shadow-float); }
.opcao-linha.fantasma { opacity: 0.35; }
.alca { display: grid; place-items: center; width: 24px; height: 32px; border-radius: 6px; color: var(--ink-4); cursor: grab; touch-action: none; }
.alca:active { cursor: grabbing; }
@media (hover: hover) { .alca:hover { color: var(--ink-2); background: var(--hover); } }
.opcao-cor { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; }
.opcao-cor i { width: 14px; height: 14px; border-radius: 4px; background: var(--cor); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
@media (hover: hover) { .opcao-cor:hover { background: var(--hover); } }
.opcao-nome { height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: none; outline: none; font-size: var(--fs-14); color: var(--ink); min-width: 0; }
.opcao-nome:hover { background: var(--hover); }
.opcao-nome:focus { background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); }
.opcao-nova { justify-self: start; color: var(--ink-3); }
