/* Tema do backoffice. Mantém os componentes Bootstrap/jQuery e os seus estados.
   Âmbito explícito; o login tem variantes próprias, sem afetar o PortalAlunos. */
body.sas-theme {
    --main-color: #07518b;
    --bs-primary: #07518b;
    --bs-primary-rgb: 7, 81, 139;
    --sas-sidebar: 238px;
    --sas-header: 76px;
    color: #24364a;
    background: #f3f6fa;
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* Estrutura: rodapé no fluxo, sem margens negativas nem sobreposição ao conteúdo. */
body.sas-theme #sidebarWrapper { display: block; overflow: visible; width: 100%; }
body.sas-theme #sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sas-sidebar); min-width: 0;
    height: 100vh; min-height: 0; margin: 0; padding: 0; float: none;
    display: flex; flex-direction: column; background: #102d49; box-shadow: none;
    z-index: 1031; transition: width .2s ease;
}
body.sas-theme #sidebar .sidebar-header { padding: 26px 20px !important; flex-shrink: 0; }
body.sas-theme #sidebar .sas-brand { display: flex; align-items: center; gap: 12px; margin: 0; padding: 0; width: auto; color: #fff; text-decoration: none; line-height: 1.5; }
body.sas-theme .sas-brand-symbol {
    width: 40px; height: 40px; flex: 0 0 40px; display: flex; align-items: center;
    justify-content: center; border: 1px solid #68829b; border-radius: 9px; font-weight: 700;
}
body.sas-theme .sas-brand-text { font-size: 20px; font-weight: 650; letter-spacing: 1px; white-space: nowrap; }
body.sas-theme .sas-brand-text small { display: block; color: #bdcedd; font-size: 9px; letter-spacing: .7px; }
body.sas-theme #sidebar .sidebar-content { flex: 1; min-height: 0; max-height: none; padding: 4px 8px 24px; overflow-y: auto; scrollbar-width: thin; }
body.sas-theme #sidebar .sidebar-content::-webkit-scrollbar { display: block; width: 5px; }
body.sas-theme #sidebar .sidebar-content::-webkit-scrollbar-thumb { background: #47637b; border-radius: 5px; }
body.sas-theme #sidebar .list-group-item {
    width: auto; margin: 3px 4px; padding: 12px; border: 0; border-radius: 7px;
    font-size: 13px; line-height: 1.5; font-weight: 400; color: #d3dfeb; background: transparent;
}
body.sas-theme #sidebar .list-group-item .arrow { margin-right: 0; font-size: 10px; }
body.sas-theme #sidebar .list-group-item::before { display: none; }
body.sas-theme #sidebar .list-group-item:hover,
body.sas-theme #sidebar .list-group-item.active { background: #214563; color: #fff; }
body.sas-theme #sidebar .list-group-item.active { font-weight: 600; }
body.sas-theme #sidebar .submenu .list-group-item { padding: 9px 10px 9px 42px; font-size: 12px; }
body.sas-theme #sidebarWrapper.sidebar-closed #sidebar { width: 64px; min-width: 64px; }
body.sas-theme #sidebarWrapper.sidebar-closed .sidebar-header { padding: 26px 12px !important; }
body.sas-theme #sidebarWrapper.sidebar-closed .sas-brand-text { display: none; }
body.sas-theme #sidebarWrapper.sidebar-closed #sidebar .sas-brand {
    width: 40px; height: 40px; padding: 0; margin: 0 auto;
    display: flex; justify-content: center; gap: 0;
}
body.sas-theme #sidebarWrapper.sidebar-closed .sas-brand-symbol {
    width: 40px; height: 40px; margin: 0; padding: 0; font-size: 14px;
    line-height: 1; color: #fff; text-align: center;
}
body.sas-theme #sidebarWrapper.sidebar-closed #sidebar .sidebar-content { padding-inline: 4px; }
body.sas-theme #sidebarWrapper.sidebar-closed #sidebar > .sidebar-content > .list-group { padding-top: 0; }
body.sas-theme .submenu.rail-flyout { background: #102d49; border: 1px solid #35546f; z-index: 1032; }
body.sas-theme .submenu.rail-flyout .list-group-item { color: #d3dfeb; background: transparent; border: 0; padding: 12px 16px; font-size: 13px; }
body.sas-theme .submenu.rail-flyout .list-group-item:hover,
body.sas-theme .submenu.rail-flyout .list-group-item.active { background: #214563; color: #fff; }
body.sas-theme #sidebarRailTooltip { z-index: 1033; }

body.sas-theme #navBar {
    position: fixed; top: 0; left: var(--sas-sidebar); right: 0; width: auto;
    height: var(--sas-header); min-height: 0; padding: 0 28px; display: flex;
    align-items: center; gap: 18px; background: #fff !important; border-bottom: 1px solid #e1e7ef;
    box-shadow: none; z-index: 1030 !important; transition: left .2s ease;
}
body.sas-theme.sas-menu-closed #navBar { left: 64px; }
body.sas-theme #navBar > div:first-child, body.sas-theme #navBarAPPLine { display: none; }
body.sas-theme #sidebarCollapse {
    display: flex !important; align-items: center; justify-content: center;
    width: 38px !important; height: 38px !important; flex: 0 0 38px;
    margin: 0 !important; padding: 0; float: none !important; color: #405b73 !important;
    border: 1px solid #d7e0ea; border-radius: 6px; background: #fff; transform: none;
}
body.sas-theme #sidebarCollapse .fa { font-size: 18px !important; }
body.sas-theme #sidebarCollapse:hover { background: #edf4fa; }
body.sas-theme #sidebarCollapse:focus-visible { outline: 2px solid #07518b; outline-offset: 3px; }
body.sas-theme #navBarAPPTitle { display: block !important; position: static; float: none; margin: 0; padding: 0; min-width: 0; max-width: none; flex: 1; height: auto; }
body.sas-theme #navBarAPPTitle > a { display: flex !important; margin: 0; padding: 0; height: auto; text-decoration: none; }
body.sas-theme .sas-app-title { color: #324b63; font-size: 14px; font-weight: 500; line-height: 1.4; }
body.sas-theme .sas-app-title small { margin-left: 16px; color: #687b8c; font-size: 12px; }
body.sas-theme #navBarAPPProfileIcon {
    position: relative; top: auto !important; right: auto !important; float: none; margin: 0 0 0 auto;
    width: 38px !important; height: 38px; flex: 0 0 38px; background: #eaf2fa !important; border-radius: 50%;
}
body.sas-theme .navBarAPPProfileIconOnClick { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
body.sas-theme #sasAccountToggle { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
body.sas-theme #sasAccountToggle > span { color: #275779; font-size: 20px; top: 0 !important; margin: 0; }
body.sas-theme #sasAccountToggle:focus-visible { outline: 2px solid #07518b; outline-offset: 3px; }
body.sas-theme .navBarAPPProfileIconContent {
    display: none; top: 48px; right: 0; left: auto; width: 300px; min-width: 0; max-width: calc(100vw - 28px);
    margin-top: 0; padding: 16px; grid-template-columns: 40px minmax(0, 1fr); gap: 12px;
    border: 1px solid #dce4ed; border-radius: 10px; background: #fff; color: #24364a;
    box-shadow: 0 12px 35px #102d4924;
}
body.sas-theme .sas-account-open .navBarAPPProfileIconContent { display: grid; visibility: visible; opacity: 1; }
body.sas-theme #navBarAPPProfileIconContentImg { float: none; width: 40px; height: 40px; margin: 0; padding: 0; border: 0; }
body.sas-theme #navBarAPPProfileIconContentData { float: none; width: auto; min-width: 0; margin: 0; padding: 0; overflow-wrap: anywhere; }
body.sas-theme #navBarAPPProfileIconContentAction { grid-column: 1 / -1; position: static; width: auto; height: auto; padding: 10px 0 0; border-top: 1px solid #e1e7ef; }
body.sas-theme #navBarAPPProfileIconContentData p { color: #24364a; }
body.sas-theme #navBarAPPProfileIconContentAction a { color: #07518b; }
body.sas-theme #content {
    display: flex; flex-direction: column; float: none; min-width: 0;
    width: calc(100% - var(--sas-sidebar)); margin: 0 0 0 var(--sas-sidebar);
    padding-top: var(--sas-header); min-height: 100vh; background: #f3f6fa !important;
    transition: margin-left .2s ease, width .2s ease;
}
body.sas-theme #sidebarWrapper.sidebar-closed #content { width: calc(100% - 64px); margin-left: 64px; }
body.sas-theme #wrap { width: 100%; min-height: 0 !important; margin: 0; padding: 24px 32px 32px; flex: 1; }
body.sas-theme #main { padding-top: 0 !important; padding-bottom: 0 !important; }
body.sas-theme #main > .container-fluid { padding-inline: 0; }
body.sas-theme #breadcrumbContainer .breadcrumb { background: transparent; box-shadow: none; padding: 0 0 6px; font-size: 12px; }
body.sas-theme #breadcrumbContainer nav { background: transparent; width: auto; height: auto; line-height: 1.5; }
body.sas-theme #content > footer.footer { margin: 0 !important; padding: 22px 20px 26px; height: auto !important; border-top: 1px solid #e1e7ef; background: #fff !important; }
body.sas-theme .footerContainer { width: 100%; padding: 0; margin: 0; }
body.sas-theme #footerContainerText { color: #53657b; font-size: 13px; }
body.sas-theme #footerImages { width: 600px; max-width: 100%; margin: 16px auto 0; }
body.sas-theme #footerImages > img { display: block; float: none; width: 100%; height: auto; padding: 0; }

/* Componentes comuns. Cores de sucesso/erro/aviso conservam o seu significado. */
body.sas-theme .card { border-radius: 10px; border: 1px solid #e1e7ef !important; box-shadow: 0 3px 12px #12334e04 !important; }
body.sas-theme .card-header { background: #fff; border-color: #e8edf3; }
body.sas-theme .btn { border-radius: 6px; font-weight: 500; text-transform: none; letter-spacing: normal; box-shadow: none !important; }
body.sas-theme .btn-primary { --bs-btn-bg: #07518b; --bs-btn-border-color: #07518b; background-color: #07518b; border-color: #07518b; color: #fff; }
body.sas-theme .btn-primary:hover, body.sas-theme .btn-primary:focus { background-color: #063e6a; border-color: #063e6a; color: #fff; }
body.sas-theme .btn-outline-primary { color: #07518b; border-color: #b9cddd; background: #fff; }
body.sas-theme .btn-outline-primary:hover { background: #07518b; border-color: #07518b; color: #fff; }
body.sas-theme .form-control, body.sas-theme .form-select { border: 1px solid #ced9e5; border-radius: 6px; font-size: 14px; color: #263d55; }
body.sas-theme .form-select { display: block; width: 100%; min-height: 38px; padding: 6px 30px 6px 12px; }
body.sas-theme .form-control:focus, body.sas-theme .form-select:focus { border-color: #81afd1; box-shadow: 0 0 0 3px #07518b1a; }
body.sas-theme .form-control:disabled, body.sas-theme .form-control[readonly], body.sas-theme .form-select:disabled { background-color: #f2f5f8; color: #53657b; }
body.sas-theme .form-label { font-size: 12px; color: #40566e !important; font-weight: 600 !important; }
body.sas-theme .select2-container .select2-choice { border: 1px solid #ced9e5; border-radius: 6px; background: #fff; color: #263d55; }
body.sas-theme .select2-container .select2-choice .select2-arrow { background: #f3f6fa; border-color: #ced9e5; }
body.sas-theme .nav-tabs { background: #fff; border-bottom: 1px solid #e1e7ef; }
body.sas-theme .nav-tabs .nav-link { font-size: 13px; padding: 13px 16px; color: #5e7185 !important; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; }
body.sas-theme .nav-tabs .nav-link.active { color: #07518b !important; border-bottom-color: #07518b; background: #fff; font-weight: 600; }
body.sas-theme .nav-tabs .nav-link:hover { color: #07518b !important; background: #f4f8fc; }
body.sas-theme table.table { color: #24364a; font-size: 13px; }
body.sas-theme table.table > thead > tr > th { padding: 13px 14px; background: #f8fafc; color: #52667b; border-color: #e1e7ef; font-size: 11px; font-weight: 600; }
body.sas-theme table.table > tbody > tr > td { padding: 12px 14px; border-color: #e8edf3; vertical-align: middle; }
body.sas-theme .dataTables_wrapper .dataTables_filter input,
body.sas-theme .dataTables_wrapper .dataTables_length select { border: 1px solid #ced9e5; border-radius: 6px; background: #fff; color: #263d55; padding: 7px 10px; }
body.sas-theme .dataTables_wrapper .dataTables_filter,
body.sas-theme .dataTables_wrapper .dataTables_length,
body.sas-theme .dataTables_wrapper .dataTables_info,
body.sas-theme .dataTables_wrapper .dataTables_paginate { color: #5e7185; font-size: 12px; }
body.sas-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current { border-color: #dce7f1; background: #eaf2fa; color: #07518b !important; border-radius: 5px; }
body.sas-theme .modal-content { border: 1px solid #dce4ed !important; border-radius: 14px; box-shadow: 0 24px 90px #102d4938 !important; }
body.sas-theme .modal-header { background: #fff !important; padding: 22px 26px; border-bottom: 1px solid #e8edf3; border-radius: 14px 14px 0 0; }
body.sas-theme .modal-title { color: #24364a !important; font-size: 20px; font-weight: 600 !important; }
body.sas-theme .modal-title.text-danger { color: #b02a37 !important; }
body.sas-theme .modal-header .btn-close-white { filter: none; }
body.sas-theme .modal-body { padding: 24px 26px !important; }
body.sas-theme .modal-footer { background: #f9fbfd !important; padding: 16px 26px; border-top: 1px solid #e1e7ef !important; border-radius: 0 0 14px 14px; gap: 8px; }
body.sas-theme .modal-backdrop { background-color: #10243e; }

/* Eventos, comunicações e templates: títulos, ações e editores em ecrãs pequenos. */
body.sas-theme .sas-section { margin-top: 20px !important; }
body.sas-theme .sas-section .sas-page-heading { align-items: flex-end; flex-wrap: wrap; }
body.sas-theme .sas-section .sas-page-heading > div { min-width: 0; }
body.sas-theme .sas-event-detail #lblNomeEvento,
body.sas-theme .sas-event-detail #lblEntidadeSelecionada { overflow-wrap: anywhere; }
body.sas-theme .sas-event-detail > .row { margin-inline: 0; }
body.sas-theme .sas-event-detail .sas-event-actions { gap: 12px; flex-wrap: wrap; }
body.sas-theme .sas-event-detail .sas-event-actions > div { display: flex; flex-wrap: wrap; gap: 8px; }
body.sas-theme .sas-editor-page .card-body { min-width: 0; }
body.sas-theme .sas-editor-page .tox-tinymce,
body.sas-theme .sas-editor-page .mce-tinymce { max-width: 100%; }
body.sas-theme .sas-editor-page .tox-editor-container,
body.sas-theme .sas-editor-page .tox-edit-area { min-width: 0; }
body.sas-theme .sas-editor-page .alert .d-flex > div:last-child { min-width: 0; }
@media (max-width: 700px) {
    body.sas-theme .sas-section .sas-page-heading > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
    body.sas-theme .sas-editor-page .card-body { padding: 20px !important; }
    body.sas-theme .sas-editor-page .divAtualizar,
    body.sas-theme .sas-editor-page #aUpdateTextoTemplate,
    body.sas-theme .sas-editor-page #aEnviarEmailUtentes { width: 100%; }
}

/* Faturação: filtros, totais e ações de confirmação. */
body.sas-theme .sas-finance .card + .card { margin-top: 24px; }
body.sas-theme .sas-finance .form-check-label { color: #40566e; }
body.sas-theme .sas-finance .input-group-text { border-color: #ced9e5; }
body.sas-theme .sas-finance .sas-finance-results { overflow: hidden; }
body.sas-theme .sas-finance #lblTotalFaturar { color: #07518b; font-size: 24px; }
body.sas-theme .sas-finance .table-responsive { border-radius: 7px; }
body.sas-theme .sas-finance .modal-body .card { box-shadow: none !important; }
body.sas-theme .sas-finance .modal-header.text-white { background: #07518b !important; }
body.sas-theme .sas-finance .nav-pills .nav-link.active { background: #07518b; }
@media (max-width: 700px) {
    body.sas-theme .sas-finance .row > [class*="col-"] { margin-bottom: 12px; }
    body.sas-theme .sas-finance .d-flex.justify-content-end > .btn,
    body.sas-theme .sas-finance .d-flex.justify-content-end > a,
    body.sas-theme .sas-finance #btnFaturarEntidade { width: 100%; }
    body.sas-theme .sas-finance .modal-body .row.text-center > [class*="col-"] { border-right: 0 !important; border-bottom: 1px solid #e8edf3; padding-block: 8px; }
    body.sas-theme .sas-finance .modal-body .row.text-center > [class*="col-"]:last-child { border-bottom: 0; }
}

/* Gestão simples: dicionários, estrutura física e listas administrativas. */
body.sas-theme .sas-simple-management { margin-top: 20px !important; }
body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child {
    align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px !important;
    padding-bottom: 18px !important; border-color: #e5ecf3 !important;
}
body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child h2 {
    color: #24364a !important; font-size: 24px; line-height: 1.25; font-weight: 650 !important;
    letter-spacing: -.4px; margin: 0; min-width: 0; overflow-wrap: anywhere;
}
body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child > a,
body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child > button { margin-left: auto; }
body.sas-theme .sas-simple-management > .card > .card-body > .container-fluid { padding-inline: 0; }
body.sas-theme .sas-simple-management .card .card { border-color: #e5ecf3 !important; }
body.sas-theme .sas-simple-management .form-switch .form-check-input { cursor: pointer; }
body.sas-theme .sas-simple-management .modal-body { overflow-wrap: anywhere; }
/* Dicionários: a ação de edição ocupa sempre a última coluna, alinhada à direita. */
body.sas-theme #divListaTiposUtente table th:last-child,
body.sas-theme #divListaTiposUtente table td:last-child,
body.sas-theme #divListaTiposResidencia table th:last-child,
body.sas-theme #divListaTiposResidencia table td:last-child,
body.sas-theme #divListaTiposQuarto table th:last-child,
body.sas-theme #divListaTiposQuarto table td:last-child,
body.sas-theme #divListaTiposCandidaturaIndividual table th:last-child,
body.sas-theme #divListaTiposCandidaturaIndividual table td:last-child,
body.sas-theme #divListaTiposDocumento table th:last-child,
body.sas-theme #divListaTiposDocumento table td:last-child,
body.sas-theme #divListaTiposArtigo table th:last-child,
body.sas-theme #divListaTiposArtigo table td:last-child,
body.sas-theme #divListaMeiosPagamento table th:last-child,
body.sas-theme #divListaMeiosPagamento table td:last-child,
body.sas-theme #divListaArtigos table th:last-child,
body.sas-theme #divListaArtigos table td:last-child,
body.sas-theme #divListaCentrosCusto table th:last-child,
body.sas-theme #divListaCentrosCusto table td:last-child { text-align: right !important; white-space: nowrap; }
body.sas-theme #divListaTiposUtente table,
body.sas-theme #divListaTiposResidencia table,
body.sas-theme #divListaTiposQuarto table,
body.sas-theme #divListaTiposCandidaturaIndividual table,
body.sas-theme #divListaTiposDocumento table,
body.sas-theme #divListaTiposArtigo table,
body.sas-theme #divListaMeiosPagamento table,
body.sas-theme #divListaArtigos table,
body.sas-theme #divListaCentrosCusto table { width: 100% !important; }
@media (max-width: 700px) {
    body.sas-theme .sas-simple-management > .card > .card-body { padding: 20px !important; }
    body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child { align-items: stretch; }
    body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child h2 { flex: 1 1 100%; font-size: 22px; }
    body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child > a,
    body.sas-theme .sas-simple-management > .card > .card-body > .d-flex:first-child > button { margin-left: 0; width: 100%; }
    body.sas-theme .sas-simple-management .modal-footer .btn { flex: 1 1 auto; }
}

/* Relatórios: filtros, resultados e ações de exportação sem alterar as tabelas DataTables. */
body.sas-theme .sas-reports { margin-top: 20px !important; }
body.sas-theme .sas-reports > .card > .card-body > .d-flex:first-child,
body.sas-theme .sas-reports > .card > .card-body > .mb-4.pb-3.border-bottom:first-child {
    margin-bottom: 24px !important; padding-bottom: 18px !important; border-color: #e5ecf3 !important;
}
body.sas-theme .sas-reports h2.h4 { color: #24364a !important; font-size: 24px; font-weight: 650 !important; letter-spacing: -.4px; }
body.sas-theme .sas-reports .row { min-width: 0; }
body.sas-theme .sas-reports .form-label { margin-bottom: 8px; }
body.sas-theme .sas-reports .d-flex.justify-content-between.align-items-center.mt-4,
body.sas-theme .sas-reports .d-flex.justify-content-between.align-items-center.mt-4.pt-3 {
    gap: 12px; flex-wrap: wrap;
}
body.sas-theme .sas-reports #htmlReportListagem,
body.sas-theme .sas-reports #divTabelaNaoIntegrados,
body.sas-theme .sas-reports #div_resultados,
body.sas-theme .sas-reports #divMapaResidenciaVisualContainer { min-width: 0; }
body.sas-theme .sas-reports .table-responsive { border-radius: 7px; }
body.sas-theme .sas-reports .nav-tabs { margin-top: 4px; }
body.sas-theme .sas-reports .modal-body pre { max-height: 55vh; overflow: auto; padding: 14px; border-radius: 7px; background: #f6f8fb; color: #24364a; }
body.sas-theme .sas-reports .card .card { border-color: #e5ecf3 !important; }
@media (max-width: 700px) {
    body.sas-theme .sas-reports > .card > .card-body { padding: 20px !important; }
    body.sas-theme .sas-reports h2.h4 { font-size: 22px; }
    body.sas-theme .sas-reports .d-flex.justify-content-between.align-items-center.mt-4 > a,
    body.sas-theme .sas-reports .d-flex.justify-content-between.align-items-center.mt-4 > button,
    body.sas-theme .sas-reports #divExportExcel,
    body.sas-theme .sas-reports #divExportar { width: 100%; }
    body.sas-theme .sas-reports #divExportExcel .btn,
    body.sas-theme .sas-reports #divExportar .btn { width: 100%; }
}

/* Página inicial: saudação clara dentro do cartão comum. */
body.sas-theme .sas-home { margin-top: 20px !important; }
body.sas-theme .sas-home-welcome > .card-body { display: flex; align-items: flex-start; gap: 24px; padding: 32px !important; }
body.sas-theme .sas-home-mark {
    display: flex; flex: 0 0 54px; align-items: center; justify-content: center; width: 54px; height: 54px;
    border-radius: 12px; color: #fff; background: #102d49; font-size: 23px; font-weight: 700;
}
body.sas-theme .sas-home-copy { min-width: 0; }
body.sas-theme .sas-home-eyebrow { margin: 0 0 8px; color: #07518b; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
body.sas-theme .sas-home-greeting { margin: 0 0 10px; color: #24364a; font-size: 26px; line-height: 1.25; font-weight: 650; overflow-wrap: anywhere; }
body.sas-theme .sas-home-greeting:empty { display: none; }
body.sas-theme .sas-home-intro { margin: 0 0 8px; color: #40566e; font-size: 15px; }
body.sas-theme .sas-home-description { margin: 0; color: #617488; font-size: 13px; line-height: 1.7; max-width: 650px; }
@media (max-width: 700px) {
    body.sas-theme .sas-home-welcome > .card-body { flex-direction: column; gap: 18px; padding: 24px !important; }
    body.sas-theme .sas-home-greeting { font-size: 23px; }
}

/* Utentes: lista e ficha independentes, sem alterar os IDs nem o HTML dos dados. */
body.sas-theme .sas-utentes { margin-top: 20px !important; }
body.sas-theme .sas-page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
body.sas-theme .sas-section .sas-page-heading,
body.sas-theme .sas-utentes .sas-page-heading { padding-bottom: 18px; border-bottom: 1px solid #e5ecf3; }
/* Mesmo tamanho dos títulos h2.h4 das outras secções (24px / 22px em ecrã estreito). */
body.sas-theme .sas-page-heading h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.4px; font-weight: 650; margin: 0 0 4px; color: #24364a; }
body.sas-theme .sas-page-heading p { margin: 0; color: #607386; font-size: 14px; }
body.sas-theme .sas-page-subtitle { margin: 0; color: #607386; font-size: 14px; }
body.sas-theme .sas-utentes-lista { margin-bottom: 24px; }
body.sas-theme .sas-context-help { background: #f5f8fc; color: #405b73; border: 1px solid #e3ebf3; border-radius: 7px; margin-top: 0; margin-bottom: 24px !important; font-size: 12px; }
body.sas-theme .sas-context-help summary { cursor: pointer; font-weight: 500 !important; }
body.sas-theme #table_utentes tbody td:first-child { font-weight: 600; }
body.sas-theme .sas-utentes .tooltipNew { position: relative; }
body.sas-theme .sas-utentes .tooltiptextNew { right: 0; left: auto; bottom: 100%; margin: 0 0 6px; max-width: 200px; }
body.sas-theme .sas-utente-heading { padding: 4px 0 20px; border-bottom: 1px solid #e8edf3; gap: 16px; }
body.sas-theme .sas-utente-heading h4 { font-size: 20px; font-weight: 600 !important; }
body.sas-theme .sas-utente-ficha > .card-header { border-radius: 10px 10px 0 0; }
body.sas-theme .sas-utente-ficha .nav-tabs { flex-wrap: wrap; overflow: visible; }
body.sas-theme .sas-utentes .tab-pane > p { margin-bottom: 20px; }
body.sas-theme .sas-utente-heading h4, body.sas-theme #div_lista_observacoes { overflow-wrap: anywhere; }
body.sas-theme #div_lista_observacoes .d-flex { flex-wrap: wrap; gap: 8px; }
body.sas-theme #tabObservacoes > .d-flex { flex-wrap: wrap; gap: 12px; }
body.sas-theme #divFotoUtente img { max-width: 100%; height: auto; }

@media (max-width: 1000px) {
    body.sas-theme { --sas-sidebar: 220px; }
    body.sas-theme #wrap { padding: 22px 20px 28px; }
    body.sas-theme #navBar { padding-inline: 20px; }
}
@media (max-width: 700px) {
    body.sas-theme { --sas-header: 64px; }
    body.sas-theme #navBar, body.sas-theme.sas-menu-closed #navBar { left: 64px; padding: 0 12px; gap: 10px; }
    body.sas-theme #content, body.sas-theme #sidebarWrapper.sidebar-closed #content { margin-left: 64px; width: calc(100% - 64px); }
    body.sas-theme #sidebar { box-shadow: 8px 0 24px #102d4926; }
    body.sas-theme #sidebarWrapper:not(.sidebar-closed) #sidebar { top: 64px; height: calc(100vh - 64px); }
    body.sas-theme .sas-app-title { font-size: 12px; }
    body.sas-theme .sas-app-title small { display: none; }
    body.sas-theme #wrap { padding: 18px 12px 24px; }
    body.sas-theme .sas-page-heading { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
    body.sas-theme .sas-page-heading h1 { font-size: 22px; }
    body.sas-theme .sas-page-heading p { font-size: 13px; }
    body.sas-theme .sas-utentes .card-body { padding: 16px !important; }
    body.sas-theme .sas-utente-heading { flex-wrap: wrap; }
    body.sas-theme .sas-utente-ficha .nav-tabs .nav-link { padding: 11px; font-size: 12px; }
    body.sas-theme .modal-dialog { min-width: 0 !important; max-width: calc(100% - 24px); margin: 12px auto; }
    body.sas-theme .modal-header, body.sas-theme .modal-body, body.sas-theme .modal-footer { padding: 18px !important; }
    body.sas-theme #content > footer.footer { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    body.sas-theme #sidebar, body.sas-theme #content, body.sas-theme #navBar { transition: none; }
}
/* Login: composição independente, mantendo o rodapé de financiamento da Master. */
body.sas-theme.sas-login #navBar,
body.sas-theme.sas-login #sidebar,
body.sas-theme.sas-login #breadcrumbContainer { display: none !important; }
body.sas-theme.sas-login #content,
body.sas-theme.sas-login #sidebarWrapper.sidebar-closed #content {
    width: 100%; margin: 0; padding: 0; min-height: 100vh;
}
body.sas-theme.sas-login #wrap { display: flex; padding: 48px 24px; }
body.sas-theme.sas-login #main { display: flex; width: 100%; }
body.sas-theme .sas-login-page { display: flex; align-items: center; justify-content: center; width: 100%; }
body.sas-theme .sas-login-layout {
    display: grid; grid-template-columns: 1.1fr 1fr; width: 940px; max-width: 100%;
    border: 1px solid #dce5ee; border-radius: 20px; overflow: hidden;
    background: #fff; box-shadow: 0 16px 48px #102d4910;
}
body.sas-theme .sas-login-intro {
    padding: 44px; background: #102d49; color: #fff; display: flex; flex-direction: column;
}
body.sas-theme .sas-login-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; letter-spacing: 1px; margin-bottom: 46px; }
body.sas-theme .sas-login-brand strong { font-weight: 400; color: #b8cfe1; }
body.sas-theme .sas-login-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; margin: 0 0 12px; }
body.sas-theme .sas-login-intro .sas-login-eyebrow { color: #b8cfe1; }
body.sas-theme .sas-login-intro h1 { color: #fff; font-family: inherit; font-size: 38px; line-height: 1.18; font-weight: 600; margin: 0 0 20px; letter-spacing: -.8px; }
body.sas-theme .sas-login-description { color: #d1deea; font-size: 14px; line-height: 1.8; margin: 0 0 36px; }
body.sas-theme .sas-login-institution { margin-top: auto; padding-top: 22px; border-top: 1px solid #35516b; color: #b8cfe1; font-size: 12px; line-height: 1.7; }
body.sas-theme .sas-login-card { padding: 56px 44px 36px; align-self: center; min-width: 0; }
body.sas-theme .sas-login-card .sas-login-eyebrow { color: #07518b; }
body.sas-theme .sas-login-card h2 { font-family: inherit; font-size: 28px; font-weight: 600; color: #24364a; margin: 0 0 10px; }
body.sas-theme .sas-login-hint { color: #64778a; font-size: 14px; line-height: 1.6; margin-bottom: 30px; }
body.sas-theme .sas-login-card .form-group { margin-bottom: 20px; }
body.sas-theme .sas-login-card label { display: block; font-size: 13px; font-weight: 600; letter-spacing: normal; text-transform: none; margin-bottom: 8px; }
body.sas-theme .sas-login-card .form-control { height: 46px; padding: 10px 12px; background: #fff; }
body.sas-theme .sas-login-submit { width: 100%; min-height: 46px; margin-top: 6px; }
body.sas-theme .sas-login-submit i { margin-left: 12px; }
body.sas-theme .sas-login-caption { text-align: center; font-size: 11px; color: #718397; margin: 28px 0 0; }
@media (max-width: 700px) {
    body.sas-theme.sas-login #wrap { padding: 24px 16px; }
    body.sas-theme .sas-login-layout { grid-template-columns: 1fr; max-width: 440px; border-radius: 14px; }
    body.sas-theme .sas-login-intro { padding: 24px; }
    body.sas-theme .sas-login-brand { margin-bottom: 22px; font-size: 19px; }
    body.sas-theme .sas-login-intro h1 { font-size: 28px; margin-bottom: 0; }
    body.sas-theme .sas-login-intro h1 br { display: none; }
    body.sas-theme .sas-login-description, body.sas-theme .sas-login-institution { display: none; }
    body.sas-theme .sas-login-card { padding: 28px 24px; }
    body.sas-theme .sas-login-card h2 { font-size: 25px; }
}
/* Candidaturas e reservas: formulários extensos, importações e listas do processo. */
body.sas-theme .sas-candidaturas { margin-top: 20px !important; }
body.sas-theme .sas-candidaturas > .d-flex:first-child,
body.sas-theme .sas-candidaturas > .card > .card-body > .d-flex:first-child {
    gap: 16px; flex-wrap: wrap; margin-bottom: 24px !important;
    padding-bottom: 18px !important; border-color: #e5ecf3 !important;
}
body.sas-theme .sas-candidaturas h2.h4,
body.sas-theme .sas-legacy-migration-title {
    color: #24364a !important; font-size: 24px; line-height: 1.25;
    font-weight: 650 !important; letter-spacing: -.4px;
}
body.sas-theme .sas-candidaturas .card .card { border-color: #e5ecf3 !important; }
body.sas-theme .sas-candidaturas .card-header { border-bottom-color: #e5ecf3 !important; }
body.sas-theme .sas-candidaturas details.alert { border-radius: 8px; }
body.sas-theme .sas-candidaturas details summary { cursor: pointer; }
body.sas-theme .sas-candidaturas .nav-pills,
body.sas-theme .sas-candidaturas .nav-tabs { flex-wrap: wrap; gap: 4px; }
body.sas-theme .sas-candidaturas .tab-content { min-width: 0; }
body.sas-theme .sas-candidaturas .table-responsive,
body.sas-theme .sas-candidaturas #divListaCandidaturas,
body.sas-theme .sas-candidaturas #divListaCandidatos,
body.sas-theme .sas-candidaturas #divListaResultados,
body.sas-theme .sas-candidaturas #divTabelaResultados { min-width: 0; }
body.sas-theme .sas-candidaturas .d-flex.justify-content-between > .btn,
body.sas-theme .sas-candidaturas .d-flex.justify-content-between > a { flex-shrink: 0; }
body.sas-theme .sas-candidaturas .modal-body { overflow-wrap: anywhere; }
body.sas-theme .sas-candidatura-preview #mainForm > .row > div > h3 {
    color: #24364a; font-size: 19px; font-weight: 650; margin: 28px 0 18px;
    padding-bottom: 10px; border-bottom: 1px solid #e5ecf3;
}
body.sas-theme .sas-legacy-migration-title {
    margin: 20px 0 0; padding-bottom: 18px; border-bottom: 1px solid #e5ecf3;
}
body.sas-theme .sas-legacy-migration { margin-top: 0 !important; }
body.sas-theme .sas-legacy-migration .h5IntroDados,
body.sas-theme .sas-legacy-migration .h4DadosUtente,
body.sas-theme .sas-legacy-migration h3,
body.sas-theme .sas-legacy-migration h2 { color: #24364a !important; }
body.sas-theme .sas-legacy-migration .inputVerDadosUtente,
body.sas-theme .sas-legacy-migration select { max-width: 100%; }
@media (max-width: 700px) {
    body.sas-theme .sas-candidaturas > .card > .card-body { padding: 20px !important; }
    body.sas-theme .sas-candidaturas > .d-flex:first-child,
    body.sas-theme .sas-candidaturas > .card > .card-body > .d-flex:first-child { align-items: stretch; }
    body.sas-theme .sas-candidaturas h2.h4,
    body.sas-theme .sas-legacy-migration-title { font-size: 22px; overflow-wrap: anywhere; }
    body.sas-theme .sas-candidaturas > .d-flex:first-child > .btn,
    body.sas-theme .sas-candidaturas > .d-flex:first-child > a,
    body.sas-theme .sas-candidaturas > .card > .card-body > .d-flex:first-child > .btn,
    body.sas-theme .sas-candidaturas > .card > .card-body > .d-flex:first-child > a,
    body.sas-theme .sas-candidaturas #divExportExcel,
    body.sas-theme .sas-candidaturas #divExportExcel .btn { width: 100%; }
    body.sas-theme .sas-candidaturas .card-footer.text-end { text-align: left !important; }
    body.sas-theme .sas-candidaturas .card-footer.text-end .btn { width: 100%; }
    body.sas-theme .sas-candidaturas .nav-pills .nav-link,
    body.sas-theme .sas-candidaturas .nav-tabs .nav-link { padding: 10px 11px; font-size: 12px; }
    body.sas-theme .sas-candidaturas .modal-footer .btn { flex: 1 1 auto; }
    body.sas-theme .sas-candidatura-preview .card-body { padding: 18px !important; }
    body.sas-theme .sas-candidatura-preview #mainForm > .row > div > h3 { font-size: 18px; }
    body.sas-theme .sas-legacy-migration .col-lg-6 { width: 100%; }
}
@media print {
    body.sas-theme #sidebar, body.sas-theme #navBar { display: none !important; }
    body.sas-theme #content, body.sas-theme #sidebarWrapper.sidebar-closed #content { width: 100%; margin: 0; padding: 0; }
}

/* Utilidade do Bootstrap 5 que o Bootstrap 4.2.1 carregado não define (substitui style="color: black"). */
body.sas-theme .text-black { color: #000 !important; }

/* Cartões de KPI (ReportsEstatisticas) — antes em style="" inline, mesmos valores. */
body.sas-theme .sas-kpi-icon { width: 48px; height: 48px; }
body.sas-theme .sas-kpi-icon-primary { background-color: rgba(2, 62, 115, 0.1); color: #023e73; }
body.sas-theme .sas-kpi-icon-success { background-color: rgba(25, 135, 84, 0.1); color: #198754; }
body.sas-theme .sas-kpi-icon-info { background-color: rgba(13, 202, 240, 0.1); color: #0dcaf0; }
body.sas-theme .sas-kpi-icon-danger { background-color: rgba(220, 53, 69, 0.1); color: #dc3545; }
body.sas-theme .sas-kpi-icon-warning { background-color: rgba(255, 193, 7, 0.1); color: #ffc107; }
body.sas-theme .sas-kpi-icon-secondary { background-color: rgba(108, 117, 125, 0.1); color: #6c757d; }
body.sas-theme .sas-kpi-label { font-size: 0.75rem; letter-spacing: 0.5px; }
body.sas-theme .sas-kpi-valor-compacto { font-size: 1.15rem !important; }

/* Utilidades do Bootstrap 5 que o Bootstrap 4.2.1 carregado não define (até 2026-10-28 os ~1800
   usos de fw-bold não faziam nada). Mesma especificidade e valores do BS5, sem o prefixo
   body.sas-theme: as regras do tema que já fixam peso/tamanho continuam a ganhar. */
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-normal { font-weight: 400 !important; }
.fs-4 { font-size: calc(1.275rem + .3vw) !important; }
.fs-5 { font-size: 1.25rem !important; }
.fs-6 { font-size: 1rem !important; }
.opacity-75 { opacity: .75 !important; }
@media (min-width: 1200px) {
    .fs-4 { font-size: 1.5rem !important; }
}

/* Adaptações ao PortalAlunos. */
body.sas-theme .navBarAPPProfileIconOnClick:focus-within .navBarAPPProfileIconContent { display: grid; visibility: visible; opacity: 1; }
body.sas-theme .navBarAPPProfileIconOnClick > span { color: #275779; font-size: 20px; }
body.sas-theme.sem-menu #navBar { left: 0; }
body.sas-theme.sem-menu #content { margin-left: 0; width: 100%; }

body.aluno-entrada { min-height: 100vh; display: flex; flex-direction: column; }
body.aluno-entrada .sas-login-page { flex: 1; padding: 48px 24px; }
body.aluno-entrada .sas-login-submit { display: block; padding: 12px; }
body.aluno-entrada > footer.footer { position: static; height: auto; margin: 0; padding: 22px; background: #fff; border-top: 1px solid #e1e7ef; }
@media (max-width: 700px) { body.aluno-entrada .sas-login-page { padding: 24px 16px; } }

/* Uma superfície por página; secções e listagens partilham o mesmo cartão. */
body.sas-theme .pagina-conteudo {
    background: #fff;
    border: 1px solid #e1e7ef;
    border-radius: 10px;
    box-shadow: 0 3px 12px #12334e04;
    padding: 24px;
}
body.sas-theme .pagina-conteudo .card {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
}
body.sas-theme .pagina-conteudo .card > .card-body {
    padding: 0 !important;
}
body.sas-theme .pagina-conteudo .card > .card-header {
    padding-left: 0;
    padding-right: 0;
    background: transparent !important;
}
@media (max-width: 700px) {
    body.sas-theme .pagina-conteudo { padding: 16px; }
}
/* Separação entre os diferentes tipos de aviso na página inicial. */
body.sas-theme .lista-avisos > div + div { border-top: 1px solid #e1e7ef; padding-top: 24px; }
