@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,400..700,0..1,-50..200");

:root {
    --primary: #2e7d32;
    --primary-dark: #1b5e20;
    --brown: #8d6e63;
    --cream: #f7f4ed;
    --danger: #d32f2f;
    --warning: #f57c00;
    --success: #388e3c;
    --text: #263238;
    --bg: #eef7f0;
    --surface: #ffffff;
    --soft: #e1f0e3;
    --line: #d7e5da;
    --muted: #66766a;
    --shadow: 0 18px 48px rgba(28, 71, 39, .1);
}

@media (max-width: 760px) {
    .language-options {
        grid-template-columns: 1fr;
    }
}


* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 100vh;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 58px;
    padding: 8px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #daf0de;
    color: var(--primary-dark);
    font-weight: 900;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
}

.nav {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.nav a {
    min-height: 42px;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border-radius: 8px;
    color: #46594b;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav a:hover,
.nav a.active {
    background: #e8f4ea;
    color: var(--primary-dark);
}

.nav a:hover span,
.nav a.active span {
    background: var(--primary);
    color: #ffffff;
}

.nav span {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: #eef7f0;
    color: var(--primary);
    font-size: 0;
    overflow: hidden;
}

.nav span::before {
    font-family: "Material Symbols Rounded";
    font-size: 19px;
    font-weight: normal;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 24;
}

.nav a[data-nav="dashboard"] span::before {
    content: "dashboard";
}

.nav a[data-nav="farm"] span::before {
    content: "home_work";
}

.nav a[data-nav="farms"] span::before {
    content: "view_list";
}

.nav a[data-nav="beef"] span::before {
    content: "agriculture";
}

.nav a[data-nav="cows"] span::before {
    content: "pets";
}

.nav a[data-nav="breeding"] span::before {
    content: "favorite";
}

.nav a[data-nav="calving"] span::before {
    content: "child_friendly";
}

.nav a[data-nav="health"] span::before {
    content: "health_and_safety";
}

.nav a[data-nav="food"] span::before {
    content: "restaurant";
}

.nav a[data-nav="costs"] span::before {
    content: "payments";
}

.nav a[data-nav="alerts"] span::before {
    content: "notifications";
}

.nav a[data-nav="ai-risk"] span::before {
    content: "psychology";
}

.nav a[data-nav="members"] span::before {
    content: "groups";
}

.nav a[data-nav="profile"] span::before {
    content: "account_circle";
}

.nav a[data-nav="reports"] span::before {
    content: "bar_chart";
}

.nav a[data-nav="language"] span::before {
    content: "translate";
}

.mobile-menu-button {
    display: none;
}

.mobile-menu-actions {
    display: none;
}

.sync-card {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 9999;
    width: min(360px, calc(100vw - 32px));
    min-height: 78px;
    margin: 0;
    padding: 14px;
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(247, 251, 248, .98);
    box-shadow: 0 18px 48px rgba(19, 58, 42, .18);
    transform: translateY(0);
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
    pointer-events: none;
}

.sync-card.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    visibility: hidden;
}

.sync-card span {
    color: var(--muted);
    font-size: 13px;
}

.workspace {
    min-width: 0;
    padding: 24px;
}

.topbar {
    min-height: 74px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.topbar p,
.topbar h1 {
    margin: 0;
}

.topbar p {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar h1 {
    margin-top: 10px;
    font-size: 34px;
}

.top-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.search {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

input,
select {
    height: 40px;
    min-width: 220px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
}

.primary-button {
    height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.secondary-button {
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    background: #ffffff;
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
}

.compact-button {
    width: auto;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.material-symbols-rounded {
    font-family: "Material Symbols Rounded";
    font-weight: normal;
    font-style: normal;
    font-size: 22px;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 24;
}

.icon-only-button {
    width: 40px;
    min-width: 40px;
    display: inline-grid;
    place-items: center;
    padding: 0;
}

.button-link {
    display: inline-flex;
    align-items: center;
}

button:disabled {
    cursor: not-allowed;
    opacity: .62;
}

.profile {
    min-height: 40px;
    display: grid;
    align-content: center;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.profile span {
    color: var(--muted);
    font-size: 11px;
}

.profile .material-symbols-rounded {
    color: var(--muted);
    font-size: 22px;
}

.profile img {
    width: 28px;
    height: 28px;
    display: block;
    border-radius: 50%;
    object-fit: cover;
}

.profile strong {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-link {
    grid-template-columns: auto minmax(0, auto);
    align-items: center;
    gap: 8px;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.profile-link:hover {
    border-color: #aec8b5;
    box-shadow: 0 10px 22px rgba(38, 50, 56, .08);
    transform: translateY(-1px);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.farm-list-summary {
    display: grid;
    grid-template-columns: minmax(0, .36fr) minmax(0, .64fr);
    gap: 14px;
    margin-bottom: 16px;
}

.summary-card,
.panel,
.cow-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.summary-card {
    min-height: 122px;
    display: grid;
    align-content: space-between;
    padding: 18px;
    border-top: 4px solid var(--primary);
}

.summary-card.danger {
    border-top-color: var(--danger);
}

.is-clickable {
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.is-clickable:hover,
.is-clickable:focus-visible {
    border-color: #aec8b5;
    box-shadow: 0 20px 48px rgba(28, 71, 39, .16);
    outline: none;
    transform: translateY(-1px);
}

.summary-card span,
.summary-card small,
.panel p,
.item-card span {
    color: var(--muted);
}

.summary-card strong {
    font-size: 34px;
}

.dashboard-layout,
.module-grid,
.ai-layout,
.farm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
    gap: 16px;
    align-items: start;
    min-width: 0;
}

.wide-panel {
    grid-column: 1 / -1;
}

.panel {
    padding: 18px;
    min-width: 0;
}

.language-panel {
    max-width: 720px;
}

.language-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.language-option {
    min-height: 92px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.language-option strong {
    font-size: 20px;
}

.language-option span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.language-option[aria-pressed="true"] {
    border-color: var(--primary);
    background: #e8f4ea;
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.farm-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 16px;
    border-top: 4px solid var(--primary);
}

.farm-logo {
    width: 82px;
    height: 82px;
    flex: 0 0 82px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4faf5;
}

.farm-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.farm-hero p,
.farm-hero h2,
.farm-hero span {
    margin: 0;
}

.farm-hero p,
.farm-badge span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.farm-hero h2 {
    margin-top: 4px;
    font-size: 32px;
    line-height: 1.08;
}

.farm-hero-copy span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.farm-badge {
    min-width: 190px;
    padding: 12px;
    border-radius: 8px;
    background: #f4faf5;
}

.farm-badge strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.farm-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.farm-select-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--primary);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(28, 71, 39, .08);
}

.farm-select-card.active {
    border-color: #9dc7a4;
    border-top-color: var(--success);
    background: #fbfefb;
}

.farm-select-card header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.farm-select-card header span,
.farm-select-card p {
    color: var(--muted);
}

.farm-select-card header span {
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.farm-select-card h3,
.farm-select-card p {
    margin: 0;
}

.farm-select-card h3 {
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.15;
}

.farm-select-card header b {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--primary-dark);
    font-size: 12px;
    white-space: nowrap;
}

.farm-select-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.farm-select-card .primary-button {
    width: fit-content;
}

.panel-head,
.section-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
}

.panel h2,
.panel p,
.section-toolbar h2 {
    margin: 0;
}

.panel h2,
.section-toolbar h2 {
    font-size: 20px;
}

.bar-chart {
    height: 300px;
    display: grid;
    grid-template-columns: repeat(8, minmax(34px, 1fr));
    gap: 10px;
    align-items: end;
    padding-top: 18px;
    max-width: 100%;
    min-width: 0;
}

.chart-bar {
    min-width: 0;
    display: grid;
    align-items: end;
    gap: 8px;
    height: 100%;
}

.chart-bar i {
    display: block;
    min-height: 8px;
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, #75b97b, var(--primary));
}

.chart-bar span {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stack-list {
    display: grid;
    gap: 10px;
}

.food-layout {
    display: grid;
    gap: 14px;
}

.food-category-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.food-category-card {
    display: grid;
    align-content: start;
    gap: 6px;
    min-height: 106px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfb;
}

.food-category-card header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.food-category-card strong {
    overflow-wrap: anywhere;
}

.food-category-card header span {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
}

.food-category-value {
    font-size: 20px;
    line-height: 1.1;
}

.food-category-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.food-low-pill {
    width: max-content;
    padding: 3px 8px;
    border-radius: 999px;
    background: #fff4d8;
    color: #9a6200;
    font-size: 11px;
    font-weight: 900;
}

.food-stock-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) minmax(130px, .8fr) minmax(130px, .8fr) auto;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.food-stock-row:hover,
.food-stock-row:focus-visible {
    border-color: #b9d2bd;
    box-shadow: 0 8px 20px rgba(28, 71, 39, .08);
    outline: 0;
    transform: translateY(-1px);
}

.food-stock-row.is-low {
    border-color: #efd28a;
    background: #fffaf0;
}

.food-stock-row div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.food-stock-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.food-stock-row span {
    color: var(--muted);
    font-size: 12px;
}

.food-status {
    justify-self: end;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef7ef;
    color: var(--primary-dark) !important;
    font-weight: 900;
}

.food-stock-row.is-low .food-status {
    background: #fff0c2;
    color: #9a6200 !important;
}

.food-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.food-list-actions select {
    width: auto;
    min-width: 156px;
}

.food-modal-panel {
    max-width: 760px;
}

.food-detail-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.food-detail-summary > div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbf8;
}

.food-detail-summary.is-low > div:first-child {
    border-color: #efd28a;
    background: #fff7df;
}

.food-detail-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.food-detail-summary strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
}

.item-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: #ffffff;
}

.item-card.warning {
    border-left-color: var(--warning);
}

.item-card.danger,
.item-card.overdue,
.item-card.urgent {
    border-left-color: var(--danger);
}

.item-card strong {
    font-size: 15px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    font-size: 13px;
}

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

.data-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

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

.detail-data-table {
    min-width: 780px;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--primary-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    padding: 0;
    text-align: left;
}

.task-grid,
.cow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.task-grid .item-card {
    min-height: 88px;
}

.cow-card {
    overflow: hidden;
}

.cow-media {
    height: 112px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #dff1e2, #f7f4ed);
    color: var(--primary-dark);
    font-size: 30px;
    font-weight: 900;
}

img.cow-media {
    width: 100%;
    object-fit: cover;
    display: block;
}

.cow-body {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.cow-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
}

.cow-title h3 {
    min-width: 0;
    margin: 0;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.cow-title .badge {
    justify-self: end;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.cow-meta {
    color: var(--muted);
    font-size: 13px;
}

.cow-stats,
.mini-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.stat,
.empty-block {
    padding: 10px;
    border-radius: 8px;
    background: #f4faf5;
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.stat strong {
    display: block;
    margin-top: 3px;
}

.empty-block {
    min-height: 120px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    color: var(--muted);
    text-align: center;
}

.loading-block {
    min-height: 120px;
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #f4faf5;
    color: var(--muted);
    text-align: center;
}

.loading-block strong {
    font-size: 14px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #d7e5da;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.skeleton-card,
.skeleton-row {
    overflow: hidden;
    position: relative;
}

.skeleton-card::after,
.skeleton-row::after,
.skeleton-media::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .68), transparent);
    animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-card i,
.skeleton-card span,
.skeleton-row i,
.skeleton-row span {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: #dfece2;
}

.skeleton-card i,
.skeleton-row i {
    width: 58%;
}

.skeleton-card span,
.skeleton-row span {
    width: 82%;
}

.skeleton-media {
    position: relative;
    background: #dfece2;
}

.skeleton-row {
    display: grid;
    gap: 10px;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.cow-detail-button {
    width: 100%;
}

.cow-card-general .cow-media {
    height: 128px;
}

.cow-card-general .soft-badge {
    width: fit-content;
    background: #eef3f8;
    color: #425466;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
}

.modal.is-open {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 34, 23, 0.45);
}

.modal-panel {
    position: relative;
    width: min(920px, calc(100% - 28px));
    max-height: calc(100vh - 32px);
    margin: 16px auto;
    overflow: auto;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(20, 34, 23, 0.28);
}

.modal-head,
.detail-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.modal-head p,
.modal-head h2,
.detail-note p,
.detail-split h3 {
    margin: 0;
}

.modal-head p {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.detail-body,
.detail-form {
    padding: 18px;
}

.cow-detail-hero {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 16px;
}

.cow-detail-photo {
    width: 100%;
    min-height: 180px;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, #dff1e2, #f7f4ed);
    object-fit: cover;
}

.cow-detail-photo-fallback {
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    font-size: 56px;
    font-weight: 900;
}

.cow-detail-summary {
    display: grid;
    align-content: center;
    gap: 12px;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbf8;
}

.cow-detail-summary > span,
.cow-detail-main-meta span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.cow-detail-summary h3 {
    margin: 0;
    font-size: 34px;
    line-height: 1.08;
    overflow-wrap: anywhere;
}

.cow-detail-main-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cow-detail-main-meta div {
    min-height: 72px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    background: #ffffff;
}

.cow-detail-main-meta strong {
    font-size: 20px;
    overflow-wrap: anywhere;
}

.detail-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 14px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4faf5;
}

.detail-tab {
    min-height: 40px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 900;
}

.detail-tab.is-active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: 0 8px 18px rgba(28, 71, 39, .08);
}

.detail-tab-panel {
    display: none;
}

.detail-tab-panel.is-active {
    display: block;
}

.detail-grid,
.detail-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-cell,
.detail-line,
.detail-note {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbf8;
}

.detail-cell span,
.detail-note span,
.detail-line span,
.detail-form span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.detail-cell strong,
.detail-line strong {
    display: block;
    margin-top: 3px;
}

.detail-note,
.detail-split {
    margin-top: 12px;
}

.detail-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-split section {
    display: grid;
    gap: 8px;
}

.detail-history {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.detail-history h3 {
    margin: 0;
}

.detail-inline-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbf8;
}

.detail-inline-form label {
    display: grid;
    gap: 6px;
}

.detail-inline-form input,
.detail-inline-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
}

.compact-actions {
    padding: 0;
    border: 0;
}

.detail-form label,
.detail-form .form-field {
    display: grid;
    gap: 6px;
}

.detail-form input,
.detail-form select,
.detail-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
}

.beef-weight-form {
    grid-template-columns: minmax(360px, 520px) minmax(180px, 240px);
    align-items: start;
    gap: 14px;
}

.beef-weight-row-list {
    display: grid;
    gap: 6px;
    max-height: 260px;
    overflow: auto;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.beef-weight-cow-field {
    grid-row: span 3;
}

.beef-weight-date-field {
    align-self: start;
}

.detail-form .beef-weight-row {
    width: fit-content;
    max-width: 100%;
    display: inline-grid;
    grid-template-columns: minmax(120px, auto) 86px;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 4px 0;
}

.detail-form .beef-weight-row span {
    color: var(--text);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.detail-form .beef-weight-row input {
    min-height: 34px;
    padding: 7px 9px;
    text-align: right;
}

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

.form-wide {
    grid-column: 1 / -1;
}

.beef-weight-form .form-wide {
    grid-column: 1 / -1;
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.beef-weight-form .detail-actions {
    align-self: end;
    padding-top: 12px;
    flex-wrap: nowrap;
}

.detail-actions .primary-button,
.detail-actions .secondary-button,
.detail-actions .danger-button {
    width: auto;
    min-width: 96px;
    white-space: nowrap;
}

.farm-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 0 0;
    border-top: 1px solid var(--line);
}

.farm-form-actions .primary-button,
.farm-form-actions .secondary-button {
    width: auto;
    min-width: 120px;
}

.permission-hint {
    margin-right: auto;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.danger-button {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: var(--danger);
    color: #ffffff;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 900;
}

.is-hidden {
    display: none !important;
}

.report-bars {
    display: grid;
    gap: 12px;
}

.report-row {
    display: grid;
    gap: 7px;
}

.report-row header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.report-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf4ee;
}

.report-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.profile-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.profile-workspace {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .52), rgba(238, 247, 240, 0) 320px);
}

.profile-workspace .topbar {
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(38, 50, 56, .08);
}

.profile-workspace .topbar p {
    color: #7d6a40;
}

.profile-workspace .topbar h1 {
    color: #1f2b24;
    letter-spacing: 0;
}

.profile-card {
    display: grid;
    gap: 18px;
    position: sticky;
    top: 24px;
    overflow: hidden;
    padding: 22px;
    border-color: #d9e7dd;
    background:
        linear-gradient(180deg, #ffffff 0%, #f8fbf8 100%);
    box-shadow: 0 22px 52px rgba(28, 71, 39, .12);
}

.profile-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), #b98f45, #263238);
}

.profile-card > * {
    position: relative;
}

.profile-card h2,
.profile-card p {
    margin: 0;
}

.profile-card h2 {
    color: #1f2b24;
    font-size: 26px;
    line-height: 1.08;
}

.profile-card p {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 4px solid #ffffff;
    border-radius: 22px;
    background: #e8f4ea;
    color: var(--primary-dark);
    box-shadow: 0 16px 34px rgba(28, 71, 39, .16);
    font-size: 38px;
    font-weight: 900;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-meta,
.profile-form {
    display: grid;
    gap: 12px;
}

.profile-meta {
    margin-top: 2px;
}

.profile-meta .stat {
    min-height: auto;
    padding: 14px;
    border: 1px solid #e0eadf;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: none;
}

.profile-meta .stat span {
    color: #7a8a7d;
    font-size: 11px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.profile-meta .stat strong {
    margin-top: 4px;
    color: #263238;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.profile-layout > .panel:not(.profile-card) {
    padding: 0;
    overflow: hidden;
    border-color: #dfe9e1;
    background: #ffffff;
    box-shadow: 0 18px 46px rgba(38, 50, 56, .08);
}

.profile-layout > .panel:not(.profile-card) .panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin: 0;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
    background: #fbfdfb;
}

.profile-layout > .panel:not(.profile-card) .panel-head .primary-button {
    min-width: 112px;
    margin-left: auto;
}

.profile-layout > .panel:not(.profile-card) .panel-head h2 {
    font-size: 24px;
}

.profile-layout > .panel:not(.profile-card) .panel-head p {
    max-width: 680px;
}

.profile-view {
    display: grid;
    gap: 18px;
    padding: 24px;
}

.profile-view-section {
    display: grid;
    gap: 12px;
}

.profile-view-section h3 {
    margin: 0;
    color: #1f2b24;
    font-size: 18px;
}

.profile-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.profile-view-grid > div,
.profile-address-card {
    display: grid;
    gap: 5px;
    min-height: 78px;
    padding: 16px;
    border: 1px solid #e0eadf;
    border-radius: 8px;
    background: #fbfdfb;
}

.profile-view-grid span,
.profile-address-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.profile-view-grid strong,
.profile-address-card strong {
    color: #263238;
    font-size: 16px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.profile-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.profile-form {
    padding: 24px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    column-gap: 16px;
    row-gap: 14px;
}

.profile-form .wide-field,
.profile-form .profile-form-section,
.profile-form .profile-field-grid,
.profile-form .profile-map-panel,
.profile-form .profile-actions,
.profile-form .member-message {
    grid-column: 1 / -1;
}

.profile-form input,
.profile-form select {
    width: 100%;
    min-width: 0;
    height: 44px;
    border-color: #dbe8de;
    background: #fbfdfb;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.profile-form input:focus,
.profile-form select:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(46, 125, 50, .12);
}

.profile-form-section {
    margin-top: 4px;
    padding: 18px 0 2px;
    border-top: 1px solid var(--line);
}

.profile-form-section h3 {
    margin: 0;
    color: #1f2b24;
    font-size: 18px;
}

.profile-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.profile-actions {
    display: grid;
    grid-template-columns: minmax(180px, .42fr) minmax(150px, .28fr);
    gap: 12px;
    align-items: center;
    padding-top: 8px;
}

.profile-map-panel {
    display: grid;
    gap: 12px;
    margin-top: 4px;
    padding: 16px;
    border: 1px solid #e0eadf;
    border-radius: 8px;
    background: #fbfdfb;
}

.profile-map-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.profile-map-head h3,
.profile-map-head p {
    margin: 0;
}

.profile-map-head h3 {
    color: #1f2b24;
    font-size: 18px;
}

.profile-map-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

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

.profile-map {
    min-height: 280px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef7f0;
}

.member-message {
    min-height: 20px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.member-message.error {
    color: var(--danger);
}

.member-message.ok {
    color: var(--success);
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, #f5faf4 0%, #edf6f1 52%, #f8f1e6 100%);
}

.login-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(420px, 1.08fr) minmax(390px, .72fr);
    isolation: isolate;
}

.login-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    align-content: start;
    gap: clamp(34px, 8vh, 84px);
    min-height: 100vh;
    padding: 42px 48px 48px;
    background:
        linear-gradient(90deg, rgba(14, 38, 26, .86) 0%, rgba(14, 38, 26, .64) 45%, rgba(14, 38, 26, .2) 100%),
        linear-gradient(180deg, rgba(14, 38, 26, .05), rgba(14, 38, 26, .58)),
        url("../images/login-hero.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    color: #ffffff;
}

.login-hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 34%;
    background: linear-gradient(180deg, transparent, rgba(14, 38, 26, .7));
    pointer-events: none;
}

.login-brand {
    position: relative;
    z-index: 1;
    width: fit-content;
    color: #ffffff;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    backdrop-filter: blur(10px);
}

.login-copy {
    position: relative;
    z-index: 1;
    max-width: 680px;
}

.login-copy p,
.login-copy h1,
.login-copy span,
.login-panel h2,
.login-panel p {
    margin: 0;
}

.login-copy p {
    width: fit-content;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: #e6f4e9;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.login-copy h1 {
    max-width: 760px;
    margin-top: 18px;
    font-size: clamp(42px, 6vw, 76px);
    line-height: .98;
    text-wrap: balance;
    text-shadow: 0 16px 44px rgba(0, 0, 0, .32);
}

.login-copy span {
    display: block;
    max-width: 520px;
    margin-top: 18px;
    color: #e8f5ea;
    font-size: 18px;
    line-height: 1.7;
}

.login-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.login-hero-stats b {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: #ffffff;
    font-size: 13px;
    backdrop-filter: blur(10px);
}

.login-panel {
    position: relative;
    display: grid;
    place-items: center;
    padding: 34px;
}

.login-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .74), rgba(255, 255, 255, .28)),
        repeating-linear-gradient(135deg, rgba(46, 125, 50, .06) 0 1px, transparent 1px 18px);
    z-index: -1;
}

.login-form {
    width: min(440px, 100%);
    display: grid;
    gap: 15px;
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 24px 72px rgba(25, 67, 38, .16);
    backdrop-filter: blur(16px);
}

.login-panel-head {
    margin-bottom: 6px;
}

.login-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: #edf7ef;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
}

.login-panel-head h2 {
    margin-top: 12px;
    font-size: 34px;
    line-height: 1;
}

.login-panel-head p {
    margin-top: 8px;
    color: var(--muted);
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.login-form input:not([type="checkbox"]) {
    height: 48px;
    border-color: #cfded2;
    background: #fbfdfb;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.login-form input:not([type="checkbox"]):focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(46, 125, 50, .13);
}

.login-form .login-remember {
    display: flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
}

.login-form .login-remember input {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    min-width: 14px;
    accent-color: var(--primary);
}

.login-form input:not([type="checkbox"]),
.login-main-button,
.social-button {
    width: 100%;
    min-width: 0;
}

.login-main-button,
.social-button {
    min-height: 48px;
}

.login-main-button {
    margin-top: 2px;
    box-shadow: 0 12px 24px rgba(46, 125, 50, .24);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.login-main-button:hover {
    background: var(--primary-dark);
    box-shadow: 0 16px 28px rgba(46, 125, 50, .28);
    transform: translateY(-1px);
}

.login-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.login-divider::before,
.login-divider::after {
    content: "";
    height: 1px;
    background: var(--line);
}

.social-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid #d7e2da;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.social-button:hover {
    border-color: #b9cbbf;
    box-shadow: 0 10px 24px rgba(38, 50, 56, .08);
    transform: translateY(-1px);
}

.social-button span {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 900;
}

.google-button span {
    background: #db4437;
}

.facebook-button span {
    background: #1877f2;
}

.login-legal-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.login-legal-links a {
    color: var(--primary-dark);
    text-decoration: none;
}

.login-message {
    min-height: 20px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.login-message.error {
    color: var(--danger);
}

.login-message.ok {
    color: var(--success);
}

@media (max-width: 1120px) {
    .app-shell {
        grid-template-columns: 92px minmax(0, 1fr);
    }

    .brand span:last-child,
    .nav a {
        font-size: 0;
    }

    .nav a {
        justify-content: center;
    }

    .nav span::before {
        font-size: 21px;
    }

    .summary-grid,
    .farm-list-summary,
    .task-grid,
    .cow-grid,
    .food-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-layout,
    .module-grid,
    .ai-layout,
    .farm-layout {
        grid-template-columns: 1fr;
    }

    .profile-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .profile-card {
        position: relative;
        top: auto;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        padding: 18px;
    }

    .profile-card .profile-meta {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .profile-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 20px;
    }

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

@media (max-width: 980px) {
    .login-layout {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 440px;
        gap: 34px;
    }

    .login-panel {
        padding: 24px;
    }
}

@media (max-width: 600px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .profile-card {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .profile-avatar {
        width: 108px;
        height: 108px;
        border-radius: 26px;
    }

    .profile-card .profile-meta {
        width: 100%;
        grid-template-columns: 1fr;
        text-align: left;
    }
}

@media (max-width: 1024px) {
    .sync-card {
        left: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
    }

    body {
        background: #f3f8f4;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar,
    aside.sidebar {
        position: sticky;
        isolation: isolate;
        top: 0;
        z-index: 5;
        display: block;
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
        padding: 4px 10px;
        background: #ffffff;
        box-shadow: 0 4px 14px rgba(38, 50, 56, .09);
    }

    .brand {
        display: none;
    }

    .mobile-menu-button {
        width: 100%;
        min-height: 42px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: #f7fbf8;
        color: var(--primary-dark);
        cursor: pointer;
        font-weight: 900;
        padding: 0 12px;
        font-size: 13px;
    }

    .mobile-menu-button::before {
        content: "";
        width: 16px;
        height: 2px;
        border-radius: 999px;
        background: var(--primary);
        box-shadow: 0 -5px 0 var(--primary), 0 5px 0 var(--primary);
    }

    .mobile-menu-button::after {
        content: "";
    }

    .mobile-menu-actions {
        position: absolute;
        top: 4px;
        right: 10px;
        z-index: 6;
        display: flex;
        gap: 6px;
    }

    .mobile-menu-icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: #ffffff;
        color: var(--primary-dark);
        cursor: pointer;
        display: grid;
        place-items: center;
    }

    .mobile-menu-icon .material-symbols-rounded {
        font-size: 20px;
    }

    .mobile-menu-icon img {
        width: 100%;
        height: 100%;
        display: block;
        border-radius: inherit;
        object-fit: cover;
    }

    .mobile-menu-icon.has-profile-photo {
        padding: 2px;
        overflow: hidden;
    }

    .mobile-menu-button[aria-expanded="true"]::before {
        height: 16px;
        background:
            linear-gradient(45deg, transparent 46%, var(--primary) 47% 53%, transparent 54%),
            linear-gradient(-45deg, transparent 46%, var(--primary) 47% 53%, transparent 54%);
        box-shadow: none;
    }

    .nav {
        position: absolute;
        top: calc(100% + 2px);
        left: 10px;
        right: 10px;
        z-index: 30;
        max-height: min(64vh, 420px);
        overflow: auto;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
        box-shadow: 0 20px 48px rgba(38, 50, 56, .16);
        opacity: 0;
        transform: translateY(-8px);
        visibility: hidden;
        pointer-events: none;
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }

    .nav.is-open {
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
        pointer-events: auto;
    }

    .nav a {
        min-height: 66px;
        display: grid;
        justify-items: center;
        align-content: center;
        gap: 4px;
        padding: 6px 4px;
        font-size: 12px;
        line-height: 1.25;
        text-align: center;
    }

    .nav span {
        width: 26px;
        height: 26px;
    }

    .nav span::before {
        font-size: 20px;
    }

    .workspace {
        padding: 4px 12px 22px;
    }

    .topbar,
    .top-actions,
    .section-toolbar {
        display: grid;
        align-items: stretch;
    }

    .topbar {
        position: relative;
        min-height: 0;
        gap: 6px;
        margin-top: 0;
        margin-bottom: 10px;
        justify-content: stretch;
    }

    .topbar > div:first-child {
        display: grid;
        gap: 0;
        padding-right: 0;
    }

    .topbar:has(.profile-link) > div:first-child {
        padding-right: 0;
    }

    .topbar:has(#refreshBtn) > div:first-child {
        padding-right: 148px;
    }

    .topbar p {
        font-size: 11px;
        line-height: 1.2;
    }

    .topbar h1 {
        margin-top: 8px;
        font-size: 25px;
        line-height: 1.12;
    }

    .top-actions {
        grid-template-columns: 1fr auto auto;
        gap: 8px;
        width: 100%;
        justify-content: stretch;
    }

    .search {
        grid-column: 1 / -1;
        gap: 4px;
        width: 100%;
    }

    .search span {
        display: none;
    }

    .search input {
        width: 100%;
        min-width: 0;
        height: 44px;
        border-color: #cbded0;
        background: #ffffff;
        box-shadow: 0 8px 20px rgba(28, 71, 39, .06);
    }

    #refreshBtn {
        position: absolute;
        top: 0;
        right: 48px;
        width: 42px;
        min-width: 42px;
        height: 42px;
        padding: 0;
        z-index: 1;
    }

    #refreshBtn .button-text {
        display: none;
    }

    .topbar .profile-link {
        display: none;
    }

    .topbar .profile-link strong {
        display: none;
    }

    .topbar .profile-link .material-symbols-rounded {
        color: var(--text);
        font-size: 24px;
    }

    .topbar:has(#refreshBtn) .profile-link {
        right: 96px;
    }

    #logoutBtn {
        display: none;
    }

    input,
    select,
    .primary-button,
    .secondary-button {
        width: 100%;
        min-width: 0;
    }

    .compact-button {
        width: auto;
        min-width: 0;
        justify-self: end;
    }

    .summary-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin: 0 0 14px;
        padding: 0;
        overflow: visible;
    }

    .farm-list-summary,
    .farm-card-grid,
    .farm-select-meta {
        grid-template-columns: 1fr;
    }

    .farm-select-card {
        padding: 13px;
    }

    .farm-select-card h3 {
        font-size: 18px;
    }

    .farm-select-card .primary-button {
        width: 100%;
    }

    .summary-card {
        min-width: 0;
        min-height: 104px;
        padding: 13px;
        box-shadow: 0 10px 26px rgba(28, 71, 39, .09);
    }

    .summary-card strong {
        font-size: 28px;
        line-height: 1;
    }

    .summary-card span,
    .summary-card small {
        font-size: 12px;
    }

    .task-grid,
    .cow-grid,
    .food-category-grid,
    .food-stock-row,
    .food-detail-summary,
    .detail-grid,
    .detail-form,
    .detail-split,
    .detail-inline-form {
        grid-template-columns: 1fr;
    }

    .beef-weight-cow-field {
        grid-row: auto;
    }

    .beef-weight-form .form-wide {
        grid-column: 1 / -1;
    }

    .food-stock-row {
        align-items: start;
    }

    .food-status {
        justify-self: start;
    }

    .food-list-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .food-list-actions select {
        width: 100%;
    }

    .dashboard-layout,
    .module-grid,
    .ai-layout,
    .farm-layout {
        gap: 12px;
    }

    .farm-hero {
        display: grid;
        grid-template-columns: 62px minmax(0, 1fr);
        gap: 12px;
        align-items: start;
    }

    .farm-hero h2 {
        font-size: 24px;
    }

    .farm-logo {
        width: 62px;
        height: 62px;
        flex-basis: 62px;
        grid-row: 1 / span 2;
    }

    .farm-hero-copy,
    .farm-badge {
        grid-column: 2;
    }

    .farm-badge {
        min-width: 0;
        padding: 9px 10px;
    }

    .panel {
        padding: 14px;
        overflow: hidden;
        box-shadow: 0 10px 28px rgba(28, 71, 39, .08);
    }

    .panel-head,
    .section-toolbar {
        align-items: start;
        gap: 8px;
        margin-bottom: 12px;
    }

    .panel h2,
    .section-toolbar h2 {
        font-size: 18px;
        line-height: 1.2;
    }

    .panel p {
        margin-top: 3px;
        font-size: 12px;
        line-height: 1.35;
    }

    .item-card {
        min-height: 74px;
        padding: 11px;
    }

    .item-card strong {
        font-size: 14px;
        line-height: 1.35;
    }

    .item-card span {
        font-size: 12px;
        line-height: 1.45;
    }

    body[data-page="alerts"] .section-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 8px;
    }

    body[data-page="alerts"] .section-toolbar .badge {
        min-height: 22px;
        padding: 0 8px;
        font-size: 11px;
    }

    body[data-page="alerts"] #alertList {
        max-height: calc(100dvh - 150px);
        overflow: auto;
        padding-right: 2px;
    }

    body[data-page="alerts"] #alertList .item-card {
        min-height: 0;
        padding: 9px 10px;
        gap: 2px;
    }

    body[data-page="alerts"] #alertList .item-card strong {
        font-size: 13px;
        line-height: 1.25;
    }

    body[data-page="alerts"] #alertList .item-card span {
        font-size: 11.5px;
        line-height: 1.35;
    }

    .task-grid,
    .cow-grid,
    .stack-list {
        gap: 9px;
    }

    .cow-card {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        min-height: 132px;
    }

    .cow-media,
    .cow-card-general .cow-media {
        width: 88px;
        height: 100%;
        min-height: 132px;
        font-size: 24px;
    }

    img.cow-media {
        height: 100%;
    }

    .cow-body {
        gap: 8px;
        padding: 12px;
    }

    .cow-title {
        align-items: start;
    }

    .cow-title h3 {
        min-width: 0;
        font-size: 16px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .badge {
        min-height: 22px;
        padding: 0 7px;
        font-size: 11px;
    }

    .cow-meta {
        font-size: 12px;
        line-height: 1.35;
    }

    .cow-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .cow-stats-general {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat {
        padding: 8px;
    }

    .stat span {
        font-size: 11px;
    }

    .stat strong {
        font-size: 13px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .mini-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    #cowGrid {
        gap: 10px;
    }

    #cowGrid .cow-card-general {
        grid-template-columns: 76px minmax(0, 1fr);
        min-height: 116px;
        border-color: #cfe1d4;
        box-shadow: 0 8px 22px rgba(28, 71, 39, .08);
    }

    #cowGrid .cow-card-general .cow-media {
        width: 76px;
        min-height: 116px;
        height: 100%;
        border-right: 1px solid var(--line);
        font-size: 22px;
    }

    #cowGrid .cow-card-general .cow-body {
        min-width: 0;
        gap: 7px;
        padding: 10px;
    }

    #cowGrid .cow-card-general .cow-title {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    #cowGrid .cow-card-general .cow-title h3 {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    #cowGrid .cow-card-general .cow-title .badge {
        max-width: 88px;
        overflow: hidden;
        justify-self: end;
        text-overflow: ellipsis;
    }

    #cowGrid .cow-card-general .cow-meta {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #cowGrid .cow-card-general .cow-stats-general {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    #cowGrid .cow-card-general .stat {
        min-height: 44px;
        padding: 6px 7px;
    }

    #cowGrid .cow-card-general .stat span {
        font-size: 10.5px;
    }

    #cowGrid .cow-card-general .stat strong {
        overflow: hidden;
        font-size: 12.5px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    #cowGrid .cow-card-general .soft-badge {
        min-height: 20px;
        justify-self: start;
        padding: 0 7px;
    }

    .modal-panel {
        width: calc(100% - 16px);
        max-height: calc(100vh - 16px);
        margin: 8px auto;
    }

    .detail-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .detail-actions .primary-button,
    .detail-actions .secondary-button,
    .detail-actions .danger-button {
        width: auto;
        min-width: 96px;
    }

    .farm-form-actions {
        display: flex;
        flex-direction: row;
        justify-content: flex-end;
    }

    .farm-form-actions .primary-button,
    .farm-form-actions .secondary-button {
        width: auto;
        min-width: 112px;
    }

    .modal-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 40px;
        align-items: start;
        gap: 10px;
    }

    .modal-head .icon-button {
        justify-self: end;
    }

    .modal-head h2 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .cow-detail-hero {
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 10px;
        margin-bottom: 12px;
    }

    .cow-detail-photo {
        min-height: 132px;
    }

    .cow-detail-photo-fallback {
        font-size: 34px;
    }

    .cow-detail-summary {
        gap: 8px;
        padding: 12px;
    }

    .cow-detail-summary h3 {
        font-size: 22px;
    }

    .cow-detail-main-meta {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .cow-detail-main-meta div {
        min-height: 48px;
        padding: 8px;
    }

    .cow-detail-main-meta strong {
        font-size: 15px;
    }

    .detail-tabs {
        margin-bottom: 10px;
    }

    .detail-tab {
        min-height: 38px;
        font-size: 13px;
    }

    .bar-chart {
        height: 210px;
        display: flex;
        align-items: flex-end;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px 2px 0;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .chart-bar {
        flex: 0 0 44px;
        min-width: 44px;
    }

    .bar-chart .empty-block,
    .bar-chart .loading-block {
        flex: 1 0 100%;
    }

    .chart-bar span {
        font-size: 11px;
    }

    .empty-block,
    .loading-block {
        min-height: 96px;
        padding: 14px;
        font-size: 13px;
    }

    .loading-spinner {
        width: 24px;
        height: 24px;
    }

    .login-layout {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 380px;
        gap: 28px;
        padding: 24px;
        background-position: center top;
    }

    .login-copy h1 {
        font-size: 42px;
    }

    .login-copy span {
        font-size: 16px;
    }

    .login-panel {
        padding: 18px;
    }

    .login-form {
        padding: 22px;
    }

    .profile-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .profile-actions .primary-button,
    .profile-actions .secondary-button {
        min-width: 0;
        padding: 0 8px;
        font-size: 12px;
    }

    .profile-map-head {
        display: grid;
    }

    .profile-map-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        justify-content: stretch;
    }

    .profile-map-actions .secondary-button {
        width: 100%;
        min-width: 0;
        padding: 0 8px;
        font-size: 12px;
    }

    .profile-map {
        min-height: 220px;
    }

    .profile-layout > .panel:not(.profile-card) .panel-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .profile-layout > .panel:not(.profile-card) .panel-head .primary-button {
        justify-self: end;
        width: auto;
    }

    .profile-form {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        padding: 18px;
    }

    .profile-field-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .beef-weight-cow-field {
        max-width: none;
    }

    .detail-form .beef-weight-row {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 82px;
    }
}

@media (max-width: 390px) {
    .profile-form,
    .profile-field-grid {
        grid-template-columns: 1fr;
    }

    #cowGrid .cow-card-general {
        grid-template-columns: 68px minmax(0, 1fr);
        min-height: 104px;
    }

    #cowGrid .cow-card-general .cow-media {
        width: 68px;
        min-height: 104px;
    }

    #cowGrid .cow-card-general .cow-stats-general {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #cowGrid .cow-card-general .cow-title .badge {
        max-width: 76px;
    }

    #cowGrid .cow-card-general .stat-secondary {
        display: none;
    }
}
