:root {
  color-scheme: light;
  --forest: #173b2b;
  --forest-2: #23513d;
  --leaf: #d8e9bd;
  --lime: #b8d67f;
  --paper: #f2f5f1;
  --white: #fffefa;
  --ink: #18231c;
  --muted: #718078;
  --line: #e3e7df;
  --orange: #df713d;
  --orange-pale: #f8e8dc;
  --yellow: #f0cf67;
  --red: #c44b3c;
  --red-pale: #f8e4de;
  --blue: #527f8d;
  --blue-pale: #e4eff0;
  --radius: 8px;
  --shadow: 0 14px 46px rgb(25 45 32 / 13%);
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #e4a142; outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .6; }
svg { display: block; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { background: var(--forest); color: white; padding: 25px 16px 18px; display: flex; flex-direction: column; gap: 34px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px 11px 11px 3px; background: var(--lime); color: var(--forest); display: grid; place-items: center; }
.brand-title { font: 600 18px 'Fraunces', Georgia, serif; letter-spacing: 0; }
.brand-sub { display: block; margin-top: 2px; color: #b7c7b9; font: 10px 'DM Mono', monospace; letter-spacing: 0; text-transform: uppercase; }
.nav-label { margin: 0 10px 8px; color: #a8bdad; font: 10px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0; }
.nav-list { display: grid; gap: 4px; }
.nav-button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 6px; text-align: left; color: #cfdbd0; background: transparent; font-size: 13px; font-weight: 600; }
.nav-button:hover { background: #ffffff12; color: white; }
.nav-button.active { color: var(--forest); background: var(--lime); }
.nav-button svg { width: 17px; height: 17px; }
.sidebar-spacer { flex: 1; }
.farm-tag { margin: 0 7px; border-top: 1px solid #ffffff25; padding: 17px 5px 2px; color: #c6d3c8; font-size: 11px; line-height: 1.6; }
.farm-tag strong { display: block; color: #fff; font-weight: 600; }
.main { min-width: 0; padding: 0 34px 50px; }
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--muted); font: 10px 'DM Mono', monospace; letter-spacing: 0; text-transform: uppercase; }
.top-date { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.live-dot { width: 7px; height: 7px; background: #83aa55; border-radius: 50%; box-shadow: 0 0 0 3px #83aa5522; }
.user-tools { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 12px; font-weight: 600; padding-right: 9px; }
.role-label { margin-left: 5px; color: var(--muted); font-weight: 400; text-transform: capitalize; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--white); }
.icon-button:hover { background: #ebefe8; }
.icon-button svg { width: 16px; height: 16px; }
.mobile-brand, .mobile-nav { display: none; }
.page { max-width: 1320px; margin: 0 auto; }
.farm-switcher { display: flex; align-items: center; justify-content: flex-end; gap: 11px; padding: 12px 0 0; }
.farm-switcher .segmented button { min-width: 86px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 29px 0 20px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font: 500 clamp(26px, 3vw, 38px) 'Fraunces', Georgia, serif; letter-spacing: 0; }
.subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; align-items: center; gap: 9px; }
.button { display: inline-flex; min-height: 39px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 5px; padding: 0 13px; font-size: 12px; font-weight: 700; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--forest); color: #fff; }
.button-primary:hover { background: var(--forest-2); }
.button-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.button-secondary:hover { background: #eff1e9; }
.button svg { width: 15px; height: 15px; }
.segmented { display: inline-flex; align-items: center; padding: 3px; gap: 2px; background: #e8ebe2; border-radius: 6px; }
.segmented button { border: 0; border-radius: 4px; background: transparent; color: var(--muted); padding: 7px 11px; font-size: 11px; font-weight: 700; }
.segmented button.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 4px #17251b15; }
.language-switch { flex: 0 0 auto; }
.language-switch button { min-width: 29px; padding: 6px 8px; font: 500 10px 'DM Mono', monospace; }
.view-switch { display: flex; align-items: center; gap: 11px; }
.view-switch > span { color: var(--muted); font-size: 11px; }
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(210px, .7fr); gap: 25px; padding: 24px 26px; color: white; background: var(--forest); border-radius: var(--radius); }
.hero::after { content: ''; position: absolute; width: 190px; height: 190px; border: 1px solid #c5dfad35; border-radius: 50%; right: 15%; top: -132px; box-shadow: 0 0 0 21px #c5dfad0c, 0 0 0 44px #c5dfad0c; pointer-events: none; }
.hero-label { color: #bdceb9; font: 10px 'DM Mono', monospace; text-transform: uppercase; }
.hero-amount { margin: 10px 0 6px; font: 500 39px 'Fraunces', Georgia, serif; letter-spacing: 0; }
.hero-caption { margin: 0; color: #d0dbd0; font-size: 12px; }
.hero-projection { align-self: center; z-index: 1; padding-left: 24px; border-left: 1px solid #ffffff31; }
.hero-projection strong { display: block; margin: 6px 0 4px; font: 500 24px 'Fraunces', Georgia, serif; }
.positive { color: var(--lime); }
.negative { color: #ffb39c; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.metric { min-width: 0; padding: 15px 16px 13px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 6px; color: var(--forest); background: #e8efdd; }
.metric-icon.orange { color: #a54b28; background: var(--orange-pale); }
.metric-icon.yellow { color: #735d1c; background: #f8f0d6; }
.metric-icon.blue { color: #3d6674; background: var(--blue-pale); }
.metric-icon svg { width: 14px; height: 14px; }
.metric-value { overflow: hidden; margin: 12px 0 3px; font: 500 26px 'Fraunces', Georgia, serif; white-space: nowrap; text-overflow: ellipsis; }
.metric-foot { color: var(--muted); font-size: 10px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr); gap: 14px; margin-top: 15px; }
.panel { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px 13px; }
.panel-title { margin: 0; font: 500 17px 'Fraunces', Georgia, serif; letter-spacing: 0; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 0 18px 17px; }
.chart { height: 174px; display: flex; align-items: stretch; gap: 8px; border-bottom: 1px solid var(--line); padding: 13px 0 0; }
.chart-column { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.chart-bars { width: 100%; height: 125px; display: flex; align-items: end; justify-content: center; gap: 4px; }
.chart-bar { width: min(26px, 35%); min-height: 2px; border-radius: 3px 3px 0 0; background: var(--forest-2); animation: rise .45s ease both; transform-origin: bottom; }
.chart-bar.secondary { background: var(--yellow); }
.chart-label { padding-bottom: 8px; color: var(--muted); font: 9px 'DM Mono', monospace; }
.legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--forest-2); }
.legend i.secondary { background: var(--yellow); }
.activity-list, .alert-list, .pig-list, .team-list { display: grid; }
.activity-row, .alert-row, .pig-row, .team-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child, .alert-row:last-child, .pig-row:last-child, .team-row:last-child { border: 0; }
.row-main { min-width: 0; }
.row-title { overflow: hidden; margin: 0; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.row-value { flex: 0 0 auto; font: 500 13px 'DM Mono', monospace; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 4px; background: #e8efdd; color: var(--forest); font-size: 9px; font-weight: 700; white-space: nowrap; }
.pill.warning { background: #f8edcf; color: #735d1c; }
.pill.danger { background: var(--red-pale); color: #9f3d31; }
.pill.blue { background: var(--blue-pale); color: #3d6674; }
.pill.dot::before { content: ''; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 8px 0 14px; }
.section-title { margin: 0; font: 500 24px 'Fraunces', Georgia, serif; }
.insights-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 15px 0; }
.insight { padding: 15px; border: 1px solid var(--line); border-left: 3px solid var(--yellow); border-radius: var(--radius); background: var(--white); }
.insight.warning { border-left-color: var(--orange); }
.insight.info { border-left-color: var(--blue); }
.insight-title { margin: 8px 0 4px; font-size: 12px; font-weight: 700; }
.insight-copy { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); font: 10px 'DM Mono', monospace; text-transform: uppercase; }
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 24px 10px; text-align: center; color: var(--muted); font-size: 11px; }
.empty strong { display: block; margin-bottom: 5px; color: var(--ink); font: 500 16px 'Fraunces', Georgia, serif; }
.finance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 15px; }
.finance-box { padding: 14px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.finance-box strong { display: block; margin: 7px 0 3px; font: 500 19px 'Fraunces', Georgia, serif; }
.flock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pig-row { justify-content: flex-start; }
.pig-id { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 50%; background: #f1e9dc; color: #735d3b; font: 10px 'DM Mono', monospace; }
.pig-detail { flex: 1; min-width: 0; }
.pig-row .button { min-height: 30px; padding: 0 8px; font-size: 10px; }
.page-foot { padding: 22px 0 0; color: var(--muted); font-size: 10px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 25px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; background: var(--forest); color: white; padding: 11px 17px; border-radius: 6px; box-shadow: var(--shadow); font-size: 12px; transition: .22s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.dialog { width: min(510px, calc(100vw - 24px)); max-height: min(86vh, 760px); padding: 0; border: 0; border-radius: 9px; box-shadow: var(--shadow); background: var(--white); color: var(--ink); }
.dialog::backdrop { background: #1021178c; backdrop-filter: blur(2px); }
.dialog-inner { padding: 21px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 17px; }
.dialog-head h2 { margin: 0 0 4px; font: 500 23px 'Fraunces', Georgia, serif; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 11px; }
.close-button { border: 0; background: transparent; padding: 4px; color: var(--muted); }
.close-button svg { width: 19px; height: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 10px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 39px; padding: 9px 10px; border: 1px solid #d7ddd5; border-radius: 5px; background: white; color: var(--ink); font-size: 12px; }
.field textarea { min-height: 68px; resize: vertical; }
.form-actions { display: flex; justify-content: end; gap: 8px; margin-top: 17px; }
.form-error { min-height: 15px; margin: 9px 0 0; color: var(--red); font-size: 11px; }
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); background: var(--paper); }
.auth-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 40px; color: white; background: var(--forest); }
.auth-visual::before { content: ''; position: absolute; inset: 0; opacity: .2; background: repeating-linear-gradient(135deg, transparent 0 28px, #d7e4d1 29px 30px, transparent 31px 57px); mask-image: linear-gradient(120deg, #000, transparent 80%); }
.auth-visual > * { position: relative; }
.auth-visual h1 { max-width: 560px; margin: 0 0 16px; font-size: clamp(44px, 6vw, 76px); line-height: 1.02; }
.auth-visual p { max-width: 420px; color: #d1ded2; font-size: 14px; line-height: 1.7; }
.auth-note { color: #c4d2c7; font: 10px 'DM Mono', monospace; }
.auth-card-wrap { display: grid; place-items: center; padding: 30px; }
.auth-card { width: min(390px, 100%); }
.auth-card .language-switch { width: max-content; margin-bottom: 19px; }
.auth-card h2 { margin: 0 0 6px; font: 500 30px 'Fraunces', Georgia, serif; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .button { width: 100%; margin-top: 4px; }
.auth-error { min-height: 18px; margin-top: 9px; color: var(--red); font-size: 11px; }
@keyframes rise { from { transform: scaleY(.15); opacity: .4; } to { transform: scaleY(1); opacity: 1; } }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 204px minmax(0,1fr); }
  .main { padding: 0 22px 42px; }
  .content-grid { grid-template-columns: minmax(0,1.1fr) minmax(250px,.9fr); }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { padding: 0 15px 35px; }
  .topbar { min-height: 59px; }
  .top-date { font-size: 10px; }
  .user-name { max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .user-tools { gap: 5px; }
  .user-tools .language-switch button { min-width: 25px; padding: 5px 6px; }
  .role-label { display: none; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font: 600 16px 'Fraunces', Georgia, serif; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; border-radius: 8px 8px 8px 3px; }
  .mobile-brand svg { width: 16px; height: 16px; }
  .mobile-nav { position: fixed; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); left: 0; right: 0; bottom: 0; min-height: 62px; padding: 4px 7px calc(4px + env(safe-area-inset-bottom)); background: #fffefaed; border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
  .mobile-nav .nav-button { min-height: 52px; flex-direction: column; justify-content: center; gap: 3px; padding: 3px 2px; border-radius: 5px; color: var(--muted); font-size: 9px; }
  .mobile-nav .nav-button.active { color: var(--forest); background: #e8efdd; }
  .mobile-nav .nav-button svg { width: 18px; height: 18px; }
  .page-heading { align-items: start; padding: 22px 0 14px; }
  .farm-switcher { align-items: flex-start; flex-direction: column; gap: 6px; }
  .farm-switcher .segmented { width: 100%; }
  .farm-switcher .segmented button { flex: 1; min-width: 0; padding-right: 5px; padding-left: 5px; }
  h1 { font-size: 29px; }
  .subtitle { font-size: 11px; }
  .heading-actions { align-items: end; flex-direction: column-reverse; }
  .heading-actions .button { min-height: 35px; font-size: 10px; }
  .heading-actions .view-switch { gap: 0; }
  .view-switch > span { display: none; }
  .segmented button { padding: 6px 8px; font-size: 9px; }
  .hero { grid-template-columns: 1fr auto; gap: 14px; padding: 19px 17px; }
  .hero-amount { font-size: 31px; }
  .hero-projection { padding-left: 14px; }
  .hero-projection strong { font-size: 19px; }
  .hero-label { font-size: 9px; }
  .hero-caption { font-size: 10px; }
  .metric-grid { gap: 7px; margin-top: 7px; }
  .metric { padding: 12px; }
  .metric-value { margin: 9px 0 2px; font-size: 22px; }
  .metric-label { font-size: 10px; }
  .metric-foot { font-size: 9px; }
  .content-grid, .flock-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
  .panel-header { padding: 14px 14px 10px; }
  .panel-body { padding: 0 14px 13px; }
  .chart { height: 156px; }
  .chart-bars { height: 108px; }
  .section-title { font-size: 21px; }
  .insights-grid { grid-template-columns: 1fr; gap: 7px; }
  .insight { padding: 12px; }
  .finance-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .finance-box { padding: 12px; }
  .auth-page { display: block; }
  .auth-visual { min-height: 220px; padding: 22px; }
  .auth-visual h1 { font-size: 38px; }
  .auth-visual p { font-size: 11px; margin-bottom: 0; }
  .auth-note { margin-top: 20px; }
  .auth-card-wrap { padding: 34px 23px; }
}
@media (max-width: 390px) {
  .main { padding-right: 11px; padding-left: 11px; }
  .hero { grid-template-columns: 1fr; }
  .hero-projection { display: grid; grid-template-columns: 1fr; gap: 5px; border-left: 0; border-top: 1px solid #ffffff31; padding: 10px 0 0; }
  .hero-projection strong { margin: 0; font-size: 21px; white-space: nowrap; }
  .top-date .eyebrow { display: none; }
  .user-name { max-width: 70px; }
  .metric-icon { width: 23px; height: 23px; }
  .metric-value { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

.sync-bar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 14px; background: #f8edcf; color: #735d1c; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.sync-bar[hidden] { display: none; }
.sync-bar-offline { background: var(--forest); color: white; }
.sync-bar-alert { background: var(--red-pale); color: #9f3d31; }
.sync-bar-actions { display: flex; gap: 6px; }
.sync-bar-actions .button { min-height: 30px; padding: 0 10px; font-size: 11px; }
