/* ==========================================================================
   Stanley Farm and Ranch · Livestock Ops
   Premium dark ranch dashboard — charcoal, gold, glass
   ========================================================================== */

:root {
  --bg-deep: #0b0d11;
  --bg: #10141b;
  --bg-elev: #161b24;
  --bg-elev-2: #1c2330;
  --bg-hover: #222b3a;
  --border: rgba(232, 195, 106, 0.1);
  --border-strong: rgba(232, 195, 106, 0.22);
  --border-subtle: rgba(255, 255, 255, 0.06);

  --text: #eef1f6;
  --text-muted: #9aa3b5;
  --text-dim: #6b7488;

  --gold: #e8c36a;
  --gold-soft: #c9942e;
  --gold-glow: rgba(232, 195, 106, 0.18);
  --gold-dim: rgba(232, 195, 106, 0.08);

  --green: #5ecf8e;
  --green-dim: rgba(94, 207, 142, 0.12);
  --red: #f07178;
  --red-dim: rgba(240, 113, 120, 0.12);
  --blue: #6eb5ff;
  --blue-dim: rgba(110, 181, 255, 0.12);
  --purple: #b794f6;
  --purple-dim: rgba(183, 148, 246, 0.12);
  --orange: #f0a35e;
  --orange-dim: rgba(240, 163, 94, 0.12);
  --teal: #4fd1c5;
  --teal-dim: rgba(79, 209, 197, 0.12);

  --radius: 1rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.5rem;
  --radius-sm: 0.5rem;
  --radius-pill: 999px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --glass: linear-gradient(145deg, rgba(28, 35, 48, 0.72), rgba(16, 20, 27, 0.85));
  --blur: blur(18px);

  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;

  --topbar-h: 5rem;
  --drawer-w: min(440px, 100vw);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --max: 1280px;

  /* Species palette */
  --sp-BOV: #e8c36a;
  --sp-CAP: #5ecf8e;
  --sp-OVI: #6eb5ff;
  --sp-AVI: #f0a35e;
  --sp-EQU: #b794f6;
  --sp-SUI: #f07178;
  --sp-CAM: #4fd1c5;
  --sp-TUR: #c4a484;
}

/* Reset / base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 1.5rem); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: #f5d78a; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

/* Ambient background */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(232, 195, 106, 0.09), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(94, 207, 142, 0.05), transparent 45%),
    radial-gradient(ellipse 50% 50% at 50% 100%, rgba(110, 181, 255, 0.04), transparent 50%),
    var(--bg-deep);
  pointer-events: none;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 13, 17, 0.78);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  flex-shrink: 0;
}
.brand-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(232, 195, 106, 0.45);
  box-shadow:
    0 0 0 2px rgba(232, 195, 106, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 20px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.brand-mark-lg {
  width: 56px;
  height: 56px;
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 3px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; gap: 0.05rem; }
.brand-kicker {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold, #e8c36a);
}
.brand-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  color: var(--text);
  line-height: 1.15;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Hero brand panel */
.hero-brand {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem 1.75rem;
  align-items: center;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.35rem;
  background:
    linear-gradient(135deg, rgba(232, 195, 106, 0.1), rgba(255, 255, 255, 0.02) 45%, transparent),
    rgba(16, 18, 24, 0.55);
  border: 1px solid rgba(232, 195, 106, 0.22);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.hero-brand-mark {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(232, 195, 106, 0.55);
  box-shadow:
    0 0 0 6px rgba(232, 195, 106, 0.08),
    0 8px 28px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(232, 195, 106, 0.18);
  overflow: hidden;
  flex-shrink: 0;
}
.hero-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 6px;
}
.hero-brand-copy { min-width: 0; }
.hero-brand-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold, #e8c36a);
}
.hero-brand-title {
  margin: 0 0 0.4rem;
}
.hero-brand-tag {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.hero-brand-actions {
  align-self: start;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.nav-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-tab.is-active {
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  box-shadow: 0 2px 12px var(--gold-glow);
}

.topbar-meta { flex-shrink: 0; }
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 3px rgba(107, 116, 136, 0.2);
}
.sync-pill.is-static .sync-dot {
  background: #e8c36a;
  box-shadow: 0 0 8px rgba(232, 195, 106, 0.7);
}
.sync-pill.is-live .sync-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
  animation: pulse-dot 2.4s ease infinite;
}
.sync-pill.is-error .sync-dot {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Main */
.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Error */
.error-banner {
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 113, 120, 0.35);
  background: linear-gradient(135deg, rgba(240, 113, 120, 0.12), rgba(240, 113, 120, 0.04));
  padding: 1rem 1.25rem;
}
.error-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  font-size: 0.9rem;
}
.error-banner code {
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: var(--gold);
}

/* Sections */
.section {
  margin-bottom: 3.5rem;
  scroll-margin-top: calc(var(--topbar-h) + 1.5rem);
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
}
.section-title {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.section-title.display {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.section-desc {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.section-actions { display: flex; gap: 0.5rem; }
.herd-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--bg-elev);
  border-color: var(--border-subtle);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Glass cards */
.glass-card {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
}
.card-head { margin-bottom: 1.1rem; }
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-sub {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--glass);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--kpi-accent, var(--gold)), transparent);
  opacity: 0.7;
}
.kpi-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.kpi-value {
  font-family: var(--serif);
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
}
.kpi-hint {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.kpi-card.accent-gold { --kpi-accent: var(--gold); }
.kpi-card.accent-green { --kpi-accent: var(--green); }
.kpi-card.accent-blue { --kpi-accent: var(--blue); }
.kpi-card.accent-muted { --kpi-accent: var(--text-dim); }

/* Overview grid */
.overview-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
}
.species-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
  align-items: center;
}
.chart-wrap {
  position: relative;
  width: 160px;
  height: 160px;
}
.species-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.species-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.875rem;
}
.species-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.species-bar-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.species-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.6s var(--ease);
}
.species-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2ch;
  text-align: right;
}

.quick-glance { display: flex; flex-direction: column; gap: 0.65rem; }
.glance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  transition: background 0.2s, border-color 0.2s;
}
.glance-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}
.glance-left { min-width: 0; }
.glance-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.glance-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}
.glance-val {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--gold);
  white-space: nowrap;
}

/* Filters */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  margin-bottom: 1rem;
  align-items: flex-end;
  padding: 1rem 1.25rem;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 140px; }
.field-grow { flex: 1; min-width: 200px; }
.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.input {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:hover { border-color: rgba(255, 255, 255, 0.12); }
.input:focus {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.input::placeholder { color: var(--text-dim); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3b5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.view-toggle {
  display: inline-flex;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-deep);
}
.view-btn {
  padding: 0.5rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.view-btn:hover { color: var(--text); }
.view-btn.is-active {
  background: var(--gold-dim);
  color: var(--gold);
}

/* Table */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  padding: 0.85rem 1.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}
.data-table th.num { text-align: right; }
.data-table td {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  vertical-align: middle;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.data-table tbody tr:hover { background: rgba(232, 195, 106, 0.05); }
.data-table tbody tr:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.animal-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cell-muted { color: var(--text-muted); font-size: 0.85rem; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-active {
  color: var(--green);
  background: var(--green-dim);
  border-color: rgba(94, 207, 142, 0.25);
}
.badge-inactive {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}
.badge-event {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Species chips */
.sp-BOV { color: var(--sp-BOV); background: rgba(232, 195, 106, 0.12); border-color: rgba(232, 195, 106, 0.25); }
.sp-CAP { color: var(--sp-CAP); background: rgba(94, 207, 142, 0.12); border-color: rgba(94, 207, 142, 0.25); }
.sp-OVI { color: var(--sp-OVI); background: rgba(110, 181, 255, 0.12); border-color: rgba(110, 181, 255, 0.25); }
.sp-AVI { color: var(--sp-AVI); background: rgba(240, 163, 94, 0.12); border-color: rgba(240, 163, 94, 0.25); }
.sp-EQU { color: var(--sp-EQU); background: rgba(183, 148, 246, 0.12); border-color: rgba(183, 148, 246, 0.25); }
.sp-SUI { color: var(--sp-SUI); background: rgba(240, 113, 120, 0.12); border-color: rgba(240, 113, 120, 0.25); }
.sp-CAM { color: var(--sp-CAM); background: rgba(79, 209, 197, 0.12); border-color: rgba(79, 209, 197, 0.25); }
.sp-TUR { color: var(--sp-TUR); background: rgba(196, 164, 132, 0.12); border-color: rgba(196, 164, 132, 0.25); }

/* Herd cards view */
.herd-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
  padding: 1.15rem;
}
.herd-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s var(--ease), background 0.2s;
}
.herd-card:hover {
  border-color: var(--border-strong);
  background: rgba(232, 195, 106, 0.04);
  transform: translateY(-2px);
}
.herd-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.herd-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.herd-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* Paddock board */
.paddock-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.paddock-col {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  background: var(--glass);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  transition: border-color 0.25s;
}
.paddock-col:hover { border-color: var(--border); }
.paddock-col-head {
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
}
.paddock-name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.paddock-stats {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.75rem;
}
.paddock-animals {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.paddock-animal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
  width: 100%;
}
.paddock-animal:hover {
  background: rgba(232, 195, 106, 0.06);
  border-color: var(--border);
}
.paddock-animal:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
.pa-name { font-weight: 500; font-size: 0.85rem; }
.pa-meta { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.1rem; }
.paddock-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 1px;
  background: linear-gradient(180deg, var(--border-strong), transparent);
}
.timeline-item {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.85rem;
  padding: 0.65rem 0.25rem;
  position: relative;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0.4rem auto 0;
  background: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-dim);
  z-index: 1;
}
.timeline-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.timeline-item:hover .timeline-body {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--border-subtle);
}
.timeline-main { min-width: 0; flex: 1; }
.timeline-summary {
  font-size: 0.9rem;
  color: var(--text);
}
.timeline-animal {
  color: var(--gold);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}
.timeline-animal:hover { text-decoration: underline; }
.timeline-animal:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}
.timeline-date {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Event type colors */
.ev-AHTR { --ev: var(--red); background: var(--red-dim); border-color: rgba(240, 113, 120, 0.3); color: var(--red); }
.ev-AMWE { --ev: var(--blue); background: var(--blue-dim); border-color: rgba(110, 181, 255, 0.3); color: var(--blue); }
.ev-ALMO { --ev: var(--teal); background: var(--teal-dim); border-color: rgba(79, 209, 197, 0.3); color: var(--teal); }
.ev-ALBI { --ev: var(--green); background: var(--green-dim); border-color: rgba(94, 207, 142, 0.3); color: var(--green); }
.ev-ALSA { --ev: var(--orange); background: var(--orange-dim); border-color: rgba(240, 163, 94, 0.3); color: var(--orange); }
.ev-AANO { --ev: var(--purple); background: var(--purple-dim); border-color: rgba(183, 148, 246, 0.3); color: var(--purple); }
.ev-ALPU { --ev: var(--gold); background: var(--gold-dim); border-color: rgba(232, 195, 106, 0.3); color: var(--gold); }
.ev-ALDE { --ev: var(--text-muted); background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: var(--text-muted); }
.ev-default { --ev: var(--text-muted); background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: var(--text-muted); }
.timeline-dot.ev-AHTR { background: var(--red); box-shadow: 0 0 0 4px var(--red-dim); }
.timeline-dot.ev-AMWE { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-dim); }
.timeline-dot.ev-ALMO { background: var(--teal); box-shadow: 0 0 0 4px var(--teal-dim); }
.timeline-dot.ev-ALBI { background: var(--green); box-shadow: 0 0 0 4px var(--green-dim); }
.timeline-dot.ev-ALSA { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-dim); }
.timeline-dot.ev-AANO { background: var(--purple); box-shadow: 0 0 0 4px var(--purple-dim); }
.timeline-dot.ev-ALPU { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-dim); }

/* Treatments / products */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.list-dense {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 420px;
  overflow-y: auto;
}
.list-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 0.15s, background 0.15s;
}
.list-row:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.list-row-main { min-width: 0; flex: 1; }
.list-row-title {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row-sub {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.35;
}
.list-row-side {
  text-align: right;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.product-type {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.15rem;
}
.product-qty {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--text);
}
.product-qty.neg { color: var(--red); }

/* Footer */
.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.footer-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  padding: 3px;
  border: 1px solid rgba(232, 195, 106, 0.35);
  box-shadow: 0 0 12px rgba(232, 195, 106, 0.15);
}
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem 2rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}
.footer-meta {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.72rem;
  opacity: 0.85;
  word-break: break-all;
}

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.drawer-backdrop.is-open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  width: var(--drawer-w);
  background: linear-gradient(180deg, #141922 0%, #0e1218 100%);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.35s var(--ease);
  outline: none;
}
.drawer.is-open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.35rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-title {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.drawer-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tab {
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.drawer-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.drawer-tab.is-active {
  color: var(--gold);
  background: var(--gold-dim);
}
.drawer-tab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1.35rem 2rem;
}
.drawer-panel { display: none; }
.drawer-panel.is-active { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.detail-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}
.detail-item.full { grid-column: 1 / -1; }
.detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.detail-value {
  font-size: 0.92rem;
  font-weight: 500;
  word-break: break-word;
}
.detail-value.muted { color: var(--text-muted); font-weight: 400; }

.drawer-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 1.25rem 0 0.65rem;
}

.weight-chart-wrap {
  position: relative;
  height: 160px;
  margin-bottom: 1rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.drawer-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.drawer-list-item {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.875rem;
}
.drawer-list-item .dli-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.drawer-list-item .dli-date {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.drawer-list-item .dli-body { color: var(--text-muted); font-size: 0.82rem; }
.drawer-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Skeletons */
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skel-lg { height: 2.2rem; width: 55%; margin-bottom: 0.5rem; }
.skel-sm { height: 0.85rem; width: 35%; }
.skel-row { height: 1.1rem; width: 100%; margin: 0.35rem 0; }
.skeleton-card { min-height: 100px; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scrollbars */
.timeline::-webkit-scrollbar,
.list-dense::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.timeline::-webkit-scrollbar-thumb,
.list-dense::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
  .split-grid { grid-template-columns: 1fr; }
  .brand-title { max-width: 160px; font-size: 1.05rem; }
  .hero-brand { grid-template-columns: auto 1fr; }
  .hero-brand-actions { grid-column: 1 / -1; justify-self: start; }
  .hero-brand-mark { width: 96px; height: 96px; }
}

@media (max-width: 768px) {
  .topbar-inner { padding: 0 1rem; gap: 0.75rem; }
  .nav-tabs { justify-content: flex-start; }
  .main { padding: 1.25rem 1rem 3rem; }
  .section-title.display { font-size: 2rem; }
  .species-layout { grid-template-columns: 1fr; justify-items: center; }
  .kpi-value { font-size: 2rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar-meta { display: none; }
  .brand-kicker { display: none; }
  .brand-mark-lg { width: 48px; height: 48px; }
  .hero-brand {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
  .hero-brand-mark { width: 110px; height: 110px; }
  .hero-brand-actions { justify-self: center; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .field, .field-grow { min-width: 0; width: 100%; }
}

/* ---------- Analytics / ADG ---------- */
.analytics-strip { margin-top: 1.25rem; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.adg-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin: 0.75rem 0 1rem;
}
.adg-kpi {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}
.adg-kpi.tone-gold { border-color: rgba(232,195,106,0.28); box-shadow: inset 0 0 0 1px rgba(232,195,106,0.06); }
.adg-kpi.tone-green { border-color: rgba(94,207,142,0.25); }
.adg-kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.adg-kpi-value {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.65rem;
  color: var(--text);
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}
.adg-kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

.insight-rail, .insights-list {
  display: grid;
  gap: 0.75rem;
}
.insight-rail { grid-template-columns: repeat(3, 1fr); }
.insights-list { grid-template-columns: 1fr; }
.insight-card {
  background: rgba(12,14,18,0.45);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  border-left: 3px solid rgba(232,195,106,0.55);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.insight-card[data-action] { cursor: pointer; }
.insight-card[data-action]:hover { transform: translateY(-1px); border-color: rgba(232,195,106,0.35); }
.insight-card.sev-high { border-left-color: #f07178; }
.insight-card.sev-medium { border-left-color: #f0a35e; }
.insight-card.sev-positive { border-left-color: #5ecf8e; }
.insight-card.sev-info { border-left-color: #6eb5ff; }
.insight-sev {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}
.insight-title { font-size: 0.98rem; font-weight: 600; margin: 0 0 0.35rem; color: var(--text); }
.insight-body { font-size: 0.84rem; color: var(--text-muted); margin: 0; line-height: 1.45; }
.insight-cat {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}
.analytics-grid-2 { grid-template-columns: 1fr 1fr; }
.chart-wrap-md { height: 220px; position: relative; margin-bottom: 0.75rem; }

.rank-list { display: flex; flex-direction: column; gap: 0.4rem; }
.rank-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.rank-row:hover { background: rgba(232,195,106,0.08); border-color: rgba(232,195,106,0.22); }
.rank-num {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.15rem;
  color: var(--gold, #e8c36a);
  opacity: 0.85;
}
.rank-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.rank-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-adg { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.rank-adg strong { font-variant-numeric: tabular-nums; }

.rate-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.rate-excellent { background: rgba(94,207,142,0.18); color: #7de0b0; }
.rate-on { background: rgba(94,207,142,0.12); color: #5ecf8e; }
.rate-fair { background: rgba(232,195,106,0.14); color: #e8c36a; }
.rate-below { background: rgba(240,163,94,0.16); color: #f0a35e; }
.rate-losing { background: rgba(240,113,120,0.18); color: #f07178; }
.rate-muted { background: rgba(255,255,255,0.06); color: var(--text-dim); }

.mini-table-wrap { overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.mini-table th, .mini-table td { padding: 0.4rem 0.35rem; border-bottom: 1px solid rgba(255,255,255,0.05); text-align: left; }
.mini-table th { color: var(--text-dim); font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.mini-table .num, .data-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.method-note { margin-top: 0.85rem; font-size: 0.75rem; color: var(--text-dim); line-height: 1.4; }

.adg-panel {
  margin-bottom: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(232,195,106,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(232,195,106,0.16);
}
.adg-panel.muted-panel {
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.06);
}
.adg-panel .detail-value.gold { color: #e8c36a; }
.adg-panel .unit { font-size: 0.75rem; color: var(--text-dim); font-weight: 500; }
.adg-bench-note { font-size: 0.75rem; color: var(--text-muted); margin: 0.55rem 0 0; line-height: 1.4; }

@media (max-width: 1024px) {
  .adg-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .insight-rail { grid-template-columns: 1fr; }
  .analytics-grid, .analytics-grid-2 { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
