@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-Medium.ttf") format("truetype");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-SemiBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    --bs-body-font-family: "Poppins", sans-serif;
}

html,
body,
button,
input,
select,
textarea,
.btn,
.form-control,
.form-select,
.dropdown-menu,
.tooltip,
.popover {
    font-family: "Poppins", sans-serif;
}

/*
 * Camada responsiva comum do sistema.
 * As regras abaixo existem apenas em telas pequenas para preservar
 * integralmente a composição desktop de cada módulo.
 */
@media (max-width: 767.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    body {
        font-size: 0.875rem;
    }

    body > .container,
    body > .container-fluid,
    main.container,
    main.container-fluid {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }

    /* Controles confortáveis para toque e sem zoom automático no iOS. */
    .btn:not(.btn-close) {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        white-space: normal;
        line-height: 1.15;
    }

    .btn-sm:not(.btn-close),
    .table .btn:not(.btn-close) {
        min-height: 36px;
    }

    .table .btn:not(.btn-close) {
        min-width: 36px;
        padding: 0.4rem 0.55rem;
    }

    .form-control,
    .form-select,
    .input-group-text {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        height: auto;
        min-height: 88px;
    }

    .form-control-sm,
    .form-select-sm,
    .input-group-sm > .form-control,
    .input-group-sm > .form-select,
    .input-group-sm > .input-group-text {
        min-height: 40px;
        font-size: 16px;
    }

    /* Cabeçalhos e barras de ação se reorganizam sem comprimir botões. */
    .toolbar,
    .page-actions,
    .header-actions,
    .panel-heading,
    .card-header,
    .topbar,
    header.top,
    body > .container > .d-flex.justify-content-between,
    body > .container-fluid > .d-flex.justify-content-between,
    main > .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.65rem;
    }

    .toolbar > *,
    .page-actions > *,
    .header-actions > *,
    .topbar > *,
    header.top > * {
        flex: 0 1 auto;
        min-width: 0;
    }

    .panel > .d-flex,
    .card > .d-flex {
        max-width: 100%;
        flex-wrap: wrap;
    }

    .panel > .d-flex > .d-flex,
    .card > .d-flex > .d-flex {
        max-width: 100%;
        min-width: 0;
        flex-wrap: wrap;
    }

    /* Filtros permanecem lado a lado quando há espaço e empilham no celular estreito. */
    .filters,
    .filter-grid,
    .filter-bar,
    .filtros {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.65rem !important;
        align-items: end;
    }

    .filters > *,
    .filter-grid > *,
    .filter-bar > *,
    .filtros > * {
        min-width: 0;
        width: 100%;
    }

    .filters .btn,
    .filter-grid .btn,
    .filter-bar .btn,
    .filtros .btn {
        width: 100%;
    }

    /* Grades largas ganham rolagem horizontal local, sem estourar a página. */
    .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        border-radius: 0.6rem;
        scrollbar-width: thin;
    }

    .list-wrap,
    .items-wrap,
    .table-wrap,
    .table-scroll,
    .dfe-grid,
    .movement-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .table-responsive > .table {
        margin-bottom: 0;
    }

    .table-responsive:has(th:nth-child(5)) > .table {
        min-width: 720px;
    }

    .table-responsive:has(th:nth-child(8)) > .table {
        min-width: 980px;
    }

    .list-wrap:has(th:nth-child(4)) > .table,
    .table-wrap:has(th:nth-child(4)) > .table,
    .table-scroll:has(th:nth-child(4)) > .table,
    .movement-table-wrap:has(th:nth-child(4)) > .table {
        min-width: 640px;
    }

    .items-wrap:has(th:nth-child(6)) > .table,
    .dfe-grid:has(th:nth-child(6)) > .table {
        min-width: 920px;
    }

    .table {
        font-size: 0.78rem;
    }

    .table > :not(caption) > * > * {
        padding: 0.62rem 0.55rem;
        vertical-align: middle;
    }

    .table th,
    .table td.text-nowrap,
    .table td.text-end,
    .table td:last-child {
        white-space: nowrap;
    }

    .table .btn-group {
        flex-wrap: nowrap;
    }

    /* Listas, paginação e abas continuam legíveis e navegáveis por toque. */
    .list-group-item {
        padding: 0.8rem;
    }

    .list-group-item > .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .page-link {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        min-height: 42px;
        white-space: nowrap;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1rem);
    }

    /* Modais aproveitam a tela útil e mantêm ações sempre acessíveis. */
    .modal-dialog,
    .modal-lg,
    .modal-xl {
        width: auto;
        max-width: calc(100% - 0.8rem);
        margin: 0.4rem auto;
    }

    .modal-dialog-scrollable {
        height: calc(100dvh - 0.8rem);
        max-height: calc(100dvh - 0.8rem);
    }

    .modal-content {
        max-height: calc(100dvh - 0.8rem);
        border-radius: 0.75rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-body {
        padding: 1rem;
        overflow-x: hidden;
    }

    .modal-body.p-3,
    .modal-body.p-4,
    .modal-body.p-5 {
        padding: 1rem !important;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer > .btn {
        flex: 1 1 140px;
        margin: 0;
    }

    /* Navegação e mensagens ocupam somente o necessário. */
    .navbar .container,
    .navbar .container-fluid {
        padding: 0.6rem 0.75rem;
    }

    .navbar-brand {
        max-width: calc(100vw - 120px);
        font-size: 0.95rem;
        white-space: normal;
    }

    .navbar-collapse {
        max-height: calc(100dvh - 72px);
        overflow-y: auto;
    }

    .alert {
        padding: 0.75rem;
    }

    .card,
    .fieldset-box,
    .tab-content-box {
        max-width: 100%;
    }

    .fieldset-box,
    .tab-content-box {
        padding: 0.8rem !important;
    }

    .topbar h3,
    header.top h3 {
        font-size: 1.15rem;
    }

    main .input-group[style*="max-width"],
    main .form-select[style*="max-width"],
    main .form-control[style*="max-width"] {
        max-width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    .filters,
    .filter-grid,
    .filter-bar,
    .filtros {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .toolbar,
    .page-actions,
    .header-actions,
    .topbar,
    header.top,
    body > .container > .d-flex.justify-content-between,
    body > .container-fluid > .d-flex.justify-content-between,
    main > .d-flex.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
    }

    .topbar > .badge,
    header.top > .badge {
        align-self: flex-start;
    }

    .panel > .d-flex > .d-flex,
    .card > .d-flex > .d-flex {
        width: 100%;
    }

    .panel > .d-flex > .d-flex > .btn,
    .card > .d-flex > .d-flex > .btn {
        flex: 1 1 140px;
    }

    .toolbar > .btn,
    .page-actions > .btn,
    .header-actions > .btn,
    body > .container > .d-flex.justify-content-between > .btn,
    body > .container-fluid > .d-flex.justify-content-between > .btn,
    main > .d-flex.justify-content-between > .btn {
        width: 100%;
    }

    .card-body {
        padding: 0.85rem;
    }

    .modal-title {
        font-size: 1rem;
    }

    .modal-footer > .btn {
        flex-basis: 100%;
    }
}
