/* Shared panel refinements: preserve the template, support keyboard and touch use. */
.module-icon { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px; flex-shrink: 0; font-size: 32px; }
.module-card { margin-bottom: 24px; }
.module-card > .card { margin-bottom: 0 !important; }
.module-card .module-heading { min-height: 100px; }
.module-card .module-actions .btn { min-height: 44px; }
.module-attendance-stats { display: flex; flex-wrap: wrap; gap: 12px; }
.module-attendance-stats li { flex: 1; }
.module-attendance-stats strong { display: block; font-size: 20px; }
.sidebar-area .menu-title-text { color: #5c636a; }
.sidebar-area .hot.tag { background: #c2410c; color: #fff; }
.pantry-panel .text-success, .pantry-panel .btn-outline-success { color: #1e7a34 !important; }
.pantry-panel .text-warning { color: #9a5b00 !important; }
.pantry-panel .btn-warning { color: #212529 !important; }
.pantry-panel .btn-info { background: #0b5ed7; border-color: #0b5ed7; color: #fff !important; }
.pantry-panel .btn-outline-success:hover, .pantry-panel .btn-outline-success:focus { background: #1e7a34; color: #fff !important; }
.pantry-panel .bg-success, .pantry-panel .bg-primary { color: #fff !important; }
.pantry-panel .bg-success { background-color: #1e7a34 !important; }
.pantry-panel .bg-warning { color: #212529 !important; }
.pantry-panel .expiry-legend-green { background: #e3f2e5; color: #185f29; }
.pantry-panel .expiry-legend-neutral { background: #e9ecef; color: #343a40; }
.pantry-panel .text-success .text-white { color: #fff !important; }
:where(a, button, input, select, textarea):focus-visible { outline: 3px solid #0b5ed7; outline-offset: 3px; }
.header-area button { min-width: 44px; min-height: 44px; }
.mobile-back-link a { min-height: 44px; overflow-wrap: anywhere; }
/* Keep legacy icon actions usable without requiring changes to their visible icons. */
.main-content-container :where(a, button):has(> .material-symbols-outlined:only-child),
.main-content-container :where(a, button):has(> i:only-child) { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 575.98px) {
    .header-area .row { flex-direction: row; flex-wrap: nowrap; }
    .header-area .row > div:first-child { flex: 0 0 52px; width: 52px; }
    .header-area .row > div:last-child { flex: 1; width: auto; min-width: 0; }
    .header-area .left-header-content ul { justify-content: flex-start !important; }
    .header-area .right-header-content { margin-top: 0 !important; }
    .header-area .right-header-content > ul { flex-wrap: nowrap; justify-content: flex-end !important; gap: 0; }
    .header-area .header-right-item { margin: 0; }
    .header-right-item:has(.fullscreen-btn) { display: none; }
    .header-area .admin-profile .dropdown-toggle > .flex-grow-1 { display: none; }
    nav[aria-label="breadcrumb"] { display: none !important; }
    .table-src-form { width: 100%; max-width: none !important; flex-basis: 100%; }
    .table-src-form input { width: 100%; }
    .main-content-container .btn, .main-content-container .btn-sm,
    .main-content-container .pagination .page-link { min-height: 44px; min-width: 44px; }
    .main-content-container .form-check { display: flex; align-items: center; gap: 8px; min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
    .main-content-container .form-check:has(> input) { cursor: pointer; }
    .main-content-container .form-check-input { width: 20px; height: 20px; min-width: 20px; min-height: 20px; flex-shrink: 0; }
    .main-content-container .form-check-label { min-height: 44px; display: inline-flex; align-items: center; }
    .modules-container > .col-xxl-3.col-lg-4.col-sm-6.module-card { flex: 0 0 50%; max-width: 50%; margin-bottom: 12px; padding-left: 6px; padding-right: 6px; }
    .modules-container > .module-card.module-card-attendance { flex: 0 0 100%; max-width: 100%; }
    .module-card .module-heading.d-flex { flex-direction: row; text-align: left; align-items: center; gap: 8px !important; padding: 12px 10px !important; min-height: 60px; }
    .module-card .module-icon { width: 32px; height: 40px; font-size: 26px; }
    .module-card .module-heading h2 { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
    .module-card .card-body.d-flex { flex-direction: column; text-align: left; align-items: stretch; padding: 0 10px 10px !important; }
    .module-card .module-stats { min-height: 32px; font-size: 12px; line-height: 1.4; margin-bottom: 8px !important; }
    .module-card .module-actions.d-flex { flex-direction: row; flex-wrap: nowrap !important; align-items: stretch; text-align: center; gap: 6px !important; }
    .module-card .module-actions > * { flex: 1; min-width: 0; width: auto !important; }
    .module-card .module-actions .btn { width: 100%; padding: 8px 4px !important; font-size: 11.5px; line-height: 1.4; }
    .module-card .module-attendance-stats { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 8px; text-align: center; min-height: 0; }
    .module-card-attendance .module-actions.d-flex { flex-direction: row; }
    .module-card-attendance .module-actions > * { flex: 1; }
}
.pantry-panel .btn-outline-info { color: #0b5ed7; border-color: #0b5ed7; }
.pantry-panel .btn-outline-info:hover, .pantry-panel .btn-outline-info:focus { color: #fff; background: #0b5ed7; }
.pantry-panel .card.bg-warning, .pantry-panel .card.bg-warning .text-white,
.pantry-panel .card.bg-warning .text-white-50 { color: #212529 !important; }
.pantry-panel .card.bg-info { background: #0b5ed7 !important; }
.pantry-panel .card:is(.bg-success, .bg-info, .bg-primary) .text-white-50 { color: #fff !important; }
/* Template selectors are more specific than Bootstrap utilities. */
.sidebar-area .menu-vertical .menu-title .menu-title-text { color: #5c636a !important; }
.sidebar-area .menu-link .hot.tag { background: #c2410c !important; color: #fff !important; }
.sidebar-area .anydesk-button { background: #b42318; }
.breadcrumb .breadcrumb-item.active, .breadcrumb .breadcrumb-item.active > span { color: #495057 !important; }
.main-content .text-body { color: #475569 !important; }
.main-content .text-primary { color: #5148d8 !important; }
.footer-area .text-primary-div { color: #7e35bf !important; }
/* Accessible semantic palette across the existing panel components. */
body:not([data-theme="dark"]) { --bs-body-color: #475569; --bs-body-color-rgb: 71, 85, 105; color: #475569; }
body:not([data-theme="dark"]) .main-content .text-muted { color: #596579 !important; }
body:not([data-theme="dark"]) .main-content .text-success { color: #1e7a34 !important; }
body:not([data-theme="dark"]) .main-content .text-warning { color: #8a5000 !important; }
body:not([data-theme="dark"]) .main-content .text-danger { color: #b42318 !important; }
body:not([data-theme="dark"]) .main-content .text-info { color: #075985 !important; }
body:not([data-theme="dark"]) .main-content .bg-success { background-color: #1e7a34 !important; }
body:not([data-theme="dark"]) .main-content .bg-danger { background-color: #b42318 !important; }
body:not([data-theme="dark"]) .main-content .badge.bg-info { background-color: #075985 !important; color: #fff !important; }
.main-content .btn-outline-primary { --bs-btn-color: #5148d8; --bs-btn-border-color: #5148d8; --bs-btn-hover-bg: #5148d8; --bs-btn-active-bg: #5148d8; }
.main-content .btn-outline-success { --bs-btn-color: #1e7a34; --bs-btn-border-color: #1e7a34; --bs-btn-hover-bg: #1e7a34; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1e7a34; --bs-btn-active-color: #fff; }
.main-content .btn-outline-warning { --bs-btn-color: #8a5000; --bs-btn-border-color: #8a5000; --bs-btn-hover-bg: #8a5000; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #8a5000; --bs-btn-active-color: #fff; }
.main-content .btn-outline-danger { --bs-btn-color: #b42318; --bs-btn-border-color: #b42318; --bs-btn-hover-bg: #b42318; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #b42318; --bs-btn-active-color: #fff; }
.main-content .btn-outline-info { --bs-btn-color: #075985; --bs-btn-border-color: #075985; --bs-btn-hover-bg: #075985; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #075985; --bs-btn-active-color: #fff; }
.main-content .btn-danger { --bs-btn-color: #fff; --bs-btn-bg: #b42318; --bs-btn-border-color: #b42318; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #921c13; --bs-btn-hover-border-color: #921c13; }
.main-content .btn-success { --bs-btn-color: #fff; --bs-btn-bg: #1e7a34; --bs-btn-border-color: #1e7a34; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #185f29; --bs-btn-hover-border-color: #185f29; }
.fc .fc-day-other .fc-daygrid-day-top { opacity: 1; }
.fc .fc-day-other .fc-daygrid-day-number { color: #596579; }
/* Retain readable foregrounds when the existing dark theme is selected. */
body[data-theme="dark"] .main-content .text-body,
body[data-theme="dark"] .main-content .text-muted { color: #cbd5e1 !important; }
body[data-theme="dark"] .main-content .text-primary { color: #b6b1ff !important; }
body[data-theme="dark"] .pantry-panel .text-success { color: #86efac !important; }
body[data-theme="dark"] .pantry-panel .text-warning { color: #fcd34d !important; }
body[data-theme="dark"] .sidebar-area .menu-vertical .menu-title .menu-title-text,
body[sidebar-dark-light-data-theme="sidebar-dark"] .sidebar-area .menu-vertical .menu-title .menu-title-text { color: #cbd5e1 !important; }
body[data-theme="dark"] .breadcrumb .breadcrumb-item.active,
body[data-theme="dark"] .breadcrumb .breadcrumb-item.active > span { color: #cbd5e1 !important; }
body[data-theme="dark"] .main-content .btn-outline-primary { --bs-btn-color: #b6b1ff; }
body[data-theme="dark"] .main-content .btn-outline-success { --bs-btn-color: #86efac; }
body[data-theme="dark"] .main-content .btn-outline-warning { --bs-btn-color: #fcd34d; }
body[data-theme="dark"] .main-content .btn-outline-danger { --bs-btn-color: #fda4af; }
body[data-theme="dark"] .main-content .btn-outline-info { --bs-btn-color: #7dd3fc; }

@media (max-width: 575.98px) {
    .modules-container > .col-xxl-3.col-lg-4.col-sm-6.module-card.module-card-attendance { flex: 0 0 100%; max-width: 100%; }
}
/* Rendering cards immediately also avoids repeatedly fading text during navigation. */
.modules-container .module-card { animation: none !important; }
body:not([data-theme="dark"]) .mobile-back-link a,
body:not([data-theme="dark"]) .breadcrumb a,
body:not([data-theme="dark"]) #pantry-search-form > a { color: #475569; }
body:not([data-theme="dark"]) .main-content .form-text { color: #596579; }
body[data-theme="dark"] .main-content .form-text { color: #cbd5e1; }
@media (max-width: 575.98px) {
    .module-card .module-actions .btn { white-space: nowrap; }
}
/* Additional active module views: live attendance, calendar and nutrition reports. */
body:not([data-theme="dark"]) .main-content .bg-light .text-muted { color: #475569 !important; }
body:not([data-theme="dark"]) .main-content .bg-light .text-success { color: #185f29 !important; }
body:not([data-theme="dark"]) .main-content .bg-light strong { color: #334155 !important; }
body:not([data-theme="dark"]) .toast-header:not(.text-white),
body:not([data-theme="dark"]) .toast-header:not(.text-white) small,
body:not([data-theme="dark"]) .toast-header:not(.text-white) strong { color: #475569 !important; }
body:not([data-theme="dark"]) .toast-header:not(.text-white) .text-muted { color: #596579 !important; }
body:not([data-theme="dark"]) #connectionStatus:not(.disconnected):not(.polling) { background-color: #1e7a34; }
body:not([data-theme="dark"]) .main-content code { color: #9d1d59; }
body:not([data-theme="dark"]) .main-content .card.bg-info { background-color: #075985 !important; }
body:not([data-theme="dark"]) .main-content .card:is(.bg-success, .bg-info, .bg-primary) .text-white-50 { color: #fff !important; }
.toast-header.bg-success { background-color: #1e7a34 !important; color: #fff !important; }
.toast-header.bg-info { background-color: #075985 !important; color: #fff !important; }
.toast-header.bg-warning.text-white { color: #212529 !important; }
.toast-header.bg-warning .btn-close-white { filter: none; }
/* Permissions retain aligned columns and visible controls in every group. */
.permissions-table { table-layout: fixed; width: 100%; min-width: 650px; }
.permissions-table .permission-module-column { width: 30%; }
.permissions-table .permission-action-column { width: 14%; }
.permissions-table th, .permissions-table td { white-space: normal; overflow-wrap: break-word; }
.permissions-table thead th:not(:first-child), .permissions-table td { text-align: center; }
.permissions-table .permission-checkbox-target { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer; }
.permissions-table .form-check-input { position: static; float: none; margin: 0; width: 20px; height: 20px; min-width: 20px; min-height: 20px; border: 2px solid #596579; background-color: #fff; opacity: 1; }
.permissions-table .form-check-input:checked { background-color: #5148d8; border-color: #5148d8; }
.permissions-table .form-check-input:disabled { opacity: .65; border-color: #596579; cursor: not-allowed; }
.permissions-table .form-check-input:focus-visible { outline: 3px solid #5148d8; outline-offset: 3px; }
.payment-row-actions { flex-wrap: wrap; }
.payment-more-panel { gap: 4px; }
@media (min-width: 576px) {
    .payment-more-panel { position: static !important; transform: none !important; float: none; padding: 0; border: 0; min-width: 0; width: auto !important; background: transparent; box-shadow: none; }
}
@media (max-width: 575.98px) {
    .child-search-form, .child-search-form > .d-flex, .child-search-form .position-relative { width: 100%; min-width: 0; max-width: none; }
    .child-search-form input[name="search"] { width: 100%; min-width: 0; padding-right: 58px !important; min-height: 48px; }
    .child-search-form button[type="submit"] { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .payments-toolbar { padding: 16px !important; align-items: stretch !important; }
    .payment-period-group, .payment-period-filter, .payment-mobile-actions { width: 100%; min-width: 0; }
    .payment-period-filter { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px !important; }
    .payment-period-filter > label, .payment-period-filter #apply-filter { grid-column: 1 / -1; }
    .payment-period-filter select { width: 100% !important; min-width: 0; min-height: 44px; }
    .payment-mobile-actions { justify-content: space-between; }
    .payment-mobile-actions .btn { white-space: nowrap; }
    .payment-new-menu { flex: 1; }
    .payment-new-menu > .btn { width: 100%; }
    .payment-new-menu .dropdown-menu { width: 100% !important; min-width: 0; max-width: none; left: 0 !important; right: auto !important; }
    .payment-new-menu .dropdown-item { min-height: 44px; display: flex; align-items: center; white-space: normal; }
    .payments-list-area, .payments-list-container { overflow: visible !important; min-width: 0 !important; width: 100%; }
    #payments-table, #payments-table > thead, #payments-table > tbody { display: block; width: 100% !important; min-width: 0 !important; }
    #payments-table > thead > tr { display: block; }
    #payments-table > thead th:not(.payment-select-heading) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    #payments-table .payment-select-heading { display: flex; align-items: center; gap: 8px; width: auto !important; min-height: 44px; padding: 8px 16px; border: 0; }
    #payments-table .payment-select-heading label { min-height: 44px; display: flex; align-items: center; }
    #payments-table > tbody > tr.payment-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 8px; padding: 16px; margin: 0 12px 16px; border: 1px solid #d5d9e2; border-radius: 12px; background: #fff; }
    #payments-table > tbody > tr.payment-card > .payment-cell { grid-column: 1 / -1; display: block; padding: 0; border: 0; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
    #payments-table > tbody > tr.payment-card > .payment-cell::before { content: attr(data-label) ': '; color: #475569; font-weight: 500; }
    #payments-table > tbody > tr.payment-card > .payment-cell-child { grid-column: 1; order: 0; font-weight: 700; }
    #payments-table > tbody > tr.payment-card > .payment-cell-status { grid-column: 2; order: 1; text-align: right; }
    #payments-table > tbody > tr.payment-card > .payment-cell-child::before,
    #payments-table > tbody > tr.payment-card > .payment-cell-status::before,
    #payments-table > tbody > tr.payment-card > .payment-cell-title::before,
    #payments-table > tbody > tr.payment-card > .payment-cell-actions::before { content: none; }
    #payments-table > tbody > tr.payment-card > .payment-cell-title { order: 2; font-weight: 600; }
    #payments-table > tbody > tr.payment-card > .payment-cell-amount { order: 3; }
    #payments-table > tbody > tr.payment-card > .payment-cell-due { order: 4; }
    #payments-table > tbody > tr.payment-card > .payment-cell-paid { order: 5; }
    #payments-table > tbody > tr.payment-card > .payment-cell-paid-date { order: 6; }
    #payments-table > tbody > tr.payment-card > .payment-cell-read { order: 7; }
    #payments-table > tbody > tr.payment-card > .payment-cell-select { order: 8; display: flex; align-items: center; gap: 8px; }
    #payments-table > tbody > tr.payment-card > .payment-cell-number { order: 9; color: #596579; font-size: 12px; }
    #payments-table > tbody > tr.payment-card > .payment-cell-actions { order: 10; padding-top: 10px; border-top: 1px solid #e2e8f0; }
    .payment-selection-target { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
    .payment-selection-target .form-check-input { margin: 0; float: none; min-width: 20px; min-height: 20px; width: 20px; height: 20px; }
    .payment-row-actions { flex-wrap: nowrap; gap: 6px !important; }
    .payment-row-actions > .btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px !important; white-space: nowrap; font-size: 13px; }
    .payment-more-actions { margin-left: auto; }
    .payment-more-panel { width: min(240px, calc(100vw - 32px)) !important; min-width: 0; padding: 8px; }
    .payment-more-panel .btn, .payment-more-panel form { width: 100%; }
    .payment-more-panel .btn { display: flex; align-items: center; justify-content: flex-start; gap: 8px; margin-bottom: 6px; padding: 8px !important; white-space: normal; }
    .payment-items > summary { min-height: 44px; display: flex; align-items: center; }
    #payments-table .payment-items .table { min-width: 0 !important; width: 100% !important; table-layout: fixed; }
    #payments-table .payment-items th, #payments-table .payment-items td { padding: 6px 4px; white-space: normal !important; overflow-wrap: anywhere; font-size: 11px; }
    #bulk-actions-bar { flex-wrap: wrap; }
}
