/* ===== Reset e Variáveis — padrão analitico.css ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-color:    #2563eb;
    --primary-dark:     #1e40af;
    --primary-light:    #3b82f6;
    --secondary-color:  #64748b;
    --success-color:    #10b981;
    --warning-color:    #f59e0b;
    --danger-color:     #ef4444;
    --info-color:       #06b6d4;
    --bg-primary:       #ffffff;
    --bg-secondary:     #f8fafc;
    --bg-tertiary:      #f1f5f9;
    --text-primary:     #1e293b;
    --text-secondary:   #64748b;
    --text-light:       #94a3b8;
    --border-color:     #e2e8f0;
    --border-light:     #f1f5f9;
    --shadow-sm:  0 1px 2px 0 rgba(0,0,0,.05);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1);
    --shadow-xl:  0 20px 25px -5px rgba(0,0,0,.1);
    --spacing-xs: .5rem;
    --spacing-sm: .75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --radius-sm:  .375rem;
    --radius-md:  .5rem;
    --radius-lg:  .75rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--spacing-md) var(--spacing-xs);
}

.container { width: 100%; margin: 0 auto; padding: 0 var(--spacing-md); }

/* ===== Header ===== */
.header {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-md);
}
.header-content { display: flex; justify-content: space-between; align-items: center; gap: var(--spacing-lg); flex-wrap: wrap; }
.header-left h1 { color: var(--primary-color); font-size: 1.75rem; font-weight: 700; margin-bottom: var(--spacing-xs); }
.subtitle { color: var(--text-secondary); font-size: .9rem; }
.header-right { display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; }
.header-user {
    font-size: .85rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    font-weight: 500;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
.card h2, .card h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-light);
}

/* ===== Credenciais API ===== */
.cred-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}
.cred-block summary {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    list-style: none;
}
.cred-block summary::-webkit-details-marker { display: none; }
.cred-block[open] summary { margin-bottom: var(--spacing-md); border-bottom: 1px solid var(--border-color); padding-bottom: var(--spacing-sm); }

.cred-status {
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: .25rem;
}
.cred-status.saved { background: #d1fae5; color: #065f46; }
.cred-status.empty { background: #fee2e2; color: #991b1b; }

/* ===== Formulários ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-row-inline { flex-direction: column !important; } }

.form-row-inline { display: flex; gap: var(--spacing-md); align-items: flex-end; flex-wrap: wrap; }
.form-row-inline .form-group { flex: 1; min-width: 160px; }

.form-group { display: flex; flex-direction: column; gap: .375rem; margin-bottom: var(--spacing-sm); }
.form-group label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-group input,
.form-group select {
    padding: .55rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group input[type="date"] { color-scheme: light; cursor: pointer; }
.form-group input::placeholder { color: var(--text-light); }

/* ===== Botões ===== */
.btn-primary, .btn-secondary, .btn-export, .btn-save {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}
.btn-primary  { background: var(--primary-color); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-export { background: var(--success-color); color: #fff; }
.btn-export:hover { background: #059669; transform: translateY(-2px); box-shadow: var(--shadow-md); }

.btn-save { background: var(--info-color); color: #fff; padding: .55rem var(--spacing-md); font-size: .85rem; }
.btn-save:hover { background: #0891b2; }

.btn-danger { background: var(--danger-color); color: #fff; padding: 4px 10px; border: none; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-danger:hover { background: #dc2626; }

.actions-bar { display: flex; gap: var(--spacing-sm); align-items: center; flex-wrap: wrap; margin-top: var(--spacing-md); }

/* ===== Mensagens ===== */
.msg-error {
    background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
    border-radius: var(--radius-md); padding: .6rem var(--spacing-md);
    font-size: .875rem; margin-bottom: var(--spacing-sm);
}
.msg-success {
    background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
    border-radius: var(--radius-md); padding: .6rem var(--spacing-md);
    font-size: .875rem; margin-bottom: var(--spacing-sm);
}
.hidden { display: none !important; }

/* ===== Progress ===== */
.import-progress {
    margin: .5rem 0; padding: .55rem .85rem;
    border-radius: var(--radius-md); background: #eff6ff;
    border: 1px solid #bfdbfe; font-size: .82rem; color: #1e40af;
    font-weight: 500; font-family: monospace;
    display: flex; align-items: center; gap: .75rem;
    transition: background .3s, border-color .3s, color .3s;
}
.import-progress .spinner {
    width: 16px; height: 16px;
    border: 2px solid #bfdbfe; border-top-color: #2563eb;
    border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-wrap { flex: 1; height: 6px; background: #dbeafe; border-radius: 3px; overflow: hidden; max-width: 220px; }
.progress-bar-fill { height: 100%; background: var(--primary-color); border-radius: 3px; transition: width .3s ease; width: 0%; }

/* ===== Summary Cards ===== */
.summary-section { margin-bottom: var(--spacing-md); }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--spacing-md); }
@media (max-width: 800px) { .summary-grid { grid-template-columns: 1fr 1fr; } }
.summary-card {
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-sm); text-align: center;
}
.summary-card.highlight { border-color: var(--primary-color); background: #eff6ff; }
.summary-val { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); display: block; }
.summary-card.highlight .summary-val { color: var(--primary-color); }
.summary-key { font-size: .72rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 4rem var(--spacing-md); color: var(--text-light); }
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: var(--spacing-md); }
.empty-state p { font-size: 1rem; color: var(--text-secondary); }
.empty-state strong { color: var(--primary-color); }

/* ===== Tabela de Resultados ===== */
.table-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.table-controls {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: var(--spacing-sm); background: var(--bg-secondary);
}
.table-controls h3 { font-size: .95rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table thead tr { background: var(--bg-tertiary); }
.data-table th {
    padding: .65rem var(--spacing-md); text-align: left;
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color); white-space: nowrap;
}
.data-table th.align-right { text-align: right; }
.data-table tbody tr { border-bottom: 1px solid var(--border-light); transition: background .15s; cursor: pointer; }
.data-table tbody tr:hover { background: #f0f4ff; }
.data-table tbody tr.expanded { background: #eff6ff; }
.data-table td { padding: .75rem var(--spacing-md); font-size: .875rem; vertical-align: middle; }
.data-table td.align-right { text-align: right; font-family: monospace; font-size: .85rem; }

.col-toggle { width: 40px; }
.col-id { width: 110px; }
.col-date { width: 100px; }
.col-status { width: 170px; }

.order-id { font-weight: 700; color: var(--primary-color); font-family: monospace; }
.amount-cell { font-weight: 600; color: var(--text-primary); font-family: monospace; }
.buyer-cell { font-size: .82rem; color: var(--text-secondary); font-family: monospace; }

.toggle-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; background: var(--bg-tertiary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    cursor: pointer; transition: all .2s;
}
.toggle-btn svg { transition: transform .2s ease; }
.data-table tbody tr.expanded .toggle-btn { background: #dbeafe; border-color: var(--primary-color); }
.data-table tbody tr.expanded .toggle-btn svg { transform: rotate(90deg); }

/* ===== Status Badges ===== */
.badge-status {
    display: inline-block; font-size: .72rem; font-weight: 700;
    padding: 3px 9px; border-radius: 12px; text-transform: uppercase; letter-spacing: .04em;
}
.status-PENDING             { background: #dbeafe; color: #1e40af; }
.status-PARTIALLY_DELIVERED { background: #fef3c7; color: #92400e; }
.status-FULLY_DELIVERED     { background: #d1fae5; color: #065f46; }
.status-CANCELED            { background: #fee2e2; color: #991b1b; }

/* ===== Itens Expansíveis ===== */
.items-row { background: #f8fafc; }
.items-row td { padding: 0; border-bottom: 2px solid var(--border-color); }
.items-container {
    padding: .75rem var(--spacing-md) var(--spacing-md) 3.5rem;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.items-header { display: flex; align-items: center; gap: var(--spacing-sm); padding: var(--spacing-sm) 0; }
.items-header-title { font-size: .72rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; }
.items-count { background: #dbeafe; color: #1e40af; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; }

.items-loading { display: flex; align-items: center; gap: .6rem; padding: var(--spacing-md) 0; color: var(--text-secondary); font-size: .875rem; }
.items-loading .spinner { width: 14px; height: 14px; border: 2px solid var(--border-color); border-top-color: var(--primary-color); border-radius: 50%; animation: spin .8s linear infinite; }

.items-table { width: 100%; border-collapse: collapse; border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.items-table th { background: var(--bg-tertiary); padding: .5rem var(--spacing-sm); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); text-align: left; }
.items-table th:nth-child(4), .items-table th:nth-child(5), .items-table th:nth-child(6) { text-align: right; }
.items-table td { padding: .55rem var(--spacing-sm); font-size: .8rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.items-table tr:last-child td { border-bottom: none; }
.items-table tr:hover td { background: #f0f4ff; }
.items-table td:nth-child(4), .items-table td:nth-child(5), .items-table td:nth-child(6) { text-align: right; font-family: monospace; font-size: .82rem; }

.item-desc { font-weight: 600; color: var(--text-primary); }
.item-detail { font-size: .75rem; color: var(--text-secondary); margin-top: 2px; }
.item-code { font-family: monospace; font-size: .72rem; color: var(--text-light); }
.unit-badge { background: var(--bg-tertiary); color: var(--text-secondary); font-size: .72rem; font-weight: 600; padding: 2px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.total-item { font-weight: 700; color: var(--primary-color); }

/* ===== Botão Banco de Dados ===== */
.btn-db {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    background: #7c3aed;
    color: #fff;
}
.btn-db:hover { background: #6d28d9; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-db:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== Abas de Visualização ===== */
.view-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tab-btn {
    flex: 1;
    padding: .75rem var(--spacing-lg);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: none;
    border-right: 1px solid var(--border-color);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
}
.tab-btn:last-child { border-right: none; }
.tab-btn.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}
.tab-btn:not(.active):hover { background: #e8edf5; color: var(--text-primary); }

/* Quando há abas, remover borda-topo da table-section */
.tab-section > .table-section {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== Banco de Dados — colunas específicas ===== */
.col-obra   { width: 80px; }
.col-pedido { width: 120px; }
.col-codigo { width: 110px; }

.db-num { font-family: monospace; font-size: .82rem; }

.obra-badge {
    display: inline-block;
    font-family: monospace;
    font-size: .82rem;
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    white-space: nowrap;
}

.db-summary-chip {
    display: inline-block;
    font-size: .8rem;
    font-weight: 600;
    color: #5b21b6;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: 20px;
    padding: 3px 12px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--secondary-color); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ===== Print ===== */
@media print {
    body { background: white; padding: 0; }
    .card, .cred-block, .actions-bar, .btn-export { display: none; }
    .data-table { font-size: .7rem; }
    .data-table th, .data-table td { padding: .25rem; }
}

/* ===== Progress — Banco de Dados ===== */
.import-progress-db {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
.import-progress-db .spinner {
    border-color: #86efac;
    border-top-color: #16a34a;
}

/* ===== Tabs (removido — substituído pelo bloco view-tabs acima) ===== */

.tab-badge {
    background: var(--primary-color);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
    line-height: 1.5;
}

/* ===== Painéis ===== */
.tab-panel { }
.tab-panel.hidden { display: none; }

/* Quando abas visíveis, a table-section perde o border-radius no topo */
.tabs-bar:not(.hidden) + .tab-panel .table-section,
.tabs-bar:not(.hidden) ~ .tab-panel .table-section {
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
}

/* ===== Banco de Dados ===== */
.db-controls {
    flex-wrap: wrap;
    gap: var(--spacing-sm) !important;
}
.db-controls-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
}
.db-search {
    padding: .5rem .85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    width: 320px;
    max-width: 100%;
    transition: border-color .2s, box-shadow .2s;
}
.db-search:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* Tabela Banco de Dados */
.db-table { min-width: 650px; }
.db-table th.sortable { cursor: pointer; user-select: none; transition: background .15s; }
.db-table th.sortable:hover { background: #e2e8f0; }
.db-table th.sorted { color: var(--primary-color); }
.sort-icon { font-size: .75rem; margin-left: .25rem; opacity: .6; }
.db-table th.sorted .sort-icon { opacity: 1; }

.col-codigo { width: 120px; }
.db-cell-obra { font-weight: 700; color: var(--text-secondary); font-family: monospace; font-size: .85rem; }
.db-cell-desc { max-width: 360px; }

/* ===== Item code badge ===== */
.item-code-badge {
    font-family: monospace;
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    white-space: nowrap;
    display: inline-block;
}

/* ── Botão Completar Faltantes ── */
.btn-retry {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    background: #f59e0b;
    color: #fff;
}
.btn-retry:hover { background: #d97706; transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ══ Query row (compacto, linha única) ══ */
.query-row {
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: var(--spacing-sm);
}
.query-row .form-group {
    flex: 1;
    min-width: 110px;
    margin-bottom: 0;
}
.query-row .form-group--btn {
    flex: 0 0 auto;
}
.query-row .form-group--btn .btn-primary {
    white-space: nowrap;
    height: 38px;
}
@media (max-width: 700px) {
    .query-row { flex-direction: column; }
    .query-row .form-group { min-width: 100%; }
}

/* ══ Filter bar (obra + busca, aparece após carregar) ══ */
.filter-bar {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: .6rem var(--spacing-md);
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
}
.filter-bar-inner {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-group-inline {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.filter-group-inline label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.filter-group-inline select,
.filter-group-inline input {
    padding: .45rem .7rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    height: 34px;
}
.filter-group-inline select:focus,
.filter-group-inline input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.filter-group-search { flex: 1; min-width: 220px; }
.filter-group-search input { width: 100%; }
/* Quando filter-bar está acima das abas, sem border-bottom-radius */
.filter-bar + .view-tabs { margin-top: 0; }

/* ══════════════════════════════════════════════════════
   BANCO DE DADOS — layout profissional
══════════════════════════════════════════════════════ */

/* Sobreescreve regras genéricas só para db-table */
.db-table {
    table-layout: fixed;
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

/* Cabeçalhos */
.db-table thead th {
    padding: .5rem .6rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Células */
.db-table tbody td {
    padding: .45rem .6rem;
    font-size: .82rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}
.db-table tbody tr:last-child td { border-bottom: none; }
.db-table tbody tr:hover td { background: #f0f4ff; }

/* Larguras fixas — soma = 100% quando min-width=860px */
.db-table .col-obra   { width: 58px;  }
.db-table .col-pedido { width: 92px;  }
.db-table .col-codigo { width: 84px;  }
/* Descrição: ocupa o restante */
.db-table .col-qtde   { width: 70px;  }
.db-table .col-un     { width: 48px;  }
.db-table .col-vunit  { width: 108px; }
.db-table .col-total  { width: 108px; }

/* Descrição: texto truncado com tooltip nativo */
.db-table .col-desc-cell {
    overflow: hidden;
    max-width: 0; /* trick para table-layout:fixed respeitar overflow */
}
.db-table .col-desc-cell .item-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    color: var(--text-primary);
    font-weight: 500;
}
.db-table .col-desc-cell .item-detail {
    font-size: .72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Números: monospace, alinhado à direita */
.db-table .td-num {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .8rem;
    text-align: right;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Unidade: centralizada, badge discreto */
.db-table .td-un {
    text-align: center;
}
.db-table .td-un .unit-badge {
    display: inline-block;
    font-family: monospace;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    min-width: 28px;
    text-align: center;
}

/* Valor: destaque em azul */
.db-table .td-valor {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .8rem;
    text-align: right;
    color: var(--primary-dark);
    white-space: nowrap;
}

/* Total item: negrito */
.db-table .td-total {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .8rem;
    text-align: right;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Alinhamento central utilitário */
.align-center { text-align: center; }

/* ══ Apropriações ══ */
.btn-aprop {
    width: 28px; height: 22px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: .7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52px;
}
.btn-aprop:hover { background: #ede9fe; color: #6d28d9; border-color: #c4b5fd; }

.aprop-row td { padding: 0; }
.aprop-container {
    padding: .5rem 1rem .75rem 3rem;
    background: #fafafe;
    border-top: 1px dashed var(--border-color);
}
.aprop-loading {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; color: var(--text-secondary);
    padding: .5rem 0;
}
.aprop-empty { font-size: .82rem; color: var(--text-light); padding: .4rem 0; margin: 0; }

.aprop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    margin-top: .25rem;
}
.aprop-table thead th {
    background: #ede9fe;
    color: #5b21b6;
    font-weight: 700;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .3rem .6rem;
    text-align: left;
    border-bottom: 1px solid #c4b5fd;
}
.aprop-table thead th.align-right { text-align: right; }
.aprop-table tbody td {
    padding: .3rem .6rem;
    border-bottom: 1px solid #f0ebff;
    color: var(--text-primary);
    vertical-align: middle;
}
.aprop-table tbody tr:last-child td { border-bottom: none; }
.aprop-table tbody tr:hover td { background: #f5f0ff; }
.aprop-table .td-valor { font-family: monospace; text-align: right; color: var(--primary-dark); }
.aprop-table .align-right { text-align: right; }
.aprop-table .db-num { font-family: monospace; text-align: right; }

/* Botão importar apropriações */
.btn-aprop-import {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    background: #7c3aed;
    color: #fff;
}
.btn-aprop-import:hover:not(:disabled) { background: #6d28d9; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-aprop-import:disabled { opacity: .5; cursor: not-allowed; }

/* ══ Tabela de itens completa (com apropriações) ══ */
.items-table-wrap { overflow-x: auto; }

.itens-completo {
    width: 100%;
    table-layout: fixed;
    min-width: 820px;
    border-collapse: collapse;
    font-size: .82rem;
    margin-top: .5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.itens-completo thead tr {
    background: linear-gradient(90deg, #1e293b 0%, #334155 100%) !important;
}
.itens-completo thead th {
    color: #e2e8f0 !important;
    background: transparent !important;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .5rem .6rem;
    text-align: left;
    white-space: nowrap;
    border: none !important;
}
.itens-completo thead th.align-right { text-align: right; }
.itens-completo thead th.align-center { text-align: center; }

/* Larguras */
.itens-completo .col-inum  { width: 44px; }
.itens-completo .col-icod  { width: 78px; }
/* col-idesc: flex */
.itens-completo .col-iun   { width: 44px; }
.itens-completo .col-ipunit { width: 100px; }
.itens-completo .col-iqtde  { width: 90px; }
.itens-completo .col-itotal { width: 104px; }
.itens-completo .col-iuc    { width: 44px; }
.itens-completo .col-iapr   { width: 110px; }

.itens-completo tbody td {
    padding: .42rem .6rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-primary);
}
.itens-completo tbody tr:last-child td { border-bottom: none; }
.itens-completo tbody tr:hover td { background: #f8faff; }

/* Item number */
.itens-completo .itn {
    font-family: monospace;
    font-size: .72rem;
    color: var(--text-light);
    text-align: center;
}

/* Números */
.itens-completo .itnum {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .78rem;
    text-align: right;
    white-space: nowrap;
}
.itens-completo .total-item {
    font-weight: 700;
    color: var(--primary-dark);
}

/* Descrição truncada */
.itens-completo .col-idesc .item-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
    display: block;
}

/* Linha de total */
.itens-total-row td {
    background: #f1f5f9 !important;
    font-weight: 700;
    font-size: .78rem;
    color: var(--text-secondary);
    border-top: 2px solid var(--border-color) !important;
    padding: .45rem .6rem;
}
.itens-total-row .total-item {
    color: var(--primary-dark);
    font-size: .84rem;
}

/* Linha extra de apropriação (quando há mais de uma) */
.aprop-extra-row td {
    padding: .2rem .6rem;
    border-bottom: 1px solid #f0ebff;
    background: #fafaff;
}
.aprop-extra-row:hover td { background: #f3f0ff !important; }

/* Código de apropriação */
.aprop-code {
    font-family: monospace;
    font-size: .78rem;
    font-weight: 700;
    color: #5b21b6;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    white-space: nowrap;
}

/* Pending (aguardando carga) */
.aprop-pending {
    color: var(--text-light);
    font-size: .78rem;
}

/* Botão inline carregar apropriações */
.btn-aprop-inline {
    margin-left: auto;
    padding: 3px 10px;
    font-size: .72rem;
    font-weight: 600;
    background: #ede9fe;
    color: #6d28d9;
    border: 1px solid #c4b5fd;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn-aprop-inline:hover:not(:disabled) { background: #ddd6fe; }
.btn-aprop-inline:disabled { opacity: .5; cursor: not-allowed; }

/* ══ Colunas % e Qtde Aprop. ══ */
.itens-completo .col-ipct  { width: 58px; }
.itens-completo .col-iqapr { width: 90px; }

/* Badge de percentual */
.aprop-pct {
    font-family: monospace;
    font-size: .76rem;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   ANÁLISE DE PREÇOS — Ranking
══════════════════════════════════════════════════════ */
.ranking-shell { padding: 0; }

/* Controles */
.ranking-controls {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.rk-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.rk-search-icon { position: absolute; left: .75rem; font-size: .9rem; pointer-events: none; }
.rk-search {
    width: 100%;
    padding: .55rem .75rem .55rem 2.2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .9rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.rk-search:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.rk-filters {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    align-items: flex-end;
}
.rk-filter-group { display: flex; flex-direction: column; gap: .25rem; }
.rk-filter-group label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.rk-filter-group select {
    padding: .38rem .65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .82rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
}
.rk-filter-group select:focus { border-color: var(--primary-color); }

/* Stats bar */
.rk-stats-bar {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: .78rem;
    color: var(--text-secondary);
    padding: .25rem 0 0;
    border-top: 1px solid var(--border-light);
    margin-top: .25rem;
}
.rk-stat { font-size: .78rem; color: var(--text-secondary); }
.rk-stat strong { color: var(--text-primary); }
.rk-stat-sep { color: var(--border-color); }
.rk-stat-warn strong { color: #b45309; }
.rk-stat-muted { color: var(--text-light); font-style: italic; }

/* Grid de cartões */
.rk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 72vh;
    overflow-y: auto;
}

/* Cartão de insumo */
.rk-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: .6rem;
    transition: box-shadow .2s, transform .15s;
    box-shadow: var(--shadow-sm);
}
.rk-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.rk-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}
.rk-card-id { display: flex; align-items: center; gap: .4rem; }
.rk-card-right { display: flex; align-items: center; gap: .5rem; }

.rk-card-desc {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Métricas min/avg/max */
.rk-card-metrics {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.rk-metric {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .4rem .3rem;
    border-right: 1px solid var(--border-light);
    gap: .15rem;
}
.rk-metric:last-child { border-right: none; }
.rk-metric-lbl { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); }
.rk-metric-val { font-family: monospace; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.rk-green { color: #059669; }
.rk-blue  { color: #2563eb; }
.rk-red   { color: #dc2626; }

/* Variação badge */
.rk-var {
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}
.rk-var-ok   { background: #d1fae5; color: #065f46; }
.rk-var-mid  { background: #fef3c7; color: #92400e; }
.rk-var-high { background: #fee2e2; color: #991b1b; }

/* Sparkline */
.rk-spark { display: block; }

/* Fornecedores */
.rk-forn-section { display: flex; flex-direction: column; gap: .25rem; }
.rk-forn-title { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-light); margin-bottom: .1rem; }
.rk-forn-row {
    display: grid;
    grid-template-columns: 18px 1fr auto auto auto;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
}
.rk-forn-medal { font-size: .8rem; line-height: 1; }
.rk-forn-id { color: var(--text-secondary); font-family: monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-forn-bar-wrap { height: 5px; background: var(--bg-tertiary); border-radius: 3px; min-width: 40px; overflow: hidden; }
.rk-forn-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 3px; transition: width .3s; }
.rk-forn-avg { font-family: monospace; font-weight: 700; color: var(--primary-color); white-space: nowrap; }
.rk-forn-count { color: var(--text-light); font-size: .68rem; white-space: nowrap; }
.rk-forn-more { font-size: .68rem; color: var(--text-light); text-align: right; font-style: italic; }

@media (max-width: 700px) {
    .rk-grid { grid-template-columns: 1fr; }
}

/* ══ Ranking v2 — por unidade ══ */
.rk-pai-code { font-size: .85rem !important; padding: 3px 10px !important; }
.rk-sub { font-size: .68rem !important; padding: 1px 5px !important; opacity: .8; }
.rk-subitens { display: flex; flex-wrap: wrap; gap: .3rem; margin: -.1rem 0 .2rem; }

.rk-card-meta { display: flex; gap: .4rem; align-items: center; }
.rk-total-chip {
    font-size: .72rem; font-weight: 700;
    color: var(--primary-dark); background: #eff6ff;
    border: 1px solid #bfdbfe; border-radius: 12px; padding: 2px 8px;
}
.rk-compras-chip {
    font-size: .68rem; color: var(--text-secondary);
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: 12px; padding: 2px 7px;
}
.rk-un-count {
    font-size: .68rem; font-weight: 600; color: #7c3aed;
    background: #ede9fe; border: 1px solid #c4b5fd;
    border-radius: 12px; padding: 2px 7px;
}

/* Bloco por unidade */
.rk-un-block {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-primary);
}
.rk-un-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .6rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.rk-un-badge { font-size: .8rem !important; padding: 3px 8px !important; }
.rk-un-metrics { display: flex; gap: .6rem; align-items: center; flex: 1; }
.rk-mmin { font-family: monospace; font-size: .74rem; font-weight: 700; color: #059669; }
.rk-mavg { font-family: monospace; font-size: .74rem; font-weight: 700; color: #2563eb; }
.rk-mmax { font-family: monospace; font-size: .74rem; font-weight: 700; color: #dc2626; }
.rk-spark-na { font-size: .72rem; color: var(--text-light); }

/* Fornecedores dentro do bloco */
.rk-forn-section { padding: .5rem .6rem; }
.rk-forn-title {
    font-size: .62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-light);
    margin-bottom: .3rem; display: flex; gap: .4rem; align-items: center;
}
.rk-muted { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-light); font-style: italic; }
.rk-legend { margin-left: auto; font-weight: 400; text-transform: none; letter-spacing: 0; }

.rk-forn-row {
    display: grid;
    grid-template-columns: 18px 1fr auto auto auto auto;
    align-items: center;
    gap: .25rem;
    padding: .18rem 0;
    font-size: .72rem;
}
.rk-delta { font-size: .65rem; font-weight: 700; padding: 1px 4px; border-radius: 4px; white-space: nowrap; }
.rk-delta-ok  { background: #d1fae5; color: #065f46; }
.rk-delta-bad { background: #fee2e2; color: #991b1b; }
.rk-delta-neu { background: var(--bg-tertiary); color: var(--text-light); }
.rk-forn-count { font-size: .62rem; color: var(--text-light); white-space: nowrap; }

/* Separador entre unidades */
.rk-un-sep { height: .4rem; }
.rk-un-wrapper { }
.rk-un-collapsed .rk-un-body { display: none; }
.rk-un-toggle {
    width: 100%; text-align: left; padding: .3rem .5rem;
    font-size: .72rem; cursor: pointer;
    background: #f8f4ff; border: 1px solid #ede9fe;
    border-radius: var(--radius-sm); color: #6d28d9; font-weight: 600;
    transition: background .15s;
}
.rk-un-toggle:hover { background: #ede9fe; }

/* ══ Fornecedor clicável na tabela de pedidos ══ */
.col-supplier { min-width: 140px; }
.col-dept     { width: 90px; }

.td-supplier {
    cursor: pointer;
    transition: background .15s;
}
.td-supplier:hover { background: #eff6ff !important; }

.supplier-id {
    display: block;
    font-family: monospace;
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary-color);
}
.supplier-name {
    display: block;
    font-size: .72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    margin-top: 1px;
}

/* Badges de departamento */
.dept-badge {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    white-space: nowrap;
    margin: 1px;
}
.dept-badge.dept-8  { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.dept-badge.dept-27 { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* ══ Modal do Credor ══ */
.cred-modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.cred-modal-overlay.active { display: flex; }

.cred-modal-box {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
    animation: modalSlideIn .2s ease;
}
@keyframes modalSlideIn {
    from { opacity:0; transform: translateY(-16px); }
    to   { opacity:1; transform: translateY(0); }
}

.cred-modal-close {
    position: absolute; top: .75rem; right: .75rem;
    background: var(--bg-tertiary); border: none;
    border-radius: 50%; width: 28px; height: 28px;
    font-size: .9rem; cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.cred-modal-close:hover { background: #fecaca; color: #991b1b; }

.cred-modal-loading {
    display: flex; align-items: center; gap: .6rem;
    padding: 2rem; color: var(--text-secondary); font-size: .9rem;
}

.cred-modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 1.25rem 1.25rem .75rem;
    border-bottom: 1px solid var(--border-color);
    gap: .75rem;
}
.cred-modal-nome {
    font-size: 1rem; font-weight: 700; color: var(--text-primary); line-height: 1.3;
}
.cred-modal-fantasia {
    font-size: .82rem; color: var(--text-secondary); margin-top: .2rem;
}
.cred-modal-badges { display: flex; gap: .4rem; flex-wrap: wrap; flex-shrink: 0; }

.cred-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    padding: 1rem 1.25rem;
}
.cred-field {
    display: flex; flex-direction: column; gap: .2rem;
}
.cred-field-full { grid-column: 1 / -1; }
.cred-lbl {
    font-size: .62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-light);
}
.cred-val {
    font-size: .84rem; color: var(--text-primary);
    display: flex; flex-wrap: wrap; gap: .3rem; align-items: center;
}
.cred-tag {
    display: inline-block;
    padding: 2px 8px; border-radius: 12px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    font-size: .78rem; color: var(--text-secondary);
}
.cred-email { color: var(--primary-color); text-decoration: none; }
.cred-email:hover { text-decoration: underline; }

.cred-raw-details {
    margin: 0 1.25rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.cred-raw-details summary {
    padding: .4rem .75rem; font-size: .72rem; color: var(--text-light);
    cursor: pointer; background: var(--bg-tertiary);
}
.cred-raw {
    padding: .75rem; font-size: .7rem; overflow-x: auto;
    color: var(--text-secondary); background: var(--bg-secondary);
    margin: 0; max-height: 200px; overflow-y: auto;
}

/* ══ Tabela de Credores ══ */
.col-cred-id    { width: 72px; }
.cred-nome-cell { font-weight: 600; font-size: .82rem; }
.cred-fantasia-cell { font-size: .78rem; color: var(--text-secondary); }
.cred-id-badge  { cursor: pointer !important; transition: background .15s !important; }
.cred-id-badge:hover { background: #dbeafe !important; }
.cred-row-sem-dados td { opacity: .55; font-style: italic; }
.credores-search {
    padding: .42rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .875rem;
    outline: none;
    width: 260px;
    transition: border-color .2s;
}
.credores-search:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* Botão importar credores */
.btn-credores {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none; border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: all .3s ease; display: inline-flex;
    align-items: center; gap: .4rem; white-space: nowrap;
    background: #0891b2; color: #fff;
}
.btn-credores:hover:not(:disabled) { background: #0e7490; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-credores:disabled { opacity: .5; cursor: not-allowed; }

/* ══ Paginação do Banco de Dados ══ */
.db-paginacao {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: .75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.db-pag-btn {
    padding: .35rem .85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--primary-color);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.db-pag-btn:hover:not(:disabled) { background: #eff6ff; border-color: var(--primary-color); }
.db-pag-btn:disabled { opacity: .4; cursor: not-allowed; }
.db-pag-info {
    font-size: .78rem;
    color: var(--text-secondary);
}
.db-pag-info strong { color: var(--text-primary); }

/* ══ Card Valor Entregue ══ */
.summary-card.highlight-green { border-color: #059669; background: #ecfdf5; }
.summary-card.highlight-green .summary-val { color: #059669; }
.summary-card.highlight-green .summary-key { color: #065f46; }

/* ══ Quota Badge (cota diária de req) ══ */
.quota-badge {
    display: inline-flex;
    align-items: center;
    padding: .25rem .6rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .01em;
    margin-right: .5rem;
    border: 1px solid transparent;
    transition: all .3s;
}
.quota-ok     { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.quota-aviso  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.quota-critico{ background: #fef2f2; color: #991b1b; border-color: #fecaca; animation: pulse-red .8s ease-in-out infinite alternate; }
@keyframes pulse-red { from { opacity: 1; } to { opacity: .6; } }

/* ══════════════════════════════════════════════════════
   NOVOS ESTILOS — Importar Obras · Nome da Obra ·
   Page Size · Estado Filter
══════════════════════════════════════════════════════ */

/* Botão Importar Obras */
.btn-obras {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none; border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: all .3s ease; display: inline-flex;
    align-items: center; gap: .4rem; white-space: nowrap;
    background: #059669; color: #fff;
}
.btn-obras:hover:not(:disabled) { background: #047857; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-obras:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Seletor de tamanho de página */
.page-size-wrap {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.page-size-sel {
    padding: .25rem .5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: .78rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
}
.page-size-sel:focus { border-color: var(--primary-color); }

/* Coluna Nome da Obra — tabela de Pedidos */
.col-nome-obra { width: 180px; }
.col-nome-obra-cell { max-width: 200px; }

/* Badge / texto de nome da obra */
.nome-obra-cell {
    display: inline-block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 190px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* Coluna Nome da Obra — tabela de Banco de Dados */
.db-table .col-nome-obra { width: 160px; overflow: hidden; }
.db-table .col-nome-obra .nome-obra-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    font-size: .75rem;
    max-width: 155px;
}

/* Ajustar min-width do db-table para nova coluna */
.db-table { min-width: 1020px; }

/* Paginação de Pedidos (reutiliza estilo db-paginacao) */
#pedPaginacao {
    border-top: 1px solid var(--border-color);
    margin-top: 0;
}

/* ══ Atualizar Pedidos ══ */
.btn-update-pedidos {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none; border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: all .3s ease; outline: none;
    display: inline-flex; align-items: center; gap: .4rem;
    white-space: nowrap;
    background: #0369a1; color: #fff;
}
.btn-update-pedidos:hover:not(:disabled) { background: #075985; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-update-pedidos:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ══ Atualizar Robô ══ */
.btn-robo {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none; border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 700; cursor: pointer;
    transition: all .3s ease; outline: none;
    display: inline-flex; align-items: center; gap: .4rem;
    white-space: nowrap;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: #fff; box-shadow: 0 2px 8px rgba(124,58,237,.35);
}
.btn-robo:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9, #1d4ed8);
    transform: translateY(-2px); box-shadow: 0 4px 16px rgba(124,58,237,.45);
}
.btn-robo:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ══ Modal Modo Entregas ══ */
.modo-modal-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn .15s ease;
}
.modo-modal-box {
    background: var(--card-bg, #fff);
    border-radius: 1.25rem;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    padding: 2rem 2.25rem 1.75rem;
    width: 100%; max-width: 440px;
    display: flex; flex-direction: column; align-items: center; gap: .75rem;
    animation: slideUp .2s ease;
}
.modo-modal-icon { font-size: 2.5rem; line-height: 1; }
.modo-modal-titulo {
    font-size: 1.25rem; font-weight: 700;
    color: var(--text-primary, #111); margin: 0;
}
.modo-modal-desc {
    font-size: .9rem; color: var(--text-secondary, #555);
    text-align: center; margin: 0;
}
.modo-modal-btns {
    display: flex; flex-direction: column; gap: .65rem;
    width: 100%; margin-top: .5rem;
}
.modo-btn-continuar, .modo-btn-refazer {
    width: 100%; padding: .85rem 1rem;
    border: none; border-radius: .85rem;
    cursor: pointer; font-weight: 600;
    display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
    font-size: .95rem; transition: all .2s ease;
    text-align: left;
}
.modo-btn-continuar {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff;
}
.modo-btn-continuar:hover { filter: brightness(1.1); transform: translateY(-1px); }
.modo-btn-refazer {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111);
    border: 1.5px solid var(--border-color, #e5e7eb);
}
.modo-btn-refazer:hover { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.modo-btn-sub {
    font-size: .78rem; font-weight: 400;
    opacity: .8;
}
.modo-btn-cancelar {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary, #888); font-size: .85rem;
    padding: .35rem .75rem; border-radius: .5rem;
    transition: color .2s;
}
.modo-btn-cancelar:hover { color: var(--text-primary, #111); }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ══ Preços Materiais Contratos ══ */
.btn-precos-contratos {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none; border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: all .3s ease; outline: none;
    display: inline-flex; align-items: center; gap: .4rem;
    white-space: nowrap;
    background: linear-gradient(135deg, #065f46, #047857);
    color: #fff; box-shadow: 0 2px 8px rgba(6,95,70,.3);
}
.btn-precos-contratos:hover:not(:disabled) {
    background: linear-gradient(135deg, #064e3b, #065f46);
    transform: translateY(-2px); box-shadow: 0 4px 14px rgba(6,95,70,.4);
}
.btn-precos-contratos:disabled { opacity: .5; cursor: not-allowed; transform: none; }
