/* recebimento.css — plano REC + mobile-first */

.recebimento-panel {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.recebimento-plano-abertura {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.recebimento-plano-abertura .recebimento-field {
    flex: 1;
    min-width: 200px;
}

.recebimento-abertura-split {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.recebimento-bloco {
    flex: 1 1 320px;
    min-width: 280px;
    border-radius: 10px;
    padding: 1rem 1.25rem 1.25rem;
}

.recebimento-bloco-titulo {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted, var(--text-secondary));
    margin-bottom: 0.6rem;
}

.recebimento-bloco-acao {
    background: var(--accent-soft, #ecebff);
    border: 1px solid var(--accent, var(--primary-color));
}

.recebimento-bloco-consulta {
    background: transparent;
    border: 1px dashed var(--line-strong, var(--border-color));
}

.recebimento-input-consulta {
    font-size: 1rem;
    font-weight: 400;
    padding: 0.625rem 0.75rem;
    border-width: 1px;
}

.consulta-of-resultado {
    margin-top: 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.consulta-of-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    padding: 0.5rem 0;
}

.consulta-of-item + .consulta-of-item {
    border-top: 1px solid var(--border-color);
}

.consulta-of-item span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted, var(--muted, inherit));
}

.consulta-of-item strong {
    font-weight: 500;
    font-size: 0.9rem;
}

.recebimento-input {
    width: 100%;
    font-size: 1.125rem;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
}

.recebimento-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(30 64 175 / 0.12);
}

.recebimento-input-chave {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    letter-spacing: 0.04em;
    font-size: 1rem;
}

.recebimento-bipagem {
    margin-bottom: 1rem;
}

.recebimento-chave-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.recebimento-chave-row .recebimento-input {
    flex: 1;
    min-width: 0;
}

.btn-camera {
    min-width: 3.25rem;
    font-size: 1.35rem;
    padding: 0.5rem 0.75rem;
}

.recebimento-plano-ativo {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.recebimento-plano-cabecalho {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.recebimento-plano-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.recebimento-plano-codigo {
    font-size: 1.15rem;
    color: var(--primary-color);
}

.recebimento-plano-cabecalho .btn-success {
    margin-left: auto;
}

.badge-plano-aberto {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #dbeafe;
    color: #1e40af;
}

.badge-plano-finalizado {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #d1fae5;
    color: #065f46;
}

.recebimento-historico-section {
    margin-top: 1.5rem;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.recebimento-historico-titulo {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}

.recebimento-historico-desc {
    margin: 0 0 1rem;
    font-size: 0.875rem;
}

.recebimento-grid-planos {
    table-layout: fixed;
    width: 100%;
}

.recebimento-grid-planos col.col-plano { width: 14%; }
.recebimento-grid-planos col.col-of { width: 10%; }
.recebimento-grid-planos col.col-status { width: 9%; }
.recebimento-grid-planos col.col-notas { width: 7%; }
.recebimento-grid-planos col.col-vol { width: 7%; }
.recebimento-grid-planos col.col-peso { width: 9%; }
.recebimento-grid-planos col.col-valor { width: 11%; }
.recebimento-grid-planos col.col-abertura { width: 16%; }
.recebimento-grid-planos col.col-fim { width: 16%; }

.recebimento-grid-planos th.col-num,
.recebimento-grid-planos td.numero {
    text-align: right;
}

.recebimento-grid-planos th.col-datahora,
.recebimento-grid-planos td.col-datahora {
    text-align: center;
    white-space: nowrap;
    font-size: 0.8rem;
}

.plano-row-clickable {
    cursor: pointer;
}

.plano-row-clickable:hover,
.plano-row-clickable:focus {
    background-color: var(--bg-color);
    outline: none;
}

.plano-row-aberto {
    background-color: #eff6ff;
}

.plano-codigo-cell {
    font-weight: 600;
    color: var(--primary-color);
}

.modal-detalhe-plano {
    max-width: 1150px;
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-detalhe-resumo {
    margin-bottom: 1rem;
}

.recebimento-plano-remetente-box strong {
    display: block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remetente-pendente {
    color: var(--text-secondary);
    font-weight: 500;
    font-style: italic;
}

.modal-detalhe-remetente {
    grid-column: span 3;
}

@media (max-width: 767px) {
    .modal-detalhe-remetente {
        grid-column: auto;
    }
}

.modal-detalhe-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.5rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.modal-detalhe-grid span {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.modal-detalhe-tabela-wrap {
    max-height: 420px;
    margin-bottom: 1rem;
}

/* Tabela de notas dentro do modal — distribui melhor e não abrevia destinatário */
.modal-detalhe-grid-notas {
    table-layout: fixed;
    width: 100%;
    font-size: 0.9rem;
}

.modal-detalhe-grid-notas col.col-nf { width: 8%; }
.modal-detalhe-grid-notas col.col-dest { width: 34%; }
.modal-detalhe-grid-notas col.col-vol { width: 8%; }
.modal-detalhe-grid-notas col.col-peso { width: 11%; }
.modal-detalhe-grid-notas col.col-valor { width: 15%; }
.modal-detalhe-grid-notas col.col-datahora { width: 16%; }
.modal-detalhe-grid-notas col.col-fonte { width: 8%; }

.modal-detalhe-grid-notas th,
.modal-detalhe-grid-notas td {
    padding: 0.5rem 0.6rem;
}

.modal-detalhe-grid-notas .motorista-nome {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    line-height: 1.25;
}

.modal-detalhe-grid-notas th.col-num,
.modal-detalhe-grid-notas td.numero {
    text-align: right;
}

.modal-detalhe-grid-notas th.col-datahora,
.modal-detalhe-grid-notas td.col-datahora {
    text-align: center;
    white-space: nowrap;
    font-size: 0.78rem;
}

@media (min-width: 768px) {
    .modal-detalhe-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 639px) {
    .recebimento-plano-cabecalho {
        flex-direction: column;
        align-items: flex-start;
    }

    .recebimento-plano-cabecalho .btn-success {
        margin-left: 0;
        width: 100%;
    }

    .modal-detalhe-grid {
        grid-template-columns: 1fr;
    }
}


.recebimento-totais {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.recebimento-total-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    text-align: center;
}

.recebimento-total-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.recebimento-total-card strong {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.recebimento-feedback {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.recebimento-feedback.ok {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.recebimento-feedback.erro {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.recebimento-feedback.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.recebimento-feedback.carregando {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Grid alinhada — cabeçalho e células com mesma largura/alinhamento */
.recebimento-grid {
    table-layout: fixed;
    width: 100%;
}

.recebimento-grid col.col-nf { width: 7%; }
.recebimento-grid col.col-dest { width: 28%; }
.recebimento-grid col.col-vol { width: 8%; }
.recebimento-grid col.col-peso { width: 10%; }
.recebimento-grid col.col-valor { width: 12%; }
.recebimento-grid col.col-datahora { width: 18%; }
.recebimento-grid col.col-fonte { width: 10%; }

.recebimento-grid th.col-num,
.recebimento-grid td.numero {
    text-align: right;
}

.recebimento-grid th.col-datahora,
.recebimento-grid td.col-datahora {
    text-align: center;
    white-space: nowrap;
    font-size: 0.8rem;
}

.recebimento-grid .motorista-nome {
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-scanner {
    max-width: 520px;
}

.modal-scanner-hint {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.scanner-reader {
    width: 100%;
    min-height: 280px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-bottom: 1rem;
}

.scanner-reader video {
    border-radius: 8px;
}

@media (min-width: 640px) {
    .recebimento-totais {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 639px) {
    .recebimento-panel {
        padding: 1rem;
    }

    .recebimento-input {
        font-size: 16px;
    }

    .recebimento-plano-abertura {
        flex-direction: column;
        align-items: stretch;
    }

    .recebimento-abertura-split {
        flex-direction: column;
    }

    .recebimento-plano-cabecalho .btn-success {
        margin-left: 0;
        width: 100%;
        text-align: left;
    }

    header h2 {
        font-size: 1rem;
    }
}

/* ==================== CONSULTA NOTA/VIAGEM — detalhe FPI046 ==================== */
.btn-sm {
    padding: 4px 10px;
    font-size: 0.82rem;
}

.grupo-detalhe {
    margin-bottom: 16px;
}

.grupo-detalhe h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: #34406b;
    border-bottom: 2px solid #d5dcf3;
    padding-bottom: 4px;
}

.grupo-detalhe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px 18px;
}

.campo-detalhe {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.campo-detalhe .campo-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7a839c;
}

.campo-detalhe .campo-valor {
    font-size: 0.92rem;
    color: #1f2740;
    word-break: break-word;
}

.campo-detalhe .campo-valor .vazio,
.campo-detalhe .campo-valor em.vazio {
    color: #b3b9c9;
}

.modal-alerta-sem-viagem {
    background: #fff4e5;
    border: 1px solid #ffc98a;
    color: #8a5a00;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 0.88rem;
}

/* Modal Consulta Nota — folgado (~+15% largura / +25% respiro vertical), sem abreviar */
#modalConsNota .modal-cons-nota {
    max-width: min(1600px, 99vw);
    width: 99vw;
    max-height: 96vh;
    overflow-y: auto;
    padding: 0.95rem 1.25rem 0.85rem;
}

#modalConsNota .modal-cons-nota h4 {
    margin: 0 0 0.45rem;
    font-size: 1.05rem;
    line-height: 1.25;
}

#modalConsNota .modal-detalhe-resumo {
    margin-bottom: 0.4rem;
}

#modalConsNota .grupo-detalhe {
    margin-bottom: 0.55rem;
}

#modalConsNota .grupo-detalhe h5 {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    padding-bottom: 3px;
    border-bottom-width: 1px;
}

#modalConsNota .grupo-detalhe-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.35rem 0.85rem;
}

#modalConsNota .campo-detalhe {
    gap: 0.1rem;
}

#modalConsNota .campo-detalhe .campo-label {
    font-size: 0.62rem;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

#modalConsNota .campo-detalhe .campo-valor {
    font-size: 0.88rem;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}

#modalConsNota .campo-detalhe--wide {
    grid-column: span 2;
}

#modalConsNota .campo-detalhe--chave {
    grid-column: span 3;
}

#modalConsNota .campo-detalhe--chave .campo-valor {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

#modalConsNota .modal-alerta-sem-viagem {
    margin-bottom: 0.45rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

#modalConsNota .modal-actions {
    margin-top: 0.5rem;
    padding-top: 0.45rem;
}

.modal-badge-natureza {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid transparent;
}

.modal-badge-natureza strong {
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.modal-badge-natureza span {
    opacity: 0.85;
    font-size: 0.8rem;
}

.modal-badge-natureza.natureza-entrega {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.modal-badge-natureza.natureza-transferencia {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e3a8a;
}

.modal-badge-natureza.natureza-coleta {
    background: #fff7ed;
    border-color: #fdba74;
    color: #9a3412;
}

.modal-badge-natureza.natureza-outro {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.badge-inline-nat {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-inline-nat.natureza-entrega { background: #d1fae5; color: #065f46; }
.badge-inline-nat.natureza-transferencia { background: #dbeafe; color: #1e3a8a; }
.badge-inline-nat.natureza-coleta { background: #ffedd5; color: #9a3412; }
.badge-inline-nat.natureza-outro { background: #e5e7eb; color: #374151; }

.modal-badge-split {
    gap: 0.45rem;
    background: #f8fafc;
    border-color: #e2e8f0;
}

.viagens-duplo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.viagem-coluna {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 0.8rem 0.7rem;
    background: #fff;
    min-width: 0;
}

.viagem-coluna.viagem-transferencia {
    border-color: #93c5fd;
    background: #f8fbff;
}

.viagem-coluna.viagem-entrega {
    border-color: #6ee7b7;
    background: #f6fdf9;
}

.viagem-coluna.viagem-vazia {
    opacity: 0.85;
    background: #fafafa;
    border-style: dashed;
    min-height: auto;
}

.viagem-coluna-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgb(148 163 184 / 0.25);
}

.viagem-sub {
    font-size: 0.78rem;
    color: #64748b;
}

.viagem-ausente {
    margin: 0.3rem 0 0;
    font-size: 0.82rem;
    color: #94a3b8;
}

.viagem-coluna-lista {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.28rem;
}

.campo-inline {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 0.25rem 0.65rem;
    align-items: start;
    min-width: 0;
    padding: 0.1rem 0;
}

.campo-inline-l {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #7a839c;
    line-height: 1.35;
    padding-top: 0.12rem;
}

.campo-inline-v {
    font-size: 0.88rem;
    color: #1f2740;
    line-height: 1.35;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
}

@media (max-width: 900px) {
    .viagens-duplo-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    #modalConsNota .grupo-detalhe-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #modalConsNota .campo-detalhe--chave {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    #modalConsNota .modal-cons-nota {
        width: 97vw;
        max-height: 92vh;
        padding: 0.75rem;
    }

    #modalConsNota .grupo-detalhe-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #modalConsNota .campo-detalhe--wide,
    #modalConsNota .campo-detalhe--chave {
        grid-column: span 2;
    }

    .campo-inline {
        grid-template-columns: 5.5rem minmax(0, 1fr);
    }
}
