/**
 * SeedQuest dashboard and BreedBase workflow presentation overlay.
 *
 * This stylesheet is loaded synchronously from the official downstream head
 * hook. Base geometry and branding must not depend on JavaScript.
 */

:root {
    --sq-overlay-ready: 1;
    --sq-page-background: #eef2f7;
    --sq-surface: #ffffff;
    --sq-surface-muted: #f8fafc;
    --sq-text: #334155;
    --sq-text-strong: #0f172a;
    --sq-text-muted: #64748b;
    --sq-line: #dbe3ee;
    --sq-blue: #0096df;
    --sq-blue-dark: #0369a1;
    --sq-green: #71c900;
    --sq-radius: 10px;
    --sq-radius-small: 8px;
    --sq-line-soft: #eef2f7;
    --sq-blue-deep: #075985;
    --sq-shadow: 0 2px 10px rgba(15, 23, 42, 0.07);
    --sq-content-max: 1920px;
}

html {
    min-width: min(320px, 100%);
    max-width: 100%;
    scrollbar-gutter: stable;
    background: var(--sq-page-background);
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}

body {
    max-width: 100%;
    min-height: 100vh;
    margin: 0;
    padding-top: 52px !important;
    color: var(--sq-text);
    background: var(--sq-page-background);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif !important;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: normal;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    -webkit-font-smoothing: antialiased;
}

/* Bootstrap compensates disappearing scrollbars inline; the root gutter owns it. */
body.modal-open {
    padding-right: 0 !important;
}

body *,
body *::before,
body *::after {
    box-sizing: border-box;
}

p,
li,
label,
legend,
button,
input,
select,
textarea,
th,
td,
.navbar,
.navbar a,
.dropdown-menu a {
    word-break: normal;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}

a {
    color: var(--sq-blue-dark);
    text-underline-offset: 2px;
}

a:hover,
a:focus {
    color: #075985;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgba(0, 150, 223, 0.35) !important;
    outline-offset: 2px;
}

/* Use the full working width instead of the legacy centered 8/12 column. */
#outercontainer {
    width: min(calc(100% - clamp(24px, 4vw, 72px)), var(--sq-content-max)) !important;
    max-width: var(--sq-content-max) !important;
    margin-right: auto !important;
    margin-left: auto !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
}

/* The official shell nests the working row in a padded Bootstrap container. */
#wrapper.container-fluid {
    width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
}

#main_row {
    width: 100%;
    margin-right: 0 !important;
    margin-left: 0 !important;
}

#main_row > [class*="col-"] {
    min-width: 0;
}

#main_row > .col-md-1.col-lg-1.col-xl-2 {
    display: none !important;
}

#main_row > .col-sm-12.col-md-10.col-lg-10.col-xl-8 {
    float: none !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
}

/* The official toolbar remains authoritative; only its presentation changes. */
.navbar-fixed-top.navbar-default {
    min-height: 52px !important;
    margin: 0 !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 0 !important;
    background: var(--sq-surface) !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08) !important;
}

.navbar-fixed-top > .container-fluid {
    width: min(100%, var(--sq-content-max));
    min-height: 52px;
    margin-right: auto;
    margin-left: auto;
    padding-right: clamp(12px, 2vw, 32px);
    padding-left: clamp(12px, 2vw, 32px);
}

.navbar-fixed-top .navbar-header {
    min-height: 52px;
}

.navbar-fixed-top .navbar-brand {
    display: inline-flex;
    align-items: center;
    width: 133px;
    height: 52px;
    margin: 0 !important;
    padding: 10px 12px !important;
}

.navbar-fixed-top .sq-brand-logo {
    display: block;
    width: 109px !important;
    min-width: 109px;
    max-width: 109px !important;
    height: 32px !important;
    object-fit: contain;
}

.navbar-fixed-top .sq-dashboard-shortcut {
    display: inline-flex;
    float: left;
    align-items: center;
    gap: 6px;
    height: 52px;
    min-height: 52px;
    padding: 0 9px;
    color: #475569 !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 22px;
    text-decoration: none !important;
    white-space: nowrap;
}

.navbar-fixed-top .sq-dashboard-shortcut:hover,
.navbar-fixed-top .sq-dashboard-shortcut:focus {
    color: var(--sq-blue-dark) !important;
    background: #f1f5f9 !important;
}

.navbar-default .navbar-nav > li > a {
    min-height: 52px;
    padding: 15px 10px !important;
    color: #475569 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 22px !important;
    white-space: nowrap;
}

.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus,
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
    color: var(--sq-blue-dark) !important;
    background: #f1f5f9 !important;
}

.navbar-fixed-top .navbar-toggle {
    min-width: 44px;
    min-height: 44px;
    margin-top: 4px;
    margin-bottom: 4px;
    border-color: var(--sq-line);
}

.navbar-fixed-top .navbar-toggle .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 1px;
    background: var(--sq-text-strong);
}

.navbar-fixed-top .navbar-toggle .icon-bar + .icon-bar {
    margin-top: 4px;
}

.navbar-fixed-top .dropdown-menu {
    max-width: min(360px, calc(100vw - 24px));
    border: 1px solid var(--sq-line);
    border-radius: 8px;
    box-shadow: var(--sq-shadow);
}

.navbar-fixed-top .dropdown-menu > li > a {
    min-height: 44px !important;
    padding: 11px 12px !important;
    overflow-wrap: break-word;
    white-space: normal;
}

#pagetitle {
    margin: 8px 0 24px !important;
    padding: 0 !important;
    border-bottom: 0;
    text-align: left !important;
}

#pagetitle_h3,
#pagetitle h1,
#pagetitle h2,
#pagetitle h3 {
    max-width: 100%;
    margin: 0 !important;
    color: var(--sq-text-strong) !important;
    font-size: clamp(28px, 4vw, 42px) !important;
    font-weight: 750 !important;
    line-height: 1.12 !important;
    overflow-wrap: break-word;
    word-break: normal;
    text-align: left !important;
}

.well,
.panel,
.modal-content {
    border: 1px solid var(--sq-line) !important;
    border-radius: var(--sq-radius) !important;
    background: var(--sq-surface) !important;
    box-shadow: var(--sq-shadow) !important;
}

.well {
    max-width: 100%;
    padding: 18px !important;
}

/* Detail pages nest multiple official panels inside a single working card. */
.well .panel,
.well .well {
    box-shadow: none !important;
}

.infosectionhead,
.infosectionhead_empty,
.sub_infosectionhead,
.sub_infosectionhead_empty {
    width: 100% !important;
    max-width: 100% !important;
    border-color: var(--sq-line) !important;
    background: var(--sq-surface-muted) !important;
}

.infosectiontitle,
.infosectiontitle_empty,
.sub_infosectiontitle,
.sub_infosectiontitle_empty,
.infosectionsubtitle,
.infosectionsubtitle_empty,
.sub_infosectionsubtitle,
.sub_infosectionsubtitle_empty {
    color: var(--sq-text-strong) !important;
    line-height: 1.35 !important;
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal !important;
}

/* Keep the explanatory copy readable instead of squeezing it into the
 * official 10% table-cell hint, which can wrap words one letter at a time. */
td.infosectiontitle,
td.infosectiontitle_empty,
td.sub_infosectiontitle,
td.sub_infosectiontitle_empty {
    width: auto !important;
}

td.infosectionsubtitle,
td.infosectionsubtitle_empty,
td.sub_infosectionsubtitle,
td.sub_infosectionsubtitle_empty {
    width: clamp(260px, 28vw, 520px) !important;
    min-width: 260px;
    max-width: 520px;
    overflow-wrap: normal;
    text-align: right;
}

td.infosectionsubtitle > [class*="col-"],
td.infosectionsubtitle_empty > [class*="col-"],
td.sub_infosectionsubtitle > [class*="col-"],
td.sub_infosectionsubtitle_empty > [class*="col-"] {
    float: none !important;
    width: auto !important;
    min-width: 0;
    padding-right: 0 !important;
    padding-left: 0 !important;
}

.table-responsive,
.dataTables_scrollBody,
.sq-table-viewport {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > table,
.dataTables_scrollBody > table,
.sq-table-viewport > table {
    max-width: none;
}

.form-control,
.btn,
.input-group {
    max-width: 100%;
}

.modal-dialog {
    max-width: calc(100vw - 24px);
    margin-right: auto;
    margin-left: auto;
}

/* The legacy derived-trait dialog uses an obsolete jQuery UI position array,
 * which places it at the top-left in current browsers. Scope the correction
 * to this dialog and keep it above the fixed application toolbar. */
body > .ui-widget-overlay {
    z-index: 1050 !important;
}

.ui-dialog[aria-describedby="compute_derived_trait_dialog"] {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    width: min(500px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px);
    margin: 0 !important;
    transform: translate(-50%, -50%);
    z-index: 1060 !important;
}

.ui-dialog[aria-describedby="compute_derived_trait_dialog"] .ui-dialog-content {
    max-height: calc(100vh - 120px) !important;
    overflow: auto;
}

.ui-dialog[aria-describedby="compute_derived_trait_dialog"] #trait_list_label_dc {
    width: 100% !important;
}

.ui-dialog[aria-describedby="compute_derived_trait_dialog"] #derived_trait_select {
    width: 100%;
    max-width: 100%;
}

#pagefooter.navbar-default,
#footer {
    border-color: var(--sq-line) !important;
    background: var(--sq-surface-muted) !important;
    color: var(--sq-text-muted) !important;
    box-shadow: none !important;
}

@media (max-width: 767px) {
    #outercontainer {
        width: calc(100% - 24px) !important;
    }

    table.infosectionhead > tbody > tr > td.infosectiontitle,
    table.infosectionhead_empty > tbody > tr > td.infosectiontitle_empty,
    table.sub_infosectionhead > tbody > tr > td.sub_infosectiontitle,
    table.sub_infosectionhead_empty > tbody > tr > td.sub_infosectiontitle_empty,
    table.infosectionhead > tbody > tr > td.infosectionsubtitle,
    table.infosectionhead_empty > tbody > tr > td.infosectionsubtitle_empty,
    table.sub_infosectionhead > tbody > tr > td.sub_infosectionsubtitle,
    table.sub_infosectionhead_empty > tbody > tr > td.sub_infosectionsubtitle_empty,
    table.infosectionhead_empty > tbody > tr > td.infosection_emptymessage,
    table.sub_infosectionhead_empty > tbody > tr > td.sub_infosection_emptymessage {
        display: block;
        width: 100% !important;
        min-width: 0;
        max-width: none;
        text-align: left;
    }

    .navbar-fixed-top .navbar-collapse {
        position: absolute;
        top: 52px;
        right: 0;
        left: 0;
        max-height: calc(100vh - 52px) !important;
        margin: 0 !important;
        padding: 8px 12px 14px !important;
        overflow-y: auto !important;
        border-top: 1px solid var(--sq-line) !important;
        background: var(--sq-surface) !important;
        box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16) !important;
    }

    .navbar-fixed-top .navbar-collapse .navbar-nav {
        margin-right: 0;
        margin-left: 0;
    }

    .navbar-fixed-top .navbar-nav > li > a {
        min-height: 44px;
        padding: 11px 12px !important;
    }

    .navbar-fixed-top .navbar-nav .open > .dropdown-menu {
        width: 100%;
        max-width: 100%;
        padding: 4px 0 !important;
    }
}

@media (min-width: 768px) {
    .navbar-fixed-top .navbar-nav > .dropdown > .dropdown-menu {
        width: max-content;
        min-width: 260px;
        max-width: min(300px, calc(100vw - 24px));
        margin-top: 0;
        padding: 3px 0 !important;
        overflow: visible;
    }

    .navbar-fixed-top .dropdown-menu > li > a {
        min-height: 24px !important;
        padding: 3px 12px !important;
        font-size: 13px !important;
        line-height: 18px !important;
        overflow-wrap: normal;
        white-space: nowrap;
    }

    .navbar-fixed-top .dropdown-menu > .divider {
        margin: 2px 0;
    }

    .navbar-fixed-top .dropdown-menu > .dropdown-header {
        padding: 3px 12px;
        font-size: 12px;
        line-height: 18px;
    }

    .navbar-fixed-top .dropdown:focus-within > .dropdown-menu {
        display: block;
        margin-top: 0;
    }
}

@media (max-width: 359px) {
    .navbar-fixed-top .sq-dashboard-shortcut {
        gap: 0;
        padding-right: 6px;
        padding-left: 6px;
    }

    .navbar-fixed-top .sq-dashboard-shortcut .glyphicon {
        display: none;
    }
}

/*
 * BreedBase renders the authenticated search form on the server, then replaces
 * the narrow Login placeholder with the full account controls over AJAX. Keep
 * both boxes at their final size so that replacement cannot reflow the toolbar.
 * Guest pages have no #toolbar_search_form and therefore remain untouched.
 */
/* AUTHENTICATED_TOOLBAR_RESERVATION_START */
.navbar-fixed-top #login_button_html_div #navbar_profile {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 768px) and (max-width: 1028px) {
    .navbar-fixed-top .navbar-right:has(#toolbar_search_form) {
        width: 386px;
        min-width: 386px;
    }

    .navbar-fixed-top .navbar-right:has(#toolbar_search_form) #login_button_html_div {
        display: block;
        width: 316px;
        min-width: 316px;
        height: 50px;
        min-height: 50px;
        text-align: right;
    }
}

@media (min-width: 992px) and (max-width: 1028px) {
    .navbar-fixed-top #navbar_lists .hidden-sm,
    .navbar-fixed-top #navbar_datasets .hidden-sm {
        display: none !important;
    }
}

@media (min-width: 1029px) {
    .navbar-fixed-top .navbar-right:has(#toolbar_search_form) {
        width: 510px;
        min-width: 510px;
    }

    .navbar-fixed-top .navbar-right:has(#toolbar_search_form) #login_button_html_div {
        display: block;
        width: 440px;
        min-width: 440px;
        height: 50px;
        min-height: 50px;
        text-align: right;
    }

    .navbar-fixed-top #login_button_html_div #navbar_profile {
        max-width: 80px;
    }
}
/* AUTHENTICATED_TOOLBAR_RESERVATION_END */

@media (min-width: 768px) and (max-width: 940px) {
    body:has(#toolbar_search_form) {
        padding-top: 90px !important;
    }
}

/* Preserve the official two-row toolbar clearance at narrow desktop widths. */
@media (min-width: 768px) and (max-width: 880px) {
    body {
        padding-top: 90px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    body {
        padding-top: 0 !important;
        background: #ffffff !important;
    }

    .navbar-fixed-top {
        position: static !important;
    }
}

/* Native BreedBase workflows use the dashboard's quiet surfaces and controls.
 * Keep these selectors at class specificity: SeedQuest-owned pages and the
 * Weather module (#bbw) can provide their own, more specific components. */
:where(body) .panel-heading,
:where(body) .modal-header {
    border-color: var(--sq-line);
    background: var(--sq-surface-muted);
}

:where(body) .panel-heading:first-child {
    border-radius: var(--sq-radius) var(--sq-radius) 0 0;
}

:where(body) .panel-title,
:where(body) .modal-title {
    color: var(--sq-text-strong);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

:where(body) .panel-body {
    padding: 18px;
}

:where(body) .modal-footer {
    border-color: var(--sq-line);
    background: var(--sq-surface-muted);
    border-radius: 0 0 var(--sq-radius) var(--sq-radius);
}

:where(body) .btn {
    border-radius: var(--sq-radius-small);
    font-weight: 600;
    box-shadow: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

:where(body) .btn-default {
    border-color: var(--sq-line);
    background: var(--sq-surface);
    color: var(--sq-text);
}

:where(body) .btn-default:hover,
:where(body) .btn-default:focus {
    border-color: #b8c8da;
    background: var(--sq-surface-muted);
    color: var(--sq-text-strong);
}

:where(body) .btn-primary {
    border-color: var(--sq-blue-dark);
    background: var(--sq-blue-dark);
    color: #ffffff;
}

/* Native link rules must not make primary-button text blue on blue. */
:where(body) a.btn-primary { color: #ffffff !important; }

:where(body) .btn-primary:hover,
:where(body) .btn-primary:focus {
    border-color: var(--sq-blue-deep);
    background: var(--sq-blue-deep);
    color: #ffffff;
}

:where(body) .btn-info {
    border-color: #0e7490;
    background: #0e7490;
    color: #ffffff;
}

:where(body) .btn-info:hover,
:where(body) .btn-info:focus {
    border-color: #155e75;
    background: #155e75;
    color: #ffffff;
}

:where(body) .btn-success {
    border-color: #4d7c0f;
    background: #4d7c0f;
    color: #ffffff;
}

:where(body) .btn-success:hover,
:where(body) .btn-success:focus {
    border-color: #3f6212;
    background: #3f6212;
    color: #ffffff;
}

:where(body) .btn-danger {
    border-color: #b91c1c;
    background: #b91c1c;
    color: #ffffff;
}

:where(body) .btn-danger:hover,
:where(body) .btn-danger:focus {
    border-color: #991b1b;
    background: #991b1b;
    color: #ffffff;
}

:where(body) .btn-link {
    color: var(--sq-blue-dark);
    font-weight: 600;
}

:where(body) .form-control {
    border-color: var(--sq-line);
    border-radius: var(--sq-radius-small);
    background: var(--sq-surface);
    box-shadow: none;
    color: var(--sq-text-strong);
}

:where(body) .form-control:focus {
    border-color: var(--sq-blue);
    box-shadow: 0 0 0 3px rgba(0, 150, 223, 0.15);
}

:where(body) .control-label,
:where(body) .form-group > label {
    color: var(--sq-text-strong);
    font-weight: 600;
}

:where(body) .input-group-addon {
    border-color: var(--sq-line);
    background: var(--sq-surface-muted);
    color: var(--sq-text-muted);
}

:where(body) .table > thead > tr > th,
:where(body) table.dataTable > thead > tr > th {
    border-bottom: 1px solid var(--sq-line);
    background: var(--sq-surface-muted);
    color: var(--sq-text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

:where(body) .table > tbody > tr > td,
:where(body) table.dataTable > tbody > tr > td {
    border-top-color: var(--sq-line-soft);
}

:where(body) .table-hover > tbody > tr:hover,
:where(body) table.dataTable.hover > tbody > tr:hover {
    background: #f1f8fc;
}

:where(body) .dataTables_wrapper .dataTables_filter input,
:where(body) .dataTables_wrapper .dataTables_length select {
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius-small);
    background: var(--sq-surface);
    color: var(--sq-text-strong);
}

:where(body) .dataTables_wrapper .dataTables_filter input:focus,
:where(body) .dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--sq-blue);
    outline: 3px solid rgba(0, 150, 223, 0.15);
    outline-offset: 0;
}

:where(body) .dataTables_wrapper .dataTables_info {
    color: var(--sq-text-muted);
    font-size: 12px;
}

:where(body) .nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 20px;
    padding: 6px;
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius);
    background: var(--sq-surface);
    box-shadow: var(--sq-shadow);
}

:where(body) .nav-tabs::before,
:where(body) .nav-tabs::after {
    display: none;
}

:where(body) .nav-tabs > li {
    float: none;
    margin: 0;
}

:where(body) .nav-tabs > li > a {
    margin: 0;
    padding: 9px 16px;
    border: 0;
    border-radius: var(--sq-radius-small);
    background: transparent;
    color: var(--sq-text);
    font-weight: 600;
}

:where(body) .nav-tabs > li > a:hover,
:where(body) .nav-tabs > li > a:focus {
    border: 0;
    background: var(--sq-surface-muted);
    color: var(--sq-text-strong);
}

:where(body) .nav-tabs > li.active > a,
:where(body) .nav-tabs > li.active > a:hover,
:where(body) .nav-tabs > li.active > a:focus {
    border: 0;
    background: var(--sq-blue-dark);
    color: #ffffff;
}

:where(body) .pagination > li > a,
:where(body) .pagination > li > span {
    border-color: var(--sq-line);
    background: var(--sq-surface);
    color: var(--sq-blue-dark);
}

:where(body) .pagination > .active > a,
:where(body) .pagination > .active > span,
:where(body) .pagination > .active > a:hover,
:where(body) .pagination > .active > span:hover {
    border-color: var(--sq-blue-dark);
    background: var(--sq-blue-dark);
    color: #ffffff;
}

:where(body) .alert {
    border-radius: var(--sq-radius-small);
    border-left-width: 4px;
    box-shadow: none;
}

:where(body) .breadcrumb {
    border-radius: var(--sq-radius-small);
    background: var(--sq-surface-muted);
    color: var(--sq-text-muted);
}

:where(body) table.infosectionhead,
:where(body) table.infosectionhead_empty,
:where(body) table.sub_infosectionhead,
:where(body) table.sub_infosectionhead_empty {
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius) var(--sq-radius) 0 0;
    box-shadow: var(--sq-shadow);
}

:where(body) td.infosectiontitle,
:where(body) td.infosectiontitle_empty,
:where(body) td.sub_infosectiontitle,
:where(body) td.sub_infosectiontitle_empty {
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 700;
}

:where(body) td.infosectionsubtitle,
:where(body) td.infosectionsubtitle_empty,
:where(body) td.sub_infosectionsubtitle,
:where(body) td.sub_infosectionsubtitle_empty {
    padding: 14px 18px;
    font-size: 13px;
}

.sq-section-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.sq-section-actions .btn {
    margin: 0;
}

@media (max-width: 767px) {
    /* Some official detail pages nest .row directly in .row. Their negative
     * gutters accumulate beyond the viewport after the centered columns go. */
    #main_row > [class*="col-"] > .row,
    #main_row .row > .row {
        margin-right: 0;
        margin-left: 0;
    }

    :where(body) .btn {
        white-space: normal;
        overflow-wrap: break-word;
    }

    .sq-section-actions {
        justify-content: flex-start;
    }

    /* The official trial tree is a two-column table. Stack its controls and
     * tree on phones so neither becomes an unreadable narrow column. */
    table.table:has(#trial_tree_search),
    table.table:has(#trial_tree_search) > tbody,
    table.table:has(#trial_tree_search) > tbody > tr,
    table.table:has(#trial_tree_search) > tbody > tr > td {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    table.table:has(#trial_tree_search) > thead {
        display: block;
    }

    table.table:has(#trial_tree_search) > tbody > tr > td + td {
        border-top: 1px solid var(--sq-line);
        min-height: 120px;
    }

    /* Native trial metadata includes long accession-style identifiers. Keep
     * both columns inside their card and allow the complete value to wrap. */
    #trial_details_content table.table:has(#trial_name) {
        width: 100%;
        table-layout: fixed;
    }

    #trial_details_content table.table:has(#trial_name) td {
        overflow-wrap: anywhere;
    }

    #trial_details_content table.table:has(#trial_name) td:first-child {
        width: 40%;
    }

    /* Keep wide native download and search tables scrollable within their
     * own controls rather than widening the entire page. */
    #download_form,
    #download_pedigree,
    #stock_search_results_div {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    #download_form > table,
    #download_pedigree > table,
    #stock_search_results_div > table {
        max-width: none;
    }

    /* DataTables adds its wide result table after load. The wrapper must own
     * that width so phenotype, ontology, and analysis pages do not grow. */
    :where(body) .dataTables_wrapper,
    :where(body) .panel-body-sm:has(> table.table),
    :where(body) .well.well-sm:has(> table.table),
    #wizard {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* The decision-meeting selector has an inline 220 px minimum inside a
     * narrow nested panel. Wrap its controls instead of widening the page. */
    #dm-topbar > .col-sm-6 {
        flex-wrap: wrap;
        max-width: 100%;
    }

    #dm_list_sel,
    #dataset_select,
    #dm_dataset_sel {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Decision Meeting nests cards and info sections several levels deep.
     * Keep usable table space on phones instead of spending it on gutters. */
    #main_row .row:has(
        > .col-sm-12 > .well #meeting_table,
        > .col-sm-12 > .well #decision_table
    ) {
        margin-right: 0;
        margin-left: 0;
    }

    #main_row .row:has(
        > .col-sm-12 > .well #meeting_table,
        > .col-sm-12 > .well #decision_table
    ) > .col-sm-12 {
        padding-right: 0;
        padding-left: 0;
    }

    .well:has(#meeting_table, #decision_table, #summary_table) {
        padding: 12px !important;
    }

    .well .well:has(#meeting_table, #decision_table, #summary_table) {
        padding-right: 0 !important;
        padding-left: 0 !important;
    }

    :where(.infosectioncontent, .sub_infosectioncontent):has(
        #meeting_table, #decision_table, #summary_table
    ) {
        margin-right: 0;
        margin-left: 0;
    }

    .panel-body:has(.well #meeting_table, .well #decision_table, .well #summary_table),
    .panel-body:has(> .panel-body > .table-responsive > #summary_table) {
        padding-right: 0;
        padding-left: 0;
    }

    #dm-saveall-wrap {
        flex-wrap: wrap;
    }

    #dm-saveall-wrap > .btn {
        min-width: 0;
        max-width: 100%;
    }

    #decision_table_wrapper .dataTables_filter,
    #summary_table_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
    }

    #decision_table_wrapper .dataTables_filter label,
    #summary_table_wrapper .dataTables_filter label {
        width: 100%;
    }

    #decision_table_wrapper .dataTables_filter input,
    #summary_table_wrapper .dataTables_filter input {
        width: 100%;
        min-width: 0 !important;
        margin-left: 0 !important;
    }

    /* Bulk tabs load their existing forms into the application page. The
     * official two-column layout tables must stack within the tab on phones. */
    #tabs .ui-tabs-panel form table,
    #tabs .ui-tabs-panel form tbody,
    #tabs .ui-tabs-panel form tr,
    #tabs .ui-tabs-panel form td {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    #tabs .ui-tabs-panel form :where(select, textarea, input[type="file"]) {
        max-width: 100%;
    }

    /* Weather shares these tokens but its crop-profile table is wider than
     * the phone viewport. Keep that table scrollable inside the Weather tab. */
    #bbw .bbw-pane:has(.bbw-profile-list) {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    :where(body) .dataTables_wrapper .dataTables_length,
    :where(body) .dataTables_wrapper .dataTables_filter {
        float: none;
        margin-bottom: 10px;
        text-align: left;
    }

    :where(body) .nav-tabs > li {
        flex: 1 1 auto;
    }
}

/* SeedQuest-owned pages. These classes never alter BreedBase form behavior. */
.sq-owned-page {
    width: 100%;
    margin: 0 auto 40px;
}

.sq-owned-page h1,
.sq-owned-page h2,
.sq-owned-page h3 {
    color: var(--sq-text-strong);
}

.sq-eyebrow {
    margin: 0 0 8px;
    color: var(--sq-blue-dark);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.sq-lead {
    max-width: 760px;
    margin: 0;
    color: var(--sq-text);
    font-size: 17px;
    line-height: 1.6;
}

.sq-page-intro {
    margin: 8px 0 24px;
}

.sq-page-intro h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 750;
    line-height: 1.12;
}

.sq-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.sq-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sq-actions a.btn-primary,
.sq-actions a.btn-primary:link,
.sq-actions a.btn-primary:visited {
    color: #fff !important;
    border-color: var(--sq-blue-dark) !important;
    background: var(--sq-blue-dark) !important;
}

.sq-actions a.btn-primary:hover,
.sq-actions a.btn-primary:focus,
.sq-actions a.btn-primary:active {
    color: #fff !important;
    border-color: #075985 !important;
    background: #075985 !important;
}

.sq-home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: clamp(24px, 5vw, 64px);
    align-items: center;
    padding: clamp(28px, 6vw, 72px) 0;
}

.sq-home-hero-copy h1 {
    max-width: 850px;
    margin: 0 0 16px;
    font-size: clamp(34px, 5vw, 62px);
    font-weight: 780;
    line-height: 1.04;
    letter-spacing: -0.025em;
}

.sq-home-summary,
.sq-info-card,
.sq-feature-card,
.sq-dashboard-group,
.sq-citation,
.sq-legal-copy,
.sq-faq-list article {
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius);
    background: var(--sq-surface);
    box-shadow: var(--sq-shadow);
}

.sq-home-summary {
    padding: 26px;
}

.sq-home-summary-logo {
    display: block;
    width: 218px;
    max-width: 100%;
    height: 64px;
    margin: 0 0 24px;
    object-fit: contain;
    object-position: left center;
}

.sq-home-summary h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.sq-home-summary > p {
    margin: 0 0 14px;
    color: var(--sq-text-muted);
    line-height: 1.55;
}

.sq-check-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sq-check-list li {
    position: relative;
    padding: 10px 0 10px 28px;
    border-top: 1px solid #eef2f7;
}

.sq-check-list li::before {
    position: absolute;
    top: 10px;
    left: 2px;
    color: var(--sq-green);
    content: "✓";
    font-weight: 800;
}

.sq-feature-grid,
.sq-info-grid,
.sq-help-grid,
.sq-dashboard-primary,
.sq-dashboard-groups {
    display: grid;
    gap: 16px;
}

.sq-feature-grid,
.sq-dashboard-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sq-info-grid,
.sq-help-grid,
.sq-dashboard-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sq-feature-card {
    display: block;
    min-height: 178px;
    padding: 24px;
    color: var(--sq-text) !important;
    text-decoration: none !important;
}

.sq-feature-card > .glyphicon {
    display: inline-grid;
    width: 42px;
    height: 42px;
    margin-bottom: 16px;
    place-items: center;
    border-radius: 9px;
    background: #e0f2fe;
    color: var(--sq-blue-dark);
    font-size: 18px;
}

.sq-feature-card h3,
.sq-info-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.sq-feature-card p,
.sq-info-card p {
    margin: 0;
    color: var(--sq-text-muted);
    line-height: 1.55;
}

.sq-info-grid {
    margin-top: 16px;
}

.sq-info-card {
    padding: 24px;
}

.sq-info-card--wide {
    grid-column: 1 / -1;
}

.sq-home-credit {
    margin-top: 14px !important;
    font-size: 12px;
}

.sq-dashboard-primary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.sq-dashboard-hero {
    display: flex;
    min-height: 158px;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
    border-radius: var(--sq-radius);
    color: #ffffff !important;
    text-decoration: none !important;
    box-shadow: var(--sq-shadow);
}

.sq-dashboard-hero--trials {
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

.sq-dashboard-hero--germplasm {
    background: linear-gradient(135deg, #3f6212, #65a30d);
}

.sq-dashboard-hero--observations {
    background: linear-gradient(135deg, #475569, #334155);
}

.sq-dashboard-hero--breeding {
    background: linear-gradient(135deg, #6d28d9, #7c3aed);
}

.sq-dashboard-hero > .glyphicon {
    margin-bottom: auto;
    font-size: 25px;
}

.sq-dashboard-hero strong {
    font-size: 18px;
}

.sq-dashboard-hero small {
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
}

.sq-dashboard-group {
    overflow: hidden;
}

.sq-dashboard-group h2 {
    margin: 0;
    padding: 16px 18px;
    border-bottom: 1px solid var(--sq-line);
    background: var(--sq-surface-muted);
    font-size: 16px;
}

.sq-dashboard-group h2 .glyphicon {
    margin-right: 7px;
    color: var(--sq-blue-dark);
}

.sq-dashboard-group > a {
    display: flex;
    min-height: 62px;
    flex-direction: column;
    justify-content: center;
    padding: 10px 18px;
    border-bottom: 1px solid #eef2f7;
    color: var(--sq-text) !important;
    text-decoration: none !important;
}

.sq-dashboard-group > a:last-child {
    border-bottom: 0;
}

.sq-dashboard-group > a:hover,
.sq-dashboard-group > a:focus {
    background: #f8fafc;
}

.sq-dashboard-group > a span {
    margin-top: 2px;
    color: var(--sq-text-muted);
    font-size: 12px;
}

.sq-help-grid {
    margin-bottom: 18px;
}

.sq-help-grid .sq-info-card a,
.sq-inline-links a {
    display: inline-block;
    margin-top: 14px;
    font-weight: 650;
}

.sq-citation,
.sq-legal-copy {
    padding: 24px;
}

.sq-citation h2 {
    margin-top: 0;
    font-size: 20px;
}

.sq-faq-list {
    display: grid;
    gap: 14px;
}

.sq-faq-list article {
    padding: 20px 22px;
}

.sq-faq-list h2 {
    margin: 0 0 8px;
    font-size: 17px;
}

.sq-faq-list p,
.sq-legal-copy p {
    margin: 0 0 14px;
    line-height: 1.65;
}

.sq-faq-list p:last-child,
.sq-legal-copy p:last-child {
    margin-bottom: 0;
}

.sq-inline-links {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 18px;
}

.sq-dashboard-nav > a .glyphicon {
    margin-right: 4px;
}

.sq-site-footer {
    margin-top: 64px;
    border-top: 1px solid var(--sq-line);
    background: var(--sq-surface-muted);
    color: var(--sq-text-muted);
}

.sq-site-footer > .container-fluid {
    width: min(calc(100% - 24px), var(--sq-content-max));
    margin: 0 auto;
    padding: 28px 0;
}

.sq-footer-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto minmax(220px, auto);
    gap: 28px;
    align-items: start;
}

.sq-footer-logo {
    display: block;
    width: 164px;
    height: 48px;
    object-fit: contain;
    object-position: left center;
}

.sq-footer-grid p {
    max-width: 460px;
    margin: 12px 0 0;
}

.sq-footer-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(80px, 1fr));
    gap: 8px 18px;
}

.sq-footer-version {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.sq-footer-version strong {
    color: var(--sq-text);
    font-size: 13px;
}

@media (max-width: 900px) {
    .sq-home-hero,
    .sq-footer-grid {
        grid-template-columns: 1fr;
    }

    .sq-feature-grid,
    .sq-dashboard-primary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .sq-home-hero {
        padding: 28px 0;
    }

    .sq-feature-grid,
    .sq-info-grid,
    .sq-help-grid,
    .sq-dashboard-primary,
    .sq-dashboard-groups {
        grid-template-columns: 1fr;
    }

    .sq-footer-links {
        grid-template-columns: 1fr;
    }
}

/* Official image galleries (/image/print_images.mas): keep each caption under
 * its thumbnail and give the visible and "See more images" tables the same
 * column geometry, so long descriptions no longer squeeze the image column. */
table.table:has(#print_images_multi_image_view) td > a.stock_image_group {
    display: block;
    width: max-content;
    max-width: 100%;
    margin-bottom: 6px;
}

table.table:has(#print_images_multi_image_view) td > a.stock_image_group > img {
    display: block;
    max-width: 100%;
    height: auto;
}

table.table:has(#print_images_multi_image_view) > thead > tr > th:first-child,
table.table:has(#print_images_multi_image_view) > thead > tr > th:nth-child(n+4) {
    width: 1%;
    white-space: nowrap;
}

@media (min-width: 768px) {
    table.table:has(#print_images_multi_image_view) > thead > tr > th:nth-child(2) {
        width: 220px;
    }
}

/* Native workflow controls share the same mobile reading width. Layout tables
 * become label/value stacks; result tables retain their own horizontal region. */
@media (max-width: 767px) {
    table.table:has(input[id$="_tree_search"]),
    table.table:has(input[id$="_tree_search"]) > :is(thead, tbody),
    table.table:has(input[id$="_tree_search"]) > :is(thead, tbody) > tr,
    table.table:has(input[id$="_tree_search"]) > :is(thead, tbody) > tr > :is(th, td) {
        display: block;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    table.table:has(input[id$="_tree_search"]) > thead > tr > th:first-child:not(:has(button, a, input, select)) {
        display: none;
    }
    table.table:has(input[id$="_tree_search"]) > tbody > tr > td + td {
        border-top: 1px solid var(--sq-line);
        min-height: 120px;
    }
    table.table:has(input[id$="_tree_search"]) .btn { max-width: 100%; }

    :is(#download_form, #download_metadata_form, #download_accession_properties,
        #download_pedigree, #download_cross_family, #download_seedlot_details,
        #download_obsolete_metadata_action, #download_gbs, #gbs_qc) {
        overflow-x: visible;
    }
    :is(#download_form, #download_metadata_form, #download_accession_properties,
        #download_pedigree, #download_cross_family, #download_seedlot_details,
        #download_obsolete_metadata_action, #download_gbs, #gbs_qc) table,
    :is(#download_form, #download_metadata_form, #download_accession_properties,
        #download_pedigree, #download_cross_family, #download_seedlot_details,
        #download_obsolete_metadata_action, #download_gbs, #gbs_qc) :is(thead, tbody, tr, th, td),
    table:has(#label_rows, #page_format),
    table:has(#label_rows, #page_format) :is(thead, tbody, tr, th, td),
    table:has(#configure_fieldbook_qrcode_div),
    table:has(#configure_fieldbook_qrcode_div) :is(tbody, tr, td) {
        display: block;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    table:has(#configure_fieldbook_qrcode_div) td[width="60"] { display: none; }
    #configure_fieldbook_qrcode_div img { max-width: 100%; height: auto; }
    :is(#download_form, #download_metadata_form, #download_accession_properties,
        #download_pedigree, #download_cross_family, #download_seedlot_details,
        #download_obsolete_metadata_action, #download_gbs, #gbs_qc,
        #search_seedlot_form) :is(select, input:not([type="radio"]):not([type="checkbox"]), textarea),
    table:has(#label_rows, #page_format) :is(select, input) {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        box-sizing: border-box;
    }
    input[type="file"] { max-width: 100%; }
    .well:has(#search_seedlot_form) { padding: 12px !important; }
    .well .well:has(#search_seedlot_form),
    .panel-body:has(#search_seedlot_form) { padding-left: 0 !important; padding-right: 0 !important; }

    .dataTables_wrapper { overflow-x: visible; }
    .dataTables_wrapper :is(.dataTables_filter, .dataTables_length) {
        float: none !important;
        width: 100%;
        max-width: 100%;
        text-align: left !important;
    }
    .dataTables_wrapper .dataTables_filter label { display: block; width: 100%; }
    .dataTables_wrapper .dataTables_filter input {
        display: block;
        width: 100%;
        min-width: 0 !important;
        max-width: 100%;
        margin-left: 0 !important;
        box-sizing: border-box;
    }
    .dataTables_wrapper :is(.dataTables_scrollHead, .dataTables_scrollBody, .dataTables_scrollFoot) {
        max-width: 100%;
    }
    .sq-table-scroll {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }
    .sq-empty-subtitle { display: none !important; }
}

/* Account fields need enough room for email addresses and password managers. */
:is(#change_account_form, #quick_create_account_input_form) {
    max-width: 760px;
    padding: 20px;
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius);
    background: var(--sq-surface);
}
#change_account_form .textlabel {
    display: block;
    float: none;
    width: auto;
    max-width: none;
    overflow: visible;
    white-space: normal;
    margin: 8px 0 4px;
}
#change_account_form .form-control { width: min(100%, 440px); }
#quick_create_account_input_form input {
    min-height: 44px;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--sq-line);
    border-radius: var(--sq-radius-small);
    background: var(--sq-surface);
}
.sq-table-scroll:focus-visible { outline-offset: -3px; }
.sq-tree-open { margin: 8px 0; }

@media (max-width: 767px) {
    .sq-upload-directory > .well > table,
    .sq-upload-directory > .well > table > :is(thead, tbody),
    .sq-upload-directory > .well > table > :is(thead, tbody) > tr,
    .sq-upload-directory > .well > table > :is(thead, tbody) > tr > :is(th, td),
    #quick_create_account_input_form :is(table, tbody, tr, td) {
        display: block;
        width: 100%;
        max-width: 100%;
    }
    .sq-upload-directory > .well > table > thead { display: none; }
    .sq-upload-directory td[data-label]::before {
        display: block;
        content: attr(data-label);
        margin-bottom: 8px;
        color: var(--sq-text-strong);
        font-weight: 650;
    }
    #quick_create_account_input_form input { width: 100%; min-width: 0; }
    #change_account_form { padding: 14px; }
    #change_account_form button { max-width: 100%; white-space: normal; }
    :is(a[id^="edit_breeding_program_link_"], a[id^="delete_breeding_program_link_"]) {
        display: inline-flex;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }
    form:has(#start-date, #end-date) > div:has(#start-date, #end-date) {
        flex-wrap: wrap;
    }
    form:has(#start-date, #end-date) :is(input[type="text"], textarea) {
        max-width: 100%;
        width: 100%;
    }
    #validated_trials_tool { max-width: 100%; overflow-x: auto; }
    #statTable { display: block; max-width: 100%; overflow-x: auto; }
    #manage_sequence_metadata :is(.btn, button) { max-width: 100%; white-space: normal; }
    #manage_sequence_metadata .infosectionhead :is(tr, td) { display: block; width: 100% !important; }
    #outercontainer table[width="720"] { width: 100% !important; }
    #outercontainer :is(img[width="720"], img[width="800"], img[width="1000"]) { max-width: 100%; height: auto; }
}

#save_sin { min-width: 72px; white-space: nowrap; }

/* Long protocol prose and legacy single-row trait selectors remain readable. */
.sequence_metadata_protocol_type_header {
    align-items: flex-start !important;
    gap: 16px;
}
.sequence_metadata_protocol_type_header > * { min-width: 0; }
.sequence_metadata_protocol_type_definition { overflow-wrap: anywhere; }
label.blast_select_label[for="pheno_select"] {
    min-width: 140px;
    width: auto;
    white-space: nowrap;
}
@media (max-width: 767px) {
    .sequence_metadata_protocol_type_header { flex-direction: column; gap: 8px; }
    .sequence_metadata_protocol_type_header :is(h4, p) { width: 100%; margin: 0; }
    #outercontainer .well .well { padding: 12px !important; }
    #outercontainer .well .well .well { padding: 8px !important; }
}

@media (max-width: 767px) {
    :is(#cross_search_form, #progeny_search_form, #progeny_search_form_male_parent) .input-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    :is(#cross_search_form, #progeny_search_form, #progeny_search_form_male_parent) .input-group > :is(input, select, .input-group-btn) {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    :is(#cross_search_form, #progeny_search_form, #progeny_search_form_male_parent) .input-group-btn > button {
        display: block;
        width: 100%;
        margin: 0 0 6px;
        white-space: normal;
    }
    .panel-body:has(> table[id$="_search_results"]) { overflow-x: auto; max-width: 100%; }
    #PCRform table:not([class]),
    #PCRform table:not([class]) :is(tbody, tr, td) {
        display: block;
        width: 100%;
        max-width: 100%;
    }
    #PCRform :is(input:not([type="checkbox"]):not([type="radio"]), select) {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    #run_motifs, #run_motifs :is(textarea, .container),
    #well_width, #ad-option, #usage_view {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

.infosectioncontent:has(#newVectorForm) [name="add_vectors_link"] {
    float: none !important;
    margin-bottom: 16px;
}
#newVectorForm::after { display: block; content: ""; clear: both; }
#newVectorForm :is(button, input[type="reset"]) {
    float: none !important;
    margin: 0 8px 8px 0;
    max-width: 100%;
    white-space: normal;
}
@media (max-width: 767px) {
    .infosectioncontent:has(#newVectorForm) > .row > .col-sm-12 > .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Results have their own scroll region at every viewport width. */
.sq-table-scroll { clear: both; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.sq-table-scroll > table { max-width: none; }
#manage_user_roles_table :is(.label, .badge, td:nth-child(2) > span[style*="border-radius"]) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 6px 4px 0;
    padding: 6px 8px;
    line-height: 1.5;
    white-space: normal;
}
#manage_user_roles_table :is(.label, .badge, td:nth-child(2) > span[style*="border-radius"]) a { display: inline-flex; min-width: 28px; min-height: 28px; align-items: center; justify-content: center; }
@media (max-width: 767px) {
    .input-group:has(#document_browser_search_input) {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .input-group:has(#document_browser_search_input) > input { flex: 1 1 160px; width: auto; min-width: 0; }
    .input-group:has(#document_browser_search_input) .input-group-btn { display: block; width: auto; }
    .input-group:has(#document_browser_search_input) button { min-width: 88px; white-space: nowrap; }
    #document_browser_search_results { max-width: 100%; overflow-x: auto; }
    #document_browser_search_results_to_list { display: flow-root; max-width: 100%; }
    #document_browser_search_results_to_list .btn { max-width: 100%; white-space: normal; }
    #document_browser_search_results_to_list .row { margin-left: 0; margin-right: 0; }
}

@media (max-width: 767px) {
    #wizard > .wizard-main > .wizard-columns {
        display: flex;
        align-items: flex-start;
        overflow-x: auto;
        gap: 12px;
        scroll-snap-type: x proximity;
    }
    #wizard > .wizard-main > .wizard-columns > .wizard-column {
        float: none !important;
        width: 270px !important;
        flex: 0 0 270px;
        min-width: 0;
        scroll-snap-align: start;
    }
    #wizard .wizard-panel { max-width: 100%; }
    .wizard-datasets .input-group { display: block; width: 100%; }
    .wizard-datasets .input-group > .input-group-btn {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        margin-top: 8px;
    }
    .wizard-datasets :is(.wizard-dataset-select, .wizard-dataset-name) {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    #stock_search_form .input-group { display: block; width: 100%; }
    #stock_search_form .input-group > .input-group-btn { display: block; width: 100%; }
    #stock_search_form :is(#any_name_matchtype, #any_name, #stock_type_select) {
        display: block;
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        margin: 0 0 8px;
    }
}
#trait_search_results { min-width: 1120px; }
#trait_search_results :is(th, td):nth-child(6) { min-width: 280px; }
#trait_search_results :is(th, td):nth-child(4) { min-width: 200px; }

/* Keep the native Primer3 scientific grids and their Min/Opt/Max labels intact. */
@media (max-width: 767px) {
    form[action="primer3/update"] {
        min-width: 0;
        max-width: 100%;
    }
    form[action="primer3/update"] table {
        width: 100%;
        max-width: 100%;
        table-layout: fixed;
    }
    form[action="primer3/update"] :is(td, th) {
        min-width: 0;
        padding: 6px 4px;
        vertical-align: top;
        overflow-wrap: anywhere;
    }
    form[action="primer3/update"] label {
        white-space: normal;
        line-height: 1.5;
    }
    form[action="primer3/update"] :is(input[type="text"], select, textarea) {
        box-sizing: border-box;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        font-size: 16px;
    }
    form[action="primer3/update"] :is(input[type="text"], select) {
        min-height: 44px;
    }
    form[action="primer3/update"] textarea {
        resize: vertical;
    }
}

/* Native list headings become labels beside their controls on narrow screens. */
.sq-mobile-download-label { display: none; }
@media (max-width: 767px) {
    .sq-mobile-download-label {
        display: block;
        margin: 0 0 6px;
        font-weight: 600;
    }
    :is(#download_form, #download_metadata_form, #download_gbs, #gbs_qc).sq-download-selectors-labelled > table > thead > tr:has(th) {
        display: none;
    }

    /* Stack only the native ontology lookup form; its results and tree retain
       their existing handlers and layout. */
    table[title="ontology browser input form"],
    table[title="ontology browser input form"] > tbody,
    table[title="ontology browser input form"] > tbody > tr,
    table[title="ontology browser input form"] > tbody > tr > td,
    :is(#ontology_browser_input, #ontology_term_input),
    :is(#ontology_browser_input, #ontology_term_input) :is(table, tbody, tr, td) {
        display: block;
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    :is(#ontology_browser_input, #ontology_term_input) :is(input[type="text"], select) {
        display: block;
        box-sizing: border-box;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        margin-bottom: 8px;
    }
    :is(#ontology_browser_input, #ontology_term_input) :is(button, input[type="button"], input[type="submit"]) {
        max-width: 100%;
        min-height: 44px;
        white-space: normal;
        margin: 6px 0;
    }
}

/* Keep native field-location settings readable on phones. The allocation grid
   and desktop field layout retain their own geometry. */
@media (max-width: 767px) {
    #farm_settings_section_content .grid-cols-4 {
        grid-template-columns: minmax(0, 1fr);
    }
}
