:root {
    --azul: #14213d;
    --azul-2: #22335c;
    --ambar: #fca311;
    --fundo: #eef1f6;
    --cartao: #ffffff;
    --texto: #16181d;
    --suave: #667085;
    --borda: #d7dce5;
    --ok: #12a150;
    --ok-fundo: #e5f7ec;
    --erro: #d92d20;
    --erro-fundo: #fdecea;
    --aviso: #b54708;
    --aviso-fundo: #fff4e0;
    --raio: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo); color: var(--texto); font-size: 16px; line-height: 1.4; }
a { color: var(--azul); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }

/* ---------- Barra superior ---------- */
.barra { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--azul); color: #fff; }
.marca { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: .01em; }
.marca-saca { position: relative; width: 22px; height: 24px; flex: none; background: var(--ambar); border-radius: 5px 5px 9px 9px; }
.marca-saca::before { content: ""; position: absolute; left: 4px; right: 4px; top: -4px; height: 7px; background: var(--ambar); border-radius: 3px; clip-path: polygon(0 100%, 15% 0, 85% 0, 100% 100%); filter: brightness(.85); }
.marca-saca::after { content: ""; position: absolute; left: 3px; right: 3px; top: 4px; height: 3px; background: var(--azul); opacity: .35; border-radius: 2px; }
.marca-saca.grande { width: 44px; height: 48px; border-radius: 9px 9px 16px 16px; }
.marca-saca.grande::before { left: 8px; right: 8px; top: -8px; height: 12px; }
.marca-saca.grande::after { left: 6px; right: 6px; top: 8px; height: 5px; }
.barra nav { display: flex; gap: 4px; flex-wrap: wrap; }
.barra nav a { white-space: nowrap; color: #dfe5f2; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.barra nav a:hover, .barra nav a:focus-visible { background: var(--azul-2); color: #fff; }

.conteudo { max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }

/* ---------- Componentes ---------- */
.cartao { background: var(--cartao); border-radius: var(--raio); padding: 18px; box-shadow: 0 1px 3px rgba(16,24,40,.08); margin-bottom: 16px; }
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 16px;
    border-radius: 12px; border: 1px solid var(--borda); background: #fff; color: var(--azul); font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1.1; text-decoration: none; cursor: pointer;
    transition: background .15s, transform .05s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primario { background: var(--ambar); border-color: var(--ambar); color: var(--azul); }
.btn.primario:hover { background: #f59e0b; }
.btn.leve { background: transparent; }
.btn.leve:hover { background: #f2f4f8; }
.btn.ativo { background: var(--azul); color: #fff; border-color: var(--azul); }
.btn.perigo { color: var(--erro); border-color: #f3c1bc; }
.btn.grande { min-height: 54px; font-size: 1.05rem; padding: 12px 22px; }

.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--suave); }
.form input:not([type=checkbox]) { font-family: inherit; font-size: 1rem; font-weight: 500; line-height: 1.2; color: var(--texto); padding: 12px 14px; min-height: 48px; border-radius: 10px; border: 1px solid var(--borda); background: #fff; width: 100%; }
.form input:focus { outline: 3px solid rgba(252,163,17,.35); border-color: var(--ambar); }
.form input:disabled { background: #f4f5f8; color: #555; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.linha { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form.linha label { flex: 1 1 220px; }
.form.linha label.curto { flex: 0 1 150px; }
.form.inline { flex-direction: row; gap: 8px; align-items: center; }
.form.inline input { min-height: 42px; padding: 8px 10px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; color: var(--texto); }
label.check input { width: 20px; height: 20px; }

.alerta { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.alerta.erro { background: var(--erro-fundo); color: var(--erro); }
.alerta.ok { background: var(--ok-fundo); color: var(--ok); }
.dica { color: var(--suave); font-size: .9rem; margin: 10px 0 0; }
.vazio { color: var(--suave); text-align: center; padding: 18px 0; }
.selo { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.selo.aberto { background: #e0f2fe; color: #075985; }
.selo.fechado { background: #ecfdf3; color: #027a48; }

/* ---------- Login ---------- */
.tela-login { background: radial-gradient(1200px 600px at 50% -10%, #2b3f6e 0, var(--azul) 60%); min-height: 100vh; }
.tela-login .conteudo { display: grid; place-items: center; min-height: 100vh; }
.login-caixa { width: min(400px, 100%); background: #fff; border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-marca { display: flex; align-items: center; gap: 12px; font-size: 2rem; font-weight: 800; color: var(--azul); justify-content: center; }
.login-sub { text-align: center; color: var(--suave); margin: 6px 0 20px; }

/* ---------- Usuários ---------- */
.lista-usuarios { list-style: none; padding: 0; margin: 0; }
.lista-usuarios li { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid #eef0f4; }
.lista-usuarios li > div { display: flex; flex-direction: column; flex: 1 1 200px; }
.lista-usuarios small { color: var(--suave); }
.lista-usuarios .inativo { opacity: .55; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10,15,30,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-caixa { background: #fff; border-radius: 16px; padding: 22px; width: min(420px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-caixa p { color: var(--suave); word-break: break-word; }
.modal-acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-acoes .espaco { flex: 1; }
.modal-caixa h2 { margin-bottom: 4px; }
.modal-caixa label small { font-weight: 500; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.enorme { min-height: 62px; font-size: 1.25rem; border-radius: 14px; width: 100%; }
button.link { appearance: none; border: 0; background: none; color: var(--azul); font: inherit; font-weight: 700; text-decoration: underline; padding: 4px; cursor: pointer; }
.pote { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

/* ---------- Tela do motorista ---------- */
.tela-motorista { background: var(--azul); min-height: 100vh; }
.tela-motorista .conteudo { max-width: 520px; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); }
.mot-topo { display: flex; align-items: center; gap: 14px; color: #fff; margin: 6px 4px 18px; }
.mot-topo div { display: flex; flex-direction: column; }
.mot-topo strong { font-size: 1.15rem; }
.mot-topo small { color: #c6cfe2; font-size: 1rem; }
.mot-cartao { background: #fff; border-radius: 20px; padding: 24px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.mot-cartao h1 { font-size: 1.6rem; margin-bottom: 14px; }
.mot-texto { font-size: 1.1rem; color: #344054; margin: 0 0 18px; }
.mot-texto.grande { font-size: 1.3rem; }
.mot-ola { font-size: 1.15rem; margin: 0 0 6px; color: var(--suave); }
.mot-ola b { color: var(--texto); }
.mot-form { gap: 18px; }
.mot-form label { font-size: 1.1rem; color: var(--texto); font-weight: 700; }
.mot-form input:not([type=checkbox]) { font-size: 1.35rem !important; min-height: 60px !important; padding: 14px 16px !important; border-width: 2px !important; }
#campo-saca { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 700; letter-spacing: .04em; }
.mot-carregando { color: #c6cfe2; text-align: center; padding: 40px 0; font-size: 1.1rem; }
.mot-pronto { text-align: center; }
.mot-check { width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 50%; background: var(--ok-fundo); color: var(--ok); font-size: 3rem; font-weight: 800; display: grid; place-items: center; }
.mot-sacas { background: #f6f8fb; border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; text-align: left; }
.mot-sacas small { color: var(--suave); font-weight: 600; }
.mot-sacas ul { list-style: none; margin: 6px 0 0; padding: 0; }
.mot-sacas li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; }
.mot-sacas li b { font: 800 1.35rem/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace; overflow-wrap: anywhere; }
.mot-rodape { color: #c6cfe2; text-align: center; margin-top: 18px; }
.mot-rodape button.link { color: #fff; }
.tela-motorista .alerta.erro { font-size: 1.05rem; }

/* ---------- Painel ---------- */
.cab-painel .cab-linha { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filtro { display: flex; gap: 8px; }
.filtro input { font: inherit; padding: 8px 10px; min-height: 46px; border-radius: 10px; border: 1px solid var(--borda); }
.contagens { display: flex; gap: 8px; flex-wrap: wrap; }
.cont { padding: 6px 12px; border-radius: 999px; font-size: .9rem; color: var(--suave); background: #f2f4f8; }
.cont b { font-size: 1.15rem; color: var(--texto); }
.cont.st-fila { background: #fff4e0; } .cont.st-fila b { color: #b54708; }
.cont.st-chamado { background: #e0f2fe; } .cont.st-chamado b { color: #075985; }
.cont.st-entregue { background: var(--ok-fundo); } .cont.st-entregue b { color: var(--ok); }
.acoes-painel { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.acoes-painel .check { margin-left: auto; font-weight: 600; }
.atualizado { margin: 10px 0 0; color: var(--suave); font-size: .82rem; }
h2 .sub { font-weight: 500; font-size: .85rem; color: var(--suave); }

.lista-fila { list-style: none; margin: 0; padding: 0; }
.reg { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 14px 6px; border-top: 1px solid #eef0f4; }
.reg:first-child { border-top: 0; }
.reg-pos { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; font-weight: 800; background: var(--ambar); color: var(--azul); font-variant-numeric: tabular-nums; }
.reg-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.reg-nome { font-size: 1.12rem; overflow-wrap: anywhere; }
.reg-tel { display: flex; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.reg-tel a { text-decoration: none; }
.reg-tel a.zap { color: #128c4b; font-size: .9rem; }
.reg-sacas { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 700 .98rem/1 ui-monospace, "SFMono-Regular", Menlo, monospace; padding: 6px 9px; border-radius: 8px; background: #eef1f6; }
.chip.repetida { background: var(--erro-fundo); color: var(--erro); outline: 1px solid #f3c1bc; }
.chip.repetida::after { content: " ⚠"; }
.reg-horas { color: var(--suave); }
.reg-acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-left: 8px; padding: 2px 7px; border-radius: 999px; background: #eef1f6; color: var(--suave); vertical-align: middle; }
.reg.st-chamado { background: #f0f9ff; }
.reg.st-chamado .reg-pos { background: #0284c7; color: #fff; }
.reg.st-entregue { opacity: .55; }
.reg.st-entregue .reg-pos { background: var(--ok); color: #fff; }
.reg.st-aguardando .reg-pos { background: #eef1f6; color: var(--suave); }
.reg.novo { animation: novo 2.5s ease-out; }
@keyframes novo { 0%, 40% { background: #fff4e0; } 100% { background: transparent; } }

@media (max-width: 640px) {
    .conteudo { padding: 10px; }
    .cartao { padding: 14px; }
    .reg { grid-template-columns: 44px 1fr; gap: 10px; }
    .reg-pos { width: 40px; height: 40px; font-size: 1.1rem; }
    .reg-acoes { grid-column: 1 / -1; justify-content: stretch; }
    .reg-acoes .btn { flex: 1 1 auto; }
    .acoes-painel .btn { flex: 1 1 auto; }
    .acoes-painel .check { margin-left: 0; }
    .barra nav a { padding: 8px 7px; }
}
@media (max-width: 420px) {
    .barra { padding-left: 10px; padding-right: 10px; }
    .barra .marca { font-size: 1rem; gap: 8px; white-space: nowrap; }
    .barra nav { gap: 0; flex-wrap: nowrap; }
    .barra nav a { padding: 8px 6px; font-size: .9rem; white-space: nowrap; }
    .barra .marca { font-size: 0; }
}
