* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    height: 100vh;
    display: flex;
    gap: 20px;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.lista {
    width: 30%;
    max-height: 100vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── ABAS (alternam entre as 3 seções, tipo abas de navegador) ── */
.lista-abas {
    display: flex;
    flex-shrink: 0;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.aba-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px;
    border: none;
    border-right: 1px solid #eef0f2;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: #868e96;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.2s ease, color 0.2s ease;
}

.aba-btn:last-child {
    border-right: none;
}

.aba-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #495057;
}

.aba-icone {
    font-size: 14px;
    line-height: 1;
}

.aba-texto {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aba-contador {
    font-size: 10px;
    font-weight: 700;
    background: #e9ecef;
    color: #868e96;
    border-radius: 20px;
    padding: 1px 6px;
    min-width: 8px;
    text-align: center;
}

.aba-btn.ativa {
    background: white;
    color: #495057;
}

.aba-btn.ativa[data-aba="validacao"] {
    border-bottom-color: #007bff;
}

.aba-btn.ativa[data-aba="validacao"] .aba-contador {
    background: #cce5ff;
    color: #004085;
}

.aba-btn.ativa[data-aba="assinatura"] {
    border-bottom-color: #28a745;
}

.aba-btn.ativa[data-aba="assinatura"] .aba-contador {
    background: #d4edda;
    color: #155724;
}

.aba-btn.ativa[data-aba="prontos"] {
    border-bottom-color: #17a2b8;
}

.aba-btn.ativa[data-aba="prontos"] .aba-contador {
    background: #d1ecf1;
    color: #0c5460;
}

/* ── PÁGINAS (conteúdo de cada aba, deslizam horizontalmente) ── */
.lista-paginas {
    flex: 1;
    overflow: hidden;
}

.lista-trilho {
    display: flex;
    width: 300%;
    height: 100%;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.lista-pagina {
    width: 33.3334%;
    height: 100%;
    overflow-y: auto;
    padding: 15px;
}

#pagina-assinatura {
    background: #f8fff9;
}

#pagina-prontos {
    background: #f0fafb;
}

.pagina-titulo {
    margin: 0 0 12px 0;
    color: #495057;
    padding-bottom: 8px;
    border-bottom: 2px solid;
    font-size: 14px;
}

#pagina-validacao .pagina-titulo {
    border-bottom-color: #007bff;
}

#pagina-assinatura .pagina-titulo {
    border-bottom-color: #28a745;
}

#pagina-prontos .pagina-titulo {
    border-bottom-color: #17a2b8;
}

/* ── TOOLBAR DE BUSCA / ATUALIZAR (por aba) ── */
.lista-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.lista-busca {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    background: white;
}

.lista-busca:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#pagina-assinatura .lista-busca:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

#pagina-prontos .lista-busca:focus {
    border-color: #17a2b8;
    box-shadow: 0 0 0 3px rgba(23, 162, 184, 0.1);
}

.btn-atualizar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #f1f3f5;
    color: #495057;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-atualizar:hover:not(:disabled) {
    background: #e9ecef;
    transform: rotate(45deg);
}

.btn-atualizar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-atualizar.girando {
    animation: spin 0.6s linear;
}

/* ── ITENS DE LISTA ── */
.item {
    padding: 11px 13px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    border-radius: 6px;
    margin: 0 0 4px 0;
    transition: all 0.2s ease;
    background: white;
}

/* validação */
.item:hover {
    background: #e3f2fd;
    transform: translateX(4px);
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.12);
}

.item.selecionado {
    background: #007bff;
    color: white;
}

.item.selecionado .item-sub {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* assinatura */
.item-contratada:hover {
    background: #e8f5e9;
    transform: translateX(4px);
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.12);
}

.item-contratada.selecionado {
    background: #28a745;
    color: white;
}

/* prontos */
.item-prontos:hover {
    background: #e0f7fa;
    transform: translateX(4px);
    box-shadow: 0 3px 10px rgba(23, 162, 184, 0.12);
}

.item-prontos.selecionado {
    background: #17a2b8;
    color: white;
}

.item-prontos.selecionado .item-sub {
    color: rgba(255, 255, 255, 0.7) !important;
}

.item-controle {
    font-weight: 700;
    font-size: 13px;
}

.item-sub {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

.item-hash {
    font-family: monospace;
    font-size: 10px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    margin-top: 3px;
}

/* badges */
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 4px;
    letter-spacing: 0.04em;
}

.badge-pendente {
    background: #cce5ff;
    color: #004085;
}

.badge-pronto {
    background: #fff3cd;
    color: #856404;
}

.badge-assinado {
    background: #d4edda;
    color: #155724;
}

/* ── PAINEL DIREITO ── */
.detalhe {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    overflow: hidden;
}

.header-detalhe {
    background: white;
    padding: 15px 20px;
    border-bottom: 2px solid #007bff;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    transition: border-bottom-color 0.25s;
}

.header-detalhe h3 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 16px;
}

/* modo labels */
.modo-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
    letter-spacing: 0.06em;
}

.modo-validacao {
    background: #cce5ff;
    color: #004085;
}

.modo-assinatura {
    background: #d4edda;
    color: #155724;
}

.modo-documento {
    background: #d1ecf1;
    color: #0c5460;
}

/* botões */
.botoes-acoes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

button {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.btn-aprovar {
    background: #28a745;
    color: white;
}

.btn-aprovar:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
}

.btn-reprovar {
    background: #dc3545;
    color: white;
}

.btn-reprovar:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35);
}

.btn-confirmar {
    background: #ffc107;
    color: #212529;
    border: 2px solid #e0a800;
}

.btn-confirmar:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-preparar {
    background: #007bff;
    color: white;
}

.btn-preparar:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.35);
}

.btn-preparar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-status {
    background: #17a2b8;
    color: white;
}

.btn-status:hover:not(:disabled) {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.35);
}

.btn-status:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* caixas */
.reprovacao-box {
    background: #fff3cd;
    border: 2px solid #ffeaa7;
    border-radius: 8px;
    padding: 14px;
    margin-top: 12px;
}

.hash-box {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 6px;
    padding: 11px 14px;
    margin-top: 12px;
}

.hash-label {
    font-size: 10px;
    font-weight: 700;
    color: #0c5460;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.hash-value {
    font-family: monospace;
    font-size: 11px;
    color: #155724;
    word-break: break-all;
}

textarea {
    width: 100%;
    height: 75px;
    margin-bottom: 10px;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    font-size: 13px;
}

textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* conteúdo */
.conteudo-detalhe {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 190px);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

th,
td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-size: 13px;
}

th {
    background: #007bff;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:hover {
    background: #f8f9fa;
}

/* document info grid (prontos) */
.doc-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #f0fafb;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.doc-info-item {
    font-size: 12px;
    line-height: 1.5;
}

.doc-info-item strong {
    color: #0c5460;
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

h4 {
    color: #495057;
    margin: 20px 0 10px 0;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vazio {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px;
}

.erro-msg {
    color: #dc3545;
    font-size: 12px;
    padding: 8px;
}

/* spinner */
.spin {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 5px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* fotos / evidências */
.foto-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e7f3ff;
    color: #0056b3;
    border: 1px solid #b8daff;
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.foto-badge:hover {
    background: #cfe6ff;
    transform: scale(1.05);
}

.foto-badge.sem-foto {
    background: #f1f3f5;
    color: #adb5bd;
    border-color: #e9ecef;
    cursor: default;
}

.foto-badge.sem-foto:hover {
    background: #f1f3f5;
    transform: none;
}

.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.lightbox-overlay.aberto {
    display: flex;
}

.lightbox-conteudo {
    background: white;
    border-radius: 10px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #dee2e6;
}

.lightbox-header h4 {
    margin: 0;
    font-size: 14px;
    color: #495057;
}

.lightbox-fechar {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 0 4px;
}

.lightbox-fechar:hover {
    color: #212529;
}

.lightbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
}

.lightbox-grid img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #dee2e6;
    transition: transform 0.15s ease;
}

.lightbox-grid img:hover {
    transform: scale(1.03);
}

.lightbox-full {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: zoom-out;
}

.lightbox-full.aberto {
    display: flex;
}

.lightbox-full img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        padding: 10px;
        height: auto;
        overflow: auto;
    }

    .lista {
        width: 100%;
        height: 56vh;
        max-height: 56vh;
    }

    .botoes-acoes {
        flex-direction: column;
    }

    .doc-info-grid {
        grid-template-columns: 1fr;
    }
}