/* SheepPro phone design system.
   Desktop chrome stays in base.html. Phone rules live under 767.98px.
   Opt-in helpers (.scroll-x, .tab-strip, .sticky-actions, .bottom-sheet,
   .list-card) are no-ops on desktop unless a later screen adds them. */

:root {
    --sp-tap: 44px;
    --sp-space-1: 4px;
    --sp-space-2: 8px;
    --sp-space-3: 12px;
    --sp-space-4: 16px;
    --sp-space-5: 24px;
    --sp-radius: 10px;
    --sp-radius-lg: 16px;
    --sp-safe-top: env(safe-area-inset-top, 0px);
    --sp-safe-right: env(safe-area-inset-right, 0px);
    --sp-safe-bottom: env(safe-area-inset-bottom, 0px);
    --sp-safe-left: env(safe-area-inset-left, 0px);
    --sp-topbar-height: 56px;
    --sp-brand: #1a2744;
    --sp-input-font: 16px;
    --sp-bg: #FAF9F6;
    --sp-window-row: 3.75rem;
    --sp-window-head: 2.25rem;
}

/* Tailwind's .collapse utility is visibility:collapse (table rows).
   Bootstrap's .collapse is a disclosure widget. After the open
   animation, .collapse.show would inherit Tailwind and look empty.
   Sidebar uses .sidebar.collapsed / body.sidebar-collapsed — not this. */
.collapse.show,
.collapsing {
    visibility: visible !important;
}

/* Page tabs (Import & Export, Drafting Groups). Same underline tabs as
   Import | Export | Pending. Lives here so HTMX pages that reuse
   .ie-page-tab are not left as bare <a> links. */
.ie-page-tab {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -2px;
    text-decoration: none;
}
a.ie-page-tab:hover,
a.ie-page-tab:focus,
a.ie-page-tab:focus-visible {
    color: #282f3c;
    text-decoration: none;
}
.ie-page-tab:hover { color: #282f3c; }
.ie-page-tab.active {
    color: #282f3c;
    border-bottom-color: #282f3c;
}

/* Sheep/lamb validation preview: compact row + gold existing-animal compare.
   Desktop stays dense (~28–30px controls). The 44px tap box is phone-only.
   Existing-animal rows start collapsed; yellow + left accent show when open. */
.ie-preview-table-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
    margin-bottom: 8px;
}
.ie-col-vis {
    width: 18px;
    height: 18px;
}
.ie-back-to-imports-form {
    display: inline;
    margin: 0;
}
.ie-existing-toggle-all {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--sp-tap);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
}
#preview-table tbody tr.ie-existing-animal-row,
#preview-table tbody tr.ie-existing-animal-row:nth-child(odd),
#preview-table tbody tr.ie-existing-animal-row:nth-child(even),
#preview-table tbody tr.ie-existing-animal-row:hover,
#preview-table tbody tr.ie-existing-animal-row > td {
    background: #fff3cd !important;
    background-color: #fff3cd !important;
}
.ie-existing-animal-row {
    box-shadow: inset 4px 0 0 #e6a800;
}
.ie-existing-animal-row > td {
    padding: 8px 12px;
    vertical-align: middle;
}
.ie-existing-animal-row[hidden] {
    display: none !important;
}
.ie-existing-animal-badge {
    background: #fde68a;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    white-space: normal;
}
.ie-existing-animal-source {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    font-weight: 600;
    color: #92400e;
}
.ie-existing-diff {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ie-existing-editable {
    cursor: pointer;
}
.ie-existing-edit,
.ie-existing-save,
.ie-existing-cancel {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.75rem;
    min-height: 1.75rem;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.ie-existing-save {
    background: #10b981;
    color: #fff;
    border: none;
}
.ie-existing-cancel {
    background: #e5e7eb;
    color: #374151;
    border: none;
}
.ie-existing-edit-input {
    width: 100%;
    min-width: 0;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
}
#preview-table col.ie-preview-errors-col,
#preview-table th.ie-preview-errors-cell,
#preview-table td.ie-preview-errors-cell {
    width: 10rem;
    max-width: 10rem;
}
.ie-preview-errors-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
#preview-table col.ie-preview-actions-col,
#preview-table th.ie-preview-actions-cell,
#preview-table td.ie-preview-actions-cell {
    width: 15rem;
    min-width: 15rem;
    max-width: 15rem;
}
#preview-table th.ie-preview-actions-cell,
#preview-table td.ie-preview-actions-cell {
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
    box-sizing: border-box;
}
#preview-table th.ie-preview-actions-cell {
    padding: 10px 12px;
}
#preview-table td.ie-preview-actions-cell {
    padding: 2px 12px;
}
.ie-resume-banners {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-2);
    margin: 0 0 var(--sp-space-4);
}
.ie-resume-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-3);
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--sp-radius);
    padding: var(--sp-space-3) var(--sp-space-4);
    color: #78350f;
    font-size: 14px;
}
.ie-resume-banner-text {
    flex: 1 1 12rem;
    min-width: 0;
}
.ie-resume-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
}

.ie-preview-actions-group {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    white-space: nowrap;
}
.ie-preview-action-form {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.ie-preview-action-form select,
.ie-preview-action-form input {
    box-sizing: border-box;
    height: 1.75rem;
    min-height: 1.75rem;
    font-size: 12px;
    padding: 2px 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}
.ie-preview-action-form input {
    width: 4.5rem;
}
#preview-table .ie-show-existing.btn-outline,
.ie-show-existing {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 1.75rem;
    min-height: 1.75rem;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 2px 8px;
    border-radius: 6px;
}
.ie-preview-edit {
    box-sizing: border-box;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.75rem;
    width: 1.75rem;
    min-height: 1.75rem;
    min-width: 1.75rem;
    padding: 2px;
    color: #6c757d;
}

/* One sideways+vertical scroller for sheep/lamb preview: thead lives
   in the same table as the body so columns stay aligned. */
#preview-table-wrapper.scroll-x {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}
#preview-table-wrapper.scroll-x-viewport {
    overflow: auto;
}
#preview-table.table,
#preview-table {
    width: max-content !important;
    min-width: max-content;
}

/* Hidden on desktop so extra body nodes do not join the flex shell. */
.sp-topbar,
.sp-drawer-backdrop {
    display: none;
}

/* Phone-only chrome. Desktop-only is the inverse, applied under 768px. */
.sp-phone-only,
.report-phone-only,
.ie-phone-only {
    display: none !important;
}

.report-phone-thead {
    display: none;
}

/* Visually hidden native file input (imports). */
.ie-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Filters that are a bottom sheet on phones stay inline on desktop
   (display:contents so the controls join the parent flex row). */
@media (min-width: 768px) {
    .bottom-sheet-inline.offcanvas,
    .bottom-sheet-inline.offcanvas-bottom {
        position: static !important;
        visibility: visible !important;
        transform: none !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        z-index: auto !important;
        display: contents !important;
        padding: 0 !important;
        transition: none !important;
    }

    .bottom-sheet-inline .offcanvas-header,
    .bottom-sheet-inline .bottom-sheet-handle,
    .bottom-sheet-inline .offcanvas-backdrop {
        display: none !important;
    }

    .bottom-sheet-inline .offcanvas-body {
        display: contents;
        padding: 0 !important;
        overflow: visible !important;
    }

    /* Split header tables stay pinned in .page-sticky-toolbar.
       The .scroll-x wrapper exists so phones can scroll header+body together;
       on desktop it must not generate a box. */
    #nsip-table-scroll,
    #genomics-table-scroll,
    #audit-table-scroll,
    #sync-table-scroll {
        display: contents;
    }
}

/* Opt-in: harmless on desktop (overflow only when content is wider). */
.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.scroll-x::-webkit-scrollbar {
    height: 4px;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Viewport-capped scroller for long wide tables (import previews).
   Caps height so this box is the vertical scroller: its own sideways
   scrollbar sits at the bottom of the box, and thead can stick.
   Desktop uses the flex shell below; phone JS in
   _mobile_import_styles.html sets --sp-viewport-scroll-max. The calc
   is fallback when neither applies. */
.scroll-x-viewport {
    overflow: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: var(--sp-viewport-scroll-max, calc(100vh - var(--sp-topbar-height) - 16rem));
    scrollbar-width: auto;
    scrollbar-color: #6b7280 #e5e7eb;
}

/* Offset is 0: this box is the scroller, sized so its top already sits
   under the app top bar / Confirm & Import toolbar. Window-sticky thead
   cannot work inside overflow-x (CSS computes overflow-y to auto). */
.scroll-x-viewport thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

.scroll-x-viewport thead th,
table[data-ie-resize] thead th {
    background: #282f3c;
    color: #fff;
    position: relative;
}

.scroll-x-viewport thead tr.col-group th {
    background: #374151;
}

table[data-ie-resize] {
    table-layout: fixed;
}

.ie-col-resize {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 4;
    touch-action: none;
    user-select: none;
}

.ie-col-resize:hover,
.ie-col-resizing .ie-col-resize {
    background: rgba(255, 255, 255, 0.28);
}

.ie-reset-col-widths {
    font-size: 13px;
    font-weight: 600;
}

.scroll-x-viewport::-webkit-scrollbar {
    height: 14px;
    width: 14px;
    background: #e5e7eb;
}

.scroll-x-viewport::-webkit-scrollbar-track {
    background: #e5e7eb;
}

.scroll-x-viewport::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 7px;
    border: 2px solid #e5e7eb;
}

.ie-preview-more {
    padding: 12px 16px;
    text-align: center;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

/* Desktop import preview: fill the content pane so the page itself
   does not scroll. Header/banners stay their natural height; the
   table viewport flexes; row-count + pager stay in view. Phone keeps
   natural page scroll (this block is desktop-only). */
@media (min-width: 768px) {
    .main-content:has(.scroll-x-viewport) {
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
    }

    #content-area:has(.scroll-x-viewport) {
        height: 100vh;
        max-height: 100vh;
        min-height: 0;
        overflow: hidden;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    #content-area:has(.scroll-x-viewport) > *:not(.ie-preview-table-block):not(.ebv-preview-page):not(.gen-preview-page) {
        flex-shrink: 0;
    }

    /* PM ZIP headers are tall (counts + breed chips). Keep the confirm
       toolbar; let the extra blocks shrink so the table stays on screen. */
    #content-area:has(#pmzip-preview-table-block) > *:not(.page-sticky-toolbar):not(.ie-preview-table-block):not(.ie-preview-end-confirm) {
        flex: 0 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #content-area:has(.scroll-x-viewport) .ebv-preview-page,
    #content-area:has(.scroll-x-viewport) .gen-preview-page {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        margin-top: 0;
        margin-bottom: 0;
    }

    #content-area:has(.scroll-x-viewport) .ebv-sticky-header,
    #content-area:has(.scroll-x-viewport) .gen-sticky-header {
        flex-shrink: 0;
    }

    #content-area:has(.scroll-x-viewport) .ie-preview-table-block {
        flex: 1 1 auto;
        min-height: 14rem;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #content-area:has(.scroll-x-viewport) .ie-preview-table-block > .scroll-x-viewport {
        flex: 1 1 auto;
        min-height: 12rem;
        max-height: none;
    }

    #content-area:has(.scroll-x-viewport) .ie-preview-page-summary,
    #content-area:has(.scroll-x-viewport) .pagination-footer {
        flex: 0 0 auto;
    }

    #content-area:has(.scroll-x-viewport) .pagination-footer {
        position: static;
        left: auto;
        right: auto;
        width: 100%;
        box-shadow: none;
        padding-left: 0;
        padding-right: 0;
    }

    #content-area:has(.scroll-x-viewport) .pagination-footer-spacer {
        display: none;
    }

    #pmzip-preview-table-block {
        padding-bottom: 0;
    }
}

/* One table + sticky th (not thead). Pixel col widths keep header/body aligned. */
.scroll-x-viewport .ie-pmzip-preview-table thead {
    position: static;
}

.scroll-x-viewport .ie-pmzip-preview-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.ie-pmzip-preview-table {
    width: 100%;
    min-width: 988px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
}

.ie-pmzip-preview-table col.ie-pmzip-col-num { width: 48px; }
.ie-pmzip-preview-table col.ie-pmzip-col-id { width: 160px; }
.ie-pmzip-preview-table col.ie-pmzip-col-action { width: 88px; }
.ie-pmzip-preview-table col.ie-pmzip-col-sex { width: 56px; }
.ie-pmzip-preview-table col.ie-pmzip-col-dob { width: 96px; }
.ie-pmzip-preview-table col.ie-pmzip-col-btrt { width: 72px; }
.ie-pmzip-preview-table col.ie-pmzip-col-status { width: 88px; }
.ie-pmzip-preview-table col.ie-pmzip-col-sire { width: 220px; }
.ie-pmzip-preview-table col.ie-pmzip-col-issues { width: 160px; }

.ie-pmzip-preview-table th,
.ie-pmzip-preview-table td {
    box-sizing: border-box;
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.ie-pmzip-preview-table thead th {
    background: #282f3c;
    color: #fff;
    border-bottom: 1px solid #1f2937;
    text-align: left;
    white-space: nowrap;
}

.ie-pmzip-preview-table .ie-pmzip-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ie-pmzip-preview-table thead th.ie-pmzip-num {
    text-align: right;
}

.ie-pmzip-preview-table .ie-pmzip-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ie-pmzip-preview-table .ie-pmzip-issues {
    white-space: normal;
    overflow-wrap: anywhere;
    color: #b45309;
}


@media (max-width: 767.98px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        overflow: auto;
        height: auto;
        display: block;
    }

    body.sp-drawer-open {
        overflow: hidden;
        touch-action: none;
    }

    /* ── Shell ── */
    .main-content {
        margin-left: 0;
        padding-top: calc(var(--sp-topbar-height) + var(--sp-safe-top));
        overflow: visible;
        height: auto;
        min-height: 0;
        transition: none;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 12px;
        min-height: 0;
        overflow: visible;
        height: auto;
    }

    .content-area > .d-flex.justify-content-between {
        padding-right: 0;
        padding-top: 0;
    }

    /* Nested toolbars (inside cards / #content-area) must not use the
       phone top-bar offset. sticky + overflow:hidden leaves a white band
       and can clip the first label. Keep sticky only for a direct child
       of .main-content, or the documented opt-in .sp-toolbar-sticky. */
    .page-sticky-toolbar,
    .animals-list-toolbar {
        position: static;
        top: auto;
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .main-content > .page-sticky-toolbar,
    .page-sticky-toolbar.sp-toolbar-sticky {
        position: sticky;
        top: calc(var(--sp-topbar-height) + var(--sp-safe-top));
    }

    .delete-footer {
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .pagination-footer {
        left: 0 !important;
        right: 0 !important;
        padding: 6px 12px calc(6px + var(--sp-safe-bottom));
    }

    body.sidebar-collapsed .pagination-footer {
        left: 0 !important;
    }

    /* ── Drawer ── */
    .sidebar,
    .sidebar.collapsed {
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
        width: clamp(200px, 56vw, 230px) !important;
        z-index: 420;
        top: 0;
        height: 100%;
        height: 100dvh;
        padding-top: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    body.sp-drawer-open .sidebar {
        transform: none;
        visibility: visible;
        transition: transform 0.25s ease, visibility 0s;
    }

    #sidebar-toggle-btn {
        display: none !important;
    }

    .sidebar .logo-section,
    .sidebar.collapsed .logo-section {
        position: sticky;
        top: 0;
        z-index: 2;
        height: 44px;
        min-height: 44px;
        max-height: 44px;
        padding: 0 2px 0 10px;
        justify-content: space-between;
        flex-direction: row;
        gap: 0;
        background-color: #1a2744;
        box-sizing: border-box;
    }

    .sidebar .logo-icon,
    .sidebar.collapsed .logo-icon {
        width: 22px;
        height: 22px;
        margin-right: 6px;
    }

    .sidebar .logo-text.sp-phone-only {
        font-size: 15px;
        font-weight: 700;
        line-height: 1;
        color: #fff;
        font-family: Georgia, "Times New Roman", serif;
    }

    .sp-drawer-close,
    #sp-drawer-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: #fff;
        cursor: pointer;
        flex-shrink: 0;
    }

    .sp-drawer-close:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.7);
        outline-offset: 2px;
    }

    .sidebar nav {
        flex: none;
        overflow: visible;
        padding: 2px 0 4px;
    }

    /* 38px visual row. A 44px box (38 + 3+3 padding) cannot fit
       Dashboard→NSIP in 664px, so the link box is 38px (real, not ::after). */
    .sidebar .sidebar-item,
    .sidebar.collapsed .sidebar-item {
        min-height: 38px;
        height: 38px;
        padding: 6px 10px;
        margin: 0 6px;
        font-size: 13.5px;
        line-height: 1.2;
        gap: 8px;
        justify-content: flex-start;
        box-sizing: border-box;
        border-radius: 8px;
        white-space: nowrap;
    }

    .sidebar .sidebar-item.active {
        padding: 6px 10px;
        border-radius: 8px;
    }

    .sidebar .sidebar-item-label {
        overflow: hidden;
        text-overflow: clip;
        min-width: 0;
    }

    .sidebar .sidebar-item svg,
    .sidebar .sidebar-item i,
    .sidebar.collapsed .sidebar-item svg,
    .sidebar.collapsed .sidebar-item i {
        width: 15px;
        min-width: 15px;
        height: 15px;
        margin-right: 0;
        font-size: 15px;
    }

    .sidebar .sidebar-group-label {
        font-size: 9.5px;
        letter-spacing: 0.06em;
        margin: 8px 0 2px;
        padding: 0 16px 0;
    }

    .sidebar-support {
        padding: 0 !important;
        margin-top: 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        flex-shrink: 0;
    }

    .sidebar-support .sidebar-item {
        font-size: 13.5px !important;
        opacity: 1 !important;
    }

    /* Collapsed desktop state must not leak: always show labels and full width. */
    .sidebar.collapsed .sidebar-item-label,
    .sidebar.collapsed .sidebar-group-label {
        display: revert !important;
    }

    .sidebar.collapsed .logo {
        margin-right: 0;
        justify-content: flex-start;
    }

    .sidebar.collapsed .sidebar-notification-badge {
        position: static;
        top: auto;
        right: auto;
        margin-left: auto;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 10px;
        border-radius: 9px;
    }

    .sidebar.collapsed .sidebar-item.sidebar-notifications {
        position: static;
    }

    .sidebar.collapsed .sidebar-premium-badge {
        position: static;
        top: auto;
        right: auto;
        width: auto;
        height: auto;
        padding: 2px 7px;
        font-size: 9px;
        border-radius: 9px;
    }

    .sidebar.collapsed .sidebar-item.premium-locked {
        position: static;
    }

    .sp-drawer-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 300;
        border: 0;
        padding: 0;
    }

    body.sp-drawer-open .sp-drawer-backdrop {
        display: block;
    }

    /* ── Top bar (phone only) ── */
    .sp-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 410;
        height: calc(var(--sp-topbar-height) + var(--sp-safe-top));
        padding: var(--sp-safe-top) 8px 0;
        background: var(--sp-brand);
        color: #fff;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
    }

    .sp-topbar-progress {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 2px;
        overflow: hidden;
        pointer-events: none;
        background: transparent;
    }

    .sp-topbar-progress.is-active {
        display: block;
    }

    .sp-topbar-progress-bar {
        height: 100%;
        width: 36%;
        background: #f59e0b;
        animation: sp-topbar-indet 1.1s ease-in-out infinite;
    }

    .sp-topbar-btn {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    .sp-topbar-btn:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.7);
        outline-offset: 2px;
    }

    .sp-topbar-title {
        flex: 1;
        min-width: 0;
        text-align: center;
        font-size: 16px;
        font-weight: 650;
        color: #fff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 8px;
    }

    .sp-topbar-profile .user-avatar {
        width: 32px;
        height: 32px;
        background-color: rgba(255, 255, 255, 0.16);
        font-size: 12px;
    }

    .profile-dropdown-wrapper {
        top: 60px;
        right: 12px;
        z-index: 250;
    }

    .profile-dropdown-wrapper .profile-trigger {
        display: none;
    }

    /* ── Scroll / tabs ── */
    .scroll-x {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
    }

    .scroll-x-viewport {
        mask-image: none;
    }

    .scroll-x-viewport thead th,
    table[data-ie-resize] thead th {
        padding-top: 6px;
        padding-bottom: 6px;
        font-size: 10px;
    }

    .ie-col-resize {
        width: 16px;
        min-height: var(--sp-tap);
    }

    .tab-strip,
    .tab-strip.nav,
    .tab-strip.nav-tabs,
    .tab-strip .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .tab-strip .nav-item,
    .tab-strip .nav-link,
    .tab-strip .ie-page-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .ie-page-tab {
        padding: 12px 18px;
        min-height: var(--sp-tap);
    }

    /* ── Sticky bottom actions ── */
    .sticky-actions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px calc(8px + var(--sp-safe-bottom));
        background: var(--sp-bg);
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .sticky-actions > * {
        min-height: var(--sp-tap);
    }

    /* ── Bottom sheet (Bootstrap offcanvas-bottom) ── */
    .bottom-sheet.offcanvas-bottom,
    .offcanvas-bottom.bottom-sheet {
        border-top-left-radius: var(--sp-radius-lg);
        border-top-right-radius: var(--sp-radius-lg);
        max-height: 85vh;
        padding-bottom: var(--sp-safe-bottom);
    }

    .bottom-sheet-handle {
        display: block;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 2px;
        background: #cbd5e1;
    }

    .bottom-sheet.offcanvas-bottom::before,
    .offcanvas-bottom.bottom-sheet::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 2px;
        background: #cbd5e1;
    }

    /* ── List card rows ── */
    .list-card {
        display: block;
        position: relative;
        padding: 12px 32px 12px 12px;
        border-bottom: 1px solid #e5e7eb;
        background: #fff;
        text-align: left;
    }

    .list-card-title {
        display: block;
        font-weight: 600;
        font-size: 16px;
        color: #111827;
    }

    .list-card-sub {
        display: block;
        font-size: 13px;
        color: #6b7280;
        margin-top: 2px;
    }

    .list-card-chip {
        display: inline-block;
        margin-top: 6px;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
        background: #e5e7eb;
        color: #374151;
    }

    .list-card::after {
        content: "";
        position: absolute;
        right: 12px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 2px solid #9ca3af;
        border-top: 2px solid #9ca3af;
        transform: translateY(-50%) rotate(45deg);
    }

    /* ── Modals: fullscreen + sticky footer ── */
    .modal-dialog {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    .modal-content {
        height: 100%;
        min-height: 100%;
        border: 0;
        border-radius: 0;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: inherit;
        padding-bottom: calc(0.75rem + var(--sp-safe-bottom));
    }

    /* ── Tap targets ── */
    .btn,
    .btn-outline,
    a.btn-outline {
        min-height: var(--sp-tap);
    }

    .btn-sm {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }

    .pw-toggle {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    a[href^="tel:"],
    a[href^="mailto:"],
    a.sp-tap-link {
        min-height: var(--sp-tap);
        display: inline-flex;
        align-items: center;
    }

    .form-control,
    .form-select {
        min-height: var(--sp-tap);
        font-size: var(--sp-input-font);
    }

    .sidebar-item {
        min-height: var(--sp-tap);
    }

    .dropdown-item,
    .profile-dropdown-item {
        min-height: var(--sp-tap);
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }

    /* Undo banner sits above a future sticky action bar. */
    #undo-banner > div {
        bottom: calc(72px + var(--sp-safe-bottom)) !important;
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        max-width: none;
    }

    .sp-desktop-only {
        display: none !important;
    }

    .sp-phone-only {
        display: revert !important;
    }

    button.sp-phone-only,
    .btn.sp-phone-only,
    .btn-outline.sp-phone-only {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        gap: 6px;
    }

    .sp-phone-only.d-flex {
        display: flex !important;
    }

    /* ── Table body → list cards (td[data-label]) ── */
    .list-card-table,
    .list-card-table tbody {
        display: block;
        width: 100%;
    }

    .list-card-table thead {
        display: none !important;
    }

    .list-card-table tbody > tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        position: relative;
        padding: 12px 32px 12px 12px;
        border-bottom: 1px solid #e5e7eb;
        background: #fff;
        text-align: left;
        width: 100%;
    }

    .list-card-table tbody > tr.row-clickable::after {
        content: "";
        position: absolute;
        right: 12px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 2px solid #9ca3af;
        border-top: 2px solid #9ca3af;
        transform: translateY(-50%) rotate(45deg);
    }

    .list-card-table td {
        overflow: visible !important;
        text-overflow: unset !important;
        white-space: normal !important;
        width: auto !important;
        max-width: none !important;
        border: none !important;
        padding: 2px 0;
        background: transparent !important;
        box-shadow: none !important;
    }

    .list-card-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-bottom: 2px;
    }

    .list-card-table tbody > tr:not(.animal-row):not(.row-clickable) {
        display: block;
        padding: 16px 12px;
    }

    .list-card-table tbody > tr:not(.animal-row):not(.row-clickable)::after {
        content: none;
    }

    .list-card-table tbody > tr:not(.animal-row) td {
        display: block;
        width: 100% !important;
        text-align: center;
        padding: 8px 0;
    }

    .list-card-table tbody > tr.animal-row-highlight {
        background-color: #fff3cd !important;
        box-shadow: inset 0 0 0 9999px rgba(255, 193, 7, 0.25);
    }

    .list-card-table tbody > tr.animal-row-highlight.animal-row-highlight-fade {
        background-color: transparent !important;
        box-shadow: none;
        transition: background-color 600ms ease, box-shadow 600ms ease;
    }

    /* Animals reference card: title / name / chips / sub, extras labeled. */
    #animals-body-table.list-card-table td {
        display: none;
    }

    #animals-body-table.list-card-table td.ac-flock_prefix,
    #animals-body-table.list-card-table td.ac-ear_tag {
        display: inline;
        order: 1;
        flex: 0 0 auto;
        font-weight: 600;
        font-size: 16px;
        color: #111827;
        padding: 0 4px 0 0;
    }

    #animals-body-table.list-card-table td.ac-name {
        display: block;
        order: 2;
        flex: 1 1 100%;
        font-size: 14px;
        color: #374151;
    }

    #animals-body-table.list-card-table td.ac-sex,
    #animals-body-table.list-card-table td.ac-status {
        display: inline-block;
        order: 3;
        flex: 0 0 auto;
        margin-top: 6px;
        margin-right: 6px;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
        background: #e5e7eb;
        color: #374151;
    }

    #animals-body-table.list-card-table td.ac-breed,
    #animals-body-table.list-card-table td.ac-nsip {
        display: block;
        order: 4;
        flex: 1 1 100%;
        font-size: 13px;
        color: #6b7280;
        margin-top: 2px;
    }

    #animals-body-table.list-card-table td.ac-ear_tag_ext,
    #animals-body-table.list-card-table td.ac-eid,
    #animals-body-table.list-card-table td.ac-year_born,
    #animals-body-table.list-card-table td.ac-draft_group,
    #animals-body-table.list-card-table td.ac-lambing_group,
    #animals-body-table.list-card-table td.ac-dam_tag,
    #animals-body-table.list-card-table td.ac-dam_nsip,
    #animals-body-table.list-card-table td.ac-sire_tag,
    #animals-body-table.list-card-table td.ac-sire_nsip,
    #animals-body-table.list-card-table td.ac-custom {
        display: block;
        order: 5;
        flex: 1 1 100%;
        font-size: 13px;
        color: #374151;
        margin-top: 6px;
    }

    #animals-body-table.list-card-table td.ac-flock_prefix {
        display: none;
    }

    #animals-body-table.list-card-table td.ac-ear_tag::before {
        content: attr(data-flock-prefix) " ";
        display: inline;
        font-weight: 600;
        font-size: 16px;
        color: #111827;
        text-transform: none;
        letter-spacing: 0;
        margin: 0;
    }

    #animals-body-table.list-card-table td.ac-flock_prefix::before,
    #animals-body-table.list-card-table td.ac-name::before,
    #animals-body-table.list-card-table td.ac-sex::before,
    #animals-body-table.list-card-table td.ac-status::before,
    #animals-body-table.list-card-table td.ac-breed::before,
    #animals-body-table.list-card-table td.ac-nsip::before {
        content: none;
    }

    #animals-body-table.list-card-table td.ac-select {
        display: none;
        order: 0;
    }

    body.animals-select-mode #animals-body-table.list-card-table td.ac-select {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 4px;
        top: 8px;
        width: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0;
    }

    body.animals-select-mode #animals-body-table.list-card-table tbody > tr.animal-row {
        padding-left: 52px;
    }

    body.animals-select-mode #animals-body-table .bulk-checkbox {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }

    .animals-col-resize {
        display: none !important;
    }

    /* Sticky first column inside a horizontal scroller. */
    .scroll-x-sticky-first th:first-child,
    .scroll-x-sticky-first td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: #fff;
    }

    .scroll-x-sticky-first thead th:first-child {
        z-index: 2;
        background: #f3f4f6;
    }

    /* Bottom-sheet checklist rows (column picker, filters). */
    .sheet-check-row,
    .sheet-row {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: var(--sp-tap);
        padding: 4px 0;
        font-size: 16px;
        cursor: pointer;
        color: #374151;
    }

    .sheet-check-row input[type="checkbox"],
    .sheet-row input[type="checkbox"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        accent-color: #1a2744;
        flex-shrink: 0;
    }

    .sheet-section-label {
        font-size: 0.75rem;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 8px;
    }

    .scroll-x .data-table,
    .scroll-x .nsip-results-table {
        overflow: visible;
    }

    #nsip-dashboard-body-table tbody tr.animal-row,
    #genomics-body-table tbody tr.animal-row {
        min-height: var(--sp-tap);
    }

    #nsip-header-table,
    #genomics-header-table,
    #audit-header-table,
    #sync-header-table {
        display: none;
    }

    #genomics-body-table.list-card td,
    #nsip-dashboard-body-table.list-card td {
        min-height: var(--sp-tap);
        padding: 12px 0 !important;
    }

    #nsip-dashboard-body-table.list-card td:first-child {
        font-weight: 600;
    }

    .pagination-footer .pagination-btn,
    .pagination-footer a.pagination-btn,
    .pagination-footer select {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        font-size: var(--sp-input-font);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .sticky-actions {
        left: 0 !important;
        right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #animal-form input[type="checkbox"],
    #animal-form .form-check-input,
    #bulk-edit-form input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    #addCustomFieldBtn {
        min-height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        padding: 8px 12px !important;
        font-size: 16px !important;
    }

    .form-section-body button.px-2.py-1 {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    /* ── Aliases of .sp-phone-only / .sp-desktop-only ── */
    .report-phone-only,
    .ie-phone-only {
        display: revert !important;
    }

    button.report-phone-only,
    .btn.report-phone-only,
    .btn-outline.report-phone-only,
    button.ie-phone-only,
    .btn.ie-phone-only,
    .btn-outline.ie-phone-only,
    .ie-show-table {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        gap: 6px;
    }

    .ie-phone-only.ie-phone-flex,
    .ie-phone-only.d-flex,
    .sticky-actions.ie-phone-only {
        display: flex !important;
    }

    .ie-desktop-only,
    .report-desktop-thead {
        display: none !important;
    }

    .report-phone-thead {
        display: table-header-group !important;
    }

    /* ── table.list-card → stacked labeled rows ── */
    .list-card-header,
    table.list-card thead {
        display: none !important;
    }

    table.list-card,
    table.list-card tbody,
    table.list-card tr {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
    }

    table.list-card {
        padding: 0;
        border-bottom: none;
        background: transparent;
    }

    table.list-card::after {
        display: none;
        content: none;
    }

    table.list-card tbody > tr,
    table.list-card tr.list-card-row {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
        width: 100%;
    }

    table.list-card td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px;
        border: none;
        white-space: normal;
    }

    table.list-card td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.8rem;
        flex-shrink: 0;
        margin-right: 12px;
    }

    table.list-card td:not([data-label])::before,
    table.list-card td[data-label=""]::before,
    table.list-card td[colspan]::before {
        content: none;
        margin-right: 0;
    }

    table.list-card td[data-label=""],
    table.list-card td[colspan] {
        justify-content: center;
    }

    table.list-card td.list-card-title {
        font-weight: 700;
        font-size: 1rem;
    }

    table.list-card colgroup {
        display: none;
    }

    .scroll-x {
        max-width: 100%;
    }

    .sticky-actions .btn,
    .sticky-actions .btn-outline {
        min-height: var(--sp-tap);
        flex: 1 1 auto;
        font-size: 16px;
    }

    /* ── Reports hub ── */
    .report-hub-grid {
        display: flex !important;
        flex-direction: column;
        gap: 12px !important;
    }

    .report-hub-card {
        width: 100% !important;
        min-height: var(--sp-tap);
        padding: 16px 14px !important;
        box-sizing: border-box;
    }

    .report-hub-banner {
        min-height: var(--sp-tap);
    }

    .analytics-chart-wrap:not(.analytics-chart-wrap--donut) {
        height: 220px;
    }

    /* ── Import shell ── */
    .ie-drop-zone {
        min-height: 120px;
        padding: 20px 14px !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .ie-map-source-row select {
        width: 100%;
        min-height: var(--sp-tap);
        font-size: var(--sp-input-font);
    }

    .ie-error-card {
        background: #fff;
        border: 1px solid #fecaca;
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 10px;
    }

    .ie-error-card .ie-error-row {
        font-size: 12px;
        font-weight: 700;
        color: #991b1b;
    }

    .ie-error-card .ie-error-field {
        font-size: 14px;
        font-weight: 700;
        color: #111827;
        margin-top: 2px;
    }

    .ie-error-card .ie-error-problem {
        font-size: 13px;
        color: #7f1d1d;
        margin-top: 4px;
    }

    .ie-error-card .ie-error-hint {
        font-size: 12px;
        color: #6b7280;
        margin-top: 4px;
    }

    .ie-preview-table-block {
        display: none;
        max-width: 100%;
        min-width: 0;
    }

    .ie-preview-table-block.is-shown {
        display: block;
    }

    #preview-table-wrapper.scroll-x {
        overflow-x: auto !important;
        max-width: 100%;
        min-width: 0;
    }
    #preview-table-wrapper.scroll-x-viewport {
        overflow-y: auto;
    }

    .ie-preview-plan {
        font-size: 14px;
        line-height: 1.5;
    }

    .ie-dup-toolbar select,
    .ie-dup-toolbar button,
    .ie-dup-toolbar label {
        min-height: var(--sp-tap);
    }

    .ie-preview-stats {
        flex-wrap: wrap;
    }

    .ie-preview-stats > div {
        min-width: calc(50% - 8px);
        flex: 1 1 calc(50% - 8px);
    }

    .ie-progress-track {
        width: 100%;
        height: 10px;
        background: #e5e7eb;
        border-radius: 999px;
        overflow: hidden;
        margin-top: 16px;
    }

    .ie-progress-fill {
        height: 100%;
        background: #16a34a;
        border-radius: 999px;
    }

    #pm-zip-running {
        margin: 16px 0;
    }

    .ie-has-sticky-actions {
        padding-bottom: 84px;
    }

    .ie-show-table {
        width: 100%;
        margin: 8px 0 12px;
        font-size: 14px;
        font-weight: 600;
    }

    .ebv-skip-label {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    .ebv-skip-cb {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sp-drawer-backdrop,
    .profile-dropdown,
    .main-content {
        transition: none !important;
    }

    .sp-topbar-progress-bar {
        animation: none;
        width: 100%;
        opacity: 0.65;
    }
}

@keyframes sp-topbar-indet {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(380%); }
}

@media print {
    .sp-topbar,
    .sp-drawer-backdrop {
        display: none !important;
    }
}

/* ===== Phone UX pass 2: compact chrome =====
   audit-mobile measures getBoundingClientRect of the element itself
   (not a ::after hit-area), so compact controls keep a 44px box
   (--sp-tap) and look smaller via 14px type + 6/12 padding + wrap. */
@media (max-width: 767.98px) {
    .btn,
    .btn-outline,
    a.btn-outline,
    .btn-sm,
    .page-header .btn,
    .page-header .btn-outline,
    .page-header .btn-sm {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.2;
        white-space: nowrap;
    }

    #preview-table .ie-show-existing.btn-outline,
    #preview-table .ie-show-existing,
    #preview-table .ie-preview-edit,
    #preview-table .ie-existing-edit,
    #preview-table .ie-existing-save,
    #preview-table .ie-existing-cancel,
    #preview-table .ie-existing-edit-input,
    #preview-table .ie-preview-action-form select,
    #preview-table .ie-preview-action-form input,
    .ie-existing-toggle-all {
        min-height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        box-sizing: border-box;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.2;
        white-space: nowrap;
    }

    #preview-table tbody > tr.ie-existing-animal-row[hidden] {
        display: none !important;
    }

    #preview-table tbody > tr.ie-existing-animal-row:not([hidden]),
    #preview-table tbody > tr.ie-existing-animal-row:not([hidden]):nth-child(odd),
    #preview-table tbody > tr.ie-existing-animal-row:not([hidden]):nth-child(even),
    #preview-table tbody > tr.ie-existing-animal-row:not([hidden]):hover {
        background: #fff3cd !important;
        background-color: #fff3cd !important;
        box-shadow: inset 4px 0 0 #e6a800;
        border-radius: var(--sp-radius);
    }

    #preview-table tbody > tr.ie-existing-animal-row:not([hidden]) > td {
        background: #fff3cd !important;
        background-color: #fff3cd !important;
    }

    #preview-table .ie-preview-edit {
        width: var(--sp-tap) !important;
        padding: 6px;
    }

    #preview-table td.ie-preview-actions-cell {
        padding: 4px 12px;
    }

    #preview-table td.ie-preview-errors-cell {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .page-header {
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
        margin-bottom: 10px;
        padding-right: 0;
    }

    .page-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
        justify-content: flex-end;
    }

    .page-header .btn,
    .page-header .btn-outline,
    .animals-list-toolbar .btn,
    .animals-list-toolbar .btn-outline,
    .ie-hub-actions .btn,
    .ie-hub-actions .btn-outline,
    .weighing-header-actions .btn,
    .weighing-header-actions .btn-outline {
        width: auto;
        flex: 0 0 auto;
    }

    .page-sticky-toolbar .form-control,
    .animals-list-toolbar input[type="text"],
    #search-animals,
    #animal-jump-search {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        box-sizing: border-box;
        font-size: 16px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .sticky-actions {
        min-height: var(--sp-tap);
        padding: 0 12px var(--sp-safe-bottom);
        align-items: center;
        box-sizing: content-box;
    }

    .sticky-actions .btn,
    .sticky-actions .btn-outline {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        font-size: 14px;
        padding: 6px 12px;
    }

    .content-area:has(.sticky-actions) {
        padding-bottom: calc(var(--sp-tap) + 16px + var(--sp-safe-bottom));
    }

    /* Pagination: slim app-style bar; sheet/backdrop sit above it. */
    .pagination-footer {
        z-index: 40;
        height: var(--sp-tap);
        padding: 0 8px var(--sp-safe-bottom);
        box-sizing: content-box;
        display: flex;
        align-items: center;
    }

    .pagination-footer-spacer {
        height: calc(var(--sp-tap) + var(--sp-safe-bottom));
    }

    .pagination-footer nav {
        width: 100%;
    }

    .pagination-footer nav > div {
        position: relative;
        width: 100%;
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important;
        padding-left: var(--sp-tap);
        padding-right: var(--sp-tap);
        box-sizing: border-box;
    }

    .pagination-nav-group {
        display: flex !important;
        flex: 0 1 auto;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border: none !important;
        background: transparent !important;
        overflow: visible !important;
        min-width: 0;
    }

    .pagination-footer .pagination-btn,
    .pagination-footer a.pagination-btn,
    .pagination-footer .pagination-btn-disabled {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        width: var(--sp-tap);
        height: var(--sp-tap);
        padding: 0 !important;
        border: 1px solid #1a2744 !important;
        border-radius: 8px;
        background: #fff !important;
        color: #1a2744 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        text-decoration: none;
        flex-shrink: 0;
    }

    .pagination-footer .pagination-btn i,
    .pagination-footer .pagination-btn-disabled i {
        font-size: 14px !important;
        color: #1a2744 !important;
    }

    .pagination-footer .pagination-btn-disabled {
        opacity: 0.4;
    }

    .pagination-range {
        flex: 0 0 auto;
        min-width: 0;
        text-align: center;
        font-size: 13px !important;
        font-weight: 600;
        color: #1a2744;
        border: none !important;
        padding: 0 2px !important;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
    }

    .pagination-per-page {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        gap: 0 !important;
        flex: 0 0 auto;
        margin: 0;
    }

    @media (max-width: 359.98px) {
        .pagination-range-of {
            display: none;
        }
    }

    .pagination-footer select,
    .pagination-per-page-select {
        -webkit-appearance: none;
        appearance: none;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        width: auto;
        height: var(--sp-tap);
        padding: 0 10px !important;
        border: 1px solid #1a2744 !important;
        border-radius: 8px;
        background: #fff !important;
        color: #1a2744;
        font-size: 13px !important;
        font-weight: 700;
        line-height: 1;
        cursor: pointer;
    }

    .offcanvas-backdrop,
    .offcanvas-backdrop.show {
        z-index: 420 !important;
    }

    .bottom-sheet.offcanvas,
    .offcanvas.bottom-sheet,
    .bottom-sheet.offcanvas-bottom,
    .offcanvas-bottom.bottom-sheet {
        z-index: 430 !important;
    }

    body:has(.bottom-sheet.show) .pagination-footer,
    body:has(.offcanvas.show) .pagination-footer,
    body:has(.offcanvas-backdrop.show) .pagination-footer {
        visibility: hidden;
        pointer-events: none;
    }

    /* List cards: no CSS prefix (template filter owns the title);
       name / NSIP are a muted second line, left-aligned. */
    #animals-body-table.list-card-table td.ac-ear_tag::before {
        content: none !important;
    }

    #animals-body-table.list-card-table td.ac-name,
    #animals-body-table.list-card-table td.ac-nsip,
    #animals-body-table.list-card-table td.ac-breed {
        display: block !important;
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: left !important;
        justify-content: flex-start;
        color: #6b7280;
        font-size: 13px;
        font-weight: 400;
    }

    #animals-body-table.list-card-table td.ac-name {
        order: 2;
        margin-top: 2px;
    }

    #animals-body-table.list-card-table td.ac-nsip,
    #animals-body-table.list-card-table td.ac-breed {
        order: 4;
    }
}

/* ===== Phone: animals infinite scroll + compact cards ===== */
@media (max-width: 767.98px) {
    .animals-pagination-desktop,
    #animals-results .pagination-footer,
    #animals-results .pagination-footer-spacer {
        display: none !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body:has(#animals-results) .pagination-footer-spacer {
        height: 0 !important;
    }

    .animals-list-toolbar .page-header {
        gap: 8px;
        margin-bottom: 8px;
    }

    #animals-filter-bar {
        padding: 8px 12px !important;
        margin-bottom: 8px;
    }

    .animals-filter-row {
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    #search-animals,
    #animals-filter-sheet-btn,
    #animals-select-toggle,
    #animals-clear-filters {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        height: var(--sp-tap);
    }

    .animals-list-head-card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        border-radius: 0 !important;
    }

    .animals-list-head-bar {
        padding: 4px 4px 8px !important;
        border-bottom: none !important;
    }

    #animals-count-heading,
    #animals-count-heading .animals-count-phone {
        font-size: 13px !important;
        font-weight: 500 !important;
        color: #6b7280 !important;
        line-height: 1.2;
    }

    #animals-body-table.list-card-table tbody > tr.animal-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 6px;
        row-gap: 2px;
        padding: 10px 32px 10px 12px;
        min-height: 56px;
        box-sizing: border-box;
    }

    #animals-body-table.list-card-table tbody > tr.animal-row.row-clickable::after {
        top: 50%;
        right: 12px;
    }

    #animals-body-table.list-card-table td.ac-ear_tag {
        display: block !important;
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        padding: 0 !important;
    }

    #animals-body-table.list-card-table td.ac-ear_tag .list-card-title,
    #animals-body-table.list-card-table td.ac-ear_tag .sp-phone-only {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    #animals-body-table.list-card-table td.ac-sex,
    #animals-body-table.list-card-table td.ac-status,
    #animals-body-table.list-card-table td.ac-sex.list-card-chip,
    #animals-body-table.list-card-table td.ac-status.list-card-chip {
        display: inline-flex !important;
        order: 2;
        flex: 0 0 auto;
        align-items: center;
        margin: 0 !important;
        padding: 1px 7px !important;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        background: #e5e7eb !important;
        color: #374151 !important;
    }

    #animals-body-table.list-card-table td.ac-name {
        order: 3;
        flex: 1 1 100%;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 13px;
        font-weight: 400;
        color: #6b7280;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    #animals-body-table.list-card-table td.ac-name .list-card-sub {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13px;
        color: #6b7280;
    }

    #animals-body-table.list-card-table td.ac-eid,
    #animals-body-table.list-card-table td.ac-nsip,
    #animals-body-table.list-card-table td.ac-breed,
    #animals-body-table.list-card-table td.ac-ear_tag_ext,
    #animals-body-table.list-card-table td.ac-year_born,
    #animals-body-table.list-card-table td.ac-draft_group,
    #animals-body-table.list-card-table td.ac-lambing_group,
    #animals-body-table.list-card-table td.ac-dam_tag,
    #animals-body-table.list-card-table td.ac-dam_nsip,
    #animals-body-table.list-card-table td.ac-sire_tag,
    #animals-body-table.list-card-table td.ac-sire_nsip,
    #animals-body-table.list-card-table td.ac-custom {
        display: none !important;
    }

    body.animals-select-mode #animals-body-table.list-card-table tbody > tr.animal-row {
        padding-left: 52px;
    }

    #animals-body-table.list-card-table tbody > tr.animals-infinite-sentinel,
    #animals-body-table.list-card-table tbody > tr.animals-infinite-end {
        display: block;
        padding: 10px 12px 16px;
        min-height: 0;
        border-bottom: none;
        background: transparent;
    }

    #animals-body-table.list-card-table tbody > tr.animals-infinite-sentinel::after,
    #animals-body-table.list-card-table tbody > tr.animals-infinite-end::after {
        content: none;
    }

    #animals-body-table.list-card-table tbody > tr.animals-infinite-sentinel td,
    #animals-body-table.list-card-table tbody > tr.animals-infinite-end td {
        display: block;
        width: 100% !important;
        padding: 0;
        text-align: center;
        border: none;
    }

    .animals-infinite-loading,
    .animals-infinite-end-label {
        display: block;
        font-size: 13px;
        color: #6b7280;
        text-align: center;
    }

    .animals-infinite-sentinel.htmx-request .animals-infinite-loading {
        opacity: 1;
    }
}

/* ===== Phone: animals always-on checkboxes + slim bulk bar ===== */
@media (max-width: 767.98px) {
    #animals-select-toggle {
        display: none !important;
    }

    #animals-body-table.list-card-table tbody > tr.animal-row {
        padding: 10px 32px 10px calc(var(--sp-tap) + 4px);
    }

    #animals-body-table.list-card-table td.ac-select,
    body.animals-select-mode #animals-body-table.list-card-table td.ac-select {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        padding: 0 !important;
        margin: 0;
        order: 0;
    }

    #animals-body-table.list-card-table td.ac-select::before {
        content: none !important;
        display: none !important;
    }

    #animals-body-table.list-card-table .bulk-checkbox,
    body.animals-select-mode #animals-body-table .bulk-checkbox {
        -webkit-appearance: none;
        appearance: none;
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        margin: 0;
        padding: 0;
        border: none;
        background-color: transparent;
        background-repeat: no-repeat;
        background-position: center;
        background-size: 24px 24px;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='3.5' y='3.5' width='17' height='17' rx='3' fill='white' stroke='%231a2744' stroke-width='1.6'/></svg>");
    }

    #animals-body-table.list-card-table .bulk-checkbox:checked,
    body.animals-select-mode #animals-body-table .bulk-checkbox:checked {
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='3' y='3' width='18' height='18' rx='3' fill='%231a2744'/><path d='M7.2 12.2l3 3 6.6-6.6' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    }

    body.animals-select-mode #animals-body-table.list-card-table tbody > tr.animal-row {
        padding-left: calc(var(--sp-tap) + 4px);
    }

    .content-area:has(#bulk-action-bar) {
        padding-bottom: 0;
    }

    body.bulk-bar-open .content-area:has(#bulk-action-bar),
    body.bulk-bar-open #content-area {
        padding-bottom: calc(var(--sp-tap) + 8px + var(--sp-safe-bottom));
    }

    body.bulk-bar-open .pagination-footer-spacer {
        height: 0 !important;
    }

    #bulk-action-bar,
    #bulk-action-bar.sticky-actions,
    body.bulk-bar-open #bulk-action-bar,
    body.bulk-bar-open #bulk-action-bar.sticky-actions {
        left: 0 !important;
        right: 0 !important;
        bottom: 0;
        height: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0 12px var(--sp-safe-bottom);
        box-sizing: content-box;
        display: none;
        align-items: center;
        background: #1a2744;
        border-top: none;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.18);
    }

    body.bulk-bar-open #bulk-action-bar,
    body.bulk-bar-open #bulk-action-bar.sticky-actions {
        display: flex !important;
    }

    #bulk-action-bar > div {
        width: 100%;
        max-width: none !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap !important;
        gap: 8px;
    }

    #bulk-action-bar > div > div {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    #bulk-count-badge {
        background: transparent !important;
        color: #fff !important;
        padding: 0 !important;
        border-radius: 0;
        font-size: 13px !important;
        font-weight: 700;
        line-height: 1;
        min-width: 0;
    }

    #bulk-count-label {
        color: #fff !important;
        font-size: 13px !important;
        font-weight: 500;
        white-space: nowrap;
    }

    #bulk-action-bar .btn {
        flex: 0 0 auto !important;
        width: auto !important;
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px !important;
        font-size: 13px !important;
        margin: 0;
        white-space: nowrap;
    }
}

/* ===== Phone: record detail pages ===== */
.sp-record-btn-short {
    display: none;
}

@media (max-width: 767.98px) {
    .sp-record-detail .page-sticky-toolbar {
        position: static;
        top: auto;
        z-index: auto;
        margin-left: 0;
        margin-right: 0;
        padding: 0 0 8px;
        overflow: visible;
    }

    .sp-record-detail .page-header {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        margin-bottom: 0;
        padding-right: 0;
    }

    .sp-record-detail .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }

    .sp-record-detail .welcome-title {
        font-size: 18px;
        font-weight: 700;
        line-height: 1.2;
        margin: 0;
    }

    .sp-record-detail .welcome-subtitle {
        display: none;
    }

    .sp-record-detail .page-header .d-flex,
    .sp-record-detail .header-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap;
        align-items: center;
        gap: 4px;
        margin-left: auto;
    }

    .sp-record-detail .page-header .btn,
    .sp-record-detail .page-header .btn-outline,
    .sp-record-detail .page-header a.btn-outline {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sp-record-detail .page-header .btn.sp-record-add-btn,
    .sp-record-detail .page-header .btn-outline.sp-record-add-btn {
        width: auto;
        padding: 0 8px !important;
        gap: 4px;
    }

    .sp-record-detail .sp-record-btn-label {
        display: none;
    }

    .sp-record-detail .sp-record-btn-short {
        display: inline;
        font-size: 13px;
        font-weight: 600;
    }

    .sp-record-detail .page-header .btn i,
    .sp-record-detail .page-header .btn-outline i,
    .sp-record-detail .page-header a.btn-outline i,
    .sp-record-detail .page-header .btn .me-1,
    .sp-record-detail .page-header .btn-outline .me-1,
    .sp-record-detail .page-header .btn .me-2,
    .sp-record-detail .page-header .btn-outline .me-2 {
        margin: 0 !important;
        font-size: 16px;
    }

    .sp-record-delete-icon {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0;
        border: 0;
        background: none;
        color: #dc2626;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .sp-record-delete-icon i {
        font-size: 16px;
    }

    .sp-record-detail .delete-footer,
    .sp-record-detail .delete-footer.sticky-actions,
    .sp-record-detail .sticky-actions.d-md-none {
        display: none !important;
    }

    .sp-record-detail .form-sections-container {
        padding-right: 0;
        overflow: visible;
    }

    .sp-record-detail .display-container {
        padding: 0;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
        overflow: visible;
        border-radius: var(--sp-radius);
    }

    .sp-record-detail .display-container > .flex.items-center,
    .sp-record-detail .data-table > .flex.items-center {
        min-height: 40px;
        padding: 8px 12px;
        margin: 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .sp-record-detail .display-container > .flex h3,
    .sp-record-detail .data-table > .flex h3 {
        font-size: 15px;
        font-weight: 700;
        margin: 0;
    }

    .sp-record-detail .display-container > .heading-row {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 15px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sp-record-detail .display-container .row.g-0,
    .sp-record-detail .display-container .row.g-0.mb-2 {
        display: contents;
    }

    .sp-record-detail .display-container .row.g-0 > [class*="col-"]:has(.heading-row) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        max-width: 100%;
        flex: none;
        min-height: 40px;
        padding: 8px 12px;
        border-bottom: 1px solid #e5e7eb;
    }

    .sp-record-detail .display-container > .row.g-0:last-of-type > [class*="col-"]:has(.heading-row):last-child {
        border-bottom: none;
    }

    .sp-record-detail .display-container label.heading-row,
    .sp-record-detail .display-container .heading-row.flex {
        background: none;
        border: none;
        padding: 0;
        margin: 0;
        font-size: 13px;
        font-weight: 500;
        color: #6b7280;
        flex: 0 1 auto;
        min-width: 0;
        line-height: 1.3;
    }

    .sp-record-detail .display-container .heading-row span[style*="font-size: 10px"],
    .sp-record-detail .display-container .heading-row br {
        display: none;
    }

    .sp-record-detail .display-container .plaintext {
        font-size: 15px;
        font-style: normal !important;
        font-weight: 500;
        color: #111827;
        margin: 0 !important;
        padding: 0;
        text-align: right;
        flex: 1 1 auto;
        min-width: 0;
        line-height: 1.3;
    }

    .sp-record-detail .display-container .row.mb-2:not(:has(.heading-row)) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 40px;
        padding: 8px 12px;
        margin: 0 !important;
        border-bottom: 1px solid #e5e7eb;
    }

    .sp-record-detail .display-container .row.mb-2:not(:has(.heading-row)) .col-md-4 {
        font-size: 13px;
        font-weight: 500;
        color: #6b7280;
        width: auto;
        max-width: 50%;
        flex: 0 1 auto;
        padding: 0;
    }

    .sp-record-detail .display-container .row.mb-2:not(:has(.heading-row)) .col-md-8 {
        font-size: 15px;
        font-weight: 500;
        color: #111827;
        text-align: right;
        width: auto;
        flex: 1 1 auto;
        padding: 0;
    }

    .sp-record-detail .display-container > div[style*="padding: 12px"] {
        padding: 0 !important;
    }

    .sp-record-detail input[type="text"],
    .sp-record-detail #search-animal,
    .sp-record-detail #search-breeds-record,
    .sp-record-detail #sg-search,
    .sp-record-detail #sg-animal-search {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        font-size: 16px !important;
        box-sizing: border-box;
    }

    .sp-record-detail .data-table {
        margin-top: 8px;
        overflow: visible;
    }

    .sp-record-detail .content-area,
    .content-area:has(.sp-record-detail) {
        padding-bottom: 12px !important;
    }

    .sp-record-detail a.text-primary,
    .sp-record-detail .data-table a {
        min-height: var(--sp-tap);
        display: inline-flex;
        align-items: center;
    }
}

/* ===== Phone: animals card left-align + bulk count ===== */
@media (max-width: 767.98px) {
    #animals-body-table.list-card-table td.ac-ear_tag,
    #animals-body-table.list-card-table td.ac-ear_tag .list-card-title,
    #animals-body-table.list-card-table td.ac-ear_tag .sp-phone-only,
    #animals-body-table.list-card-table td.ac-name,
    #animals-body-table.list-card-table td.ac-name .list-card-sub {
        text-align: left !important;
        justify-content: flex-start !important;
        margin-left: 0 !important;
        margin-right: auto;
    }

    #bulk-action-bar > div > div:first-child {
        gap: 0;
    }

    #bulk-count-badge {
        font-size: 14px !important;
        font-weight: 600 !important;
        letter-spacing: 0;
        padding: 0 !important;
        min-width: 0 !important;
        width: auto !important;
    }

    #bulk-count-label[hidden] {
        display: none !important;
    }
}

/* ===== Phone: record add/edit forms ===== */
@media (max-width: 767.98px) {
    .page-sticky-toolbar:has(.sp-form-head) {
        padding-top: 4px;
        padding-bottom: 0;
    }

    .sp-form-head {
        margin-bottom: 8px !important;
        align-items: center !important;
        gap: 8px;
        flex-wrap: nowrap !important;
    }

    .sp-form-head .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }

    .sp-form-head .welcome-title {
        font-size: 1.1rem;
        margin-bottom: 0;
        line-height: 1.2;
    }

    .sp-form-head .welcome-subtitle {
        display: none;
    }

    .sp-form-actions-top {
        display: flex !important;
        flex: 0 0 auto;
        align-items: center;
        gap: 8px;
    }

    .sp-form-actions-top .btn,
    .sp-form-actions-top .btn-outline {
        width: auto !important;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.2;
    }

    .content-area:has(.sp-form-head) .sticky-actions,
    .content-area:has(.sp-form-head) .animal-form-actions.sticky-actions,
    .content-area:has(.sp-form-head) .animal-form-actions {
        display: none !important;
    }

    .content-area:has(.sp-form-head) {
        padding-bottom: 12px !important;
    }

    .content-area:has(.sp-form-head) .form-sections-container,
    .content-area:has(.sp-form-head) .input-container {
        padding-bottom: 0 !important;
    }

    .content-area:has(.sp-form-head) .form-section,
    .content-area:has(.sp-form-head) .input-container,
    .content-area:has(.sp-form-head) .dg-panel,
    .content-area:has(.sp-form-head) .sp-form-card {
        margin-bottom: 10px;
    }

    .content-area:has(.sp-form-head) .form-section-header,
    .content-area:has(.sp-form-head) .sp-form-card-header,
    .content-area:has(.sp-form-head) .dg-panel-header,
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between,
    .content-area:has(.sp-form-head) .heading-row {
        position: static;
        top: auto;
        z-index: auto;
        padding: 8px 12px;
        min-height: 40px;
        font-size: 0.875rem;
    }

    .content-area:has(.sp-form-head) .form-section-body,
    .content-area:has(.sp-form-head) .input-container > .p-1,
    .content-area:has(.sp-form-head) .input-container > .mt-2 {
        padding: 8px 12px;
    }

    .content-area:has(.sp-form-head) .form-label {
        font-size: 13px;
        color: #6b7280;
        margin-bottom: 2px;
    }

    .content-area:has(.sp-form-head) .form-text,
    .content-area:has(.sp-form-head) small.text-muted,
    .content-area:has(.sp-form-head) .animal-gender-hint {
        display: none;
    }

    .content-area:has(.sp-form-head) .form-control,
    .content-area:has(.sp-form-head) .form-select,
    .content-area:has(.sp-form-head) input[type="date"],
    .content-area:has(.sp-form-head) input[type="number"],
    .content-area:has(.sp-form-head) input[type="text"],
    .content-area:has(.sp-form-head) input[type="email"],
    .content-area:has(.sp-form-head) input[type="password"],
    .content-area:has(.sp-form-head) select,
    .content-area:has(.sp-form-head) .dropdown > button {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        font-size: 16px;
    }

    .content-area:has(.sp-form-head) textarea.form-control,
    .content-area:has(.sp-form-head) textarea {
        height: auto;
        min-height: calc(var(--sp-tap) * 2);
        font-size: 16px;
    }

    .content-area:has(.sp-form-head) .row {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
        margin-bottom: 8px;
    }

    .content-area:has(.sp-form-head) .row > .col-md-6:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-6:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-4:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-3:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-2:not(.sp-field-full) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .content-area:has(.sp-form-head) .row > [class*="col-md-"]:only-child,
    .content-area:has(.sp-form-head) .sp-field-full,
    .content-area:has(.sp-form-head) .row > .col-md-8,
    .content-area:has(.sp-form-head) .row > .col-md-12,
    .content-area:has(.sp-form-head) .row > [class*="col-"]:has(textarea) {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sp-form-actions-bottom {
        display: flex;
        justify-content: flex-end;
        padding: 4px 0 12px;
    }

    .sp-form-actions-bottom .btn,
    .sp-form-actions-bottom .btn-outline {
        width: auto;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
        font-size: 14px;
    }

    .content-area:has(.sp-form-head) input[type="checkbox"],
    .content-area:has(.sp-form-head) .form-check-input {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    #bulkEditModal.sp-form .bulk-edit-fields {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px !important;
    }

    #bulkEditModal.sp-form .form-select,
    #bulkEditModal.sp-form .form-control {
        min-height: var(--sp-tap);
        font-size: 16px !important;
    }
}

/* ===== Phone: NSIP, genomics, imports, reports, profile ===== */
.report-load-more { display: none; }
.ie-step-label-short { display: none; }

@media (max-width: 767.98px) {
    /* Compact title row: no subtitle; Add stays labeled; secondaries are 44px icons. */
    .page-header:has(.welcome-title) .welcome-subtitle {
        display: none;
    }

    .page-header {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

    .page-header .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }

    .page-header .welcome-title {
        font-size: 18px;
        font-weight: 700;
        line-height: 1.2;
        margin: 0;
    }

    .page-header-actions,
    .ie-hub-actions,
    .report-header-actions {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 4px;
        margin-left: auto;
    }

    .page-header .sp-page-add-btn,
    .page-header .btn.sp-page-add-btn {
        width: auto;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        padding: 0 10px !important;
        gap: 4px;
        font-size: 14px;
    }

    .page-header .sp-page-icon-btn,
    .page-header .btn-outline.sp-page-icon-btn,
    .ie-hub-actions .btn-outline,
    .report-header-actions .btn,
    .report-header-actions .btn-outline,
    .report-header-actions a.btn-outline,
    .report-header-actions .report-phone-only {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        max-width: var(--sp-tap);
        padding: 0 !important;
        font-size: 0 !important;
        line-height: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        flex: 0 0 var(--sp-tap);
    }

    .page-header .sp-page-icon-btn i,
    .ie-hub-actions .btn-outline i,
    .report-header-actions .btn i,
    .report-header-actions .btn-outline i,
    .report-header-actions a.btn-outline i {
        margin: 0 !important;
        font-size: 16px;
        line-height: 1;
    }

    /* Hide desktop pagination on these list/report pages. */
    #nsip-results .pagination-footer,
    #nsip-results .pagination-footer-spacer,
    .nsip-list-page .pagination-footer,
    .nsip-list-page .pagination-footer-spacer,
    #genomics-results .pagination-footer,
    #genomics-results .pagination-footer-spacer,
    .genomics-list-page .pagination-footer,
    .genomics-list-page .pagination-footer-spacer,
    .content-area:has(.report-header-actions) .pagination-footer,
    .content-area:has(.report-header-actions) .pagination-footer-spacer,
    .content-area:has(#animal-report-body-table) .pagination-footer,
    .content-area:has(#animal-report-body-table) .pagination-footer-spacer {
        display: none !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Search + Filter on one row; muted count above the list. */
    .genomics-filter-row {
        flex-wrap: nowrap !important;
        gap: 8px !important;
    }

    /* NSIP also keeps its group dropdown inline, so search gets its own row. */
    .nsip-filter-row {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .nsip-filter-row .nsip-search-wrap {
        flex: 1 1 100% !important;
    }
    .nsip-filter-row #filter-management-group {
        flex: 1 1 0;
        min-width: 0;
        max-width: none !important;
        min-height: var(--sp-tap);
    }

    #nsip-filter-bar,
    .genomics-search-wrap {
        padding: 8px 12px !important;
        margin-bottom: 8px;
    }

    #search-nsip,
    .genomics-search-wrap #search-animals,
    #nsip-filter-btn,
    #genomics-filter-btn {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
    }

    .nsip-search-wrap,
    .genomics-search-input-wrap,
    .sp-search-grow {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .nsip-list-chrome,
    .genomics-list-chrome {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        border-radius: 0 !important;
    }

    .nsip-list-head-bar,
    .genomics-list-head-bar {
        padding: 4px 4px 8px !important;
        border-bottom: none !important;
    }

    #nsip-count-heading,
    #nsip-count-heading .nsip-count-phone,
    #genomics-count-heading,
    #genomics-count-heading .genomics-count-phone,
    .report-count-phone {
        font-size: 13px !important;
        font-weight: 500 !important;
        color: #6b7280 !important;
        line-height: 1.2;
        margin: 0 0 4px;
    }

    /* Two-line 58–64px flat rows (match Animals). */
    #nsip-dashboard-body-table.list-card,
    #nsip-dashboard-body-table.list-card-table,
    #genomics-body-table.list-card,
    #genomics-body-table.list-card-table,
    #select-nsip-body-table.list-card-table,
    .report-list-cards.list-card-table {
        display: block;
        width: 100%;
        min-width: 0 !important;
        table-layout: auto !important;
    }

    #nsip-dashboard-body-table.list-card tbody,
    #nsip-dashboard-body-table.list-card-table tbody,
    #genomics-body-table.list-card tbody,
    #genomics-body-table.list-card-table tbody,
    #select-nsip-body-table.list-card-table tbody,
    .report-list-cards.list-card-table tbody {
        display: block;
        width: 100%;
    }

    #nsip-dashboard-body-table.list-card tbody > tr.animal-row,
    #nsip-dashboard-body-table.list-card-table tbody > tr.animal-row,
    #genomics-body-table.list-card tbody > tr.animal-row,
    #genomics-body-table.list-card-table tbody > tr.animal-row,
    #select-nsip-body-table.list-card-table tbody > tr.animal-row,
    .report-list-cards.list-card-table tbody > tr,
    .report-list-cards.list-card-table tbody > tr.animal-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 6px;
        row-gap: 2px;
        padding: 10px 32px 10px 12px;
        min-height: 58px;
        max-height: 64px;
        box-sizing: border-box;
        background: #fff;
        border: none;
        border-bottom: 1px solid #e5e7eb;
        border-radius: 0;
        margin: 0;
        width: 100%;
    }

    #nsip-dashboard-body-table.list-card td::before,
    #nsip-dashboard-body-table.list-card-table td::before,
    #genomics-body-table.list-card td::before,
    #genomics-body-table.list-card-table td::before,
    #select-nsip-body-table.list-card-table td::before,
    .report-list-cards.list-card-table td::before {
        content: none !important;
        display: none !important;
    }

    #nsip-dashboard-body-table.list-card td,
    #nsip-dashboard-body-table.list-card-table td,
    #genomics-body-table.list-card td,
    #genomics-body-table.list-card-table td,
    #select-nsip-body-table.list-card-table td,
    .report-list-cards.list-card-table td {
        display: none;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        min-height: 0 !important;
        position: static !important;
        left: auto !important;
    }

    #nsip-dashboard-body-table td.nc-ear_tag,
    #nsip-dashboard-body-table td.list-card-title,
    #genomics-body-table td.gc-ear_tag,
    #genomics-body-table td.list-card-title,
    #select-nsip-body-table td.list-card-title,
    .report-list-cards td.list-card-title {
        display: block !important;
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        text-align: left !important;
        justify-content: flex-start !important;
        margin-right: auto;
    }

    #nsip-dashboard-body-table td.nc-sex,
    #nsip-dashboard-body-table td.list-card-chip,
    #genomics-body-table td.gc-sex,
    #genomics-body-table td.list-card-chip,
    #select-nsip-body-table td.list-card-chip,
    .report-list-cards td.list-card-chip {
        display: inline-flex !important;
        order: 2;
        flex: 0 0 auto;
        align-items: center;
        margin: 0 !important;
        padding: 1px 7px !important;
        border-radius: 999px;
        background: #e5e7eb !important;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        color: #374151 !important;
        white-space: nowrap;
    }

    #nsip-dashboard-body-table td.list-card-sub,
    #nsip-dashboard-body-table td.nc-phone-line2,
    #genomics-body-table td.list-card-sub,
    #genomics-body-table td.gc-phone-line2,
    #select-nsip-body-table td.list-card-sub,
    .report-list-cards td.list-card-sub {
        display: block !important;
        order: 3;
        flex: 1 1 100%;
        width: 100% !important;
        min-width: 0;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 13px;
        font-weight: 400;
        color: #6b7280;
    }

    #nsip-dashboard-body-table tbody > tr.phone-infinite-sentinel,
    #nsip-dashboard-body-table tbody > tr.phone-infinite-end,
    #genomics-body-table tbody > tr.phone-infinite-sentinel,
    #genomics-body-table tbody > tr.phone-infinite-end,
    .report-list-cards tbody > tr.report-load-more {
        display: block;
        padding: 10px 12px 16px;
        min-height: 0;
        max-height: none;
        border-bottom: none;
        background: transparent;
    }

    #nsip-dashboard-body-table tbody > tr.phone-infinite-sentinel::after,
    #nsip-dashboard-body-table tbody > tr.phone-infinite-end::after,
    #genomics-body-table tbody > tr.phone-infinite-sentinel::after,
    #genomics-body-table tbody > tr.phone-infinite-end::after {
        content: none;
    }

    .phone-infinite-sentinel td,
    .phone-infinite-end td,
    .nsip-infinite-sentinel td,
    .nsip-infinite-end td,
    .genomics-infinite-sentinel td,
    .genomics-infinite-end td,
    .report-load-more td {
        display: block !important;
        width: 100%;
        text-align: center;
        padding: 8px 0 !important;
        color: #6b7280;
        font-size: 13px;
    }

    .report-load-more .btn,
    .report-load-more button {
        width: 100%;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        font-size: 14px;
    }

    /* NSIP select + report toolbars: unstick so they do not overlap the top bar. */
    .nsip-select-shell .page-sticky-toolbar,
    .content-area:has(#select-nsip-body-table) .page-sticky-toolbar,
    .content-area:has(.report-header-actions) .page-sticky-toolbar,
    .lambing-report-shell .page-sticky-toolbar {
        position: static !important;
        top: auto !important;
        z-index: auto;
        margin-left: 0;
        margin-right: 0;
        overflow: visible;
    }

    .nsip-select-shell thead,
    #select-nsip-body-table thead,
    .content-area:has(.report-header-actions) .report-phone-thead,
    .content-area:has(.report-header-actions) .report-desktop-thead {
        display: none !important;
    }

    /* Wide report tables scroll sideways; pin the first column; no clipped NSIP. */
    .content-area:has(.report-header-actions) .scroll-x {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .content-area:has(.report-header-actions) .scroll-x table:not(.list-card-table) {
        min-width: 720px;
        width: max-content;
        table-layout: auto !important;
    }

    .content-area:has(.report-header-actions) .scroll-x table:not(.list-card-table) th:first-child,
    .content-area:has(.report-header-actions) .scroll-x table:not(.list-card-table) td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: #fff;
    }

    /* Imports: compact header + stepper that does not clip. */
    #progress-steps,
    #breeding-progress-steps > div,
    #ebv-progress-steps > div,
    #genomics-progress-steps > div,
    #pmzip-progress-steps > div {
        overflow-x: auto;
        justify-content: flex-start !important;
        flex-wrap: nowrap;
        gap: 0;
        padding: 8px 4px 0 !important;
        margin-bottom: 12px !important;
        -webkit-overflow-scrolling: touch;
    }

    #progress-steps > div[style*="flex: 0 0 40px"],
    #breeding-progress-steps div[style*="flex: 0 0 40px"],
    #ebv-progress-steps div[style*="flex: 0 0 40px"],
    #genomics-progress-steps div[style*="flex: 0 0 40px"],
    #pmzip-progress-steps div[style*="flex: 0 0 40px"] {
        flex: 0 0 16px !important;
        margin: 0 4px !important;
    }

    .ie-step-label {
        font-size: 11px !important;
        white-space: nowrap;
    }

    .ie-step-label-long {
        display: none;
    }

    .ie-step-label-short {
        display: inline;
    }

    /* Export column picks: 44px rows, not a dense checkbox grid. */
    .ie-export-checks,
    .ie-export-checks-cols {
        display: flex !important;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
        max-height: none;
        overflow: visible;
        margin: 0 0 12px;
    }

    .ie-export-checks label,
    .ie-export-checks-cols label {
        display: flex !important;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 0 4px;
        margin: 0;
        font-size: 14px;
        white-space: normal;
        box-sizing: border-box;
    }

    .ie-export-checks input[type="checkbox"],
    .ie-export-checks-cols input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        margin: 0;
        flex-shrink: 0;
        accent-color: #1a2744;
    }

    /* Report builder field pick list: 44px rows. */
    .rb-picker-panel label,
    .rb-fields-panel label,
    .rb-picker-panel.rb-fields-panel label {
        display: flex !important;
        align-items: center;
        gap: 10px;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 0 4px;
        font-size: 14px;
        white-space: normal;
        box-sizing: border-box;
    }

    .rb-picker-panel input[type="checkbox"],
    .rb-fields-panel input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        margin: 0;
        flex-shrink: 0;
        accent-color: #1a2744;
    }

    .rb-picker-panel,
    .rb-picker-panel.rb-fields-panel,
    .rb-picker-panel.rb-fields-panel.is-open {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column;
        max-height: none;
        min-width: 0;
    }

    .rb-template-item {
        min-height: var(--sp-tap);
        align-items: center;
    }

    .rb-template-item button {
        min-height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        font-size: 14px !important;
        padding: 0 8px !important;
        display: inline-flex !important;
        align-items: center;
    }

    #search-select-animals {
        min-height: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        font-size: 16px !important;
        box-sizing: border-box;
    }

    /* Analytics hub KPI tiles 3-up; 5-tile hub uses 3+2 with no ragged gap. */
    .analytics-kpi-grid,
    .analytics-kpi-grid.cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    .analytics-kpi-grid.cols-5 {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    .analytics-kpi-grid.cols-5 > .stat-card:nth-child(-n+3) {
        grid-column: span 2;
    }

    .analytics-kpi-grid.cols-5 > .stat-card:nth-child(n+4) {
        grid-column: span 3;
    }

    .analytics-kpi-grid .stat-card {
        padding: 8px 6px;
        min-width: 0;
    }

    .analytics-kpi-grid .stat-number {
        font-variant-numeric: tabular-nums;
        font-size: 15px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .analytics-kpi-grid .stat-number-long {
        font-size: 11px !important;
    }

    .analytics-kpi-grid .stat-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .analytics-kpi-grid .stat-desc {
        font-size: 12px !important;
        line-height: 1.25;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
    }

    @media (max-width: 359.98px) {
        .analytics-kpi-grid,
        .analytics-kpi-grid.cols-4,
        .analytics-kpi-grid.cols-5 {
            grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        }
        .analytics-kpi-grid.cols-5 > .stat-card {
            grid-column: auto;
        }
    }

    /* Profile: Save on the title row; no sticky footer; two-across short fields. */
    .content-area:has(#profile-form) .sticky-actions,
    #ptab-profile .sticky-actions,
    #ptab-settings .sticky-actions {
        display: none !important;
    }

    .content-area:has(#profile-form) {
        padding-bottom: 12px !important;
    }

    .profile-back-btn {
        width: var(--sp-tap) !important;
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        padding: 0 !important;
        font-size: 0;
    }

    .profile-tab-row .profile-tab {
        min-height: var(--sp-tap);
        padding: 8px 12px;
        font-size: 14px;
    }

    #ptab-profile .col-md-6:not(.sp-field-full),
    #ptab-settings .col-md-6:not(.sp-field-full),
    #ptab-profile .col-6:not(.sp-field-full),
    #ptab-feedback .col-md-4:not(.sp-field-full) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    #ptab-profile .sp-field-full,
    #ptab-settings .sp-field-full,
    #ptab-feedback .sp-field-full,
    #ptab-feedback .col-md-8.sp-field-full {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    #ptab-profile .form-label,
    #ptab-settings .form-label,
    #ptab-feedback .form-label {
        white-space: normal;
        overflow-wrap: break-word;
    }

    #ptab-profile .form-control,
    #ptab-settings .form-control,
    #ptab-feedback .form-control {
        min-width: 0;
        max-width: 100%;
    }
}

/* ===== Phone: record list dashboards ===== */
@media (max-width: 767.98px) {
    .sp-list-dash.page-sticky-toolbar {
        position: static !important;
        top: auto !important;
    }
    .sp-list-dash .welcome-subtitle { display: none !important; }
    .sp-list-dash .welcome-title {
        font-size: 22px;
        font-weight: 700;
        line-height: 1.2;
        margin: 0;
    }
    .sp-list-dash .page-header {
        flex-wrap: nowrap !important;
        align-items: center;
        margin-bottom: 8px !important;
        padding-bottom: 0 !important;
        gap: 8px;
    }
    .sp-list-dash .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }
    .sp-list-dash .welcome-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sp-list-dash .sp-list-actions,
    .sp-list-dash .header-actions,
    .sp-list-dash .page-header-actions,
    .sp-list-dash .weighing-header-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap !important;
    }
    .sp-list-dash .sp-list-add {
        font-size: 14px;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
    }
    .sp-list-dash .sp-list-icon-btn {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        width: var(--sp-tap);
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .sp-list-dash .sp-list-search-row {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0 0 8px !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    .sp-list-dash .sp-list-search,
    .sp-list-dash .sp-list-search-row input[type='text'] {
        flex: 1 1 auto;
        min-width: 0;
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        font-size: 16px !important;
    }
    .sp-list-dash .sp-list-search-row > div[style*="display: flex"] {
        flex-wrap: nowrap !important;
        width: 100%;
        min-width: 0;
    }
    .sp-search-grow {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }
    .sp-list-dash .sp-list-filter-btn {
        flex: 0 0 auto;
        font-size: 14px;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    .sp-list-dash .sp-list-head-card,
    .sp-list-body .sp-list-head-card {
        display: none !important;
    }
    .sp-list-dash .pagination-footer,
    .sp-list-dash .pagination-footer-spacer,
    .sp-list-body + .sp-desktop-only .pagination-footer,
    .sp-list-body .pagination-footer,
    .sp-list-body .pagination-footer-spacer {
        display: none !important;
    }
    .sp-health-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    .sp-health-kpis .stat-card {
        padding: 8px 6px;
        min-width: 0;
    }
    .sp-health-kpis .stat-number { font-size: 18px; }
    .sp-health-kpis .stat-label { font-size: 11px; }
    .sp-health-kpis .stat-desc { display: none; }
    .sp-list-body.data-table,
    .data-table.sp-list-body,
    .sp-list-body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        box-shadow: none !important;
        overflow: hidden;
    }
    .sp-list-body table.list-card,
    .sp-list-body table.list-card-table {
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .sp-list-body table.list-card tbody > tr,
    .sp-list-body table.list-card-table tbody > tr,
    .sp-list-body table.list-card tbody > tr.row-clickable,
    .sp-list-body table.list-card tbody > tr.animal-row,
    .sp-list-body table.list-card tbody > tr.employee-row,
    .sp-list-body table.list-card tbody > tr.treatment-row,
    .sp-list-body table.list-card tbody > tr.draft-group-row,
    .sp-list-body table.list-card tbody > tr.draft-rule-row,
    .sp-list-body table.list-card tbody > tr.lambing-group-row,
    .sp-list-body table.list-card tbody > tr.breed-pct-row,
    .sp-list-body table.list-card tbody > tr.breeding_event-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 6px;
        row-gap: 2px;
        padding: 10px 32px 10px 12px !important;
        min-height: 58px;
        max-height: none;
        box-sizing: border-box;
        position: relative;
        width: 100% !important;
        margin: 0 !important;
        border: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    .sp-list-body table.list-card tbody > tr:not(:has(td.list-card-sub)),
    .sp-list-body table.list-card-table tbody > tr:not(:has(td.list-card-sub)) {
        align-items: center;
    }
    .sp-list-body table.list-card tbody > tr.row-clickable::after,
    .sp-list-body table.list-card-table tbody > tr.row-clickable::after {
        content: '';
        position: absolute;
        right: 12px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 2px solid #9ca3af;
        border-top: 2px solid #9ca3af;
        transform: translateY(-50%) rotate(45deg);
    }
    .sp-list-body table.list-card tbody > tr > td:not(.list-card-title):not(.list-card-chip):not(.list-card-sub),
    .sp-list-body table.list-card-table tbody > tr > td:not(.list-card-title):not(.list-card-chip):not(.list-card-sub) {
        display: none !important;
    }
    .sp-list-body table.list-card tbody > tr.pregscan-day-row,
    .sp-list-body table.list-card-table tbody > tr.pregscan-day-row {
        display: block !important;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 10px 4px 2px;
        margin: 8px 0 0;
    }
    .sp-list-body table.list-card tbody > tr.pregscan-day-row > td:not(.list-card-title):not(.list-card-chip):not(.list-card-sub),
    .sp-list-body table.list-card-table tbody > tr.pregscan-day-row > td:not(.list-card-title):not(.list-card-chip):not(.list-card-sub) {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        overflow: visible !important;
        white-space: normal !important;
        text-overflow: unset !important;
    }
    .sp-list-body table.list-card tbody > tr.pregscan-day-row .list-card-title,
    .sp-list-body table.list-card-table tbody > tr.pregscan-day-row .list-card-title {
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        white-space: normal !important;
    }
    .sp-list-body table.list-card tbody > tr.pregscan-day-row .list-card-sub,
    .sp-list-body table.list-card-table tbody > tr.pregscan-day-row .list-card-sub {
        display: block !important;
        font-size: 12px;
        font-weight: 500;
        color: #6b7280;
        white-space: normal !important;
    }
    .sp-list-body table.list-card td[data-label]::before,
    .sp-list-body table.list-card-table td[data-label]::before {
        content: none !important;
        display: none !important;
    }
    .sp-list-body table.list-card tbody > tr.row-clickable > td.list-card-title,
    .sp-list-body table.list-card td.list-card-title,
    .sp-list-body table.list-card-table td.list-card-title {
        display: block !important;
        order: 1;
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0;
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        padding: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: left !important;
    }
    .sp-list-body table.list-card td.list-card-title::before,
    .sp-list-body table.list-card-table td.list-card-title::before { content: none !important; }
    .sp-list-body table.list-card tbody > tr.row-clickable > td.list-card-chip,
    .sp-list-body table.list-card td.list-card-chip,
    .sp-list-body table.list-card-table td.list-card-chip {
        display: inline-flex !important;
        order: 2;
        flex: 0 0 auto !important;
        width: auto !important;
        align-items: center;
        margin: 0 !important;
        padding: 1px 7px !important;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        background: #e5e7eb !important;
        color: #374151 !important;
    }
    .sp-list-body table.list-card td.list-card-chip::before,
    .sp-list-body table.list-card-table td.list-card-chip::before { content: none !important; }
    .sp-list-body table.list-card tbody > tr.row-clickable > td.list-card-sub,
    .sp-list-body table.list-card td.list-card-sub,
    .sp-list-body table.list-card-table td.list-card-sub {
        display: block !important;
        order: 3;
        flex: 1 0 100% !important;
        width: 100% !important;
        font-size: 13px;
        font-weight: 400;
        color: #6b7280;
        padding: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: left !important;
    }
    .sp-list-body table.list-card td.list-card-sub::before,
    .sp-list-body table.list-card-table td.list-card-sub::before { content: none !important; }
    .sp-list-body td.list-card-sub:empty,
    .sp-list-body td.list-card-chip:has(.sp-phone-only:empty):not(:has(.sp-desktop-only:not(:empty))) {
        display: none !important;
    }
    .sp-list-body td.list-card-chip .status-alive,
    .sp-list-body td.list-card-chip .status-dead,
    .sp-list-body td.list-card-chip .badge {
        background: transparent !important;
        color: inherit !important;
        padding: 0 !important;
        border: none !important;
        font-size: inherit !important;
        font-weight: inherit !important;
    }
    .sp-list-body table.list-card tbody > tr.phone-infinite-sentinel,
    .sp-list-body table.list-card tbody > tr.phone-infinite-end,
    .sp-list-body table.list-card-table tbody > tr.phone-infinite-sentinel,
    .sp-list-body table.list-card-table tbody > tr.phone-infinite-end {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 12px;
        min-height: var(--sp-tap) !important;
        border-bottom: none !important;
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    .sp-list-body table.list-card tbody > tr.phone-infinite-sentinel::after,
    .sp-list-body table.list-card tbody > tr.phone-infinite-end::after {
        content: none;
    }
    .sp-list-body table.list-card tbody > tr.phone-infinite-sentinel td,
    .sp-list-body table.list-card tbody > tr.phone-infinite-end td {
        display: block !important;
        width: 100% !important;
        text-align: center;
        color: #6b7280;
        font-size: 13px;
    }
    .sp-list-body table.list-card tbody > tr.phone-infinite-sentinel td::before,
    .sp-list-body table.list-card tbody > tr.phone-infinite-end td::before {
        content: none !important;
    }
}

/* ===== Phone: record add/edit forms ===== */
.sp-form-actions-bottom {
    display: none;
}

@media (max-width: 767.98px) {
    .page-sticky-toolbar:has(.sp-form-head) {
        padding-top: 4px;
        padding-bottom: 0;
    }

    .sp-form-head {
        margin-bottom: 8px !important;
        align-items: center !important;
        gap: 8px;
        flex-wrap: nowrap !important;
    }

    .sp-form-head .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }

    .sp-form-head .welcome-title {
        font-size: 1.1rem;
        margin-bottom: 0;
        line-height: 1.2;
    }

    .sp-form-head .welcome-subtitle {
        display: none;
    }

    .sp-form-actions-top {
        display: flex !important;
        flex: 0 0 auto;
        align-items: center;
        gap: 8px;
    }

    .sp-form-actions-top .btn,
    .sp-form-actions-top .btn-outline {
        width: auto !important;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.2;
    }

    .content-area:has(.sp-form-head) .sticky-actions,
    .content-area:has(.sp-form-head) .animal-form-actions.sticky-actions,
    .content-area:has(.sp-form-head) .animal-form-actions {
        display: none !important;
    }

    .content-area:has(.sp-form-head) {
        padding-bottom: 12px !important;
    }

    .content-area:has(.sp-form-head) .form-sections-container,
    .content-area:has(.sp-form-head) .input-container {
        padding-bottom: 0 !important;
    }

    .content-area:has(.sp-form-head) .form-section,
    .content-area:has(.sp-form-head) .input-container,
    .content-area:has(.sp-form-head) .dg-panel,
    .content-area:has(.sp-form-head) .sp-form-card {
        margin-bottom: 10px;
        overflow: visible;
    }

    .content-area:has(.sp-form-head) .form-section-header,
    .content-area:has(.sp-form-head) .sp-form-card-header,
    .content-area:has(.sp-form-head) .dg-panel-header,
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between,
    .content-area:has(.sp-form-head) .heading-row {
        position: static !important;
        top: auto !important;
        z-index: auto;
        padding: 8px 12px;
        min-height: 40px;
        font-size: 0.875rem;
    }

    .content-area:has(.sp-form-head) .form-section-body,
    .content-area:has(.sp-form-head) .input-container > .p-1,
    .content-area:has(.sp-form-head) .input-container > .mt-2 {
        padding: 8px 12px;
    }

    .content-area:has(.sp-form-head) .form-label {
        font-size: 13px;
        color: #6b7280;
        margin-bottom: 2px;
    }

    .content-area:has(.sp-form-head) .form-text,
    .content-area:has(.sp-form-head) small.text-muted,
    .content-area:has(.sp-form-head) .animal-gender-hint {
        display: none;
    }

    .content-area:has(.sp-form-head) .form-control,
    .content-area:has(.sp-form-head) .form-select,
    .content-area:has(.sp-form-head) input[type="date"],
    .content-area:has(.sp-form-head) input[type="number"],
    .content-area:has(.sp-form-head) input[type="text"],
    .content-area:has(.sp-form-head) input[type="email"],
    .content-area:has(.sp-form-head) input[type="password"],
    .content-area:has(.sp-form-head) select,
    .content-area:has(.sp-form-head) .dropdown > button {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        font-size: 16px;
    }

    .content-area:has(.sp-form-head) textarea.form-control,
    .content-area:has(.sp-form-head) textarea {
        height: auto;
        min-height: calc(var(--sp-tap) * 2);
        font-size: 16px;
    }

    .content-area:has(.sp-form-head) .row {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
        margin-bottom: 8px;
    }

    .content-area:has(.sp-form-head) .row > .col-md-6:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-6:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-4:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-3:not(.sp-field-full),
    .content-area:has(.sp-form-head) .row > .col-md-2:not(.sp-field-full) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .content-area:has(.sp-form-head) .row > [class*="col-md-"]:only-child,
    .content-area:has(.sp-form-head) .sp-field-full,
    .content-area:has(.sp-form-head) .row > .col-md-8,
    .content-area:has(.sp-form-head) .row > .col-md-12,
    .content-area:has(.sp-form-head) .row > [class*="col-"]:has(textarea) {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sp-form-actions-bottom,
    .sp-form-actions-bottom.sp-phone-only {
        display: flex !important;
        justify-content: flex-end;
        padding: 4px 0 12px;
    }

    .sp-form-actions-bottom .btn,
    .sp-form-actions-bottom .btn-outline {
        width: auto;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
        font-size: 14px;
    }

    .content-area:has(.sp-form-head) input[type="checkbox"],
    .content-area:has(.sp-form-head) .form-check-input {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    #bulkEditModal.sp-form .bulk-edit-fields {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px !important;
    }

    #bulkEditModal.sp-form .form-select,
    #bulkEditModal.sp-form .form-control {
        min-height: var(--sp-tap);
        font-size: 16px !important;
    }
}

/* ===== Phone: record detail child lists ===== */
@media (max-width: 767.98px) {
    .sp-record-detail .data-table > .flex,
    .sp-record-detail .data-table > .flex.items-center,
    .sp-record-detail .sg-panel-header {
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 0 12px !important;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        overflow: hidden;
    }

    .sp-record-detail .data-table > .flex h3,
    .sp-record-detail .data-table > .flex h3.text-lg,
    .sp-record-detail .sg-panel-header h5 {
        font-size: 15px !important;
        font-weight: 700;
        line-height: 1.2;
        margin: 0 !important;
    }

    .sp-record-detail .list-card-table thead,
    .sp-record-detail .list-card-header {
        display: none !important;
    }

    .sp-record-detail .sp-record-search {
        margin: 8px 0 !important;
    }

    .sp-record-detail .sp-record-search .w-full.mb-3,
    .sp-record-detail .sp-record-search .mb-3.mt-3 {
        margin: 0 !important;
    }

    .sp-record-detail .sp-record-search input,
    .sp-record-detail input#search-animal,
    .sp-record-detail input#search-breeds-record,
    .sp-record-detail input#sg-search,
    .sp-record-detail input#sg-animal-search {
        height: var(--sp-tap);
        min-height: var(--sp-tap);
        box-sizing: border-box;
        font-size: 16px;
        width: 100%;
        padding: 0 14px;
    }

    .sp-record-detail .sg-panel-header + .sp-record-search {
        margin: 0 !important;
        padding: 8px !important;
    }

    .sp-record-detail .list-card-table td[data-label]::before {
        content: none !important;
        display: none !important;
    }

    .sp-record-detail .list-card-table tbody > tr.animal-row,
    .sp-record-detail .list-card-table tbody > tr.row-clickable {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 6px;
        row-gap: 2px;
        padding: 10px 32px 10px 12px;
        min-height: 58px;
        box-sizing: border-box;
        text-align: left;
        width: 100%;
    }

    .sp-record-detail .list-card-table tbody > tr.animal-row::before,
    .sp-record-detail .list-card-table tbody > tr.row-clickable::before {
        content: "";
        flex-basis: 100%;
        width: 0;
        height: 0;
        min-height: 0;
        max-height: 0;
        line-height: 0;
        font-size: 0;
        order: 2;
        overflow: hidden;
        padding: 0;
        margin: 0;
        border: 0;
    }

    .sp-record-detail .list-card-table tbody > tr.animal-row td,
    .sp-record-detail .list-card-table tbody > tr.row-clickable td {
        display: none;
        width: auto !important;
        max-width: none !important;
        text-align: left !important;
        padding: 0 !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        border: none !important;
    }

    .sp-record-detail .list-card-table td.list-card-title {
        display: block !important;
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        text-overflow: ellipsis !important;
    }

    .sp-record-detail .list-card-table td.list-card-title .text-gray-900 {
        font-size: inherit;
        font-weight: inherit;
        color: inherit;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sp-record-detail .list-card-table td.sp-card-chip,
    .sp-record-detail .list-card-table td[data-label="Gender"],
    .sp-record-detail .list-card-table td[data-label="Sex"],
    .sp-record-detail .list-card-table td[data-label="Status"] {
        display: inline-flex !important;
        order: 1;
        flex: 0 0 auto;
        align-items: center;
        margin: 0 !important;
        padding: 1px 7px !important;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        background: #e5e7eb !important;
        color: #374151 !important;
    }

    .sp-record-detail .list-card-table td.sp-card-chip:has(.badge) {
        background: transparent !important;
        padding: 0 !important;
    }

    .sp-record-detail .list-card-table td.sp-card-chip .badge,
    .sp-record-detail .list-card-table td.sp-card-chip .list-card-chip,
    .sp-record-detail .list-card-table td[data-label="Gender"] .text-gray-900,
    .sp-record-detail .list-card-table td[data-label="Sex"] .text-gray-900,
    .sp-record-detail .list-card-table td[data-label="Status"] .list-card-chip {
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        padding: 1px 7px;
        border-radius: 999px;
    }

    .sp-record-detail .list-card-table td.sp-card-sub {
        display: inline !important;
        order: 3;
        flex: 0 1 auto;
        font-size: 13px;
        font-weight: 400;
        color: #6b7280 !important;
        white-space: nowrap !important;
    }

    .sp-record-detail .list-card-table td.sp-card-sub .text-gray-900,
    .sp-record-detail .list-card-table td.sp-card-sub .sp-phone-only,
    .sp-record-detail .list-card-table td.sp-card-sub .sp-desktop-only {
        font-size: 13px;
        font-weight: 400;
        color: #6b7280 !important;
    }

    .sp-record-detail .list-card-table td.sp-card-sub + td.sp-card-sub::before {
        content: " · " !important;
        display: inline !important;
        color: #6b7280;
        font-weight: 400;
        font-size: 13px;
        text-transform: none;
        letter-spacing: 0;
        margin: 0;
    }

    .sp-record-detail .list-card-table td.sp-card-action {
        display: none !important;
    }

    .sp-record-detail .list-card-table td[data-label="Select"] {
        display: inline-flex !important;
        order: 0;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        background: transparent !important;
        padding: 0 !important;
    }

    .sp-record-detail .list-card-table td[data-label="Select"] input[type="checkbox"] {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    .sp-record-detail .list-card-table td[data-label="Remove"] {
        display: inline-flex !important;
        order: 4;
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        align-items: center;
        justify-content: center;
        background: transparent !important;
        padding: 0 !important;
    }

    .sp-record-detail .list-card-table .sg-remove-btn {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sp-record-detail .list-card-table tbody > tr:has([data-label="Remove"]) {
        padding-right: 48px;
    }

    .sp-record-detail .list-card-table tbody > tr:has([data-label="Remove"])::after {
        content: none;
    }

    .sp-record-detail .list-card-table tbody > tr:not(.animal-row):not(.row-clickable) {
        display: block;
        padding: 16px 12px;
        min-height: 0;
    }

    .sp-record-detail .list-card-table tbody > tr:not(.animal-row):not(.row-clickable) td {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        white-space: normal !important;
    }
}

/* ===== Phone: record add/edit form section headers ===== */
@media (max-width: 767.98px) {
    .content-area:has(.sp-form-head) .input-container,
    .content-area:has(.sp-form-head) .sp-form-card,
    .content-area:has(.sp-form-head) .form-section,
    .content-area:has(.sp-form-head) .dg-panel {
        padding: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 10px !important;
        overflow: hidden;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
    }

    .content-area:has(.sp-form-head) .sp-form-card > .sp-form-card-head,
    .content-area:has(.sp-form-head) .form-section-header,
    .content-area:has(.sp-form-head) .sp-form-card-head,
    .content-area:has(.sp-form-head) .dg-panel-header,
    .content-area:has(.sp-form-head) .heading-row,
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between,
    .content-area:has(.sp-form-head) .dg-panel > h5 {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start;
        gap: 8px;
        box-sizing: border-box;
        min-height: 40px;
        height: 40px;
        padding: 0 12px !important;
        margin: 0 !important;
        background: #f3f4f6 !important;
        color: #1f2937 !important;
        border: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        border-radius: 0 !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        text-transform: none !important;
        letter-spacing: 0 !important;
    }

    .content-area:has(.sp-form-head) .dg-panel-header,
    .content-area:has(.sp-form-head) .sp-form-card-head:has(button),
    .content-area:has(.sp-form-head) .form-section-header:has(button),
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between:has(.btn) {
        justify-content: space-between !important;
    }

    .content-area:has(.sp-form-head) .sp-form-card-head h3,
    .content-area:has(.sp-form-head) .sp-form-card-head h5,
    .content-area:has(.sp-form-head) .form-section-header h3,
    .content-area:has(.sp-form-head) .dg-panel-header h5,
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between h3,
    .content-area:has(.sp-form-head) .dg-panel > h5 {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        color: #1f2937 !important;
    }

    .content-area:has(.sp-form-head) .form-section-header i,
    .content-area:has(.sp-form-head) .sp-form-card-head i,
    .content-area:has(.sp-form-head) .dg-panel-header i,
    .content-area:has(.sp-form-head) .heading-row i,
    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between h3::before,
    .content-area:has(.sp-form-head) .dg-panel > h5::before {
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-style: normal;
        font-size: 0.9rem;
        color: #6b7280;
        margin-right: 8px;
    }

    .content-area:has(.sp-form-head) .input-container > .flex.items-center.justify-between h3::before,
    .content-area:has(.sp-form-head) .dg-panel > h5::before {
        content: "\f02b";
    }

    .content-area:has(.sp-form-head) .input-container > .p-1,
    .content-area:has(.sp-form-head) .input-container > .mt-2,
    .content-area:has(.sp-form-head) .input-container > form,
    .content-area:has(.sp-form-head) .dg-panel > .p-3,
    .content-area:has(.sp-form-head) .sp-form-card > .sp-form-card-body {
        padding: 8px 12px !important;
        margin: 0 !important;
    }

    .content-area:has(.sp-form-head) .sp-pick-desktop {
        display: none !important;
    }

    .content-area:has(.sp-form-head) .sp-pick-row,
    .content-area:has(.sp-form-head) .sp-pick-row.sp-phone-only {
        display: flex !important;
        align-items: center;
        min-height: var(--sp-tap);
        height: var(--sp-tap);
        gap: 8px;
        margin-bottom: 8px;
    }

    .content-area:has(.sp-form-head) .row > [class*="col-"]:has(.sp-pick-row) {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .content-area:has(.sp-form-head) .sp-pick-row .form-label {
        display: none !important;
    }

    .content-area:has(.sp-form-head) .sp-pick-row .form-label,
    .content-area:has(.sp-form-head) .sp-pick-label {
        margin: 0;
        flex: 0 0 auto;
        font-size: 13px;
        color: #6b7280;
        font-weight: 500;
    }

    .content-area:has(.sp-form-head) .sp-pick-value,
    .content-area:has(.sp-form-head) .sp-pick-row .plaintext,
    .content-area:has(.sp-form-head) .sp-pick-row p {
        flex: 1 1 auto;
        min-width: 0;
        width: auto !important;
        margin: 0 !important;
        font-size: 14px;
        color: #6b7280;
        font-style: italic;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .content-area:has(.sp-form-head) .sp-pick-btn,
    .content-area:has(.sp-form-head) .sp-pick-row .btn {
        flex: 0 0 auto;
        width: auto !important;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        height: var(--sp-tap);
        padding: 6px 12px !important;
        font-size: 14px !important;
        line-height: 1.2;
    }

    .content-area:has(.sp-form-head) .sp-form-card-head .btn,
    .content-area:has(.sp-form-head) .dg-panel-header .btn,
    .content-area:has(.sp-form-head) .form-section-header .btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.2;
    }
}

/* Import field-mapping grid — 7 equal columns; last row may be short. */
.ie-field-map-wrap {
    padding: 0 16px;
}

.ie-field-map-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px 12px;
    align-items: start;
    padding: 0 16px 10px;
}

.ie-field-map-wrap .ie-field-map-grid {
    padding-left: 0;
    padding-right: 0;
}

.ie-field-map-grid.ie-field-map-grid--wrap {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: none;
    align-items: flex-end;
    overflow-x: visible;
    padding: 0 16px 10px;
}

.ie-field-map-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ie-dob-not-required {
    padding: 2px 16px 4px;
}

.ie-field-map-wrap .ie-dob-not-required {
    padding-left: 0;
    padding-right: 0;
}

.ie-map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 4px 16px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
}

.ie-field-map-wrap .ie-map-legend,
.ie-field-map-grid--wrap .ie-map-legend {
    flex: 1 1 100%;
    padding-left: 0;
    padding-right: 0;
}

.ie-map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.ie-map-swatch {
    width: 0.7em;
    height: 0.7em;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid transparent;
}

.ie-map-legend-item--matched .ie-map-swatch {
    background: #ecfdf5;
    border-color: #6ee7b7;
}

.ie-map-legend-item--guessed .ie-map-swatch {
    background: #fff7ed;
    border-color: #fdba74;
}

.ie-map-legend-item--unmapped .ie-map-swatch {
    background: #fef2f2;
    border-color: #fca5a5;
}

.ie-req-create {
    margin-left: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0;
}

.ie-map-req-legend {
    flex: 1 1 100%;
    margin: 2px 0 0;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
}

.ie-map-req-legend--muted {
    color: #64748b;
}

.ie-field-map-cell select[data-ie-conf="matched"] {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #374151;
}

.ie-field-map-cell select[data-ie-conf="guessed"] {
    background: #fff7ed;
    border-color: #fdba74;
    color: #374151;
}

.ie-field-map-cell select[data-ie-conf="unmapped"] {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #374151;
}

.ie-field-map-cell select[data-ie-conf="manual"] {
    background: #fff;
    border-color: #e5e7eb;
    color: #374151;
}

.ie-dob-not-required .sheet-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    white-space: normal;
}

.ie-field-map-grid--wrap .ie-field-map-cell {
    flex: 1 1 170px;
    min-width: 140px;
}

.ie-field-map-cell label {
    font-size: 11px;
    font-weight: 700;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
    margin-bottom: 0;
}

.ie-field-map-cell select,
.ie-field-map-cell input[type="text"] {
    padding: 5px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    background: white;
    width: 100%;
}

/* ===== Phone: restored field-mapping grid ===== */
@media (max-width: 767.98px) {
    .ie-field-map-grid,
    .ie-field-map-grid.ie-field-map-grid--wrap {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        grid-template-columns: none !important;
    }

    .ie-field-map-cell,
    .ie-dob-not-required,
    .ie-map-legend {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100%;
    }

    .ie-map-legend {
        gap: 8px 12px;
    }

    .ie-map-req-legend,
    .ie-req-create {
        white-space: normal;
    }

    .ie-dob-not-required .sheet-row {
        min-height: var(--sp-tap);
        align-items: center;
    }

    .ie-field-map-grid select,
    .ie-field-map-grid input[type="text"] {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        font-size: var(--sp-input-font, 16px);
    }
}

/* ===== Phone: import column mapping ===== */
@media (max-width: 767.98px) {
    form:has(.ie-col-map) {
        flex: 0 0 auto !important;
        min-height: 0 !important;
        height: auto !important;
    }

    form:has(.ie-col-map) .page-sticky-toolbar {
        flex: 0 0 auto;
        min-height: 0;
        height: auto;
    }

    form:has(.ie-col-map) .welcome-subtitle {
        display: none;
    }

    .ie-col-map {
        position: relative;
    }

    .ie-col-hidden-maps {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        pointer-events: none;
    }

    .ie-col-hidden-maps select {
        min-height: 0 !important;
        height: 0 !important;
        width: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        font-size: 1px !important;
        position: absolute !important;
    }

    .ie-col-rows {
        min-height: 0;
        gap: 8px;
        margin: 0;
        padding: 0;
    }

    .ie-col-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        min-height: var(--sp-tap);
    }

    .ie-col-row.is-collapsed,
    .ie-col-row--matched.is-collapsed {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .ie-col-source,
    .ie-col-target-wrap {
        flex: 1 1 auto;
        width: 100%;
    }

    .ie-col-target-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ie-col-target,
    .ie-col-custom-fields input[type="text"],
    .ie-col-custom-fields select,
    .ie-col-footer-validate,
    .ie-map-actions .btn,
    .ie-map-actions .btn-outline,
    .ie-map-actions input[type="number"] {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        font-size: var(--sp-input-font, 16px);
    }

    .ie-col-pill {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
        justify-content: center;
        padding: 6px 12px;
        font-size: 12px;
    }

    .ie-col-custom-toggle {
        min-height: var(--sp-tap);
    }

    .ie-col-custom-toggle input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
    }

    .ie-col-matched-bar button,
    .ie-col-saved button {
        min-height: var(--sp-tap);
    }

    .ie-col-matched-bar {
        margin-bottom: 8px;
    }

    .ie-col-footer-validate {
        display: none;
    }

    .ie-col-map.is-overflowing .ie-col-footer-validate {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .ie-map-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .ie-back-to-imports,
    .ie-back-to-imports-form .ie-back-to-imports {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 12px;
        white-space: normal;
        text-align: center;
    }

    .page-header:has(.ie-back-to-imports) {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
    }

    .heading-area:has(.ie-back-to-imports) {
        min-width: 0;
        flex: 1 1 100%;
    }

    #ie-inpage-confirm-panel {
        align-items: flex-end;
        justify-content: center;
    }

    #ie-inpage-confirm-card {
        max-width: 100%;
    }

    .ie-col-map .sticky-actions,
    form:has(.ie-col-map).ie-has-sticky-actions,
    form.ie-has-sticky-actions:has(.ie-map-actions) {
        position: static;
        padding-bottom: 0;
    }

    #mapping-header-row,
    #mapping-data-wrapper,
    #mapping-fixed-scrollbar,
    #gen-header-row,
    #gen-data-wrapper,
    #gen-fixed-scrollbar {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: none !important;
    }
}

/* ===== Phone: import preview (no sticky footer) ===== */
@media (max-width: 767.98px) {
    .page-sticky-toolbar.ie-has-sticky-actions:has(.ie-preview-actions),
    .ebv-preview-page.ie-has-sticky-actions,
    .gen-preview-page.ie-has-sticky-actions,
    .ie-has-sticky-actions:has(.ie-preview-actions) {
        padding-bottom: 0;
    }

    .content-area:has(.ie-preview-actions) {
        padding-bottom: 12px !important;
    }

    .sticky-actions.ie-preview-actions,
    .ie-preview-actions.sticky-actions {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: auto;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0;
        margin-right: 0 !important;
        background: transparent;
        border: none;
        box-shadow: none;
        min-height: 0;
    }

    .ie-preview-actions {
        margin-right: 0 !important;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
    }

    .ie-preview-startover {
        min-width: var(--sp-tap);
        padding-left: 10px;
        padding-right: 10px;
    }

    .ie-preview-actions .ie-back-to-imports,
    .ie-preview-actions .ie-back-to-imports-form .ie-back-to-imports {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }

    .ie-col-vis,
    .sheet-row input.ie-col-vis {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        box-sizing: border-box;
    }

    .ie-preview-plan {
        font-size: 13px;
        line-height: 1.4;
        word-break: break-word;
        overflow-wrap: anywhere;
        padding: 10px 12px !important;
    }

    .ie-dup-toolbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .ie-dup-toolbar form {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
    }

    .ie-dup-toolbar select,
    .ie-dup-toolbar button,
    .ie-dup-toolbar label {
        width: 100%;
        max-width: 100%;
    }

    .ie-error-card.list-card,
    .ie-errors-first .list-card {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .ie-preview-end-confirm {
        margin: 12px 0 0;
    }

    .content-area:has(#ebv-preview-table-block) .ie-preview-end-confirm,
    .content-area:has(#gen-preview-table-block) .ie-preview-end-confirm {
        display: none;
    }

    .ie-preview-end-confirm .btn,
    .ie-preview-end-confirm button {
        width: 100%;
        min-height: var(--sp-tap);
        justify-content: center;
    }

    .ebv-summary-card,
    .gen-summary-card {
        min-width: 0;
        flex: 1 1 calc(50% - 8px);
    }

    .ebv-sticky-header .info-row,
    .gen-sticky-header .info-row {
        gap: 8px;
    }

    .ie-pmzip-preview-table.list-card-table {
        min-width: 0;
        width: 100%;
        table-layout: auto;
    }
}

/* ===== Phone: final-gate leftover taps / sticky overlap ===== */
@media (max-width: 767.98px) {
    .adj-ww-lbs-input { width: 60px; }
    .adj-ww-date-input { width: 130px; }

    #adj-ww-toolbar .adj-ww-filters .form-select-sm,
    #adj-ww-toolbar .adj-ww-filters .lg-select-toggle,
    #adj-ww-toolbar .adj-ww-filters .btn-sm,
    #adj-ww-filter-sheet .form-select-sm,
    #adj-ww-filter-sheet .lg-select-toggle,
    #adj-ww-filter-sheet .btn-sm {
        min-height: 44px;
        font-size: 16px;
    }
    #adj-ww-toolbar .nav-link { min-height: 44px; display: inline-flex; align-items: center; }
    #adj-ww-container th .adj-ww-sort { min-height: var(--sp-tap); display: inline-flex; align-items: center; }
    #adj-ww-container .page-header .btn,
    #adj-ww-container .page-header .btn-outline { min-height: 44px; }
    .adj-ww-row .form-select-sm,
    .adj-ww-row .form-control-sm { font-size: 16px !important; }

    #gestation-input {
        min-height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        box-sizing: border-box;
        font-size: 16px;
    }

    .action-btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 12px;
    }

    .flock-insights-grid a {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        display: inline-flex;
        align-items: center;
    }

    .ie-history-table tbody tr.history-detail,
    .ie-history-table tbody tr.history-detail a {
        min-height: var(--sp-tap);
    }

    .ie-history-table tbody tr.history-detail a {
        display: inline-flex;
        align-items: center;
    }

    .content-area:has(.ie-detail-actions) a,
    .content-area:has(.ie-detail-actions) button {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }

    .content-area:has(.ie-detail-actions) a {
        display: inline-flex;
        align-items: center;
    }

    #adj-ww-container .pagination-footer,
    #adj-ww-container .pagination-footer-spacer,
    .content-area:has(#adj-ww-container) .pagination-footer,
    .content-area:has(#adj-ww-container) .pagination-footer-spacer,
    .content-area:has(.ie-detail-actions) .pagination-footer,
    .content-area:has(.ie-detail-actions) .pagination-footer-spacer {
        display: none !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .sticky-actions.ie-detail-actions {
        position: static;
    }
}

/* ===== Phone: keep list cards after infinite-scroll row inserts =====
   Root cause: iOS WebKit can drop display:block/flex on <table>/<tr>
   after HTMX inserts rows, so a card list snaps back to a desktop table
   until a scroll-to-top reflow. Lock the card display so it cannot be
   lost. Desktop is unchanged (this block is phone-only). */
@media (max-width: 767.98px) {
    .list-card-table,
    .list-card-table tbody {
        display: block !important;
        width: 100% !important;
    }

    .list-card-table tbody > tr.animal-row,
    .list-card-table tbody > tr.row-clickable {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }

    .list-card-table tbody > tr.animals-infinite-sentinel,
    .list-card-table tbody > tr.animals-infinite-end,
    .list-card-table tbody > tr.phone-infinite-sentinel,
    .list-card-table tbody > tr.phone-infinite-end {
        display: block !important;
        width: 100% !important;
    }

    #animals-body-table.list-card-table {
        table-layout: auto !important;
    }

    #animals-infinite-sentinel.animals-infinite-sentinel,
    #animals-infinite-sentinel.animals-infinite-end {
        display: block;
        width: 100%;
        padding: 10px 12px 16px;
        text-align: center;
    }
}

/* ===== Phone: checkbox visual vs tap row (Sep 15 2026) =====
   Tap target is the label / .form-check row (44px). The input stays a
   normal Bootstrap-sized box (~1.25em). Desktop unchanged.
   Does not restyle animals-list bulk boxes, animal-form toggles, or
   import-preview skip checkboxes (other agents own those). */
@media (max-width: 767.98px) {
    .ie-export-checks input[type="checkbox"],
    .ie-export-checks-cols input[type="checkbox"],
    .ie-col-custom-toggle input[type="checkbox"],
    .form-check-input,
    .form-check input[type="checkbox"],
    .form-check input[type="radio"],
    .content-area:has(.sp-form-head) .form-check-input,
    .content-area:has(.sp-form-head) .form-check input[type="checkbox"] {
        width: 1.25em !important;
        height: 1.25em !important;
        min-width: 1.25em !important;
        min-height: 1.25em !important;
        margin-top: 0;
        flex-shrink: 0;
        accent-color: #1a2744;
    }

    .ie-export-checks label,
    .ie-export-checks-cols label,
    .ie-col-custom-toggle,
    .form-check,
    .rb-picker-panel label,
    .rb-fields-panel label {
        display: flex !important;
        align-items: center;
        gap: 10px;
        min-height: var(--sp-tap);
        width: 100%;
        box-sizing: border-box;
    }

    #animal-form input[type="checkbox"],
    #animal-form .form-check-input,
    #bulk-edit-form input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
    }

    /* Section-header toggles ("Is Dead", "Is Sold"): the 40px header grows
       to hold the 44px row. Left at 40px, the row spills onto the first
       field below, and that field takes the tap. */
    .content-area:has(.sp-form-head) .form-section-header:has(> .form-check) {
        height: auto !important;
    }

    .form-section-header > .form-check {
        width: auto;
        margin: 0 !important;
    }

    /* Export column picks (16 Sep 2026): the input's own box is the real
       44px hit area (audit-mobile measures the input, and the label row
       alone is not enough when a card sits inside the first screen). The
       drawn box stays 20px via padding + background-clip, so it still looks
       like the Sep 15 "normal-sized" checkbox. Not a ::after fake. */
    .ie-export-checks input[type="checkbox"],
    .ie-export-checks-cols input[type="checkbox"] {
        appearance: none;
        -webkit-appearance: none;
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        margin: 0 -12px 0 -12px;
        padding: 12px;
        box-sizing: border-box;
        border: none;
        border-radius: 0;
        background-color: transparent;
        background-image: none;
        cursor: pointer;
        position: relative;
    }
    .ie-export-checks input[type="checkbox"]::before,
    .ie-export-checks-cols input[type="checkbox"]::before {
        content: "";
        position: absolute;
        inset: 12px;
        border: 2px solid #6b7280;
        border-radius: 4px;
        background: #fff;
        box-sizing: border-box;
    }
    .ie-export-checks input[type="checkbox"]:checked::before,
    .ie-export-checks-cols input[type="checkbox"]:checked::before {
        border-color: #1a2744;
        background: #1a2744 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/></svg>") center / 14px 14px no-repeat;
    }
    .ie-export-checks input[type="checkbox"]:focus-visible::before,
    .ie-export-checks-cols input[type="checkbox"]:focus-visible::before {
        outline: 2px solid #1a2744;
        outline-offset: 2px;
    }
}

/* ===== Phone: export column picker 2-wide grid (Sep 15 2026) =====
   Overrides the one-per-row flex list and the template max-height
   scroller. Desktop keeps auto-fill + optional max-height. */
@media (max-width: 767.98px) {
    .ie-export-checks,
    .ie-export-checks-cols {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 4px 12px;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 0 12px;
    }

    .ie-export-checks label,
    .ie-export-checks-cols label {
        display: flex !important;
        align-items: center;
        gap: 8px;
        min-height: var(--sp-tap);
        min-width: 0;
        width: auto;
        max-width: 100%;
        overflow: hidden;
        padding: 0 2px;
        margin: 0;
        font-size: 14px;
        white-space: nowrap;
        box-sizing: border-box;
    }

    .ie-export-check-text {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ie-export-picker-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin: 0 0 4px;
    }

    .ie-export-picker-count {
        font-size: 13px;
        color: #6b7280;
    }

    .ie-export-picker-links {
        display: flex;
        align-items: center;
        gap: 0;
    }

    .ie-export-picker-link {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 6px 10px;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .ie-resume-banner-actions .btn,
    .ie-resume-banner-actions .btn-outline {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
    }
}

/* Shared look for Animals toolbar filters (native selects + Year born button). */
.animals-filter-select {
    padding: 8px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    background: white;
    cursor: pointer;
}
button.animals-filter-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    color: inherit;
    font-family: inherit;
    font-weight: 400;
    white-space: nowrap;
}
.animals-filter-select:focus,
.animals-filter-select:focus-visible {
    border-color: #1a2744;
}

/* Year-born filter: select-styled button + dropdown on desktop, bottom sheet on phones. */
.animals-year-dropdown {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    z-index: 30;
}
.animals-year-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    line-height: 1.2;
    color: inherit;
    font-family: inherit;
    font-weight: 400;
    white-space: nowrap;
    box-sizing: border-box;
    /* Holds "Year born (99) ▾" so the toolbar does not jump when a count appears. */
    min-width: 10.5rem;
}
.animals-year-panel[hidden],
.animals-year-backdrop[hidden] {
    display: none !important;
}
.animals-year-panel {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 10px 12px;
    z-index: 200;
    min-width: 11rem;
    max-height: 20rem;
    overflow-y: auto;
}
.animals-year-dropdown.is-open .animals-year-panel:not([hidden]),
.animals-year-panel:not([hidden]) {
    display: block;
}
.animals-year-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.animals-year-panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.animals-year-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.animals-year-clear {
    background: none;
    border: none;
    color: #1a2744;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}
.animals-year-panel .sheet-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 2rem;
    padding: 0;
    font-size: 0.9rem;
    cursor: pointer;
    color: #374151;
    white-space: nowrap;
}
.animals-year-panel .sheet-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1a2744;
    flex-shrink: 0;
    cursor: pointer;
}
.animals-year-empty {
    display: block;
    color: #6b7280;
    font-size: 0.85rem;
}

@media (max-width: 767.98px) {
    .animals-filter-select,
    .animals-year-btn {
        min-height: var(--sp-tap);
        font-size: 14px;
        padding: 6px 12px;
        box-sizing: border-box;
    }
    .animals-filter-select:not(.animals-year-btn) {
        min-width: var(--sp-tap);
    }
    .animals-year-btn {
        min-width: 10.5rem;
    }
    .animals-year-dropdown.is-open::before,
    .animals-year-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.35);
        z-index: 1050;
    }
    .animals-year-dropdown.is-open::before {
        content: "";
    }
    .animals-year-backdrop:not([hidden]) {
        display: block;
    }
    .animals-year-dropdown.is-open .animals-year-panel:not([hidden]),
    body > .animals-year-panel:not([hidden]),
    .animals-year-panel:not([hidden]) {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        margin-top: 0;
        width: 100%;
        min-width: 0;
        max-height: 85vh;
        border: none;
        border-radius: var(--sp-radius-lg) var(--sp-radius-lg) 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 1051;
        padding: 8px 16px calc(12px + var(--sp-safe-bottom));
    }
    .animals-year-dropdown.is-open .animals-year-panel:not([hidden]),
    body > .animals-year-panel:not([hidden]) {
        display: block;
        position: fixed;
    }
    .animals-year-panel-head {
        min-height: var(--sp-tap);
    }
    .animals-year-clear {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        font-size: 14px;
    }
    .animals-year-panel .sheet-row {
        font-size: 16px;
        min-height: var(--sp-tap);
    }
    .animals-year-panel .sheet-row input[type="checkbox"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }
    .mgmt-group-actions-cell.list-card-sub {
        flex: 1 0 100%;
        color: inherit;
        font-weight: 500;
    }
    .mgmt-group-actions .btn,
    .mgmt-group-actions .btn-outline,
    #bulkMgmtModal .btn,
    #bulkMgmtModal .btn-outline,
    #bulkMgmtModal .form-select {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
    }
}

/* Management group typeahead — desktop + phone. */
.mg-typeahead {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}
.mg-animals-panel {
    overflow: visible;
}
.mg-typeahead-list {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 40;
    width: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 16rem;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}
.mg-typeahead-list .sheet-row,
.mg-typeahead-list .mg-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: var(--sp-tap);
    padding: 0 12px;
    border: 0;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    color: #111827;
}
.mg-typeahead-list .sheet-row:last-child,
.mg-typeahead-list .mg-search-row:last-child {
    border-bottom: 0;
}
.mg-typeahead-list .sheet-row.is-active,
.mg-typeahead-list .sheet-row:hover,
.mg-typeahead-list .mg-search-row.is-active,
.mg-typeahead-list .mg-search-row:hover {
    background: #f3f4f6;
}
.mg-search-tag {
    font-weight: 600;
    flex: 0 0 auto;
}
.mg-search-meta {
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}
.mg-search-empty {
    cursor: default;
    color: #6b7280;
    font-style: italic;
}
.mg-add-hint {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: #dc2626;
}
.mg-reports-menu {
    max-width: min(18rem, calc(100vw - 16px));
    max-height: min(20rem, calc(100vh - 6rem));
    overflow-y: auto;
}
#mgmt-members-body a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== W5 record / tags / UX (Sep 16 2026) =====
   Pedigree tab, scanner photo lightbox, time-range undo. */
.animal-photo-meta {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    max-width: 84px;
    line-height: 1.3;
}
.animal-photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: rgba(15, 23, 42, 0.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.animal-photo-lightbox[hidden] { display: none !important; }
.animal-photo-lightbox img {
    max-width: min(920px, 100%);
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}
.animal-photo-lightbox-caption {
    color: #e5e7eb;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
}
.animal-photo-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    min-width: var(--sp-tap);
    min-height: var(--sp-tap);
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.time-range-undo select,
.time-range-undo input,
.time-range-undo button {
    min-height: var(--sp-tap);
}
@media (max-width: 767.98px) {
    /* The record toolbar stays pinned; cap so it does not cover more
       than ~40% of the phone viewport. */
    .page-sticky-toolbar:has(.animal-record-header) {
        max-height: 40vh;
        overflow-x: hidden;
        overflow-y: auto;
        z-index: 50;
        background: #FAF9F6;
    }
    .mgmt-animals-toolbar {
        display: block;
    }
    .mg-add-animal {
        width: 100%;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 8px 12px;
        box-sizing: border-box;
    }
    .mg-add-animal .form-control {
        min-width: 0;
        flex: 1 1 auto;
        min-height: var(--sp-tap);
    }
    .mg-add-animal .btn {
        flex: 0 0 auto;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        white-space: nowrap;
    }
    .mg-typeahead-list {
        width: 100%;
        max-width: 100%;
    }
    .mg-typeahead-list .sheet-row,
    .mg-typeahead-list .mg-search-row {
        min-height: var(--sp-tap);
    }
    .mg-reports-menu .dropdown-item {
        min-height: var(--sp-tap);
    }
    .mgmt-remove-btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }

    /* Super admin company list — farmer shell offset does not apply. */
    body.sheep-admin .main-content {
        padding-top: 0;
    }
    body.sheep-admin .content-area {
        padding: 12px;
    }
    body.sheep-admin .sp-admin-toolbar {
        flex-direction: column;
        align-items: stretch;
        max-width: 100%;
    }
    body.sheep-admin .sp-admin-toolbar > * {
        min-width: 0 !important;
        width: 100%;
        max-width: 100%;
    }
    body.sheep-admin .sp-admin-filter-row {
        flex-wrap: wrap;
        max-width: 100%;
    }
    body.sheep-admin .sp-admin-filter-row select,
    body.sheep-admin .sp-admin-filter-row button,
    body.sheep-admin #search-companies {
        min-width: 0 !important;
        max-width: 100%;
        width: 100%;
        min-height: var(--sp-tap);
        box-sizing: border-box;
    }
    body.sheep-admin .sp-admin-filter-row select,
    body.sheep-admin .sp-admin-filter-row button {
        flex: 1 1 100%;
    }
    body.sheep-admin .sp-admin-owner-link {
        display: inline-flex;
        align-items: center;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    body.sheep-admin .companies-table-scroll .table.list-card-table {
        min-width: 0;
        width: 100%;
        table-layout: auto;
    }
    body.sheep-admin .companies-table-scroll .list-card-table th,
    body.sheep-admin .companies-table-scroll .list-card-table td,
    body.sheep-admin .companies-table-scroll .list-card-table td > div {
        overflow: visible;
        text-overflow: unset;
    }
    body.sheep-admin .bp-upload .form-control,
    body.sheep-admin .bp-upload .btn,
    body.sheep-admin .bp-upload .btn-outline,
    body.sheep-admin .bp-upload a.btn-outline {
        min-height: var(--sp-tap);
        box-sizing: border-box;
        font-size: 16px;
    }
}

@media (max-width: 767.98px) {
    .pregscan-form-layout {
        display: block;
    }
    .content-area:has(#pregscan-form) .sp-form-actions-top,
    .content-area:has(#pregscan-edit-form) .sp-form-actions-top {
        display: none !important;
    }
    .content-area:has(#pregscan-form) .sticky-actions,
    .content-area:has(#pregscan-edit-form) .sticky-actions {
        display: flex !important;
    }
    .content-area:has(#pregscan-form),
    .content-area:has(#pregscan-edit-form) {
        padding-bottom: 88px !important;
    }
    .pregscan-lookup-item,
    .pregscan-add-ewe,
    .pregscan-row-actions .btn-outline,
    .pregscan-row-actions .btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    #pregscan-filter-sheet .btn-close {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        width: var(--sp-tap);
        height: var(--sp-tap);
        box-sizing: border-box;
        padding: 0;
        margin: 0;
    }
    #filter-pregscan-from,
    #filter-pregscan-to,
    #filter-pregscan-result {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
        font-size: 16px;
    }
    .pregscan-comment-flags label {
        min-height: var(--sp-tap);
        display: flex;
        align-items: center;
        gap: 8px;
    }
}

.pregscan-form-card,
.pregscan-ewe-card,
.pregscan-scanned-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
}
.pregscan-lookup-wrap {
    position: relative;
}
.pregscan-lookup-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 20;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.pregscan-lookup-item,
.pregscan-lookup-empty {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 10px 12px;
    color: #1f2937;
}
.pregscan-add-ewe {
    margin: 0 0 16px;
}
.pregscan-scanned-list {
    padding: 12px;
}
.pregscan-scanned-row + .pregscan-scanned-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}
.pregscan-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.pregscan-delete-form {
    display: inline;
    margin: 0;
}
.pregscan-comment-flags {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}
.pregscan-comment-flags fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}
.pregscan-comment-flags legend {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.pregscan-comment-flags label {
    margin-right: 12px;
}
.pregscan-priority-chip,
.pregscan-handled-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.pregscan-priority-high { background: #fee2e2; color: #991b1b; }
.pregscan-priority-medium { background: #fef3c7; color: #92400e; }
.pregscan-priority-low { background: #e0e7ff; color: #3730a3; }
.pregscan-handled-chip { background: #dcfce7; color: #166534; }
.pregscan-followups {
    margin-top: 8px;
}

.sa-imports-scroll {
    max-height: calc(15 * 2.75rem + 2.75rem);
    overflow-y: auto;
}
.sa-imports-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
}
.sa-import-results {
    display: none;
    padding: 12px 8px;
}
.sa-import-results.is-open {
    display: block;
}
.sa-imports-keep-reason {
    display: block;
    font-size: 12px;
    color: #6b7280;
}
.sa-imports-filter {
    min-width: 10rem;
}

@media (max-width: 767.98px) {
    .sa-imports-toggle,
    .sa-imports-download,
    .sa-imports-more,
    .sa-imports-filter {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    .sa-import-results-row td::before {
        content: none;
    }
    .sa-imports-keep-reason {
        margin-top: 4px;
    }
}

.ie-pending-page {
    padding: 8px 0 16px;
}
.ie-pending-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 0 12px;
}
.ie-pending-chip {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
}
.ie-pending-empty,
.ie-pending-help,
.ie-pending-count {
    font-size: 14px;
    color: #6b7280;
    margin: 8px 0;
}
.ie-pending-heading {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0 8px;
}
.ie-pending-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 8px 0 16px;
}
.ie-pending-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
}
.ie-pending-filter select,
.ie-pending-filter input {
    min-height: var(--sp-tap);
    min-width: 12rem;
    padding: 8px 12px;
    font-size: 14px;
}
.ie-pending-filters .btn {
    min-height: var(--sp-tap);
    padding: 8px 18px;
}
.ie-pending-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}
.ie-pending-table thead.list-card-header {
    display: table-header-group;
}
.ie-pending-table th,
.ie-pending-table td {
    display: table-cell;
    text-align: left;
    vertical-align: top;
    padding: 12px 14px;
    white-space: normal;
}
.ie-pending-table th {
    white-space: nowrap;
}
.ie-pending-table td .list-card-title {
    font-weight: 700;
    font-size: 15px;
    color: #111827;
}
.ie-pending-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.ie-pending-link-chip {
    background: #f3f4f6;
    color: #374151;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    margin-top: 0;
}
.ie-pending-more {
    display: inline-block;
}
.ie-pending-more summary {
    cursor: pointer;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 600;
    list-style: none;
    min-height: var(--sp-tap);
    display: inline-flex;
    align-items: center;
}
.ie-pending-more summary::-webkit-details-marker {
    display: none;
}
.ie-pending-more[open] .ie-pending-links {
    margin-top: 8px;
}
.ie-pending-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ie-pending-actions .btn,
.ie-pending-actions .btn-outline {
    min-height: var(--sp-tap);
}
.ie-pending-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--sp-tap);
    font-weight: 600;
}
.ie-pending-conflict {
    background: #fee2e2;
    color: #b91c1c;
}
.ie-pending-conflict-detail {
    font-size: 12px;
    color: #7f1d1d;
}
.ie-pending-decision {
    border-left: 3px solid #fca5a5;
    padding: 4px 0 4px 10px;
    margin-bottom: 10px;
}
.ie-pending-decision .ie-pending-actions {
    margin-top: 6px;
}
.ie-pending-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
}
@media (min-width: 768px) {
    table.ie-pending-table.list-card-table,
    table.ie-pending-table.list-card-table thead,
    table.ie-pending-table.list-card-table tbody {
        display: table;
        width: 100%;
    }
    table.ie-pending-table.list-card-table thead,
    table.ie-pending-table.list-card-table thead.list-card-header {
        display: table-header-group;
    }
    table.ie-pending-table.list-card-table tbody {
        display: table-row-group;
    }
    table.ie-pending-table.list-card-table tr {
        display: table-row;
    }
    table.ie-pending-table.list-card-table th,
    table.ie-pending-table.list-card-table td {
        display: table-cell;
        width: auto;
        max-width: none;
        text-align: left;
        vertical-align: top;
    }
}
.ie-preview-error-banner,
.ie-preview-note-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
}
.ie-preview-error-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.ie-preview-note-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}
.ie-note-pill {
    font-size: 9px;
    color: #b45309;
    font-weight: 700;
    background: #fef3c7;
    padding: 1px 5px;
    border-radius: 8px;
}

@media (max-width: 767.98px) {
    #ie-inpage-confirm-panel {
        padding: 16px;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    }
    #ie-inpage-confirm-card .sticky-actions {
        gap: 12px;
        padding-top: 8px;
    }
    #import-history .page-sticky-toolbar.ie-has-sticky-actions {
        z-index: 4;
        background: #fff;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    /* The history filter bar is position:fixed at the bottom, and so is
       the pager. Keep that bar one row so one tap of lift clears the
       arrows on a 360px phone as well as on iPhone 13. */
    #import-history .sticky-actions.ie-history-actions {
        flex-wrap: nowrap;
        gap: 8px;
    }
    #import-history .sticky-actions.ie-history-actions > * {
        flex: 1 1 0;
        min-width: 0;
    }
    #import-history .pagination-footer {
        bottom: calc(var(--sp-tap) + var(--sp-safe-bottom));
        padding-bottom: 0;
        z-index: 55;
    }
    #import-history .pagination-footer-spacer {
        height: calc((var(--sp-tap) * 2) + var(--sp-safe-bottom));
    }
    .content-area:has(.ie-pending-bulk) .ie-pending-pager {
        margin-bottom: calc(var(--sp-tap) + var(--sp-safe-bottom));
    }
    #import-history .ie-history-table {
        margin-top: 4px;
    }
    .ie-pending-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .ie-pending-filter select,
    .ie-pending-filter input,
    .ie-pending-filters .btn {
        width: 100%;
        min-width: 0;
        min-height: var(--sp-tap);
    }
    .ie-pending-chip {
        font-size: 14px;
        padding: 8px 14px;
    }
    .ie-pending-table.list-card-table tbody > tr {
        display: block;
        width: 100%;
        padding: 16px 12px;
        margin: 0 0 12px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
        box-sizing: border-box;
    }
    .ie-pending-table.list-card-table td {
        display: block;
        width: 100% !important;
        text-align: left !important;
        padding: 8px 0;
    }
    .ie-pending-actions .btn,
    .ie-pending-actions .btn-outline,
    .ie-pending-bulk .btn,
    .ie-pending-bulk .btn-outline,
    .ie-pending-pager .btn-outline {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    #pending-select-all-bar,
    .ie-pending-page .pending-select-all,
    .ie-pending-page .pending-group-check,
    .ie-pending-table input[type="checkbox"],
    .ie-pending-select-all input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        margin: 0;
        flex: 0 0 var(--sp-tap);
        accent-color: #1a2744;
    }
    .ie-pending-table.list-card-table td[data-label="Select"] {
        display: flex !important;
        align-items: center;
        width: auto !important;
        min-height: var(--sp-tap);
        padding-top: 0;
        padding-bottom: 0;
    }
    .ie-pending-table.list-card-table td[data-label="Select"]::before {
        content: none;
    }
}

/* Shared record theme: every record page (Animal Record included) draws its
   hero, cards, card headers, chips and label/value rows from these rules. */
.sp-hero, .sp-record-card, .ar-card, .ar-hero {
    background: #fff;
    border: 1px solid #e7e2d6;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(26, 39, 68, .06), 0 8px 24px rgba(26, 39, 68, .04);
}
.ar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--sp-tap);
    padding: 0 16px; font-size: 0.875rem; font-weight: 700; color: #1a2744; background: #f3f1ea; border-bottom: 1px solid #e7e2d6; }
.ar-head:has(+ [hidden]:last-child) { border-bottom: 0; }
.ar-head-title { margin: 0; font-size: inherit; font-weight: 700; color: inherit; }
.kv-list > .kv-row:last-child, .kv-group > .kv-row:last-child { border-bottom: 0; }
.sp-hero {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    margin-top: 8px;
}
.sp-hero-photo {
    flex: 0 0 5.5rem;
    width: 5.5rem;
    height: 5.5rem;
}
.sp-hero-photo img,
.sp-hero-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    background: #d7d2c8;
    color: #5b5346;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.25;
}
.sp-hero-main {
    flex: 1 1 auto;
    min-width: 0;
}
.sp-hero-tag {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: #1a2744;
    line-height: 1.15;
}
.sp-hero-tag a {
    color: inherit;
    text-decoration: none;
}
.sp-hero-sub {
    margin: 4px 0 10px;
    color: #6b7280;
    font-size: 0.95rem;
}
.sp-hero-meta {
    flex: 0 0 auto;
    text-align: right;
    color: #6b7280;
    font-size: 0.85rem;
}
.sp-hero-meta-item + .sp-hero-meta-item {
    margin-top: 6px;
}
.sp-hero-meta-lbl {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}
.sp-hero-meta-val {
    font-weight: 600;
    color: #1f2937;
}

.sp-record-card {
    margin-top: 14px;
}
/* Super Admin status menu is position:absolute; overflow:hidden clips it.
   Keep the unclip at the card, not the page shell — .main-content /
   .content-area overflow-x:hidden must stay. Table menus use
   status-dropdown-fixed (viewport) and do not need the shell. */
.sp-record-card:has(.status-dropdown),
.sp-record-card:has(.status-dropdown) .kv-list,
.sp-record-card:has(.status-dropdown) .kv-row,
.sp-record-card:has(.status-dropdown) .kv-val {
    overflow: visible;
}

.sp-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 12px;
    padding: 14px 0 0;
    background: transparent;
    border: 0;
}
.sp-kpi {
    background: #fff;
    border: 1px solid #e7e2d6;
    border-radius: 12px;
    padding: 14px 16px;
}
.sp-kpi-lbl {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
}
.sp-kpi-val {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1a2744;
    margin-top: 4px;
}
.sp-kpi-hint {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 2px;
}
.sp-kpi-created {
    border-color: #dcfce7;
}
.sp-kpi-created .sp-kpi-lbl,
.sp-kpi-created .sp-kpi-val {
    color: #10b981;
}
.sp-kpi-updated {
    border-color: #dbeafe;
}
.sp-kpi-updated .sp-kpi-lbl,
.sp-kpi-updated .sp-kpi-val {
    color: #2563eb;
}
.sp-kpi-skipped {
    border-color: #fee2e2;
}
.sp-kpi-skipped .sp-kpi-lbl,
.sp-kpi-skipped .sp-kpi-val {
    color: #dc2626;
}

.sp-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 2px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 0.78rem;
    font-weight: 600;
}

@media (max-width: 767.98px) {
    .sp-hero {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    .sp-hero-photo {
        width: 4.5rem;
        height: 4.5rem;
        flex-basis: 4.5rem;
    }
    .sp-hero-tag {
        font-size: 1.45rem;
    }
    .sp-hero-tag a {
        display: inline-flex;
        align-items: center;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
    }
    .page-sticky-toolbar .welcome-title a,
    .sp-record-card .kv-val a,
    .parent-record-link {
        display: inline-flex;
        align-items: center;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        box-sizing: border-box;
    }
    .sp-hero-meta {
        text-align: left;
    }
    .sp-kpis {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding-top: 10px;
    }
}

/* ── Animal Record (hero, tiles, cards, + Record) ───────────────────────── */
.ar-page { padding-bottom: 2rem; color: #1f2937; font-size: 0.9375rem; line-height: 1.45; }
.ar-card { margin-bottom: 14px; }
.ar-page .ar-tile { border-color: #e7e2d6; border-radius: 12px;
    box-shadow: 0 1px 2px rgba(26, 39, 68, .06), 0 8px 24px rgba(26, 39, 68, .04); }
.ar-head-link { background: none; border: 0; padding: 0 4px; min-height: var(--sp-tap); display: inline-flex; align-items: center;
    color: #2563eb; font-weight: 650; font-size: 0.875rem; text-decoration: none; cursor: pointer; }
.ar-body { padding: 12px 0 16px; }
.ar-muted { color: #6b7280; font-weight: 500; }
.ar-note { margin: 0; padding: 10px 16px 0; font-size: 0.75rem; color: #6b7280; }
.ar-sec { margin: 10px 16px 4px; font-size: 0.72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #6b7280; }
.ar-lbl { display: block; font-size: 0.68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #6b7280; }
.ar-val { display: block; font-weight: 700; color: #1a2744; }
.ar-sub { display: block; font-size: 0.78rem; color: #6b7280; }
.ar-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 16px; font-size: 0.82rem; flex-wrap: wrap; }
.ar-btn { display: inline-flex; align-items: center; gap: 8px; min-height: var(--sp-tap); padding: 6px 14px; border-radius: 8px;
    border: 1.5px solid #d1d5db; background: #fff; color: #1a2744; font-weight: 700; font-size: 0.85rem; cursor: pointer; text-decoration: none; }
.ar-btn-danger { color: #be123c; border-color: #fecaca; }
.ar-delete { margin: 18px 0 0; }

.ar-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #f3f4f6;
    color: #374151; font-size: 0.75rem; font-weight: 700; white-space: nowrap; line-height: 1.45; }
.ar-chip.green { background: #d1fae5; color: #065f46; }
.ar-chip.blue { background: #eef2ff; color: #1e3a8a; }
.ar-chip.amber { background: #fef3c7; color: #92400e; white-space: normal; }
.ar-chip.red { background: #fee2e2; color: #991b1b; }
.ar-chip.muted { background: #f9fafb; color: #6b7280; border: 1px dashed #d1d5db; }
.ar-chip-link { color: #2563eb; font-weight: 800; text-decoration: underline; display: inline-flex; align-items: center;
    justify-content: center; min-height: var(--sp-tap); min-width: var(--sp-tap); margin: -14px 0; }
.ar-chip-act { display: inline-flex; align-items: center; min-height: var(--sp-tap); margin: -12px -6px -12px 6px; padding: 0 6px;
    border: 0; background: none; color: #92400e; font-weight: 800; text-decoration: underline; cursor: pointer; }
.ar-chip-x { display: inline-flex; align-items: center; justify-content: center; min-width: var(--sp-tap); min-height: var(--sp-tap);
    margin: -12px -10px -12px -4px; border: 0; background: none; color: #6b7280; cursor: pointer; }

.ar-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: start; padding: 16px 18px; margin-bottom: 14px; }
.ar-photo { width: 112px; height: 112px; border-radius: 10px; border: 1.5px dashed #cbd5e1; background: #f8fafc; color: #64748b;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 0.72rem; font-weight: 700;
    cursor: pointer; overflow: hidden; padding: 0; }
.ar-photo i { font-size: 1.2rem; }
.ar-photo-img { border-style: solid; }
.ar-photo-img img { width: 100%; height: 100%; object-fit: cover; }
.ar-hero-tag { margin: 0; font-size: 1.75rem; font-weight: 800; color: #1a2744; line-height: 1.1; letter-spacing: -0.03em; }
.ar-hero-name { margin-left: 10px; font-size: 1rem; font-weight: 600; color: #6b7280; letter-spacing: 0; }
.ar-hero-sub { margin: 4px 0 0; color: #6b7280; }
.ar-hero-main { min-width: 0; }
.ar-hero-main [role="status"] { margin: 8px 0 0; white-space: normal; overflow-wrap: anywhere; }
.ar-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ar-facts { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; text-align: right; font-size: 0.75rem; color: #6b7280; }
.ar-fact-act { display: inline-flex; align-items: center; min-height: var(--sp-tap); min-width: var(--sp-tap); margin: -14px 0; padding: 0 4px;
    border: 0; background: none; color: #2563eb; font-weight: 700; font-size: 0.82rem; cursor: pointer; }
.ar-move { display: grid; gap: 8px; padding: 10px 16px; border-bottom: 1px solid #f1eee6; }
.ar-page .ar-move[hidden] { display: none; }
.ar-move-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.ar-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ar-tile { background: #fff; border: 1px solid #e7e2d6; padding: 10px 12px; min-width: 0; }
.ar-page .ar-tile { border-radius: 10px; }
.ar-tile-lbl { font-size: 0.6875rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6b7280;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-tile-val { margin-top: 2px; font-size: 1.125rem; font-weight: 800; color: #1a2744; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-tile-hint { font-size: 0.6875rem; color: #9ca3af; overflow-wrap: anywhere; }
.ar-tile-empty .ar-tile-val { color: #9ca3af; }

.ar-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.ar-col-box > .ar-card, .ar-col-box #record-lazy-panels > .ar-card { margin-top: 0; margin-bottom: 14px; }

.ar-ebv { padding: 0 16px; }
.ar-ebv-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1eee6; }
.ar-ebv-line b { font-weight: 650; color: #374151; }
.ar-ebv-line > span:last-child { color: #4b5563; text-align: right; }
.ar-bar { height: 8px; border-radius: 99px; background: #ece8de; margin: -4px 0 10px; overflow: hidden; position: relative; }
.ar-bar i { display: block; height: 100%; background: #0f766e; }
.ar-bar i.lower { background: #b45309; }

.ar-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 10px 16px 4px; }
.ar-spark { display: block; width: calc(100% - 32px); height: 56px; margin: 0 16px; }
.ar-spark polyline { fill: none; stroke: #0f766e; stroke-width: 2.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ar-chart { display: block; width: calc(100% - 24px); height: auto; margin: 6px 12px; }
.ar-chart .g { stroke: #eceef2; }
.ar-chart text { font-size: 11px; fill: #6b7280; }
.ar-chart .u { font-weight: 700; }
.ar-chart polyline { fill: none; stroke: #0f766e; stroke-width: 2.5; }
.ar-chart circle { fill: #0f766e; }
.ar-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.ar-table th { background: #f3f4f6; color: #6b7280; font-size: 0.66rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    padding: 8px 12px; text-align: left; }
.ar-table td { padding: 8px 12px; border-bottom: 1px solid #f1f2f4; color: #1a2744; font-weight: 600; }
.ar-table td small { font-weight: 500; }
.ar-table td:first-child { white-space: nowrap; }
.ar-table tbody[hidden] { display: none !important; }

.ar-rec { position: relative; }
.animal-record-actions .animal-nav-btn:not(.btn) { display: inline-flex; align-items: center; justify-content: center;
    min-width: var(--sp-tap); min-height: var(--sp-tap); padding: 0 !important; }
.animal-record-actions .animal-nav-btn:not(.btn) .animal-nav-label { display: none; }
.animal-record-actions .animal-nav-btn:not(.btn) i { margin: 0 !important; }
@media (min-width: 768px) {
    .animal-record-actions .animal-nav-back:not(.btn) { gap: 6px; padding: 0 14px !important; }
    .animal-record-actions .animal-nav-back:not(.btn) .animal-nav-label { display: inline; }
}
.ar-rec-title { margin: 8px 20px 4px; font-weight: 800; color: #1a2744; }
.ar-rec-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 13rem; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 10px; box-shadow: 0 10px 28px rgba(26, 39, 68, .16); padding: 6px 0; }
.ar-rec-menu[hidden] { display: none; }
.ar-rec-menu a, .ar-rec-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--sp-tap); padding: 8px 16px;
    border: 0; background: none; text-align: left; font-weight: 600; font-size: 0.9rem; color: #1a2744; text-decoration: none; cursor: pointer; }
.ar-rec-menu a:hover, .ar-rec-menu button:hover { background: #f3f4f6; }
.ar-rec-menu i { width: 18px; text-align: center; color: #0f766e; }
.ar-hist { list-style: none; margin: 0; padding: 0; }
.ar-hist li { display: grid; grid-template-columns: 22px 104px minmax(0, 1fr); gap: 8px; padding: 7px 16px; border-bottom: 1px solid #f1f2f4;
    align-items: start; font-size: 0.86rem; }
.ar-hist li.ar-hist-empty { display: block; }
.ar-hist li i { color: #0f766e; padding-top: 3px; }
.ar-h-date { color: #6b7280; font-size: 0.82rem; white-space: nowrap; }
.ar-h-txt small { display: block; color: #6b7280; }

.ar-tree { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; padding: 0 16px;
    font-size: 0.8125rem; }
.ar-node { border: 1px solid #e7e2d6; border-radius: 8px; padding: 8px 10px; background: #fff; display: flex; flex-direction: column;
    min-width: 0; overflow-wrap: anywhere; }
.ar-node-link { min-height: var(--sp-tap); text-decoration: none; color: inherit; }
.ar-node-link b { color: #2563eb; font-weight: 600; }
.ar-node-link:hover { border-color: #93c5fd; }
.ar-node-me { border-color: #c7d2fe; background: #eef2ff; color: #1a2744; font-weight: 800; }
.ar-node { justify-content: center; }
.ar-hist li:last-child, .ar-kv-pad .kv-row:last-child { border-bottom: 0; }
.ar-off-table .parent-record-link { display: inline-flex; align-items: center; min-height: var(--sp-tap); min-width: var(--sp-tap); }
.ar-off-table th, .ar-off-table td { vertical-align: middle; text-align: left; }
.ar-ebv-table td:first-child { white-space: normal; text-align: left; }
.ar-ebv-table th:last-child, .ar-ebv-table td:last-child { padding-right: 16px; }
.ar-ebv-table td:not(:first-child), .ar-ebv-table th:not(:first-child) { text-align: right; white-space: nowrap; }
.ar-ebv-table .ar-ebv-sec th { background: #fafaf7; color: #374151; border-top: 1px solid #eceef2; }
.ar-card.ar-o-ebvs { overflow: visible; }
.ar-hero-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; color: #1a2744; }
.ar-hero-bit b { font-weight: 800; }
.ar-ebv-tools { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.ar-ebv-run { font-size: 0.75rem; white-space: nowrap; }
.ar-ebv-flat td.ar-ebv-name, .ar-ebv-flat th.ar-ebv-name { text-align: left; font-weight: 500; }
.ar-ebv-flat td.ar-ebv-trait, .ar-ebv-flat td.ar-ebv-val { font-weight: 800; }
.ar-ebv-flat td.ar-ebv-trait { display: flex; align-items: center; gap: 2px; }
.ar-ebv-trait-text { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; overflow: hidden; line-height: 1.25; }
.ar-ebv-sub { display: block; width: 0; min-width: 100%; color: #6b7280; font-weight: 500; font-size: 0.75rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-ebv-window, .ar-off-window { overflow-x: hidden; overflow-y: auto; }
.ar-ebv-window { max-height: calc(6 * var(--sp-window-row) + var(--sp-window-head)); container-type: inline-size; }
.ar-off-window { max-height: calc(10 * var(--sp-window-row) + var(--sp-window-head)); }
.ar-ebv-window .ar-ebv-flat, .ar-off-window .ar-off-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.ar-ebv-window .ar-ebv-flat { table-layout: auto; }
@media (min-width: 768px) {
    .ar-ebv-flat th:nth-child(1), .ar-ebv-flat td:nth-child(1) { width: 100%; }
    .ar-ebv-flat th:nth-child(2), .ar-ebv-flat td:nth-child(2),
    .ar-ebv-flat th:nth-child(3), .ar-ebv-flat td:nth-child(3),
    .ar-ebv-flat th:nth-child(4), .ar-ebv-flat td:nth-child(4) { width: 1%; white-space: nowrap; }
}
@container (max-width: 360px) {
    .ar-ebv-flat th, .ar-ebv-flat td { padding-left: 4px; padding-right: 4px; }
    .ar-ebv-flat th:last-child, .ar-ebv-flat td:last-child { padding-right: 4px; }
}
@container (max-width: 310px) {
    .ar-ebv-flat th, .ar-ebv-flat td { padding-left: 2px; padding-right: 2px; }
    .ar-ebv-flat th:last-child, .ar-ebv-flat td:last-child { padding-right: 2px; }
}
.ar-ebv-window .ar-ebv-flat thead th, .ar-off-window .ar-off-table thead th {
    position: sticky; top: 0; z-index: 1; background: #f3f4f6;
}
.ebv-row-grip {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: var(--sp-tap); height: var(--sp-tap); min-width: var(--sp-tap); min-height: var(--sp-tap);
    margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #6b7280;
    cursor: grab; touch-action: none;
}
.ebv-row-grip:focus-visible { outline: 2px solid #1a2744; outline-offset: 2px; }
.ebv-row-grip:active { cursor: grabbing; }
@media (hover: hover) and (pointer: fine) {
    .ebv-row-grip:hover::after {
        content: "Drag to reorder";
        position: absolute; left: calc(100% + 4px); top: 50%; transform: translateY(-50%);
        padding: 2px 8px; border-radius: 4px; background: #1a2744; color: #fff;
        font-size: 0.75rem; font-weight: 650; line-height: 1.3; white-space: nowrap;
        pointer-events: none; z-index: 4;
    }
}
html.ebv-grabbing, html.ebv-grabbing * { cursor: grabbing; }
.ebv-row-grip-mark {
    width: 10px; height: 16px;
    background-image: radial-gradient(currentColor 1.25px, transparent 1.35px);
    background-size: 5px 5px; background-position: center;
}
.ar-ebv-top { color: #0f766e; font-weight: 800; }
.ar-ebv-dir { color: #a16207; font-weight: 650; }
.ar-ebv-unlinked td { color: #9ca3af; }
.ar-ebv-flat tr.is-dragging { outline: 2px solid #2563eb; background: #eef2ff; }
.ar-ebv-draghint { display: none; margin-left: 8px; color: #2563eb; font-weight: 700; }
.ar-ebv-flat tr.is-dragging .ar-ebv-draghint { display: inline; }
.ebv-trait-panel { min-width: 16rem; }
.ebv-trait-row { justify-content: space-between; }
.ebv-trait-row.is-dragging { background: #eef2ff; }
#ebv-trait-save { position: sticky; bottom: 0; min-height: var(--sp-tap); margin-top: 8px; background: #fff; }
.ar-kv-pad { padding: 0 16px; }
.ar-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid #eceef2; }
.ar-tab { min-height: var(--sp-tap); padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: none;
    color: #6b7280; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.ar-tab[aria-selected="true"] { color: #1a2744; border-bottom-color: #1a2744; }
.ar-page [role="tabpanel"][hidden] { display: none; }
.ar-timeline { list-style: none; margin: 0; padding: 4px 0; }
.ar-timeline-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 0 8px; padding: 7px 16px; border-bottom: 1px solid #f1f2f4; }
.ar-timeline-dot { grid-row: span 2; color: #0f766e; padding-top: 2px; }
.ar-timeline-what { font-weight: 700; color: #1a2744; }
.ar-timeline-when { color: #6b7280; font-size: 0.82rem; }
.ar-timeline-undone { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: 0.72rem; }
.ar-page .animal-record-empty { margin: 0; padding: 8px 16px; color: #6b7280; }

/* Label / value list: one row per field, label left, value right, row separators. */
.kv-rows { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.kv-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
    padding: 8px 0; border-bottom: 1px solid #f1eee6; }
.kv-key { margin: 0; min-width: 0; flex: 0 1 auto; color: #374151; font-weight: 650; overflow-wrap: anywhere; }
.kv-raw { display: block; color: #9ca3af; font-size: 0.7rem; font-weight: 500; }
.kv-val { margin: 0; min-width: 0; flex: 0 1 auto; color: #4b5563; font-weight: 400; text-align: right; overflow-wrap: anywhere; }
.kv-val .ar-chip { white-space: normal; text-align: left; }
.kv-list { padding: 0 16px 10px; }
.kv-list .kv-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.kv-group { margin-top: 12px; }
.kv-group-head { margin: 0 0 2px; font-size: 0.72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #374151; }
.kv-group-head span { letter-spacing: 0; text-transform: none; font-weight: 600; }
.kv-row.is-empty, .kv-group.is-empty { display: none; }
.kv-show-empty .kv-row.is-empty { display: flex; }
.kv-show-empty .kv-group.is-empty { display: block; }
.kv-row.is-empty .kv-val { color: #9ca3af; font-weight: 500; }

.ar-more[hidden] { display: none; }
.ar-more { border-top: 1px solid #f1f2f4; }
.ar-group-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.ar-group-add .form-select { width: auto; max-width: 100%; min-height: var(--sp-tap); }

.ar-btn-primary { background: #1a2744; border-color: #1a2744; color: #fff; }
.ar-card-slim { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 16px 8px; }
.ar-slim-text { margin: 0; color: #4b5563; font-size: 0.84rem; }
.ar-page [data-ar-slim][hidden], .ar-page .ar-qn[hidden] { display: none !important; }
.ar-qn { display: grid; gap: 8px; padding: 10px 16px 12px; border-bottom: 1px solid #f1f2f4; background: #fafaf7; }
.ar-qn textarea { min-height: 5.5rem; }
.ar-qn-check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--sp-tap); font-weight: 600; justify-self: start; }
.ar-qn-msg { margin: 0; color: #b91c1c; font-size: 0.82rem; font-weight: 600; }
.ar-qn-msg:empty { display: none; }
.ar-qn-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ar-page input.ar-check { appearance: none; -webkit-appearance: none; flex: none; position: relative; box-sizing: border-box;
    width: var(--sp-tap); height: var(--sp-tap); margin: 0 -10px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.ar-check::before { content: ""; position: absolute; inset: 12px; border: 2px solid #9ca3af; border-radius: 4px; background: #fff; }
.ar-check:checked::before { border-color: #1a2744; background: #1a2744 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/></svg>") center / 14px 14px no-repeat; }
.ar-check:focus-visible::before { outline: 2px solid #1a2744; outline-offset: 2px; }
.ar-page .animal-photo-upload input[type="file"], .ar-page .animal-photo-caption-input { min-height: var(--sp-tap); }
.ar-page .animal-photo-upload input[type="file"] { display: inline-flex; align-items: center; max-width: 100%; }
.ar-page .animal-photo-action { min-height: var(--sp-tap); min-width: var(--sp-tap); padding: 0 6px; }
.ar-page .animal-photo-primary-check { min-height: var(--sp-tap); }

@media (max-width: 767.98px) {
    .search-clear-x { width: var(--sp-tap) !important; height: var(--sp-tap) !important; right: 0 !important;
        padding: 11px !important; background-clip: content-box !important; box-sizing: border-box; }
    .ar-page { display: flex; flex-direction: column; }
    .ar-cols, .ar-col { display: contents; }
    .ar-o-hero { order: 1; }
    .ar-o-tiles { order: 2; }
    .ar-o-ebvs { order: 3; }
    .ar-o-weights { order: 4; }
    .ar-o-gen { order: 5; }
    .ar-o-ped { order: 6; }
    .ar-o-info { order: 7; }
    .ar-o-off { order: 8; }
    .ar-o-hist { order: 9; }
    .ar-o-photos { order: 10; }
    .ar-o-delete { order: 11; }
    .ar-hero { grid-template-columns: 72px minmax(0, 1fr); gap: 18px; padding: 16px 18px; align-items: start; }
    .ar-photo { width: 72px; height: 72px; font-size: 0.62rem; gap: 2px; }
    .ar-hero-tag { font-size: 1.375rem; }
    .ar-hero-name { display: block; margin: 0; font-size: 0.85rem; }
    .ar-hero-sub { font-size: 0.875rem; }
    .ar-hero-summary { font-size: 0.875rem; gap: 4px 12px; }
    .ar-o-ebvs .ar-head { flex-wrap: wrap; height: auto; }
    .ebv-trait-panel:not([hidden]) {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        margin: 0;
        max-height: 85vh;
        z-index: 1080;
        border-radius: 16px 16px 0 0;
        padding: 8px 16px calc(12px + var(--sp-safe-bottom));
        width: auto;
    }
    .ebv-trait-backdrop {
        position: fixed;
        inset: 0;
        border: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1070;
    }
    .ebv-trait-move {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        border: 1px solid #d1d5db;
        background: #fff;
        border-radius: 6px;
        font-weight: 700;
    }
    .ar-facts { display: none; }

    .ar-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .ar-hist li { grid-template-columns: 18px 84px minmax(0, 1fr); font-size: 0.85rem; }
    .ar-rec-menu { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 1060; min-width: 0; max-height: 85vh;
        overflow-y: auto; border-radius: 16px 16px 0 0; padding: 0 0 calc(8px + var(--sp-safe-bottom)); }
    .ar-rec:has(> .ar-rec-menu:not([hidden]))::before { content: ""; position: fixed; inset: 0; z-index: 1059;
        background: rgba(15, 23, 42, .4); }
    .ar-rec-menu a, .ar-rec-menu button { padding: 10px 20px; font-size: 1rem; }
    .ar-sum { gap: 8px; padding: 8px 16px 2px; }
    .ar-sum .ar-val { font-size: 0.9rem; }
    .ar-tree { grid-template-columns: minmax(0, 1fr); }
    .kv-list .kv-rows { grid-template-columns: minmax(0, 1fr); }
    .ar-page .ar-off-table tbody > tr.ar-off-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px;
        align-items: start; padding: 8px 16px 10px; border-bottom: 1px solid #f1eee6; }
    .ar-page .ar-off-table tbody > tr.ar-off-row td { display: block; width: auto !important; min-width: 0; padding: 0; text-align: left;
        font-size: 0.82rem; overflow-wrap: anywhere; }
    .ar-page .ar-off-table tbody > tr.ar-off-row td.list-card-title { grid-column: 1 / span 2; font-size: 1rem; }
    .ar-page .ar-off-table tbody > tr.ar-off-row td.list-card-title::before,
    .ar-page .ar-off-table tbody > tr.ar-off-row td[data-label="Status"]::before { content: none; }
    .ar-page .ar-off-table tbody > tr.ar-off-row td[data-label="Status"] { grid-column: 3; grid-row: 1; align-self: center; justify-self: end; }
    .ar-page .ar-off-table tbody > tr.ar-off-row td.sp-cell-empty { display: none; }

    .ar-table .ar-xcol { display: none; }
    .ar-table th, .ar-table td { padding: 7px 8px; font-size: 0.8rem; }
    .ar-table th { font-size: 0.6rem; }
    .ar-table th:first-child, .ar-table td:first-child { padding-left: 14px; }

    .ar-o-ebvs .ar-ebv-window,
    .ar-off-window { --sp-window-row: 4.75rem; }
    .ar-o-ebvs .ar-ebv-window {
        overflow-x: hidden;
        mask-image: none;
        max-height: calc(6 * var(--sp-window-row));
    }
    .ar-off-window { max-height: calc(10 * var(--sp-window-row)); }
    .ebv-row-grip:hover::after { content: none; }
    .ar-ebv-flat.list-card-table,
    .ar-ebv-flat.list-card-table tbody {
        display: block;
        width: 100%;
    }
    .ar-ebv-flat.list-card-table tbody > tr:not([hidden]) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        column-gap: 8px;
        row-gap: 2px;
        align-items: center;
        width: 100%;
        min-height: var(--sp-tap);
        padding: 10px 12px;
        text-align: left;
    }
    .ar-ebv-flat.list-card-table tbody > tr:not([hidden]) > td {
        display: block;
        width: auto !important;
        max-width: 100%;
        min-height: 0;
        padding: 0 !important;
        text-align: left;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ar-ebv-flat.list-card-table tbody > tr > td[data-label]::before {
        content: none;
        display: none;
    }
    .ar-ebv-flat.list-card-table tbody > tr:not([hidden]) > td.ar-ebv-trait {
        display: flex;
        align-items: flex-start;
        gap: 2px;
        grid-column: 1;
        grid-row: 1 / span 2;
        min-width: 0;
        font-weight: 800;
        font-size: 0.95rem;
        line-height: 1.3;
        color: #1a2744;
        overflow: hidden;
        white-space: nowrap;
    }
    .ar-ebv-flat.list-card-table td.ar-ebv-val {
        grid-column: 2 / span 2;
        grid-row: 1;
        justify-self: end;
        text-align: right;
        font-weight: 800;
        font-size: 0.95rem;
        line-height: 1.3;
    }
    .ar-ebv-flat.list-card-table tbody > tr:not([hidden]) > td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
        text-align: right;
        color: #6b7280;
        font-size: 0.75rem;
        font-weight: 500;
        line-height: 1.3;
    }
    .ar-ebv-flat.list-card-table tbody > tr:not([hidden]) > td:nth-child(4) {
        grid-column: 3;
        grid-row: 2;
        justify-self: end;
        text-align: right;
        font-size: 0.75rem;
        line-height: 1.3;
        white-space: normal !important;
        overflow: visible;
    }
    #ebv-history-panel .list-card-table tbody > tr.animal-row,
    #ebv-chosen-extras .list-card-table tbody > tr.animal-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 12px;
        align-items: center;
        width: 100%;
        padding: 8px 12px;
    }
    #ebv-history-panel .list-card-table tbody > tr.animal-row > td,
    #ebv-chosen-extras .list-card-table tbody > tr.animal-row > td {
        display: block;
        width: auto !important;
        min-height: 0;
        padding: 0;
        text-align: left;
    }
    #ebv-history-panel .list-card-table tbody > tr.animal-row > td:last-child,
    #ebv-chosen-extras .list-card-table tbody > tr.animal-row > td:last-child {
        text-align: right;
        font-weight: 700;
    }
    #ebv-history-panel .list-card-table td[data-label]::before,
    #ebv-chosen-extras .list-card-table td[data-label]::before {
        content: none;
        display: none;
    }
}

/* ── Death Record ───────────────────────────────────────────────────────── */
.dr-page { padding-bottom: 1.5rem; }
.dr-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px; margin-top: 8px; }
.dr-hero-main { min-width: 0; }
.dr-tag { margin: 0; font-size: 1.75rem; font-weight: 800; color: #1a2744; line-height: 1.1; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.dr-name { margin-left: 10px; font-size: 1rem; font-weight: 600; color: #6b7280; letter-spacing: 0; }
.dr-sub { margin: 4px 0 0; color: #6b7280; }
.dr-hero-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.dr-died { font-size: 1.125rem; font-weight: 800; color: #1a2744; }
.dr-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--sp-tap); color: #2563eb; font-weight: 650;
    font-size: 0.875rem; text-decoration: none; }
.dr-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0 0; }
.dr-page .ar-tile { border-radius: 12px; }
.dr-card .kv-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 28px; padding-bottom: 6px; }
.dr-card .kv-list .kv-rows { grid-template-columns: minmax(0, 1fr); }
.dr-card .kv-row:last-child { border-bottom: 0; }
.dr-card .kv-key { flex: none; overflow-wrap: normal; }
.dr-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 767.98px) {
    .dr-hero { flex-direction: column; gap: 8px; padding: 14px 16px; }
    .dr-tag { font-size: 1.375rem; }
    .dr-name { display: block; margin: 2px 0 0; font-size: 0.85rem; }
    .dr-sub { font-size: 0.875rem; }
    .dr-hero-side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 10px; text-align: left; }
    .dr-died { font-size: 1rem; }
    .dr-tiles { gap: 8px; }
    .dr-tiles .ar-tile { padding: 8px 10px; }
    .dr-tiles .ar-tile-val { font-size: 0.95rem; white-space: normal; overflow-wrap: anywhere; }
    .dr-card .kv-list { grid-template-columns: minmax(0, 1fr); }
}

/* ── Birth Record ───────────────────────────────────────────────────────── */
.br-page { padding-bottom: 1.5rem; }
.br-hero .sp-hero-tag { letter-spacing: -0.03em; overflow-wrap: anywhere; }
.br-hero .sp-hero-sub { margin-bottom: 0; }
.br-record-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--sp-tap); color: #2563eb; font-weight: 650;
    font-size: 0.875rem; text-decoration: none; }
.br-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 14px 0 0; }
.br-page .ar-tile { border-radius: 12px; }
.br-card .kv-list { padding-bottom: 6px; }
.br-card .kv-row:last-child { border-bottom: 0; }
.br-missing { color: #9ca3af; }
.br-empty { margin: 0; padding: 12px 0; color: #6b7280; }
.br-delete { display: flex; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 767.98px) {
    .br-hero .sp-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
    .br-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .br-tiles .ar-tile { padding: 8px 10px; }
    .br-tiles .ar-tile-val { font-size: 0.95rem; white-space: normal; overflow-wrap: anywhere; }
}

/* ── Genomics Record ─────────────────────────────────────────────────────── */
.geno-page .sp-record-card { margin-top: 0; }
.geno-page .ar-card { margin-bottom: 14px; }
.geno-page .page-header a.btn-outline { text-decoration: none; }
.geno-hero { grid-template-columns: minmax(0, 1fr) auto; }
.geno-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.geno-tile-green .ar-tile-val { color: #065f46; }
.geno-tile-amber .ar-tile-val { color: #92400e; }
.geno-tile-red .ar-tile-val { color: #991b1b; }

@media (max-width: 767.98px) {
    .geno-hero { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .geno-hero .ar-facts { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; text-align: left; gap: 0 12px; }
    .geno-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

/* ── NSIP Record ─────────────────────────────────────────────────────────── */
.nsip-rec .ar-hero { grid-template-columns: minmax(0, 1fr) auto; }
.nsip-rec .ar-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nsip-rec .ar-delete { padding: 0; }

@media (max-width: 767.98px) {
    .nsip-rec .ar-hero { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .nsip-rec .ar-facts { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; text-align: left; gap: 0 12px; }
    .nsip-rec .ar-tiles { gap: 8px; }
    .nsip-rec .ar-tile { padding: 8px 10px; }
}

.unknown-parent-btn {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 8px 12px;
    font-weight: 600;
}

@media (max-width: 767.98px) {
    .unknown-parent-btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
}

.sp-tap-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    line-height: 0;
    flex-shrink: 0;
    cursor: pointer;
}

@media (max-width: 767.98px) {
    .sp-tap-check {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    .sp-tap-check input[type="checkbox"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        margin: 0;
        flex-shrink: 0;
    }
}

/* Empty list rows are not title/chip/subtitle cells, so the phone card
   rule hides them. Keep the "nothing here yet" sentence visible. */
@media (max-width: 767.98px) {
    .sp-list-body table.list-card tbody > tr.sp-list-empty-row,
    .sp-list-body table.list-card-table tbody > tr.sp-list-empty-row {
        display: block !important;
        min-height: 0 !important;
        padding: 8px 12px 16px !important;
    }

    .sp-list-body table.list-card tbody > tr.sp-list-empty-row > td.list-card-title.sp-list-empty,
    .sp-list-body table.list-card-table tbody > tr.sp-list-empty-row > td.list-card-title.sp-list-empty {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        padding: 16px 12px !important;
        overflow: visible !important;
        white-space: normal !important;
        text-overflow: unset !important;
        text-align: center !important;
    }
}

/* NSIP Records filter row: search stays beside the Filter button on a phone. */
@media (max-width: 767.98px) {
    #nsip-filter-bar {
        padding: 8px 12px !important;
        margin-bottom: 8px;
    }

    .nsip-filter-row {
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    #search-nsip,
    #nsip-filter-sheet-btn {
        min-height: var(--sp-tap);
        height: var(--sp-tap);
    }
}

/* Group scanner-alert checkboxes: a real 44px tap on a phone. */
@media (max-width: 767.98px) {
    #lambingAlertActive,
    #mgmtAlertActive {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }
}

/* Pedigree: animal on the left, sire above, dam below. Phone keeps the sideways shape. */
.nsip-rec .ar-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ebv-cards { position: relative; }
.ebv-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.ebv-bar-title { font-size: 0.75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #6b7280; }
.ebv-cols-wrap { position: relative; }
.ebv-cols-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-height: var(--sp-tap);
    min-width: var(--sp-tap);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #374151;
}
.ebv-cols-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
    padding: 8px 12px;
    z-index: 30;
    min-width: 13.5rem;
    max-height: 20rem;
    overflow-y: auto;
}
.ebv-cols-panel[hidden] { display: none !important; }
.ebv-cols-label { font-size: 0.75rem; font-weight: 600; color: #6b7280; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.ebv-check { display: flex; align-items: center; gap: 8px; min-height: 2rem; margin: 0; font-size: 0.82rem; color: #374151; cursor: pointer; }
.ped-open { min-height: var(--sp-tap); }
.ped-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 8.875rem;
    min-height: var(--sp-tap);
    min-width: var(--sp-tap);
    margin: 0;
    padding: 4px 8px;
    border: 1px solid #e7e2d6;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-align: left;
    line-height: 1.25;
    text-decoration: none;
    box-sizing: border-box;
}
.ped-node { display: flex; align-items: center; gap: 2px; }
.ped-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: var(--sp-tap);
    height: var(--sp-tap);
    min-width: var(--sp-tap);
    min-height: var(--sp-tap);
    margin: 0;
    padding: 0;
    border: 1px solid #d9d3c5;
    border-radius: 8px;
    background: #fff;
    color: #1a2744;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}
.ped-split[hidden] { display: none; }
.ped-box b { color: #2563eb; font-weight: 700; font-size: 0.9rem; }
.ped-box small { color: #6b7280; font-size: 0.68rem; overflow-wrap: anywhere; }
.ped-role { font-size: 0.65rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #6b7280; }
.ped-me { border-color: #c7d2fe; background: #eef2ff; }
.ped-me b { color: #1a2744; }
.ped-unknown { border-style: dashed; background: #fafaf7; }
.ped-unknown b { color: #9ca3af; font-weight: 650; }
.ped-outside { background: #fff; }
.ped-flag { color: #92400e; font-weight: 700; }
.ped-tree { display: flex; align-items: center; width: max-content; padding: 4px 0 8px; }
.ped-branch { display: flex; align-items: center; }
.ped-split { display: flex; flex-direction: column; justify-content: center; position: relative; margin-left: 1.125rem; }
.ped-split::before {
    content: "";
    position: absolute;
    right: 100%;
    width: 1.125rem;
    top: 50%;
    border-top: 2px solid #c4bfb2;
}
.ped-arm { position: relative; padding: 3px 0 3px 1rem; }
.ped-arm::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 1rem;
    border-top: 2px solid #c4bfb2;
}
.ped-arm::after {
    content: "";
    position: absolute;
    left: 0;
    border-left: 2px solid #c4bfb2;
}
.ped-arm:first-child::after { top: 50%; bottom: 0; }
.ped-arm:last-child::after { top: 0; bottom: 50%; }
.ped-arm:only-child::after { display: none; }
.ped-scroll { overflow-x: auto; max-width: 100%; min-width: 0; padding: 0 16px 8px; }
.ped-legend { margin: 0; padding: 0 16px 12px; font-size: 0.75rem; color: #6b7280; }
.ped-dedicated { padding: 8px 4px 24px; min-width: 0; }
.ped-toolbar { margin-bottom: 12px; }
.ped-toolbar .page-header { margin-bottom: 0; }
.ped-toolbar .ped-header-actions { gap: 0.5rem; }
#record-card-sheet .ebv-check { min-height: var(--sp-tap); }

@media (max-width: 767.98px) {
    .ped-toolbar .page-header {
        padding-right: 48px;
    }

    .ped-toolbar .ped-header-actions {
        flex-wrap: nowrap;
        gap: 4px;
    }

    .ped-toolbar .ped-back {
        width: var(--sp-tap);
        min-width: var(--sp-tap);
        padding: 0;
        font-size: 0;
    }

    .ped-toolbar .ped-back i {
        font-size: 16px;
        margin: 0 !important;
    }

    .ped-box { width: 8.25rem; }
    .nsip-rec .ar-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ebv-bar { flex-wrap: wrap; }
    #record-card-sheet.offcanvas-bottom {
        height: auto;
        max-height: 85vh;
    }
    #record-card-sheet .offcanvas-body {
        overflow-y: auto;
        max-height: 70vh;
    }
    #record-card-sheet .ebv-check { min-height: var(--sp-tap); }
    .animal-picker .ap-hit {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    .animal-picker .ap-results .list-card-table tbody > tr.ap-result-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding: 6px 8px;
        cursor: pointer;
    }
    .animal-picker .ap-results .list-card-table tbody > tr.ap-result-row > td {
        display: block;
        width: auto !important;
        text-align: left;
        padding: 0;
    }
    .animal-picker .ap-results .list-card-table tbody > tr.ap-result-row > td[data-label]::before {
        content: none;
        display: none;
    }
    .animal-picker .ap-results .ap-col-extra {
        display: none !important;
    }
    .animal-picker .ap-results .ap-check {
        flex: 0 0 var(--sp-tap);
        width: var(--sp-tap) !important;
    }
    .animal-picker .ap-results .list-card-table tbody > tr.ap-result-row > td.list-card-title {
        flex: 1 1 auto;
        min-width: 0;
    }
    .animal-picker .ap-results .ap-row-cb,
    .animal-picker .ap-include {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        margin: 0;
    }
    .animal-picker .ap-include-label {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-height: var(--sp-tap);
    }
    .mgmt-remove-btn {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }
    .animal-picker[data-sticky="0"] .sticky-actions {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: auto;
        padding: 0;
        background: transparent;
        border-top: 0;
        box-shadow: none;
    }
    .animal-picker .list-card-table tbody > tr > td {
        text-align: left;
    }
}

.animal-picker[data-multiple="0"] .ap-single-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    text-align: left;
    cursor: pointer;
}
.animal-picker[data-multiple="0"] .ap-single-list {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-height: 16rem;
    overflow: auto;
}
.animal-picker[data-multiple="0"] .ap-include-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.animal-picker[data-multiple="0"] .ap-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.animal-picker[data-multiple="0"] .ap-filters[hidden] {
    display: none;
}

@media print {
    .sidebar, .sp-topbar, .sp-drawer-backdrop, .ped-back, .ped-print, .ped-expand, .ebv-cards, .proto-switch {
        display: none !important;
    }
    .main-content { margin-left: 0 !important; padding-top: 0 !important; }
    .ped-dedicated { display: block !important; }
}

.weight-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

@media (max-width: 767.98px) {
    .animal-picker[data-multiple="0"] .ap-single-row {
        min-height: var(--sp-tap);
    }
    .weight-row-actions .weight-row-action {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    .sp-list-body table.list-card tbody > tr > td.wc-actions:not(.list-card-title):not(.list-card-chip):not(.list-card-sub),
    .sp-list-body table.list-card-table tbody > tr > td.wc-actions:not(.list-card-title):not(.list-card-chip):not(.list-card-sub) {
        display: flex !important;
        order: 4;
        flex: 1 1 100%;
        width: 100% !important;
        justify-content: flex-start;
        align-items: center;
        gap: 4px;
        padding: 8px 0 0 !important;
        overflow: visible !important;
        white-space: normal !important;
    }
}

/* sp-table-tools: column filter menus and the Ave. row */
.sp-col-toggle {
    min-height: var(--sp-tap);
    background: transparent;
    color: inherit;
    border: 0;
    font: inherit;
    font-weight: 600;
    text-align: left;
    padding: 0.25rem 0.4rem;
}
.sp-col-menu {
    display: none;
    position: absolute;
    z-index: 1060;
    min-width: 12rem;
    max-height: 18rem;
    overflow: auto;
    background: #fff;
    color: #212529;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
}
.sp-col-menu.is-open { display: block; }
table[data-sp-table-tools] thead th { position: sticky; }
.sp-col-action,
.sp-col-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: var(--sp-tap);
    background: transparent;
    border: 0;
    text-align: left;
    color: #212529;
    padding: 0.25rem 0.5rem;
}
.sp-col-text {
    width: 100%;
    min-height: var(--sp-tap);
    margin: 0.25rem 0;
    padding: 0.25rem 0.5rem;
}
.sp-avg-row td {
    font-weight: 700;
    background: #f8f9fa;
}
input.sp-lamb-pick,
input.sp-lamb-select-all {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0 0.35rem 0 0;
    accent-color: #282f3c;
    vertical-align: middle;
}
.table th input.sp-lamb-select-all {
    accent-color: #fff;
}
.sp-col-backdrop {
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1070;
}

@media (max-width: 767.98px) {
    .sp-col-menu.bottom-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 1080;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        padding-bottom: var(--sp-safe-bottom);
    }
    .sp-col-menu.bottom-sheet .sheet-row,
    .sp-col-toggle {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }

    /* Sticky corner was painted #fff over .table th's dark header, so the
       white label disappeared. Body cells stay white so they cover the scroll. */
    .content-area:has(.report-header-actions) .scroll-x .table:not(.list-card-table) thead th:first-child,
    .scroll-x-sticky-first .table:not(.list-card-table) thead th:first-child {
        background: #282f3c;
        background-color: #282f3c;
        color: #fff;
        z-index: 12;
    }

    /* Card chip/title rules must not pull these cells out of the table. */
    .scroll-x table:not(.list-card-table) > tbody > tr > td.list-card-title,
    .scroll-x table:not(.list-card-table) > tbody > tr > td.list-card-chip,
    .scroll-x table:not(.list-card-table) > tbody > tr > td.list-card-sub {
        display: table-cell;
        margin: 0;
        border-radius: 0;
        padding: 14px 16px;
        font-size: 0.9rem;
        font-weight: 400;
        color: inherit;
    }

    input.sp-lamb-pick,
    input.sp-lamb-select-all {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }

    .list-card-table tbody > tr.sp-avg-row:not(.animal-row):not(.row-clickable) {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 12px;
        padding: 8px 12px;
    }
    .list-card-table tbody > tr.sp-avg-row:not(.animal-row) > td {
        display: none;
        width: auto !important;
        padding: 0;
        text-align: left;
    }
    .list-card-table tbody > tr.sp-avg-row:not(.animal-row) > td:first-child,
    .list-card-table tbody > tr.sp-avg-row:not(.animal-row) > td:not(.sp-avg-empty) {
        display: inline-block;
    }
    .list-card-table tbody > tr.sp-avg-row > td:first-child {
        flex: 1 1 100%;
    }
    .list-card-table tbody > tr.sp-avg-row > td:first-child::before {
        content: none;
    }
    .list-card-table tbody > tr.sp-avg-row > td:not(:first-child)::before {
        display: inline;
        margin: 0 4px 0 0;
    }

    .pw-ewe-table.list-card-table tbody > tr.animal-row {
        gap: 4px 12px;
        align-items: baseline;
        padding: 8px 12px;
    }
    .pw-ewe-table.list-card-table tbody > tr.animal-row > td {
        display: inline-block;
        flex: 0 0 auto;
        width: auto !important;
        padding: 0;
        text-align: left;
    }
    .pw-ewe-table.list-card-table tbody > tr.animal-row > td.list-card-title {
        flex: 1 1 100%;
        font-weight: 700;
        font-size: 16px;
    }
    .pw-ewe-table.list-card-table tbody > tr.animal-row > td.list-card-title::before {
        content: none;
    }
    .pw-ewe-table.list-card-table tbody > tr.animal-row > td:not(.list-card-title)::before {
        display: inline;
        margin: 0 4px 0 0;
    }
    .pw-ewe-table.list-card-table tbody > tr.animal-row > td:empty {
        display: none;
    }

    .ns-scan-table.report-list-cards.list-card-table tbody > tr {
        max-height: none;
        height: auto;
        align-items: flex-start;
    }
    .ns-scan-table td.list-card-title,
    .ns-scan-table td.list-card-sub {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }
    .ns-scan-table td.list-card-chip {
        white-space: normal;
        width: auto !important;
        max-width: 100%;
        flex: 0 0 auto;
    }
    .ns-scan-table td.list-card-chip:empty {
        display: none !important;
    }
    .ns-scan-table tbody > tr.sp-avg-row > td:not(:first-child):not(.sp-avg-empty)::before {
        content: attr(data-label) !important;
        display: inline;
        margin: 0 4px 0 0;
    }

    #draft-store-weight {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        margin: 0;
        flex-shrink: 0;
    }

    .content-area:has(.animal-form-heading) .animal-form-actions-bottom {
        display: none !important;
    }
    .content-area:has(.animal-form-heading) [data-animal-pane="notes"] .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .ns-scan-table.list-card-table tbody > tr {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center;
        text-align: left;
    }
    .ns-scan-table.list-card-table tbody > tr > td.list-card-chip {
        display: inline-flex !important;
        width: auto !important;
        max-width: max-content !important;
        flex: 0 0 auto !important;
    }
    .ns-scan-table.list-card-table tbody > tr > td.list-card-title {
        flex: 1 1 100% !important;
        width: 100% !important;
    }
    .ns-scan-table.list-card-table tbody > tr > td.list-card-sub {
        text-align: left !important;
    }
}

@media (max-width: 767.98px) {
    #lamb-filter-sheet.offcanvas-bottom {
        height: auto;
        max-height: 85vh;
    }
    #lamb-filter-sheet .lamb-group-dropdown {
        width: 100%;
    }
    #lamb-selection #lamb-filter-sheet .lamb-group-toggle {
        width: 100%;
        min-width: 0;
        max-width: none;
        min-height: var(--sp-tap);
    }
    #lamb-selection #lamb-filter-sheet .lamb-group-menu {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        float: none;
        width: 100%;
        min-width: 0;
        max-height: 45vh;
        overflow-y: auto;
    }
    #lamb-filter-sheet .form-select,
    #lamb-filter-sheet .form-control,
    #lamb-filter-sheet .lamb-group-option {
        min-height: var(--sp-tap);
    }
    #lamb-filter-sheet .lamb-group-option .form-check-input {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        margin: 0;
    }
    #lamb-filter-sheet .offcanvas-body {
        overflow-y: auto;
        max-height: 70vh;
    }
}

/* Adjusted Weaning Weights: one page scroll, shared sideways bar.
   overflow-x: clip does not make a scroll container, so group headers
   can stick to .main-content. A hidden overflow-x would not. */
#adj-ww-container .card {
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
#adj-ww-container .card-header {
    background: transparent;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
}
#adj-ww-container .card-header h5 {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
    margin: 0;
}
#adj-ww-container .adj-ww-groups.analytics-panel {
    padding: 0;
    overflow: clip;
    margin-bottom: 16px;
}
#adj-ww-container .adj-ww-group-title {
    background: #fff;
    border-bottom: 0;
}
#adj-ww-container .adj-ww-group-title h6 {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
}
#adj-ww-toolbar .nav-tabs { border-bottom: 0; }
#adj-ww-toolbar .adj-ww-toolbar-row {
    border-bottom: 1px solid var(--bs-nav-tabs-border-color, #dee2e6);
}
#adj-ww-toolbar .lg-select-toggle::after { display: none; }
#adj-ww-toolbar .lg-dropdown-menu {
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
}
#adj-ww-toolbar .lg-dropdown-menu .dropdown-item { cursor: pointer; }
#adj-ww-toolbar .lg-dropdown-menu .dropdown-item:active {
    color: inherit;
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

@media (min-width: 768px) {
    .main-content:has(#adj-ww-container),
    .main-content:has(#lamb-selection[data-sp-hscroll]) {
        min-width: 0;
        overflow-x: clip;
    }
    .content-area:has(#adj-ww-container),
    .content-area:has(#lamb-selection[data-sp-hscroll]) {
        min-width: 0;
        max-width: 100%;
    }
    #adj-ww-container .page-header {
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 12px;
    }
    #adj-ww-container .heading-area {
        min-width: 0;
        flex: 1 1 auto;
    }
    #adj-ww-container .adj-ww-actions {
        display: flex;
        gap: 8px;
        flex-wrap: nowrap;
        flex: 0 0 auto;
        align-items: center;
        justify-content: flex-end;
    }
    #adj-ww-container .adj-ww-page-sticky {
        border-bottom: 1px solid #e5e7eb;
    }
    #adj-ww-container .adj-ww-group-title {
        position: sticky;
        top: var(--sp-sticky-page-h, 0px);
        z-index: 20;
        background: #fff;
    }
    #adj-ww-container .adj-ww-table,
    #lamb-selection .adj-ww-table {
        width: max-content;
        min-width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }
    #adj-ww-container .adj-ww-table thead th,
    #lamb-selection .adj-ww-table thead th {
        position: sticky;
        top: calc(var(--sp-sticky-page-h, 0px) + var(--sp-sticky-group-h, 0px));
        z-index: 4;
        background-color: #212529;
        color: #fff;
        background-clip: padding-box;
        box-shadow: 0 1px 0 #212529;
    }
    #adj-ww-container .adj-ww-hclip,
    #lamb-selection .adj-ww-hclip {
        position: relative;
        overflow-x: auto;
        overflow-y: visible;
        max-width: 100%;
        min-width: 0;
        contain: inline-size;
    }
    #adj-ww-container[data-sp-hscroll-live="1"] .adj-ww-hclip,
    #lamb-selection[data-sp-hscroll-live="1"] .adj-ww-hclip {
        overflow-x: clip;
        scrollbar-width: none;
    }
    #adj-ww-container[data-sp-hscroll-live="1"] .adj-ww-hclip::-webkit-scrollbar,
    #lamb-selection[data-sp-hscroll-live="1"] .adj-ww-hclip::-webkit-scrollbar {
        display: none;
        height: 0;
    }
    #adj-ww-container .adj-ww-pin,
    #lamb-selection .adj-ww-pin {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 6;
        background: #fff;
        pointer-events: auto;
    }
    #adj-ww-container .adj-ww-pin[hidden],
    #lamb-selection .adj-ww-pin[hidden] {
        display: none !important;
    }
    #adj-ww-container .adj-ww-pin-table,
    #lamb-selection .adj-ww-pin-table {
        width: 100%;
        margin: 0;
        background: #fff;
        table-layout: fixed;
    }
    #adj-ww-container .adj-ww-pin-table thead th,
    #lamb-selection .adj-ww-pin-table thead th {
        z-index: 8;
        background-color: #212529;
        color: #fff;
        overflow: hidden;
    }
    #adj-ww-container .adj-ww-pin-table tbody td,
    #lamb-selection .adj-ww-pin-table tbody td {
        overflow: hidden;
    }
    #lamb-selection .adj-ww-pin-table tr[data-sp-pin-band] td {
        background: transparent;
        border-color: transparent;
        pointer-events: none;
    }
    #lamb-selection .lamb-band-stick {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: var(--sp-pane-w, 100%);
        box-sizing: border-box;
        padding: 8px 12px 8px var(--sp-pin-w, 0px);
        transform: translateX(var(--sp-hscroll-x, 0px));
        color: #212529;
    }
    #lamb-selection .lamb-band-title {
        min-width: 0;
        font-weight: 700;
    }
    #lamb-selection .sp-band-row > td {
        background: #fff;
        padding: 0;
    }
    #adj-ww-container .adj-ww-dock,
    #lamb-selection .adj-ww-dock {
        z-index: 40;
        background: #FAF9F6;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
        padding: 0 30px;
        box-sizing: border-box;
        max-width: 100%;
    }
    #adj-ww-container .adj-ww-hbar,
    #lamb-selection .adj-ww-hbar {
        position: relative;
        z-index: 3;
        box-sizing: content-box;
        overflow: hidden;
        height: 8px;
        padding: 6px 0;
        margin: 2px 0 8px;
        background: #e5e7eb;
        background-clip: content-box;
        border-radius: 4px;
        touch-action: none;
        user-select: none;
        cursor: pointer;
    }
    #adj-ww-container .adj-ww-hbar[hidden],
    #lamb-selection .adj-ww-hbar[hidden] {
        display: none !important;
    }
    #adj-ww-container .adj-ww-hthumb,
    #lamb-selection .adj-ww-hthumb {
        position: absolute;
        top: 6px;
        height: 8px;
        background: #9ca3af;
        border-radius: 4px;
        cursor: grab;
    }
    #adj-ww-container .adj-ww-hbar:hover .adj-ww-hthumb,
    #adj-ww-container .adj-ww-hbar.is-dragging .adj-ww-hthumb,
    #lamb-selection .adj-ww-hbar:hover .adj-ww-hthumb,
    #lamb-selection .adj-ww-hbar.is-dragging .adj-ww-hthumb {
        background: #6b7280;
    }
    #adj-ww-container .adj-ww-banner {
        position: relative;
        z-index: 1;
        margin: 0;
        pointer-events: auto;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
    }
    #adj-ww-toolbar .lg-select-toggle {
        min-width: 160px;
    }
    #adj-ww-toolbar .adj-ww-filters .form-select-sm,
    #adj-ww-toolbar .adj-ww-filters .lg-select-toggle {
        min-height: 31px;
    }
}

@media (max-width: 767.98px) {
    #adj-ww-container .adj-ww-hclip,
    #lamb-selection .adj-ww-hclip {
        overflow: visible;
        contain: none;
        max-width: 100%;
    }
    #adj-ww-container .adj-ww-pin,
    #lamb-selection .adj-ww-pin {
        display: none !important;
    }
    #adj-ww-container .adj-ww-hbar,
    #lamb-selection .adj-ww-hbar,
    #lamb-selection .adj-ww-dock {
        display: none !important;
    }
    #lamb-selection .lamb-band-stick {
        transform: none;
        width: auto;
        padding-left: 0;
        flex-wrap: wrap;
    }
    #lamb-selection .sp-band-row {
        display: block;
        margin: 8px 0;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
        text-align: left;
    }
    #lamb-selection .sp-band-row > td {
        display: block;
        width: auto !important;
        text-align: left;
        padding: 8px 12px;
    }
    #lamb-selection .sp-band-row > td::before {
        content: none !important;
    }
    #lamb-selection .lamb-add-group .btn,
    #lamb-selection .sp-lamb-select-group {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
    }
    #adj-ww-container .adj-ww-dock {
        position: static !important;
        left: auto !important;
        width: auto !important;
        bottom: auto !important;
        box-shadow: none;
        border: 0;
        padding: 0;
        background: transparent;
    }
    #adj-ww-container .adj-ww-table.list-card-table tbody > tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 12px;
        padding: 8px 12px;
        text-align: left;
    }
    #adj-ww-container .adj-ww-table.list-card-table tbody > tr > td {
        display: inline-block;
        width: auto !important;
        padding: 0;
        text-align: left;
    }
    #adj-ww-container .adj-ww-table.list-card-table tbody > tr > td.list-card-title {
        flex: 1 1 100%;
        font-weight: 700;
        font-size: 16px;
    }
    #adj-ww-container .adj-ww-table.list-card-table td.list-card-title::before {
        content: none;
    }
    #adj-ww-container .adj-ww-table.list-card-table td:not(.list-card-title)::before {
        display: inline;
        margin: 0 4px 0 0;
    }
    #adj-ww-container .adj-ww-banner {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 12px;
        margin-bottom: 0;
    }
}

@media print {
    #adj-ww-container .adj-ww-dock,
    #lamb-selection .adj-ww-dock {
        position: static !important;
        width: auto !important;
        left: auto !important;
        box-shadow: none;
    }
    #adj-ww-container .adj-ww-hbar,
    #adj-ww-container .adj-ww-pin,
    #lamb-selection .adj-ww-hbar,
    #lamb-selection .adj-ww-pin,
    #lamb-selection .adj-ww-dock {
        display: none !important;
    }
    #lamb-selection .adj-ww-table {
        margin-left: 0 !important;
    }
    #lamb-selection .lamb-band-stick {
        transform: none !important;
        width: auto !important;
        padding-left: 0 !important;
    }
    #lamb-selection .adj-ww-table thead th {
        position: static !important;
    }
}

@media (max-width: 767.98px) {
    .animal-record-header .merge-phone-launch {
        order: 4;
        flex: 1 1 100%;
        width: 100%;
    }

    .merge-page {
        padding-bottom: calc(88px + var(--sp-safe-bottom));
    }

    .merge-page .page-header .welcome-title {
        text-align: left;
    }

    .merge-page .page-header .welcome-subtitle {
        display: block;
        text-align: left;
    }

    .merge-page .sheet-row input[type="radio"],
    .merge-page .sheet-row input[type="checkbox"] {
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
        width: var(--sp-tap);
        height: var(--sp-tap);
    }
}

a.sp-row-open-link,
a.sp-row-open-link:visited,
a.sp-row-open-link:hover {
    color: inherit;
    text-decoration: none;
}

@media (max-width: 767.98px) {
    #animals-body-table.list-card-table td.ac-ear_tag a.sp-row-open-link {
        display: flex;
        align-items: center;
        box-sizing: border-box;
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        flex: 1 1 auto;
    }
}

.sp-impersonation-confirm {
    border: 0;
    border-radius: 12px;
    padding: 20px;
    max-width: 420px;
    width: calc(100% - 32px);
}

.sp-impersonation-confirm::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.sp-impersonation-confirm-text {
    margin: 0 0 16px;
    font-size: 16px;
    line-height: 1.4;
    white-space: pre-line;
}

.sp-impersonation-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 767.98px) {
    #impersonation-banner.sp-impersonation-banner {
        flex-wrap: wrap;
        text-align: center;
        row-gap: 8px;
    }

    #impersonation-banner .sp-impersonation-exit {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sp-tap-check input[type="radio"] {
        width: var(--sp-tap) !important;
        height: var(--sp-tap) !important;
        min-width: var(--sp-tap) !important;
        min-height: var(--sp-tap) !important;
        margin: 0;
        flex-shrink: 0;
    }

    .sp-impersonation-confirm .btn {
        min-height: var(--sp-tap);
        min-width: var(--sp-tap);
        flex: 1 1 auto;
    }

    .user-section .user-avatar {
        width: var(--sp-tap);
        height: var(--sp-tap);
        min-width: var(--sp-tap);
        min-height: var(--sp-tap);
    }
}

/* Narrow desktop. Measured on the animal record with the menu open:
   at 1200px the Edit button ends 10px clear of the account button, the same
   gap as 1440px. Under that, Edit's right edge stays at 1047px once search
   hits its minimum, so it crosses the account button and then the window.
   The icon rail is 68px, the same width as .sidebar.collapsed. The head
   script adds html.sp-sidebar-collapsed before first paint. A chevron click
   is stored and wins over this automatic rail. */
@media (min-width: 768px) {
    html.sp-sidebar-collapsed .sidebar {
        width: 68px;
    }
    html.sp-sidebar-collapsed .main-content {
        margin-left: 68px;
    }
    html.sp-sidebar-collapsed .pagination-footer {
        left: 68px;
    }
    html.sp-sidebar-collapsed .logo-text.sp-desktop-only,
    html.sp-sidebar-collapsed .sidebar-item-label,
    html.sp-sidebar-collapsed .sidebar-group-label {
        display: none;
    }
    html.sp-sidebar-collapsed .logo {
        margin-right: 0;
        justify-content: center;
    }
    html.sp-sidebar-collapsed .logo-icon {
        margin-right: 0;
        width: 32px;
        height: 32px;
    }
    html.sp-sidebar-collapsed .logo-section {
        padding: 18px 0;
        justify-content: center;
        flex-direction: column;
        gap: 4px;
    }
    html.sp-sidebar-collapsed .sidebar-item {
        padding: 10px 0;
        margin: 2px 8px;
        justify-content: center;
    }
    html.sp-sidebar-collapsed .sidebar-item svg,
    html.sp-sidebar-collapsed .sidebar-item i {
        margin-right: 0;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .page-header,
    .page-header-actions,
    .page-header > div:last-child,
    .animal-record-header,
    .animal-record-actions {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .page-header .heading-area,
    .animal-record-header .heading-area,
    .animal-jump-search-wrap,
    .animal-record-actions {
        min-width: 0;
        max-width: 100%;
    }
}
