/**
 * Componentes e layout da aplicação.
 * Fundações (cores, espaçamento 8px, tipografia, sombras): design-tokens.css
 */

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--ds-bg-app); }

body.app {
    min-height: 100vh;
    background: var(--ds-bg-app-gradient);
}

/* layout: menu fixo flutuante + área principal com recuo */
.app {
    display: block;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 200;
    left: var(--sidebar-float);
    top: var(--sidebar-float);
    bottom: var(--sidebar-float);
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, #0f1620 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: 16px;
    border: 1px solid var(--sidebar-border);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.2),
        0 12px 32px rgba(0, 0, 0, 0.28),
        0 40px 80px rgba(15, 23, 42, 0.35);
    overflow: hidden;
}

.sidebar-header {
    padding: 1.05rem 1.15rem 0.9rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #fff;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    flex-shrink: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.65rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.nav-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5c6d82;
    padding: 0 0.65rem 0.5rem;
    margin-bottom: 0.15rem;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.52rem 0.85rem 0.52rem 0.95rem;
    color: #c5d0de;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 9px;
    flex-shrink: 0;
    transition: background 0.14s ease, color 0.14s ease;
}

.nav-ico {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    min-width: 1.2em;
    line-height: 0;
}

.nav-ico--svg svg {
    width: 1.12em;
    height: 1.12em;
    display: block;
    color: inherit;
}

.nav-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    border-radius: 0 2px 2px 0;
    background: var(--accent);
    opacity: 0;
    transition: height 0.16s ease, opacity 0.16s ease;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item:hover::before {
    height: 40%;
    opacity: 0.7;
}

.nav-item--active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.nav-item--active::before {
    height: 65%;
    opacity: 1;
}

.nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-item.subtle { opacity: 0.8; font-size: 0.8rem; }

/* Submenu: abre ao clicar em “Contas a pagar” (<details>) */
.nav-details {
    border-radius: 9px;
}

.nav-details__summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    list-style: none;
    padding: 0.52rem 1.85rem 0.52rem 0.95rem;
    color: #c5d0de;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 9px;
    cursor: pointer;
    user-select: none;
    transition: background 0.14s ease, color 0.14s ease;
}

.nav-details__summary::-webkit-details-marker {
    display: none;
}

.nav-details__summary::after {
    content: "";
    position: absolute;
    right: 0.75rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.22rem;
    border-right: 2px solid #7c8fa3;
    border-bottom: 2px solid #7c8fa3;
    transform: rotate(45deg);
    transition: transform 0.18s ease, border-color 0.14s ease;
}

.nav-details[open] .nav-details__summary::after {
    transform: rotate(-135deg);
    margin-top: -0.05rem;
    border-color: #a8b8cc;
}

.nav-details__summary:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-details[open] .nav-details__summary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
}

.nav-details:has(.nav-item--active) .nav-details__summary {
    color: #e8eef4;
    font-weight: 600;
}

.nav-details__summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 9px;
}

.nav-details__panel {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.35rem 0 0.45rem;
    margin: 0.15rem 0 0.2rem;
    border-left: 2px solid var(--ds-color-primary-border);
    margin-left: 0.85rem;
    padding-left: 0.5rem;
}

.nav-details__panel .nav-item--sub {
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.42rem 0.65rem 0.42rem 0.7rem;
    color: #a8b8cc;
}

.nav-details__panel .nav-ico {
    width: 1.1em;
    min-width: 1.1em;
    opacity: 0.92;
}

.nav-details__panel .nav-ico--svg svg {
    width: 1.02em;
    height: 1.02em;
}

.nav-details__panel .nav-item--sub:hover {
    color: #fff;
}

.nav-details__panel .nav-item--sub::before {
    left: -0.5rem;
}

.sidebar-foot {
    margin-top: auto;
    flex-shrink: 0;
    padding: 1rem 0.85rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-user {
    margin-bottom: 0.85rem;
    min-width: 0;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
    word-wrap: break-word;
}

.sidebar-user-role {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--sidebar-muted);
    line-height: 1.2;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    color: #fecaca;
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.28);
    border-radius: 9px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-logout:hover {
    color: #fff;
    background: rgba(220, 38, 38, 0.35);
    border-color: rgba(252, 165, 165, 0.45);
}

.sidebar-logout:active {
    transform: translateY(1px);
}

.sidebar-logout:focus-visible {
    outline: 2px solid #fca5a5;
    outline-offset: 2px;
}

.main {
    background: transparent;
    margin-left: calc(var(--sidebar-w) + var(--sidebar-float) * 2 + var(--sidebar-gap));
    min-height: 100vh;
    padding: var(--ds-space-4) var(--ds-page-padding-x) var(--ds-space-6);
    overflow: auto;
}

.page-head { margin-bottom: var(--ds-space-3); }
.page-head.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: clamp(var(--ds-space-2), 2vw, var(--ds-space-4));
    column-gap: var(--ds-space-3);
}
@media (max-width: 640px) {
    .page-head.row {
        grid-template-columns: 1fr;
    }
    .page-head.row .actions {
        justify-self: stretch;
        width: 100%;
    }
}
.page-head h1 {
    margin: 0 0 var(--ds-space-1);
    font-size: var(--ds-font-size-h1);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: var(--ds-tracking-page-title);
    line-height: var(--ds-line-height-h1);
    color: var(--ds-text-ink);
}
.muted { color: var(--muted); font-size: var(--ds-font-size-small); line-height: var(--ds-line-height-small); }

/* .cards, .card, .table*, .parties-table-toolbar* (controles): ui-components.css */

.section-title {
    font-size: var(--ds-font-size-h3);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: var(--ds-letter-spacing-tight);
    line-height: var(--ds-line-height-h3);
    color: var(--ds-text-primary);
    margin: var(--ds-space-3) 0 var(--ds-space-2);
}

/* Título de subsecção (ex.: <h2 class="h3">) */
h2.h3,
.h3 {
    font-size: var(--ds-font-size-h3);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: var(--ds-letter-spacing-tight);
    line-height: var(--ds-line-height-h3);
    color: var(--ds-text-primary);
}

/* Cadastros PF/PJ — layout da toolbar (campos: ui-components.css) */
.parties-table-toolbar__form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}
.parties-table-toolbar__field--grow {
    flex: 1;
    min-width: 12rem;
}
.parties-table-toolbar__field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 10rem;
}
.parties-table-toolbar__field-label {
    font-size: var(--ds-font-size-caption);
    font-weight: var(--ds-font-weight-semibold);
    color: var(--ds-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.parties-table-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.table th.payables-cb-col,
.table td.payables-cb-cell {
    text-align: center;
    vertical-align: middle;
    width: 3.65rem;
    min-width: 3.65rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.payables-bulk-bar .btn.small {
    white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Contas a pagar — sem scroll horizontal: table-layout fixed + quebra de texto
   + colunas secundárias ocultas em ecrãs mais estreitos (dados ainda na API/detalhe)
   ------------------------------------------------------------------------- */

.table-wrap.payables-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* Evita o thead sticky “colado” ao topo do card (borda/sombra cortadas por overflow) */
    padding-top: 0.125rem;
    box-sizing: border-box;
}

.table-wrap.payables-table-wrap .payables-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.table-wrap.payables-table-wrap .payables-table > thead > tr > th,
.table-wrap.payables-table-wrap .payables-table > tbody > tr > td {
    min-width: 0;
    vertical-align: top;
    padding: 0.45rem 0.45rem;
    box-sizing: border-box;
}

.table-wrap.payables-table-wrap .payables-table thead th {
    white-space: normal;
    line-height: 1.25;
    hyphens: auto;
}

.table-wrap.payables-table-wrap .payables-col-desc,
.table-wrap.payables-table-wrap .payables-col-supplier,
.table-wrap.payables-table-wrap .payables-col-party,
.table-wrap.payables-table-wrap .payables-col-branch,
.table-wrap.payables-table-wrap .payables-col-sector,
.table-wrap.payables-table-wrap .payables-col-ek {
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.table-wrap.payables-table-wrap .payables-col-party .muted.small {
    display: block;
    margin-top: 0.2rem;
    line-height: 1.25;
    word-break: break-word;
}

.table-wrap.payables-table-wrap .payables-col-valor {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    width: 6.25rem;
}

.table-wrap.payables-table-wrap .payables-col-nf {
    width: 2.75rem;
    text-align: center;
}

.table-wrap.payables-table-wrap .payables-col-due,
.table-wrap.payables-table-wrap .payables-col-paid {
    white-space: nowrap;
    width: 5.5rem;
    font-variant-numeric: tabular-nums;
    font-size: var(--ds-font-size-caption);
}

.table-wrap.payables-table-wrap .payables-col-status,
.table-wrap.payables-table-wrap .payables-th-status {
    width: 4.75rem;
    text-align: center;
}

.table-wrap.payables-table-wrap .payables-td-status {
    vertical-align: middle;
}

.table-wrap.payables-table-wrap .payables-td-status .badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    box-sizing: border-box;
}

.table-wrap.payables-table-wrap .payables-th-actions,
.table-wrap.payables-table-wrap .payables-col-actions {
    width: 7rem;
    min-width: 0;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.table-wrap.payables-table-wrap .payables-td-actions {
    min-width: 0;
    width: 7rem;
    white-space: normal;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.table-wrap.payables-table-wrap .payables-td-actions-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.35rem;
}

.table-wrap.payables-table-wrap .payables-td-actions-inner > a {
    flex-shrink: 0;
    align-self: stretch;
    text-align: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.table-wrap.payables-table-wrap .payables-td-actions__pay {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    margin: 0;
}

.table-wrap.payables-table-wrap .payables-td-actions__pay .mini {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.table-wrap.payables-table-wrap .payables-td-actions__pay .btn.small {
    width: 100%;
    justify-content: center;
}

/* Largura ≥ toggle global (2.75rem) + padding; evita sobreposição na coluna Descrição.
   Selector com thead/tr vence o bloco genérico que força vertical-align: top em todos os th/td. */
.table-wrap.payables-table-wrap .payables-table > thead > tr > th.payables-cb-col,
.table-wrap.payables-table-wrap .payables-table > tbody > tr > td.payables-cb-cell {
    width: 3.65rem;
    min-width: 3.65rem;
    max-width: 3.65rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    vertical-align: middle;
    overflow: visible;
}

@media (max-width: 1400px) {
    .table-wrap.payables-table-wrap .payables-col-sector,
    .table-wrap.payables-table-wrap .payables-col-ek {
        display: none;
    }
}

@media (max-width: 1280px) {
    .table-wrap.payables-table-wrap .payables-col-branch {
        display: none;
    }
}

@media (max-width: 1024px) {
    .table-wrap.payables-table-wrap .payables-col-paid {
        display: none;
    }
}

@media (max-width: 768px) {
    .table-wrap.payables-table-wrap .payables-col-supplier {
        display: none;
    }
}

/* .badge, .btn: ui-components.css */

.form-grid {
    display: grid;
    gap: 1rem;
    width: min(100%, clamp(18rem, 92vw, 32.5rem));
    justify-items: stretch;
}
.form-grid.narrow {
    width: min(100%, clamp(17rem, 88vw, 30rem));
}
.form-grid.form-wide {
    width: min(100%, clamp(20rem, 94vw, 45rem));
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
}
/* Cadastro em 2 colunas: quando um rótulo é mais alto (ex.: *), alinha a base dos campos */
.form-grid .grid-2 {
    align-items: end;
}

.panel-inline {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0;
}
.panel-inline legend { padding: 0 0.35rem; font-weight: 600; }
.inline-radio { margin-right: 1.25rem; font-weight: normal; }
.inline-radio input { margin-right: 0.35rem; }

/* Cadastro PF/PJ: .form-grid label usa column — força linha rádio + texto alinhados */
.form-grid fieldset.panel-inline {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding-top: 0.75rem;
}
.form-grid fieldset.panel-inline label.inline-radio {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    margin-right: 0;
    font-weight: normal;
    cursor: pointer;
}
.form-grid fieldset.panel-inline label.inline-radio input {
    margin: 0;
    flex-shrink: 0;
}

.form-section {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

.small { font-size: var(--ds-font-size-small); line-height: var(--ds-line-height-small); }
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    font-weight: 500;
}
/* Indicador discreto de obrigatoriedade ao lado do rótulo */
abbr.field-req {
    font-weight: 600;
    color: #dc2626;
    font-size: 1.08em;
    margin-left: 0.15em;
    vertical-align: 0.1em;
    text-decoration: none;
    border: none;
    cursor: help;
}
.form-grid label > .label-caption {
    display: block;
}
/* .form-grid input/textarea/select: ui-components.css */

/* Interruptores (toggle) em todos os checkboxes da plataforma */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    box-sizing: border-box;
    width: 2.75rem;
    height: 1.5rem;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    vertical-align: middle;
    border: none;
    border-radius: 999px;
    background: #d4dce6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

input[type="checkbox"]::before {
    content: "";
    position: absolute;
    width: 1.18rem;
    height: 1.18rem;
    border-radius: 50%;
    background: #fff;
    top: 50%;
    left: 0.16rem;
    transform: translateY(-50%);
    transition: left 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

input[type="checkbox"]:hover:not(:disabled) {
    background: #c6ced9;
}

input[type="checkbox"]:checked {
    background: #4ade80;
    box-shadow:
        inset 0 0 0 1px rgba(21, 128, 61, 0.35),
        inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

input[type="checkbox"]:checked:hover:not(:disabled) {
    background: #22c55e;
}

input[type="checkbox"]:checked::before {
    left: calc(100% - 1.18rem - 0.16rem);
}

input[type="checkbox"]:indeterminate {
    background: #94a3b8;
}

input[type="checkbox"]:indeterminate::before {
    left: 50%;
    transform: translate(-50%, -50%);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

input[type="checkbox"]:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
    input[type="checkbox"],
    input[type="checkbox"]::before {
        transition: none;
    }
}

label.checkbox-row,
.form-grid label.checkbox-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.65rem;
    cursor: pointer;
    font-weight: 500;
}

label.checkbox-row input[type="checkbox"],
.form-grid label.checkbox-row input[type="checkbox"] {
    margin-top: 0.12rem;
}

.actions { display: flex; gap: var(--ds-space-2); align-items: center; flex-wrap: wrap; margin-top: var(--ds-space-1); }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-height: 720px) and (min-width: 901px) {
    .nav-item {
        padding: 0.38rem 0.75rem;
        font-size: 0.84rem;
    }
    .sidebar-header {
        padding-top: 0.85rem;
        padding-bottom: 0.65rem;
    }
    .brand {
        font-size: 0.98rem;
    }
    .sidebar-foot {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    .sidebar-user-name {
        font-size: 0.88rem;
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: sticky;
        z-index: 200;
        left: 0;
        right: 0;
        top: 0;
        bottom: auto;
        width: 100%;
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        border-radius: 0 0 16px 16px;
        padding: 0;
        margin: 0 0 0.65rem;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    }
    .sidebar-header {
        border-bottom: none;
        border-right: 1px solid var(--sidebar-border);
        padding: 0.65rem 0.75rem;
    }
    .brand-block {
        padding-top: 0;
    }
    .brand {
        font-size: 0.92rem;
    }
    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        flex: 1 1 auto;
        min-width: 0;
        gap: 3px;
        padding: 0.5rem 0.45rem;
        justify-content: flex-start;
        align-content: center;
        align-items: center;
    }
    .nav-label {
        display: none;
    }
    .nav-details {
        flex: 1 1 100%;
        width: 100%;
    }
    .nav-details__summary {
        padding: 0.38rem 1.5rem 0.38rem 0.55rem;
        font-size: 0.78rem;
    }
    .nav-details__summary::after {
        right: 0.5rem;
        width: 0.32rem;
        height: 0.32rem;
    }
    .nav-details__panel {
        margin-left: 0;
        padding-left: 0.35rem;
        border-left-width: 2px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 3px;
    }
    .nav-details__panel .nav-item--sub {
        font-size: 0.72rem;
        padding: 0.32rem 0.5rem;
        white-space: nowrap;
    }
    .nav-item {
        padding: 0.38rem 0.55rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }
    .nav-item::before {
        display: none;
    }
    .sidebar-foot {
        border-top: none;
        border-left: 1px solid var(--sidebar-border);
        margin-top: 0;
        padding: 0.5rem 0.65rem;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 0.45rem;
        min-width: 0;
        background: rgba(0, 0, 0, 0.25);
    }
    .sidebar-user {
        margin-bottom: 0;
    }
    .sidebar-user-name {
        font-size: 0.78rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-width: 9rem;
    }
    .sidebar-user-role {
        font-size: 0.65rem;
        max-width: 9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-logout {
        padding: 0.4rem 0.5rem;
        font-size: 0.76rem;
    }
    .main {
        margin-left: 0;
        padding-top: 0;
    }
    .detail-grid { grid-template-columns: 1fr; }
}

/* .panel base + .panel h2/h3: ui-components.css */

/* Configuração → Versão do sistema */
.sistema-versao-lead {
    margin: 0;
    max-width: 28rem;
}

.sistema-versao-card {
    max-width: 20rem;
    padding: 1.1rem 1.2rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.sistema-versao-label {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted, #64748b);
}

.sistema-versao-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
}

.sistema-versao-main {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: #0f172a;
}

.sistema-versao-pill {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* .filter-panel, .panel.filter-panel--invoices: ui-components.css */
.panel.invoice-zip-toolbar {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.filter-panel-title {
    font-size: var(--ds-font-size-h3);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: var(--ds-letter-spacing-tight);
    margin: 0 0 var(--ds-space-2);
    color: var(--ds-text-primary);
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(9.5rem, 28vw, 14rem)), 1fr));
    gap: var(--ds-space-2) var(--ds-space-3);
    margin-bottom: var(--ds-space-2);
}
.filter-grid label { display: flex; flex-direction: column; gap: var(--ds-space-1); font-size: var(--ds-font-size-small); }
.filter-label { color: var(--muted); font-weight: var(--ds-font-weight-medium); }
/* .filter-grid input/select: ui-components.css */
.filter-actions { display: flex; gap: var(--ds-space-2); flex-wrap: wrap; align-items: center; }

.kv {
    display: grid;
    grid-template-columns: minmax(min(100%, 7.5rem), min(11rem, 38%)) minmax(0, 1fr);
    gap: 0.35rem clamp(0.75rem, 2vw, 1.25rem);
    margin: 0;
}
@media (max-width: 480px) {
    .kv {
        grid-template-columns: 1fr;
    }
}
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; }
.obs { margin-top: 1rem; font-size: 0.92rem; }

.inline-forms { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.upload-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 1rem; }

.attach-list { list-style: none; padding: 0; margin: 0; }
.attach-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; }
.attach-list a { color: var(--accent); text-decoration: none; }
.attach-list a:hover { text-decoration: underline; }

/* ——— Login (split layout · UX/UI) ——— */
.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    font-family: var(--font);
    color: #0f172a;
    position: relative;
    background: #f1f5f9;
}

.login-skip {
    position: absolute;
    left: -9999px;
    top: 0.75rem;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: #fff;
    color: #1e40af;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}
.login-skip:focus {
    left: 0.75rem;
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.login-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse 90% 70% at 0% 0%, rgba(37, 99, 235, 0.18), transparent 55%),
        radial-gradient(ellipse 70% 60% at 100% 100%, rgba(99, 102, 241, 0.12), transparent 50%),
        linear-gradient(180deg, #e8eef5 0%, #f1f5f9 40%, #e2e8f0 100%);
    pointer-events: none;
}

.login-shell {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    width: min(100%, clamp(20rem, 94vw, 70rem));
    margin-inline: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06), 0 25px 80px rgba(15, 23, 42, 0.12);
}

.login-aside {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 5vw, 3.5rem);
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 42%, #172554 100%);
    color: #e2e8f0;
    overflow: hidden;
}

.login-aside__noise {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    pointer-events: none;
}

.login-aside__content {
    position: relative;
    width: min(100%, clamp(17rem, 85%, 22rem));
}

.login-aside__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 1.5rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #93c5fd;
    backdrop-filter: blur(8px);
}

.login-aside__mark-svg {
    width: 26px;
    height: 26px;
}

.login-aside__eyebrow {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
}

.login-aside__title {
    margin: 0 0 1rem;
    font-size: clamp(1.5rem, 2.5vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: #fff;
}

.login-aside__lead {
    margin: 0 0 1.75rem;
    font-size: 1rem;
    line-height: 1.6;
    color: #cbd5e1;
    font-weight: 400;
}

.login-aside__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.login-aside__list li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #e2e8f0;
}

.login-aside__check {
    flex-shrink: 0;
    margin-top: 0.12rem;
    color: #4ade80;
    display: flex;
}

.login-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    background: #fff;
    position: relative;
}

.login-mobile-brand {
    display: none;
    align-items: center;
    gap: 0.65rem;
    width: min(100%, clamp(17rem, 90vw, 28rem));
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.login-mobile-brand__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.login-mobile-brand__name {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.login-card {
    width: min(100%, clamp(17rem, 88vw, 28rem));
    background: #fff;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.login-card__head {
    margin-bottom: 1.5rem;
}

.login-card__title {
    margin: 0 0 0.4rem;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.login-card__sub {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #64748b;
}

.login-card__body {
    margin-bottom: 0;
}

.login-card__foot {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}

.login-alert {
    margin: 0 0 1.25rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
}
.login-alert--err {
    background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%);
    color: #7f1d1d;
    border: 1px solid #fecaca;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.login-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.01em;
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
}

.login-input {
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 0.95rem;
    font-size: 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #fafafa;
    color: #0f172a;
    font-family: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.login-input::placeholder {
    color: #94a3b8;
}
.login-input:hover {
    border-color: #cbd5e1;
    background: #fff;
}
.login-input:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.login-input:focus-visible {
    outline: none;
}
.login-input--pw {
    padding-right: 3.25rem;
}

.login-pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.login-pw-toggle:hover {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
}
.login-pw-toggle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.login-pw-toggle.is-visible {
    color: #2563eb;
}

.login-row {
    display: flex;
    align-items: center;
    margin-top: -0.15rem;
}

.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.8125rem;
    color: #475569;
    cursor: pointer;
    user-select: none;
    line-height: 1.3;
}
.login-remember input[type="checkbox"] {
    flex-shrink: 0;
}

.login-submit {
    position: relative;
    margin-top: 0.35rem;
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 8px 24px rgba(37, 99, 235, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.login-submit:hover:not(:disabled) {
    filter: brightness(1.04);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.22) inset,
        0 2px 4px rgba(0, 0, 0, 0.08),
        0 12px 32px rgba(37, 99, 235, 0.4);
}
.login-submit:active:not(:disabled) {
    transform: translateY(1px);
}
.login-submit:disabled {
    cursor: wait;
    opacity: 0.88;
    filter: saturate(0.95);
}
.login-submit__spinner {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-spin 0.65s linear infinite;
}
.login-submit[aria-busy="true"] .login-submit__text {
    opacity: 0;
}
.login-submit[aria-busy="true"] .login-submit__spinner {
    display: block;
}

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

@media (prefers-reduced-motion: reduce) {
    .login-submit,
    .login-input,
    .login-pw-toggle {
        transition: none;
    }
    .login-submit__spinner {
        animation: none;
        border: 2px solid #fff;
    }
}

.login-divider {
    height: 1px;
    margin: 0.15rem 0 0.25rem;
    background: linear-gradient(90deg, transparent, #e2e8f0 15%, #e2e8f0 85%, transparent);
}

.login-forgot-wrap {
    text-align: center;
    margin: 0;
}

.login-link {
    background: none;
    border: none;
    padding: 0.35rem 0.25rem;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.login-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.login-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.login-forgot-panel {
    font-size: 0.8125rem;
    line-height: 1.55;
    color: #475569;
    padding: 0.9rem 1rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-top: 0.65rem;
}

.login-secure-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #94a3b8;
}
.login-secure-badge svg {
    flex-shrink: 0;
    opacity: 0.9;
    color: #64748b;
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        box-shadow: none;
    }
    .login-aside {
        display: none;
    }
    .login-main {
        flex: 1;
        padding: 1.25rem 1.25rem 2rem;
    }
    .login-mobile-brand {
        display: flex;
    }
    .login-card {
        width: min(100%, clamp(17rem, 90vw, 28rem));
    }
}

@media (max-width: 380px) {
    .login-main {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .login-card__title {
        font-size: 1.25rem;
    }
}

/* .flash*, .app-alert-banner*: ui-components.css */

.nowrap { white-space: nowrap; }
.inline { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
input.mini { padding: 0.25rem; font-size: 0.8rem; max-width: 130px; }

/* ——— Dashboard BI ——— */
.dashboard-bi {
    width: 100%;
    max-width: none;
}

.dashboard-bi--ux {
    padding-bottom: 2rem;
}

.dash-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding: 1.35rem 1.5rem 1.4rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 48%, #f1f5f9 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 8px 28px rgba(15, 23, 42, 0.07);
}

.dash-hero-main {
    flex: 1;
    min-width: min(100%, 320px);
}

.dash-hero-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.dash-hero-title {
    margin: 0;
    font-size: clamp(1.45rem, 2.5vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
}

.dash-hero-name {
    color: var(--accent);
}

.dash-hero-meta {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.dash-hero-lead {
    margin: 0.65rem 0 0;
    max-width: min(100%, 65ch, 44rem);
    line-height: 1.5;
    font-size: 0.92rem;
}

.dash-hero-alert {
    margin-top: 0.85rem;
    max-width: min(100%, 68ch, 48rem);
}

.dash-hero-aside {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: flex-start;
}

.dash-section {
    margin-bottom: 1.5rem;
}

.dash-section-head {
    margin-bottom: 1rem;
}

.dash-section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.dash-section-desc {
    margin: 0.35rem 0 0;
    font-size: 0.86rem;
    max-width: min(100%, 62ch, 42rem);
    line-height: 1.45;
}

.dash-meta-details {
    margin-top: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    border: 1px dashed var(--border);
    background: rgba(248, 250, 252, 0.9);
}

.dash-meta-summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--accent);
    list-style-position: outside;
}

.dash-meta-body {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: min(100%, 72ch, 52rem);
}

.dashboard-bi-head {
    align-items: flex-start;
}

.dashboard-bi-lead {
    max-width: min(100%, 72ch, 52rem);
    line-height: 1.45;
}

.dashboard-bi-period {
    color: var(--text);
}

.dashboard-bi-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

.bi-period-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.15rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}

.dash-period-toolbar {
    border-top: 3px solid var(--accent);
}

.bi-period-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem;
}

.bi-period-form--wide {
    align-items: flex-end;
}

.bi-period-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bi-period-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.bi-period-input {
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.9rem;
    background: #fff;
}

.bi-period-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bi-chartjs-wrap {
    position: relative;
    height: min(360px, 55vh);
    margin: 0 0 1rem;
}

.bi-chartjs-wrap--setores {
    height: min(280px, 50vh);
    margin-bottom: 1.25rem;
}

.bi-chartjs-wrap--ops {
    height: min(400px, 58vh);
    margin-bottom: 1rem;
}

.bi-table--ops .bi-num {
    text-align: right;
    white-space: nowrap;
}

.bi-table-foot td {
    background: rgba(241, 245, 249, 0.85);
    border-top: 2px solid var(--border);
}

.bi-ops-footnote {
    font-size: 0.82rem;
    margin: 0.75rem 0 0;
    max-width: min(100%, 72ch, 52rem);
    line-height: 1.45;
}

.bi-chartjs-caption {
    font-size: 0.82rem;
    margin: -0.35rem 0 1rem;
}

.bi-chart-empty {
    margin: 0;
    padding: 0.5rem 0 0.25rem;
}

.bi-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.65rem;
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-font-size-caption);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: 0.04em;
    text-transform: none;
    color: var(--ds-text-inverse);
    background: var(--ds-neutral-800);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--ds-shadow-xs);
}

.bi-pill--filial {
    background: #0f766e;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Impostos retidos na NF (formulário expansível) */
.nf-retidos-details {
    margin: 0.65rem 0 1rem;
    padding: 0.65rem 1rem 1rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: var(--surface-alt, #f8fafc);
}

.nf-retidos-details > summary {
    cursor: pointer;
    font-weight: 600;
    list-style-position: outside;
    padding: 0.15rem 0;
}

.nf-retidos-details[open] > summary {
    margin-bottom: 0.25rem;
}

.nf-retidos-hint {
    margin: 0.5rem 0 0.35rem;
    font-size: 0.9rem;
}

.nf-retidos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(10rem, 32vw, 14rem)), 1fr));
    gap: 0.75rem clamp(0.75rem, 2vw, 1.25rem);
    margin-top: 0.5rem;
}

.bi-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(11rem, 28vw, 15rem)), 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-bi--ux .bi-kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(10.5rem, 26vw, 14rem)), 1fr));
}

.avulso-motivo-cell {
    max-width: min(100%, 22rem);
    line-height: 1.35;
    font-size: 0.88rem;
}

.bi-kpi {
    position: relative;
    background: var(--panel);
    border-radius: 14px;
    padding: 1.15rem 1.2rem 1.1rem;
    border: 1px solid var(--border);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.8) inset,
        0 4px 20px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.bi-kpi::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: var(--accent);
}

.bi-kpi--warn::before { background: #d97706; }
.bi-kpi--danger::before { background: #dc2626; }
.bi-kpi--soon::before { background: #ea580c; }
.bi-kpi--ok::before { background: #059669; }
.bi-kpi--ok2::before { background: #0d9488; }
.bi-kpi--in::before { background: #2563eb; }
.bi-kpi--neutral::before { background: #64748b; }
.bi-kpi--doc::before { background: #7c3aed; }

.bi-kpi-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Ícones KPI: traço único (estilo UI outline), sem preenchimento */
.bi-kpi-ico {
    width: 2rem;
    height: 2rem;
    border-radius: 0;
    flex-shrink: 0;
    opacity: 0.88;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.25rem 1.25rem;
    box-shadow: none;
}

.bi-kpi-ico--clock {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
}
.bi-kpi-ico--check {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
}
.bi-kpi-ico--in {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='m19 12-7 7-7-7'/%3E%3C/svg%3E");
}
.bi-kpi-ico--money {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8'/%3E%3Cpath d='M12 18V6'/%3E%3C/svg%3E");
}
.bi-kpi-ico--stack {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z'/%3E%3Cpath d='m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65'/%3E%3Cpath d='m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65'/%3E%3C/svg%3E");
}
.bi-kpi-ico--doc {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cline x1='10' y1='9' x2='8' y2='9'/%3E%3C/svg%3E");
}
.bi-kpi-ico--alert {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");
}
.bi-kpi-ico--soon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Crect width='18' height='18' x='3' y='4' rx='2'/%3E%3Cpath d='M3 10h18'/%3E%3Cpath d='M8 14h.01'/%3E%3Cpath d='M12 14h.01'/%3E%3Cpath d='M16 14h.01'/%3E%3C/svg%3E");
}

.bi-kpi-cat {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.bi-kpi-label {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.3;
}

.bi-kpi-value {
    margin: 0.35rem 0 0;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text);
}

.bi-kpi-value--ok { color: var(--ok); }
.bi-kpi-value--warn { color: var(--warn); }
.bi-kpi-value--danger { color: var(--danger); }

.bi-kpi-hint {
    margin: 0.45rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.35;
}

.bi-kpi-link {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.bi-kpi-link:hover { text-decoration: underline; }

.bi-kpi--pulse {
    animation: bi-pulse-soft 2.4s ease-in-out infinite;
}

@keyframes bi-pulse-soft {
    0%, 100% { box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06); }
    50% { box-shadow: 0 4px 24px rgba(124, 58, 237, 0.18); }
}

.bi-kpi--danger.bi-kpi--pulse {
    animation: bi-pulse-danger 2.2s ease-in-out infinite;
}

@keyframes bi-pulse-danger {
    0%, 100% { box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06); }
    50% { box-shadow: 0 4px 22px rgba(220, 38, 38, 0.22); }
}

.bi-panel {
    background: var(--panel);
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 1.25rem 1.35rem 1.35rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
}

.bi-panel--table { padding-bottom: 0; overflow: hidden; }
.bi-panel--table .bi-panel-head { padding: 0 0 1rem; }
.bi-panel--cta {
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border-color: #bfdbfe;
}

.bi-cta-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text);
}

.bi-panel-head {
    margin-bottom: 1rem;
}

.bi-panel-title {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.bi-panel-sub {
    margin: 0;
    font-size: 0.86rem;
    color: var(--muted);
    line-height: 1.45;
}

.bi-panel-foot {
    margin: 1rem 0 0;
    font-size: 0.88rem;
}
.bi-panel-foot a {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.bi-panel-foot a:hover { text-decoration: underline; }

.bi-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.bi-legend-i {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.bi-legend-i::before {
    content: "";
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 3px;
    background: transparent;
    box-sizing: border-box;
    border: 2px solid currentColor;
}
.bi-legend-i--pay-open::before { color: #d97706; border-color: #d97706; }
.bi-legend-i--pay-paid::before { color: #059669; border-color: #059669; }
.bi-legend-i--rec-open::before { color: #2563eb; border-color: #2563eb; }
.bi-legend-i--rec-ok::before { color: #0d9488; border-color: #0d9488; }

.bi-chart--months {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.bi-chart-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    gap: 0.65rem;
    align-items: center;
}

@media (min-width: 640px) {
    .bi-chart-row {
        grid-template-columns: 4.25rem 1fr;
    }
}

.bi-chart-mo {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.bi-chart-cluster {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.bi-chart-track {
    height: 7px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.bi-chart-fill {
    display: block;
    height: 100%;
    border-radius: 6px;
    min-width: 0;
    transition: width 0.35s ease;
}

.bi-chart-fill--pay-open { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bi-chart-fill--pay-paid { background: linear-gradient(90deg, #34d399, #059669); }
.bi-chart-fill--rec-open { background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.bi-chart-fill--rec-ok { background: linear-gradient(90deg, #5eead4, #0d9488); }

.bi-split {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 0.25rem;
}

@media (min-width: 900px) {
    .bi-split {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.bi-hbar-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.bi-hbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4fr auto;
    gap: 0.5rem 0.75rem;
    align-items: center;
    font-size: 0.88rem;
}

.bi-hbar--stacked {
    grid-template-columns: 3.5rem 1fr auto;
}

.bi-hbar-name,
.bi-sector-name {
    font-weight: 600;
    color: var(--text);
}

.bi-sector-block {
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
}
.bi-sector-block:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.bi-sector-name {
    margin-bottom: 0.45rem;
    display: block;
}

.bi-hbar-subl {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bi-hbar-track {
    height: 10px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.bi-hbar-fill {
    display: block;
    height: 100%;
    border-radius: 6px;
    min-width: 0;
    transition: width 0.35s ease;
}

.bi-hbar-fill--compras {
    background: linear-gradient(90deg, #818cf8, #4f46e5);
}
.bi-hbar-fill--paid {
    background: linear-gradient(90deg, #34d399, #059669);
}
.bi-hbar-fill--open {
    background: linear-gradient(90deg, #fcd34d, #ea580c);
}

.bi-hbar-val {
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    text-align: right;
    min-width: 4.5rem;
}

.bi-table-wrap {
    border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg);
    border: none;
    box-shadow: none;
}

.bi-table th {
    background-color: var(--table-head-bg-solid);
    background-image: var(--table-head-bg);
    border-bottom-color: var(--table-head-border);
    color: var(--table-head-text);
}

.bi-num-ok {
    color: var(--ok);
    font-weight: 600;
}

.bi-num-diff-pos {
    color: var(--ok);
    font-weight: 600;
}

.bi-num-diff-neg {
    color: #b91c1c;
    font-weight: 600;
}

/* Referência manual no dashboard — destaque suave, não preto puro */
.bi-num-receber-ref {
    color: #64748b;
    font-weight: 500;
}

.receivables-filter {
    margin-bottom: 0.65rem;
}

/* Painel de filtros — inadimplência (contas a receber) */
.receivables-inadimpl-filters.card {
    padding: 0;
    border-top: 3px solid var(--accent);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

.receivables-inadimpl-filters__inner {
    padding: 1rem 1.2rem 1.15rem;
}

.receivables-inadimpl-filters__head {
    margin-bottom: 0.95rem;
}

.receivables-inadimpl-filters__title {
    margin: 0 0 0.2rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
}

.receivables-inadimpl-filters__hint {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.35;
}

.receivables-inadimpl-filters__grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem 1.15rem;
}

.receivables-inadimpl-field {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    min-width: 0;
}

.receivables-inadimpl-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.receivables-inadimpl-input {
    width: 100%;
    min-height: 2.4rem;
    box-sizing: border-box;
    border-radius: 8px;
}

.receivables-inadimpl-field--branch {
    flex: 0 0 11.5rem;
    max-width: 14rem;
}

.receivables-inadimpl-field--party {
    flex: 1 1 16rem;
    min-width: min(100%, 14rem);
    max-width: 28rem;
}

.receivables-inadimpl-field--q {
    flex: 2 1 12rem;
    min-width: min(100%, 14rem);
}

.receivables-inadimpl-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding-bottom: 1px;
}

.receivables-inadimpl-submit {
    min-width: 6.5rem;
}

@media (max-width: 720px) {
    .receivables-inadimpl-field--branch,
    .receivables-inadimpl-field--party {
        flex: 1 1 calc(50% - 0.6rem);
        max-width: none;
    }

    .receivables-inadimpl-field--q {
        flex: 1 1 100%;
    }

    .receivables-inadimpl-actions {
        margin-left: 0;
        flex: 1 1 100%;
        justify-content: stretch;
    }

    .receivables-inadimpl-actions .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .receivables-inadimpl-field--branch,
    .receivables-inadimpl-field--party {
        flex: 1 1 100%;
    }
}

/* Formulário GET vazio: campos usam atributo form= (evita aninhar com POST “Receber” nas linhas) */
.receivables-filter-form-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.receivables-table-wrap {
    margin-top: 0.15rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Scroll horizontal fino se necessário — evita badges/ações sobrepostos com table-layout:fixed */
.table-wrap.receivables-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Toolbar depois da <table> no DOM (tab após os filtros), visualmente acima */
.receivables-table-wrap .receivables-filter-toolbar {
    order: -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
    padding: 0 0.05rem;
    flex-shrink: 0;
}

.receivables-filter-toolbar .receivables-limit-hint {
    margin-right: auto;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 22rem;
    text-align: left;
    font-size: 0.68rem;
}

.receivables-filter-toolbar__btns {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    flex-shrink: 0;
}

.main .receivables-filter-toolbar .btn.small.receivables-toolbar-btn {
    font-size: var(--ds-font-size-caption);
    padding: 0.28rem 0.5rem;
    line-height: 1.25;
    font-weight: var(--ds-font-weight-semibold);
    border-radius: var(--ds-radius-pill);
    border-color: var(--ds-border-default);
    box-shadow: var(--ds-shadow-xs);
}

.table.receivables-table {
    /* collapse: alinha thead e tbody na mesma grelha: separate costuma deslocar colunas */
    border-collapse: collapse;
    border-spacing: 0;
    min-width: 0;
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
}

.receivables-table > tbody > tr > td {
    padding: 0.5rem 0.6rem;
    vertical-align: middle;
    min-width: 0;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

/* Uma linha: rótulo da coluna + filtro à direita (inline na mesma célula) */
.receivables-table .receivables-thead th.receivables-th-cell {
    padding: 0.45rem 0.6rem;
    min-width: 0;
    vertical-align: middle;
    box-sizing: border-box;
    background-color: var(--table-head-bg-solid);
    background-image: var(--table-head-bg);
    border-bottom: 2px solid var(--table-head-border);
    font-weight: 400;
}

.receivables-th-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.32rem;
    min-width: 0;
    width: 100%;
}

.receivables-th-label {
    flex: 0 0 auto;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--table-head-text);
    line-height: 1.2;
    white-space: nowrap;
}

.receivables-th-cell--noop .receivables-th-field {
    flex: 0 0 auto;
}

.receivables-th-field {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
}

.receivables-th-field .receivables-filter-control {
    width: 100%;
}

.receivables-th-field--dates {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.35rem;
    justify-content: stretch;
    width: 100%;
}

.receivables-th-field--dates .receivables-filter-date {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: none;
}

/* Só no thead: rótulo em cima, campos usam a largura inteira da coluna (datas/status legíveis) */
.receivables-th-inner--filter-stack {
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    gap: 0.3rem;
}

.receivables-th-inner--filter-stack .receivables-th-label {
    line-height: 1.15;
}

.receivables-th-inner--filter-stack .receivables-th-field {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
}

.receivables-th-inner--filter-stack .receivables-th-field--dates {
    gap: 0.4rem;
}

.receivables-th-inner--filter-stack .receivables-th-field--dates .receivables-filter-date {
    flex: 1 1 50%;
    min-width: 0;
}

.receivables-th-cell--filterhead-venc,
.receivables-th-cell--filterhead-status {
    vertical-align: top;
}

.receivables-th-muted {
    color: #94a3b8;
    font-size: 0.75rem;
    user-select: none;
}

.receivables-table td.receivables-td-desc {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.receivables-table td.receivables-td-tight {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.receivables-table td.receivables-td-party {
    overflow-wrap: break-word;
    word-break: break-word;
    vertical-align: top;
}

.receivables-td-party__nome {
    display: inline-block;
    line-height: 1.35;
    max-width: 100%;
    word-break: break-word;
}

.receivables-td-party__doc {
    display: block;
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* Status + ações: larguras mínimas (fixed layout esmagava colunas e pills sobrepuem vizinhas) */
.receivables-col-status,
.receivables-th-cell--filterhead-status {
    min-width: clamp(5.5rem, 16vw, 7.75rem);
}

.receivables-table td.receivables-td-status {
    vertical-align: middle;
}

.receivables-table td.receivables-td-status .badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    box-sizing: border-box;
}

.receivables-td-actions {
    vertical-align: top;
    min-width: clamp(9.5rem, 34vw, 18rem);
}

.receivables-td-actions-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    align-content: flex-end;
    gap: 0.45rem 0.55rem;
    min-width: 0;
}

.receivables-td-actions__edit {
    flex-shrink: 0;
    white-space: nowrap;
}

.receivables-td-actions__receive {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    margin: 0;
}

.receivables-receive-date.mini {
    max-width: 7.25rem;
    padding: 0.2rem 0.3rem;
    font-size: 0.75rem;
}

.receivables-receive-btn {
    flex-shrink: 0;
    padding: 0.18rem 0.4rem !important;
    font-size: 0.72rem !important;
    line-height: 1.2 !important;
}

/* Última coluna do thead: ações (largura mínima real, não 1% que colapsa o miolo) */
.receivables-th-cell--corner {
    width: auto;
    min-width: clamp(9.5rem, 34vw, 18rem);
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
    vertical-align: middle;
}


/* .receivables-filter-control: ui-components.css */

.receivables-filter-date {
    font-size: 0.7rem;
    padding: 0.2rem 0.28rem;
}

.receivables-limit-hint {
    margin: 0;
    line-height: 1.25;
}

/* Central de pagamento simplificado — grelha por dia (30 dias ou mês completo) */
.central-pagamentos-head {
    align-items: flex-start;
}

.central-pagamentos-disclaimer {
    color: var(--danger, #dc2626);
    font-weight: 600;
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
}

.central-pagamentos-filial-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1.25rem;
    margin-top: 0.55rem;
}

.central-pagamentos-saldo-filial {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 11rem;
    padding: 0.5rem 0.85rem;
    background: #f1f5f9;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
}

.central-pagamentos-saldo-filial__label {
    line-height: 1.25;
}

.central-pagamentos-saldo-filial__val {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text, #0f172a);
}

.central-pagamentos-saldo-filial__val:not(.central-pagamentos-saldo-filial__val--empty) {
    color: #15803d;
}

.central-pagamentos-saldo-filial__val--empty {
    font-size: 0.95rem;
    font-weight: 600;
    color: #64748b;
}

.central-pagamentos-filial-form__label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.central-pagamentos-filial-form__select {
    min-width: 14rem;
    max-width: 100%;
}

.central-pagamentos-modo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 0.65rem;
}

.central-pagamentos-mes-form {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

/* .central-pagamentos-mes-form input[type="month"]: ui-components.css */

.central-pagamentos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
    gap: 1.15rem;
    margin-top: 0.65rem;
}

.central-pag-card {
    --cp-accent: #94a3b8;
    --cp-accent-soft: #f1f5f9;
    background: var(--panel, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 16px;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 8px 24px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    min-height: 100%;
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.central-pag-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--cp-accent);
    border-radius: 16px 0 0 16px;
}

.central-pag-card:hover {
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.05),
        0 12px 32px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
    .central-pag-card {
        transition: none;
    }

    .central-pag-card:hover {
        transform: none;
    }
}

.central-pag-card--active {
    --cp-accent: var(--ds-color-primary);
    --cp-accent-soft: var(--ds-color-primary-muted);
    border-color: var(--ds-color-primary-border);
}

.central-pag-card--quiet {
    --cp-accent: #cbd5e1;
}

.central-pag-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.85rem 1rem 0.75rem 1.15rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    background: linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
}

.central-pag-card__head-main {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    min-width: 0;
}

.central-pag-card__head-icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border, #e2e8f0);
    color: #64748b;
}

.central-pag-card--active .central-pag-card__head-icon {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: linear-gradient(160deg, #eff6ff 0%, #e0f2fe 100%);
}

.central-pag-card__head-icon .nav-ico {
    display: flex;
    width: 1.2rem;
    height: 1.2rem;
}

.central-pag-card__head-icon .nav-ico--svg svg {
    width: 100%;
    height: 100%;
}

.central-pag-card__head-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.central-pag-card__date {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.02em;
    color: var(--text, #0f172a);
    line-height: 1.2;
}

.central-pag-card__filial {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.central-pag-card__count-pill {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    background: #fff;
    border: 1px solid var(--border, #e2e8f0);
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.central-pag-card--active .central-pag-card__count-pill {
    color: #1e40af;
    border-color: #93c5fd;
    background: linear-gradient(180deg, #dbeafe 0%, #e0f2fe 100%);
}

.central-pag-card__body {
    padding: 1rem 1rem 1.05rem 1.15rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.central-pag-card__metric {
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: var(--cp-accent-soft);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.central-pag-card__metric--due {
    background: linear-gradient(145deg, #eff6ff 0%, #e0f2fe 55%, #dbeafe 100%);
    border-color: #93c5fd;
}

.central-pag-card__metric-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.central-pag-card--active .central-pag-card__metric-label {
    color: #1d4ed8;
}

.central-pag-card__metric-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8rem;
}

.central-pag-card__total {
    font-size: 1.55rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #94a3b8;
}

.central-pag-card__total--has {
    color: #000000;
}

/* .app-modal*, .app-alert-host, .app-alert-banner*: ui-components.css */

.app-toast-stack {
    position: fixed;
    top: 1.15rem;
    right: 1.15rem;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: min(26.5rem, calc(100vw - 2rem));
    pointer-events: none;
}

.app-toast-stack .app-toast {
    pointer-events: auto;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1rem 0.95rem 1.05rem;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: -0.01em;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(15, 23, 42, 0.06),
        0 18px 40px rgba(15, 23, 42, 0.1);
    opacity: 0;
    transform: translateX(0.65rem) scale(0.98);
    transition:
        opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-toast--in {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.app-toast--out {
    opacity: 0;
    transform: translateX(0.4rem) scale(0.98);
}

.app-toast__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
}

.app-toast__glyph {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
}

.app-toast--success {
    background: linear-gradient(145deg, #ecfdf5 0%, #d1fae5 48%, #ecfdf5 100%);
    color: #14532d;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.app-toast--success .app-toast__icon {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
}

.app-toast--info {
    background: linear-gradient(145deg, var(--ds-color-info-muted) 0%, rgba(2, 132, 199, 0.08) 50%, var(--ds-color-info-muted) 100%);
    color: #0c4a6e;
    border: 1px solid var(--ds-color-info-border);
}

.app-toast--info .app-toast__icon {
    background: var(--ds-color-info-muted);
    color: var(--ds-color-info);
}

.app-toast--warn {
    background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 50%, #fffbeb 100%);
    color: #78350f;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.app-toast--warn .app-toast__icon {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
}

.app-toast--error {
    background: linear-gradient(145deg, #fef2f2 0%, #fecaca 45%, #fef2f2 100%);
    color: #7f1d1d;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.app-toast--error .app-toast__icon {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.app-toast__text {
    flex: 1;
    min-width: 0;
    padding: 0.1rem 0;
}

.app-toast__close {
    flex-shrink: 0;
    align-self: center;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    opacity: 0.65;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.app-toast__close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.09);
}

.app-snackbar-root {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99990;
    padding: 1rem;
    max-width: min(32rem, 100vw - 2rem);
    pointer-events: none;
}

.app-snackbar-root .app-snackbar {
    pointer-events: auto;
}

.app-snackbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-snackbar--in {
    opacity: 1;
    transform: translateY(0);
}

.app-snackbar--out {
    opacity: 0;
    transform: translateY(0.5rem);
}

.app-snackbar--info {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-snackbar--success {
    background: #14532d;
    color: #ecfdf5;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-snackbar--error {
    background: #7f1d1d;
    color: #fef2f2;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-snackbar--warn {
    background: #78350f;
    color: #fffbeb;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-snackbar__text {
    flex: 1;
    min-width: 0;
}

.app-snackbar__close {
    flex-shrink: 0;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
}

.app-snackbar__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

html.app-confirm-open,
html.app-confirm-open body {
    overflow: hidden;
}

.app-confirm {
    position: fixed;
    inset: 0;
    z-index: 99995;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
}

.app-confirm[hidden] {
    display: none !important;
}

.app-confirm__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 25, 0.5);
    backdrop-filter: blur(2px);
}

.app-confirm__dialog {
    position: relative;
    z-index: 1;
    width: min(400px, 100%);
    background: var(--panel, #fff);
    color: var(--text, #1a2330);
    border-radius: var(--radius, 10px);
    padding: 1.25rem 1.35rem 1.15rem;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 20px 50px rgba(15, 23, 42, 0.22);
}

.app-confirm__title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.app-confirm__message {
    margin: 0 0 1.15rem;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted, #5c6b7a);
}

.app-confirm__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.app-inline-error {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: #b91c1c;
    line-height: 1.35;
}

/* Barra de carregamento (anexos, geração de download) — mín. 2s no JS */
.app-loading-bar-root {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 18vh 1rem 1rem;
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.32s ease;
}

.app-loading-bar-root[hidden] {
    display: none !important;
}

.app-loading-bar-root--visible:not([hidden]) {
    display: flex !important;
}

.app-loading-bar-root--in {
    opacity: 1;
    pointer-events: auto;
}

.app-loading-bar-root__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(3px);
}

.app-loading-bar {
    position: relative;
    z-index: 1;
    width: min(22rem, calc(100vw - 2rem));
    padding: 1.15rem 1.35rem 1.25rem;
    background: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.8) inset,
        0 12px 40px rgba(15, 23, 42, 0.14),
        0 4px 12px rgba(15, 23, 42, 0.08);
}

.app-loading-bar__label {
    margin: 0 0 0.85rem;
    font-size: 0.98rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.02em;
    text-align: center;
    line-height: 1.35;
}

.app-loading-bar__track {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-loading-bar__fill {
    height: 100%;
    width: 42%;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #22c55e 0%,
        #4ade80 25%,
        #86efac 50%,
        #4ade80 75%,
        #16a34a 100%
    );
    background-size: 200% 100%;
    animation: app-loading-bar-flow 1.15s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.45);
}

@keyframes app-loading-bar-flow {
    0% {
        transform: translateX(-100%);
        background-position: 0% 50%;
    }
    100% {
        transform: translateX(280%);
        background-position: 100% 50%;
    }
}
