/* ===========================================================================
   SELLER 2 — SISTEMA VISUAL

   Uma folha só no lugar das onze que se sobrepunham. Ordem de leitura:

     1. tokens        — cor, espaço, raio, tipo, sombra, movimento
     2. base          — reset e tipografia
     3. componentes   — botão, campo, chip, cartão, folha, aviso…

   Princípios (valem para qualquer tela nova):

     MÃO PRIMEIRO     alvo de toque >= 44px; o que se usa o dia todo fica
                      ao alcance do polegar (rodapé), nunca no topo.
     DUAS LUZES       claro e escuro de verdade, não um filtro. Vendedor de
                      rua lê tela no sol; o dono revisa à noite.
     UM VERDE         verde é WhatsApp/dinheiro/ok. Vermelho é urgência.
                      Nada decorativo usa essas duas cores.
     MOVIMENTO COM    transição explica a mudança (de onde veio, para onde
     MOTIVO           foi). Quem pediu menos movimento recebe nenhum.
   =========================================================================== */

/* ---------- 1. TOKENS ---------------------------------------------------- */

:root {
  color-scheme: dark;

  /* marca */
  --marca-1: #5b8cff;
  --marca-2: #8b5cff;
  --marca-grad: linear-gradient(135deg, #5b8cff 0%, #7a6bff 55%, #8b5cff 100%);

  /* semântica (iguais nos dois temas, ajustadas por contraste onde preciso) */
  --zap: #25d366;
  --zap-fundo: rgba(37, 211, 102, 0.14);
  /* Dinheiro é um verde-água, de propósito diferente do verde do semáforo. */
  --dinheiro: #12c9a3;

  /* SEMÁFORO DA TEMPERATURA — decisão de produto, não estética.
     Verde = melhor oportunidade, âmbar = média, vermelho APAGADO = baixa.
     É a convenção que todo mundo lê sem legenda. Vermelho vivo (--quente,
     abaixo) é reservado a ERRO e URGÊNCIA: pintar o melhor lead com a cor de
     erro obriga a aprender uma exceção, e quem tem pressa erra a exceção.
     64% da base é fria: por isso o vermelho de baixo potencial é apagado. */
  --temp-quente: #2fd35f;
  --temp-quente-fundo: rgba(47, 211, 95, 0.15);
  --temp-frio: #b4586a;
  --temp-frio-fundo: rgba(180, 88, 106, 0.16);

  --quente: #ff5d4f;
  --quente-fundo: rgba(255, 93, 79, 0.14);
  --morno: #ffa63d;
  --morno-fundo: rgba(255, 166, 61, 0.14);
  --frio: #6ea8ff;
  --frio-fundo: rgba(110, 168, 255, 0.14);
  --info: #5bc0ff;

  /* superfícies — escuro */
  --fundo: #0a0c13;
  --fundo-2: #0e111a;
  --s1: #131723;
  --s2: #1a1f2e;
  --s3: #232939;
  --linha: rgba(255, 255, 255, 0.08);
  --linha-forte: rgba(255, 255, 255, 0.16);
  --texto: #f2f4fb;
  --texto-2: #a9b0c4;
  --texto-3: #727a91;
  --vidro: rgba(14, 17, 26, 0.9);
  --sombra-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.25);
  --sombra-2: 0 10px 40px rgba(0, 0, 0, 0.5);
  --brilho: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  /* espaço (base 4) */
  --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e5: 20px; --e6: 24px; --e8: 32px; --e10: 40px;

  /* raios */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* tipo */
  --fonte: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text',
           'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fonte-titulo: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display',
                  'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --t-xs: 12px; --t-sm: 13px; --t-base: 15px; --t-md: 17px; --t-lg: 20px; --t-xl: 26px; --t-xxl: 34px;

  /* movimento */
  --mola: cubic-bezier(0.22, 1, 0.36, 1);
  --rapido: 140ms;
  --medio: 260ms;

  /* áreas seguras do iPhone (notch / Dynamic Island / barra home).
     --sai-test-* existem só para o teste simular o aparelho no navegador do
     computador, onde env(safe-area-inset-*) vale 0. */
  --sai-t: max(env(safe-area-inset-top, 0px), var(--sai-test-t, 0px));
  --sai-b: max(env(safe-area-inset-bottom, 0px), var(--sai-test-b, 0px));
  --sai-l: max(env(safe-area-inset-left, 0px), var(--sai-test-l, 0px));
  --sai-r: max(env(safe-area-inset-right, 0px), var(--sai-test-r, 0px));

  --altura-tabbar: 68px;
  --altura-topo: 56px;
}

/* tema claro: manual (data-tema) ou o do sistema, quando nada foi escolhido */
:root[data-tema='claro'] {
  color-scheme: light;
  --fundo: #f3f5fb;
  --fundo-2: #eaeef7;
  --s1: #ffffff;
  --s2: #f0f3fa;
  --s3: #e4e9f4;
  --linha: rgba(15, 23, 42, 0.09);
  --linha-forte: rgba(15, 23, 42, 0.18);
  --texto: #0d1322;
  --texto-2: #475069;
  --texto-3: #7a839b;
  --vidro: rgba(255, 255, 255, 0.92);
  --sombra-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.07);
  --sombra-2: 0 10px 40px rgba(15, 23, 42, 0.16);
  --brilho: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --zap: #11a84f;
  --zap-fundo: rgba(17, 168, 79, 0.12);
  --dinheiro: #0a9d86;
  --temp-quente: #16a34a;
  --temp-quente-fundo: rgba(22, 163, 74, 0.12);
  --temp-frio: #a6465a;
  --temp-frio-fundo: rgba(166, 70, 90, 0.12);
  --quente: #e0382b;
  --quente-fundo: rgba(224, 56, 43, 0.1);
  --morno: #d97706;
  --morno-fundo: rgba(217, 119, 6, 0.12);
  --frio: #2f6fe0;
  --frio-fundo: rgba(47, 111, 224, 0.1);
  --info: #0f8fd1;
}

@media (prefers-color-scheme: light) {
  :root:not([data-tema]) {
    color-scheme: light;
    --fundo: #f3f5fb;
    --fundo-2: #eaeef7;
    --s1: #ffffff;
    --s2: #f0f3fa;
    --s3: #e4e9f4;
    --linha: rgba(15, 23, 42, 0.09);
    --linha-forte: rgba(15, 23, 42, 0.18);
    --texto: #0d1322;
    --texto-2: #475069;
    --texto-3: #7a839b;
    --vidro: rgba(255, 255, 255, 0.92);
    --sombra-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.07);
    --sombra-2: 0 10px 40px rgba(15, 23, 42, 0.16);
    --brilho: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --zap: #11a84f;
    --zap-fundo: rgba(17, 168, 79, 0.12);
    --dinheiro: #0a9d86;
    --temp-quente: #16a34a;
    --temp-quente-fundo: rgba(22, 163, 74, 0.12);
    --temp-frio: #a6465a;
    --temp-frio-fundo: rgba(166, 70, 90, 0.12);
    --quente: #e0382b;
    --quente-fundo: rgba(224, 56, 43, 0.1);
    --morno: #d97706;
    --morno-fundo: rgba(217, 119, 6, 0.12);
    --frio: #2f6fe0;
    --frio-fundo: rgba(47, 111, 224, 0.1);
    --info: #0f8fd1;
  }
}

/* ---------- 2. BASE ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--fundo);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--fonte);
  font-size: var(--t-base);
  line-height: 1.45;
  color: var(--texto);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--fonte-titulo); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }
a { color: var(--marca-1); text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
.oculto { display: none !important; }

/* foco visível só para quem usa teclado */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--marca-1); outline-offset: 2px; border-radius: var(--r-sm); }

::selection { background: color-mix(in srgb, var(--marca-1) 35%, transparent); }

.ic { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.cheio { fill: currentColor; stroke: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* rolagem agradável */
.rola { overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.rola-x { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.rola-x::-webkit-scrollbar { display: none; }

/* ---------- 3. COMPONENTES ----------------------------------------------- */

/* botão ------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  min-height: 44px; padding: 0 var(--e5);
  border: 1px solid var(--linha-forte); border-radius: var(--r-md);
  background: var(--s2); color: var(--texto);
  font-size: var(--t-base); font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform var(--rapido) var(--mola), background var(--rapido), border-color var(--rapido), opacity var(--rapido);
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; pointer-events: none; }

.btn.primario {
  background: var(--marca-grad); border-color: transparent; color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--marca-2) 38%, transparent);
}
.btn.zap {
  background: var(--zap); border-color: transparent; color: #04210f;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--zap) 35%, transparent);
}
:root[data-tema='claro'] .btn.zap { color: #fff; }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--texto-2); }
.btn.perigo { background: var(--quente-fundo); border-color: transparent; color: var(--quente); }
.btn.pequeno { min-height: 36px; padding: 0 var(--e3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn.grande { min-height: 54px; padding: 0 var(--e6); font-size: var(--t-md); border-radius: var(--r-lg); }
.btn.cheio { width: 100%; }
.btn.icone { width: 44px; padding: 0; }
.btn.icone.pequeno { width: 36px; }

@media (hover: hover) {
  .btn:hover { background: var(--s3); }
  .btn.primario:hover { background: var(--marca-grad); filter: brightness(1.08); }
  .btn.zap:hover { background: var(--zap); filter: brightness(1.06); }
  .btn.fantasma:hover { background: var(--s2); }
}

/* campos ------------------------------------------------------------------ */
.campo { display: grid; gap: var(--e2); }
.campo > span, .rotulo { font-size: var(--t-sm); font-weight: 600; color: var(--texto-2); }
.campo small { color: var(--texto-3); font-size: var(--t-xs); font-weight: 400; }

input, select, textarea {
  width: 100%; min-height: 48px; padding: 0 var(--e4);
  font: inherit;
  /* 16px é o piso do iOS: abaixo disso o Safari dá zoom ao focar o campo. */
  font-size: 16px;
  color: var(--texto); background: var(--s2);
  border: 1px solid var(--linha); border-radius: var(--r-md);
  transition: border-color var(--rapido), box-shadow var(--rapido), background var(--rapido);
  -webkit-appearance: none; appearance: none;
}
textarea { padding: var(--e3) var(--e4); min-height: 96px; resize: vertical; line-height: 1.45; }
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a92a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--marca-1); background: var(--s1);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--marca-1) 22%, transparent);
}
input[type='checkbox'] { width: 22px; min-height: 22px; height: 22px; padding: 0; accent-color: var(--marca-1); }
/* Os campos perdem a aparência nativa (appearance: none), e com ela o desenho de "marcado":
   uma caixa marcada ficava igual a uma vazia. Desenho próprio, com o contraste da marca. */
input[type='checkbox'] { -webkit-appearance: none; appearance: none; flex: none; display: inline-grid; place-content: center; border: 2px solid var(--linha-forte); border-radius: 7px; background: var(--s2); cursor: pointer; }
input[type='checkbox']:checked { background: var(--marca-1); border-color: var(--marca-1); }
input[type='checkbox']:checked::after { content: ''; width: 6px; height: 11px; margin-top: -2px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
input[type='checkbox']:focus-visible { outline: 2px solid var(--marca-1); outline-offset: 2px; }
input[type='datetime-local'], input[type='date'] { min-height: 48px; }

.busca { position: relative; }
.busca .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--texto-3); pointer-events: none; }
.busca input { padding-left: 42px; border-radius: var(--r-pill); }

/* chips e tags ------------------------------------------------------------ */
.chips { display: flex; gap: var(--e2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 0 var(--e4);
  border: 1px solid var(--linha); border-radius: var(--r-pill);
  background: var(--s1); color: var(--texto-2);
  font-size: var(--t-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--rapido), color var(--rapido), border-color var(--rapido), transform var(--rapido) var(--mola);
  touch-action: manipulation;
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed='true'], .chip.ativo { background: var(--texto); color: var(--fundo); border-color: transparent; }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; font-weight: 700; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--s2); color: var(--texto-2);
  font-size: var(--t-xs); font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.tag.zap { background: var(--zap-fundo); color: var(--zap); }
.tag.quente { background: var(--quente-fundo); color: var(--quente); }
.tag.morno { background: var(--morno-fundo); color: var(--morno); }
.tag.frio { background: var(--frio-fundo); color: var(--frio); }
/* temperatura do lead (semáforo) — ver os tokens --temp-* */
.tag.t-quente { background: var(--temp-quente-fundo); color: var(--temp-quente); }
.tag.t-morno { background: var(--morno-fundo); color: var(--morno); }
.tag.t-frio { background: var(--temp-frio-fundo); color: var(--temp-frio); }
.tag.dinheiro { background: color-mix(in srgb, var(--dinheiro) 15%, transparent); color: var(--dinheiro); }
.tag.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }

/* controle segmentado ----------------------------------------------------- */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--s2); }
.seg button {
  min-height: 38px; padding: 0 var(--e4); border: 0; border-radius: calc(var(--r-md) - 3px);
  background: transparent; color: var(--texto-2); font-size: var(--t-sm); font-weight: 600; cursor: pointer;
  transition: background var(--rapido), color var(--rapido);
}
.seg button[aria-pressed='true'] { background: var(--s1); color: var(--texto); box-shadow: var(--sombra-1); }

/* cartão ------------------------------------------------------------------ */
.cartao {
  background: var(--s1); border: 1px solid var(--linha); border-radius: var(--r-lg);
  box-shadow: var(--brilho); padding: var(--e4);
}
.cartao.sem-borda { border-color: transparent; }
.cartao-titulo { display: flex; align-items: center; justify-content: space-between; gap: var(--e3); margin-bottom: var(--e3); }
.cartao-titulo h3 { font-size: var(--t-md); }
.cartao-titulo .btn { margin-right: calc(var(--e2) * -1); }

.vidro { background: var(--vidro); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }

/* linha de lista ---------------------------------------------------------- */
.linha {
  display: flex; align-items: center; gap: var(--e3);
  min-height: 56px; padding: var(--e3) var(--e4);
  background: transparent; border: 0; width: 100%; text-align: left; color: inherit; cursor: pointer;
  touch-action: manipulation;
}
.linha + .linha { border-top: 1px solid var(--linha); }
.linha:active { background: var(--s2); }
.linha .corpo { flex: 1; min-width: 0; }
.linha .titulo { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .sub { display: block; color: var(--texto-3); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .ic.seta { color: var(--texto-3); width: 1em; height: 1em; }
@media (hover: hover) { .linha:hover { background: var(--s2); } }

/* nota circular (anel) ---------------------------------------------------- */
.anel { position: relative; width: 46px; height: 46px; flex: none; display: grid; place-items: center; }
.anel svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.anel circle { fill: none; stroke-width: 4; stroke-linecap: round; }
.anel .trilho { stroke: var(--s3); }
.anel .valor { stroke: var(--cor-anel, var(--temp-frio)); transition: stroke-dashoffset 700ms var(--mola); }
.anel b { font-size: var(--t-sm); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.anel.t-quente { --cor-anel: var(--temp-quente); }
.anel.t-morno { --cor-anel: var(--morno); }
.anel.t-frio { --cor-anel: var(--temp-frio); }
.anel.grande { width: 84px; height: 84px; }
.anel.grande b { font-size: var(--t-xl); }
.anel.grande circle { stroke-width: 6; }

/* barra de progresso ------------------------------------------------------ */
.barra { height: 8px; border-radius: var(--r-pill); background: var(--s3); overflow: hidden; }
.barra > i { display: block; height: 100%; width: var(--pct, 0%); border-radius: inherit; background: var(--marca-grad); transition: width 600ms var(--mola); }
.barra.ok > i { background: var(--dinheiro); }
.barra.aviso > i { background: var(--morno); }
.barra.cheia > i { background: var(--quente); }

/* esqueleto --------------------------------------------------------------- */
.esqueleto {
  border-radius: var(--r-md); min-height: 72px;
  background: linear-gradient(100deg, var(--s1) 30%, var(--s2) 50%, var(--s1) 70%);
  background-size: 300% 100%; animation: brilha 1.4s linear infinite;
}
@keyframes brilha { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* vazio ------------------------------------------------------------------- */
.vazio { display: grid; justify-items: center; gap: var(--e3); text-align: center; padding: var(--e10) var(--e6); color: var(--texto-2); }
.vazio .emoji { font-size: 44px; line-height: 1; }
.vazio h3 { color: var(--texto); font-size: var(--t-lg); }
.vazio p { max-width: 34ch; }

/* aviso (toast) ----------------------------------------------------------- */
.avisos {
  position: fixed; left: 0; right: 0; z-index: 90; display: grid; justify-items: center; gap: var(--e2);
  bottom: calc(var(--altura-tabbar) + var(--sai-b) + var(--e4)); padding: 0 var(--e4); pointer-events: none;
}
.notificacao {
  display: flex; align-items: center; gap: var(--e3); max-width: min(92vw, 460px);
  padding: var(--e3) var(--e4); border-radius: var(--r-md); pointer-events: auto;
  background: var(--texto); color: var(--fundo); font-size: var(--t-sm); font-weight: 600;
  box-shadow: var(--sombra-2); animation: sobe var(--medio) var(--mola);
}
.notificacao button { background: transparent; border: 0; color: var(--marca-1); font-weight: 700; min-height: 32px; padding: 0 var(--e2); cursor: pointer; }
:root:not([data-tema='claro']) .notificacao button { color: #3b63d6; }
.notificacao.erro { background: var(--quente); color: #fff; }
@keyframes sobe { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

/* mensagem inline --------------------------------------------------------- */
.msg { font-size: var(--t-sm); min-height: 1.2em; color: var(--texto-2); }
.msg.ok { color: var(--dinheiro); }
.msg.erro { color: var(--quente); }
.msg.aviso { color: var(--morno); }

/* kbd --------------------------------------------------------------------- */
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--s3); color: var(--texto-2); font-size: 11px; font-weight: 700; }

/* movimento reduzido ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* vigia: a camada que cobre a tela quando o console está aberto. Vale para
   a tela de entrada e para o app, por isso mora aqui. */
#vigia-trava { position: fixed; inset: 0; z-index: 2147483647; display: grid; place-items: center; background: var(--fundo); color: var(--texto); text-align: center; padding: var(--e6); }
.vigia-caixa { display: grid; gap: var(--e3); max-width: 340px; }
.vigia-icone { font-size: 44px; }
.vigia-dim { color: var(--texto-3); }
.vigia-selo { color: var(--quente); font-weight: 700; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; }
