:root {
    --bg: #f4f6f9;
    --card-bg: #fff;
    --primary: #1a56db;
    --primary-hover: #1444b0;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

header {
    background: var(--primary);
    color: #fff;
    padding: 16px 32px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    margin-right: 8px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
}

.btn-config {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
}

.btn-config:hover {
    background: rgba(255,255,255,0.25);
}

.config-section {
    margin-bottom: 16px;
}

.config-section label {
    font-weight: 600;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.config-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.config-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.config-row input[type="time"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.config-status {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
}

.config-status.ok { color: var(--success); }
.config-status.err { color: var(--danger); }

.modal-lg { max-width: 700px; }

.users-new {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.users-new input, .users-new select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.users-table th {
    background: #f9fafb;
    padding: 8px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
}

.users-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.users-table .btn-sm { padding: 4px 8px; font-size: 11px; margin-right: 4px; }

.user-inactive { opacity: 0.5; }

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-updated {
    font-size: 12px;
    color: var(--text-light);
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.card {
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border-left: 4px solid;
}

.card-liquidados { border-color: var(--success); background: #f0fdf4; }
.card-baixados { border-color: var(--primary); background: #eff6ff; }
.card-registrados { border-color: #f59e0b; background: #fffbeb; }

.card-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-count {
    font-size: 32px;
    font-weight: 700;
}

.card-valor {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

/* Consulta */
#consulta h2 { margin-bottom: 16px; }

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

#cpf { width: 200px; }
#situacao { width: 160px; }

.form-group-btn { padding-bottom: 1px; }

/* Buttons */
button {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#btn-consultar,
#btn-refresh-dash {
    background: var(--primary);
    color: #fff;
}

#btn-consultar:hover:not(:disabled),
#btn-refresh-dash:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

/* Resultados */
.resultados-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.resultados-header h2 span {
    font-weight: 400;
    color: var(--text-light);
    font-size: 14px;
}

.filtro-data-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: var(--radius);
    font-size: 13px;
}

.filtro-data-bar label {
    font-weight: 500;
    color: var(--text-light);
    white-space: nowrap;
}

.filtro-data-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: #f9fafb;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #f9fafb;
}

tbody tr.row-baixado {
    color: var(--text-light);
}

tbody tr.row-liquidado {
    color: var(--success);
}

th:first-child, td:first-child {
    width: 40px;
    text-align: center;
}

.situacao-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.situacao-entrada { background: #dbeafe; color: #1e40af; }
.situacao-baixado { background: #e5e7eb; color: #4b5563; }
.situacao-liquidado { background: #d1fae5; color: #065f46; }
.situacao-comandada { background: #fef3c7; color: #92400e; }

tbody tr.row-comandado {
    background: #fffbeb;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.modal p {
    margin-bottom: 12px;
    color: var(--text-light);
    font-size: 14px;
}

#modal-lista {
    margin-bottom: 16px;
    font-size: 13px;
}

#modal-lista .modal-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.result-ok { color: var(--success); }
.result-err { color: var(--danger); }

#modal-resultados {
    font-size: 13px;
}

#modal-resultados .result-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Liquidacoes */
.liq-resumo {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.liq-resumo-item {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
}

.liq-cart-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e5e7eb;
    border-radius: 10px;
    margin-right: 6px;
    font-size: 11px;
}

.cache-tag {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
}

.liq-resumo-total { background: #f3f4f6; }
.liq-resumo-ok { background: #d1fae5; color: #065f46; }
.liq-resumo-falta { background: #fef3c7; color: #92400e; }
.liq-resumo-incon { background: #fee2e2; color: #991b1b; }

.liq-filtros {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.liq-filtros label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    margin-right: 4px;
}

.liq-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
}

.liq-filtros select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}

.liq-filtro-btn.active {
    background: var(--primary);
    color: #fff;
}

.btn-download {
    background: #059669;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-download:hover {
    background: #047857;
}

.btn-download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.status-ok { background: #d1fae5; color: #065f46; }
.status-falta { background: #fef3c7; color: #92400e; }
.status-inconsistente { background: #fee2e2; color: #991b1b; }
.status-cancelado { background: #e5e7eb; color: #4b5563; }
.status-ja-liq { background: #fce7f3; color: #9d174d; }

.status-badge {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cel-cliente {
    min-width: 140px;
    line-height: 1.3;
}

.cliente-nome {
    color: #1a56db;
    font-weight: 600;
    font-size: 12px;
}

.cliente-id {
    color: var(--text-light);
    font-size: 11px;
}

tbody tr.row-falta { background: #fffbeb; }
tbody tr.row-inconsistente { background: #fef2f2; }

.liq-totais {
    margin-top: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.liq-totais-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.liq-total-item {
    text-align: center;
}

.liq-total-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.liq-total-value {
    font-size: 18px;
    font-weight: 700;
}

.liq-total-value.val-green { color: #059669; }
.liq-total-value.val-red { color: #dc2626; }

.liq-totais h4 {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text-light);
}

.liq-totais-carteira {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.liq-totais-carteira table {
    font-size: 12px;
}

.liq-totais-carteira th {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-light);
}

.liq-totais-carteira td {
    padding: 6px 10px;
    border-bottom: 1px solid #f3f4f6;
}

.liq-relatorio-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.btn-pdf {
    background: #dc2626;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-pdf:hover { background: #b91c1c; }

.liq-relatorio-bar label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

@media (max-width: 768px) {
    .cards { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    #cpf, #situacao { width: 100%; }
}
