/* CattleGo — see docs/ui-guidelines.md. Phone first; wider screens get more columns, not smaller targets. */
:root {
    --cg-primary: #A06000;
    --cg-primary-soft: #F6EBDA;
    --cg-amber: #B45309;
    --cg-amber-soft: #FDF1E3;
    --cg-red: #C62828;
    --cg-red-soft: #FDECEC;
    --cg-blue-soft: #E8EEF6;
    --cg-text: #1F2421;
    --cg-muted: #5B635D;
    --cg-line: #E3E6E0;
    --cg-bg: #F5F6F2;
    --cg-surface: #FFFFFF;
    --cg-radius: 10px;
    --cg-touch: 48px;
    --cg-bottom-nav: 64px;
    --cg-top-search: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body {
    background: var(--cg-bg);
    color: var(--cg-text);
    -webkit-tap-highlight-color: transparent;
}
.muted { color: var(--cg-muted); }
/* Sentence-case buttons and tabs read better on small screens than all-caps. */
.mud-button-root, .mud-tab { text-transform: none !important; letter-spacing: normal !important; }
/* Keep notifications above the bottom navigation on phones. */
.main.narrow ~ .mud-snackbar-location-bottom-center,
.mud-snackbar-location-bottom-center { bottom: calc(var(--cg-bottom-nav) + var(--safe-bottom) + 12px) !important; }
@media (min-width: 1024px) { .mud-snackbar-location-bottom-center { bottom: 24px !important; } }
.error-text { color: var(--cg-red); font-size: .875rem; }
/* ---------- loading & error ---------- */
.app-loading { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--cg-bg); }
.app-loading-mark { font: 700 1.5rem/1 system-ui, sans-serif; color: var(--cg-primary); letter-spacing: .02em; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
#blazor-error-ui { background: #FFF4E5; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem calc(.7rem + var(--safe-bottom)); position: fixed; width: 100%; z-index: 2000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
/* ---------- shell ---------- */
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--cg-primary); font-weight: 800; font-size: .8rem; }
.brand-mark.big { width: 44px; height: 44px; font-size: 1.05rem; background: var(--cg-primary); color: #fff; }
.main { min-height: 100vh; padding-top: 0 !important; } /* no app bar */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.main.narrow { padding-bottom: calc(var(--cg-bottom-nav) + var(--safe-bottom) + 8px); }
.page { padding: 16px; }
.main.wide .page { padding: 20px 24px; }
.banners .mud-alert { border-radius: 0; }
.side-nav .mud-navmenu { padding-top: 8px; padding-bottom: 120px; } /* room for the account + sync footer */
/* Animal search on every page: top of the side menu (desktop), a bar pinned to the top with the sync status (phone). */
.side-search { padding: 12px 12px 0; }
.top-search { position: sticky; top: 0; z-index: 20; height: var(--cg-top-search); display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; background: var(--cg-bg); border-bottom: 1px solid var(--cg-line); }
.top-search .global-search-box { flex: 1; min-width: 0; }
.top-search .global-search { width: 100%; }
.global-search { margin: 0 !important; }
.global-search .mud-input-outlined { background: var(--cg-surface); }
.global-search-box { position: relative; width: 100%; }
.search-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1400; max-height: min(70vh, 520px); overflow-y: auto; padding: 4px 0; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: var(--cg-radius); box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.search-pop-title { padding: 6px 12px 4px; color: var(--cg-muted); text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.search-pop-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 12px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: inherit; }
.search-pop-row:hover, .search-pop-row.active { background: var(--cg-primary-soft); }
.search-pop-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-pop-row .muted { font-size: .8rem; }
.search-pop-empty { padding: 10px 12px; font-size: .9rem; }
.search-pop-all { display: block; width: 100%; padding: 10px 12px; border: 0; border-top: 1px solid var(--cg-line); background: none; font: inherit; font-weight: 600; color: var(--cg-primary); text-align: left; cursor: pointer; }
.side-nav-footer { position: absolute; bottom: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px 12px; font-size: .85rem; background: var(--cg-surface); }
.side-nav-account { width: 100%; padding-top: 8px; border-top: 1px solid var(--cg-line); }
/* Ranch + who is signed in; opens My Account. */
.account-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border-radius: var(--cg-radius); color: inherit; text-decoration: none; }
.account-link:hover { background: var(--cg-primary-soft); }
.account-avatar { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--cg-primary); color: #fff; font-weight: 700; font-size: .85rem; }
.account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.account-ranch { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-user { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-account { margin-bottom: 12px; padding: 6px 8px; background: var(--cg-surface); border-radius: var(--cg-radius); border: 1px solid var(--cg-line); }
.more-account .account-link { min-height: 56px; }
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--cg-bottom-nav) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--cg-surface); border-top: 1px solid var(--cg-line);
}
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--cg-muted); text-decoration: none; font-size: .72rem; font-weight: 500; }
.bottom-nav-item.active { color: var(--cg-primary); }
.bottom-nav-item.active .mud-icon-root { background: var(--cg-primary-soft); border-radius: 14px; padding: 2px 14px; box-sizing: content-box; }
.sync-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; color: var(--cg-primary); text-decoration: none; font-size: .8rem; font-weight: 600; background: var(--cg-primary-soft); white-space: nowrap; }
.sync-badge.compact { flex: 0 0 auto; min-height: 36px; padding: 4px 10px; }
.sync-badge.pending { background: #F59E0B; color: #1F2421; }
.sync-badge.warn { background: #FDE68A; color: #1F2421; }
.sync-badge.error { background: #FCA5A5; color: #1F2421; }
/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--cg-surface); border-radius: 16px; padding: 28px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.3rem; font-weight: 700; color: var(--cg-primary); margin-bottom: 20px; }
/* ---------- layout helpers ---------- */
.page-header { margin-bottom: 16px; }
.section-title { margin: 24px 0 8px; font-weight: 600; }
.back-row { margin: -8px 0 4px -8px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 8px; }
.form-grid.single { grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid:not(.single) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-section { margin-bottom: 12px; }
.form-section-title { margin-bottom: 8px; color: var(--cg-muted); text-transform: uppercase; letter-spacing: .04em; font-size: .75rem; }
.narrow-form { max-width: 760px; }
.editor-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.editor-actions.sticky { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-bottom)); background: linear-gradient(to top, var(--cg-bg) 80%, transparent); }
.main.narrow .editor-actions.sticky { bottom: calc(var(--cg-bottom-nav) + var(--safe-bottom)); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { padding: 16px; border-radius: var(--cg-radius); margin-bottom: 16px; border: 1px solid var(--cg-line); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--cg-touch); border-bottom: 1px solid var(--cg-line); }
.mud-button-root.mud-button-size-large { min-height: var(--cg-touch); }
/* ---------- ear tag: always the most prominent thing ---------- */
.tag { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; padding: 6px 10px; border-radius: 8px; background: #FFD34E; color: #1F2421; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; border: 2px solid #E0B530; }
.tag.small { min-width: 56px; padding: 1px 8px; font-size: .9rem; border-width: 1px; } /* same width in lists (tags up to 4 characters) */
.tag.big { font-size: 1.8rem; min-width: 88px; padding: 8px 14px; }
.picker-add { border-bottom: 1px solid var(--cg-line); padding: 4px 8px; display: flex; flex-direction: column; align-items: flex-start; }
.picker-tag { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 6px; }
.tag-input input { font-size: 1.3rem; font-weight: 700; }
/* ---------- chips (text + icon, never colour alone) ---------- */
.status-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #EEF0EC; color: var(--cg-text); white-space: nowrap; }
.chip .mud-icon-root { font-size: .95rem; }
.chip.type { background: #EEF0EC; }
.chip.repro.open { background: #F1F1F1; }
.chip.repro.exposed { background: var(--cg-blue-soft); color: #1D4E89; }
.chip.repro.pregnant { background: var(--cg-primary-soft); color: var(--cg-primary); }
.chip.due { background: var(--cg-amber-soft); color: var(--cg-amber); }
.chip.pending { background: #FEF3C7; color: #92400E; }
.chip.problem { background: var(--cg-red-soft); color: var(--cg-red); }
.chip.neutral { background: #EEF0EC; color: var(--cg-muted); }
/* ---------- stats ---------- */
.stat-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-tile { display: block; padding: 14px; border-radius: var(--cg-radius); background: var(--cg-surface); border: 1px solid var(--cg-line); color: inherit; text-decoration: none; min-height: 84px; }
.stat-tile:hover { border-color: var(--cg-primary); }
.stat-value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { display: flex; align-items: center; gap: 4px; color: var(--cg-muted); font-size: .85rem; margin-top: 4px; }
.stat-tile.pregnant .stat-value { color: var(--cg-primary); }
.stat-tile.exposed .stat-value { color: #1D4E89; }
.stat-tile.due .stat-value, .stat-tile.pending .stat-value { color: var(--cg-amber); }
.stat-tile.problem .stat-value { color: var(--cg-red); }
.quick-actions { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .quick-actions { grid-template-columns: repeat(4, max-content); } }
/* ---------- lists ---------- */
.list-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.list-toolbar .chip-scroller { flex: 1; min-width: 0; }
/* Sideways row with arrows at the edges while there is more out of sight (the wrapper gets more-left / more-right). */
.chip-scroller { position: relative; }
.chip-arrow { display: none; position: absolute; top: 4px; bottom: 10px; z-index: 1; width: 56px; border: 0; cursor: pointer;
    align-items: center; font-size: 1.5rem; line-height: 1; color: var(--mud-palette-primary); background-color: transparent; padding: 0; }
.chip-arrow.left { left: 0; justify-content: flex-start; background: linear-gradient(to right, var(--cg-bg) 55%, transparent); }
.chip-arrow.right { right: 0; justify-content: flex-end; background: linear-gradient(to left, var(--cg-bg) 55%, transparent); }
.chip-scroller.more-left .chip-arrow.left, .chip-scroller.more-right .chip-arrow.right { display: flex; }
.chip-arrow span { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding-bottom: 3px;
    background: var(--cg-surface); border: 1px solid var(--cg-line); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; align-items: center; }
.filter-chip { border: 1px solid var(--cg-line); background: var(--cg-surface); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .85rem; white-space: nowrap; cursor: pointer; min-height: 36px; }
.filter-chip.active { background: var(--cg-primary); border-color: var(--cg-primary); color: #fff; }
.list-toolbar .count { white-space: nowrap; font-size: .85rem; }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.cattle-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--cg-surface); border-radius: var(--cg-radius); border: 1px solid var(--cg-line); cursor: pointer; min-height: 84px; }
.cattle-card:active { background: #F0F2EE; }
.cattle-card.selected { border-color: var(--cg-primary); }
.cattle-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cattle-card-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cattle-card-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: .8rem; }
.fab { position: fixed !important; right: 16px; bottom: calc(var(--cg-bottom-nav) + var(--safe-bottom) + 16px); z-index: 1200; }
/* ---------- desktop master/detail ---------- */
.master-detail { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
.master-detail .detail { position: sticky; top: 24px; max-height: calc(100vh - 90px); overflow: auto; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: var(--cg-radius); padding: 16px; }
.data-table { border: 1px solid var(--cg-line); border-radius: var(--cg-radius); }
.data-table .row-active td { background: var(--cg-primary-soft) !important; }
.data-table tbody tr { cursor: pointer; }
.data-table th, .data-table .mud-table-cell { white-space: nowrap; } /* one-line headers and cells, as CattleMax */
.data-table.mud-table-striped tbody tr:nth-of-type(odd) td { background: #F2F2F0; }
/* ---------- animal detail ---------- */
.animal-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.animal-header-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--cg-muted); font-size: .875rem; }
.facts dd { margin: 0; }
/* ---------- timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.timeline-item { display: flex; gap: 12px; padding: 10px 8px; border-radius: 8px; align-items: flex-start; }
.timeline-item.clickable { cursor: pointer; }
.timeline-item.clickable:hover { background: #F0F2EE; }
.timeline-item.voided .timeline-title > span:first-child, .timeline-item.voided .timeline-summary { text-decoration: line-through; color: var(--cg-muted); }
.timeline-item.calculated { border: 1px dashed var(--cg-line); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.timeline-summary { font-weight: 400; }
/* ---------- editors ---------- */
.dialog-title { display: flex; align-items: center; gap: 10px; }
.result-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.big-toggle { width: 100%; }

/* ---------- work session ---------- */
.op-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .op-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 820px; } }
.op-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 108px; border-radius: 14px; border: 1px solid var(--cg-line); background: var(--cg-surface); font: inherit; font-weight: 600; cursor: pointer; color: var(--cg-text); }
.op-button:active, .op-button:hover { border-color: var(--cg-primary); color: var(--cg-primary); }
.session-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.scan-box { max-width: 760px; }
.scan-input input { font-size: 1.4rem; font-weight: 700; }
.last-result { margin: 8px 0 12px; color: var(--cg-muted); }
.session-animal { max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.done-list { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.done-item { display: flex; gap: 10px; align-items: center; padding: 6px 8px; background: var(--cg-surface); border-radius: 8px; border: 1px solid var(--cg-line); }
/* ---------- groups, sync, more ---------- */
.add-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; max-width: 560px; }
.ref-list { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.ref-item { display: flex; align-items: center; gap: 8px; min-height: var(--cg-touch); padding: 0 8px 0 12px; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: 8px; }
.ref-item.archived .ref-name { color: var(--cg-muted); text-decoration: line-through; }
.outbox-list { display: flex; flex-direction: column; gap: 6px; }
.outbox-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: var(--cg-surface); border: 1px solid var(--cg-line); border-left-width: 4px; border-radius: 8px; }
.outbox-item.pending, .outbox-item.sending { border-left-color: #F59E0B; }
.outbox-item.failed { border-left-color: var(--cg-amber); }
.outbox-item.rejected { border-left-color: var(--cg-red); }
.more-list { display: flex; flex-direction: column; background: var(--cg-surface); border-radius: var(--cg-radius); border: 1px solid var(--cg-line); }
.more-item { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 16px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--cg-line); }
.more-item span { flex: 1; }
.more-item:last-child { border-bottom: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 16px; gap: 4px; }
.empty-icon { color: #A7B0A9; margin-bottom: 8px; }
/* ---------- cattle record form: two columns like a record card on wide screens, one on phones ---------- */
.wide-form { max-width: 1200px; }
.cattle-form { display: grid; grid-template-columns: 1fr; gap: 0 32px; }
@media (min-width: 1100px) { .cattle-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field-pair { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.comments { white-space: pre-wrap; }
/* ---------- ear tag colors (the physical tag) ---------- */
.tag.tag-white { background: #FFFFFF; border-color: #C9CCC7; }
.tag.tag-orange { background: #FB923C; border-color: #EA7A1F; }
.tag.tag-red { background: #DC2626; border-color: #B91C1C; color: #fff; }
.tag.tag-blue { background: #2563EB; border-color: #1D4ED8; color: #fff; }
.tag.tag-green { background: #16A34A; border-color: #15803D; color: #fff; }
.tag.tag-pink { background: #F9A8D4; border-color: #EC89BE; }
.tag.tag-purple { background: #7C3AED; border-color: #6D28D9; color: #fff; }
.tag.tag-black { background: #1F2421; border-color: #000; color: #fff; }
.tag.tag-turquoise { background: #2DD4BF; border-color: #14B8A6; }
/* ---------- ready to promote ---------- */
.promote-list { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.promote-item { display: flex; align-items: center; gap: 10px; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: 10px; padding: 8px 12px; }
.promote-name { font-weight: 600; }
/* MudBlazor labels are clipped at 1.15rem; with system fonts that cuts the tails of g, p, y. Room below, same position. */
.mud-input-control .mud-input-label.mud-input-label-inputcontrol { padding-bottom: .3em !important; } /* MudBlazor sets padding with !important */
/* ---------- pastures: rotation board ---------- */
:root {
    --cg-grazing: #2E7D32; --cg-grazing-soft: #E7F3E8;
    --cg-resting: #B45309; --cg-resting-soft: #FDF1E3;
    --cg-ready: #1B6E4A; --cg-ready-soft: #DDF3E8;
    --type-cow: #A06000; --type-heifer: #D9A441; --type-calf: #EBCB8B; --type-bull: #4E3B2A; --type-steer: #8A9A5B;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.small { font-size: .78rem; }

.board-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 720px) { .board-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.board-kpi { background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: var(--cg-radius); padding: 12px 14px; }
.board-kpi-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.board-kpi.ready .board-kpi-value { color: var(--cg-ready); }

.pasture-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .pasture-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .pasture-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pasture-card { display: flex; flex-direction: column; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: 14px; overflow: hidden;
    border-top: 4px solid #C9CCC7; transition: box-shadow .15s, transform .15s; }
.pasture-card:hover { box-shadow: 0 6px 18px rgba(31, 36, 33, .08); transform: translateY(-1px); }
.pasture-card.grazing { border-top-color: var(--cg-grazing); }
.pasture-card.resting { border-top-color: var(--cg-resting); }
.pasture-card.ready { border-top-color: var(--cg-ready); }
.pasture-card-main { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 10px; color: inherit; text-decoration: none; flex: 1; }
.pasture-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pasture-name { font-size: 1.1rem; font-weight: 700; }
.pasture-meta { display: flex; align-items: center; gap: 12px; font-size: .82rem; flex-wrap: wrap; }
.pasture-meta .mud-icon-root { font-size: 1rem; vertical-align: -3px; color: #2563EB; }
.pasture-card-actions { display: flex; justify-content: flex-end; gap: 4px; padding: 4px 8px 8px; border-top: 1px solid var(--cg-line); }

.pasture-status { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 3px 10px 3px 8px; border-radius: 999px;
    font-size: .8rem; font-weight: 600; white-space: nowrap; background: #EEF0EC; color: var(--cg-muted); }
.pasture-status .mud-icon-root { font-size: 1.05rem; }
.pasture-status.grazing { background: var(--cg-grazing-soft); color: var(--cg-grazing); }
.pasture-status.resting { background: var(--cg-resting-soft); color: var(--cg-resting); }
.pasture-status.ready { background: var(--cg-ready-soft); color: var(--cg-ready); }

.rest-meter { height: 6px; border-radius: 999px; background: #EEF0EC; overflow: hidden; }
.rest-meter-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #F2C98B, var(--cg-resting)); }
.pasture-card.ready .rest-meter-fill { background: var(--cg-ready); }

.pasture-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pasture-big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }

.composition { display: flex; flex-direction: column; gap: 6px; }
.composition-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; background: #EEF0EC; }
.composition-bar .seg { min-width: 6px; }
.composition-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--cg-muted); }
.composition-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
.type-cow { background: var(--type-cow); } .type-heifer { background: var(--type-heifer); } .type-calf { background: var(--type-calf); }
.type-bull { background: var(--type-bull); } .type-steer { background: var(--type-steer); }

.archived-pastures { margin-top: 20px; }
.archived-pastures summary { cursor: pointer; color: var(--cg-muted); font-weight: 600; }

/* ---------- pasture detail ---------- */
.pasture-title { display: flex; align-items: center; gap: 10px; }
.stat-tile.static:hover { border-color: var(--cg-line); }
.stat-label { color: var(--cg-muted); font-size: .85rem; display: flex; align-items: center; gap: 4px; }
.pasture-animals { display: flex; flex-direction: column; gap: 4px; }
.pasture-animal { display: flex; align-items: center; gap: 4px; background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: 10px; padding: 2px 10px 2px 2px; }
.pasture-animal-link { display: flex; align-items: center; gap: 10px; flex: 1; min-height: 44px; color: inherit; text-decoration: none; }
.pasture-animal-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pasture-animal-days { font-variant-numeric: tabular-nums; }

.grazing-calendar { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 120px; padding: 8px 0; }
.gc-cell { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; gap: 4px; }
.gc-bar { height: calc(8px + var(--level) * 80px); border-radius: 6px; background: color-mix(in srgb, var(--cg-grazing) calc(15% + var(--level) * 85%), #EEF0EC); }
.gc-label { text-align: center; font-size: .72rem; color: var(--cg-muted); }
.gc-legend { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.gc-scale { display: inline-flex; gap: 3px; }
.gc-scale i { width: 14px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--cg-grazing) calc(15% + var(--level) * 85%), #EEF0EC); }
.grazing-periods { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.grazing-period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--cg-line); border-radius: 10px; background: var(--cg-surface); }
.grazing-period.current { border-color: var(--cg-grazing); background: var(--cg-grazing-soft); }
.gp-dates { font-weight: 600; }

/* ---------- move animals ---------- */
.move-dialog { display: flex; flex-direction: column; gap: 12px; }
.move-route { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.move-arrow { color: var(--cg-primary); }
.field-pair.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .move-route, .field-pair.even { grid-template-columns: 1fr; } .move-arrow { transform: rotate(90deg); justify-self: center; } }
.move-empty { padding: 24px; text-align: center; border: 1px dashed var(--cg-line); border-radius: 10px; }
.move-list-head { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.move-list { display: flex; flex-direction: column; gap: 3px; max-height: 50vh; overflow: auto; }
.move-row { display: flex; align-items: center; gap: 10px; padding: 2px 10px 2px 2px; border: 1px solid var(--cg-line); border-radius: 10px; cursor: pointer; }
.move-row.on { border-color: var(--cg-primary); background: var(--cg-primary-soft); }
.move-row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-row-where { font-size: .8rem; }
.move-summary { flex: 1; padding-left: 8px; }.pasture-rest-note { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pasture-rest-when { margin-left: auto; font-weight: 600; color: var(--cg-text); }
.pasture-card.resting .pasture-rest-when { color: var(--cg-resting); }
.pasture-card.ready .pasture-rest-when { color: var(--cg-ready); }
/* ---------- season plan ---------- */
.season-timeline { display: flex; flex-direction: column; gap: 0; margin-top: 16px; border-left: 2px solid var(--cg-line); margin-left: 7px; }
.season-step { display: flex; align-items: flex-start; gap: 12px; padding: 6px 0 10px; margin-left: -8px; }
.season-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--cg-surface); border: 2px solid var(--cg-primary); flex: none; margin-top: 3px; }
.season-step.now .season-dot { background: var(--cg-primary); box-shadow: 0 0 0 4px var(--cg-primary-soft); }
.season-step.now .season-stage { color: var(--cg-primary); }
.season-stage { font-weight: 600; }
@media (min-width: 900px) {
    .season-timeline { flex-direction: row; border-left: 0; border-top: 2px solid var(--cg-line); margin: 20px 0 0; padding-top: 0; }
    .season-step { flex: 1; flex-direction: column; margin: -9px 0 0; gap: 6px; padding: 0 8px 0 0; }
}
/* ---------- calving board ---------- */
.calving-page { --cb-surface: var(--cg-surface); --cb-line: var(--cg-line); --cb-text: var(--cg-text); }
.calving-page.night { --cb-surface: #1B211D; --cb-line: #2F3A33; --cb-text: #F2F6F3; background: #0F1411; color: #F2F6F3;
    margin: -16px; padding: 16px; min-height: calc(100vh - 56px); }
.calving-page.night .muted, .calving-page.night .mud-typography-body2 { color: #A9B7AE !important; }
.calving-page.night .mud-button-outlined { color: #F7C774; border-color: #F7C774; }
.calving-page.night .mud-button-filled { background: #F7C774; color: #1A1305; }
.calving-page.night .chip.neutral { background: #2F3A33; color: #DDE6E0; }
.calving-page.night .calving-card { font-size: 1.08rem; }
.calving-section { margin-bottom: 18px; }
.calving-section-title { font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
details.calving-section summary { cursor: pointer; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.calving-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .calving-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .calving-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.calving-card { display: flex; flex-direction: column; background: var(--cb-surface); color: var(--cb-text); border: 1px solid var(--cb-line); border-left: 5px solid var(--cb-line); border-radius: 12px; overflow: hidden; }
.calving-card.overdue { border-left-color: var(--cg-red); }
.calving-card.labor { border-left-color: var(--cg-grazing); }
.calving-card.watch { border-left-color: var(--cg-resting); }
.calving-card.help { border-left-color: var(--cg-red); animation: pulse-border 1.2s ease-in-out infinite; }
@keyframes pulse-border { 50% { box-shadow: 0 0 0 4px rgba(198, 40, 40, .25); } }
.calving-card-main { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.calving-card-body { flex: 1; min-width: 0; }
.calving-card-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calving-card-when { text-align: right; }
.calving-days { font-weight: 700; font-size: 1.05rem; }
.calving-card.overdue .calving-days { color: var(--cg-red); }
.labor-timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.calving-card.watch .labor-timer { color: var(--cg-resting); }
.calving-card.help .labor-timer, .calving-card.help .calving-card-when .small { color: var(--cg-red); }
.calving-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 12px 12px; }
.calving-card-actions .mud-button-root { min-height: 48px; font-size: 1rem; }
.calved-list, .calves-list { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.calved-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--cb-line, var(--cg-line)); border-radius: 10px; background: var(--cb-surface, var(--cg-surface)); color: inherit; text-decoration: none; }
.calved-calves { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip.heifer { background: #FCE7F3; color: #9D174D; }
.chip.bull { background: #E0ECFA; color: #1D4E89; }

.calving-spread { background: var(--cb-surface); border: 1px solid var(--cb-line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.spread-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #EEF0EC; }
.calving-page.night .spread-bar { background: #2F3A33; }
.spread-bar .s21, .spread-legend i.s21 { background: var(--cg-grazing); }
.spread-bar .s42, .spread-legend i.s42 { background: #7CB342; }
.spread-bar .s63, .spread-legend i.s63 { background: #D4E157; }
.spread-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.spread-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- calving dialog: big targets for gloves ---------- */
.calved-dialog { display: flex; flex-direction: column; gap: 12px; }
.calved-cow { display: flex; align-items: center; gap: 12px; }
.calved-cow-name { font-weight: 700; font-size: 1.1rem; }
.big-choice { display: grid; gap: 8px; }
.big-choice.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.big-choice.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 600px) { .big-choice.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.big-option { min-height: 56px; border-radius: 12px; border: 2px solid var(--cg-line); background: var(--cg-surface); font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--cg-text); cursor: pointer; }
.big-option.on { border-color: var(--cg-primary); background: var(--cg-primary-soft); color: var(--cg-primary); }
.calf-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--cg-line); border-radius: 12px; }
.calf-card-title { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.scale-choice { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.scale-option { min-height: 48px; border-radius: 10px; border: 2px solid var(--cg-line); background: var(--cg-surface); font: inherit; font-size: 1.15rem; font-weight: 800; cursor: pointer; }
.scale-option.on { border-color: var(--cg-grazing); background: var(--cg-grazing-soft); color: var(--cg-grazing); }
.scale-option.hard.on { border-color: var(--cg-red); background: var(--cg-red-soft); color: var(--cg-red); }
.inherit-summary { padding-top: 4px; }
.op-button.stage { text-decoration: none; }
/* ---------- herd health ---------- */
.board-kpi.alert .board-kpi-value { color: var(--cg-red); }
.health-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.health-main { min-width: 0; }
@media (max-width: 599px) { .health-main .mud-tab { padding-inline: 10px; } }
@media (min-width: 1200px) { .health-layout { grid-template-columns: minmax(0, 1fr) 340px; } }
.health-charts { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 8px; }
@media (min-width: 900px) { .health-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.week-bars { background: var(--cg-surface); border: 1px solid var(--cg-line); border-radius: 12px; padding: 12px 14px; }
.week-bars-title { font-weight: 700; margin-bottom: 8px; }
.week-bars-plot { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.wb-col { flex: 1; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; gap: 3px; }
.wb-bar { background: var(--cg-primary); border-radius: 6px 6px 2px 2px; min-height: 2px; opacity: .85; }
.wb-col.overdue .wb-bar { background: var(--cg-red); }
.wb-count { text-align: center; font-weight: 700; font-size: .85rem; min-height: 1.1em; }
.wb-label { text-align: center; font-size: .7rem; color: var(--cg-muted); white-space: nowrap; }
.health-list { display: flex; flex-direction: column; gap: 4px; }
.health-row { display: flex; align-items: center; gap: 10px; padding: 6px 12px; min-height: 48px; border: 1px solid var(--cg-line); border-radius: 10px;
    background: var(--cg-surface); color: inherit; text-decoration: none; flex-wrap: wrap; }
.health-row-main { flex: 1; min-width: 140px; font-weight: 600; }
.log-date { min-width: 92px; }
.panel.presets { display: flex; flex-direction: column; gap: 6px; }
.preset-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1px solid var(--cg-line); border-radius: 10px;
    background: var(--cg-surface); font: inherit; text-align: left; cursor: pointer; }
.preset-row:hover { border-color: var(--cg-primary); }
.preset-name { font-weight: 700; }
/* ---------- work sessions: stages, chute, scale import, summary ---------- */
.stage-grid .op-button { padding: 12px 10px; text-align: center; }
.op-hint { font-size: .75rem; font-weight: 400; color: var(--cg-muted); line-height: 1.25; }
.op-button.stage.current { border: 2px solid var(--cg-primary); background: var(--cg-primary-soft); }
.task-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 760px; }
.task-chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--cg-touch); padding: 0 14px; border-radius: 999px; border: 1px solid var(--cg-line);
    background: var(--cg-surface); color: var(--cg-text); font: inherit; font-weight: 600; cursor: pointer; }
.task-chip.on { border-color: var(--cg-primary); background: var(--cg-primary-soft); color: var(--cg-primary); }
.session-header { flex-wrap: wrap; max-width: 760px; }
.session-date { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 760px; margin-bottom: 12px; }
.session-date .mud-input-control { max-width: 220px; }
.remaining { margin-top: 12px; }
.remaining-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.remaining-tags button.tag { border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.chute { display: flex; flex-direction: column; gap: 10px; }
.chute-task { border: 1px solid var(--cg-line); border-radius: 12px; background: var(--cg-surface); padding: 10px 14px 14px; }
.chute-task.skipped { padding-bottom: 10px; opacity: .75; }
div.chute-task.skipped { display: flex; align-items: center; gap: 6px; }
.chute-task-head { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 4px; }
.chute-task-title { font-weight: 700; }
.chute-task-head .mud-switch { margin: 0; }
.perf-preview { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--cg-ready-soft); }
.perf-preview.light { background: var(--cg-amber-soft); }
.perf-main { display: flex; align-items: baseline; gap: 6px; }
.perf-label { font-size: .8rem; color: var(--cg-muted); }
.perf-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.perf-preview.light .perf-value { color: var(--cg-amber); }
.perf-note { flex-basis: 100%; }
.done-summary { flex: 1; min-width: 0; }
.done-item { flex-wrap: wrap; }
.summary-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 760px; }
@media (min-width: 720px) { .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.small-value { font-size: 1.25rem; }
.scale-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scale-file-label { position: relative; overflow: hidden; cursor: pointer; padding: 5px 15px; }
.scale-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.scale-unit { max-width: 110px; }
.scale-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.scale-list { display: flex; flex-direction: column; gap: 2px; max-height: 45vh; overflow: auto; }
.scale-row { display: grid; grid-template-columns: 44px minmax(0, 1.4fr) 80px minmax(0, 2fr); gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; }
.scale-row.bad { background: var(--cg-red-soft); }
.scale-id { font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- preconditioning certificate (screen preview + print) ---------- */
.muted-row { opacity: .8; }
.pc-problems { color: var(--cg-red); flex-basis: 100%; padding-left: 42px; }
@media (min-width: 720px) { .pc-problems { flex-basis: auto; padding-left: 0; } }
.certificate { max-width: 820px; background: #fff; color: #1d1d1d; border: 1px solid var(--cg-line); border-radius: 12px; padding: 28px 32px; }
.certificate header { border-bottom: 3px solid var(--cg-primary); padding-bottom: 12px; margin-bottom: 16px; }
.certificate h1 { font-size: 1.7rem; margin: 4px 0; }
.certificate h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.cert-kicker { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 700; color: var(--cg-primary); }
.cert-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.cert-facts dt { color: #555; }
.cert-facts dd { margin: 0; font-weight: 600; }
.cert-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cert-table th, .cert-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #ddd; }
.cert-table th { background: #f4efe6; }
.cert-sign { margin-top: 28px; }
.cert-lines { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 42px; }
.cert-lines span { border-top: 1px solid #333; padding-top: 4px; font-size: .8rem; color: #555; }
@media (max-width: 599px) { .certificate { padding: 18px 14px; } .cert-table { font-size: .78rem; } .cert-table th, .cert-table td { padding: 4px; } }
@media print {
    body * { visibility: hidden; }
    .certificate, .certificate * { visibility: visible; }
    .certificate { position: absolute; left: 0; top: 0; width: 100%; max-width: none; border: 0; border-radius: 0; padding: 0; }
    .no-print { display: none !important; }
    @page { margin: 16mm; }
}

/* ---------- replacement heifers ---------- */
.board-kpi.warn .board-kpi-value { color: var(--cg-amber); }
.ok-value { color: var(--cg-ready); }
.heifer-row .health-row-main { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.heifer-bar { display: block; height: 6px; border-radius: 3px; background: var(--cg-line); overflow: hidden; max-width: 260px; }
.heifer-bar span { display: block; height: 100%; background: var(--cg-primary); }
.selection-row .rank { min-width: 32px; font-weight: 700; color: var(--cg-muted); font-variant-numeric: tabular-nums; }
.selection-row .score { min-width: 44px; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.selection-row a.tag { text-decoration: none; }
.plan-select { max-width: 150px; flex: 0 0 150px; }

/* ---------- home: production cycle + today feed ---------- */
.cycle { display: grid; gap: 10px; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 8px 0 4px; }
.cycle-stage { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 10px; border-radius: 14px; border: 1px solid var(--cg-line);
    background: var(--cg-surface); color: var(--cg-text); text-decoration: none; min-width: 0; }
.cycle-stage:hover { border-color: var(--cg-primary); }
.cycle-stage:not(.health):not(:nth-last-child(2))::after { content: "›"; position: absolute; right: -9px; top: 50%; transform: translateY(-50%); color: var(--cg-muted);
    font-size: 1.2rem; z-index: 1; }
.cycle-stage.current { border: 2px solid var(--cg-primary); background: var(--cg-primary-soft); }
.cycle-stage.health { border-style: dashed; }
.cycle-head { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.cycle-now { margin-left: auto; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; background: var(--cg-primary); color: #fff; border-radius: 999px; padding: 1px 7px; }
.cycle-facts { list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--cg-muted); display: flex; flex-direction: column; gap: 2px; }
.cycle-facts li.alert { color: var(--cg-red); font-weight: 700; }
.cycle-actions { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cycle-action { display: inline-flex; align-items: center; font-weight: 700; color: var(--cg-primary); font-size: .88rem; }
.cycle-link { font-size: .8rem; font-weight: 600; color: var(--cg-primary); text-decoration: underline; cursor: pointer; }
.cycle-stage.pulse { animation: cycle-pulse 1.6s ease-in-out infinite; border-color: var(--cg-red); }
@keyframes cycle-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, .45); } 50% { box-shadow: 0 0 0 7px rgba(198, 40, 40, 0); } }
@media (prefers-reduced-motion: reduce) { .cycle-stage.pulse { animation: none; box-shadow: 0 0 0 3px rgba(198, 40, 40, .35); } }
@media (max-width: 1100px) { .cycle { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cycle-stage::after { display: none; } }
@media (max-width: 599px) {
    .cycle { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; margin: 8px -16px 4px; padding: 2px 16px 8px; }
    .cycle-stage { flex: 0 0 64%; scroll-snap-align: start; }
}
.today-feed { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.today-card { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--cg-line);
    border-left-width: 4px; background: var(--cg-surface); color: var(--cg-text); text-decoration: none; }
.today-card.urgent { border-left-color: var(--cg-red); background: var(--cg-red-soft); }
.today-card.urgent > .mud-icon-root:first-child { color: var(--cg-red); }
.today-card.warn { border-left-color: var(--cg-amber); }
.today-card.warn > .mud-icon-root:first-child { color: var(--cg-amber); }
.today-card.info { border-left-color: var(--cg-primary); }
.today-card.good { border-left-color: var(--cg-ready); }
.today-card.good > .mud-icon-root:first-child { color: var(--cg-ready); }
.today-text { flex: 1; min-width: 0; }
.today-title { font-weight: 700; }
.today-empty { padding: 12px 0; }
.stat-grid.compact .stat-tile { min-height: 0; }

/* ---------- reports ---------- */
.report-section { max-width: 820px; margin-bottom: 28px; }
.report-title { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; }
.report-subtitle { font-weight: 700; margin: 16px 0 6px; }
.scorecard { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .8fr); border: 1px solid var(--cg-line); border-radius: 12px;
    background: var(--cg-surface); overflow: hidden; }
.scorecard > div { padding: 9px 12px; border-bottom: 1px solid var(--cg-line); }
.scorecard > div:nth-last-child(-n+3) { border-bottom: 0; }
.score-head { font-weight: 700; font-size: .85rem; background: var(--cg-primary-soft); }
.score-label.strong, .score-value.strong { font-weight: 700; }
.score-value { font-variant-numeric: tabular-nums; }
.score-value.strong { font-size: 1.15rem; }
.score-delta { margin-left: 6px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.score-delta.up { color: var(--cg-ready); }
.score-delta.down { color: var(--cg-red); }
.cull-reasons { color: var(--cg-red); flex-basis: 100%; }
@media (min-width: 720px) { .cull-reasons { flex-basis: auto; } }
@media print { html, body { background: #fff !important; } }
@media (max-width: 599px) {
    .selection-row .plan-select { flex: 0 0 124px; max-width: 124px; margin-left: auto; }
    .selection-row .health-row-main { order: 10; flex-basis: 100%; padding-left: 42px; font-weight: 400; }
}

/* Animal list (desktop): CattleMax-style selection bar and ear-tag links. */
.selection-bar { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 4px 12px; margin-bottom: 8px; border-radius: 8px; background: var(--cg-surface); border: 1px solid var(--cg-line); }
.selection-bar.active { background: var(--cg-primary-soft); border-color: var(--cg-primary); }
.tag-link { text-decoration: none; }
.tag-link:hover .tag { outline: 2px solid var(--cg-primary); }

/* Group Update dialog: two columns of choices as in CattleMax; one weight box per animal. */
.group-update-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: center; }
/* padding-top: room for the first row's floating label inside the scrolling box. */
.group-update-rows { max-height: 50vh; overflow-y: auto; margin-top: 4px; padding-top: 8px; display: flex; flex-direction: column; gap: 12px; }
/* Tag | weight [| BCS], and the gain since the last weight underneath; the boxes line up whatever the tag length. */
.group-update-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 2px 8px; }
.group-update-row.with-bcs { grid-template-columns: 96px minmax(0, 1fr) 110px; }
.group-update-row > .tag { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-update-row .mud-input-control { margin-top: 0; }
.group-update-row .gain-hint { grid-column: 2 / -1; font-size: 0.8rem; }
/* Yearling: who | weight | hip height | scrotal (bulls); on a phone the weight gets its own line. */
.yearling-row { grid-template-columns: 150px minmax(0, 1fr) 130px 130px; }
.yearling-row.no-scrotal { grid-template-columns: 150px minmax(0, 1fr) 130px; }
.yearling-who { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.small-text { font-size: 0.75rem; }
/* Breeding soundness exam: one card per bull (who | date | class | motility | normal | scrotal | BCS, defects, comments), SFT check underneath. */
.bse-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; align-items: center; padding: 12px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; }
.bse-row .mud-input-control { margin-top: 0; }
.bse-who { display: flex; align-items: center; gap: 8px; }
.bse-comments, .bse-check { grid-column: 1 / -1; }
.bse-check { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .8rem; color: var(--cg-muted); }
.bse-check.below { color: var(--cg-red); }
.bse-skip { color: var(--cg-amber); }
.defects-field { display: flex; align-items: center; gap: 2px; grid-column: span 2; }
.defects-field .mud-input-control { flex: 1; }
@media (max-width: 719px) { .bse-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .defects-field { grid-column: 1 / -1; } }
/* Update DNA Parentage: one card per animal, values in three columns, the parents (pickers) in two wide ones; one column on phones. */
.dna-row { display: grid; gap: 10px 12px; padding: 12px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; }
.dna-row.has-error { border-color: var(--mud-palette-error); }
.dna-who { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dna-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.dna-parents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.dna-row .mud-input-control { margin-top: 0; }
.dna-paste { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 4px 0 8px; }
.dna-paste .mud-input-control { align-self: stretch; }
/* OCV markings are recorded one animal at a time; the two official values remain legible on a phone. */
.ocv-row { display: grid; gap: 8px 12px; padding: 12px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; }
.ocv-who { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ocv-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.ocv-row .mud-input-control { margin-top: 0; }
.ocv-note { display: block; }
@media (max-width: 719px) { .ocv-fields { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 719px) { .dna-fields, .dna-parents { grid-template-columns: minmax(0, 1fr); } }
/* Expense amount with its per head / total choice and the worked-out total underneath. */
.expense-amount { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.expense-amount .mud-radio-group { display: flex; flex-wrap: wrap; }
/* Pelvic: who | horizontal | vertical | RTS; on a phone the two sizes share a line and the score gets its own. */
.pelvic-row { grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr); }
@media (max-width: 719px) {
    .pelvic-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 10px; }
    .pelvic-row > .yearling-who, .pelvic-row > .mud-select, .pelvic-row .gain-hint { grid-column: 1 / -1; }
}
/* The latest notes at the top of an animal's overview. */
.latest-notes { border-left: 3px solid var(--mud-palette-warning); padding: 4px 0 4px 10px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
/* Retag: who | new ear tag | new EID, warnings underneath; on a phone the boxes stack. */
.retag-row { grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr); }
.retag-warning { grid-column: 2 / -1; font-size: 0.8rem; color: var(--mud-palette-warning-darken); }
@media (max-width: 719px) {
    .retag-row { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
    .retag-warning { grid-column: 1; }
}
@media (max-width: 719px) {
    .yearling-row, .yearling-row.no-scrotal { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 10px; }
    .yearling-row > .yearling-who, .yearling-row > .mud-input-control:nth-child(2), .yearling-row .gain-hint { grid-column: 1 / -1; }
}
.mud-typography.group-update-selected-count, .mud-typography.weaning-selection-count { font-weight: 700; } /* beats MudText's own weight */
.group-update-skipped { color: #b65c00; background: #fff3e0; }
/* Record Calfhood Procedures: tick | fields | which animals the row changes. */
.calfhood-rows { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.calfhood-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 230px; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--cg-line); }
.calfhood-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.calfhood-fields > * { flex: 1 1 180px; margin-top: 0 !important; }
.calfhood-note { color: var(--cg-muted); font-size: .8rem; }
@media (max-width: 720px) { .calfhood-row { grid-template-columns: 1fr; gap: 4px; } }
.group-update-row.weaning-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--mud-palette-divider); border-radius: 8px; padding: 12px; gap: 12px; }
.group-update-row.purchase-row { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--mud-palette-divider); border-radius: 8px; padding: 12px; gap: 12px; }
.weaning-animal { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 0.875rem; }
@media (max-width: 600px) { .group-update-row.weaning-row, .group-update-row.purchase-row { grid-template-columns: 1fr; } }
@media (max-width: 599px) { .group-update-options { grid-template-columns: 1fr; } }

/* Phone selection (press and hold a card, or the checklist button). */
.cattle-card.selectable { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.cattle-card.checked { background: var(--cg-primary-soft); border-color: var(--cg-primary); }
.card-check { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--cg-muted); color: #fff; transition: background .12s, border-color .12s; }
.card-check.on { background: var(--cg-primary); border-color: var(--cg-primary); }
.select-header { position: sticky; top: var(--cg-top-search); /* under the phone search bar */ z-index: 10; display: flex; align-items: center; gap: 4px; min-height: 48px; margin: -4px 0 8px; padding: 0 4px; border-radius: var(--cg-radius); background: var(--cg-primary-soft); border: 1px solid var(--cg-primary); }
.select-header .select-count { flex: 1; font-weight: 600; }
.card-list.selecting { padding-bottom: 76px; }
.select-actions { position: fixed; left: 0; right: 0; bottom: calc(var(--cg-bottom-nav) + var(--safe-bottom)); z-index: 1250; padding: 10px 16px; background: var(--cg-surface); border-top: 1px solid var(--cg-line); box-shadow: 0 -2px 8px rgba(0,0,0,.06); }

/* Animal photos. */
.photo-preview { display: block; max-width: 100%; max-height: 50vh; margin-top: 12px; border-radius: var(--cg-radius); border: 1px solid var(--cg-line); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-tile { margin: 0; }
.photo-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--cg-line); display: block; }
.photo-missing { width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; border: 1px dashed var(--cg-line); display: flex; align-items: center; justify-content: center; }

/* Recent activity. */
.activity-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.activity-list { display: flex; flex-direction: column; }
.activity-day { font-weight: 600; margin: 14px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--cg-line); }
.activity-row { display: grid; grid-template-columns: 76px 140px 1fr; gap: 10px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--cg-line); }
.activity-who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-what { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.activity-detail { flex-basis: 100%; font-size: .85rem; }
@media (max-width: 599px) { .activity-row { grid-template-columns: 64px 1fr; } .activity-what { grid-column: 1 / -1; } }

/* A date with the days after the record date that work it out (treatment withdrawal / booster). */
.date-days { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 8px; align-items: start; }
/* Lined up with the My Presets box (an outlined field starts 8px into its cell). */
.treat-preset-actions { display: flex; align-items: center; height: 56px; align-self: start; margin-top: 8px; }
.treat-attachment { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
/* What a form puts at the left of the Cancel / Save row; on a phone, a row of its own above the buttons. */
.actions-start { min-width: 0; }
.actions-start:empty { display: none; }
.editor-actions, .mud-dialog-actions { flex-wrap: wrap; }
@media (max-width: 719px) { .actions-start { flex: 1 0 100%; } }
.treat-attachment .mud-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.treat-attachment .mud-icon-button { padding: 2px; }
/* Room below Cancel / Save in a dialog. */
.mud-dialog .editor-actions { margin-bottom: 16px; }
/* Group Update: asking price and marketing comments, one card per animal */
.asking-row { display: grid; gap: 8px 12px; padding: 12px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; }
.asking-row.has-error { border-color: var(--mud-palette-error); }
.asking-who { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.asking-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px 12px; }
.asking-row .mud-input-control { margin-top: 0; }
.asking-note { display: block; }
/* Groups & lists: help line with the New smart group button; head count links to the group's animals */
.groups-help-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.group-count { margin-left: 8px; font-size: 0.85rem; white-space: nowrap; }
/* Animals list opened for one group */
.group-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 12px; margin: 4px 0 8px;
                border: 1px solid var(--mud-palette-divider); border-radius: 8px; background: var(--mud-palette-background-gray); }
/* Remove from Group: one line per animal, saying which groups it leaves */
.ungroup-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.ungroup-list .tag { margin-right: 6px; }
.sale-asking { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
@media (max-width: 719px) { .asking-fields { grid-template-columns: minmax(0, 1fr); } }
/* Sync: reused ear tags, one link per tag */
.duplicate-tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.duplicate-tag-list a.tag { text-decoration: none; }
/* Tasks: one row per task; overdue ones in red; linked animals as tag chips */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; background: var(--cg-surface); }
.task-list.compact .task-row { padding: 6px 10px; }
.task-row.done .task-name { text-decoration: line-through; color: var(--mud-palette-text-secondary); }
.task-row.overdue { border-color: var(--mud-palette-error); }
.task-main { flex: 1; min-width: 0; }
.task-name { font-weight: 500; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.task-overdue { color: var(--mud-palette-error); }
.task-notes { white-space: pre-line; margin-top: 4px; font-size: .9rem; }
.task-animals { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.task-animals a.tag { text-decoration: none; }
.task-animal-remove { border: 0; background: transparent; cursor: pointer; margin-left: 4px; padding: 0; font: inherit; color: inherit; }
.task-animal-add { margin-top: 8px; max-width: 360px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Ear tag inputs: shown in capitals while typing (the value is saved in capitals too) */
.upper-input input { text-transform: uppercase; }
