/*!
 * rabdash-mobile.css: RabDash's own stylesheet for phone and tablet layouts.
 *
 * Load LAST (after sb-admin-2.min.css and the DataTables CSS) in both layouts.
 * Desktop (>= 992px) is unchanged. Below that the site keeps the desktop
 * design: red sidebar on the left, white topbar. The sidebar is shown in its
 * slim icon form (the same as desktop's minimised "<" state), with submenus
 * flying out beside it.
 *   < 992px  slim sidebar + landing-page spacing (phones and tablets)
 *   < 768px  content tweaks (forms, tables, modals, auth), phones only
 * Keep the breakpoints in rabdash-mobile.js in sync.
 *
 * Structure:
 *   1. Global (all widths): additive classes only
 *   2. Slim sidebar and topbar
 *   3. Content: spacing, cards, alerts
 *   4. Forms: touch-sized inputs, sticky submit bar
 *   5. Data tables: DataTables controls, full-screen edit modals
 *   6. Home dashboard (styled in home2.blade.php)
 *   7. Landing (welcome) page
 *   8. Auth pages (login / register / passwords)
 *   9. Analytics pages (overflow guards only)
 */

:root {
    --rd-red: #e74a3b;
    --rd-safe-bottom: env(safe-area-inset-bottom, 0px);
    --rd-rail-w: 6.5rem;
}

/* ---------------------------------------------------------------------
 * 1. Global
 * ------------------------------------------------------------------- */

/* Fluid embed wrapper for third-party iframes (Facebook page plugin). */
.rd-embed {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.rd-embed iframe {
    display: block;
    width: 100% !important;
    max-width: 500px;
    border: 0;
}

/* Form5 illness checklist labels (was repeated inline styles). */
.rd-check-label {
    font-size: 1.1em;
    display: inline-block;
    width: 100%;
}

/* =====================================================================
 * 2. Slim sidebar: phones and tablets (< 992px)
 *
 * Tablets (768-991px): rabdash-mobile.js starts the sidebar minimised
 * (.toggled), which is sb-admin-2's own desktop icon sidebar; "<" still
 * expands it. Phones (< 768px): sb-admin-2 already draws the sidebar
 * slim; the rules below make its submenus fly out instead of expanding
 * inside the narrow column.
 * =================================================================== */
@media (max-width: 991.98px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        -webkit-tap-highlight-color: rgba(231, 74, 59, .15);
    }

    /* Flyout submenus: comfortable tap targets, above page content. */
    #accordionSidebar .nav-item .collapse .collapse-inner {
        min-width: 12rem;
    }

    #accordionSidebar .nav-item .collapse .collapse-inner .collapse-item {
        padding-top: .7rem;
        padding-bottom: .7rem;
    }

    #wrapper #content-wrapper {
        /* sb-admin uses overflow-x:hidden here, which turns the wrapper into
           a scroll container and breaks position:sticky inside it (the
           sticky submit bar). clip hides overflow without that side effect. */
        overflow-x: clip;
        min-width: 0;
    }
}

@media (max-width: 767.98px) {
    /* This project's sb-admin-2.min.css lays the sidebar OVER the page below
       576px (position:absolute under the topbar), so content slid beneath
       it. Keep it in its own column beside the content, sticky, exactly as
       desktop does. z-index above the sticky topbar so flyouts aren't
       covered (they never overlap the topbar's column otherwise). */
    #accordionSidebar.sidebar {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        height: -webkit-fit-content;
        height: fit-content;
        z-index: 1031;
    }

    /* The layout's inline style forces submenus inline for the full-width
       desktop sidebar (:not(.toggled)); on phones the un-toggled sidebar is
       the slim one, so fly them out beside it like desktop's minimised
       sidebar does. */
    #accordionSidebar:not(.toggled) .nav-item {
        position: relative;
    }

    #accordionSidebar:not(.toggled) .nav-item .collapse {
        position: absolute !important;
        left: calc(var(--rd-rail-w) + .5rem) !important;
        top: 2px !important;
        z-index: 1060;
    }

    #accordionSidebar:not(.toggled) .nav-item .collapse .collapse-inner {
        box-shadow: 0 .25rem 1.75rem rgba(58, 59, 69, .25);
    }

    /* Topbar: compact and kept in view while scrolling; same white bar. */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        height: 3.5rem !important;
        margin-bottom: 1rem !important;
        padding: 0 .5rem;
    }

    .topbar #sidebarToggleTop {
        width: 44px;
        height: 44px;
        margin-right: .25rem !important;
        color: var(--rd-red);
    }

    .topbar .navbar-nav,
    .topbar .navbar-nav .nav-item {
        display: flex;
        align-items: center;
        height: 100%;
    }

    .topbar .nav-item .nav-link {
        min-width: 44px;
        min-height: 44px;
        height: auto !important;
        padding: 0 .25rem !important;
        justify-content: center;
    }

    .topbar .dropdown-menu .dropdown-item {
        padding-top: .75rem;
        padding-bottom: .75rem;
    }

    .scroll-to-top {
        right: .75rem;
        bottom: calc(.75rem + var(--rd-safe-bottom));
    }

    footer.sticky-footer {
        padding: 1.25rem 0;
    }
}


/* =====================================================================
 * Content: phones only (< 768px)
 * =================================================================== */
@media (max-width: 767.98px) {

    /* -----------------------------------------------------------------
     * 3. Content
     * --------------------------------------------------------------- */
    #content > .container-fluid {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    #content .container {
        padding-left: 0;
        padding-right: 0;
    }

    /* Cards placed directly in a .row (common in forms/tables): full width,
       no extra BS5 gutter padding inside the card border. */
    #content .row > .card {
        flex: 1 1 100%;
        padding-left: 0;
        padding-right: 0;
        margin-left: .75rem;
        margin-right: .75rem;
        width: calc(100% - 1.5rem);
    }

    #content .card-header {
        padding: .85rem 1rem;
    }

    #content .card-header h6 {
        font-size: 1rem;
        line-height: 1.3;
    }

    #content .card-body {
        padding: 1rem;
    }

    #content h1.h3 {
        font-size: 1.35rem;
        margin-bottom: 1rem !important;
    }

    .alert {
        font-size: .95rem;
    }

    .alert-dismissible {
        padding-right: 3rem;
    }

    .alert-dismissible .close {
        padding: .65rem 1rem;
    }

    /* Bigger tap targets for generic buttons. */
    #content .btn:not(.btn-sm):not(.btn-link):not(.close) {
        min-height: 44px;
    }

    /* Media never wider than the screen. */
    #content img,
    #content video,
    #content iframe {
        max-width: 100%;
    }

    /* -----------------------------------------------------------------
     * 4. Forms
     * --------------------------------------------------------------- */
    #content .pl-lg-4,
    .modal .pl-lg-4 {
        padding-left: 0 !important;
    }

    /* 16px text stops iOS Safari zooming in when an input is focused. */
    #content .form-control,
    #content .form-select,
    #content .custom-select,
    .modal .form-control,
    .modal .form-select,
    .modal .custom-select {
        min-height: 46px;
        font-size: 16px;
    }

    #content textarea.form-control,
    .modal textarea.form-control {
        min-height: 96px;
    }

    #content input[type="date"].form-control,
    #content input[type="time"].form-control,
    .modal input[type="date"].form-control,
    .modal input[type="time"].form-control {
        -webkit-appearance: none;
        appearance: none;
        line-height: 1.5;
    }

    #content .form-group,
    .modal .form-group {
        margin-bottom: 1rem;
    }

    #content .form-control-label,
    #content .form-label,
    .modal .form-control-label,
    .modal .form-label {
        font-size: .95rem;
        font-weight: 600;
        margin-bottom: .35rem;
    }

    /* Checkbox / radio rows: whole label is a comfortable target. */
    #content .rd-check-label,
    #content label.checkbox {
        display: flex !important;
        align-items: center;
        gap: .6rem;
        min-height: 44px;
        margin: 0;
        padding: .35rem 0;
    }

    #content input[type="checkbox"],
    #content input[type="radio"] {
        width: 1.25rem;
        height: 1.25rem;
        flex: 0 0 auto;
        accent-color: var(--rd-red);
    }

    #content .custom-control {
        min-height: 2rem;
        padding-left: 2rem;
    }

    #content .custom-control-label {
        padding-top: .1rem;
    }

    #content .custom-control-label::before,
    #content .custom-control-label::after {
        left: -2rem;
        width: 1.35rem;
        height: 1.35rem;
    }

    /* Upload rows: stack the button above the file picker. */
    #content .input-group:has(.custom-file) {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
    }

    #content .input-group:has(.custom-file) > .input-group-prepend,
    #content .input-group:has(.custom-file) > .custom-file {
        width: 100%;
        margin: 0;
    }

    #content .input-group:has(.custom-file) .btn,
    #content .input-group:has(.custom-file) .custom-file-label {
        width: 100%;
        border-radius: .35rem !important;
    }

    #content .input-group:has(.custom-file) > .input-group-prepend {
        order: 2;
    }

    #content .custom-file,
    #content .custom-file-input,
    #content .custom-file-label {
        height: 46px;
    }

    #content .custom-file-label,
    #content .custom-file-label::after {
        display: flex;
        align-items: center;
        height: 46px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* Sticky submit bar: stays reachable at the bottom of long forms. */
    .rd-form-actions {
        position: sticky;
        bottom: var(--rd-safe-bottom);
        z-index: 20;
        /* Bleed exactly to the card's edges: the negative margins must equal
           the phone .card-body padding (.75rem, set at the end of this
           file), or the bar overhangs the card and leaves a seam. */
        margin: .75rem -.75rem -.75rem;
        padding: .75rem !important;
        background: rgba(255, 255, 255, .96);
        border-top: 1px solid #e3e6f0;
        box-shadow: 0 -.35rem 1rem rgba(58, 59, 69, .08);
        border-radius: 0 0 .35rem .35rem;
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
    }

    /* The wrapper also carries .pl-lg-4, whose phone reset (#content
       .pl-lg-4 { padding-left: 0 }) outranked the padding above and pushed
       the Submit button off-centre. */
    #content .rd-form-actions.pl-lg-4 {
        padding-left: .75rem !important;
    }

    .rd-form-actions .row {
        margin: 0;
    }

    .rd-form-actions .col {
        padding: 0;
    }

    .rd-form-actions .btn {
        display: block;
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
        font-weight: 700;
    }

    /* Validation: make the problem obvious on a small screen. */
    #content .invalid-feedback {
        font-size: .875rem;
    }

    #content .alert-danger ul {
        padding-left: 1.1rem !important;
    }

    /* -----------------------------------------------------------------
     * 5. Data tables
     * --------------------------------------------------------------- */

    /* Action row above each table (Add Data / Download Template). */
    #content .card > .container.mt-5 {
        margin-top: 1rem !important;
        padding: 0 1rem;
    }

    /* The <br><br> spacers between the action buttons and the table leave a
       big empty gap on a phone. */
    #content .card > .container.mt-5 > br {
        display: none;
    }

    #content .card > .container.mt-5 > .table-responsive,
    #content .card > .container.mt-5 > .dataTables_wrapper {
        margin-top: 1rem;
    }

    #content #create_record,
    #content #download_template {
        width: 100%;
        margin-bottom: .5rem;
    }

    #content a:has(> #download_template) {
        display: block;
    }

    /* DataTables controls: export buttons in one swipeable row, then a
       full-width search box, then the table. */
    div.dataTables_wrapper div.dt-buttons {
        display: flex;
        flex-wrap: nowrap;
        gap: .5rem;
        float: none;
        width: 100%;
        margin: 0 0 .75rem;
        padding-bottom: .25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    div.dataTables_wrapper div.dt-buttons::-webkit-scrollbar {
        display: none;
    }

    div.dataTables_wrapper div.dt-buttons > .btn,
    div.dataTables_wrapper div.dt-buttons > .btn-group {
        flex: 1 0 auto;
        min-height: 44px;
        margin: 0 !important;
        border-radius: .35rem !important;
        white-space: nowrap;
    }

    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_length {
        float: none;
        width: 100%;
        text-align: left !important;
        margin-bottom: .5rem;
    }

    div.dataTables_wrapper div.dataTables_filter label {
        display: flex;
        align-items: center;
        gap: .5rem;
        width: 100%;
        margin: 0;
        font-weight: 600;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        min-height: 44px;
        margin-left: 0 !important;
        font-size: 16px;
    }

    div.dataTables_wrapper div.dataTables_length label {
        display: flex;
        align-items: center;
        gap: .5rem;
        margin: 0;
    }

    div.dataTables_wrapper div.dataTables_length select {
        min-height: 40px;
        width: auto;
        font-size: 16px;
    }

    div.dataTables_wrapper div.dataTables_info {
        padding-top: .75rem;
        text-align: center;
        white-space: normal;
        font-size: .85rem;
    }

    div.dataTables_wrapper div.dataTables_paginate {
        margin-top: .5rem;
    }

    div.dataTables_wrapper div.dataTables_paginate ul.pagination {
        justify-content: center !important;
        flex-wrap: wrap;
        gap: .25rem;
    }

    div.dataTables_wrapper div.dataTables_paginate .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    div.dataTables_wrapper div.dataTables_processing {
        z-index: 5;
    }

    /* The table itself: Responsive extension hides overflow columns;
       tap the first cell (+) to see them. */
    #content .table-responsive {
        overflow-x: visible;
    }

    #content table.dataTable {
        font-size: .9rem;
    }

    #content table.dataTable > tbody > tr > td,
    #content table.dataTable > thead > tr > th {
        padding: .65rem .6rem;
        vertical-align: middle;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
        padding-left: 2.1rem !important;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
        width: 1.1rem;
        height: 1.1rem;
        line-height: 1.1rem;
        left: .5rem;
        margin-top: -0.55rem;
        top: 50%;
        border: 0;
        border-radius: 50%;
        box-shadow: none;
        background-color: var(--rd-red);
        font-size: .95rem;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control::before {
        background-color: #858796;
    }

    /* Expanded detail rows: label / value stacked like a record card. */
    table.dataTable > tbody > tr.child {
        background: #f8f9fc;
    }

    table.dataTable > tbody > tr.child ul.dtr-details {
        display: block;
        width: 100%;
    }

    table.dataTable > tbody > tr.child ul.dtr-details > li {
        display: grid;
        grid-template-columns: minmax(7rem, 40%) 1fr;
        gap: .5rem;
        padding: .55rem 0;
        white-space: normal;
        word-break: break-word;
    }

    table.dataTable > tbody > tr.child span.dtr-title {
        min-width: 0;
        color: #5a5c69;
        font-weight: 700;
    }

    table.dataTable > tbody > tr.child span.dtr-data .btn {
        min-height: 40px;
        margin: .15rem .25rem .15rem 0;
    }

    /* Modals: large edit forms become full-screen pages; small dialogs
       (delete confirm, logout) become bottom sheets near the thumb. */
    .modal-dialog {
        display: flex;
        align-items: flex-end;
        max-width: 100%;
        width: 100%;
        min-height: 100%;
        margin: 0;
    }

    .modal-dialog > .modal-content {
        width: 100%;
        border: 0;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        align-items: stretch;
    }

    .modal-dialog.modal-lg > .modal-content,
    .modal-dialog.modal-xl > .modal-content {
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
    }

    .modal.fade .modal-dialog {
        transform: translateY(2rem);
    }

    .modal.show .modal-dialog {
        transform: none;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        align-items: center;
        background: #fff;
        padding: .75rem 1rem;
    }

    .modal-header .close,
    .modal-header .btn-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: -.5rem -.5rem -.5rem auto;
        padding: 0;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Field pairs inside modals stack to one column. */
    .modal-body .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        flex-wrap: nowrap;
        gap: .5rem;
        background: #fff;
        padding: .75rem 1rem calc(.75rem + var(--rd-safe-bottom));
        box-shadow: 0 -.35rem 1rem rgba(58, 59, 69, .08);
    }

    .modal-footer > * {
        flex: 1 1 0;
        min-height: 46px;
        margin: 0 !important;
    }

    .modal-footer > input[type="hidden"] {
        display: none;
    }

    /* 6. Home dashboard: styles live in home2.blade.php (responsive
     *    there), nothing phone-specific needed here. */

    /* -----------------------------------------------------------------
     * 7. Landing page (welcome.blade.php): phone-only grid tweaks.
     *    Spacing/alignment shared with tablets is in its own block below.
     * --------------------------------------------------------------- */
    #content section .lead {
        font-size: 1.05rem;
        text-align: left !important;
    }

    /* Partner logos: 3 per row instead of 1 huge logo per line. */
    #about .row.justify-content-center > .col-md-2 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
        padding: .5rem;
    }

    #about .row.justify-content-center > .row {
        width: 100%;
        margin: 0;
    }

    /* Team: one card per row beside the slim sidebar. Two per row left
       each card ~80px wide while the photo ring is a fixed 150px, so the
       photos spilled over each other. */
    #services .row > .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: .5rem 0;
    }

    #services .card-box {
        height: 100%;
        max-width: 20rem;
        margin: 0 auto;
    }

    #services .card-box p {
        margin-bottom: 0;
    }
}

/* Landing page spacing, phones and tablets (< 992px): the red banner spans
   the content width while each section sat in a narrower centred .container
   with 9rem top/bottom padding (styles.css), so text and banner never lined
   up and there were large empty gaps. Give the sections the banner's width. */
@media (max-width: 991.98px) {
    #content header.bg-danger {
        padding: 3.5rem 1.25rem;
    }

    #content header.bg-danger h1 {
        font-size: clamp(1.75rem, 7vw, 3rem);
    }

    #content section {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }

    #content section h2 {
        font-size: clamp(1.5rem, 5.5vw, 2.25rem);
    }

    #content section > .container {
        max-width: none;
    }

    #content section > .container.px-4 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Sections with their own grey panel (Team, Contact Us): keep the text
       off the panel's edges, like the banner's text sits inside the red. */
    #content section[class*="bg-"] > .container.px-4 {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }
}

@media (max-width: 767.98px) {

    /* -----------------------------------------------------------------
     * 8. Auth pages (layouts/auth.blade.php)
     * --------------------------------------------------------------- */
    body.rd-auth {
        align-items: flex-start !important;
        padding: 1rem .75rem calc(1rem + var(--rd-safe-bottom));
    }

    body.rd-auth .container,
    body.rd-auth .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    body.rd-auth .card {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 1rem;
    }

    body.rd-auth .card .p-5 {
        padding: 1.75rem 1.25rem !important;
    }

    body.rd-auth .form-control,
    body.rd-auth .form-select,
    body.rd-auth .custom-select {
        min-height: 50px;
        font-size: 16px;
    }

    body.rd-auth .btn {
        min-height: 50px;
        font-size: 1rem;
    }

    body.rd-auth .custom-control {
        min-height: 2rem;
    }

    body.rd-auth .modal-dialog {
        min-height: 0;
        margin: auto .75rem;
        width: auto;
    }

    body.rd-auth .modal-content {
        min-height: 0;
        border-radius: .75rem;
    }

    /* -----------------------------------------------------------------
     * 9. Analytics pages: guard against overflow only
     * --------------------------------------------------------------- */
    .section-title {
        font-size: clamp(1.5rem, 7vw, 2.8rem) !important;
        position: static !important;
    }

    #content .embed-responsive-16by9 {
        /* A 16:9 report is unreadably short on a portrait phone. */
        padding-top: 0;
        height: 70vh;
        height: 70svh;
    }

    #content .embed-responsive-16by9::before {
        padding-top: 0;
        display: none;
    }

    #content table:not(.dataTable) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =====================================================================
 * Phones: give the content more room beside the slim sidebar.
 * (Last in the file so it wins over the content rules above.)
 * Narrower slim sidebar (84px instead of sb-admin's 104px; the icon
 * labels still fit) and less stacked padding around cards, so data
 * tables keep their key columns visible.
 * =================================================================== */
@media (max-width: 767.98px) {
    :root {
        --rd-rail-w: 5.25rem;
    }

    #accordionSidebar.sidebar:not(.toggled) {
        width: var(--rd-rail-w) !important;
    }

    #accordionSidebar:not(.toggled) .nav-item .nav-link {
        width: var(--rd-rail-w) !important;
        padding: .75rem .25rem !important;
    }

    #accordionSidebar:not(.toggled) .sidebar-brand {
        padding-left: .25rem;
        padding-right: .25rem;
    }

    #accordionSidebar:not(.toggled) .sidebar-brand-icon img {
        width: 48px;
        height: 48px;
    }

    #accordionSidebar:not(.toggled) hr.sidebar-divider {
        margin-left: .5rem;
        margin-right: .5rem;
    }

    #accordionSidebar:not(.toggled) .sidebar-heading {
        padding-left: .25rem;
        padding-right: .25rem;
        font-size: .6rem;
    }

    #content > .container-fluid {
        padding-left: .5rem;
        padding-right: .5rem;
    }

    #content .row {
        margin-left: 0;
        margin-right: 0;
    }

    /* ...but inside a card keep Bootstrap's normal negative row margins
       (= half the .75rem gutter), so form fields line up with their
       section headings ("Owner's Profile", "Vaccine Information"). */
    #content .card-body .row {
        margin-left: -.75rem;
        margin-right: -.75rem;
    }

    #content .card-body .rd-form-actions .row {
        margin-left: 0;
        margin-right: 0;
    }

    /* Some forms (IEC, Schedule, Budget, parts of Exposure) put columns
       straight inside .pl-lg-4 with no .row, so the column's gutter padding
       was never offset and those fields sat 12px further in than the rest. */
    #content .card-body .pl-lg-4 > [class*="col"] {
        padding-left: 0;
        padding-right: 0;
    }

    #content .row > .card {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    #content .card-body {
        padding: .75rem;
    }

    #content .card > .container,
    #content .card .card-body > .container {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    /* Tables are built with .nowrap, so one long name filled the whole
       width and pushed Date/Action into the expand row. On phones let
       text cells wrap so the key columns fit side by side. */
    #content table.dataTable.nowrap th,
    #content table.dataTable.nowrap td {
        white-space: normal;
    }

    #content table.dataTable.nowrap td.dtr-control,
    #content table.dataTable.nowrap td:last-child .btn {
        white-space: nowrap;
    }

    /* Pages that nest a second .container-fluid (Phylogenomics, landing)
       paid its 24px side padding twice; on a phone beside the slim sidebar
       that squeezed text into a ~130px column. */
    #content .container-fluid .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    #content section[class*="bg-"] > .container.px-4 {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }

    /* Big one-word page titles (e.g. PHYLOGENOMICS at an inline 60px) ran
       past the screen edge: scale them to the space beside the sidebar. */
    #content .section-title {
        font-size: clamp(1.1rem, calc((100vw - 6.5rem) / 10.5), 2.8rem) !important;
        overflow-wrap: anywhere;
    }

    #content section h1 {
        font-size: clamp(1.4rem, 7vw, 2.25rem);
        overflow-wrap: break-word;
    }

    /* Card headers holding a title plus a badge (Forecasting "Under
       Revamp") wrap instead of pushing the badge off screen. */
    #content .card-header.d-flex {
        flex-wrap: wrap;
        gap: .5rem;
    }

}

/* Touch devices below desktop (phones and tablets): small text links get a
   bigger touch area without changing their look. */
@media (max-width: 991.98px) {
    .topbar .navbar-nav a:not(.nav-link):not(.dropdown-item) {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 0 .5rem;
    }

    body.rd-auth a.small,
    #content section li > a {
        display: inline-block;
        padding-top: .5rem;
        padding-bottom: .5rem;
    }
}

/* Phones: Edit / Delete in the table's Action column. They were inline
   buttons separated by spaces, so they wrapped unevenly (different widths,
   loose gap). Stack them as two equal-width buttons with a tidy gap. Only
   in the table row itself; the expanded detail view keeps them inline. */
@media (max-width: 767.98px) {
    #content table.dataTable > tbody > tr > td > .btn.edit,
    #content table.dataTable > tbody > tr > td > .btn.delete {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: .35rem;
        width: 100%;
        min-width: 5rem;
        min-height: 36px;
        margin: 0;
        white-space: nowrap;
    }

    #content table.dataTable > tbody > tr > td > .btn.edit + .btn.delete {
        margin-top: .4rem;
    }

    #content table.dataTable > tbody > tr > td {
        vertical-align: middle;
    }
}

/* Tablets (768-991px). iPad Safari zooms the page when a field with text
   under 16px is focused, as phones do, so fields get 16px text here too.
   Bootstrap only widens .modal-lg at >= 992px, leaving the long Edit
   Record form in a 500px column on an 800px tablet: use most of the width. */
@media (min-width: 768px) and (max-width: 991.98px) {
    .form-control,
    .form-select,
    .custom-select,
    body.rd-auth .form-control {
        font-size: 16px;
    }

    .modal-lg,
    .modal-xl {
        max-width: calc(100% - 3.5rem);
    }
}

/* Phones held sideways (short screens). With the keyboard open only a thin
   strip of page is visible, and the pinned topbar + pinned Submit bar (and a
   full-screen modal's pinned header/footer) covered the field being typed
   in. Let them scroll with the page here; Submit stays at the end of the
   form, Update/Close at the end of the modal. Portrait is unaffected. */
@media (orientation: landscape) and (max-height: 500px) {
    .topbar {
        position: relative !important;
    }

    .rd-form-actions {
        position: static !important;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .modal-header,
    .modal-footer {
        position: static !important;
    }

    /* The floating back-to-top button also sat over the fields. */
    .scroll-to-top {
        display: none !important;
    }
}

