:root {
  /* paleta "grafite": base neutra, como nos apps de mobilidade. A única cor
     forte da tela é a do semáforo de decisão, que é a informação que importa */
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #ececee;
  --text: #111113;
  --text-dim: #5f5f68;
  --border: #dedee2;
  --brand: #111113;
  --brand-soft: #e9e9ec;
  --on-brand: #ffffff;
  --otima: #0f9d58;
  --otima-bg: #e4f5ec;
  --boa: #1a73c7;
  --boa-bg: #e2eefb;
  --regular: #c47600;
  --regular-bg: #fcf0dc;
  --recusar: #cc2f3e;
  --recusar-bg: #fbe5e7;
  --shadow: 0 1px 2px rgba(17,17,19,.06), 0 4px 16px rgba(17,17,19,.06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* cor da última decisão: acende o fundo. Sem decisão na tela, nada acende */
  --sinal: transparent;
  /* intensidade do brilho: discreto no claro, aceso no escuro */
  --glow: .45;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --surface: #151517;
    --surface-2: #1e1e21;
    --text: #f4f4f5;
    --text-dim: #9b9ba3;
    --border: #2a2a2e;
    --brand: #f4f4f5;
    --brand-soft: #232326;
    --on-brand: #0a0a0b;
    --otima: #3ee07f;
    --otima-bg: #0f2a1b;
    --boa: #5fb4ff;
    --boa-bg: #102236;
    --regular: #ffb547;
    --regular-bg: #2e220c;
    --recusar: #ff5d6c;
    --recusar-bg: #33121a;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.4);
    --glow: 1;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --surface: #151517; --surface-2: #1e1e21;
  --text: #f4f4f5; --text-dim: #9b9ba3; --border: #2a2a2e;
  --brand: #f4f4f5; --brand-soft: #232326; --on-brand: #0a0a0b;
  --otima: #3ee07f; --otima-bg: #0f2a1b;
  --boa: #5fb4ff; --boa-bg: #102236;
  --regular: #ffb547; --regular-bg: #2e220c;
  --recusar: #ff5d6c; --recusar-bg: #33121a;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.4);
  --glow: 1;
}

* { box-sizing: border-box; }

/* a barra inferior é fixa: reserva espaço ao rolar até um elemento */
html { scroll-padding-bottom: 96px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* telas de nível superior: só a ativa aparece */
.screen:not(.active) { display: none; }

/* ── LOGIN ── */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; color: var(--brand); }
.brand h1 { margin: 0; font-size: 30px; letter-spacing: -.5px; color: var(--text); }
.brand-mark { width: 44px; height: 44px; }
.brand-mark.sm { width: 26px; height: 26px; }
.tagline { text-align: center; color: var(--text-dim); font-size: 14.5px; margin: 10px 0 26px; }

label { display: block; margin-bottom: 14px; font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.hint { font-weight: 400; opacity: .8; }
.unit { font-weight: 400; color: var(--text-dim); opacity: .75; }

input, select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  height: 48px;          /* o select do navegador sai 2px mais alto que o input */
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

button { font-family: inherit; cursor: pointer; }
.btn-primary {
  width: 100%; padding: 13px;
  font-size: 15.5px; font-weight: 650;
  color: var(--on-brand); background: var(--brand);
  border: none; border-radius: 11px;
  transition: filter .15s, transform .08s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-lg { padding: 15px; font-size: 16.5px; margin-top: 4px; }
.btn-ghost {
  width: 100%; padding: 11px; margin-top: 9px;
  font-size: 14.5px; font-weight: 600;
  color: var(--brand); background: transparent;
  border: 1.5px solid var(--border); border-radius: 11px;
}
.btn-ghost:hover { background: var(--surface-2); }
.row-buttons { display: flex; gap: 10px; }
.row-buttons .btn-ghost { margin-top: 0; }

.form-error { color: var(--recusar); font-size: 13.5px; margin: 12px 0 0; min-height: 1em; }
.form-ok { color: var(--otima); font-size: 13.5px; margin: 10px 0 0; min-height: 1em; }

/* ── TOPBAR ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17.5px; color: var(--brand); }
.topbar-brand span { color: var(--text); letter-spacing: -.3px; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  color: var(--text-dim); background: transparent;
  border: none; border-radius: 10px; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10.5px; font-weight: 700; line-height: 16px;
  color: #fff; background: var(--recusar);
  border-radius: 8px;
}

main { padding: 18px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }
.tab-title { font-size: 21px; margin: 2px 0 16px; letter-spacing: -.3px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card-note { margin: 0 0 16px; font-size: 13px; color: var(--text-dim); }
.card h3 + form, .card h3 + .row-buttons { margin-top: 16px; }

/* alinha pela base: quando um rótulo quebra em duas linhas, as caixas da
   mesma linha continuam niveladas */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
.field-grid .full, .full { grid-column: 1 / -1; }
/* campo de data tem largura mínima própria e empurraria a tela para o lado */
.field-grid > * { min-width: 0; }
input[type="date"] { min-width: 0; }
@media (max-width: 380px) { .field-grid { grid-template-columns: 1fr; } }

/* ── CHIPS ── */
.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  flex: none; padding: 7px 15px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-dim); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 999px;
  transition: all .15s;
}
.chip.active { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }

/* ── RESULTADO ── */
.result {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--rc, var(--border));
  box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.result-head { padding: 20px; background: var(--rcbg); text-align: center; }
.verdict { font-size: 30px; font-weight: 800; letter-spacing: -.6px; color: var(--rc); margin: 0; }
.verdict-sub { margin: 6px 0 0; font-size: 14px; color: var(--text-dim); line-height: 1.45; }
.result-body { background: var(--surface); padding: 4px 18px 18px; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); margin: 0 -18px; }
.metric { background: var(--surface); padding: 14px 18px; }
.metric .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.metric .v { font-size: 20px; font-weight: 700; margin-top: 3px; letter-spacing: -.4px; }
.metric .v.pos { color: var(--otima); }
.metric .v.neg { color: var(--recusar); }

.factors { margin-top: 18px; }
.factors h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin: 0 0 10px; }
.factor {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--border);
  font-size: 14px;
}
.factor .mark { flex: none; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; }
.factor.ok .mark { background: var(--otima); }
.factor.no .mark { background: var(--recusar); }
.factor .lbl { flex: 1; }
.factor .val { font-variant-numeric: tabular-nums; font-weight: 650; }
.factor .lim { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.save-row { display: flex; gap: 10px; margin-top: 16px; }
.save-row button { flex: 1; margin-top: 0; }

/* ── PAINEL ── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 15px; box-shadow: var(--shadow);
}
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.stat .v { font-size: 21px; font-weight: 750; margin-top: 4px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .v.pos { color: var(--otima); }
.stat .v.neg { color: var(--recusar); }
.stat.wide { grid-column: 1 / -1; }

.bars { display: grid; gap: 9px; margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .name { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--text-dim); border-radius: 5px; transition: width .5s cubic-bezier(.2,.8,.3,1); }
.bar-row .amt { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 12.5px; }

.goal-bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin: 12px 0 8px; }
.goal-fill { display: block; height: 100%; background: var(--otima); border-radius: 6px; transition: width .6s; }

/* ── HISTÓRICO ── */
.ride {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 13px 15px; margin-bottom: 9px;
}
.pill {
  flex: none; padding: 4px 9px; border-radius: 7px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .4px;
}
.pill.OTIMA { color: var(--otima); background: var(--otima-bg); }
.pill.BOA { color: var(--boa); background: var(--boa-bg); }
.pill.REGULAR { color: var(--regular); background: var(--regular-bg); }
.pill.RECUSAR { color: var(--recusar); background: var(--recusar-bg); }
.ride-main { flex: 1; min-width: 0; }
.ride-top { font-weight: 650; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.ride-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.ride-profit { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.ride-profit.pos { color: var(--otima); }
.ride-profit.neg { color: var(--recusar); }

.ride { flex-wrap: wrap; }
.ride-acoes { flex-basis: 100%; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.ride-acoes .rotulo { margin-right: auto; }
.btn-nota {
  padding: 5px 12px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); background: var(--surface); border: 1.5px solid var(--border); border-radius: 999px;
}
.btn-nota[aria-pressed="true"].boa { color: var(--otima); background: var(--otima-bg); border-color: var(--otima); }
.btn-nota[aria-pressed="true"].ruim { color: var(--recusar); background: var(--recusar-bg); border-color: var(--recusar); }

.hist-filtros { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 14px 15px 0; margin-bottom: 14px; }
.hist-filtros .btn-ghost { margin-top: 6px; width: 100%; height: 48px; }

/* ── CARD RÁPIDO: os quatro números que decidem num olhar ── */
.rapido { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 16px 0 4px; }
.rapido > div { text-align: center; padding: 10px 4px; border-radius: 11px; background: var(--surface-2); min-width: 0; }
.rapido .k { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.rapido .v { font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 2px; }
.rapido > .ok { background: var(--otima-bg); }
.rapido .ok .v { color: var(--otima); }
.rapido > .no { background: var(--recusar-bg); }
.rapido .no .v { color: var(--recusar); }
@media (max-width: 360px) { .rapido { grid-template-columns: repeat(2, 1fr); } }
.modo-nota { font-size: 12.5px; color: var(--text-dim); margin: 8px 0 0; }

/* ── LUGARES ── */
.aviso-lugar { margin: 14px 0 0; padding: 11px 13px; border-radius: 11px; font-size: 14px; border: 1.5px solid; }
.aviso-lugar.bom { color: var(--otima); background: var(--otima-bg); }
.aviso-lugar.atencao { color: var(--regular); background: var(--regular-bg); }
.aviso-lugar.ruim { color: var(--recusar); background: var(--recusar-bg); }
.aviso-lugar b { display: block; }
.anotar { margin-top: 14px; font-size: 13px; color: var(--text-dim); }
.anotar .row-buttons { margin-top: 6px; }
.anotar .btn-ghost { flex: 1; }
.lugar-tag { flex: none; padding: 4px 9px; border-radius: 7px; font-size: 11px; font-weight: 800; }
.lugar-tag.bom { color: var(--otima); background: var(--otima-bg); }
.lugar-tag.atencao { color: var(--regular); background: var(--regular-bg); }
.lugar-tag.ruim { color: var(--recusar); background: var(--recusar-bg); }

/* ── ESCOLHAS (modo do semáforo, tema) ── */
fieldset.modo { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.modo legend { padding: 0; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.opcao {
  display: flex; gap: 11px; align-items: flex-start; margin-bottom: 8px; padding: 11px 13px;
  font-weight: 400; color: var(--text); border: 1.5px solid var(--border); border-radius: 11px; cursor: pointer;
}
.opcao b { font-weight: 650; }
.opcao span { font-size: 13.5px; line-height: 1.4; }
.opcao input { width: auto; height: auto; margin: 3px 0 0; accent-color: var(--brand); }
.opcao:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.opcao:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }

/* ── ALERTAS ── */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(8,9,16,.5); display: grid; align-items: end; }
.sheet-body {
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(24px + var(--safe-b));
  max-height: 78dvh; overflow-y: auto;
  animation: slideup .25s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.alert-item {
  border-left: 3px solid var(--regular);
  background: var(--surface-2);
  border-radius: 0 11px 11px 0;
  padding: 12px 14px; margin-bottom: 10px;
}
.alert-item.critico { border-left-color: var(--recusar); }
.alert-item .t { font-weight: 650; font-size: 14.5px; }
.alert-item .m { font-size: 13px; color: var(--text-dim); margin-top: 4px; line-height: 1.45; }
.alert-item button { margin-top: 10px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--brand); background: transparent; border: 1.5px solid var(--border); border-radius: 8px; }

/* ── TABBAR ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tabbtn {
  display: grid; justify-items: center; gap: 3px;
  padding: 9px 4px 8px;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-dim); background: transparent; border: none;
  transition: color .15s;
}
.tabbtn svg { width: 22px; height: 22px; }
.tabbtn.active { color: var(--brand); }

/* ── DIVERSOS ── */
.loading, .empty { text-align: center; color: var(--text-dim); font-size: 14px; padding: 36px 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60; max-width: 90vw;
  padding: 11px 18px; border-radius: 11px;
  font-size: 14px; font-weight: 600;
  color: #fff; background: #23283a;
  box-shadow: 0 6px 22px rgba(0,0,0,.28);
  animation: fade .2s;
}
.toast.err { background: var(--recusar); }

/* bloco de busca de rota: separado do resto do formulário por uma linha */
.route-box {
  display: grid;
  gap: 0;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.route-box .btn-ghost { margin-top: 4px; }
.route-hint { margin: 8px 0 0; min-height: 1em; font-size: 13px; }
.route-hint.err { color: var(--recusar); opacity: 1; }

/* botão de localização e o aviso do GPS */
.btn-gps { margin-bottom: 4px; }
.gps-hint { margin: 2px 0 6px; font-size: 13px; }
.gps-hint.ok { color: var(--otima); opacity: 1; }
.gps-hint.err { color: var(--recusar); opacity: 1; }
/* campo de endereço apagado quando o GPS está mandando */
#f-addr-driver.por-gps { opacity: .55; }

/* botão de excluir nas listas (corridas, despesas, metas) */
.btn-del {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 14px; color: var(--text-dim);
  background: transparent; border: 1.5px solid var(--border); border-radius: 8px;
}
.btn-del:hover { color: var(--recusar); border-color: var(--recusar); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; }
.plat-sub { grid-column: 2 / -1; margin-top: -5px; font-size: 11.5px; color: var(--text-dim); }

/* gráfico de faturamento e lucro por dia */
.dias { display: flex; align-items: flex-end; gap: 3px; height: 130px; margin-top: 12px; }
.dia { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dia-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 1px; }
.dia-fat, .dia-luc { width: 45%; max-width: 12px; border-radius: 3px 3px 0 0; min-height: 1px; }
.dia-fat { background: var(--text-dim); }
.dia-luc { background: var(--otima); }
.dia-luc.neg { background: var(--recusar); }
.dia-lbl { font-size: 9.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.legenda { margin: 10px 0 0; display: flex; align-items: center; gap: 6px; }
.legenda .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legenda .sw.fat { background: var(--text-dim); }
.legenda .sw.luc { background: var(--otima); margin-left: 10px; }
.bar-fill.neg { background: var(--recusar); }

/* ══ MOVIMENTO E BRILHO ══════════════════════════════════════════════════
   A mesma linguagem do cartão (/cartao): números que contam, barras que
   enchem até a marca do limite, o selo da decisão que acende e o fundo que
   ganha a cor da última recomendação. No tema claro o brilho é discreto
   (--glow menor); no escuro, o "painel noturno", ele aparece de verdade.
   Quem pediu menos movimento ao sistema vê tudo parado (fim do arquivo). */

body {
  background:
    radial-gradient(ellipse 90% 340px at 50% -60px,
      color-mix(in srgb, var(--sinal) calc(var(--glow) * 22%), transparent), transparent 75%)
    no-repeat,
    var(--bg);
  background-attachment: fixed;
  transition: background-color .4s ease;
}

/* topo e barra de abas um pouco mais translúcidos para o brilho passar */
.topbar { background: color-mix(in srgb, var(--bg) 72%, transparent); }
.tabbar { background: color-mix(in srgb, var(--bg) 82%, transparent); }

/* troca de aba: entra subindo um pouco, sem pular */
.tab.active { animation: entra .32s cubic-bezier(.2,.8,.2,1); }
@keyframes entra { from { opacity: 0; transform: translateY(10px); } }

/* aba ativa: um "trilho" aceso em cima do ícone */
.tabbtn { position: relative; transition: color .2s ease, transform .15s ease; }
.tabbtn::before {
  content: ""; position: absolute; top: 0; left: 50%;
  width: 0; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--brand);
  transform: translateX(-50%);
  transition: width .3s cubic-bezier(.2,.8,.2,1);
}
.tabbtn.active::before { width: 28px; }
.tabbtn:active { transform: scale(.94); }

/* cartões e números do painel entram em cascata (--i vem do JS) */
.stat, .card, .ride { animation: sobe .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }
.stat .v, .metric .v, .rapido .v { font-variant-numeric: tabular-nums; }

/* barras crescem a partir do zero */
.bar-fill, .goal-fill { transform-origin: left; animation: cresce-x .9s cubic-bezier(.2,.8,.2,1) both; }
.dia-fat, .dia-luc { transform-origin: bottom; animation: cresce-y .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes cresce-x { from { transform: scaleX(0); } }
@keyframes cresce-y { from { transform: scaleY(0); } }

/* botões: resposta ao toque e um leve brilho no principal */
.btn-primary { box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.btn-ghost, .chip, .btn-nota { transition: background-color .15s, border-color .15s, color .15s, transform .1s; }
.btn-ghost:active, .chip:active, .btn-nota:active { transform: scale(.97); }

/* ── resultado: o selo da decisão ── */
.result {
  border: 1px solid color-mix(in srgb, var(--rc) 55%, var(--border));
  box-shadow: var(--shadow), 0 0 calc(var(--glow) * 40px) color-mix(in srgb, var(--rc) 22%, transparent);
  animation: pop .35s cubic-bezier(.2,.9,.3,1.2);
}
.result-head {
  background:
    radial-gradient(ellipse 80% 120% at 50% 0%, color-mix(in srgb, var(--rc) calc(var(--glow) * 30%), transparent), transparent 70%),
    var(--rcbg);
  padding: 22px 20px 20px;
}
.verdict {
  display: inline-block;
  padding: 6px 18px;
  border: 2px solid var(--rc);
  border-radius: 14px;
  background: color-mix(in srgb, var(--rc) 10%, transparent);
  box-shadow: 0 0 calc(var(--glow) * 26px) color-mix(in srgb, var(--rc) 40%, transparent);
  text-shadow: 0 0 calc(var(--glow) * 16px) color-mix(in srgb, var(--rc) 55%, transparent);
  animation: acende .5s .15s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes acende { from { opacity: 0; transform: scale(.8); } }

/* critérios: barra com a marca do limite, como no cartão */
.factor { flex-wrap: wrap; row-gap: 6px; }
.factor.ok .mark { box-shadow: 0 0 calc(var(--glow) * 12px) var(--otima); }
.factor.no .mark { box-shadow: 0 0 calc(var(--glow) * 12px) var(--recusar); }
.factor.ok .val { color: var(--otima); }
.factor.no .val { color: var(--recusar); }
.factor-bar {
  flex-basis: 100%;
  position: relative; height: 6px; border-radius: 6px;
  background: var(--surface-2); overflow: hidden;
}
.factor-bar i {
  position: absolute; inset: 0 auto 0 0; border-radius: inherit;
  transform-origin: left; animation: cresce-x .9s .2s cubic-bezier(.2,.8,.2,1) both;
}
.factor.ok .factor-bar i { background: var(--otima); }
.factor.no .factor-bar i { background: var(--recusar); }
.factor-bar b { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--text); opacity: .55; }

.rapido > div { transition: background-color .3s ease; }

/* histórico: o selo de cada corrida com um brilho mínimo */
.pill { box-shadow: 0 0 calc(var(--glow) * 10px) color-mix(in srgb, currentColor 25%, transparent); }

/* ══ COMPUTADOR ═══════════════════════════════════════════════════════════
   O app nasceu para o celular: uma coluna e a barra de abas embaixo. Numa tela
   larga isso deixava as laterais vazias. Daqui para cima as abas viram uma
   barra lateral e cada tela usa a largura: na avaliação, o formulário fica à
   esquerda e a decisão à direita, lado a lado. */
@media (min-width: 1000px) {
  html { scroll-padding-bottom: 0; }

  .tabbar {
    top: 0; bottom: 0; right: auto; width: 232px; z-index: 15;
    display: flex; flex-direction: column; gap: 4px;
    padding: 80px 12px 16px;
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tabbtn {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 12px;
    font-size: 14.5px; text-align: left;
  }
  .tabbtn:hover { background: var(--surface-2); color: var(--text); }
  .tabbtn.active { background: var(--surface-2); color: var(--text); }
  .tabbtn::before { top: 50%; left: 0; width: 3px; height: 0; border-radius: 0 3px 3px 0; transform: translateY(-50%); transition: height .3s cubic-bezier(.2,.8,.2,1); }
  .tabbtn.active::before { width: 3px; height: 22px; }
  .tabbtn:active { transform: none; }

  main { margin-left: 232px; max-width: none; padding: 28px 36px 48px; }
  main > .tab { max-width: 1180px; margin: 0 auto; }
  .tab-title { font-size: 24px; margin-bottom: 20px; }
  .toast { bottom: 28px; margin-left: 116px; }

  /* avaliar: formulário à esquerda, decisão à direita */
  #tab-calcular.active { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 0 22px; align-items: start; }
  #tab-calcular > .tab-title { grid-column: 1 / -1; }
  #form-ride { grid-column: 1; grid-row: 2; }
  #ride-result { grid-column: 2; grid-row: 2; position: sticky; top: 84px; }
  #tab-calcular:has(#ride-result.hidden)::after {
    content: "Preencha a oferta e toque em Calcular. A decisão aparece aqui, com o motivo de cada critério.";
    grid-column: 2; grid-row: 2; align-self: start;
    padding: 56px 32px; text-align: center; font-size: 15px; line-height: 1.5;
    color: var(--text-dim);
    border: 1.5px dashed var(--border); border-radius: var(--radius);
  }

  /* painel: quatro números por linha e os cartões em duas colunas */
  #painel-content { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  #painel-content > .stat-grid, #painel-content > .loading, #painel-content > .empty { grid-column: 1 / -1; }
  #painel-content .stat-grid { grid-template-columns: repeat(4, 1fr); }
  #painel-content .stat.wide { grid-column: span 2; }

  /* histórico e listas: duas colunas */
  #historico-content { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
  #historico-content > .loading, #historico-content > .empty { grid-column: 1 / -1; }

  /* gastos: o formulário à esquerda, o que já foi lançado à direita */
  #pane-despesas, #pane-energia, #pane-extra { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 0 22px; align-items: start; }
  #pane-despesas > .card-note, #energia-resumo { grid-column: 1 / -1; }

  /* ajustes: os cartões em duas colunas */
  #tab-ajustes.active { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  #tab-ajustes > .tab-title { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
