:root {
    --bg: #edf3f9;
    --card: #ffffff;
    --text: #334155;
    --muted: #64748b;
    --line: #d2dfef;
    --primary: #7393b8;
    --primary-hover: #6483a8;
    --link-table: #668ab2;
    --link-table-hover: #567aa2;
    --success: #5f8a73;
    --success-bg: #ebf5ef;
    --warning: #a88958;
    --warning-bg: #f9f1df;
    --danger: #b97876;
    --danger-bg: #faeceb;
    --radius: 8px;
    --font-title: 1.5rem;
    --font-section: 1rem;
    --font-body: 0.875rem;
    --font-small: 0.75rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--font-body);
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

a.table-link {
    color: var(--link-table);
    font-weight: 500;
}

a.table-link:hover {
    color: var(--link-table-hover);
}

a.table-link--strong {
    font-weight: 600;
    color: var(--text);
}

a.table-link--strong:hover {
    color: var(--primary);
}

/* Primary-blue text links (matches default <a>; use where table-link indigo / --strong body color is wrong). */
a.link-primary {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

a.link-primary:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.status-pill--ok {
    background: var(--success-bg);
    border-color: #86efac;
    color: #166534;
}

.status-pill--muted {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #4b5563;
}

.container {
    width: min(1100px, 92vw);
    margin: 0 auto;
}

.topbar {
    background: #84a2c5;
    color: #fff;
    border-bottom: 1px solid #7592b4;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}

.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.brand:hover {
    color: #fff;
    text-decoration: none;
    opacity: 0.92;
}

.nav {
    display: flex;
    gap: 16px;
}

.nav a {
    color: #f3f4f6;
    font-weight: 500;
}

.nav a:hover {
    color: #fff;
    text-decoration: underline;
}

.nav-logout {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.nav-link-button {
    background: none;
    border: none;
    color: #f3f4f6;
    font-weight: 500;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
}

.nav-link-button:hover {
    text-decoration: underline;
}

.nav-current-user {
    color: #eef2f7;
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 2px 8px;
    border: 1px solid rgba(238, 242, 247, 0.4);
    border-radius: 999px;
    white-space: nowrap;
}

.auth-card {
    max-width: 420px;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stack-form label {
    font-weight: 600;
    font-size: 0.9rem;
}

.stack-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 1rem;
}


.main-content {
    padding: 26px 0 32px;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0;
    font-size: var(--font-title);
    font-weight: 700;
    line-height: 1.25;
}

.page-header-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.muted {
    color: var(--muted);
}

.required-mark {
    color: #b97876;
    margin-left: 2px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.cards--stats {
    gap: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.card h2 {
    margin-top: 0;
    font-size: var(--font-section);
}

.metric {
    font-size: 1.8rem;
    margin: 8px 0 0;
    font-weight: 700;
}

/* Dashboard stat cards */
.card--stat {
    padding: 16px 18px;
}

.stat-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card__icon {
    display: flex;
    color: var(--muted);
    flex-shrink: 0;
}

.stat-card__label {
    margin: 0;
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card__metric {
    margin: 8px 0 0;
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}

.stat-card__sub {
    margin: 6px 0 0;
    font-size: var(--font-small);
}

.stat-card__sub--faint {
    color: #9ca3af;
}

.section-title {
    font-size: var(--font-section);
    font-weight: 700;
    margin: 0 0 12px;
}

.card--quick-actions .section-title {
    margin-bottom: 12px;
}

.button {
    display: inline-block;
    padding: 9px 14px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    font-size: var(--font-body);
    border: 1px solid transparent;
    line-height: 1.25;
}

.button:hover {
    text-decoration: none;
    background: var(--primary-hover);
}

.button-light {
    background: #e5eef9;
    color: #456282;
    border-color: #bfd1e9;
    margin-left: 0;
}

.button-export {
    background: #d6e5f6;
    color: #3f5f86;
    border-color: #b9d0ea;
}

.button-export:hover {
    background: #c9dbf1;
    color: #355578;
}

.button-secondary {
    background: #fff;
    color: var(--primary);
    border: 1px solid #93c5fd;
}

.button-secondary:hover {
    background: #eff6ff;
    color: var(--primary-hover);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    font-weight: 500;
}

.button-ghost:hover {
    background: #f9fafb;
    color: var(--text);
}

.button-reset {
    background: transparent;
    color: var(--muted);
    border: none;
    font-weight: 500;
    padding-left: 10px;
    padding-right: 10px;
}

.button-reset:hover {
    color: var(--text);
    text-decoration: underline;
    background: transparent;
}

.table-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.data-table--compact th,
.data-table--compact td {
    padding: 7px 10px;
    font-size: 0.875rem;
}

.data-table th {
    background: #eaf2fb;
    font-weight: 700;
    font-size: 0.8125rem;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.data-table tbody tr:hover td {
    background: #edf4fc;
}

.data-table tbody tr.row-inactive:hover td {
    background: #f3f4f6;
}

.table-wrap--data {
    border-radius: var(--radius);
}

a.col-uid-link {
    font-weight: 600;
}

.th-sort-age {
    white-space: nowrap;
}

.table-sort-link {
    color: var(--link-table);
    font-weight: 600;
}

.table-sort-link:hover {
    color: var(--link-table-hover);
    text-decoration: underline;
}

.table-sort-link__mark {
    font-size: 0.75em;
    opacity: 0.85;
}

.owner-cell {
    font-size: var(--font-body);
    color: var(--text);
    white-space: nowrap;
}

.cell-empty {
    color: #9ca3af;
    font-weight: 400;
}

.col-genotype {
    min-width: 220px;
    max-width: 320px;
    line-height: 1.35;
    vertical-align: top;
    font-size: 0.8125rem;
    color: #374151;
}

.genotype-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    display: block;
    scrollbar-width: thin;
}

.genotype-scroll-wrap {
    position: relative;
}

.genotype-scroll-wrap.is-overflowing::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff);
}

.genotype-scroll-hint {
    display: none;
    position: absolute;
    right: 2px;
    top: -14px;
    font-size: 0.65rem;
    color: #6b7280;
    background: rgba(255, 255, 255, 0.95);
    padding: 0 4px;
    border-radius: 999px;
    pointer-events: none;
}

.genotype-scroll-wrap.is-overflowing .genotype-scroll-hint {
    display: inline-block;
}

.cage-genotype-overview {
    max-width: 320px;
    white-space: pre-line;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #374151;
    vertical-align: top;
}

.col-purpose {
    font-weight: 500;
}

.col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.col-cage-id a {
    font-weight: 600;
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
    font-size: 0.8125rem;
    font-weight: 500;
}

.status-pill--mouse-active {
    background: var(--success-bg);
    border-color: #86efac;
    color: #166534;
}

.status-pill--mouse-dead,
.status-pill--mouse-euthanized,
.status-pill--mouse-culled {
    background: var(--danger-bg);
    border-color: #fecaca;
    color: #991b1b;
}

.status-pill--mouse-transferred,
.status-pill--mouse-archived {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #4b5563;
}

.breeding-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.breeding-badge {
    display: inline-block;
    margin: 2px 6px 2px 0;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
    font-size: 0.76rem;
    font-weight: 600;
}

.breeder-members {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breeder-member-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(260px, 1fr) auto;
    gap: 8px;
    align-items: start;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.breeder-member-meta,
.breeder-member-warning {
    grid-column: 1 / -1;
    margin: 0;
}

.breeder-member-warning {
    margin-top: -2px;
}

.status-pill--cage-active {
    background: var(--success-bg);
    border-color: #86efac;
    color: #166534;
}

.status-pill--cage-archived,
.status-pill--cage-retired,
.status-pill--cage-closed,
.status-pill--cage-sanitizing {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #4b5563;
}

.row-inactive td {
    color: #9ca3af;
    background: #f9fafb;
}

.row-inactive a {
    color: #6b7280;
}

.empty-row {
    color: var(--muted);
    text-align: center;
    padding: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 12px;
    margin: 0;
}

.detail-grid dt {
    color: var(--muted);
    font-weight: 600;
}

.detail-grid dd {
    margin: 0;
}

.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    min-width: 360px;
    flex: 1;
    padding: 9px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    align-items: end;
}

.filter-grid .search-input {
    min-width: 0;
    width: 100%;
}

.filter-grid input,
.filter-grid select {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
    font-size: var(--font-body);
}

.form-layout {
    display: grid;
    gap: 12px;
}

.form-row {
    display: grid;
    gap: 6px;
}

.form-row label {
    font-weight: 600;
    color: #374151;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}

.form-row textarea {
    resize: vertical;
}

.formset-card {
    margin-bottom: 10px;
}

.action-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.action-links--primary {
    gap: 10px;
}

.action-links--secondary {
    margin-top: 10px;
    gap: 8px;
}

.action-links--tertiary {
    margin-top: 8px;
    gap: 8px;
}

.action-links--stack {
    flex-direction: column;
    align-items: stretch;
}

.toolbar-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: min(280px, 100%);
}

.page-header--toolbar {
    align-items: flex-start;
}

.more-actions {
    margin-top: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 12px;
    background: #fafafa;
}

.more-actions--inline {
    margin-top: 0;
    align-self: flex-end;
}

.more-actions__summary {
    cursor: pointer;
    font-size: var(--font-body);
    font-weight: 600;
    color: var(--text);
    list-style: none;
}

.more-actions__summary::-webkit-details-marker {
    display: none;
}

.more-actions__summary::after {
    content: " ▾";
    font-size: 0.65em;
    opacity: 0.75;
}

.card--quick-actions {
    padding-bottom: 18px;
}

.more-actions[open] .more-actions__summary::after {
    content: " ▴";
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.action-inline-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.action-inline-form button {
    margin: 0;
}

.field-error,
.form-errors {
    color: #915b59;
    background: #faeceb;
    border: 1px solid #eac6c4;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.92rem;
}

.print-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cage-print-sheet {
    display: flex;
    justify-content: center;
}

.cage-card {
    width: 86mm;
    min-height: 54mm;
    background: #fff;
    color: #111827;
    border: 1px solid #111827;
    border-radius: 3mm;
    padding: 3mm;
    font-size: 10px;
    line-height: 1.25;
}

.cage-card-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2mm;
}

.cage-card-header h1 {
    margin: 0;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.qr-placeholder {
    width: 14mm;
    height: 14mm;
    border: 1px dashed #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
}

.cage-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5mm 3mm;
    margin-bottom: 2mm;
}

.cage-notes {
    border-top: 1px solid #d1d5db;
    border-bottom: 1px solid #d1d5db;
    padding: 1.5mm 0;
    margin-bottom: 2mm;
}

.cage-mice h2 {
    margin: 0 0 1.5mm;
    font-size: 11px;
}

.cage-mice table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
}

.cage-mice th,
.cage-mice td {
    border-bottom: 1px solid #e5e7eb;
    padding: 1mm 0.8mm;
    text-align: left;
    vertical-align: top;
}

@page {
    size: 86mm 54mm;
    margin: 2mm;
}

@media print {
    .topbar,
    .print-toolbar,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
        margin: 0;
    }

    .container {
        width: auto;
        margin: 0;
    }

    .main-content {
        padding: 0;
    }

    .cage-print-sheet {
        display: block;
    }

    .cage-card {
        margin: 0;
        border-radius: 0;
        border: 1px solid #000;
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

.flash-messages {
    margin-bottom: 14px;
}

.flash-message {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
}

.flash-message.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.dashboard-sections {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.mini-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 4px;
}

.attention-pill {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #e7bbb9;
    background: #faeceb;
    color: #915b59;
    font-size: 0.78rem;
    font-weight: 600;
}

.guide-card h2 {
    margin-bottom: 10px;
}

.guide-subheading {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 18px 0 8px;
    color: #1f2937;
}

.guide-card p {
    line-height: 1.65;
    margin: 8px 0;
}

.guide-list {
    margin: 8px 0 0 18px;
    padding: 0;
    display: grid;
    gap: 6px;
    line-height: 1.6;
}

.guide-table-wrap {
    margin-top: 10px;
}

.guide-table th,
.guide-table td {
    white-space: normal;
    vertical-align: top;
}

.guide-faq {
    margin: 0;
    display: grid;
    gap: 10px;
}

.guide-faq dt {
    font-weight: 700;
}

.guide-faq dd {
    margin: 0;
    color: #374151;
    line-height: 1.6;
}

.family-tree-block {
    position: relative;
}

.family-tree-grid {
    display: grid;
    gap: 12px;
}

.family-tree-grid.two-col {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.family-tree-grid.three-col {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.family-tree-grid.four-col {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.family-mouse-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.family-mouse-card h3 {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

.family-mouse-card p {
    margin: 3px 0;
}

.focal-card {
    border: 2px solid #c7d2fe;
}

/* Litters workflow (wide list + status pills) */
.container-wide {
    width: min(1400px, 96vw);
    margin: 0 auto;
}

.table-wrap-scroll {
    max-width: 100%;
}

.data-table-compact th,
.data-table-compact td {
    padding: 8px 10px;
    font-size: 0.88rem;
}

.cell-ellipsis {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nowrap {
    white-space: nowrap;
}

.workflow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-grid-litter {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.card-subheading {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
    color: #374151;
}

.card-nested {
    margin-bottom: 12px;
    padding: 12px;
}

.small-print {
    font-size: 0.88rem;
}

.status-pill-active {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.status-pill-weaned {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.status-pill-tail_tagged {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.status-pill-ended,
.status-pill-archived {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #4b5563;
}

/* Breeding age tiers (pairing hints) */
.age-tier {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.12rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

.age-tier--elevated {
    background: #f9f1df;
    color: #8e6d3f;
    border: 1px solid #e8d5b1;
}

.age-tier--caution {
    background: #f7ead2;
    color: #916645;
    border: 1px solid #e8c79d;
}

.age-tier--high {
    background: #faeceb;
    color: #915b59;
    border: 1px solid #eac6c4;
}

.breeding-age-hint {
    margin: 0.35rem 0 0;
    font-size: 0.88rem;
    min-height: 1.25em;
}

.breeding-age-hint.is-elevated {
    color: #854d0e;
}

.breeding-age-hint.is-caution {
    color: #9a3412;
}

.breeding-age-hint.is-high {
    color: #991b1b;
    font-weight: 600;
}

.mouse-age-banner {
    border: 1px solid #eac6c4;
    background: #faeceb;
}

.mouse-age-banner__text {
    margin: 0;
    color: #915b59;
    font-size: 0.95rem;
}

/* Mice list: age highlight (left bar + pills) */
.data-table tbody tr.mouse-row-age > td:first-child {
    border-left: 4px solid transparent;
}

.data-table tbody tr.mouse-row-age--6mo > td:first-child {
    border-left-color: #f59e0b;
}

.data-table tbody tr.mouse-row-age--1yr > td:first-child {
    border-left-color: #dc2626;
}

.data-table tbody tr.mouse-row-age--unknown > td:first-child {
    border-left-color: #9ca3af;
}

.mouse-age-cell {
    white-space: nowrap;
}

.mouse-age-pill {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

.mouse-age-pill--6mo {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fdba74;
}

.mouse-age-pill--1yr {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.mouse-age-pill--unknown {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
    font-weight: 600;
}

/* Dashboard alerts */
.dashboard-alert {
    display: flex;
    flex-direction: column;
    min-height: 200px;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.dashboard-alert--hot {
    border-color: #fcd34d;
    background: linear-gradient(180deg, #fffbeb 0%, #ffffff 48%);
}

.dashboard-alert--hot .dashboard-alert__title a {
    color: #92400e;
}

.dashboard-alert--clear {
    border-color: #e8eaee;
    background: #fafbfc;
}

.dashboard-alert--clear .dashboard-alert__title a {
    color: #6b7280;
}

.dashboard-alert__title {
    margin: 0 0 10px;
    font-size: var(--font-section);
    line-height: 1.35;
}

.dashboard-alert__title a:hover {
    color: var(--primary);
}

.dashboard-alert-count {
    font-weight: 600;
    color: var(--muted);
}

.dashboard-alert-count--warn {
    color: var(--warning);
}

.dashboard-alert .mini-list {
    flex: 1;
}

.dashboard-alert-empty {
    list-style: none;
    margin-left: 0;
    padding-left: 0;
    color: #9ca3af;
    font-size: var(--font-small);
}

/* Filter panels (Mice / Cages) */
.card--filters {
    padding: 14px 16px;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-row--primary {
    align-items: center;
}

.filter-row--secondary {
    align-items: center;
    margin-top: 4px;
}

.filter-control {
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
    font-size: var(--font-body);
}

.filter-form .search-input {
    min-width: min(360px, 100%);
    flex: 1 1 220px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.filter-label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--muted);
    margin-right: 6px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: min(200px, 100%);
}

.filter-more {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 12px;
    background: #fafafa;
}

.filter-more .filter-row--secondary {
    margin-top: 4px;
}

.filter-more__summary {
    cursor: pointer;
    font-size: var(--font-body);
    font-weight: 600;
    color: var(--text);
    list-style: none;
}

.filter-more__summary::-webkit-details-marker {
    display: none;
}

.filter-more__summary::after {
    content: " ▾";
    font-size: 0.65em;
    opacity: 0.75;
}

.filter-more[open] .filter-more__summary::after {
    content: " ▴";
}

/* Projects / strain tables subtle zebra */
.data-table--striped tbody tr:nth-child(even) td {
    background: #fafafa;
}

.data-table--striped tbody tr:hover td {
    background: #f3f4f6;
}

.col-num-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Pedigree tree layout */
.pedigree-tree {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 960px;
    margin: 0 auto;
}

.pedigree-tree__parents {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    position: relative;
}

@media (max-width: 720px) {
    .pedigree-tree__parents {
        grid-template-columns: 1fr;
    }
}

.pedigree-tree__node {
    position: relative;
    padding: 16px 18px;
    border: 1px solid var(--line);
}

.pedigree-tree__node-title {
    margin: 0 0 8px;
    font-size: var(--font-section);
}

.pedigree-tree__line {
    margin: 0;
    line-height: 1.45;
}

.pedigree-tree__meta {
    margin: 8px 0 0;
    font-size: 0.8125rem;
}

.pedigree-tree__stem {
    height: 28px;
    margin: 0 auto;
    width: 2px;
    background: linear-gradient(to bottom, var(--line), var(--primary));
    position: relative;
}

.pedigree-tree__stem::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: min(70%, 420px);
    height: 2px;
    background: var(--line);
}

.pedigree-tree__focal {
    padding: 18px 20px;
    border: 2px solid #c7d2fe;
    background: linear-gradient(180deg, #eef2ff 0%, #fff 48%);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}

.pedigree-tree__focal-title {
    margin: 0 0 8px;
    font-size: var(--font-section);
    color: var(--primary);
}

.pedigree-tree__branches {
    margin-top: 20px;
    display: grid;
    gap: 16px;
}

.pedigree-tree__branch {
    padding: 16px 18px;
    border: 1px solid var(--line);
}

.pedigree-tree__branch-title {
    margin: 0 0 12px;
    font-size: var(--font-section);
}

.pedigree-tree__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pedigree-tree__list-item {
    position: relative;
    padding-left: 18px;
    margin-bottom: 10px;
    line-height: 1.45;
}

.pedigree-tree__list-item:last-child {
    margin-bottom: 0;
}

.pedigree-tree__twig {
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 10px;
    height: 2px;
    background: var(--line);
    border-radius: 1px;
}

.pedigree-tree__twig::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 100%;
    width: 2px;
    height: 0.55em;
    background: var(--line);
}

.filter-grid .form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 4px;
}

.filter-row--per-page {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    margin-top: 4px;
}

.filter-row--per-page .list-range-meta {
    margin: 0;
    font-size: var(--font-body);
}

.pagination-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.pagination-nav__status {
    font-size: var(--font-body);
    margin: 0 4px;
}

.pagination-nav__edge {
    font-size: var(--font-body);
}

.section-subtitle {
    margin: 16px 0 8px;
    font-size: var(--font-section);
    font-weight: 600;
    color: var(--text);
}

.card--timeline .table-wrap {
    margin-top: 8px;
}

.audit-msg {
    white-space: normal;
    max-width: min(520px, 100%);
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #374151;
}

.cage-projects-cell {
    white-space: normal;
    max-width: 280px;
    font-size: 0.8125rem;
    line-height: 1.45;
    vertical-align: top;
}

.cage-owners-cell {
    white-space: normal;
    max-width: 220px;
    font-size: 0.8125rem;
    line-height: 1.45;
    vertical-align: top;
}

.cage-projects-cell__row {
    margin-bottom: 4px;
}

.cage-projects-cell__row:last-child {
    margin-bottom: 0;
}

.cage-project-list {
    margin: 0;
    padding-left: 1.2rem;
}

.cage-project-list li {
    margin-bottom: 6px;
}

.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding: 12px 0 18px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.site-footer-beian {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.35rem 0.65rem;
}

.site-footer-beian__sep {
    color: var(--muted);
    user-select: none;
}

.site-footer a {
    color: var(--muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}
