:root {
    --brand-green: #a5b93e;
    --brand-blue: #2b88c0;
    --brand-red: #e11d2a;
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #24303c;
    --muted: #6b7280;
    --border: #d8dee6;
    --ok-bg: #e8f8ee;
    --ok-text: #167a3f;
    --pending-bg: #ffe9e9;
    --pending-text: #b42318;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
    color: #fff;
    padding: 24px 32px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.topbar-main {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-logo {
    width: 84px;
    height: 84px;
    object-fit: contain;
    background: rgba(255,255,255,.15);
    border-radius: 20px;
    padding: 6px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar p {
    margin: 6px 0 0;
    opacity: .95;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255,255,255,.18);
    padding: 10px 14px;
    border-radius: 16px;
    backdrop-filter: blur(4px);
}

.btn-logout, .btn-primary, .btn-secondary {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-logout {
    background: #fff;
    color: var(--brand-red);
    padding: 10px 14px;
}

.page-content {
    padding: 24px;
}

.filters-card, .table-card, .summary-card, .alert-error, .chart-card, .login-card, .login-brand {
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.filters-card {
    padding: 20px;
    margin-bottom: 20px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 16px;
    align-items: end;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 700; }
.field input, .field select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    background: #fff;
}

.field-actions { justify-content: end; }

.btn-primary {
    background: var(--brand-red);
    color: #fff;
}

.btn-secondary {
    background: #e8f1f7;
    color: var(--brand-blue);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.summary-card {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.summary-card span { color: var(--muted); }
.summary-card strong { font-size: 28px; }
.summary-ok { border-left: 6px solid var(--ok-text); }
.summary-pending { border-left: 6px solid var(--pending-text); }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.chart-card {
    padding: 18px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chart-card-header h2, .table-header h2 {
    margin: 0;
    font-size: 20px;
}

.chart-scroll {
    overflow-x: auto;
}

.chart-svg {
    width: 100%;
    min-width: 640px;
    min-height: 320px;
}

.table-card { padding: 16px; }

.legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
}

.legend-box {
    width: 14px;
    height: 14px;
    display: inline-block;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-ok { background: var(--ok-bg); border: 1px solid #c6f0d4; }
.legend-pending { background: var(--pending-bg); border: 1px solid #f5b8b8; }

.table-responsive { overflow-x: auto; }

.table-card table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

.table-card th, .table-card td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.table-card thead th {
    background: #eff5f9;
    position: sticky;
    top: 0;
}

.row-ok { background: var(--ok-bg); }
.row-pending { background: var(--pending-bg); }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-ok { background: #d1fadf; color: var(--ok-text); }
.badge-pending { background: #ffd6d6; color: var(--pending-text); }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.empty-state { text-align: center; color: var(--muted); padding: 28px; }
.alert-error { padding: 16px 18px; color: var(--pending-text); margin-bottom: 18px; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #dcecf7, #f8f3d8);
}

.login-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 24px;
}

.login-brand, .login-card {
    padding: 32px;
}

.login-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.login-brand h1 {
    margin-bottom: 8px;
    font-size: 34px;
}

.login-brand p {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.5;
}

.login-form {
    display: grid;
    gap: 16px;
}

.btn-block {
    width: 100%;
}

.login-tip {
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

.field-validation-error {
    color: var(--pending-text);
    font-size: 12px;
}

@media (max-width: 1100px) {
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-grid,
    .charts-grid,
    .login-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .page-content { padding: 16px; }
    .topbar { padding: 18px; }
    .topbar-main, .brand-wrap, .user-box {
        flex-direction: column;
        align-items: flex-start;
    }
    .brand-logo { width: 64px; height: 64px; }
    .filters-grid, .summary-grid {
        grid-template-columns: 1fr;
    }
}


.filters-grid-extended {
    grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.filters-hint {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.table-header-stack {
    gap: 12px;
    flex-wrap: wrap;
}

.pagination-summary {
    color: var(--muted);
    font-weight: 700;
}

.pagination-nav {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.page-link.active {
    background: var(--brand-blue);
    color: #fff;
    border-color: var(--brand-blue);
}

.page-link.disabled {
    opacity: .45;
    pointer-events: none;
}


.filters-form-classic {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.filters-grid-classic {
    display: grid;
    grid-template-columns: 1.05fr 1.05fr 1.05fr 1.05fr 320px;
    gap: 14px;
    align-items: end;
}

.field-group-classic, .field-group-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-group-classic label, .field-group-compact label {
    font-weight: 700;
    color: var(--text);
}

.input-classic, .input-compact {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0 14px;
    font-size: 14px;
    background: #fff;
}

.field-button-classic {
    align-self: end;
}

.btn-primary-classic {
    width: 100%;
    height: 44px;
    border-radius: 14px;
}

.filters-subrow-classic {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.filters-subgroup-classic {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.field-group-compact {
    min-width: 180px;
}

.btn-secondary-classic {
    height: 44px;
    border-radius: 14px;
    min-width: 180px;
}

@media (max-width: 1200px) {
    .filters-grid-classic {
        grid-template-columns: repeat(2, 1fr);
    }

    .field-button-classic {
        grid-column: span 2;
    }
}

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

    .field-button-classic {
        grid-column: auto;
    }

    .filters-subrow-classic, .filters-subgroup-classic {
        flex-direction: column;
        align-items: stretch;
    }

    .field-group-compact, .btn-secondary-classic {
        min-width: 100%;
    }
}


.table-head-stack {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
}

.cell-chave {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Atualizações: pesquisa nos selects, marcações de notas e tabela */
.filters-grid-classic-v2 {
    grid-template-columns: 1fr 1fr 1.35fr 1.35fr 220px;
}

.searchable-field {
    gap: 6px;
}

.input-search-option {
    height: 36px;
    font-size: 13px;
    background: #f8fafc;
}

.row-canceled {
    background: #f3f4f6;
    color: #475467;
}

.row-returned {
    background: #fff4e5;
}

.legend-canceled {
    background: #e5e7eb;
    border: 1px solid #cbd5e1;
}

.legend-returned {
    background: #ffe4bd;
    border: 1px solid #ffc078;
}

.badge-neutral {
    background: #e8f1f7;
    color: var(--brand-blue);
}

.badge-received {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-canceled {
    background: #e5e7eb;
    color: #374151;
}

.badge-returned {
    background: #ffedd5;
    color: #c2410c;
}

.mark-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 230px;
}

.mark-actions form {
    margin: 0;
}

.btn-mark {
    border: 0;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.btn-mark-received {
    background: #dbeafe;
    color: #1d4ed8;
}

.btn-mark-canceled {
    background: #e5e7eb;
    color: #374151;
}

.btn-mark-returned {
    background: #ffedd5;
    color: #c2410c;
}

.btn-mark-clear {
    background: #fee2e2;
    color: #b91c1c;
}

.notes-table {
    min-width: 1450px;
}

@media (max-width: 1200px) {
    .filters-grid-classic-v2 {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* Ajustes desta versão: filtros alinhados, pesquisa ao abrir select, etiqueta e usuários */
.filters-grid-classic-v2 {
    grid-template-columns: 1fr 1fr 1.4fr 1.4fr 220px;
    align-items: end;
}

.select-search-wrapper {
    position: relative;
}

.select-search-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.select-search-panel.open {
    display: block;
}

.select-search-input {
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 12px;
    font-size: 13px;
    outline: none;
}

.input-search-option {
    display: none;
}

.topbar-link {
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,.16);
}

.topbar-link:hover {
    background: rgba(255,255,255,.25);
}

.alert-success {
    background: #e8f8ee;
    color: #167a3f;
    padding: 16px 18px;
    margin-bottom: 18px;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.btn-small {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.users-table {
    min-width: 900px;
}

.user-edit-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.user-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.checkbox-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    font-weight: 700;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stores-permission-box {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: #f8fafc;
}

.stores-grid {
    margin-top: 14px;
    max-height: 360px;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.store-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
}

.store-check small {
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 1200px) {
    .filters-grid-classic-v2,
    .user-form-grid,
    .stores-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .filters-grid-classic-v2,
    .user-form-grid,
    .stores-grid {
        grid-template-columns: 1fr;
    }
}


/* Correções de performance/layout: filtros pesquisáveis reais e linhas no rodapé */
.combo-search {
    position: relative;
    width: 100%;
}

.combo-button {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0 40px 0 14px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

.combo-button::after {
    content: "▾";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.combo-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .18);
    padding: 10px;
}

.combo-panel.open {
    display: block;
}

.combo-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 12px;
    margin-bottom: 8px;
    font-size: 14px;
    outline: none;
}

.combo-options {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    gap: 4px;
}

.combo-option {
    width: 100%;
    border: 0;
    background: #fff;
    padding: 9px 10px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
}

.combo-option:hover {
    background: #e8f1f7;
    color: var(--brand-blue);
}

.pagination-wrap-bottom {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    align-items: center;
}

.page-size-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

.page-size-bottom select {
    min-width: 90px;
}

.filters-subgroup-classic {
    align-items: end;
}

.filters-grid-classic-v2 {
    grid-template-columns: 1fr 1fr 1.35fr 1.35fr 220px;
    align-items: end;
}

.select-search-wrapper,
.select-search-panel,
.input-search-option {
    display: none;
}


/* Ajuste rodapé: seletor de linhas compacto ao lado dos botões */
.pagination-wrap-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.pagination-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.page-size-bottom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    flex: 0 0 auto;
}

.page-size-bottom label {
    white-space: nowrap;
}

.input-page-size {
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
    height: 40px;
    padding: 0 8px;
}

.pagination-nav {
    margin-top: 0 !important;
    display: inline-flex;
    align-items: center;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.module-header h2 {
    margin: 0 0 6px;
    font-size: 26px;
}

.module-header p {
    margin: 0;
    color: var(--muted);
}

.alert-success {
    background: #e8f8ee;
    color: #167a3f;
    border: 1px solid #bfe8cd;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-weight: 700;
}

.relation-form-card h3 {
    margin: 0 0 16px;
}

.relation-section-title {
    font-weight: 800;
    color: var(--brand-blue);
    margin: 18px 0 12px;
}

.relation-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
}

.field-wide { grid-column: span 2; }
.field-wide-2 { grid-column: span 2; }

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.relation-confirmed {
    align-self: end;
    min-height: 44px;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
}

.validation-message {
    color: var(--brand-red);
    font-size: 12px;
    font-weight: 700;
}

.relation-filter-grid {
    grid-template-columns: 2fr 1fr 1fr 150px auto;
}

.relation-table-card {
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f8fafc;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.muted-line {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.tag-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-line span,
.badge-neutral,
.badge-ok,
.badge-warning,
.badge-danger {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
}

.tag-line span,
.badge-neutral {
    background: #eef2f7;
    color: #334155;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.badge-warning {
    background: #fff7db;
    color: #946200;
}

.badge-danger {
    background: var(--pending-bg);
    color: var(--pending-text);
}

.row-muted {
    opacity: .58;
}

.actions-cell {
    min-width: 170px;
}

.inline-form {
    display: inline;
}

.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    margin: 2px;
}

.btn-danger-outline {
    color: var(--brand-red);
    border-color: #f2b5ba;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 28px !important;
}

.pagination-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
}

.disabled {
    pointer-events: none;
    opacity: .45;
}

@media (max-width: 1100px) {
    .relation-grid,
    .relation-filter-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .field-wide,
    .field-wide-2 {
        grid-column: span 2;
    }
}

@media (max-width: 700px) {
    .module-header,
    .form-actions,
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .relation-grid,
    .relation-filter-grid {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .field-wide-2 {
        grid-column: span 1;
    }
}

/* Relacionamento por nota fiscal */
.page-header-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.page-header-row p {
    color: #667085;
    margin-top: 4px;
}

.relation-filters {
    align-items: end;
    margin-bottom: 18px;
}

.relation-key {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.note-summary-grid > div {
    background: #f8f8fb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
}

.note-summary-grid span,
.note-summary-grid small,
.muted-block {
    display: block;
    color: #667085;
    font-size: 0.82rem;
}

.note-summary-grid strong {
    display: block;
    color: #344054;
    margin-top: 3px;
}

.relation-help-box {
    background: #fff7df;
    border: 1px solid #f6d66b;
    color: #594100;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.relation-items-table td {
    vertical-align: top;
}

.relation-input-grid {
    display: grid;
    grid-template-columns: minmax(120px, 0.7fr) minmax(140px, 0.8fr) minmax(260px, 2fr);
    gap: 8px;
}

.inline-relation-form input {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 8px 10px;
}

.inline-relation-form small {
    display: block;
    color: #667085;
    margin-top: 6px;
}

.btn-danger {
    background: #b42318;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    text-decoration: none;
}

.btn-small {
    padding: 7px 10px;
    font-size: 0.85rem;
}

.alert-success {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: #067647;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    background: #f2f4f7;
    color: #344054;
    font-weight: 600;
    font-size: 0.8rem;
}

.badge-relacionada,
.relation-status-confirmado .badge-status {
    background: #dcfae6;
    color: #067647;
}

.badge-parcial,
.relation-status-sugerido .badge-status {
    background: #fef0c7;
    color: #93370d;
}

.badge-sem-vínculos,
.badge-sem-itens,
.relation-status-sem-sugestão .badge-status {
    background: #fee4e2;
    color: #b42318;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.pagination-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 900px) {
    .page-header-row,
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .relation-input-grid {
        grid-template-columns: 1fr;
    }
}

/* Ajustes do relacionamento por nota para seguir o padrão visual dos filtros principais */
.relation-note-filter-grid {
    grid-template-columns: 1fr 1fr 1.35fr 1.1fr 180px;
}

.note-summary-grid-v2 {
    grid-template-columns: repeat(4, 1fr);
}

.product-selected-box {
    border: 1px dashed var(--border);
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    display: grid;
    gap: 4px;
}

.product-selected-box.has-product {
    border-style: solid;
    background: var(--ok-bg);
    border-color: #abefc6;
}

.product-selected-box span {
    color: var(--muted);
    font-size: 12px;
}

.product-search-box {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.product-search-results {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    max-height: 260px;
    overflow: auto;
}

.product-result-item {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 4px;
}

.product-result-item:hover {
    border-color: var(--brand-blue);
    background: #e8f1f7;
}

.product-result-item span,
.product-result-item small,
.product-result-muted {
    color: var(--muted);
    font-size: 12px;
}

.product-result-muted {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

@media (max-width: 1200px) {
    .relation-note-filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .note-summary-grid-v2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .relation-note-filter-grid,
    .note-summary-grid-v2,
    .product-search-box {
        grid-template-columns: 1fr;
    }
}

/* Defeitos */
.selected-product-box {
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 14px 16px;
    background: #f8fafc;
    color: #475569;
}
.relation-product-search-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.relation-search-results {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}
.relation-result-item {
    border: 1px solid #dbe4ef;
    background: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 4px;
}
.relation-result-item:hover {
    border-color: #0ea5e9;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}
.relation-result-item span {
    color: #52627a;
    font-size: .9rem;
}
.validation-message {
    color: #dc2626;
    font-size: .85rem;
}
@media (max-width: 760px) {
    .relation-product-search-row { grid-template-columns: 1fr; }
}
.relation-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
}
.summary-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
    padding: 18px 20px;
}
.summary-card span {
    color: #64748b;
    font-size: .92rem;
}
.summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 1.12rem;
    color: #0f172a;
}
.summary-card small {
    display: block;
    margin-top: 6px;
    color: #475569;
    word-break: break-word;
}
.form-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
    padding: 20px;
}
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
@media (max-width: 980px) {
    .relation-summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .relation-summary-grid { grid-template-columns: 1fr; }
}

/* Menu por abas para reduzir excesso de botões no topo */
.module-tabs {
    display: flex;
    gap: 10px;
    padding: 12px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    position: sticky;
    top: 0;
    z-index: 20;
}

.module-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    color: var(--brand-blue);
    background: #edf6fb;
}

.module-tab.active {
    background: var(--brand-red);
    color: #ffffff;
}

.header-actions-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.user-box-compact {
    gap: 12px;
}

.alert-info-soft {
    background: #fff8e1;
    color: #6b4e00;
    border: 1px solid #f3cc55;
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 18px;
}
.badge-danger {
    background: var(--pending-bg) !important;
    color: var(--pending-text) !important;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}
.hamburger-menu {
    position: relative;
}
.hamburger-menu summary {
    list-style: none;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255,255,255,.22);
    color: #fff;
    font-size: 28px;
    font-weight: 800;
    user-select: none;
}
.hamburger-menu summary::-webkit-details-marker { display: none; }
.hamburger-panel {
    position: absolute;
    top: 54px;
    right: 0;
    min-width: 260px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
    padding: 10px;
    z-index: 100;
}
.hamburger-panel a {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
}
.hamburger-panel a:hover,
.hamburger-panel a.active {
    background: #edf6fb;
    color: var(--brand-blue);
}
@media (max-width: 800px) {
    .topbar-main { flex-direction: column; align-items: flex-start; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .hamburger-panel { left: 0; right: auto; }
}

.defect-manager-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 18px;
    background: #fff;
}

.defect-manager-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.defect-manager-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.defect-origin-form {
    margin-top: 12px;
}

.suggested-row {
    background: #f8fafc;
}

.quantity-origin-input {
    max-width: 130px;
}

/* Fretes / CT-e */
.detail-section-card {
    margin-bottom: 18px;
}

.detail-section-card h2 {
    margin-top: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.detail-grid > div {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
}

.detail-grid span,
.detail-grid small {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.detail-grid strong {
    display: block;
    margin-top: 4px;
}

.detail-two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.note-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
    margin-bottom: 10px;
}

.note-box p {
    margin-bottom: 0;
}

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

/* Portal Operacional Estripulia - ajustes de fretes e responsividade */
.fretes-filters-card {
    margin-bottom: 16px;
}

.fretes-filters-form .filters-grid-classic-v2 {
    grid-template-columns: 150px 150px minmax(190px, 1.2fr) minmax(190px, 1.2fr) minmax(190px, 1.2fr) 140px;
    gap: 14px;
    align-items: end;
}

.fretes-filters-form .field-button-classic {
    grid-column: auto;
}

.fretes-filters-form .filters-subrow-classic {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 14px;
}

.fretes-filters-form .filters-subgroup-classic {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(150px, .85fr) minmax(150px, .8fr) 90px 90px 110px;
    gap: 14px;
    align-items: end;
}

.fretes-filters-form .filters-subactions-classic {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: end;
}

.fretes-filters-form .field-group-compact,
.fretes-filters-form .field-group-classic {
    min-width: 0;
}

.fretes-summary-grid {
    margin-top: 0;
    margin-bottom: 20px;
}

.fretes-summary-grid .summary-card strong {
    word-break: break-word;
}

/* Tabelas e textos longos: melhora o uso em telas menores sem quebrar dados */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.data-table td,
.table-card td {
    word-break: normal;
}

.muted-block,
.muted-line,
.cell-chave,
.relation-key {
    overflow-wrap: anywhere;
}

/* Topo mais compacto para notebooks e monitores menores */
@media (max-width: 1366px) {
    .topbar { padding: 18px 24px; }
    .brand-logo { width: 68px; height: 68px; border-radius: 16px; }
    .topbar h1 { font-size: 24px; }
    .topbar p { font-size: 14px; }
    .page-content { padding: 20px; }
    .filters-card { padding: 16px; }
    .summary-card strong { font-size: 22px; }
}

@media (max-width: 1280px) {
    .fretes-filters-form .filters-grid-classic-v2 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .fretes-filters-form .field-button-classic {
        grid-column: span 3;
    }

    .fretes-filters-form .filters-subrow-classic {
        grid-template-columns: 1fr;
    }

    .fretes-filters-form .filters-subgroup-classic {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .fretes-filters-form .filters-subactions-classic {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 900px) {
    .topbar-main {
        align-items: stretch;
    }

    .brand-wrap {
        align-items: center;
    }

    .topbar-actions {
        justify-content: space-between;
        width: 100%;
    }

    .user-box-compact {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex: 1;
        min-width: 0;
    }

    .user-box-compact span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .summary-grid,
    .fretes-summary-grid,
    .relation-summary-grid,
    .note-summary-grid-v2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-head-stack,
    .table-header,
    .page-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .table-card {
        padding: 12px;
    }

    .data-table th,
    .data-table td,
    .table-card th,
    .table-card td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-logout,
    .btn-primary-classic,
    .btn-secondary-classic {
        min-height: 42px;
    }
}

@media (max-width: 760px) {
    .fretes-filters-form .filters-grid-classic-v2,
    .fretes-filters-form .filters-subgroup-classic {
        grid-template-columns: 1fr;
    }

    .fretes-filters-form .field-button-classic {
        grid-column: auto;
    }

    .fretes-filters-form .filters-subactions-classic,
    .filters-subactions-classic,
    .form-actions,
    .pagination-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .fretes-filters-form .filters-subactions-classic a,
    .filters-subactions-classic a,
    .form-actions a,
    .form-actions button,
    .pagination-actions a {
        width: 100%;
    }

    .combo-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        max-height: 72vh;
        overflow: hidden;
        z-index: 300;
    }

    .combo-options {
        max-height: 54vh;
    }
}

@media (max-width: 640px) {
    .page-content { padding: 12px; }
    .topbar { padding: 14px; }

    .brand-wrap {
        gap: 12px;
        flex-direction: row;
    }

    .brand-logo {
        width: 54px;
        height: 54px;
        border-radius: 14px;
    }

    .topbar h1 {
        font-size: 19px;
        line-height: 1.15;
    }

    .topbar p {
        font-size: 12px;
    }

    .hamburger-menu summary {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 24px;
    }

    .hamburger-panel {
        position: fixed;
        top: 86px;
        left: 12px;
        right: 12px;
        min-width: 0;
        max-height: calc(100vh - 104px);
        overflow-y: auto;
    }

    .user-box-compact {
        padding: 8px 10px;
        border-radius: 12px;
        gap: 8px;
    }

    .user-box-compact span {
        max-width: 150px;
        font-size: 13px;
    }

    .btn-logout {
        padding: 8px 10px;
        font-size: 12px;
    }

    .filters-card,
    .table-card,
    .form-card,
    .summary-card,
    .chart-card,
    .login-card,
    .login-brand {
        border-radius: 14px;
    }

    .summary-grid,
    .fretes-summary-grid,
    .relation-summary-grid,
    .note-summary-grid-v2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .summary-card {
        padding: 14px 16px;
    }

    .summary-card strong {
        font-size: 20px;
    }

    .input-classic,
    .input-compact,
    .field input,
    .field select,
    .combo-button {
        height: 42px;
        font-size: 14px;
    }

    .login-shell {
        gap: 14px;
    }

    .login-brand,
    .login-card {
        padding: 20px;
    }

    .login-brand h1 {
        font-size: 24px;
    }

    .login-brand p {
        font-size: 15px;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 0;
    }
}

@media (max-width: 420px) {
    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .hamburger-menu summary {
        width: 100%;
    }

    .hamburger-panel {
        top: 132px;
    }

    .user-box-compact {
        width: 100%;
    }

    .user-box-compact span {
        max-width: 190px;
    }

    .data-table,
    .table-card table {
        min-width: 980px;
    }
}

/* Ajustes finais: rolagem horizontal, ações agrupadas, permissões e mobile */
.table-wrapper,
.table-responsive,
.horizontal-scroll,
.note-items-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
}

.table-wrapper::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.horizontal-scroll::-webkit-scrollbar,
.note-items-scroll::-webkit-scrollbar {
    height: 12px;
}

.table-wrapper::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.horizontal-scroll::-webkit-scrollbar-thumb,
.note-items-scroll::-webkit-scrollbar-thumb {
    background: #b8c3cf;
    border-radius: 999px;
}

.actions-dropdown {
    position: relative;
    display: inline-block;
}

.actions-dropdown > summary {
    list-style: none;
    cursor: pointer;
}

.actions-dropdown > summary::-webkit-details-marker {
    display: none;
}

.actions-dropdown-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 190px;
    z-index: 250;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, .20);
    padding: 8px;
    display: grid;
    gap: 6px;
}

.actions-dropdown-panel form {
    margin: 0;
}

.actions-dropdown-panel .btn-mark {
    width: 100%;
    justify-content: flex-start;
    border-radius: 10px;
    text-align: left;
}

.btn-mark-info {
    background: #e8f1f7;
    color: var(--brand-blue);
}

.note-items-row td {
    background: #f8fafc;
}

.note-items-container {
    padding: 10px;
}

.note-items-table {
    min-width: 860px;
}

.screens-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.fretes-filters-form .filters-subgroup-classic {
    grid-template-columns: minmax(260px, 1fr) 120px;
}

.relation-table-wrap .data-table {
    min-width: 1250px;
}

@media (max-width: 760px) {
    .actions-dropdown-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        min-width: 0;
    }
}

/* Tela separada de itens da nota */
.note-items-page-header {
    align-items: flex-start;
    gap: 16px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.note-items-summary .summary-text {
    font-size: 16px;
    line-height: 1.25;
}

.note-items-page-table {
    min-width: 1280px;
}

.note-items-page-table th,
.note-items-page-table td {
    white-space: nowrap;
}

.note-items-page-table td:nth-child(4) {
    white-space: normal;
    min-width: 320px;
}

@media (max-width: 760px) {
    .note-items-page-header,
    .page-header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-header-actions .btn-secondary {
        width: 100%;
    }
}

/* Conferência de entrega */
.scanner-panel {
    margin: 18px 0;
    padding: 16px;
    border: 1px solid #d7dde8;
    border-radius: 14px;
    background: #f8fafc;
}

.scan-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 140px auto auto;
    gap: 12px;
    align-items: end;
}

.scan-input {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.camera-box {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.camera-box video {
    width: min(100%, 520px);
    max-height: 340px;
    border-radius: 14px;
    background: #111827;
}

.detail-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.table-wrapper-horizontal {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 760px) {
    .scan-form {
        grid-template-columns: 1fr;
    }

    .scanner-panel {
        padding: 12px;
    }

    .detail-actions {
        justify-content: stretch;
    }

    .detail-actions form,
    .detail-actions button {
        width: 100%;
    }
}

/* Ajustes conferência de entrega */
.quick-scan-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.quick-scan-field {
    min-width: 0;
}

.scan-import-form {
    margin-top: 14px;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding-top: 14px;
    border-top: 1px solid #d7dde8;
}

.camera-box[hidden] {
    display: none !important;
}

@media (max-width: 760px) {
    .quick-scan-form,
    .scan-import-form {
        grid-template-columns: 1fr;
    }
}

/* Leitura por câmera em tela fixa */
.camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 6, 23, .72);
}

.camera-overlay[hidden] {
    display: none !important;
}

.camera-overlay-card {
    width: min(720px, 100%);
    max-height: calc(100vh - 28px);
    overflow: auto;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .35);
    padding: 14px;
    display: grid;
    gap: 12px;
}

.camera-overlay-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.camera-overlay video {
    width: 100%;
    max-height: 56vh;
    border-radius: 16px;
    background: #111827;
    object-fit: cover;
}

.camera-overlay-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.camera-overlay-info div {
    border-radius: 14px;
    background: #f1f5f9;
    padding: 12px;
}

.camera-overlay-info span {
    display: block;
    color: #64748b;
    font-size: .82rem;
}

.camera-overlay-info strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 1.15rem;
    word-break: break-all;
}

@media (max-width: 640px) {
    .camera-overlay {
        align-items: stretch;
        padding: 8px;
    }

    .camera-overlay-card {
        max-height: calc(100vh - 16px);
    }

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


.camera-tap-button {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
}

.btn-danger {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    background: #dc2626;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.btn-danger:hover {
    filter: brightness(.96);
}


.login-links {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.login-links a {
    color: #0b76b7;
    font-weight: 700;
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

/* Ajustes notas em lote */
.bulk-actions-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
    padding: 10px;
    border: 1px solid #dbe3ec;
    border-radius: 14px;
    background: #f8fbff;
}
.bulk-select-label { font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.selection-col { width: 44px; text-align: center; }
.badge-authorized { background: #dcfce7; color: #166534; }
.btn-mark-authorized { background: #22c55e; color: #fff; }
.legend-authorized { background: #22c55e; }

.inline-import-form { display: inline-flex; align-items: center; margin: 0; }
.import-file-button { white-space: nowrap; }
.relation-product-search-row-wrap { flex-wrap: wrap; gap: 10px; }
.data-table th.sortable-header { cursor: pointer; user-select: none; position: relative; }
.data-table th.sortable-header::after { content: '⇅'; font-size: 11px; opacity: .45; margin-left: 6px; }
.data-table th.sort-asc::after { content: '↑'; opacity: .9; }
.data-table th.sort-desc::after { content: '↓'; opacity: .9; }
@media (max-width: 760px) { .relation-product-search-row-wrap > * { width: 100%; } .inline-import-form, .import-file-button { width: 100%; } }

/* Ajustes adicionais: ações compactas, ordenação e telas de defeitos */
.action-stack-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.action-stack-inline form { margin: 0; }
.btn-danger {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    background: #b42318;
    color: #fff;
}
.btn-danger.btn-small, .btn-small.btn-danger {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
}
.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sortable-header::after {
    content: ' ⇅';
    font-size: 11px;
    color: #64748b;
}
.sortable-header.sort-asc::after { content: ' ↑'; color: var(--brand-blue); }
.sortable-header.sort-desc::after { content: ' ↓'; color: var(--brand-blue); }
.defect-form-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}
.defect-side-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}
.defect-side-card .field-group-classic + .field-group-classic { margin-top: 12px; }
.defect-search-panel {
    min-width: 0;
}
@media (max-width: 900px) {
    .defect-form-grid { grid-template-columns: 1fr; }
    .action-stack-inline { flex-direction: column; align-items: stretch; }
    .action-stack-inline a, .action-stack-inline button { width: 100%; text-align: center; }
}

/* Módulos RH/CRM */
.module-tabs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    color: var(--brand-blue);
    background: #edf6fb;
}
.module-tabs a.active { background: var(--brand-red); color: #fff; }
.submenu-panel { display: flex; flex-direction: column; gap: 4px; }
.submenu-panel summary {
    cursor: pointer;
    padding: 10px 12px;
    font-weight: 800;
    color: var(--brand-blue);
    background: #f1f8fc;
    border-radius: 10px;
}
.submenu-panel[open] summary { background: #e8f1f7; }
.alert-success {
    background: #e8f8ee;
    color: #167a3f;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-weight: 700;
}


/* Ajuste do menu hambúrguer: impede que submenus RH/CRM herdem o botão grande do menu principal */
.hamburger-menu > summary {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255,255,255,.22);
    color: #fff;
    font-size: 28px;
    font-weight: 800;
}
.hamburger-panel .submenu-panel {
    display: block;
    margin: 4px 0;
}
.hamburger-panel .submenu-panel > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 800;
    background: transparent;
    width: auto;
    height: auto;
    display: block;
}
.hamburger-panel .submenu-panel > summary::-webkit-details-marker { display: none; }
.hamburger-panel .submenu-panel > summary:hover,
.hamburger-panel .submenu-panel[open] > summary {
    background: #edf6fb;
    color: var(--brand-blue);
}
.hamburger-panel .submenu-panel a {
    margin-left: 10px;
    padding: 9px 14px;
    font-weight: 700;
    font-size: 14px;
}
.system-config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 18px;
}
.config-row {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.config-row small { color: var(--muted); display: block; margin-top: 4px; }
.config-row textarea { width: 100%; min-height: 132px; resize: vertical; }
@media (max-width: 900px) { .system-config-grid, .config-row { grid-template-columns: 1fr; } }

/* RH - lançamentos de folha */
.grid-two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.sub-card { border: 1px solid #e5e7eb; border-radius: 12px; padding: 1rem; background: #fff; }
.field-wide { grid-column: 1 / -1; }
.checkbox-list { max-height: 220px; overflow: auto; border: 1px solid #d1d5db; border-radius: 10px; padding: .5rem; background: #fff; }
.checkbox-list label { display: block; margin: .25rem 0; font-size: .9rem; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
@media (max-width: 900px) { .grid-two-columns { grid-template-columns: 1fr; } }

/* =========================================================
   Correção mobile: filtros dentro da área visível da tela
   ========================================================= */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.page-content,
.topbar,
.topbar-main,
.filters-card,
.table-card,
.form-card,
.chart-card,
.summary-card,
.module-header,
.page-header-row {
    max-width: 100%;
}

.filters-card,
.form-card,
.table-card {
    min-width: 0;
}

.filters-grid,
.filters-grid-classic,
.filters-grid-classic-v2,
.relation-filter-grid,
.relation-note-filter-grid,
.fretes-filters-form .filters-grid-classic-v2,
.fretes-filters-form .filters-subgroup-classic,
.filters-subgroup-classic,
.filters-subrow-classic,
.grid-two-columns,
.relation-grid,
.user-form-grid,
.system-config-grid,
.config-row,
.defect-form-grid,
.scan-form,
.quick-scan-form,
.scan-import-form,
.product-search-box,
.relation-product-search-row {
    max-width: 100%;
    min-width: 0;
}

.field,
.field-group-classic,
.field-group-compact,
.searchable-field,
.combo-search,
.select-search-wrapper,
.field-actions,
.field-button-classic {
    min-width: 0;
    max-width: 100%;
}

.field input,
.field select,
.field textarea,
.field-group-classic input,
.field-group-classic select,
.field-group-classic textarea,
.field-group-compact input,
.field-group-compact select,
.field-group-compact textarea,
.input-classic,
.input-compact,
.combo-button,
.combo-input,
.select-search-input,
.btn-primary,
.btn-secondary,
.btn-primary-classic,
.btn-secondary-classic {
    max-width: 100%;
}

@media (max-width: 900px) {
    .filters-grid,
    .filters-grid-classic,
    .filters-grid-classic-v2,
    .relation-filter-grid,
    .relation-note-filter-grid,
    .fretes-filters-form .filters-grid-classic-v2,
    .fretes-filters-form .filters-subgroup-classic,
    .grid-two-columns,
    .relation-grid,
    .user-form-grid,
    .system-config-grid,
    .config-row,
    .defect-form-grid,
    .scan-form,
    .quick-scan-form,
    .scan-import-form,
    .product-search-box,
    .relation-product-search-row {
        grid-template-columns: 1fr !important;
    }

    .field-wide,
    .field-wide-2,
    .field-button-classic {
        grid-column: auto !important;
    }

    .filters-subrow-classic,
    .filters-subgroup-classic,
    .fretes-filters-form .filters-subrow-classic,
    .fretes-filters-form .filters-subactions-classic,
    .filters-subactions-classic,
    .form-actions,
    .pagination-wrap-bottom,
    .pagination-right,
    .page-header-actions,
    .header-actions-inline {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        width: 100%;
    }

    .field-actions,
    .field-button-classic {
        align-self: stretch !important;
    }

    .field-actions button,
    .field-button-classic button,
    .filters-subactions-classic a,
    .filters-subactions-classic button,
    .form-actions a,
    .form-actions button,
    .page-header-actions a,
    .page-header-actions button,
    .header-actions-inline a,
    .header-actions-inline button {
        width: 100%;
    }

    .filters-card {
        overflow: visible;
    }

    .table-card,
    .table-responsive,
    .table-wrapper,
    .horizontal-scroll,
    .note-items-scroll,
    .table-wrapper-horizontal {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 640px) {
    .topbar-main,
    .topbar-actions,
    .brand-wrap,
    .user-box-compact,
    .module-header,
    .page-header-row {
        max-width: 100%;
    }

    .page-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .filters-card,
    .form-card,
    .table-card {
        padding: 12px !important;
        margin-left: 0;
        margin-right: 0;
    }

    .brand-wrap > div {
        min-width: 0;
    }

    .topbar h1,
    .topbar p {
        overflow-wrap: anywhere;
    }

    .input-classic,
    .input-compact,
    .field input,
    .field select,
    .field textarea,
    .combo-button {
        width: 100%;
    }
}

/* Pedidos de compra */
.page-header-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { display: inline; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.form-footer-actions { padding: 16px 20px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.pedido-itens-wrap { overflow-x: auto; }
.pedido-itens-table { min-width: 1900px; }
.pedido-itens-table input, .pedido-itens-table select { width: 100%; min-width: 90px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.pedido-itens-table .product-search-cell { min-width: 280px; position: relative; }
.produto-sugestoes { display: none; position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 28px rgba(15,23,42,.18); z-index: 50; max-height: 280px; overflow: auto; }
.produto-sugestoes[style*="block"] { display: block; }
.produto-sugestao { display: block; width: 100%; border: 0; background: #fff; padding: 10px 12px; text-align: left; cursor: pointer; color: var(--text); }
.produto-sugestao:hover { background: #eef7ff; }
.muted { color: var(--muted); }
.alert-success { padding: 14px 18px; border-radius: 14px; background: var(--ok-bg); color: var(--ok-text); margin-bottom: 18px; font-weight: 700; }
.alert-danger { padding: 14px 18px; border-radius: 14px; background: var(--pending-bg); color: var(--pending-text); margin-bottom: 18px; font-weight: 700; }
.badge-danger { background: var(--pending-bg); color: var(--pending-text); }
.badge-success { background: var(--ok-bg); color: var(--ok-text); }

@media (max-width: 800px) {
    .page-header-actions { align-items: stretch; }
    .page-header-buttons { flex-direction: column; }
    .form-footer-actions { justify-content: stretch; }
    .form-footer-actions .btn-primary { width: 100%; }
}

/* Pedidos de compra - pesquisa robusta fora da área de rolagem da tabela */
.produto-sugestoes-portal {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(15,23,42,.22);
    z-index: 9999;
    max-height: 320px;
    overflow: auto;
    padding: 4px;
}

.notas-relacionadas {
    margin-top: 8px;
    min-width: 360px;
    max-width: 520px;
    white-space: normal;
}

.notas-relacionadas-titulo {
    font-size: 12px;
    font-weight: 800;
    color: var(--text);
    margin: 6px 0;
}

.nota-relacionada-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #f8fafc;
    font-size: 12px;
    line-height: 1.35;
}

.pedido-itens-table .product-search-cell {
    vertical-align: top;
}

/* Pedidos de compra - grade de quantidades por loja */
.pedido-quantidades-wrap {
    max-height: 72vh;
    overflow: auto;
}

.pedido-quantidades-table th:first-child,
.pedido-quantidades-table td:first-child {
    min-width: 320px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
}

.pedido-quantidades-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.pedido-quantidades-table thead th:first-child {
    z-index: 4;
}

.pedido-quantidades-table th,
.pedido-quantidades-table td {
    white-space: nowrap;
}

.qtd-loja-cell input,
.qtd-loja-input {
    width: 90px;
    min-width: 90px;
    text-align: right;
}

.produto-grade-cell strong {
    white-space: normal;
    display: block;
}
.text-success { color: #198754; }
.text-danger { color: #b00020; }
.details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.details-grid div { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px; }
.details-grid span { display: block; color: #64748b; font-size: .85rem; margin-bottom: 4px; }
.details-grid .detail-wide { grid-column: 1 / -1; word-break: break-all; }

.supplier-variations {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    min-width: 360px;
}

.supplier-variation-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid #dce5ee;
    border-radius: 12px;
    background: #f8fbfd;
}

.supplier-default-form {
    display: flex;
    gap: 8px;
    min-width: 360px;
}

.supplier-default-form input[type="text"] {
    min-width: 260px;
}

.badge-ok,
.badge-muted {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-ok {
    color: #0f5132;
    background: #d1e7dd;
}

.badge-muted {
    color: #53606d;
    background: #edf2f7;
}

.btn-small {
    padding: 6px 10px !important;
    font-size: 12px !important;
}

@media (max-width: 768px) {
    .supplier-variation-row,
    .supplier-default-form {
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
    }

    .supplier-default-form input[type="text"] {
        min-width: 0;
        width: 100%;
    }
}

/* Padronização visual do módulo Pedidos de Compra */
.pedido-itens-wrap { overflow-x: auto; }
.pedido-itens-table th,
.pedido-itens-table td { vertical-align: top; }
.pedido-itens-table input,
.pedido-itens-table select { min-height: 38px; }
.pedido-itens-table .product-search-cell { min-width: 280px; }
.produto-sugestoes-portal {
    position: fixed;
    z-index: 9999;
    display: none;
    max-height: 360px;
    overflow: auto;
    background: #fff;
    border: 1px solid #d8e0ea;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
    padding: 8px;
}
.produto-sugestao {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: #0f2438;
}
.produto-sugestao:hover { background: #eef6fb; }
.vinculo-produto-form {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) minmax(160px, 2fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 560px;
}
.vinculo-produto-form input { min-height: 36px; }
.table-header-stack { align-items: flex-start; gap: 16px; }
@media (max-width: 900px) {
    .vinculo-produto-form { grid-template-columns: 1fr; min-width: 260px; }
    .page-header-buttons { width: 100%; display: grid; grid-template-columns: 1fr; gap: 8px; }
}

/* Pedidos de Compra - padronização de botões e resumo do recebimento */
.pedidos-compra-page .page-header-buttons a,
.pedidos-compra-page .page-header-buttons button,
.pedidos-compra-page .field-actions a,
.pedidos-compra-page .field-actions button {
    min-height: 40px;
    padding: 9px 16px !important;
    font-size: 14px !important;
    line-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.pedidos-compra-page .actions-cell .btn-small,
.pedidos-compra-page .actions-cell form .btn-small {
    min-width: 82px;
    min-height: 34px;
    padding: 6px 10px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.receipt-result-card {
    margin: 16px 0;
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px solid #dce5ee;
    background: #fff;
}
.receipt-result-card.receipt-authorized { border-left: 6px solid #198754; }
.receipt-result-card.receipt-denied { border-left: 6px solid #dc3545; }
.receipt-status-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.receipt-status-line h2 { margin: 3px 0 5px; }
.receipt-status-line p { margin: 0; }
.receipt-status-label { color: #687789; font-size: 13px; }
.receipt-summary-grid { margin-bottom: 16px; }
.receipt-details-card { padding: 16px; }
.receipt-details-card details > summary { list-style: none; cursor: pointer; width: fit-content; }
.receipt-details-card details > summary::-webkit-details-marker { display: none; }
.receipt-details-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.receipt-details-content { margin-top: 18px; }
.receipt-items-table { margin-top: 18px; }
.receipt-waiting-row { opacity: .76; background: #f8fafc; }

@media (max-width: 768px) {
    .receipt-status-line { align-items: flex-start; flex-direction: column; }
    .receipt-details-card details > summary { width: 100%; }
    .receipt-details-button { width: 100%; }
}

/* Recebimento de pedidos: a grade exibe somente itens da NF-e. */
.pedidos-compra-page .receipt-items-table tr.receipt-item-ok > td {
    background: rgba(22, 163, 74, 0.08);
}
.pedidos-compra-page .receipt-items-table tr.receipt-item-error > td {
    background: rgba(220, 38, 38, 0.10);
}
.pedidos-compra-page .receipt-items-table tr.receipt-item-error td:first-child {
    border-left: 4px solid #b91c1c;
}

.totem-order-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-bottom:18px}.totem-product-stock{padding:18px 0;border-bottom:1px solid #dfe7df}.totem-product-stock:last-child{border-bottom:0}.totem-product-head{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;margin-bottom:12px}.totem-product-head>div{display:flex;flex-direction:column;gap:4px}.totem-product-head>div:last-child{flex-direction:row;flex-wrap:wrap;gap:16px}.data-table.compact td,.data-table.compact th{padding:8px 10px}.config-section-wide{margin-top:22px}.config-form-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;align-items:end}.config-form-grid label{display:flex;flex-direction:column;gap:6px}.checkbox-field{display:flex!important;flex-direction:row!important;align-items:center;gap:8px!important}.checkbox-field input[type=checkbox]{width:auto}.status-email-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.status-email-card{border:1px solid #dfe7df;border-radius:12px;padding:16px;background:#fff}.status-email-card label{display:flex;flex-direction:column;gap:6px;margin-top:12px}.status-email-title{display:flex;justify-content:space-between;gap:16px}.status-email-title>div{display:flex;flex-direction:column}.status-email-card textarea{width:100%;font-family:inherit}.status-badge{display:inline-block;padding:5px 9px;border-radius:999px;background:#eef6e6;font-weight:700;font-size:.82rem}.inline-form{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:10px}.pagination-bar{display:flex;justify-content:space-between;align-items:center;margin-top:16px}.empty-state{text-align:center;padding:30px!important;color:#667}.alert-error{background:#fdecec;color:#8b1e1e;border:1px solid #f0bcbc;border-radius:8px;padding:12px;margin:12px 0}
@media(max-width:1000px){.totem-order-summary,.config-form-grid,.status-email-grid{grid-template-columns:1fr}.totem-product-head{flex-direction:column}}

/* =========================================================
   Redesign comercial 2026 - Portal Operacional Estripulia
   Mantém as classes antigas e moderniza o shell inteiro.
   ========================================================= */
:root {
    --poe-blue-900: #0f3154;
    --poe-blue-800: #0b5f8c;
    --poe-blue-700: #1179a5;
    --poe-green-700: #15955a;
    --poe-green-600: #16a05f;
    --poe-green-100: #e8f7ee;
    --poe-lime: #9ab82e;
    --poe-red-600: #df2735;
    --poe-red-100: #fde7ea;
    --poe-amber-600: #f59e0b;
    --poe-amber-100: #fff4db;
    --poe-purple-600: #7c5bf2;
    --poe-purple-100: #f0ebff;
    --poe-bg: #f5f7fb;
    --poe-surface: #ffffff;
    --poe-surface-soft: #f8fafc;
    --poe-line: #dfe6ef;
    --poe-line-strong: #cfd8e3;
    --poe-text: #1d2c44;
    --poe-muted: #66758a;
    --poe-shadow-sm: 0 4px 14px rgba(15, 35, 60, .06);
    --poe-shadow-md: 0 12px 32px rgba(15, 35, 60, .10);
    --poe-radius: 18px;
}

.portal-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 90% 2%, rgba(154,184,46,.10), transparent 24rem),
        radial-gradient(circle at 4% 3%, rgba(17,121,165,.10), transparent 26rem),
        var(--poe-bg);
    color: var(--poe-text);
    font-family: Inter, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
}

.app-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.portal-body .topbar.app-topbar {
    position: sticky;
    top: 0;
    z-index: 260;
    min-height: 84px;
    padding: 15px 28px;
    background: linear-gradient(112deg, #075a86 0%, #147f94 49%, #89ad2e 100%);
    color: #fff;
    box-shadow: 0 10px 28px rgba(10, 48, 70, .16);
}

.portal-body .topbar-main {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.portal-body .brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.portal-body .brand-logo {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    padding: 5px;
    object-fit: contain;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}

.portal-body .topbar h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.08;
    font-weight: 850;
    letter-spacing: -.02em;
}

.portal-body .topbar p {
    margin: 5px 0 0;
    font-size: 13px;
    color: rgba(255,255,255,.92);
}

.sidebar-toggle {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.16);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.side-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 280;
    display: grid;
    grid-template-rows: 1fr auto;
    background: rgba(255,255,255,.92);
    border-right: 1px solid var(--poe-line);
    box-shadow: 10px 0 30px rgba(15,35,60,.05);
    backdrop-filter: blur(16px);
}

.side-nav-scroll {
    padding: 104px 14px 16px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.side-nav-item,
.side-nav-group > summary {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 4px 0;
    border-radius: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    color: #263951;
    font-size: 14px;
    font-weight: 760;
    list-style: none;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.side-nav-group > summary::-webkit-details-marker { display: none; }

.side-nav-item:hover,
.side-nav-group > summary:hover,
.side-nav-item.active,
.side-nav-group.active > summary {
    color: #067647;
    background: linear-gradient(180deg, rgba(232,247,238,.95), rgba(232,247,238,.72));
    border-color: rgba(22,160,95,.14);
}

.side-nav-item.active,
.side-nav-group.active > summary {
    box-shadow: inset 4px 0 0 var(--poe-green-600);
}

.nav-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f1f5f9;
    color: #31506d;
    font-size: 14px;
    font-weight: 900;
}

.side-nav-item.active .nav-icon,
.side-nav-group.active > summary .nav-icon,
.side-nav-item:hover .nav-icon,
.side-nav-group > summary:hover .nav-icon {
    color: #067647;
    background: #dff6e8;
}

.side-nav-subitems {
    display: grid;
    gap: 3px;
    margin: 3px 0 9px 42px;
}

.side-nav-subitems a {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    color: #59687d;
    text-decoration: none;
    font-size: 13px;
    font-weight: 720;
}

.side-nav-subitems a:hover,
.side-nav-subitems a.active {
    color: var(--poe-blue-800);
    background: #eef7ff;
}

.side-collapse {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 14px 18px;
    padding: 12px 14px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #31465e;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
}
.side-collapse span { font-size: 24px; }
.side-collapse:hover { background: #f1f5f9; }

.app-shell.sidebar-collapsed { grid-template-columns: 86px minmax(0, 1fr); }
.app-shell.sidebar-collapsed .side-nav-item span:not(.nav-icon),
.app-shell.sidebar-collapsed .side-nav-group > summary span:not(.nav-icon),
.app-shell.sidebar-collapsed .side-nav-subitems,
.app-shell.sidebar-collapsed .side-collapse strong { display: none; }
.app-shell.sidebar-collapsed .side-nav-scroll { padding-left: 12px; padding-right: 12px; }
.app-shell.sidebar-collapsed .side-nav-item,
.app-shell.sidebar-collapsed .side-nav-group > summary,
.app-shell.sidebar-collapsed .side-collapse { justify-content: center; padding-left: 10px; padding-right: 10px; }
.app-shell.sidebar-collapsed .side-nav-item.active,
.app-shell.sidebar-collapsed .side-nav-group.active > summary { box-shadow: inset 0 -3px 0 var(--poe-green-600); }

.portal-body .topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-dot {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 22px;
    font-weight: 900;
}

.portal-body .user-box {
    min-height: 44px;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 7px 10px 7px 14px;
    border-radius: 14px;
    background: rgba(25, 78, 24, .22);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}

.user-avatar {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #fff;
    color: #0d6c7f;
    font-size: 12px;
    letter-spacing: -.02em;
}

.logout-form { margin: 0; }
.portal-body .btn-logout {
    min-height: 44px;
    padding: 0 17px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.70);
    background: rgba(255,255,255,.08);
    color: #fff;
    font-weight: 850;
}
.portal-body .btn-logout:hover { background: rgba(255,255,255,.18); }

.portal-body .page-content.app-content {
    width: 100%;
    padding: 30px 34px 18px;
    max-width: 1880px;
    margin: 0 auto;
}

.app-footer {
    padding: 14px 24px 20px;
    color: #98a4b3;
    text-align: center;
    font-size: 12px;
}

/* Estrutura comercial comum dos módulos */
.portal-body .module-header,
.portal-body .page-header-row {
    margin-bottom: 18px;
}
.portal-body .module-header h2,
.portal-body .page-header-row h1,
.portal-body .page-header-row h2,
.portal-body .table-head h2,
.portal-body .table-header h2 {
    color: var(--poe-text);
    font-weight: 850;
    letter-spacing: -.02em;
}
.portal-body .module-header p,
.portal-body .page-header-row p,
.portal-body .table-head p,
.portal-body .filters-note,
.portal-body .filters-hint,
.portal-body .muted,
.portal-body .muted-line,
.portal-body .muted-block {
    color: var(--poe-muted);
}

.portal-body .filters-card,
.portal-body .table-card,
.portal-body .summary-card,
.portal-body .chart-card,
.portal-body .form-card,
.portal-body .login-card,
.portal-body .login-brand,
.portal-body .detail-section-card,
.portal-body .receipt-result-card,
.portal-body .defect-manager-card,
.portal-body .sub-card,
.portal-body .status-email-card {
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(206, 216, 228, .88);
    border-radius: var(--poe-radius);
    box-shadow: var(--poe-shadow-sm);
}

.portal-body .filters-card {
    padding: 20px;
    margin-bottom: 20px;
}

.portal-body .table-card {
    padding: 18px;
    overflow: hidden;
}

.portal-body .table-head,
.portal-body .table-header,
.portal-body .table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--poe-line);
    margin-bottom: 12px;
}

.portal-body .summary-grid,
.portal-body .fretes-summary-grid,
.portal-body .relation-summary-grid,
.portal-body .note-summary-grid,
.portal-body .note-summary-grid-v2,
.portal-body .totem-order-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.portal-body .summary-card {
    min-height: 94px;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "icon label" "icon value";
    column-gap: 16px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.portal-body .summary-card::before {
    content: "";
    grid-area: icon;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(22,160,95,.16), rgba(22,160,95,.06));
    border: 1px solid rgba(22,160,95,.14);
}
.portal-body .summary-grid .summary-card:nth-child(2)::before { background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(59,130,246,.06)); border-color: rgba(59,130,246,.12); }
.portal-body .summary-grid .summary-card:nth-child(3)::before { background: linear-gradient(135deg, rgba(245,158,11,.22), rgba(245,158,11,.07)); border-color: rgba(245,158,11,.16); }
.portal-body .summary-grid .summary-card:nth-child(4)::before { background: linear-gradient(135deg, rgba(124,91,242,.17), rgba(124,91,242,.06)); border-color: rgba(124,91,242,.14); }

.portal-body .summary-card span {
    grid-area: label;
    color: #354862;
    font-weight: 800;
    font-size: 14px;
}
.portal-body .summary-card strong {
    grid-area: value;
    margin-top: 0;
    font-size: 24px;
    line-height: 1.05;
    color: #1d2c44;
    font-weight: 900;
}
.portal-body .summary-card small { grid-column: 1 / -1; color: var(--poe-muted); }
.portal-body .summary-ok,
.portal-body .summary-pending,
.portal-body .summary-card-ok,
.portal-body .summary-card-pending { border-left: 0; }

/* Formulários e filtros */
.portal-body .field label,
.portal-body .field-group-classic label,
.portal-body .field-group-compact label,
.portal-body .config-form-grid label,
.portal-body .status-email-card label {
    color: #2d3e56;
    font-size: 13px;
    font-weight: 830;
}

.portal-body .field input,
.portal-body .field select,
.portal-body .field textarea,
.portal-body .field-group-classic input,
.portal-body .field-group-classic select,
.portal-body .field-group-classic textarea,
.portal-body .field-group-compact input,
.portal-body .field-group-compact select,
.portal-body .field-group-compact textarea,
.portal-body .input-classic,
.portal-body .input-compact,
.portal-body .combo-button,
.portal-body .combo-input,
.portal-body .select-search-input,
.portal-body .pedido-itens-table input,
.portal-body .pedido-itens-table select {
    border: 1px solid var(--poe-line-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--poe-text);
    min-height: 42px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.portal-body .field input:focus,
.portal-body .field select:focus,
.portal-body .field textarea:focus,
.portal-body .field-group-classic input:focus,
.portal-body .field-group-classic select:focus,
.portal-body .field-group-classic textarea:focus,
.portal-body .field-group-compact input:focus,
.portal-body .field-group-compact select:focus,
.portal-body .field-group-compact textarea:focus,
.portal-body .input-classic:focus,
.portal-body .input-compact:focus,
.portal-body .combo-button:focus,
.portal-body .combo-input:focus {
    outline: 0;
    border-color: rgba(22,160,95,.64);
    box-shadow: 0 0 0 4px rgba(22,160,95,.12);
}
.portal-body .combo-panel,
.portal-body .produto-sugestoes-portal,
.portal-body .select-search-panel {
    border-radius: 14px;
    border-color: var(--poe-line-strong);
    box-shadow: 0 20px 48px rgba(20, 36, 56, .20);
}
.portal-body .combo-option:hover,
.portal-body .combo-option[aria-selected="true"] { background: #edf8f2; color: #067647; }

/* Botões */
.portal-body .btn-primary,
.portal-body .btn-primary-classic,
.portal-body .btn-secondary,
.portal-body .btn-secondary-classic,
.portal-body .btn-small,
.portal-body .btn-danger,
.portal-body .page-link,
.portal-body .btn-mark {
    border-radius: 12px;
    font-weight: 850;
    letter-spacing: -.01em;
    transition: transform .12s ease, box-shadow .18s ease, filter .18s ease, background .18s ease;
}
.portal-body .btn-primary,
.portal-body .btn-primary-classic {
    border: 1px solid rgba(3, 132, 73, .08);
    background: linear-gradient(180deg, #16a05f, #07854c);
    color: #fff;
    box-shadow: 0 9px 18px rgba(22,160,95,.18);
}
.portal-body .btn-primary:hover,
.portal-body .btn-primary-classic:hover,
.portal-body .btn-secondary:hover,
.portal-body .btn-secondary-classic:hover,
.portal-body .btn-danger:hover {
    transform: translateY(-1px);
    filter: brightness(.985);
}
.portal-body .btn-secondary,
.portal-body .btn-secondary-classic,
.portal-body .btn-small {
    border: 1px solid var(--poe-line-strong);
    background: #fff;
    color: #234766;
    box-shadow: var(--poe-shadow-sm);
}
.portal-body .btn-danger,
.portal-body .btn-mark-clear {
    border: 1px solid rgba(223,39,53,.15);
    background: linear-gradient(180deg, #ef4450, #d91e2c);
    color: #fff;
    box-shadow: 0 9px 18px rgba(223,39,53,.16);
}
.portal-body .quick-scan-form > .btn-primary,
.portal-body .scan-form .btn-primary,
.portal-body #scanForm .btn-primary {
    background: linear-gradient(180deg, #ef4450, #d91e2c);
    border-color: rgba(223,39,53,.16);
    box-shadow: 0 9px 18px rgba(223,39,53,.16);
}
.portal-body .btn-mark-authorized,
.portal-body .btn-mark-received { background: #dcfce7; color: #166534; }
.portal-body .btn-mark-canceled { background: #eef2f7; color: #374151; }
.portal-body .btn-mark-returned { background: #ffedd5; color: #c2410c; }

/* Tabelas */
.portal-body .table-responsive,
.portal-body .table-wrapper,
.portal-body .horizontal-scroll,
.portal-body .note-items-scroll,
.portal-body .table-wrapper-horizontal {
    border-radius: 14px;
}
.portal-body .data-table,
.portal-body .notes-table,
.portal-body .table-card table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
.portal-body .data-table th,
.portal-body .notes-table th,
.portal-body .table-card th {
    background: #f4f8fb;
    color: #31455f;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .01em;
    text-transform: none;
    border-top: 1px solid var(--poe-line);
    border-bottom: 1px solid var(--poe-line);
}
.portal-body .data-table th:first-child,
.portal-body .notes-table th:first-child,
.portal-body .table-card th:first-child { border-left: 1px solid var(--poe-line); border-top-left-radius: 12px; }
.portal-body .data-table th:last-child,
.portal-body .notes-table th:last-child,
.portal-body .table-card th:last-child { border-right: 1px solid var(--poe-line); border-top-right-radius: 12px; }
.portal-body .data-table td,
.portal-body .notes-table td,
.portal-body .table-card td {
    border-bottom: 1px solid #edf1f6;
    color: #263951;
}
.portal-body .data-table tbody tr,
.portal-body .notes-table tbody tr { background: #fff; }
.portal-body .data-table tbody tr:hover,
.portal-body .notes-table tbody tr:hover { background: #fbfdff; }
.portal-body .cell-chave,
.portal-body .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; color: #34455b; }

/* Badges e estados */
.portal-body .status-badge,
.portal-body .badge-status,
.portal-body .badge-neutral,
.portal-body .badge-ok,
.portal-body .badge-success,
.portal-body .badge-warning,
.portal-body .badge-danger,
.portal-body .badge-pending,
.portal-body .badge-canceled,
.portal-body .badge-returned,
.portal-body .badge-received,
.portal-body .badge-authorized {
    border-radius: 999px;
    padding: 5px 9px;
    line-height: 1;
    font-size: 12px;
    font-weight: 850;
}
.portal-body .badge-ok,
.portal-body .badge-success,
.portal-body .badge-authorized,
.portal-body .badge-received { background: #dcfae6 !important; color: #067647 !important; }
.portal-body .badge-pending,
.portal-body .badge-warning { background: #fff2cf !important; color: #9a6200 !important; }
.portal-body .badge-danger { background: #ffe4e7 !important; color: #ba1b2a !important; }
.portal-body .badge-canceled,
.portal-body .badge-neutral { background: #eef2f7 !important; color: #465568 !important; }
.portal-body .badge-returned { background: #ffedd5 !important; color: #b45309 !important; }
.portal-body .row-ok { background: #f3fcf6; }
.portal-body .row-pending { background: #fff7f7; }
.portal-body .row-canceled { background: #f5f6f8; }
.portal-body .row-returned { background: #fff8ee; }

.portal-body .legend {
    align-items: center;
    gap: 18px;
    color: #66758a;
}
.portal-body .legend-box {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.portal-body .bulk-actions-bar,
.portal-body .scanner-panel,
.portal-body .receipt-details-card,
.portal-body .relation-help-box,
.portal-body .alert-info-soft,
.portal-body .selected-product-box,
.portal-body .defect-side-card {
    border-radius: 14px;
    border: 1px solid var(--poe-line);
    background: #f8fbfd;
}
.portal-body .alert-success { background: #ecfdf3; border: 1px solid #abefc6; color: #067647; }
.portal-body .alert-error,
.portal-body .alert-danger { background: #fff1f2; border: 1px solid #fecdd3; color: #b42318; }
.portal-body .alert-info-soft { background: #fffbeb; border-color: #fde68a; color: #7c4d00; }

/* Conferência de entrega em layout operacional */
.portal-body .scanner-panel {
    padding: 18px;
    box-shadow: var(--poe-shadow-sm);
}
.portal-body .scan-form,
.portal-body .quick-scan-form,
.portal-body .scan-import-form {
    gap: 14px;
}
.portal-body .scan-input {
    font-size: 1rem;
    letter-spacing: .01em;
    font-weight: 760;
}
.portal-body .detail-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}
.portal-body .camera-overlay-card {
    border-radius: 22px;
    box-shadow: 0 26px 80px rgba(0,0,0,.34);
}
.portal-body .btn-minus-item {
    min-width: 44px;
    color: #1d4ed8;
    background: #fff;
}

/* Login com a mesma identidade visual */
.login-body {
    background:
        radial-gradient(circle at 10% 20%, rgba(17,121,165,.18), transparent 28rem),
        radial-gradient(circle at 86% 14%, rgba(154,184,46,.18), transparent 30rem),
        linear-gradient(135deg, #eef7fb, #f7faf4);
}
.login-brand,
.login-card {
    border: 1px solid rgba(206, 216, 228, .88);
    box-shadow: var(--poe-shadow-md);
}
.login-card .btn-primary { background: linear-gradient(180deg, #16a05f, #07854c); }

/* Responsividade do novo shell */
@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
    .portal-body .page-content.app-content { padding: 24px 22px 16px; }
    .portal-body .summary-grid,
    .portal-body .fretes-summary-grid,
    .portal-body .relation-summary-grid,
    .portal-body .note-summary-grid,
    .portal-body .note-summary-grid-v2,
    .portal-body .totem-order-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .side-nav {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(310px, 88vw);
        transform: translateX(-105%);
        transition: transform .22s ease;
        box-shadow: 22px 0 50px rgba(15,35,60,.22);
    }
    .app-shell.sidebar-open .side-nav { transform: translateX(0); }
    .side-nav-scroll { padding-top: 22px; }
    .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
    .app-shell.sidebar-collapsed .side-nav-item span:not(.nav-icon),
    .app-shell.sidebar-collapsed .side-nav-group > summary span:not(.nav-icon),
    .app-shell.sidebar-collapsed .side-collapse strong { display: inline; }
    .app-shell.sidebar-collapsed .side-nav-subitems { display: grid; }
    .app-shell.sidebar-collapsed .side-nav-item,
    .app-shell.sidebar-collapsed .side-nav-group > summary,
    .app-shell.sidebar-collapsed .side-collapse { justify-content: flex-start; }
    .portal-body .topbar.app-topbar { min-height: 76px; padding: 12px 16px; }
    .portal-body .topbar-actions { gap: 8px; }
    .notification-dot { display: none; }
}

@media (max-width: 700px) {
    .portal-body .page-content.app-content { padding: 16px 10px 14px; }
    .portal-body .brand-logo { width: 46px; height: 46px; }
    .portal-body .topbar h1 { font-size: 18px; }
    .portal-body .topbar p { font-size: 11px; }
    .portal-body .user-box span { max-width: 112px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .user-avatar { display: none; }
    .portal-body .summary-grid,
    .portal-body .fretes-summary-grid,
    .portal-body .relation-summary-grid,
    .portal-body .note-summary-grid,
    .portal-body .note-summary-grid-v2,
    .portal-body .totem-order-summary { grid-template-columns: 1fr; }
    .portal-body .filters-card,
    .portal-body .table-card,
    .portal-body .form-card { padding: 14px !important; border-radius: 16px; }
    .portal-body .table-head,
    .portal-body .table-header,
    .portal-body .table-toolbar { align-items: stretch; flex-direction: column; }
    .portal-body .detail-actions { align-items: stretch; flex-direction: column; }
    .portal-body .detail-actions a,
    .portal-body .detail-actions button,
    .portal-body .detail-actions form { width: 100%; }
}

@media (max-width: 440px) {
    .portal-body .brand-wrap > div { display: none; }
    .portal-body .topbar-main { gap: 8px; }
    .portal-body .btn-logout { padding: 0 12px; }
}

/* Correções finais de conflito com estilos legados em telas menores */
@media (max-width: 900px) {
    .portal-body .topbar-main,
    .portal-body .brand-wrap,
    .portal-body .topbar-actions,
    .portal-body .user-box {
        flex-direction: row !important;
        align-items: center !important;
    }
    .portal-body .topbar-main { justify-content: space-between !important; }
    .portal-body .topbar-actions { width: auto !important; }
}

@media (max-width: 640px) {
    .portal-body .topbar-main,
    .portal-body .brand-wrap,
    .portal-body .topbar-actions,
    .portal-body .user-box {
        flex-direction: row !important;
        align-items: center !important;
    }
    .portal-body .topbar-actions {
        justify-content: flex-end !important;
        gap: 6px !important;
    }
}

/* =========================================================
   Ajustes solicitados: menu estático abaixo da faixa, filtros
   com limpar individual, telas ativáveis e tons mais confortáveis.
   ========================================================= */
:root {
    --poe-bg: #eef3f7;
    --poe-surface: #fbfcfe;
    --poe-surface-soft: #f3f7fa;
    --poe-line: #d5dee9;
    --poe-line-strong: #c4d0dc;
    --poe-topbar-height: 84px;
    --poe-shadow-sm: 0 4px 16px rgba(15, 35, 60, .07);
    --poe-shadow-md: 0 14px 36px rgba(15, 35, 60, .11);
}

.portal-body {
    background:
        radial-gradient(circle at 88% 1%, rgba(154,184,46,.08), transparent 25rem),
        radial-gradient(circle at 5% 3%, rgba(17,121,165,.08), transparent 25rem),
        var(--poe-bg) !important;
}

.portal-body .app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
}

.portal-body .topbar.app-topbar {
    grid-column: 1 / -1;
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 320;
}

.portal-body .side-nav {
    grid-column: 1;
    grid-row: 2;
    position: sticky;
    top: var(--poe-topbar-height);
    height: calc(100vh - var(--poe-topbar-height));
    z-index: 250;
    align-self: start;
    background: rgba(248, 251, 253, .96);
    border-right: 1px solid var(--poe-line);
}

.portal-body .side-nav-scroll {
    padding: 18px 14px 16px !important;
}

.portal-body .app-main {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}

.portal-body .app-shell.sidebar-collapsed {
    grid-template-columns: 86px minmax(0, 1fr);
}

.portal-body .side-collapse {
    margin-bottom: 16px;
}

.portal-body .screen-disabled-admin {
    opacity: .55;
    filter: grayscale(.35);
}
.portal-body .screen-disabled-admin::after {
    content: "Off";
    margin-left: auto;
    padding: 2px 7px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
}
.portal-body .app-shell.sidebar-collapsed .screen-disabled-admin::after { display: none; }

.portal-body .filters-card,
.portal-body .table-card,
.portal-body .summary-card,
.portal-body .chart-card,
.portal-body .form-card,
.portal-body .login-card,
.portal-body .login-brand,
.portal-body .detail-section-card,
.portal-body .receipt-result-card,
.portal-body .defect-manager-card,
.portal-body .sub-card,
.portal-body .status-email-card {
    background: rgba(251, 252, 254, .97) !important;
    border-color: rgba(196, 208, 220, .95) !important;
}

.portal-body .table-card,
.portal-body .filters-card,
.portal-body .form-card {
    box-shadow: 0 8px 26px rgba(15, 35, 60, .075) !important;
}

.portal-body .data-table tbody tr,
.portal-body .notes-table tbody tr,
.portal-body .table-card table tbody tr {
    background: rgba(252, 253, 255, .98) !important;
}
.portal-body .data-table tbody tr:hover,
.portal-body .notes-table tbody tr:hover,
.portal-body .table-card table tbody tr:hover {
    background: #f4f8fb !important;
}

.portal-body .field input,
.portal-body .field select,
.portal-body .field textarea,
.portal-body .field-group-classic input,
.portal-body .field-group-classic select,
.portal-body .field-group-classic textarea,
.portal-body .field-group-compact input,
.portal-body .field-group-compact select,
.portal-body .field-group-compact textarea,
.portal-body .input-classic,
.portal-body .input-compact,
.portal-body .combo-button,
.portal-body .combo-input,
.portal-body .select-search-input,
.portal-body .pedido-itens-table input,
.portal-body .pedido-itens-table select {
    background: #f8fbfd !important;
    border-color: var(--poe-line-strong) !important;
}

/* Botão individual para limpar filtros */
.filter-clear-host {
    position: relative;
}
.filter-clear-host > input,
.filter-clear-host > select,
.filter-clear-host > .input-classic,
.filter-clear-host > .input-compact {
    padding-right: 38px !important;
}
.filter-clear-btn {
    position: absolute;
    right: 8px;
    bottom: 7px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #eef4f8;
    color: #475569;
    font-size: 18px;
    line-height: 1;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15,35,60,.08);
}
.filter-clear-btn.visible { display: inline-flex; }
.filter-clear-btn:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}
.field-button-classic.filter-clear-host,
.field-actions.filter-clear-host { position: static; }

/* Status com tonalidade mais forte e melhor leitura */
.portal-body .badge-ok,
.portal-body .badge-success,
.portal-body .badge-authorized,
.portal-body .badge-received,
.portal-body .badge-lancada,
.portal-body .badge-relacionada,
.portal-body .relation-status-confirmado .badge-status {
    background: #bbf7d0 !important;
    color: #065f46 !important;
    border: 1px solid #86efac !important;
}
.portal-body .badge-pending,
.portal-body .badge-warning,
.portal-body .badge-parcial,
.portal-body .relation-status-sugerido .badge-status {
    background: #fed7aa !important;
    color: #9a3412 !important;
    border: 1px solid #fdba74 !important;
}
.portal-body .badge-danger,
.portal-body .badge-sem-vínculos,
.portal-body .badge-sem-itens,
.portal-body .relation-status-sem-sugestão .badge-status {
    background: #fecaca !important;
    color: #991b1b !important;
    border: 1px solid #fca5a5 !important;
}
.portal-body .badge-canceled,
.portal-body .badge-neutral {
    background: #cbd5e1 !important;
    color: #1f2937 !important;
    border: 1px solid #94a3b8 !important;
}
.portal-body .badge-returned {
    background: #fdba74 !important;
    color: #7c2d12 !important;
    border: 1px solid #fb923c !important;
}
.portal-body .badge-received,
.portal-body .badge-status.recebimento-autorizado,
.portal-body .badge-status.autorizado {
    background: #bfdbfe !important;
    color: #1e3a8a !important;
    border: 1px solid #93c5fd !important;
}
.portal-body .legend-ok { background: #bbf7d0 !important; border-color: #86efac !important; }
.portal-body .legend-pending { background: #fed7aa !important; border-color: #fdba74 !important; }
.portal-body .legend-canceled { background: #cbd5e1 !important; border-color: #94a3b8 !important; }
.portal-body .legend-returned { background: #fdba74 !important; border-color: #fb923c !important; }

/* Configuração de telas do portal */
.admin-screen-toggle-card .table-head { align-items: flex-start; }
.screen-toggle-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}
.screen-toggle-card {
    min-height: 122px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 14px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--poe-line);
    border-radius: 16px;
    background: #f7fafc;
    cursor: pointer;
}
.screen-toggle-card small {
    grid-column: 1 / -1;
    color: var(--poe-muted);
    line-height: 1.35;
}
.screen-toggle-head {
    display: grid;
    gap: 6px;
}
.screen-toggle-head strong {
    color: var(--poe-text);
    font-weight: 900;
}
.screen-toggle-status {
    width: fit-content;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}
.screen-toggle-active {
    background: #f0fbf4;
    border-color: #a7f3d0;
}
.screen-toggle-active .screen-toggle-status {
    background: #bbf7d0;
    color: #065f46;
}
.screen-toggle-inactive {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.screen-toggle-inactive .screen-toggle-status {
    background: #cbd5e1;
    color: #1f2937;
}
.switch-control {
    position: relative;
    display: inline-flex;
    width: 52px;
    height: 30px;
}
.switch-control > input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.switch-control > span {
    width: 52px;
    height: 30px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .18s ease;
    box-shadow: inset 0 1px 4px rgba(15,35,60,.18);
}
.switch-control > span::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15,35,60,.22);
    transition: transform .18s ease;
}
.switch-control > input:checked + span {
    background: #16a05f;
}
.switch-control > input:checked + span::after {
    transform: translateX(22px);
}
.switch-control > input:disabled + span {
    opacity: .62;
    cursor: not-allowed;
}

@media (max-width: 1180px) {
    .portal-body .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
    .screen-toggle-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

@media (max-width: 920px) {
    .portal-body .app-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .portal-body .side-nav {
        position: fixed;
        top: var(--poe-topbar-height);
        bottom: 0;
        left: 0;
        height: calc(100vh - var(--poe-topbar-height));
        width: min(310px, 88vw);
        transform: translateX(-105%);
    }
    .portal-body .app-main { grid-column: 1; grid-row: 2; }
    .portal-body .app-shell.sidebar-open .side-nav { transform: translateX(0); }
    .portal-body .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
    .portal-body .app-shell.sidebar-collapsed .side-nav-item span:not(.nav-icon),
    .portal-body .app-shell.sidebar-collapsed .side-nav-group > summary span:not(.nav-icon),
    .portal-body .app-shell.sidebar-collapsed .side-collapse strong { display: inline; }
    .portal-body .app-shell.sidebar-collapsed .side-nav-subitems { display: grid; }
    .portal-body .app-shell.sidebar-collapsed .side-nav-item,
    .portal-body .app-shell.sidebar-collapsed .side-nav-group > summary,
    .portal-body .app-shell.sidebar-collapsed .side-collapse { justify-content: flex-start; }
}

@media (max-width: 760px) {
    :root { --poe-topbar-height: 76px; }
    .screen-toggle-grid { grid-template-columns: 1fr; }
    .filter-clear-btn { bottom: 8px; }
}
.combo-clear-host .combo-button { padding-right: 42px !important; }
.combo-clear-host .combo-clear-btn { bottom: 8px; z-index: 3; }

/* Correções pós-validação: menu, telas ativas, filtros em overlay e contraste visual */
.portal-body {
    background: #edf4f7 !important;
}
.portal-body .app-main {
    background:
        radial-gradient(circle at 0 0, rgba(15, 118, 161, .035), transparent 34rem),
        linear-gradient(180deg, #edf4f7 0%, #f2f6f8 55%, #eef4f7 100%) !important;
}
.portal-body .page-content.app-content {
    background: transparent !important;
}
.portal-body .filters-card,
.portal-body .table-card,
.portal-body .summary-card,
.portal-body .chart-card,
.portal-body .form-card,
.portal-body .detail-section-card,
.portal-body .receipt-result-card,
.portal-body .defect-manager-card,
.portal-body .sub-card,
.portal-body .status-email-card {
    background: #f8fbfd !important;
    border-color: #bfccd8 !important;
}
.portal-body .table-card table thead th,
.portal-body .data-table thead th,
.portal-body .notes-table thead th {
    background: #edf3f7 !important;
}
.portal-body .data-table tbody tr,
.portal-body .notes-table tbody tr,
.portal-body .table-card table tbody tr {
    background: #fbfdff !important;
}
.portal-body .screen-disabled-admin,
.portal-body .screen-disabled-admin::after {
    display: none !important;
}
.portal-body .side-nav-item,
.portal-body .side-nav-group > summary {
    min-height: 44px;
}
.portal-body .combo-search {
    isolation: isolate;
}
.portal-body .combo-panel.open {
    position: fixed !important;
    top: var(--combo-panel-top, 90px) !important;
    left: var(--combo-panel-left, 12px) !important;
    right: auto !important;
    width: var(--combo-panel-width, 360px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: var(--combo-panel-max-height, 420px) !important;
    z-index: 10020 !important;
    overflow: hidden !important;
}
.portal-body .combo-panel.open .combo-options {
    max-height: min(310px, calc(var(--combo-panel-max-height, 420px) - 64px)) !important;
}
.portal-body .combo-clear-host .combo-panel.open {
    padding-right: 10px !important;
}
.portal-body .filter-clear-btn {
    background: #e7eff5;
}
.portal-body .filter-clear-host:focus-within .filter-clear-btn.visible {
    display: inline-flex;
}
.portal-body .screen-toggle-card {
    background: #f6fafc;
}
.portal-body .screen-toggle-active {
    background: #edf9f2 !important;
    border-color: #86efac !important;
}
.portal-body .screen-toggle-inactive {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
}

/* Reformulação comercial + importação de defeitos com análise de notas */
.portal-body {
    --poe-card-bg: #f7fbfd;
    --poe-card-border: #c2d2dc;
    --poe-soft-panel: #eef5f8;
    --poe-ink-strong: #08223f;
}
.portal-body h2,
.portal-body .page-header-row h2 {
    letter-spacing: -.025em;
}
.portal-body .filters-card,
.portal-body .table-card,
.portal-body .form-card {
    box-shadow: 0 16px 36px rgba(15, 54, 86, .08) !important;
}
.defect-import-header p { max-width: 760px; }
.defect-import-info {
    margin: 0 0 18px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid #bbd7e2;
    background: linear-gradient(135deg, #eff9fb, #f7fbf5);
    color: #27445f;
    box-shadow: 0 10px 24px rgba(15, 54, 86, .06);
}
.defect-import-info strong {
    color: var(--poe-ink-strong);
    display: block;
    margin-bottom: 4px;
}
.defect-import-info p { margin: 0; }
.defect-import-grid {
    grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .9fr) minmax(180px, .8fr) minmax(240px, 1.3fr) minmax(260px, 1.4fr) auto;
    align-items: end;
}
.defect-observacao-field { min-width: 0; }
.defect-import-kpis {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    margin: 18px 0;
}
.defect-import-preview .table-head span { color: #64748b; }
.defect-analysis-table td { vertical-align: top; }
.note-chip {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    margin: 0 0 6px;
    border-radius: 12px;
    border: 1px solid #c7e7d3;
    background: #eefaf3;
    color: #164e31;
    min-width: 210px;
}
.note-chip small { color: #3f6d52; }
.badge-ok { background: #d7f5e3 !important; color: #09623a !important; border-color: #7bdca4 !important; }
.badge-warning { background: #fff0c2 !important; color: #8a4f00 !important; border-color: #f0c35d !important; }
.badge-danger { background: #ffe1e1 !important; color: #a41515 !important; border-color: #f2aaaa !important; }
.defect-confirm-form {
    margin-top: 16px;
    padding: 14px 16px;
    border-top: 1px solid #d5e0e8;
    background: #f2f7fa;
    border-radius: 0 0 16px 16px;
}
.split-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.text-danger { color: #b91c1c; }
.portal-body .status-badge,
.portal-body .badge-status {
    border-width: 1px;
    border-style: solid;
    font-weight: 700;
}
@media (max-width: 1180px) {
    .defect-import-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
    .defect-import-kpis { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 760px) {
    .defect-import-grid,
    .defect-import-kpis { grid-template-columns: 1fr; }
    .split-actions { align-items: stretch; }
    .split-actions .btn-primary { width: 100%; }
}
.defect-import-kpis {
    display: grid;
    gap: 16px;
}
.defect-import-kpis .stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border: 1px solid var(--poe-card-border, #c2d2dc);
    border-radius: 18px;
    background: var(--poe-card-bg, #f7fbfd);
    box-shadow: 0 16px 36px rgba(15, 54, 86, .07);
}
.defect-import-kpis .stat-card small {
    color: #64748b;
    display: block;
    font-weight: 700;
}
.defect-import-kpis .stat-card strong {
    display: block;
    font-size: 26px;
    color: #08223f;
    margin-top: 3px;
}
.defect-import-kpis .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 20px;
}
.defect-import-kpis .stat-green { background: #dff7e8; color: #08743e; }
.defect-import-kpis .stat-blue { background: #dcecff; color: #1d5fd6; }
.defect-import-kpis .stat-orange { background: #fff1ce; color: #a55a00; }
.defect-import-kpis .stat-red { background: #ffe0e0; color: #b91c1c; }

/* Ajustes da importação de defeitos por TXT com múltiplas lojas */
.defect-import-grid-v2 {
    grid-template-columns: minmax(280px, 1.35fr) minmax(190px, .7fr) minmax(180px, .7fr) minmax(260px, 1.1fr) minmax(240px, 1fr) minmax(150px, .55fr);
    align-items: end;
}
.defect-lojas-field { align-self: stretch; }
.defect-multi-select {
    min-height: 126px;
    padding: 10px 12px;
}
.defect-multi-select option {
    padding: 7px 8px;
    border-radius: 8px;
}
.note-chip-detailed {
    display: block;
    min-width: 760px;
    margin: 0 0 10px;
    background: #f5fbf8;
    border-color: #b8dfca;
}
.return-doc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 8px 14px;
}
.return-doc-grid small {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: #5f7284;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.return-doc-grid strong {
    display: block;
    font-size: 12px;
    color: #0b2642;
    word-break: break-word;
}
.defect-analysis-table td:nth-child(6) {
    min-width: 820px;
}
@media (max-width: 1400px) {
    .defect-import-grid-v2 { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
    .return-doc-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
    .defect-import-grid-v2 { grid-template-columns: 1fr; }
    .return-doc-grid { grid-template-columns: 1fr; }
}

/* Correção: filtros pesquisáveis da tela de notas não devem deslocar os demais filtros */
.portal-body .filters-card {
    overflow: visible !important;
    position: relative;
    z-index: 40;
}
.portal-body .summary-grid,
.portal-body .table-card {
    position: relative;
    z-index: 1;
}
.portal-body .combo-panel.open {
    position: fixed !important;
    z-index: 2147483000 !important;
    top: var(--combo-panel-top, 120px) !important;
    left: var(--combo-panel-left, 12px) !important;
    right: auto !important;
    width: var(--combo-panel-width, 360px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: var(--combo-panel-max-height, 380px) !important;
    overflow: hidden !important;
    background: #fbfcfe !important;
}
.portal-body .combo-panel.open .combo-options {
    max-height: min(300px, calc(var(--combo-panel-max-height, 380px) - 64px)) !important;
    overflow-y: auto !important;
}
.portal-body .combo-panel.open .combo-input {
    position: relative;
    z-index: 1;
    background: #f8fbfd !important;
}
.portal-body .field-group-classic,
.portal-body .field-group-compact {
    position: relative;
    z-index: auto;
}
.portal-body .filter-clear-btn {
    z-index: 3;
}

/* Correções finais de usabilidade: menu fixo, filtros sobrepostos, rolagem horizontal flutuante e ações sem corte */
.portal-body {
    overflow-x: hidden !important;
}
.portal-body .app-shell {
    grid-template-columns: 260px minmax(0, 1fr) !important;
}
.portal-body .side-nav {
    position: fixed !important;
    top: var(--poe-topbar-height, 84px) !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 260px !important;
    height: calc(100vh - var(--poe-topbar-height, 84px)) !important;
    z-index: 260 !important;
}
.portal-body .app-main {
    grid-column: 2 !important;
    min-width: 0 !important;
}
.portal-body .app-shell.sidebar-collapsed {
    grid-template-columns: 78px minmax(0, 1fr) !important;
}
.portal-body .app-shell.sidebar-collapsed .side-nav {
    width: 78px !important;
}
.portal-body .side-nav-scroll {
    padding: 16px 10px 12px !important;
}
.portal-body .side-nav-item,
.portal-body .side-nav-group > summary {
    min-height: 40px !important;
    margin: 3px 0 !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
}
.portal-body .side-nav-subitems {
    margin-left: 32px !important;
}
.portal-body .side-collapse {
    margin: 0 10px 12px !important;
    padding: 10px 12px !important;
}
.portal-body .page-content.app-content {
    max-width: none !important;
    padding: 22px 24px 14px !important;
}
.portal-body .filters-card {
    overflow: visible !important;
    position: relative !important;
    z-index: 80 !important;
    padding: 18px !important;
}
.portal-body .summary-grid,
.portal-body .table-card {
    position: relative !important;
    z-index: 2 !important;
}
.portal-body .combo-panel.open {
    position: fixed !important;
    z-index: 2147483647 !important;
    top: var(--combo-panel-top, 120px) !important;
    left: var(--combo-panel-left, 12px) !important;
    right: auto !important;
    width: var(--combo-panel-width, 360px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: var(--combo-panel-max-height, 380px) !important;
    overflow: hidden !important;
    background: #fbfcfe !important;
    box-shadow: 0 22px 52px rgba(15, 35, 60, .24) !important;
    pointer-events: auto !important;
}
.portal-body .combo-panel.open .combo-options {
    overflow-y: auto !important;
}
.portal-body .field-group-classic,
.portal-body .field-group-compact {
    position: relative;
    z-index: auto !important;
}
.portal-body .filters-grid-classic,
.portal-body .filters-subrow-classic,
.portal-body .filters-subgroup-classic {
    overflow: visible !important;
}
.portal-body .filters-grid-classic-v2 {
    grid-template-columns: minmax(150px, .8fr) minmax(150px, .8fr) minmax(230px, 1.2fr) minmax(220px, 1.1fr) minmax(160px, .7fr) !important;
    gap: 12px !important;
}
.portal-body .filters-subgroup-classic {
    gap: 10px !important;
}
.portal-body .field-group-compact {
    min-width: 150px !important;
}
.portal-body .field-group-search-notes {
    min-width: 230px !important;
}
.portal-body .input-classic,
.portal-body .input-compact,
.portal-body .combo-button,
.portal-body .combo-input {
    height: 40px !important;
    border-radius: 12px !important;
    font-size: 13px !important;
}
.portal-body .btn-primary-classic,
.portal-body .btn-secondary-classic {
    min-height: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
}
.portal-body .table-card {
    overflow: visible !important;
}
.portal-body .table-wrapper,
.portal-body .table-responsive,
.portal-body .horizontal-scroll,
.portal-body .table-wrapper-horizontal {
    overflow-x: auto !important;
    overflow-y: visible !important;
}
.portal-body .table-card th,
.portal-body .table-card td,
.portal-body .notes-table th,
.portal-body .notes-table td,
.portal-body .data-table th,
.portal-body .data-table td {
    padding: 9px 8px !important;
    font-size: 13px !important;
}
.portal-body .notes-table {
    min-width: 1280px !important;
}
.portal-body .cell-chave,
.portal-body td:nth-child(9),
.portal-body .notes-table td:nth-child(9) {
    max-width: 260px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
.actions-dropdown[open] {
    z-index: 2147483000 !important;
}
.actions-dropdown-panel.portal-actions-fixed {
    position: fixed !important;
    right: auto !important;
    top: var(--actions-panel-top, 80px) !important;
    left: var(--actions-panel-left, 80px) !important;
    width: var(--actions-panel-width, 210px) !important;
    min-width: var(--actions-panel-width, 210px) !important;
    max-width: calc(100vw - 24px) !important;
    z-index: 2147483646 !important;
    box-shadow: 0 24px 58px rgba(15, 35, 60, .26) !important;
}
.portal-floating-x-scroll {
    position: fixed;
    left: var(--floating-scroll-left, 260px);
    right: 0;
    bottom: 0;
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 2147482500;
    background: rgba(226, 236, 243, .96);
    border-top: 1px solid #b8c7d5;
    box-shadow: 0 -8px 18px rgba(15, 35, 60, .10);
    display: none;
}
.portal-floating-x-scroll.visible { display: block; }
.portal-floating-x-scroll > div { height: 1px; }
.portal-floating-x-scroll::-webkit-scrollbar { height: 14px; }
.portal-floating-x-scroll::-webkit-scrollbar-thumb { background: #8fa2b6; border-radius: 999px; }
@media (max-width: 1180px) {
    .portal-body .filters-grid-classic-v2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .portal-body .app-shell { grid-template-columns: 240px minmax(0, 1fr) !important; }
    .portal-body .side-nav { width: 240px !important; }
    .portal-floating-x-scroll { left: var(--floating-scroll-left, 240px); }
}
@media (max-width: 920px) {
    .portal-body .app-shell { grid-template-columns: 1fr !important; }
    .portal-body .app-main { grid-column: 1 !important; }
    .portal-body .side-nav { width: min(310px, 88vw) !important; transform: translateX(-105%); }
    .portal-body .app-shell.sidebar-open .side-nav { transform: translateX(0); }
    .portal-floating-x-scroll { left: 0 !important; }
}

/* Ajustes: chave oculta com cópia, edição rápida de quantidade e ações da conferência */
.copy-key-cell {
    text-align: center !important;
    white-space: nowrap !important;
    min-width: 112px !important;
}
.btn-copy-key.copied {
    border-color: #0f9f6e !important;
    background: #dff8eb !important;
    color: #08704e !important;
}
.row-actions-inline,
.item-actions-qty {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.row-actions-inline form,
.item-actions-qty form {
    margin: 0 !important;
}
.set-qty-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.input-qty-adjust {
    width: 92px !important;
    min-width: 92px !important;
    height: 32px !important;
    padding: 5px 8px !important;
    text-align: right !important;
}
.notes-table .row-actions-inline .btn-small,
.notes-table .item-actions-qty .btn-small {
    min-height: 30px !important;
    height: 30px !important;
    padding: 0 10px !important;
}

/* =========================================================
   Correções finais - layout 100%, filtros em portal, lojas no TXT,
   rolagem horizontal flutuante e ações sem sobreposição.
   ========================================================= */
html, body {
    overflow-x: auto !important;
}
.portal-body {
    overflow-x: auto !important;
}
.portal-body .app-main {
    overflow-x: auto !important;
    min-width: 0 !important;
}
.portal-body .app-content {
    min-width: 0 !important;
    width: 100% !important;
    padding: 18px 18px 14px !important;
}
.portal-body .topbar.app-topbar {
    min-height: auto !important;
    padding: 14px 22px !important;
}
.portal-body .brand-logo {
    width: 58px !important;
    height: 58px !important;
}
.portal-body .topbar h1 {
    font-size: 23px !important;
    line-height: 1.1 !important;
}
.portal-body .topbar p {
    font-size: 13px !important;
}
.portal-body .sidebar-toggle {
    width: 42px !important;
    height: 42px !important;
}

.portal-body .filters-grid-classic-v2 {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 10px !important;
}
.portal-body .filters-subrow-classic {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: end !important;
}
.portal-body .filters-subgroup-classic {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    gap: 10px !important;
    min-width: 0 !important;
}
.portal-body .filters-subactions-classic {
    display: flex !important;
    align-items: end !important;
    justify-content: flex-end !important;
    min-width: 160px !important;
}
.portal-body .field-group-classic,
.portal-body .field-group-compact,
.portal-body .field-group-search-notes {
    min-width: 0 !important;
    max-width: 100% !important;
}

/* O painel dos filtros pesquisáveis agora é levado para o body via JS. */
body > .combo-panel.open,
.portal-body .combo-panel-portal.open {
    position: fixed !important;
    z-index: 2147483647 !important;
    top: var(--combo-panel-top, 120px) !important;
    left: var(--combo-panel-left, 12px) !important;
    width: var(--combo-panel-width, 360px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: var(--combo-panel-max-height, 420px) !important;
    overflow: hidden !important;
    background: #fbfcfe !important;
    border: 1px solid var(--poe-line-strong) !important;
    border-radius: 14px !important;
    box-shadow: 0 24px 60px rgba(15, 35, 60, .28) !important;
    pointer-events: auto !important;
}
body > .combo-panel.open .combo-options,
.portal-body .combo-panel-portal.open .combo-options {
    max-height: min(340px, calc(var(--combo-panel-max-height, 420px) - 66px)) !important;
    overflow-y: auto !important;
}
body > .combo-panel.open .combo-input,
.portal-body .combo-panel-portal.open .combo-input {
    background: #fff !important;
}

/* Importar TXT com notas: seletor de lojas compacto, aberto somente ao clicar. */
.defect-import-card,
.defect-import-card .filters-form-classic,
.defect-import-grid-v2 {
    overflow: visible !important;
}
.defect-import-grid-v2 {
    display: grid !important;
    grid-template-columns: minmax(260px, 1.4fr) minmax(150px, .8fr) minmax(150px, .8fr) minmax(230px, 1.2fr) minmax(210px, 1fr) auto !important;
    gap: 12px !important;
    align-items: end !important;
}
.defect-lojas-field {
    min-width: 260px !important;
    position: relative;
}
.defect-store-dropdown {
    position: relative;
    width: 100%;
}
.defect-store-button {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    background: #f8fbfd;
}
.defect-store-button #defectStoreButtonText {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.defect-store-panel {
    display: none;
    position: absolute;
    z-index: 2147483640;
    top: calc(100% + 8px);
    left: 0;
    width: min(560px, calc(100vw - 32px));
    max-height: min(420px, calc(100vh - 180px));
    overflow: hidden;
    background: #fbfcfe;
    border: 1px solid var(--poe-line-strong);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 35, 60, .26);
    padding: 10px;
}
.defect-store-dropdown.open .defect-store-panel {
    display: block;
}
.defect-store-search {
    width: 100%;
    margin-bottom: 8px;
    background: #fff;
}
.defect-store-all,
.defect-store-option {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    cursor: pointer;
    color: #20324a;
}
.defect-store-all {
    font-weight: 850;
    padding: 8px 8px 10px;
    border-bottom: 1px solid #dce6ee;
    margin-bottom: 8px;
}
.defect-store-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 6px 10px;
    max-height: 270px;
    overflow: auto;
    padding: 2px 4px 2px 0;
}
.defect-store-option {
    padding: 7px 8px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e4ebf2;
    font-size: 13px;
}
.defect-store-option:hover {
    border-color: #9bd1b4;
    background: #effaf4;
}
.defect-store-option input,
.defect-store-all input {
    margin-top: 2px;
}
@media (max-width: 1400px) {
    .defect-import-grid-v2 {
        grid-template-columns: repeat(3, minmax(180px, 1fr)) !important;
    }
}
@media (max-width: 920px) {
    .defect-import-grid-v2 {
        grid-template-columns: 1fr !important;
    }
    .defect-store-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: 120px;
        width: auto;
    }
}

/* Menus de ações em camada independente, sem corte no rodapé/tabela. */
body > .actions-dropdown-panel.portal-actions-fixed {
    position: fixed !important;
    display: grid !important;
    right: auto !important;
    top: var(--actions-panel-top, 80px) !important;
    left: var(--actions-panel-left, 80px) !important;
    width: var(--actions-panel-width, 220px) !important;
    min-width: var(--actions-panel-width, 220px) !important;
    max-width: calc(100vw - 24px) !important;
    z-index: 2147483646 !important;
    background: #fff !important;
    box-shadow: 0 24px 58px rgba(15, 35, 60, .30) !important;
}
body > .actions-dropdown-panel.portal-actions-fixed[hidden] {
    display: none !important;
}

/* Rolagem horizontal fixa: aparece também quando o conteúdo inteiro estoura a tela. */
.portal-floating-x-scroll.visible {
    display: block !important;
}
.portal-floating-x-scroll {
    height: 20px !important;
    z-index: 2147483600 !important;
}
.portal-floating-x-scroll::-webkit-scrollbar {
    height: 16px !important;
}
.portal-floating-x-scroll::-webkit-scrollbar-thumb {
    background: #7890a7 !important;
}
.portal-body .table-wrapper,
.portal-body .table-responsive,
.portal-body .horizontal-scroll,
.portal-body .table-wrapper-horizontal {
    overflow-x: auto !important;
    overflow-y: visible !important;
}

@media (max-width: 920px) {
    .portal-body .app-content {
        padding: 14px 10px !important;
    }
    .portal-body .filters-subrow-classic {
        grid-template-columns: 1fr !important;
    }
    .portal-body .filters-subactions-classic {
        justify-content: stretch !important;
    }
    .portal-body .filters-subactions-classic > * {
        width: 100% !important;
    }
}


/* Correção: manter o botão Ações visível na tela de notas fiscais.
   A chave continua substituída pelo botão Copiar chave, mas o menu de opções da nota não pode desaparecer. */
.portal-body .notes-table th.actions-col,
.portal-body .notes-table td.actions-col {
    position: sticky !important;
    right: 0 !important;
    z-index: 8 !important;
    min-width: 124px !important;
    width: 124px !important;
    text-align: center !important;
    background: #f8fbfd !important;
    box-shadow: -10px 0 18px rgba(15, 35, 60, .08) !important;
}
.portal-body .notes-table thead th.actions-col {
    z-index: 12 !important;
    background: #eaf2f8 !important;
}
.portal-body .notes-table tbody tr:hover td.actions-col {
    background: #f4f9fc !important;
}
.portal-body .notes-table td.actions-col .actions-dropdown {
    display: inline-block !important;
}
.portal-body .notes-table td.actions-col .actions-dropdown > summary {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 82px !important;
    white-space: nowrap !important;
}
.portal-body .notes-table td.actions-col .actions-dropdown > summary::after {
    content: "▾";
    font-size: 11px;
    margin-left: 6px;
    opacity: .75;
}
@media (max-width: 920px) {
    .portal-body .notes-table th.actions-col,
    .portal-body .notes-table td.actions-col {
        min-width: 110px !important;
        width: 110px !important;
    }
}

/* =========================================================
   Ajuste solicitado: faixa colorida fixa + preview de TXT por item
   ========================================================= */
:root {
    --poe-topbar-height: 86px;
}

.portal-body .topbar.app-topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-height: var(--poe-topbar-height) !important;
    z-index: 2147483000 !important;
}

.portal-body .app-shell {
    padding-top: var(--poe-topbar-height) !important;
}

.portal-body .side-nav {
    position: fixed !important;
    top: var(--poe-topbar-height) !important;
    left: 0 !important;
    height: calc(100vh - var(--poe-topbar-height)) !important;
    width: 290px !important;
    z-index: 2147482000 !important;
}

.portal-body .app-shell.sidebar-collapsed .side-nav {
    width: 86px !important;
}

.portal-body .app-main {
    min-width: 0 !important;
}

.defect-found-stores {
    margin: 0 0 14px;
}
.defect-found-stores p {
    margin: 6px 0 0;
}
.defect-analysis-items-only th:last-child,
.defect-analysis-items-only td:last-child {
    width: 140px;
    text-align: right;
    white-space: nowrap;
}
.defect-notes-template[hidden] {
    display: none !important;
}
.defect-notes-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2147483200;
}
.defect-notes-modal.open {
    display: block;
}
.defect-notes-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 22, 36, .52);
    backdrop-filter: blur(3px);
}
.defect-notes-modal-box {
    position: absolute;
    top: calc(var(--poe-topbar-height) + 26px);
    left: 50%;
    transform: translateX(-50%);
    width: min(1120px, calc(100vw - 48px));
    max-height: calc(100vh - var(--poe-topbar-height) - 52px);
    overflow: auto;
    border-radius: 20px;
    background: #f8fbfd;
    border: 1px solid rgba(148, 163, 184, .34);
    box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
    padding: 22px;
}
.defect-notes-modal-close {
    position: sticky;
    top: 0;
    float: right;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}
.defect-notes-modal-header h3 {
    margin: 0 0 6px;
    font-size: 20px;
    color: #0f253a;
}
.defect-notes-modal-header p {
    margin: 0 0 16px;
    color: #475569;
}
.defect-notes-modal-list {
    display: grid;
    gap: 12px;
}
.defect-note-card {
    margin: 0 !important;
    background: #ffffff !important;
    border: 1px solid rgba(148, 163, 184, .25) !important;
    box-shadow: 0 8px 24px rgba(15, 35, 60, .06);
}
.text-break {
    word-break: break-word;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    :root { --poe-topbar-height: 78px; }
    .portal-body .app-shell { grid-template-columns: 1fr !important; }
    .portal-body .side-nav {
        transform: translateX(-105%);
        transition: transform .18s ease;
    }
    .portal-body .app-shell.sidebar-open .side-nav {
        transform: translateX(0);
    }
    .defect-notes-modal-box {
        width: calc(100vw - 20px);
        top: calc(var(--poe-topbar-height) + 10px);
        max-height: calc(100vh - var(--poe-topbar-height) - 20px);
        padding: 16px;
    }
}
.stat-purple {
    background: #ede9fe !important;
    color: #6d28d9 !important;
}

/* Módulo de Inventários */
.inventory-upload-card { margin-bottom: 18px; }
.inventory-section-title { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:16px; }
.inventory-section-title h2 { margin:0 0 5px; }
.inventory-section-title p { margin:0; color:#667788; }
.inventory-upload-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; align-items:end; }
.inventory-upload-grid label { display:flex; flex-direction:column; gap:6px; }
.inventory-upload-grid input,
.inventory-upload-grid select { min-height:40px; }
.inventory-final-checkbox { min-height:40px; align-self:end; }
.inventory-upload-action { align-self:end; }
.inventory-actions { display:flex; gap:6px; flex-wrap:wrap; min-width:190px; }
.inventory-ok { color:#167044; font-weight:700; }
.inventory-error { color:#b42318; font-weight:700; }
.inventory-row-ok td { background:rgba(22,163,74,.045); }
.inventory-row-error td { background:rgba(220,38,38,.075); }
.inventory-row-error td:first-child { border-left:4px solid #b91c1c; }
.inventory-summary-grid { margin-bottom:18px; }
.inventory-summary-grid small { display:block; margin-top:4px; color:#64748b; }
.inventory-detail-table { overflow:auto; max-height:68vh; }
.inventory-detail-table thead th { position:sticky; top:0; z-index:2; }
.alert-warning { background:#fff4d6; color:#7a5200; border:1px solid #f2d28b; border-radius:8px; padding:12px; margin:12px 0; }
@media(max-width:1100px){.inventory-upload-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:700px){.inventory-section-title{flex-direction:column}.inventory-upload-grid{grid-template-columns:1fr}.inventory-actions{min-width:0}}


/* Inventários e transferências — layout padronizado v1.1.1 */
.inventory-page-header { margin-bottom: 18px; }
.inventory-page-header p { max-width: 850px; }
.inventory-filters-card { margin-bottom: 16px; }
.filters-card-title { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:14px; }
.filters-card-title h2 { margin:0 0 4px; font-size:20px; }
.filters-card-title p { margin:0; color:var(--muted); }
.inventory-filter-grid {
    display:grid;
    grid-template-columns:minmax(250px,1.45fr) minmax(210px,1.1fr) minmax(180px,.9fr) 145px 145px 90px auto;
    gap:12px;
    align-items:end;
}
.inventory-filter-grid .field input,
.inventory-filter-grid .field select { width:100%; }
.inventory-filter-actions { display:flex; gap:8px; align-items:end; }
.inventory-filter-actions .btn-primary,
.inventory-filter-actions .btn-secondary { min-height:42px; white-space:nowrap; }

.inventory-manual-upload { padding:0; overflow:visible; margin-bottom:18px; }
.inventory-manual-upload > summary {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    padding:16px 20px;
    cursor:pointer;
    list-style:none;
}
.inventory-manual-upload > summary::-webkit-details-marker { display:none; }
.inventory-manual-upload > summary strong,
.inventory-manual-upload > summary span { display:block; }
.inventory-manual-upload > summary strong { font-size:18px; }
.inventory-manual-upload > summary span { margin-top:4px; color:var(--muted); font-size:13px; }
.inventory-manual-upload .inventory-expand-label {
    margin:0;
    color:var(--brand-blue);
    font-weight:800;
    white-space:nowrap;
}
.inventory-manual-upload[open] .inventory-expand-label { font-size:0; }
.inventory-manual-upload[open] .inventory-expand-label::after { content:"Fechar formulário"; font-size:13px; }
.inventory-upload-grid-v2 { padding:0 20px 20px; grid-template-columns:repeat(5,minmax(0,1fr)); }
.inventory-upload-grid-v2 label { font-weight:700; font-size:13px; }
.inventory-upload-grid-v2 input,
.inventory-upload-grid-v2 select { width:100%; border:1px solid var(--border); border-radius:12px; padding:10px 12px; background:#fff; }
.inventory-list-card { padding:16px; }
.inventory-table-wrap { max-height:68vh; }
.inventory-table { min-width:1450px !important; }
.inventory-table td { vertical-align:middle; }
.inventory-actions { min-width:210px; }
.inventory-summary-grid-v2 { grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); }
.inventory-detail-table { max-height:none; }

@media (max-width:1450px) {
    .inventory-filter-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
    .inventory-filter-actions { grid-column:span 4; justify-content:flex-end; }
    .inventory-upload-grid-v2 { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:900px) {
    .inventory-filter-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .inventory-filter-actions { grid-column:span 2; }
    .inventory-upload-grid-v2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:650px) {
    .inventory-filter-grid,
    .inventory-upload-grid-v2 { grid-template-columns:1fr; }
    .inventory-filter-actions { grid-column:span 1; flex-direction:column; }
    .inventory-filter-actions .btn-primary,
    .inventory-filter-actions .btn-secondary { width:100%; }
    .inventory-manual-upload > summary { align-items:flex-start; flex-direction:column; }
}
