/* Controle do Motorista — tela pensada primeiro para o celular.
   O elemento de destaque é o medidor da meta semanal; o resto fica discreto. */

:root {
  color-scheme: dark light;
  --fundo: #0b0f19;
  --painel: #111827;
  --painel-2: #182033;
  --linha: #243049;
  --texto: #e8ecf3;
  --suave: #9aa4b5;
  --acento: #6366f1;
  --acento-2: #22d3ee;
  --pos: #34d399;
  --neg: #f87171;
  --aviso: #fbbf24;
  --raio: 16px;
  --raio-campo: 12px;
  --nav-h: 64px;
  --seguro-baixo: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --fundo: #f3f5fa;
    --painel: #ffffff;
    --painel-2: #eef1f8;
    --linha: #d9dfec;
    --texto: #111827;
    --suave: #5b6578;
    --acento: #4f46e5;
    --acento-2: #0891b2;
    --pos: #059669;
    --neg: #dc2626;
    --aviso: #b45309;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acento-2); outline-offset: 2px; }

/* ---------- estrutura ---------- */
#raiz { max-width: 640px; margin: 0 auto; }
.tela { padding: 16px 16px calc(var(--nav-h) + var(--seguro-baixo) + 96px); }
.tela-cheia { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }

.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 16px; }
.topo h1 { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.01em; }
.topo .sub { color: var(--suave); font-size: 0.875rem; }
.secao { font-size: 1rem; font-weight: 700; margin: 24px 0 10px; }
.secao small { color: var(--suave); font-weight: 500; margin-left: 6px; }

.cartao {
  background: var(--painel);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 16px;
}
.cartao + .cartao { margin-top: 12px; }
.suave { color: var(--suave); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- campos ---------- */
.campo { display: block; }
.campo > span { display: block; font-size: 0.8125rem; color: var(--suave); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="date"], input[type="search"], select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--painel-2);
  border: 1px solid var(--linha);
  border-radius: var(--raio-campo);
}
select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa4b5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input:focus, select:focus { border-color: var(--acento); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 30%, transparent); }
.seletor-mes { width: auto; min-height: 40px; padding: 6px 12px; font-size: 0.9375rem; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pilha > * + * { margin-top: 12px; }
.linha { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
fieldset { border: 1px solid var(--linha); border-radius: var(--raio); margin: 16px 0 0; padding: 12px 14px 16px; }
legend { padding: 0 6px; font-weight: 650; font-size: 0.9375rem; }
.chave { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 2px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.chave { cursor: pointer; }
.chave input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--painel-2); border: 2px solid var(--suave);
}
.chave input[type="checkbox"]:checked {
  background: var(--acento) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--acento);
}

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--painel-2); border: 1px solid var(--linha); border-radius: var(--raio-campo); padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg label { position: relative; cursor: pointer; font-weight: 600; font-size: 0.9375rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 11px 6px; border-radius: 9px; }
.seg input:checked + span { background: var(--acento); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--acento-2); }

/* ---------- botões ---------- */
.botao {
  min-height: 48px; padding: 10px 18px; border-radius: var(--raio-campo);
  border: 1px solid var(--linha); background: var(--painel-2); font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--texto);
}
.botao:active { transform: translateY(1px); }
.botao.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.botao.perigo { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, var(--linha)); background: transparent; }
.botao.cheio { width: 100%; }
.botao.pequeno { min-height: 40px; padding: 6px 14px; font-size: 0.9375rem; }
.botao[disabled] { opacity: 0.55; pointer-events: none; }
.acoes { display: flex; gap: 12px; margin-top: 20px; }
.acoes .primario { flex: 1; }
.fab {
  position: fixed; z-index: 20; right: max(16px, calc((100vw - 640px) / 2 + 16px));
  bottom: calc(var(--nav-h) + var(--seguro-baixo) + 16px);
  min-height: 52px; padding: 0 22px; border-radius: 999px; border: none;
  background: var(--acento); color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- navegação inferior ---------- */
.abas {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--painel) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--linha);
  padding-bottom: var(--seguro-baixo);
}
.abas-lista { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.aba { height: var(--nav-h); border: none; background: none; color: var(--suave); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.75rem; font-weight: 600; }
.aba svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.aba[aria-current="page"] { color: var(--acento-2); }

/* ---------- medidor da meta (destaque da tela) ---------- */
.meta { padding: 18px 16px 16px; }
.meta-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meta-topo h2 { font-size: 1rem; font-weight: 700; }
.meta-topo span { color: var(--suave); font-size: 0.8125rem; }
.medidor { position: relative; max-width: 360px; margin: 6px auto 0; }
.medidor svg { display: block; width: 100%; height: auto; overflow: visible; }
.medidor .trilho { stroke: var(--painel-2); }
.medidor .avanco { stroke: url(#gradMeta); transition: stroke-dasharray 0.7s ease; }
.medidor .avanco.ok { stroke: var(--pos); }
.medidor .ponto-proj { fill: var(--painel); stroke: var(--acento-2); stroke-width: 3; }
.medidor-centro { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; }
.medidor-valor { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.medidor-de { color: var(--suave); font-size: 0.875rem; margin-top: 2px; }
.meta-texto { margin-top: 14px; display: grid; gap: 6px; font-size: 0.9375rem; }
.meta-texto .destaque { font-weight: 650; }
.meta-texto .nota { color: var(--suave); font-size: 0.875rem; }
.aviso-vazio { text-align: center; color: var(--suave); padding: 12px 0 4px; }

/* ---------- comparativos e indicadores ---------- */
.comp { display: grid; gap: 12px; }
.comp-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.comp-item .rot { font-size: 0.8125rem; color: var(--suave); }
.comp-item .val { font-size: 1.125rem; font-weight: 700; }
.delta { font-size: 0.8125rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--painel-2); white-space: nowrap; }
.delta.pos { color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, transparent); }
.delta.neg { color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, transparent); }
.grade-kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.kpi .rot { font-size: 0.8125rem; color: var(--suave); }
.kpi .val { font-size: 1.25rem; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.kpi.forte { grid-column: span 2; padding: 14px 16px; }
.kpi.forte .val { font-size: 1.75rem; }
.kpi.forte.pos { border-color: color-mix(in srgb, var(--pos) 50%, var(--linha)); }
.kpi.forte.neg { border-color: color-mix(in srgb, var(--neg) 50%, var(--linha)); }

.grafico { overflow-x: auto; padding-bottom: 4px; }
.grafico svg { display: block; }
.grafico .b-pos { fill: var(--pos); }
.grafico .b-neg { fill: var(--neg); }
.grafico text { fill: var(--suave); font-size: 10px; }
.grafico .media { stroke: var(--aviso); stroke-dasharray: 4 4; stroke-width: 1.5; }

/* ---------- listas ---------- */
.lista { display: grid; gap: 8px; }
.mes-sep { font-size: 0.8125rem; color: var(--suave); font-weight: 650; margin: 14px 2px 2px; }
.item {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; padding: 10px 14px;
}
.item:active { background: var(--painel-2); }
.item-data { text-align: center; line-height: 1.1; }
.item-data b { display: block; font-size: 1.375rem; }
.item-data span { font-size: 0.75rem; color: var(--suave); }
.item-lucro { font-size: 1.0625rem; font-weight: 700; }
.item-sub { font-size: 0.8125rem; color: var(--suave); margin-top: 2px; }
.item-fim { text-align: right; font-size: 0.8125rem; color: var(--suave); white-space: nowrap; }
.item.folga .item-lucro { color: var(--suave); font-weight: 600; }
.vazio { text-align: center; color: var(--suave); padding: 36px 16px; }
.vazio b { display: block; color: var(--texto); font-size: 1.0625rem; margin-bottom: 4px; }

/* ---------- conta ---------- */
.bloco { margin-top: 24px; }
.bloco > h2 { font-size: 1rem; font-weight: 700; margin-bottom: 10px; }
.linha-info { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linha); }
.linha-info:last-child { border-bottom: none; }
.linha-info .suave { font-size: 0.875rem; }
.nota { font-size: 0.8125rem; color: var(--suave); margin-top: 8px; }
.botoes { display: grid; gap: 10px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; color: #fff; background: linear-gradient(135deg, var(--acento), var(--acento-2)); flex: none; }
.perfil { display: flex; align-items: center; gap: 14px; }
.perfil b { display: block; font-size: 1.0625rem; }
.etiqueta { display: inline-block; font-size: 0.75rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--painel-2); color: var(--suave); }

/* ---------- login e caixas ---------- */
.marca { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.marca-icone { width: 56px; height: 56px; border-radius: 16px; flex: none; }
.marca h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.marca p { color: var(--suave); font-size: 0.9375rem; }
.erro { color: var(--neg); background: color-mix(in srgb, var(--neg) 12%, transparent); border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent); border-radius: var(--raio-campo); padding: 10px 14px; font-size: 0.9375rem; margin-top: 12px; }

/* ---------- folha de baixo (formulários) ---------- */
.fundo-folha { position: fixed; inset: 0; z-index: 30; background: rgba(5, 8, 15, 0.6); }
.folha {
  position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--fundo); border: 1px solid var(--linha); border-bottom: none; border-radius: 22px 22px 0 0;
  padding: 0 16px; animation: sobe 0.2s ease-out;
}
@keyframes sobe { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.folha-topo { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 14px 0 10px; }
.folha-topo h2 { font-size: 1.25rem; font-weight: 750; }
.folha-corpo { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--seguro-baixo)); }
.fechar { flex: none; border: none; background: var(--painel-2); width: 44px; height: 44px; border-radius: 50%; font-size: 1.25rem; line-height: 1; color: var(--suave); }
.previa { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--painel); border: 1px dashed var(--linha); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.previa b { font-size: 1.25rem; }
.previa small { display: block; color: var(--suave); font-size: 0.75rem; }

/* ---------- avisos ---------- */
#aviso { position: fixed; z-index: 40; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--seguro-baixo) + 84px); max-width: 420px; margin: 0 auto; pointer-events: none; }
.aviso { background: var(--texto); color: var(--fundo); padding: 12px 16px; border-radius: 12px; font-weight: 600; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.aviso.ruim { background: var(--neg); color: #fff; }

@media (min-width: 720px) {
  .tela { padding-top: 28px; }
  .grade-kpi { grid-template-columns: repeat(3, 1fr); }
  .kpi.forte { grid-column: span 3; }
}
@media (prefers-reduced-motion: reduce) {
  .folha { animation: none; }
  .medidor .avanco { transition: none; }
}
