:root {
  --primary: #d0ddd1;
  --primary-dark: #1dda33;
  --primary-light: #1f3d20;
  --primary-bg: #e8f5e9;
  --accent: #ff8f00;
  --accent-light: #fff8e1;
  --danger: #c62828;
  --danger-light: #ffebee;
  --info: #0277bd;
  --info-light: #e1f5fe;
  --warning: #f57f17;
  --warning-light: #fff9c4;
  --white: #ffffff;
  --grey-50: #fafafa;
  --grey-100: #f5f5f5;
  --grey-200: #eeeeee;
  --grey-300: #e0e0e0;
  --grey-400: #bdbdbd;
  --grey-500: #6b6b6b;
  --grey-600: #444444;
  --grey-700: #2e2e2e;
  --grey-800: #1f1f1f;
  --grey-900: #111111;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--grey-100);
  color: var(--grey-900);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 84px 20px 0;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.auth-wrapper {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  margin-bottom: 40px;
  /* Fill the screen (minus the page's top padding) so the footer always starts
     below the fold and is only seen by scrolling down */
  min-height: calc(100vh - 84px);
  min-height: calc(100dvh - 84px);
}

.auth-video-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.auth-video-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.auth-page > div {
  position: relative;
  z-index: 2;
}
/* The dark overlay must stay fixed over the video (the rule above would otherwise collapse it) */
.auth-page > .auth-video-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── AUTH TOP BAR (Sign In / Register on the top right) ── */
.auth-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px 22px;
  /* soft dark fade so white text/buttons stay readable over bright video frames */
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0));
}
.auth-topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--white); font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.auth-topbar-brand .logo-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 8px; background: #2e7d32; color: var(--white); font-size: 13px; font-weight: 800;
}
.auth-topbar-actions { display: flex; gap: 10px; }
.auth-top-btn {
  padding: 8px 18px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: rgba(0,0,0,0.25); color: var(--white); border: 1.5px solid rgba(255,255,255,0.85);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.auth-top-btn:hover { background: rgba(255,255,255,0.15); }
.auth-top-btn-primary { background: #2e7d32; border-color: #2e7d32; }
.auth-top-btn-primary:hover { background: #1b5e20; border-color: #1b5e20; }
/* The button for the form being shown */
.auth-top-btn.active { background: var(--white); color: #1b5e20; border-color: var(--white); }
.auth-top-btn:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
@media (max-width: 480px) {
  .auth-topbar { padding: 10px 14px; }
  .auth-topbar-brand span:last-child, .auth-topbar-brand { font-size: 15px; }
  .auth-top-btn { padding: 7px 12px; font-size: 13px; }
}

/* ── AUTH FOOTER ── */
.auth-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.85);
  padding: 38px 4px 4px;
  /* No fixed gap needed: .auth-wrapper fills the screen, so the footer starts just below the fold */
  margin-top: 0;
}

.auth-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.auth-footer-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 36px;
}

.auth-footer-logo {
  font-family: 'Cinzel', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 2px;
  line-height: 1;
  flex-shrink: 0;
}

.auth-footer-name {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.auth-footer-tagline {
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 600;
  margin: 2px 0 6px;
}

.auth-footer-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  margin: 0;
}

.auth-footer-links {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.auth-footer-col h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  margin-bottom: 12px;
}

.auth-footer-col a {
  display: block;
  font-size: 12.5px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  margin-bottom: 7px;
  transition: color 0.2s;
}

.auth-footer-col a:hover { color: var(--primary-dark); }

.auth-footer-social {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 24px;
  margin-bottom: 24px;
}

.auth-footer-social h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  margin-bottom: 12px;
}

.auth-footer-social-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.social-btn {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  transition: all 0.2s;
}

.social-btn:hover {
  border-color: var(--primary-dark);
  color: var(--primary-dark);
}

.auth-footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  font-family: 'Cinzel', serif;
  font-size: 42px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
  color: var(--primary-dark);
  letter-spacing: 2px;
}

.auth-logo h1 {
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 700;
}

.auth-logo p {
  color: var(--grey-600);
  font-size: 13px;
}

/* ===== APP LAYOUT ===== */
#app { display: none; }
#app.visible { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .logo-emoji {
  font-family: 'Cinzel', serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  line-height: 1;
}

.sidebar-header .brand h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.sidebar-header .brand p {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}

.sidebar-farm-selector {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-farm-selector select {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}

.sidebar-farm-selector select option { background: var(--primary-dark); color: black; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: rgba(5, 5, 5, 0.75);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  font-size: 13.5px;
}

.nav-item:hover {
  background: rgba(63, 0, 0, 0.08);
  color: var(--white);
}

.nav-item.active {
  background: rgba(71, 2, 2, 0.12);
  color: var(--white);
  border-left-color: var(--primary-light);
}

.nav-item .nav-icon { font-size: 8px; width: 22px; text-align: center; color: rgba(255,255,255,0.5); }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--white);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.nav-item.nav-sub {
  padding-left: 40px;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title { font-size: 18px; font-weight: 600; color: var(--grey-900); flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  background: green;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--grey-600);
  font-size: 20px;
  position: relative;
  transition: background var(--transition);
}

.topbar-btn:hover { background: var(--grey-100); }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: var(--white);
  font-size: 9px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: var(--green);
}

/* Page content */
.page-content {
  padding: 24px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

/* ===== COMPONENTS ===== */

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-200);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 { font-size: 15px; font-weight: 600; color: var(--grey-900); }
.card-body { padding: 20px; }

/* Summary cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-200);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.summary-card[onclick] { cursor: pointer; }
.summary-card[onclick]:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }

.summary-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.summary-icon.green { background: var(--primary-bg); }
.summary-icon.orange { background: var(--accent-light); }
.summary-icon.blue { background: var(--info-light); }
.summary-icon.red { background: var(--danger-light); }
.summary-icon.yellow { background: var(--warning-light); }

.summary-info .label { font-size: 12px; color: var(--grey-600); margin-bottom: 4px; }
.summary-info .value { font-size: 22px; font-weight: 700; color: var(--grey-900); }
.summary-info .sub { font-size: 11px; color: var(--grey-500); margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: var(--green); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--grey-200); color: var(--grey-800); }
.btn-secondary:hover { background: var(--grey-300); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b71c1c; }
.btn-warning { background: var(--accent); color: var(--white); }
.btn-warning:hover { background: #e65100; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
/* View / Edit buttons: outlined, fill green on hover */
.btn-view-edit { background: var(--white); border: 1px solid var(--primary); color: var(--grey-800); font-weight: 500; }
.btn-view-edit:hover,
.btn-view-edit:focus-visible { background: #2e7d32; border-color: #2e7d32; color: var(--white); }
.btn-icon { padding: 6px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--grey-700); margin-bottom: 6px; }
.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--grey-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}

.form-control.error { border-color: var(--danger); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Tables */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--grey-50);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--grey-700);
  border-bottom: 2px solid var(--grey-200);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-100);
  color: var(--grey-800);
}

tbody tr:hover { background: var(--grey-50); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--primary-bg); color: var(--primary-dark); }
.badge-orange { background: var(--accent-light); color: #e65100; }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-blue { background: var(--info-light); color: var(--info); }
.badge-grey { background: var(--grey-200); color: var(--grey-700); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: scale(1); }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--grey-500); padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--grey-100); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--grey-200); display: flex; justify-content: flex-end; gap: 10px; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: var(--primary-bg); color: var(--primary-dark); border: 1px solid #a5d6a7; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #ef9a9a; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #ffe082; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #81d4fa; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--grey-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

.toast.success { background: var(--primary-dark); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-container { position: relative; height: 260px; }

/* Search & filter bar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239e9e9e' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  outline: none;
}

.search-input:focus { border-color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--grey-500);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; color: var(--grey-700); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--grey-500);
  gap: 10px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--grey-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--grey-200); margin-bottom: 20px; gap: 4px; }
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--grey-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover { color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Notification panel */
.notif-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: 360px;
  height: calc(100vh - var(--topbar-height));
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  transform: translateX(100%);
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
}

.notif-panel.open { transform: translateX(0); }
.notif-panel-header { padding: 16px 20px; border-bottom: 1px solid var(--grey-200); display: flex; align-items: center; justify-content: space-between; }
.notif-panel-header h3 { font-size: 15px; font-weight: 600; }
.notif-list { flex: 1; overflow-y: auto; }
.notif-item { padding: 14px 20px; border-bottom: 1px solid var(--grey-100); cursor: pointer; transition: background var(--transition); }
.notif-item:hover { background: var(--grey-50); }
.notif-item.unread { background: var(--primary-bg); }
.notif-item .notif-title { font-size: 13.5px; font-weight: 600; color: var(--grey-900); margin-bottom: 4px; }
.notif-item .notif-msg { font-size: 12.5px; color: var(--grey-600); }
.notif-item .notif-time { font-size: 11px; color: var(--grey-400); margin-top: 4px; }
.notif-priority-high { border-left: 3px solid var(--danger); }
.notif-priority-normal { border-left: 3px solid var(--primary); }

/* Responsive */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--grey-700);
  padding: 4px;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .auth-footer-links { grid-template-columns: repeat(2, 1fr); }
  .auth-footer { padding: 36px 16px 20px; }
}

@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
  .auth-footer-links { grid-template-columns: 1fr; }
  .auth-footer-brand { flex-direction: column; gap: 8px; }
}

/* Profit/loss colors */
.text-profit { color: var(--primary); font-weight: 600; }
.text-loss { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--grey-500); }
.text-sm { font-size: 12px; }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 { font-size: 20px; font-weight: 700; color: var(--grey-900); }
.section-header p { font-size: 13px; color: var(--grey-600); margin-top: 2px; }

/* Offline indicator */
.offline-bar {
  background: var(--warning);
  color: var(--white);
  text-align: center;
  padding: 6px;
  font-size: 12.5px;
  font-weight: 500;
  display: none;
}

.offline-bar.visible { display: block; }

/* Print styles */
@media print {
  .sidebar, .topbar, .toolbar, .btn, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
}

/* ===== SHOW / HIDE PASSWORD ===== */
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 76px; width: 100%; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 30px; padding: 0 8px; border: none; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  background: transparent; color: var(--grey-500, #888); cursor: pointer;
}
.password-toggle:hover { color: var(--primary, #2e7d32); background: rgba(0,0,0,0.05); }
.password-toggle:focus-visible { outline: 2px solid var(--primary, #2e7d32); outline-offset: 1px; }

/* Text labels next to icon buttons (menu, notifications, close) */
.modal-close, .sidebar-toggle, .topbar-btn { display: inline-flex; align-items: center; gap: 4px; }
.sidebar-toggle { display: none; }
.btn-label { font-size: 13px; font-weight: 600; line-height: 1; }
@media (max-width: 768px) { .sidebar-toggle { display: inline-flex; } }

/* ===== VACCINE NAME PICKER ===== */
.vaccine-picker { position: relative; }
.vaccine-list {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 280px; overflow-y: auto; background: var(--white);
  border: 1px solid var(--grey-300); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 4px 0;
}
.vaccine-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--grey-500); }
.vaccine-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 8px 12px; border: none; background: none; text-align: left; cursor: pointer; font: inherit;
}
.vaccine-option:hover { background: var(--primary-bg); }
.vaccine-option-name { font-size: 13.5px; color: var(--grey-900); }
.vaccine-option-meta { font-size: 12px; color: var(--grey-500); }
.vaccine-add { color: #2e7d32; font-weight: 600; font-size: 13.5px; border-top: 1px solid var(--grey-200); }
.vaccine-empty, .vaccine-note { padding: 8px 12px; font-size: 12px; color: var(--grey-500); }
.vaccine-note { border-top: 1px solid var(--grey-200); font-style: italic; }

/* ===== NEW SALE: CUSTOMER ===== */
.sale-customer-info { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 16px;
  padding: 10px 12px; background: var(--primary-bg); border-radius: var(--radius); font-size: 13px; }
.sale-new-customer { margin-bottom: 16px; padding: 12px; border: 1px solid var(--grey-200); border-radius: var(--radius); background: var(--grey-50); }
.sale-new-customer-title { font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.sale-new-customer-title .text-muted { font-weight: 400; }

/* Customer picker in New Sale */
.customer-picker { position: relative; }
.customer-list { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0; max-height: 300px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px 0; }
.customer-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--grey-500); }
.customer-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 8px 12px;
  border: none; background: none; text-align: left; cursor: pointer; font: inherit; }
.customer-option:hover { background: var(--primary-bg); }
.customer-option-name { font-size: 13.5px; color: var(--grey-900); }
.customer-option-meta { font-size: 12px; color: var(--grey-500); }
.customer-new { color: #2e7d32; font-weight: 600; font-size: 13.5px; border-top: 1px solid var(--grey-200); }
.customer-walkin { color: var(--grey-600); font-size: 13px; }
.customer-empty { padding: 8px 12px; font-size: 12px; color: var(--grey-500); }

/* Auto-recorded expenses */
.expense-source { font-size: 11px; color: var(--grey-500); margin-top: 2px; }

/* Admin "logged in as" banner */
.impersonate-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: #fff3e0; border-bottom: 2px solid var(--accent); color: var(--grey-900); font-size: 13.5px; }
.impersonate-return { background: var(--accent); color: var(--white); font-weight: 600; }
.impersonate-return:hover { background: #e65100; }

/* Inventory: bags summary in the add item form */
.inv-bag-summary { padding: 10px 12px; background: var(--primary-bg); border-radius: var(--radius); font-size: 13px; color: var(--grey-800); }

/* Feed stock: one card per feed */
.feed-stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.feed-stock-card { background: var(--white); border: 1px solid var(--grey-200); border-left: 4px solid #2e7d32; border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.feed-stock-card.low { border-left-color: var(--danger); background: var(--danger-light); }
.feed-stock-name { font-size: 13px; font-weight: 600; color: var(--grey-700); }
.feed-stock-value { font-size: 20px; font-weight: 700; color: var(--grey-900); margin: 2px 0; }
.feed-stock-sub { font-size: 12px; color: var(--grey-500); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.feed-stock-empty { padding: 12px 14px; background: var(--grey-50); border: 1px dashed var(--grey-300); border-radius: var(--radius); font-size: 13px; color: var(--grey-600); }

/* Inventory: purchase history totals */
.purchase-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.purchase-totals:empty { display: none; }
.purchase-totals > div { flex: 1; min-width: 140px; padding: 10px 14px; background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: var(--radius); }
.purchase-totals span { display: block; font-size: 12px; color: var(--grey-500); }
.purchase-totals strong { font-size: 18px; color: var(--grey-900); }
.purchase-totals .in strong, .stock-in strong { color: #2e7d32; }
.purchase-totals .out strong, .stock-out strong { color: var(--danger); }

/* ===== PLANS & PAYMENT ===== */
.auth-wrapper.wide { max-width: 1040px; }
.plan-picker-head { text-align: center; color: var(--white); margin-bottom: 20px; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.plan-picker-head h1 { font-size: 30px; font-weight: 800; }
.plan-picker-head p { opacity: .9; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: stretch; }
.plan-card { position: relative; display: flex; flex-direction: column; background: var(--white); border-radius: 14px; padding: 24px 22px; box-shadow: var(--shadow-lg); }
.plan-card.featured { outline: 3px solid #2e7d32; transform: translateY(-6px); }
.plan-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: #2e7d32; color: #fff; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.plan-card h3 { font-size: 20px; font-weight: 800; color: var(--grey-900); }
.plan-for { font-size: 13px; color: var(--grey-500); margin: 2px 0 12px; }
.plan-price { font-size: 30px; font-weight: 800; color: #1b5e20; margin-bottom: 14px; }
.plan-price span { font-size: 14px; font-weight: 500; color: var(--grey-500); }
.plan-price-quote { font-size: 24px; }
.plan-card ul { list-style: none; padding: 0; margin: 0 0 18px; flex: 1; }
.plan-card li { font-size: 13.5px; color: var(--grey-800); padding: 5px 0; display: flex; gap: 8px; }
.plan-ok { color: #2e7d32; font-weight: 800; }
.plan-no { color: var(--grey-400); font-weight: 800; }
.plan-card li:has(.plan-no) { color: var(--grey-500); }
.plan-btn { justify-content: center; width: 100%; padding: 11px; border: 2px solid #2e7d32; color: #1b5e20; background: var(--white); font-weight: 700; text-decoration: none; }
.plan-btn:hover, .plan-btn-primary { background: #2e7d32; color: var(--white); }
.plan-btn-primary:hover { background: #1b5e20; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: 1fr; } .plan-card.featured { transform: none; } }

.chosen-plan { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 16px; background: var(--primary-bg); border-radius: var(--radius); font-size: 13.5px; }
.chosen-plan a { color: #1b5e20; font-weight: 700; }
.pay-plans { display: grid; gap: 8px; margin-bottom: 14px; }
.pay-plan { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--grey-200); border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.pay-plan:has(input:checked) { border-color: #2e7d32; background: var(--primary-bg); }
.pay-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; background: var(--grey-100); padding: 4px; border-radius: var(--radius); }
.pay-tab { border: none; background: none; padding: 9px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; color: var(--grey-600); }
.pay-tab.active { background: var(--white); color: #1b5e20; box-shadow: var(--shadow-sm); }
.pay-btn { width: 100%; justify-content: center; padding: 11px; background: #2e7d32; color: var(--white); }
.pay-btn:hover { background: #1b5e20; }
.pay-btn:disabled { opacity: .6; cursor: wait; }
.pay-note { font-size: 13px; color: var(--grey-600); margin-bottom: 12px; }
.pay-status { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; }
.pay-status.info { background: var(--info-light); color: #01579b; }
.pay-status.success { background: var(--primary-bg); color: #1b5e20; }
.pay-status.error { background: var(--danger-light); color: var(--danger); }
.pay-foot { text-align: center; margin-top: 14px; font-size: 12px; color: var(--grey-500); }
.pay-foot a { color: var(--grey-700); }

/* Settings: subscription */
.subscription-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 18px; background: var(--white); border: 1px solid var(--grey-200); border-left: 4px solid #2e7d32; border-radius: var(--radius); }
.subscription-box.ending { border-left-color: var(--warning); background: var(--warning-light); }
.sub-label { font-size: 12px; color: var(--grey-500); }
.sub-plan { font-size: 18px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.sub-until { font-size: 13px; color: var(--grey-600); }

/* Remember me */
.remember-me { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; font-size: 13.5px; font-weight: 600; color: var(--grey-800); cursor: pointer; }
.remember-me input { width: 16px; height: 16px; accent-color: #2e7d32; cursor: pointer; }
.remember-me span { font-weight: 400; color: var(--grey-500); font-size: 12px; }

.agree-note { margin-top: 10px; font-size: 12px; color: var(--grey-500); text-align: center; }
.agree-note a { color: #1b5e20; font-weight: 600; }

/* Admin: farm owner popup */
.owner-summary { padding: 10px 12px; background: var(--primary-bg); border-radius: var(--radius); font-size: 13.5px; }
.owner-renew-info { padding: 10px 12px; margin-bottom: 14px; background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: var(--radius); font-size: 13.5px; }
.owner-login-box { white-space: pre-wrap; background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 12px; font-size: 13px; font-family: inherit; margin: 0; }

/* ===== PROFILE MENU (top right) ===== */
.profile-menu { position: relative; }
.profile-trigger { display: flex; align-items: center; gap: 4px; background: none; border: none; padding: 2px; border-radius: 999px; cursor: pointer; }
.profile-trigger:hover .user-avatar, .profile-trigger[aria-expanded="true"] .user-avatar { box-shadow: 0 0 0 3px var(--primary-bg); }
.profile-trigger:focus-visible { outline: 2px solid #2e7d32; outline-offset: 2px; }
.profile-caret { font-size: 11px; color: var(--grey-500); }
.profile-dropdown { position: absolute; right: 0; top: calc(100% + 8px); z-index: 200; min-width: 230px; background: var(--white); border: 1px solid var(--grey-200); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; }
.profile-dropdown[hidden] { display: none; }
.profile-dropdown-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--grey-200); margin-bottom: 6px; }
.profile-dropdown-name { font-weight: 700; color: var(--grey-900); font-size: 14px; }
.profile-dropdown-role { font-size: 12px; color: #2e7d32; font-weight: 600; text-transform: capitalize; }
.profile-dropdown-email { font-size: 12px; color: var(--grey-500); word-break: break-all; }
.profile-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: none; background: none; border-radius: 6px; font: inherit; font-size: 13.5px; color: var(--grey-800); text-align: left; cursor: pointer; }
.profile-item:hover { background: var(--grey-100); }
.profile-signout { color: var(--danger); font-weight: 600; }
.profile-signout:hover { background: var(--danger-light); }

/* Wide tables scroll inside their box instead of pushing the whole page (and the top bar) off screen */
.main-content, .page-content, .page, .card, .card-body, .tab-panel { min-width: 0; }
.table-wrapper { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#usersTab td:last-child { white-space: nowrap; }

/* Inventory: what the chosen category is */
.inv-cat-info { padding: 10px 12px; border-left: 4px solid #2e7d32; background: var(--grey-50); border-radius: var(--radius); font-size: 13px; color: var(--grey-700); line-height: 1.5; }

/* Closed inventory items: kept for history, greyed out */
tr.inv-closed td { color: var(--grey-500); background: var(--grey-50); }
tr.inv-closed td strong { color: var(--grey-500) !important; }

.vac-cost-total { padding: 8px 12px; background: var(--primary-bg); border-radius: var(--radius); font-size: 13px; }
