/* Shared styles for AnimalHeroCard + AnimalScorePanel (global, not scoped) */

.animal-hero {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
    padding: 1rem;
}

.animal-portrait {
    display: grid;
    place-items: center;
}

.animal-portrait img,
.animal-avatar {
    width: 128px;
    height: 128px;
    border-radius: var(--ds-radius-xl);
    object-fit: cover;
    border: 1px solid var(--ds-border);
    background: linear-gradient(180deg, #f7fbff 0%, #eef4f8 100%);
    box-shadow: var(--ds-soft-shadow);
}

.animal-portrait img.animal-photo--species-default {
    object-fit: contain;
    background: linear-gradient(135deg, #e8f5ec, #d7ebdd);
    padding: 0.35rem;
}

.animal-avatar.animal-photo--species-default {
    font-size: 3rem;
    font-weight: 400;
    background: linear-gradient(135deg, #e8f5ec, #d7ebdd);
}

.animal-avatar {
    display: grid;
    place-items: center;
    color: var(--ds-primary);
    font-size: 2.5rem;
    font-weight: 900;
}

.animal-hero-content {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.animal-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.animal-title-block {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.animal-title-block h1 {
    margin: 0;
    color: var(--ds-text);
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.1;
}

.animal-subtitle {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    color: var(--ds-muted);
    font-weight: 700;
}

.gender-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.gender-pill.male { color: #1d4ed8; background: #dbeafe; }
.gender-pill.female { color: #be185d; background: #fce7f3; }
.status-pill.success { color: #166534; background: #dcfce7; }
.status-pill.warning { color: #9a6500; background: #fff4da; }
.status-pill.info { color: #0369a1; background: #e0f2fe; }
.status-pill.neutral { color: #475569; background: #e2e8f0; }
.status-pill.danger { color: #b91c1c; background: #fee2e2; }

.animal-actions {
    flex: 0 0 auto;
    max-width: 100%;
}

.animal-actions-toolbar {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    justify-content: flex-end;
}

.animal-actions-toolbar .btn,
.animal-actions-toolbar .fl-btn,
.animal-actions-toolbar .hero-menu summary {
    flex: 0 0 auto;
    width: auto !important;
    min-height: 2.25rem;
    height: 2.25rem;
    padding: 0 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    line-height: 1.1;
    font-size: 0.875rem;
    font-weight: 700;
}

.animal-actions-toolbar .hero-menu {
    flex: 0 0 auto;
    position: relative;
}

.animal-actions-toolbar .hero-menu summary {
    list-style: none;
    cursor: pointer;
}

.animal-actions-toolbar .hero-menu summary::-webkit-details-marker {
    display: none;
}

.animal-meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: 0 0.7rem;
    border-radius: 999px;
    background: #f3f6f9;
    border: 1px solid var(--ds-border);
    color: var(--ds-muted-strong);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.meta-chip.success { background: #ecfdf3; border-color: #bbf7d0; color: #166534; }
.meta-chip.warning { background: #fff7e8; border-color: #fed7aa; color: #b45309; }

.hero-menu { position: relative; }
.hero-menu summary { list-style: none; }
.hero-menu summary::-webkit-details-marker { display: none; }

.hero-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    z-index: 30;
    display: grid;
    min-width: 220px;
    padding: 0.45rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
}

.hero-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ds-text);
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.hero-menu-item:hover { background: #f5f8fb; }
.hero-menu-item.danger { color: var(--ds-danger); }

.animal-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.animal-recap {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem 1rem;
    border-radius: var(--ds-radius-md);
    border: 1px solid transparent;
}

.animal-recap strong { color: var(--ds-text); font-weight: 900; }
.animal-recap span { color: var(--ds-muted-strong); font-weight: 600; }
.animal-recap.info { border-color: #dbeafe; background: #f8fbff; }
.animal-recap.success { border-color: #c8ead6; background: #f0fbf4; }
.animal-recap.warning { border-color: #f1ddb3; background: #fff8ea; }
.animal-recap.danger { border-color: #f2c1c1; background: #fff3f3; }

.summary-card {
    display: grid;
    gap: 0.3rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.summary-card span {
    color: var(--ds-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-card strong {
    color: var(--ds-text);
    font-size: 1.15rem;
    line-height: 1.2;
    font-weight: 900;
    word-break: break-word;
}

.summary-card small { color: var(--ds-muted); font-size: 0.8rem; font-weight: 700; }
.summary-card.summary-card-accent {
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    border-color: #d9e7ff;
}

.summary-card .positive { color: var(--ds-success); }
.summary-card .negative { color: var(--ds-danger); }
.summary-card .neutral { color: var(--ds-muted-strong); }

.do-now-panel,
.analysis-section {
    margin-bottom: 0.75rem;
}

.do-now-panel ::deep .dashboard-section-header,
.do-now-panel ::deep .dashboard-section-header-toggle {
    padding-block: 0.55rem;
}

.do-now-panel ::deep .dashboard-section-title {
    font-size: 1rem;
    line-height: 1.2;
}

.do-now-panel ::deep .dashboard-section-subtitle {
    font-size: 0.78rem;
}

.do-now-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.35rem;
}

.analysis-section {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--ds-soft-shadow);
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-head h3 {
    margin: 0.15rem 0 0;
    color: var(--ds-text);
    font-size: 1.15rem;
    font-weight: 900;
}

.section-head p {
    margin: 0.25rem 0 0;
    color: var(--ds-muted);
}

.analysis-head { align-items: flex-start; }

.analysis-badge {
    display: grid;
    gap: 0.1rem;
    align-items: center;
    justify-items: center;
    min-width: 120px;
    padding: 0.8rem 1rem;
    border-radius: var(--ds-radius-md);
    border: 1px solid transparent;
    background: var(--ds-surface-alt);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.analysis-badge strong { font-size: 2rem; line-height: 1; font-weight: 900; }
.analysis-badge.success { border-color: #c8ead6; background: #f0fbf4; color: #166534; }
.analysis-badge.warning { border-color: #f1ddb3; background: #fff8ea; color: #9a6500; }
.analysis-badge.danger { border-color: #f2c1c1; background: #fff3f3; color: #b91c1c; }
.analysis-badge.info { border-color: #dbeafe; background: #f8fbff; color: #0369a1; }

.analysis-reason-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.analysis-reason-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 700;
}

.analysis-score-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.analysis-missing {
    display: grid;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    border: 1px dashed var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: #fafcff;
}

.analysis-missing-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.analysis-missing-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
}

.priority-action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.eyebrow {
    color: var(--ds-primary);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 1100px) {
    .animal-kpi-grid,
    .analysis-score-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .priority-action-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .animal-hero {
        grid-template-columns: 1fr;
        justify-items: stretch;
        text-align: start;
        padding: 0.85rem;
        gap: 0.85rem;
    }

    .animal-portrait {
        justify-self: center;
    }

    .animal-portrait img,
    .animal-avatar {
        width: 96px;
        height: 96px;
    }

    .animal-hero-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .animal-title-block h1 {
        font-size: 1.45rem;
        line-height: 1.15;
        word-break: break-word;
    }

    .animal-hero-head,
    .animal-subtitle,
    .animal-meta-chips {
        justify-content: flex-start;
    }

    .animal-actions-toolbar {
        justify-content: flex-start;
        width: 100%;
    }

    .animal-kpi-grid,
    .analysis-score-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .meta-chip {
        white-space: normal;
        text-align: start;
    }

    .section-head,
    .analysis-head {
        flex-direction: column;
        align-items: stretch;
    }

    .analysis-badge {
        width: 100%;
        min-width: 0;
    }

    .analysis-section,
    .do-now-panel {
        padding: 0.85rem;
    }
}

/* ------------------------------------------------------------------ */
/* Animal details — tabs & panels (child tab components, global CSS)   */
/* ------------------------------------------------------------------ */

.animal-details-page .animal-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.85rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
}

.animal-details-page .animal-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    padding: 0.7rem 0.95rem;
    color: var(--ds-muted-strong);
    background: var(--ds-surface);
    font-weight: 700;
    cursor: pointer;
}

.animal-details-page .animal-tab:hover {
    border-color: var(--ds-primary);
    background: #eef5ff;
}

.animal-details-page .animal-tab.active {
    color: #ffffff;
    border-color: var(--ds-primary);
    background: var(--ds-primary);
}

.animal-details-page .animal-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.45rem;
    height: 1.45rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.72rem;
    font-weight: 800;
}

.animal-details-page .animal-tab-badge.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.animal-details-page .animal-tab.active .animal-tab-badge {
    background: rgba(255, 255, 255, 0.16);
}

.animal-details-page .animal-tab.active .animal-tab-badge.danger {
    background: rgba(255, 255, 255, 0.92);
    color: #b91c1c;
}

.animal-details-page .feed-ration-alert {
    border: 1px solid #f2c1c1;
    background: #fff3f3;
}

.animal-details-page .feed-ration-alert-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.animal-details-page .empty-state-danger {
    border-color: #f2c1c1;
    background: #fff8f8;
    color: #991b1b;
}

.animal-details-page .animal-panel {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
}

.animal-details-page .animal-tab-shell {
    display: grid;
    gap: 1rem;
}

.animal-details-page .tab-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.animal-details-page .tab-header h3 {
    margin: 0.15rem 0 0;
    color: var(--ds-text);
    font-weight: 900;
}

.animal-details-page .tab-header p {
    margin: 0.25rem 0 0;
    color: var(--ds-muted);
}

.animal-details-page .tab-header .eyebrow,
.animal-details-page .tab-header .eyebrow {
    color: var(--ds-accent);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.animal-details-page .tab-actions,
.animal-details-page .animal-inline-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.animal-details-page .panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.animal-details-page .panel-card {
    display: grid;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
}

.animal-details-page .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.animal-details-page .panel-head h3 {
    margin: 0;
    color: var(--ds-text);
    font-size: 1.05rem;
    font-weight: 900;
}

.animal-details-page .muted-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--ds-muted-strong);
    background: var(--ds-surface-alt);
    border: 1px solid var(--ds-border);
}

.animal-details-page .detail-grid {
    display: grid;
    grid-template-columns: minmax(130px, 180px) minmax(0, 1fr);
    gap: 0.4rem 0.8rem;
    margin: 0;
}

.animal-details-page .detail-grid dt {
    color: var(--ds-muted);
    font-weight: 800;
}

.animal-details-page .detail-grid dd {
    margin: 0;
    color: var(--ds-text);
    font-weight: 700;
}

.animal-details-page .stack-card {
    display: grid;
    gap: 0.35rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.animal-details-page .stack-card strong { color: var(--ds-text); }
.animal-details-page .stack-card span { color: var(--ds-muted-strong); }
.animal-details-page .stack-card-empty {
    border-style: dashed;
    background: #fafcff;
}

.animal-details-page .stack-metric-grid {
    display: grid;
    grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
    gap: 0.35rem 0.8rem;
    margin: 0;
}

.animal-details-page .stack-metric-grid dt {
    color: var(--ds-muted);
    font-weight: 800;
}

.animal-details-page .stack-metric-grid dd {
    margin: 0;
    color: var(--ds-text);
    font-weight: 800;
}

.animal-details-page .summary-overview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.9rem;
}

.animal-details-page .summary-metric-card,
.animal-details-page .summary-priority-card {
    display: grid;
    gap: 0.65rem;
    min-height: 170px;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.animal-details-page .summary-metric-head {
    display: grid;
    gap: 0.3rem;
}

.animal-details-page .summary-metric-head span,
.animal-details-page .summary-priority-kicker {
    color: var(--ds-muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.animal-details-page .summary-metric-head strong {
    font-size: 1.85rem;
    line-height: 1;
    font-weight: 900;
}

.animal-details-page .summary-metric-head strong.success { color: var(--ds-success); }
.animal-details-page .summary-metric-head strong.warning { color: #b45309; }
.animal-details-page .summary-metric-head strong.danger { color: var(--ds-danger); }
.animal-details-page .summary-metric-head strong.info { color: var(--ds-accent); }

.animal-details-page .summary-metric-card .progress {
    height: 0.65rem;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.animal-details-page .summary-metric-card .progress-bar { height: 100%; border-radius: 999px; }
.animal-details-page .summary-metric-card .progress-bar.success { background: linear-gradient(90deg, #16a34a, #22c55e); }
.animal-details-page .summary-metric-card .progress-bar.warning { background: linear-gradient(90deg, #d97706, #f59e0b); }
.animal-details-page .summary-metric-card .progress-bar.danger { background: linear-gradient(90deg, #dc2626, #ef4444); }
.animal-details-page .summary-metric-card .progress-bar.info { background: linear-gradient(90deg, #0284c7, #0ea5e9); }

.animal-details-page .summary-priority-card {
    background: linear-gradient(180deg, #fdfbf5 0%, #fffdf8 100%);
    border-color: #f3dfb0;
}

.animal-details-page .summary-priority-card strong {
    font-size: 2rem;
    line-height: 1;
    font-weight: 900;
}

.animal-details-page .weight-summary-grid,
.animal-details-page .cost-summary-grid,
.animal-details-page .feeding-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.animal-details-page .cost-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.animal-details-page .summary-card .positive { color: var(--ds-success); }
.animal-details-page .summary-card .negative { color: var(--ds-danger); }
.animal-details-page .summary-card .neutral { color: var(--ds-muted-strong); }

.animal-details-page .weight-chart-block {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
}

.animal-details-page .weight-insight-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
}

.animal-details-page .weight-insight-bar.positive { border-left: 4px solid var(--ds-success); }
.animal-details-page .weight-insight-bar.negative { border-left: 4px solid var(--ds-danger); }
.animal-details-page .weight-insight-bar.neutral { border-left: 4px solid var(--ds-border); }

.animal-details-page .weight-insight-bar__lead {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.animal-details-page .weight-insight-bar__eyebrow {
    color: var(--ds-muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.animal-details-page .weight-insight-bar__lead strong {
    color: var(--ds-text);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.45;
}

.animal-details-page .weight-insight-bar__delta {
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 900;
    white-space: nowrap;
}

.animal-details-page .weight-insight-bar.positive .weight-insight-bar__delta { color: var(--ds-success); }
.animal-details-page .weight-insight-bar.negative .weight-insight-bar__delta { color: var(--ds-danger); }

.animal-details-page .decision-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.animal-details-page .decision-card {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
}

.animal-details-page .decision-list {
    display: grid;
    gap: 0.75rem;
}

.animal-details-page .decision-item {
    display: grid;
    gap: 0.35rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.animal-details-page .decision-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.animal-details-page .decision-item p {
    margin: 0;
    color: var(--ds-muted-strong);
}

.animal-details-page .decision-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.animal-details-page .decision-item.danger { border-color: #f2c1c1; background: #fff4f4; }
.animal-details-page .decision-item.danger .decision-badge { color: #991b1b; background: #fee2e2; }
.animal-details-page .decision-item.warning { border-color: #f1ddb3; background: #fffaf0; }
.animal-details-page .decision-item.warning .decision-badge { color: #9a6500; background: #fff4da; }
.animal-details-page .decision-item.info { border-color: #dbeafe; background: #f8fbff; }
.animal-details-page .decision-item.info .decision-badge { color: #0369a1; background: #e0f2fe; }
.animal-details-page .decision-item.success { border-color: #c8ead6; background: #f0fbf4; }
.animal-details-page .decision-item.success .decision-badge { color: #166534; background: #dcfce7; }

.animal-details-page .decision-explain-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 0.9rem;
}

.animal-details-page .decision-explain-grid div { display: grid; gap: 0.15rem; }

.animal-details-page .decision-explain-grid span,
.animal-details-page .decision-rule {
    color: var(--ds-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.animal-details-page .decision-explain-grid strong,
.animal-details-page .decision-rule strong {
    color: var(--ds-text);
    font-size: 0.92rem;
    font-weight: 900;
    text-transform: none;
}

.animal-details-page .analysis-inline-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.animal-details-page .analysis-inline-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 700;
}

.animal-details-page .analysis-action {
    color: var(--ds-primary);
    font-size: 0.82rem;
    font-weight: 800;
}

.animal-details-page .timeline {
    display: grid;
    gap: 0.75rem;
}

.animal-details-page .timeline-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 1rem;
    padding: 0.95rem 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
}

.animal-details-page .timeline-item.weight { border-left: 4px solid #0ea5e9; }
.animal-details-page .timeline-item.health { border-left: 4px solid #ef4444; }
.animal-details-page .timeline-item.birth { border-left: 4px solid #8b5cf6; }
.animal-details-page .timeline-item.sale { border-left: 4px solid #16a34a; }
.animal-details-page .timeline-item.cost,
.animal-details-page .timeline-item.purchase { border-left: 4px solid #f59e0b; }
.animal-details-page .timeline-item.feed { border-left: 4px solid #16a34a; }
.animal-details-page .timeline-item.decision { border-left: 4px solid #2563eb; }

.animal-details-page .timeline-date {
    color: var(--ds-accent);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.animal-details-page .timeline-body {
    display: grid;
    gap: 0.25rem;
}

.animal-details-page .feed-breakdown-list,
.animal-details-page .mini-timeline-grid {
    display: grid;
    gap: 0.75rem;
}

.animal-details-page .mini-timeline-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.animal-details-page .feed-breakdown-item,
.animal-details-page .mini-timeline-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.animal-details-page .feed-breakdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.animal-details-page .feed-breakdown-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    color: var(--ds-muted-strong);
    font-size: 0.85rem;
    font-weight: 700;
}

.animal-details-page .confidence-badge,
.animal-details-page .theory-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.animal-details-page .theory-badge {
    color: #8a5a00;
    background: #fff4da;
}

.animal-details-page .mini-timeline-card span {
    color: var(--ds-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.animal-details-page .mini-timeline-card strong {
    color: var(--ds-text);
    font-size: 1.05rem;
    font-weight: 900;
}

.animal-details-page .mini-timeline-card small {
    color: var(--ds-muted-strong);
    font-weight: 700;
}

.animal-details-page .animal-data-table { margin: 0; }
.animal-details-page .animal-data-table .actions-cell { white-space: nowrap; }

@media (max-width: 1100px) {
    .animal-details-page .weight-summary-grid,
    .animal-details-page .cost-summary-grid,
    .animal-details-page .feeding-kpi-grid,
    .animal-details-page .summary-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .animal-details-page .decision-grid,
    .animal-details-page .panel-grid {
        grid-template-columns: 1fr;
    }

    .animal-details-page .mini-timeline-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .animal-details-page {
        min-width: 0;
        overflow-x: clip;
    }

    .animal-details-page .fl-page-container {
        padding-inline: 0.75rem;
    }

    .animal-details-page .animal-back-link {
        width: 100%;
        justify-content: center;
    }

    .animal-details-page .animal-archived-banner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.35rem;
    }

    .animal-details-page .animal-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        gap: 0.45rem;
        padding: 0.65rem 0.75rem;
        margin-inline: -0.15rem;
    }

    .animal-details-page .animal-tab {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        padding: 0.55rem 0.75rem;
        font-size: 0.82rem;
    }

    .animal-details-page .animal-panel {
        padding: 0.85rem;
    }

    .animal-details-page .tab-header {
        flex-direction: column;
        align-items: stretch;
    }

    .animal-details-page .tab-actions,
    .animal-details-page .animal-inline-actions {
        width: 100%;
    }

    .animal-details-page .tab-actions .btn,
    .animal-details-page .tab-actions .fl-btn,
    .animal-details-page .animal-inline-actions .btn,
    .animal-details-page .animal-inline-actions .fl-btn {
        flex: 1 1 auto;
    }

    .animal-details-page .panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .animal-details-page .summary-metric-card,
    .animal-details-page .summary-priority-card {
        min-height: 0;
    }

    .animal-details-page .summary-metric-head strong,
    .animal-details-page .summary-priority-card strong {
        font-size: 1.45rem;
    }

    .animal-details-page .animal-data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .animal-details-page .feed-ration-alert-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .animal-details-page .weight-summary-grid,
    .animal-details-page .cost-summary-grid,
    .animal-details-page .feeding-kpi-grid,
    .animal-details-page .summary-overview-grid,
    .animal-details-page .mini-timeline-grid,
    .animal-details-page .decision-explain-grid {
        grid-template-columns: 1fr;
    }

    .animal-details-page .weight-insight-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .animal-details-page .detail-grid,
    .animal-details-page .timeline-item,
    .animal-details-page .stack-metric-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .animal-kpi-grid,
    .analysis-score-grid,
    .animal-details-page .weight-summary-grid,
    .animal-details-page .cost-summary-grid,
    .animal-details-page .feeding-kpi-grid {
        grid-template-columns: 1fr;
    }

    .animal-actions-toolbar {
        gap: 0.4rem;
    }
}

/* Animal group details — feed tab (same visual language as animal details).
   Global file so styles reach child components (CSS isolation does not). */
.animal-group-details-page .panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.animal-group-details-page .panel-card {
    display: grid;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
}

.animal-group-details-page .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.animal-group-details-page .panel-head h3 {
    margin: 0;
    color: var(--ds-text);
    font-size: 1.05rem;
    font-weight: 900;
}

.animal-group-details-page .feeding-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.animal-group-details-page .feed-breakdown-list {
    display: grid;
    gap: 0.75rem;
}

.animal-group-details-page .feed-breakdown-item,
.animal-group-details-page .mini-timeline-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.animal-group-details-page .feed-breakdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.animal-group-details-page .feed-breakdown-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    color: var(--ds-muted-strong);
    font-size: 0.85rem;
    font-weight: 700;
}

.animal-group-details-page .mini-timeline-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
}

.animal-group-details-page .mini-timeline-card span {
    color: var(--ds-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.animal-group-details-page .mini-timeline-card strong {
    color: var(--ds-text);
    font-size: 1.05rem;
    font-weight: 900;
}

.animal-group-details-page .mini-timeline-card small {
    color: var(--ds-muted-strong);
    font-weight: 700;
}

.animal-group-details-page .theory-badge,
.animal-group-details-page .muted-chip,
.animal-group-details-page .decision-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--ds-muted-strong);
    background: var(--ds-surface-alt);
    border: 1px solid var(--ds-border);
}

.animal-group-details-page .theory-badge {
    color: #8a5a00;
    background: #fff4da;
    border-color: #f3dfb0;
}

.animal-group-details-page .confidence-high {
    color: #166534;
    background: rgba(22, 163, 74, 0.12);
    border-color: transparent;
}

.animal-group-details-page .confidence-medium {
    color: #a16207;
    background: rgba(202, 138, 4, 0.14);
    border-color: transparent;
}

.animal-group-details-page .confidence-low {
    color: #b91c1c;
    background: rgba(220, 38, 38, 0.12);
    border-color: transparent;
}

.animal-group-details-page .feed-ration-alert-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.animal-group-details-page .empty-state {
    color: var(--ds-muted);
    padding: 0.75rem 0;
}

.animal-group-details-page .empty-state-danger {
    color: #b91c1c;
}

.animal-group-details-page .eyebrow {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ds-muted);
    font-weight: 800;
}

@media (max-width: 1100px) {
    .animal-group-details-page .panel-grid,
    .animal-group-details-page .feeding-kpi-grid {
        grid-template-columns: 1fr;
    }

    .animal-group-details-page .mini-timeline-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .animal-group-details-page .feeding-kpi-grid,
    .animal-group-details-page .mini-timeline-grid {
        grid-template-columns: 1fr;
    }
}

.animals-page-topbar-row--title {
    width: 100%;
}

.animals-page-topbar-row--view-mode {
    justify-content: center;
    width: 100%;
}

.animals-view-mode-nav--featured {
    width: min(100%, 40rem);
    height: 3rem;
    min-height: 3rem;
    max-height: 3rem;
    grid-template-columns: 1fr 1fr;
    border-width: 1px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.animals-view-mode-nav--featured .animals-view-mode-card {
    width: 100%;
    justify-content: center;
    padding: 0 0.85rem;
    gap: 0.45rem;
}

.animals-view-mode-nav--featured .animals-view-mode-title {
    font-size: 0.9rem;
    font-weight: 800;
}

.animals-view-mode-nav--featured .animals-view-mode-card.is-active {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.animals-view-mode-nav--featured .animals-view-mode-card .animals-view-mode-icon {
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
}

.animals-view-mode-nav--featured .animals-view-mode-card .animals-view-mode-icon svg,
.animals-view-mode-nav--featured .animals-view-mode-card .animals-view-mode-icon i,
.animals-view-mode-nav--featured .animals-view-mode-card .animals-view-mode-icon .ti {
    width: 0.95rem;
    height: 0.95rem;
    font-size: 0.95rem;
}

/* Animals list / groups — segmented switch (full labels, comfortable size) */
.animals-view-mode-nav {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 0;
    width: max-content;
    min-width: 0;
    max-width: 100%;
    height: 2.75rem;
    min-height: 2.75rem;
    max-height: 2.75rem;
    margin: 0;
    padding: 0.22rem;
    flex: 0 0 auto;
    box-sizing: border-box;
    border: 1px solid var(--fl-border, var(--ds-border, #e5e7eb));
    border-radius: 999px;
    background: var(--fl-surface-2, var(--ds-surface-2, #f3f4f6));
    box-shadow: none;
}

.animals-view-mode-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: auto;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-height: none;
    padding: 0 0.95rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--fl-text-muted, var(--ds-text-muted, #6b7280));
    text-decoration: none;
    box-shadow: none;
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.animals-view-mode-card:hover {
    color: var(--fl-text, var(--ds-text, #1f2937));
    background: rgba(255, 255, 255, 0.55);
    text-decoration: none;
}

.animals-view-mode-card.is-active {
    background: var(--fl-surface, var(--ds-surface, #fff));
    color: var(--fl-text, var(--ds-text, #111827));
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.animals-view-mode-card .animals-view-mode-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    min-width: 1.05rem;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 0.72rem;
    line-height: 1;
    position: relative;
    overflow: visible;
}

.animals-view-mode-card .animals-view-mode-icon--lot {
    width: 1.05rem;
    height: 1.05rem;
}

.animals-view-mode-lot-sub {
    display: none !important;
}

.animals-view-mode-card .animals-view-mode-icon svg,
.animals-view-mode-card .animals-view-mode-icon i,
.animals-view-mode-card .animals-view-mode-icon .ti {
    width: 0.85rem;
    height: 0.85rem;
    font-size: 0.85rem;
    line-height: 1;
}

.animals-view-mode-card.is-active .animals-view-mode-icon {
    background: color-mix(in srgb, var(--fl-brand, var(--ds-brand, #16a34a)) 14%, transparent);
    color: var(--fl-brand, var(--ds-brand, #16a34a));
}

.animals-view-mode-copy {
    display: block;
    min-width: 0;
    overflow: hidden;
}

.animals-view-mode-title {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.animals-view-mode-desc,
.animals-view-mode-subtitle {
    display: none !important;
}

.animal-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 0;
}

.animal-page-actions--primary {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
}

.animal-page-actions--secondary {
    width: 100%;
    justify-content: flex-end;
}

/* Topbar: title | compact switch | Ajouter — no tall cards, no H-scroll */
.animals-page-topbar {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 0 0.55rem;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.animals-page-topbar-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.65rem 0.85rem;
    width: 100%;
    min-width: 0;
}

.animals-page-topbar-row > .animals-page-header-compact,
.animals-page-topbar-row > .animals-page-header {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.animals-page-topbar-row > .animals-view-mode-nav {
    flex: 0 1 auto;
    width: max-content;
    min-width: 0;
    max-width: 100%;
}

.animals-page-topbar-row > .animal-page-actions--primary {
    flex: 0 0 auto;
    margin-left: auto;
}

.animals-page-header-compact.fl-page-header {
    margin-block-end: 0;
    min-width: 0;
    gap: 0.2rem;
}

.animals-page-header-compact .fl-page-title {
    font-size: clamp(1.15rem, 1.6vw, 1.4rem);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.animals-page-header-compact .fl-page-header-icon {
    font-size: 1.25rem;
}

.animals-page-header-compact .fl-small,
.animals-page-header-compact .fl-eyebrow {
    display: none;
}

.animals-page-topbar .animal-page-actions .btn,
.animals-page-topbar .animal-page-actions .fl-btn {
    min-height: 2.15rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    white-space: nowrap;
}

.animals-page-topbar .animal-page-actions .btn-sm,
.animals-page-topbar .animal-page-actions .fl-btn-sm {
    min-height: 2rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

.animals-page-topbar-side {
    display: contents;
}

@media (max-width: 1100px) {
    .animals-page-topbar-row {
        flex-wrap: wrap;
    }

    .animals-page-topbar-row > .animals-page-header-compact,
    .animals-page-topbar-row > .animals-page-header {
        flex: 1 1 calc(100% - 10rem);
        min-width: 12rem;
    }

    .animals-page-topbar-row > .animals-view-mode-nav {
        order: 3;
        flex: 0 0 auto;
        min-width: 0;
        width: max-content;
        max-width: 100%;
    }

    .animals-page-topbar-row > .animal-page-actions--primary {
        margin-left: auto;
    }
}

@media (max-width: 720px) {
    .animals-page-topbar-row > .animals-page-header-compact,
    .animals-page-topbar-row > .animals-page-header,
    .animals-page-topbar-row > .animals-view-mode-nav,
    .animals-page-topbar-row > .animal-page-actions {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: none;
        margin-left: 0;
    }

    .animals-page-topbar-row > .animals-view-mode-nav {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex-basis: 100%;
    }

    .animals-page-topbar-row > .animal-page-actions {
        justify-content: stretch;
    }

    .animals-page-topbar-row > .animal-page-actions .btn,
    .animals-page-topbar-row > .animal-page-actions .fl-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

.animals-kpi-tour-anchor .fl-grid-kpi,
.animals-kpi-tour-anchor .animals-kpi-grid,
.animals-kpi-tour-anchor .fl-skeleton-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 0.3rem !important;
}

.animals-kpi-tour-anchor .fl-kpi-card,
.animals-kpi-tour-anchor .fl-skeleton-kpi {
    padding: 0.3rem 0.4rem !important;
    min-block-size: 0 !important;
    min-height: 0 !important;
    height: auto !important;
}

.animals-kpi-tour-anchor .fl-skeleton-kpi {
    min-block-size: 2.55rem !important;
    border-radius: 8px;
}

.animals-kpi-tour-anchor .fl-kpi-value {
    font-size: 0.98rem !important;
}

.animals-kpi-tour-anchor .fl-kpi-label {
    font-size: 0.55rem !important;
}

.animal-filters-flat {
    position: relative;
    z-index: 80;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: 10px;
    background: var(--fl-surface, #fff);
    overflow: visible !important;
}

.animal-filters-toolbar--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.45rem;
    margin-bottom: 0.35rem !important;
}

.animal-add-toolbar-btn {
    flex: 0 0 auto;
    min-height: 2.15rem;
    white-space: nowrap;
}

.animal-filters-toolbar--inline .animal-search-bar {
    flex: 0 1 18rem;
    width: min(100%, 18rem);
    max-width: 18rem;
    min-width: 10rem;
}

.animal-filters-toolbar--inline .animal-search-bar .fl-input {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.animal-filter-field--combined {
    flex: 0 1 11rem;
    position: relative;
    z-index: 90;
}

/* Animal list: never clip row hover popovers */
.animal-page .animal-table-shell .fl-table-card {
    overflow: visible !important;
}

.animal-page .animal-table tbody tr.animal-row:hover,
.animal-page .animal-table tbody tr.animal-row:focus-within {
    position: relative;
    z-index: 30;
}

/* Dropdown must paint above the animal table (sibling stacking context) */
.animal-page .fl-check-dropdown {
    position: relative;
}

.animal-page .fl-check-dropdown[open] {
    z-index: 100;
}

.animal-page .fl-check-dropdown__panel {
    position: absolute !important;
    z-index: 110 !important;
    left: 0;
    right: auto;
    top: calc(100% + 0.2rem);
    min-width: 14rem;
    max-width: min(18rem, calc(100vw - 1.5rem));
    background: var(--fl-surface, #fff);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

.animal-filter-field--combined .fl-check-dropdown__panel {
    left: 0;
    right: auto;
}

/* Compact KPI strip — force wrap (~2 rows on 1320px, no horizontal scroll) */
.animals-kpi-tour-anchor {
    overflow-x: hidden;
}

.animals-kpi-tour-anchor .fl-grid-kpi,
.animals-kpi-tour-anchor .animals-kpi-grid,
.animals-kpi-tour-anchor .fl-skeleton-kpi-grid {
    gap: 0.3rem !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
}

.animals-kpi-tour-anchor .fl-kpi-card {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
        "icon label"
        "icon value";
    align-items: center;
    column-gap: 0.35rem;
    row-gap: 0 !important;
    min-block-size: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0.3rem 0.4rem !important;
    border-radius: 8px;
    box-shadow: none;
    min-width: 0;
}

.animals-kpi-tour-anchor .fl-kpi-icon {
    grid-area: icon;
    inline-size: 1.15rem !important;
    block-size: 1.15rem !important;
    font-size: 0.65rem !important;
    border-radius: 5px;
}

.animals-kpi-tour-anchor .fl-kpi-label {
    grid-area: label;
    margin: 0;
    font-size: 0.55rem !important;
    letter-spacing: 0.02em;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.animals-kpi-tour-anchor .fl-kpi-value {
    grid-area: value;
    font-size: 0.98rem !important;
    line-height: 1.1 !important;
}

.animals-kpi-tour-anchor .fl-kpi-meta {
    display: none;
}

.animals-kpi-tour-anchor.mb-3 {
    margin-bottom: 0.45rem !important;
}

/* Dense search / filters card on animals list */
.fl-card.animal-filters-card {
    overflow: visible !important;
}


.animal-filters-card > .fl-card-header {
    padding: 0.4rem 0.6rem 0 !important;
}

.animal-filters-card > .fl-card-body {
    padding: 0.4rem 0.6rem 0.5rem !important;
    overflow: visible !important;
}

.animal-filters-card .fl-card-title {
    font-size: 0.85rem !important;
}

.animal-filters-card .animal-filters-toolbar {
    margin-bottom: 0.35rem !important;
}

.animal-filters-card .animal-search-bar .fl-input {
    min-height: 1.9rem !important;
    padding-block: 0.25rem;
    font-size: 0.82rem;
}

.animal-filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.4rem 0.55rem;
}

.animal-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.animal-filter-field--species,
.animal-filter-field--gender {
    flex: 0 0 auto;
}

.animal-filter-field--status,
.animal-filter-field--quick {
    flex: 0 1 9.5rem;
    position: relative;
    z-index: 5;
}

.animal-filter-field--pagesize {
    flex: 0 0 auto;
}

.animal-filter-field--scope {
    flex: 1 1 auto;
    min-width: 12rem;
}

.animal-filter-select {
    width: auto !important;
    max-width: 100%;
    min-width: 0;
    field-sizing: content;
    padding-inline: 0.45rem 1.5rem !important;
}

.animal-filter-field--species .animal-filter-select {
    width: 7.5rem !important;
}

.animal-filter-field--gender .animal-filter-select {
    width: 6.25rem !important;
}

.animal-filter-select--sm {
    width: 3.5rem !important;
    min-width: 3.25rem;
}

.animal-filters-card .fl-label,
.animal-filters-card .fl-chip-label {
    margin-bottom: 0.15rem;
    font-size: 0.62rem !important;
}

.animal-filters-card .fl-input,
.animal-filters-card select.fl-input {
    min-height: 1.9rem;
    padding-block: 0.22rem;
    font-size: 0.8rem;
}

.animal-filters-card .fl-chip {
    padding: 0.18rem 0.45rem !important;
    font-size: 0.72rem !important;
}

.animal-filters-card.mb-3 {
    margin-bottom: 0.5rem !important;
}

.animal-list-count {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    line-height: 1.3;
}

.animal-list-count span {
    margin-inline: 0.3rem;
    opacity: 0.55;
}

.animal-species-chips {
    margin-bottom: 0.45rem !important;
}

@media (max-width: 1100px) {
    .animals-kpi-tour-anchor .fl-grid-kpi,
    .animals-kpi-tour-anchor .animals-kpi-grid,
    .animals-kpi-tour-anchor .fl-skeleton-kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 720px) {
    .animals-view-mode-nav {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex-basis: 100%;
        height: 2.75rem;
        min-height: 2.75rem;
        max-height: 2.75rem;
        grid-template-columns: 1fr 1fr;
    }

    .animals-view-mode-card {
        width: 100%;
        padding: 0 0.55rem;
    }

    .animals-kpi-tour-anchor .fl-grid-kpi,
    .animals-kpi-tour-anchor .animals-kpi-grid,
    .animals-kpi-tour-anchor .fl-skeleton-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 640px) {
    .animal-page-actions {
        justify-content: stretch;
    }

    .animal-page-actions .fl-btn {
        flex: 1 1 auto;
    }

    .animals-kpi-tour-anchor .fl-grid-kpi,
    .animals-kpi-tour-anchor .animals-kpi-grid,
    .animals-kpi-tour-anchor .fl-skeleton-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .animal-filter-field--status,
    .animal-filter-field--quick {
        flex: 1 1 8rem;
    }
}

/* -------------------------------------------------------------------------- */
/* Add-animal chooser modal (Animals + AnimalGroups)                          */
/* -------------------------------------------------------------------------- */

.animals-add-chooser-backdrop {
    /* Above sticky .fl-app-header (1250) / farm menu (1260); align with farmlivo-theme modals */
    z-index: 1390;
}

.animals-add-chooser-modal {
    z-index: 1400;
}

.animal-import-wizard-backdrop {
    z-index: 2000 !important;
}

.animal-import-wizard-modal {
    z-index: 2010 !important;
    pointer-events: auto !important;
}

.animal-import-wizard-modal .modal-dialog,
.animal-import-wizard-modal .modal-content,
.animal-import-wizard-modal .modal-body,
.animal-import-wizard-modal .modal-footer {
    pointer-events: auto !important;
}

.animal-import-wizard-modal .import-preview-edit input,
.animal-import-wizard-modal .import-preview-edit select,
.animal-import-wizard-modal .import-preview-edit button {
    pointer-events: auto !important;
    position: relative;
    z-index: 2;
}

.animal-import-wizard-modal .import-sex-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.animal-import-wizard-modal .import-sex-toggle .btn {
    pointer-events: auto !important;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
}

.animal-import-wizard-modal .import-gen-field {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    min-width: 9rem;
}

.animal-import-wizard-modal .import-gen-field input {
    flex: 1 1 auto;
    min-width: 0;
}

.animal-import-wizard-modal .import-gen-field .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
}

.animals-add-chooser {
    overflow: hidden;
}

.animals-add-chooser .modal-header {
    align-items: flex-start;
    gap: 0.75rem;
}

.animals-add-chooser .modal-title {
    margin: 0;
    padding-right: 0.25rem;
    font-size: 1.05rem;
    line-height: 1.35;
    text-wrap: pretty;
}

.animals-add-chooser__header-text {
    min-width: 0;
    flex: 1 1 auto;
}

.animals-add-chooser__body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-top: 1rem;
}

.animals-add-chooser__meta {
    margin-bottom: 0.25rem;
}

.animals-add-chooser__action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.85rem 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    text-align: start;
    white-space: normal;
    font-family: inherit;
    line-height: 1.35;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.animals-add-chooser__action:focus-visible {
    outline: none;
    box-shadow: var(--fl-focus-ring, 0 0 0 3px rgba(36, 81, 58, 0.25));
}

.animals-add-chooser__action-title {
    display: block;
    width: 100%;
    font-size: 0.95rem;
    font-weight: 650;
    white-space: normal;
    overflow-wrap: anywhere;
}

.animals-add-chooser__action-hint {
    display: block;
    width: 100%;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0.8;
    white-space: normal;
    overflow-wrap: anywhere;
}

.animals-add-chooser__action--primary {
    background: var(--fl-primary, #24513a);
    color: #fff;
    border-color: var(--fl-primary, #24513a);
}

.animals-add-chooser__action--primary:hover {
    background: var(--fl-primary-hover, #1c3f2d);
    border-color: var(--fl-primary-hover, #1c3f2d);
    color: #fff;
}

.animals-add-chooser__action--soft {
    background: var(--fl-olive-soft, #e8f2e4);
    color: var(--fl-primary, #24513a);
    border-color: color-mix(in srgb, var(--fl-primary, #24513a) 12%, transparent);
}

.animals-add-chooser__action--soft:hover {
    background: #dcebd8;
    color: var(--fl-primary-hover, #1c3f2d);
}

.animals-add-chooser .modal-footer .fl-btn {
    white-space: normal;
}
