* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #0f172a;
    color: #0f172a;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    background: #111827;
    color: #fff;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.topbar a { color: #fff; text-decoration: none; font-size: 14px; opacity: .85; margin-right: 14px; }
.topbar a:last-child { margin-right: 0; }
.topbar a:hover { opacity: 1; }
.topbar .marca { font-weight: 700; font-size: 16px; }
.container {
    flex: 1;
    min-width: 0;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 60px;
}
.wide { max-width: 900px; }
.card {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    margin-bottom: 20px;
}
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 14px; }
p.sub { color: #6b7280; margin: 0 0 20px; font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #374151; }
input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px; /* abaixo de 16px o iOS Safari dá zoom automático ao focar o campo, "estourando" a tela */
}
input[type="date"] {
    min-width: 0;
    max-width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
/* Trava física: mesmo que o controle nativo de data do iOS ignore a largura
   em CSS, o contêiner corta qualquer parte que ultrapasse a tela. */
.input-clamp {
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
}
.btn {
    display: block;
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 18px;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary { background: #e5e7eb; color: #111827; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; display: inline-block; margin: 4px 4px 0 0; }
.status-ok { color: #16a34a; font-weight: 700; }
.msg { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.msg-erro { background: #fee2e2; color: #991b1b; }
.msg-sucesso { background: #dcfce7; color: #166534; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e7eb; }
th { color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-motorista { background: #dbeafe; color: #1d4ed8; }
.badge-ativo { background: #dcfce7; color: #166534; }
.badge-inativo { background: #f3f4f6; color: #6b7280; }
.badge-pago { background: #dcfce7; color: #166534; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-pego { background: #dbeafe; color: #1d4ed8; }
.badge-deixado { background: #ede9fe; color: #6d28d9; }
.badge-coletado { background: #cffafe; color: #0e7490; }
.badge-entregue { background: #dcfce7; color: #166534; }
.lista-entregas { margin-top: 16px; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
.linha-entrega {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
}
.linha-entrega:last-child { border-bottom: none; }
.linha-entrega:hover { background: #f9fafb; }
.linha-entrega-coletada { opacity: .55; }
.linha-entrega-principal { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.linha-entrega-data { font-size: 12px; color: #6b7280; }
.linha-entrega-cliente { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-entrega-local { font-size: 13px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-entrega-info { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.linha-entrega-valor { font-weight: 700; font-size: 14px; white-space: nowrap; }
.linha-entrega-custo { font-size: 11px; color: #b91c1c; white-space: nowrap; }
.autocomplete-wrap { position: relative; }
.autocomplete-lista {
    display: none;
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0,0,0,.12);
}
.autocomplete-opcao { padding: 10px 12px; cursor: pointer; font-size: 14px; }
.autocomplete-opcao:hover { background: #f3f4f6; }
.autocomplete-opcao.autocomplete-criar { color: #2563eb; font-weight: 600; border-top: 1px solid #e5e7eb; }
.status-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.status-linha:last-of-type { border-bottom: none; }
.status-linha .btn-sm { margin: 0; }
.resumo { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.resumo .item { flex: 1; min-width: 120px; background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center; }
.resumo .item strong { display: block; font-size: 20px; }
.resumo .item span { font-size: 12px; color: #6b7280; }
form.inline { display: inline; }

/* Tabelas em formato de cartão no celular — evita rolagem horizontal */
@media (max-width: 680px) {
    .container { padding-left: 10px; padding-right: 10px; }
    .card { padding: 16px; }
    .resumo { gap: 8px; }
    .resumo .item { padding: 10px; }
    .linha-entrega { padding: 10px 12px; gap: 8px; }
    .linha-entrega-local { max-width: 45vw; }

    table.responsiva thead { display: none; }
    table.responsiva, table.responsiva tbody, table.responsiva tr, table.responsiva td {
        display: block;
        width: 100%;
    }
    table.responsiva tr {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 4px 14px;
    }
    table.responsiva td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #f3f4f6;
        padding: 10px 0;
        text-align: right;
    }
    table.responsiva td:last-child { border-bottom: none; }
    table.responsiva td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        color: #6b7280;
        text-align: left;
    }
    table.responsiva td[data-label="Ações"] {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
        gap: 6px;
    }
    table.responsiva td[data-label="Ações"]::before { margin-bottom: 2px; }
    table.responsiva td[data-label="Ações"] .btn-sm,
    table.responsiva td[data-label="Ações"] form { width: 100%; margin: 0; }
    table.responsiva td[data-label="Ações"] .btn-sm { width: 100%; text-align: center; }
    table.responsiva td a { padding: 6px 4px; font-weight: 600; }
}

/* Relatório de ponto — lista compacta de dias, igual em qualquer tamanho de
   tela (não vira "cartão" empilhado no celular como table.responsiva) */
.lista-ponto { margin-top: 16px; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
.linha-ponto { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; }
.linha-ponto:last-child { border-bottom: none; }
.linha-ponto-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.linha-ponto-data { font-weight: 700; font-size: 13px; color: #111827; }
.linha-ponto-total { font-weight: 700; font-size: 14px; }
.linha-ponto-saldo { font-size: 12px; font-weight: 700; margin-left: 6px; }
.linha-ponto-saldo.positivo { color: #166534; }
.linha-ponto-saldo.negativo { color: #b91c1c; }
.linha-ponto-horarios { font-size: 13px; color: #6b7280; margin-top: 4px; }
.linha-ponto-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip-horario { display: inline-block; padding: 5px 9px; background: #f3f4f6; border-radius: 6px; font-size: 12px; color: #111827; text-decoration: none; font-weight: 600; }
.chip-horario:hover { background: #e5e7eb; }
.chip-horario.vazio { color: #9ca3af; font-weight: 400; }
.linha-ponto-acao { margin-top: 8px; }
.linha-ponto-acao .btn-sm { width: 100%; text-align: center; margin: 0; }

/* Impressão / Baixar PDF — mesma lista compacta em retrato, cabe mais por página */
@media print {
    @page { margin: 12mm; }
    body { background: #fff; }
    .no-print { display: none !important; }
    .container.wide { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; padding: 12px; }
    table a, .chip-horario { color: inherit; text-decoration: none; }
    .resumo .item { border: 1px solid #ddd; }
    .lista-ponto { border-color: #ddd; }
    .linha-ponto { padding: 6px 10px; border-bottom-color: #eee; }
}
