/* ==========================================================================
   HADDEN PREMIUM BEEF - ADVANCED FEEDLOT OS DESIGN SYSTEM
   Theme: Obsidian & Pasture Emerald Luxe | Ultra-Mobile & Multi-Orientation
   ========================================================================== */

:root {
  --bg-darkest: #050a08;
  --bg-base: #09120e;
  --bg-surface: #0e1c16;
  --bg-surface-elevated: #142720;
  --bg-surface-hover: #1b352b;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-accent: rgba(16, 185, 129, 0.4);

  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-emerald-dark: #064e3b;

  --accent-amber: #f59e0b;
  --accent-amber-light: #fbbf24;
  --accent-amber-glow: rgba(245, 158, 11, 0.22);

  --accent-copper: #ea580c;
  --accent-cyan: #06b6d4;
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.25);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 30px rgba(16, 185, 129, 0.2);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  --dock-height: 60px;
}

/* Base Reset & Core Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-darkest);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.05) 0%, transparent 45%),
    linear-gradient(180deg, #050a08 0%, #09120e 100%);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* App Shell Structure */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==========================================================================
   HERO WELCOME / SPLASH SCREEN
   ========================================================================== */
.welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #040907;
  background-image: 
    radial-gradient(circle at 50% 30%, rgba(16, 185, 129, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #040907 0%, #08140f 100%);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
}

.welcome-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.03);
}

.welcome-ambient-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, transparent 70%);
  pointer-events: none;
  filter: blur(40px);
}

.welcome-card {
  position: relative;
  background: rgba(14, 28, 22, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(16, 185, 129, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: welcomeCardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes welcomeCardEnter {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.bovine-emblem-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emblem-halo {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.35) 0%, transparent 70%);
  animation: pulseAnimation 3s infinite ease-out;
}

.emblem-halo-outer {
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  border: 1px dashed rgba(245, 158, 11, 0.4);
  animation: spinSlow 20s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.bovine-crest-icon {
  width: 90px;
  height: 90px;
  background: linear-gradient(135deg, #0f3d30 0%, #071f18 100%);
  border: 2px solid rgba(16, 185, 129, 0.6);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(16, 185, 129, 0.3);
  position: relative;
  z-index: 2;
}

.bovine-svg {
  width: 66px;
  height: 66px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.welcome-titles {
  margin-bottom: 20px;
}

.welcome-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--accent-amber);
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.welcome-brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  line-height: 1.15;
}

.welcome-brand span {
  color: var(--accent-emerald);
  font-weight: 600;
}

.welcome-tagline {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

.welcome-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 26px;
}

.feat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.feat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.feat-dot.emerald { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.feat-dot.amber { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }
.feat-dot.cyan { background: var(--accent-cyan); box-shadow: 0 0 6px var(--accent-cyan); }
.feat-dot.gold { background: #eab308; box-shadow: 0 0 6px #eab308; }

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-hero-enter {
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #041a12;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
}

.btn-hero-enter:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.6);
}

.btn-hero-enter:active {
  transform: scale(0.98);
}

.btn-hero-enter svg {
  width: 20px;
  height: 20px;
}

.welcome-sub-actions {
  display: flex;
  gap: 10px;
}

.welcome-sub-actions .btn {
  flex: 1;
}

.welcome-footer-note {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 18px;
}

/* ==========================================================================
   TOP COCKPIT BAR / HEADER
   ========================================================================== */
.app-header {
  height: 64px;
  background: rgba(14, 28, 22, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 60;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-nav-toggle svg {
  width: 18px;
  height: 18px;
}

.brand-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-crest {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #134e40, #062d24);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 14px var(--accent-emerald-glow);
  flex-shrink: 0;
}

.crest-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-emerald);
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-emerald);
  opacity: 0.4;
  animation: pulseAnimation 3s infinite ease-out;
}

@keyframes pulseAnimation {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-eyebrow {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-amber);
  text-transform: uppercase;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-name span {
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Quick Search with Autocomplete */
.search-command-bar {
  flex: 1;
  max-width: 400px;
  margin: 0 16px;
  position: relative;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  height: 38px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  padding: 0 85px 0 38px;
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-sans);
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 14px var(--accent-emerald-glow);
}

.shortcut-badge {
  position: absolute;
  right: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  pointer-events: none;
}

/* Autocomplete Dropdown */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #0e1c16;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  padding: 6px;
}

.search-results-dropdown.open {
  display: flex;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-result-item:hover {
  background: var(--bg-surface-elevated);
}

/* Header Right */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-search-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-search-btn svg {
  width: 16px;
  height: 16px;
}

.live-ticker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.28);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.ticker-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.ticker-val {
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Workspace Layout */
.workspace-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
  position: relative;
  width: 100%;
}

/* ==========================================================================
   SIDEBAR DOCK (Desktop: Fixed left bar | Mobile: Drawer modal)
   ========================================================================== */
.sidebar-dock {
  width: 260px;
  background: rgba(10, 19, 16, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 14px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  z-index: 40;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.mobile-drawer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.16) 0%, rgba(16, 185, 129, 0.04) 100%);
  border-color: rgba(16, 185, 129, 0.35);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-emerald);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--text-main);
}

.nav-badge.alert {
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
  border: 1px solid rgba(234, 88, 12, 0.4);
}

.nav-badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weather-widget {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.weather-icon { font-size: 18px; }
.weather-temp { font-size: 11.5px; font-weight: 600; color: #fff; }
.weather-desc { font-size: 9.5px; color: var(--text-dim); }

.system-sync {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  padding: 0 4px;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.mobile-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 70;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-drawer-overlay.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   MAIN VIEWPORT & PANELS
   ========================================================================== */
.main-viewport {
  flex: 1;
  padding: 24px 28px 70px 28px;
  overflow-y: auto;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.view-panel {
  display: none;
  animation: fadeIn 0.22s ease-out;
  width: 100%;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.page-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-emerald);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  line-height: 1.2;
}

.action-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #051912;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border: 1px solid var(--border-medium);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-full { width: 100%; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; }
.btn-sm { padding: 8px 14px; font-size: 12.5px; }
.btn .icon { width: 15px; height: 15px; }

/* ==========================================================================
   KPI CARDS & GLASS PANELS
   ========================================================================== */
.kpi-ribbon {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
}

.kpi-card.accent-emerald::before { background: var(--accent-emerald); }
.kpi-card.accent-amber::before { background: var(--accent-amber); }
.kpi-card.accent-blue::before { background: var(--accent-cyan); }
.kpi-card.accent-gold::before { background: #eab308; }

.kpi-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.accent-emerald .kpi-icon-wrap { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.accent-amber .kpi-icon-wrap { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.accent-blue .kpi-icon-wrap { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); }
.accent-gold .kpi-icon-wrap { background: rgba(234, 179, 8, 0.12); color: #eab308; }

.kpi-icon-wrap svg { width: 20px; height: 20px; }

.kpi-content { display: flex; flex-direction: column; min-width: 0; }
.kpi-title { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-metric { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.kpi-subtext { font-size: 11px; color: var(--text-dim); margin-top: 3px; white-space: nowrap; }
.kpi-trend.positive { color: var(--accent-emerald); font-weight: 600; }

.glass-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-heading { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.card-caption { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Interactive Simulator */
.interactive-sim-card {
  background: linear-gradient(135deg, #0e221b 0%, #0a1813 100%);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 20px;
  align-items: center;
}

.sim-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-surface-elevated);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.sim-control-item { display: flex; flex-direction: column; gap: 6px; }
.sim-control-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.sim-control-label strong { font-family: var(--font-mono); color: var(--accent-emerald); }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-emerald);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-emerald);
}

.sim-results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.sim-result-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.sim-res-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; font-weight: 600; }
.sim-res-val { font-family: var(--font-mono); font-size: 18px; font-weight: 800; color: #fff; margin: 3px 0; }
.sim-res-val.highlight { color: var(--accent-cyan); }
.sim-res-val.warning { color: var(--accent-amber); }
.sim-res-sub { font-size: 10px; color: var(--text-dim); }

/* Pipeline Cards */
.stage-legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend-pill { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border-subtle); white-space: nowrap; }
.legend-pill.starter { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.legend-pill.grower { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.legend-pill.s-finisher { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.legend-pill.finisher { background: rgba(234, 88, 12, 0.16); color: #fb923c; }

.stage-pipeline-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.pipeline-stage-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.pipeline-stage-card:hover { transform: translateY(-2px); border-color: rgba(16, 185, 129, 0.4); }
.pipeline-stage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pipeline-stage-name { font-size: 13.5px; font-weight: 700; color: #fff; }
.pipeline-stage-count { font-family: var(--font-mono); font-size: 26px; font-weight: 800; color: #fff; line-height: 1; margin-bottom: 4px; }
.pipeline-stage-sub { font-size: 11px; color: var(--text-muted); }

.pipeline-progress-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}

.pipeline-progress-fill { height: 100%; border-radius: 999px; }

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.stream-list { display: flex; flex-direction: column; gap: 8px; }

.stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.stream-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tag-badge { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.3); padding: 2px 7px; border-radius: 6px; flex-shrink: 0; }
.stream-meta-title { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-meta-sub { font-size: 10.5px; color: var(--text-muted); }
.stream-right { text-align: right; flex-shrink: 0; }
.stream-value { font-family: var(--font-mono); font-size: 13.5px; font-weight: 700; color: var(--accent-emerald); }
.stream-value-sub { font-size: 10px; color: var(--text-dim); }

.ingredient-stock-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stock-meter-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stock-meter-header { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 600; margin-bottom: 6px; }
.stock-bar-track { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 999px; }
.stock-meter-footer { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 5px; font-family: var(--font-mono); }

/* ==========================================================================
   GROWTH STAGES: NAV STRIP & CARDS
   ========================================================================== */
.stage-nav-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stage-nav-strip::-webkit-scrollbar { display: none; }

.stage-tab {
  flex-shrink: 0;
  min-width: 130px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.stage-tab.active {
  background: linear-gradient(180deg, #183329 0%, #10241d 100%);
  border-color: var(--accent-emerald);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}

.stage-tab-name { font-size: 12.5px; font-weight: 700; color: #fff; }
.stage-tab-weight { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.stage-tab-count { font-family: var(--font-mono); font-size: 18px; font-weight: 800; color: var(--accent-emerald); margin-top: 4px; }

.stage-tab.archive-tab { background: rgba(30, 20, 20, 0.35); }
.stage-tab.archive-tab.active { border-color: var(--accent-amber); }
.stage-tab.archive-tab.active .stage-tab-count { color: var(--accent-amber); }

.stage-summary-strip {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08) 0%, rgba(10, 19, 16, 0.6) 100%);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-pill-group { display: flex; gap: 14px; flex-wrap: wrap; }
.summary-metric-unit { display: flex; flex-direction: column; }
.summary-metric-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.summary-metric-val { font-family: var(--font-mono); font-size: 14.5px; font-weight: 700; color: #fff; }

/* View Mode Switcher */
.view-mode-toggle {
  display: flex;
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
}

.view-mode-btn svg { width: 13px; height: 13px; }
.view-mode-btn.active { background: var(--accent-emerald-dark); color: #fff; }

/* Cattle Card Grid */
.cattle-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
}

.cattle-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cattle-card-head { display: flex; justify-content: space-between; align-items: center; }
.cattle-card-tag { display: flex; align-items: center; gap: 6px; }
.cattle-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.cattle-metric-tile { display: flex; flex-direction: column; }
.cattle-metric-tile span { font-size: 9.5px; color: var(--text-dim); text-transform: uppercase; }
.cattle-metric-tile strong { font-family: var(--font-mono); font-size: 13.5px; color: #fff; }
.cattle-card-fin-row { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; border-top: 1px dashed var(--border-subtle); padding-top: 8px; }
.cattle-card-actions { display: flex; gap: 6px; margin-top: 2px; }
.cattle-card-actions .btn { flex: 1; }

/* Table Cards */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  width: 100%;
}

.table-card-toolbar {
  padding: 12px 16px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-search {
  height: 34px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: #fff;
  font-size: 12.5px;
  width: 160px;
}

.filter-select {
  height: 34px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.luxury-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.luxury-table thead th {
  background: rgba(10, 19, 16, 0.7);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
}

.luxury-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.luxury-table tfoot td {
  padding: 12px 14px;
  border-top: 2px solid var(--border-medium);
  font-size: 13px;
}

.tag-cell { font-family: var(--font-mono); font-weight: 700; color: var(--accent-emerald); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.mono-metric { font-family: var(--font-mono); font-weight: 600; }
.profit-pos { color: var(--accent-emerald); font-family: var(--font-mono); font-weight: 700; }
.profit-neg { color: var(--accent-red); font-family: var(--font-mono); font-weight: 700; }

/* ==========================================================================
   EDITABLE HERD INFORMATION TABLE STYLING
   ========================================================================== */
.editable-herd-table tbody tr:hover {
  background: rgba(16, 185, 129, 0.04);
}

.editable-herd-table tbody tr.row-new {
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--accent-emerald);
}

.tbl-input, .tbl-select {
  height: 30px;
  background: #060e0a;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  color: #fff;
  padding: 2px 7px;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.tbl-input:focus, .tbl-select:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  background: #091711;
}

.tbl-input.mono, .tbl-number {
  font-family: var(--font-mono);
  font-weight: 600;
}

.tbl-input.tag-input {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-emerald);
  text-transform: uppercase;
  min-width: 90px;
}

.tbl-number {
  min-width: 65px;
  text-align: right;
}

.tbl-date {
  min-width: 110px;
}

.tbl-select {
  cursor: pointer;
  min-width: 100px;
}

.flash-saved {
  animation: flashSavedAnim 1.2s ease-out;
}

@keyframes flashSavedAnim {
  0% { background-color: rgba(16, 185, 129, 0.35); }
  100% { background-color: transparent; }
}

/* ADG (Average Daily Gain) Pill Badges */
.badge-adg {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-adg.gain-high {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-adg.gain-med {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-adg.gain-low {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.adg-formula-caption {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 2px;
  display: block;
}

/* Minimum Selling Weight Restrictions (430 kg) */
.sale-pill-qualified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  white-space: nowrap;
}

.sale-pill-restricted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  white-space: nowrap;
}

.btn-sell-qualified {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.btn-sell-qualified:hover {
  background: var(--accent-emerald);
  color: #050a08;
}

.btn-sell-restricted {
  opacity: 0.6;
  cursor: not-allowed;
  border: 1px dashed rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.alert-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.alert-banner.warning {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.alert-banner.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.info-note-box {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #a5f3fc;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.45;
}

/* ==========================================================================
   FEED FORMULATION STRUCTURED TABLES (Stage & Master Multi-Stage Matrix)
   ========================================================================== */
.feed-matrix-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.formulation-view-switch {
  display: flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
}

.form-view-btn {
  background: transparent;
  border: none;
  padding: 7px 14px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.form-view-btn.active {
  background: var(--accent-emerald-dark);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.master-matrix-table th.stage-group-header {
  text-align: center;
  border-left: 1px solid var(--border-medium);
  border-right: 1px solid var(--border-medium);
  background: rgba(16, 185, 129, 0.1);
}

.master-matrix-table th.stage-group-header.starter { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.master-matrix-table th.stage-group-header.grower { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.master-matrix-table th.stage-group-header.s-finisher { background: rgba(245, 158, 11, 0.15); color: #fde68a; }
.master-matrix-table th.stage-group-header.finisher { background: rgba(234, 88, 12, 0.18); color: #fdba74; }

.feed-tbl-input {
  width: 65px;
  height: 28px;
  background: #050a08;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  padding: 0 5px;
}

.feed-tbl-input:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.stage-feed-batch-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.batch-card-tile {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.batch-card-tile span {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.batch-card-tile strong {
  font-family: var(--font-mono);
  font-size: 16px;
  color: #fff;
  margin-top: 3px;
}

.batch-card-tile.highlight strong {
  color: var(--accent-emerald);
}

.batch-card-tile.warning strong {
  color: var(--accent-amber);
}

.badge-tag { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge-tag.success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-tag.warning { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-tag.danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-tag.info { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.text-right { text-align: right; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

/* ==========================================================================
   FEED FORMULATIONS: DUAL VIEW (CARDS ON MOBILE, TABLE ON DESKTOP)
   ========================================================================== */
.formula-tabs-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.formula-tabs-bar::-webkit-scrollbar { display: none; }

.formula-tab {
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.formula-tab.active { background: var(--accent-emerald-dark); color: #fff; border-color: var(--accent-emerald); }

.interactive-ration-banner {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 11.5px;
  color: #a7f3d0;
  margin-bottom: 12px;
}

.grid-feed-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.ration-meta-pill {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Mobile Formula Cards (Visible on Phones, Hidden on Desktop) */
.mobile-formula-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.ingredient-mobile-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ing-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ing-card-name { font-size: 13px; font-weight: 700; color: #fff; }

.ing-card-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.ing-input-group { display: flex; flex-direction: column; gap: 3px; }
.ing-input-group label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; font-weight: 600; }
.ing-input-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ing-input-control input {
  width: 100%;
  height: 32px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 0 6px;
}

.ing-card-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 6px;
}

/* Desktop Formula Table (Hidden on Phones, Visible on Desktop) */
.desk-formula-table { display: block; }

.stage-metric-box {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.metric-row strong { font-family: var(--font-mono); color: #fff; }
.metric-row.highlight { border-top: 1px dashed var(--border-medium); padding-top: 8px; font-weight: 700; }
.metric-row.highlight strong { color: var(--accent-emerald); font-size: 14px; }

.feeding-notes-box {
  margin-top: 16px;
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.feeding-notes-box h4 { font-size: 11.5px; font-weight: 700; color: var(--accent-amber); margin-bottom: 6px; text-transform: uppercase; }
.feeding-notes-box ul { padding-left: 16px; font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

/* 21-Day Induction Roadmap */
.protocol-steps-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.protocol-step {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  position: relative;
}

.protocol-step::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-amber));
}

.step-num { font-family: var(--font-mono); font-size: 10px; font-weight: 800; color: var(--accent-amber); margin-bottom: 3px; }
.step-title { font-size: 12.5px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.step-desc { font-size: 10.5px; color: var(--text-muted); line-height: 1.35; }

.induction-cards-grid {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
  padding: 12px;
}

.induction-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Mobile Silo & Clinic Cards (Hidden on desktop, rendered on mobile) */
.silo-mobile-cards, .treatment-mobile-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
  background: #0d1a15;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalEnter 0.22s ease-out;
}

.modal-dialog.dossier-dialog { max-width: 900px; }
.modal-dialog.spec-dialog { max-width: 950px; }

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #0d1a15;
  z-index: 10;
}

.modal-title { font-size: 16px; font-weight: 700; color: #fff; }
.modal-sub { font-size: 11px; color: var(--text-muted); }
.modal-actions { display: flex; align-items: center; gap: 8px; }
.modal-close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg-darkest);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-sans);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.weigh-calc-preview {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Dossier Passport */
.dossier-header-badge { display: flex; align-items: center; gap: 10px; }
.dossier-tag-pill { font-family: var(--font-mono); font-size: 18px; font-weight: 800; color: #fff; background: var(--accent-emerald-dark); padding: 3px 12px; border-radius: 6px; }
.dossier-stage-pill { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }
.dossier-body { display: flex; flex-direction: column; gap: 16px; }
.dossier-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; }
.dossier-bio-card, .dossier-growth-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px; }
.dossier-stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-size: 12px; }
.dossier-stat-label { color: var(--text-muted); }
.dossier-stat-val { font-family: var(--font-mono); font-weight: 600; color: #fff; }
.svg-chart-wrap { width: 100%; height: 160px; margin-top: 8px; }
.dossier-treatments-table { width: 100%; font-size: 11.5px; border-collapse: collapse; }
.dossier-treatments-table th, .dossier-treatments-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-subtle); text-align: left; }

/* Financials Hero */
.financials-hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.fin-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 18px; }
.fin-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.fin-value { font-family: var(--font-mono); font-size: 24px; font-weight: 800; color: #fff; margin: 4px 0; }
.fin-value.warning { color: #f59e0b; }
.fin-value.info { color: #06b6d4; }
.fin-value.highlight { color: #10b981; }
.fin-sub { font-size: 10.5px; color: var(--text-dim); }

.group-pnl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.group-pnl-card { background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 14px; }
.health-calendar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.health-routine-card { background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 14px; }
.routine-date { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent-emerald); font-weight: 700; }
.routine-title { font-size: 13px; font-weight: 700; color: #fff; margin: 3px 0; }
.routine-detail { font-size: 11.5px; color: var(--text-muted); }

/* Mobile Bottom Dock */
.mobile-bottom-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--dock-height);
  background: rgba(7, 15, 11, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 55;
  justify-content: space-around;
  align-items: center;
}

.bottom-dock-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.bottom-dock-item svg { width: 18px; height: 18px; }
.bottom-dock-item.active { color: var(--accent-emerald); }

/* Mobile Floating Action Button (FAB) */
.mobile-fab-container {
  display: none;
  position: fixed;
  bottom: calc(var(--dock-height) + 12px);
  right: 14px;
  z-index: 52;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.mobile-fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: #061c14;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.mobile-fab svg { width: 22px; height: 22px; }

.mobile-fab-container.open .mobile-fab {
  transform: rotate(45deg);
  background: var(--accent-red);
  color: #fff;
}

.fab-speed-dial {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.9);
  transition: var(--transition);
}

.mobile-fab-container.open .fab-speed-dial {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.fab-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.fab-action-btn svg { width: 16px; height: 16px; }

.fab-tooltip {
  position: absolute;
  right: 48px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
}

/* Toast Container */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 150;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #142821;
  border: 1px solid var(--accent-emerald);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 12.5px;
}

.toast.toast-warning { border-color: var(--accent-amber); }
.toast.toast-error { border-color: var(--accent-red); }

/* ==========================================================================
   MULTI-ORIENTATION RESPONSIVE BREAKPOINTS (Mobile First!)
   ========================================================================== */

@media (max-width: 1200px) {
  .kpi-ribbon { grid-template-columns: repeat(2, 1fr); }
  .stage-pipeline-grid, .financials-hero-grid, .group-pnl-grid, .health-calendar-grid, .protocol-steps-grid { grid-template-columns: repeat(2, 1fr); }
  .ingredient-stock-bars { grid-template-columns: repeat(2, 1fr); }
  .grid-feed-layout { grid-template-columns: 1fr; }
  .sim-grid { grid-template-columns: 1fr; }
}

/* MOBILE PHONES (Portrait & Narrow Screens down to 300px!) */
@media (max-width: 768px) {
  .app-header { height: 56px; padding: 0 12px; }
  .mobile-nav-toggle { display: inline-flex; }
  .brand-eyebrow { display: none; }
  .brand-name { font-size: 15px; }

  .search-command-bar { display: none; }
  .search-command-bar.mobile-open {
    display: block;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    max-width: 100%;
    margin: 0;
    padding: 8px 12px;
    background: #09120e;
    border-bottom: 1px solid var(--border-medium);
    z-index: 65;
  }

  .mobile-search-btn { display: inline-flex; }
  .desk-only { display: none !important; }

  /* Mobile Drawer Sidebar */
  .sidebar-dock {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #0b1712;
    z-index: 80;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.7);
  }

  .sidebar-dock.open { transform: translateX(0); }
  .mobile-drawer-header { display: flex; }

  /* Viewport spacing for bottom dock */
  .main-viewport {
    padding: 12px 10px calc(var(--dock-height) + 16px) 10px;
  }

  .page-title { font-size: 19px; }
  .kpi-ribbon { grid-template-columns: 1fr; gap: 8px; }
  .kpi-card { padding: 12px; }
  .grid-2col { grid-template-columns: 1fr; gap: 12px; }
  .stage-pipeline-grid { grid-template-columns: 1fr; gap: 10px; }
  .protocol-steps-grid { grid-template-columns: 1fr; gap: 8px; }
  .ingredient-stock-bars { grid-template-columns: 1fr; gap: 8px; }
  .health-calendar-grid { grid-template-columns: 1fr; gap: 8px; }
  .financials-hero-grid { grid-template-columns: 1fr; gap: 8px; }
  .group-pnl-grid { grid-template-columns: 1fr; gap: 8px; }

  /* FEED FORMULATION: Show Cards on Mobile, Hide Table */
  .desk-formula-table { display: none !important; }
  .mobile-formula-cards { display: flex !important; }

  /* SILO & CLINIC: Show Cards on Mobile, Hide Table */
  .desk-silo-table { display: none !important; }
  .silo-mobile-cards { display: flex !important; }

  .desk-treatment-table { display: none !important; }
  .treatment-mobile-cards { display: flex !important; }

  .induction-cards-grid { display: grid; }
  .desk-table { display: none; }

  /* Bottom Dock and FAB visible */
  .mobile-bottom-dock { display: flex; }
  .mobile-fab-container { display: flex; }

  /* Bottom sheet modal */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-dialog {
    max-height: 86vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: none;
  }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: span 1; }
  .dossier-grid { grid-template-columns: 1fr; }

  .toast-stack {
    bottom: calc(var(--dock-height) + 12px);
    right: 10px;
    left: 10px;
  }
}

/* MOBILE LANDSCAPE (@media max-height: 500px) */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header { height: 46px; padding: 0 12px; }
  .brand-crest { width: 30px; height: 30px; }
  .crest-icon { width: 16px; height: 16px; }
  .brand-name { font-size: 14px; }
  .main-viewport { padding: 10px 12px calc(var(--dock-height) + 8px) 12px; }
  .kpi-ribbon { grid-template-columns: repeat(2, 1fr); }
  .sim-results-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-dialog { max-height: 92vh; }
  .svg-chart-wrap { height: 120px; }
  .mobile-fab-container { bottom: calc(var(--dock-height) + 6px); right: 8px; }
}
