/* ===== AUTH OVERLAY ===== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; background: var(--bg);
}
.auth-brand-panel {
  width: 400px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center;
  padding: 60px 48px; gap: 20px;
}
.auth-logo { height: 192px; width: auto; }
.auth-tagline { color: #b7e4c7; font-size: 17px; font-weight: 500; line-height: 1.4; }
.auth-features { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.auth-features li { color: #74c69d; font-size: 14px; }
.auth-form-panel {
  flex: 1; display: flex; align-items: center;
  justify-content: center; padding: 40px;
  overflow-y: auto;
}
.auth-card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 40px;
  width: 100%; max-width: 400px;
}
.auth-tabs {
  display: flex; background: var(--bg);
  border-radius: var(--radius); padding: 4px; margin-bottom: 28px;
}
.auth-tab {
  flex: 1; padding: 8px 16px; border: none;
  background: transparent; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-3);
  cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.auth-tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.auth-field input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
  color: var(--text); background: var(--card); outline: none; transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--primary); }
.auth-error { font-size: 13px; color: var(--red); margin-bottom: 12px; min-height: 18px; line-height: 1.4; }
.auth-submit { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; margin-top: 4px; }
.auth-footer-text { text-align: center; margin-top: 24px; font-size: 12px; color: var(--text-4); }
.auth-link-btn { background: none; border: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.auth-link-btn:hover { opacity: 0.8; }

/* Loading screen */
.app-loading {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); flex-direction: column; gap: 16px;
}
.app-loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: bp-spin 0.8s linear infinite;
}
@keyframes bp-spin { to { transform: rotate(360deg); } }
.app-loading-text { font-size: 14px; color: var(--text-3); font-weight: 500; }

/* Logout button */
.logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: transparent;
  border-radius: var(--radius-sm); color: var(--sidebar-text-muted);
  cursor: pointer; flex-shrink: 0; transition: background 0.15s, color 0.15s;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.logout-btn svg { width: 16px; height: 16px; }

/* Sidebar footer flex layout */
.sidebar-footer { display: flex; align-items: center; gap: 8px; }
.sidebar-footer .farm-profile { flex: 1; min-width: 0; }

@media (max-width: 700px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 20px; align-items: flex-start; }
  .auth-card { padding: 24px 20px; box-shadow: none; border-radius: var(--radius); }
  .auth-field input { padding: 12px; font-size: 16px; } /* 16px prevents iOS zoom */
  .auth-submit { padding: 14px; font-size: 15px; }
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #1b4332;
  --sidebar-hover: #2d6a4f;
  --sidebar-active: #40916c;
  --sidebar-text: #b7e4c7;
  --sidebar-text-muted: #74c69d;
  --sidebar-width: 240px;
  --topbar-h: 64px;

  --primary: #40916c;
  --primary-dark: #2d6a4f;
  --primary-light: #52b788;
  --primary-xlight: #d8f3dc;

  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --red: #ef4444;
  --red-light: #fee2e2;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --teal: #14b8a6;
  --teal-light: #ccfbf1;

  --bg: #f0f4f2;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;

  --text: #111827;
  --text-2: #374151;
  --text-3: #6b7280;
  --text-4: #9ca3af;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
#app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar-top {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.collapsed .brand-name { opacity: 0; pointer-events: none; }

.brand-logo-img {
  width: 160px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
  transition: width 0.25s, opacity 0.2s;
}

.sidebar.collapsed .brand-logo-img {
  width: 36px;
  object-fit: cover;
  object-position: left center;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-text-muted);
  padding: 12px 20px 6px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-list {
  list-style: none;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  position: relative;
  white-space: nowrap;
  user-select: none;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; }

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: #74c69d;
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 13.5px;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.farm-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.15s;
}
.farm-profile:hover { background: rgba(255,255,255,0.07); }

.farm-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.farm-info-block { overflow: hidden; }
.farm-name-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s;
}
.farm-role-text {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.collapsed .farm-name-text,
.sidebar.collapsed .farm-role-text { opacity: 0; }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
  width: 36px; height: 36px;
  border: none;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: background 0.15s;
}
.menu-toggle:hover { background: var(--border); }
.menu-toggle svg { width: 18px; height: 18px; }

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topbar-date {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
}

.notification-wrap { position: relative; }

.topbar-icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: all 0.15s;
  position: relative;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--text); }
.topbar-icon-btn svg { width: 18px; height: 18px; }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--card);
}

/* ===== ALERTS PANEL ===== */
.alerts-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  overflow: hidden;
}

.alerts-panel.open { display: block; }

.alerts-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  background: var(--border-light);
}

.alert-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}

.alert-item:last-child { border-bottom: none; }

.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.alert-dot.red { background: var(--red); }
.alert-dot.amber { background: var(--amber); }
.alert-dot.green { background: var(--primary); }

.alert-text { font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.alert-sub { font-size: 11px; color: var(--text-4); margin-top: 2px; }

.alerts-empty { padding: 20px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 14px; height: 14px; pointer-events: none; }
.btn-icon.danger:hover { background: var(--red-light); color: var(--red); border-color: #fca5a5; }
.btn-icon.harvest-btn { color: var(--primary); }
.btn-icon.harvest-btn:hover { background: var(--primary-xlight); color: var(--primary-dark); border-color: var(--primary-light); }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ===== DASHBOARD ===== */
.dash-grid {
  display: grid;
  gap: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.green::before { background: var(--primary); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.teal::before { background: var(--teal); }
.stat-card.red::before { background: var(--red); }

.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon-wrap {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrap.green { background: var(--primary-xlight); color: var(--primary); }
.stat-icon-wrap.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon-wrap.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon-wrap.amber { background: var(--amber-light); color: var(--amber); }
.stat-icon-wrap.teal { background: var(--teal-light); color: var(--teal); }
.stat-icon-wrap.red { background: var(--red-light); color: var(--red); }

.stat-icon-wrap svg { width: 22px; height: 22px; }

.stat-trend {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 20px;
}

.stat-trend.up { background: var(--primary-xlight); color: var(--primary-dark); }
.stat-trend.down { background: var(--red-light); color: var(--red); }
.stat-trend.neutral { background: var(--border-light); color: var(--text-3); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
}

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

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

.chart-wrap {
  position: relative;
  height: 240px;
  padding: 0 4px;
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

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

thead th {
  background: var(--border-light);
  padding: 11px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--border-light); }

.td-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-green { background: var(--primary-xlight); color: var(--primary-dark); }
.badge-blue { background: var(--blue-light); color: #1d4ed8; }
.badge-amber { background: var(--amber-light); color: #92400e; }
.badge-red { background: var(--red-light); color: #991b1b; }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-teal { background: var(--teal-light); color: #0f766e; }
.badge-gray { background: var(--border-light); color: var(--text-3); }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

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

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  min-width: 220px;
}

.search-box svg { width: 16px; height: 16px; color: var(--text-4); flex-shrink: 0; }

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  width: 100%;
}

.search-box input::placeholder { color: var(--text-4); }

.filter-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-2);
  background: var(--card);
  cursor: pointer;
  outline: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; color: var(--text-4); }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-3); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }
.modal-box.map-mode { max-width: 720px; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--border-light);
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: all 0.15s;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== FORM ===== */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.2px;
}

.form-label .req { color: var(--red); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(64,145,108,0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-4);
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
  grid-column: 1 / -1;
}

/* Auto-generate bar inside inventory form */
.autogen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.autogen-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  height: auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* ===== CONFIRM DIALOG ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.confirm-overlay.open { display: flex; }

.confirm-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

.confirm-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--amber-light);
  color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.confirm-icon svg { width: 24px; height: 24px; }

.confirm-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.confirm-msg { font-size: 13.5px; color: var(--text-3); margin-bottom: 24px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success { background: var(--primary-dark); }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== CROP CARDS ===== */
.crop-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Crops grouped by grow location */
.crop-group { margin-bottom: 22px; }
.crop-group-header {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 700; color: var(--text-1);
  padding: 6px 0 10px; margin-bottom: 4px;
  border-bottom: 2px solid var(--border);
}
.crop-group-count {
  font-size: 11px; font-weight: 700;
  background: var(--primary-light); color: #fff;
  padding: 1px 8px; border-radius: 99px;
}
/* Table view group separator row */
.crop-group-row td {
  background: var(--bg);
  font-weight: 700; font-size: 13px; color: var(--text-1);
  padding: 8px 12px !important;
}
.crop-group-row .crop-group-count { background: var(--primary); }

.crop-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.crop-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.crop-card-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.crop-card-body { padding: 12px 16px; }
.crop-card-footer {
  padding: 10px 16px;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crop-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.crop-variety { font-size: 12px; color: var(--text-3); }

.crop-meta { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.crop-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}
.crop-meta-label { color: var(--text-3); }
.crop-meta-value { color: var(--text-2); font-weight: 500; }

.progress-bar-wrap {
  margin-top: 12px;
}
.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 5px;
}
.progress-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.5s ease;
}

/* ===== CALENDAR ===== */
.calendar-wrap {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.calendar-title { font-size: 16px; font-weight: 700; color: var(--text); }

.calendar-nav { display: flex; gap: 8px; }

.cal-nav-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: all 0.15s;
}
.cal-nav-btn:hover { background: var(--bg); color: var(--text); }
.cal-nav-btn svg { width: 16px; height: 16px; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day-header {
  padding: 10px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--border-light);
}

.cal-day {
  min-height: 90px;
  padding: 8px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--border-light); }

.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .cal-day-num { color: var(--text-4); }

.cal-day.today { background: rgba(64,145,108,0.05); }
.cal-day.today .cal-day-num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}

.cal-events { display: flex; flex-direction: column; gap: 2px; }

.cal-event {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-event.planting { background: var(--primary-xlight); color: var(--primary-dark); }
.cal-event.harvest { background: var(--amber-light); color: #92400e; }
.cal-event.delivery { background: var(--blue-light); color: #1d4ed8; }
.cal-event.task { background: var(--purple-light); color: #5b21b6; }

.cal-event-more {
  font-size: 10px;
  color: var(--text-4);
  padding-left: 4px;
}

/* ===== TASK ITEMS ===== */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--border-light); }

.task-checkbox {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}
.task-checkbox.checked { background: var(--primary); border-color: var(--primary); }
.task-checkbox svg { width: 12px; height: 12px; color: white; }

.task-content { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.task-title.done { text-decoration: line-through; color: var(--text-3); }
.task-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-meta-text { font-size: 11.5px; color: var(--text-4); }

.task-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.task-item:hover .task-actions { opacity: 1; }

/* ===== INVENTORY ===== */
.inv-alert { background: var(--red-light); color: var(--red); }
.inv-warn { background: var(--amber-light); color: #92400e; }

/* ===== PRIORITY INDICATORS ===== */
.priority-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.priority-high { background: var(--red); }
.priority-medium { background: var(--amber); }
.priority-low { background: var(--text-4); }

/* ===== CONTACT CARDS ===== */
.contact-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.contact-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: box-shadow 0.2s;
}

.contact-card:hover { box-shadow: var(--shadow); }

.contact-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.contact-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.contact-name { font-size: 14.5px; font-weight: 700; color: var(--text); }
.contact-company { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.contact-info { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.contact-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-3);
}
.contact-info-row svg { width: 14px; height: 14px; flex-shrink: 0; }

.contact-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* ===== SUMMARY MINI CARDS ===== */
.mini-list { display: flex; flex-direction: column; gap: 8px; }

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  gap: 8px;
}

.mini-item-name { font-size: 13px; font-weight: 500; color: var(--text-2); }
.mini-item-sub { font-size: 11.5px; color: var(--text-4); margin-top: 2px; }
.mini-item-val { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ===== LOT / BATCH BADGE ===== */
.lot-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--teal-light);
  color: #0f766e;
  font-family: monospace;
}

.batch-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--blue-light);
  color: #1d4ed8;
  font-family: monospace;
}

/* ===== AUDIT PAGE ===== */
.audit-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.audit-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.audit-stat-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.audit-stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.audit-chain-row {
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0;
  overflow: hidden;
}

.audit-chain-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.audit-chain-header:hover { background: var(--border); }

.audit-chain-detail {
  padding: 0 14px 12px;
  display: none;
  border-top: 1px solid var(--border);
}

.audit-chain-detail.open { display: block; }

.traceability-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.trace-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  flex: 1;
  position: relative;
}

.trace-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--border);
}

.trace-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  z-index: 1;
}

.trace-dot svg { width: 15px; height: 15px; }
.trace-dot.green { background: var(--primary-xlight); color: var(--primary); }
.trace-dot.blue  { background: var(--blue-light); color: var(--blue); }
.trace-dot.amber { background: var(--amber-light); color: var(--amber); }
.trace-dot.teal  { background: var(--teal-light); color: var(--teal); }
.trace-dot.purple { background: var(--purple-light); color: var(--purple); }

.trace-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 3px; }
.trace-value { font-size: 12px; font-weight: 600; color: var(--text-2); text-align: center; }
.trace-sub   { font-size: 10.5px; color: var(--text-4); text-align: center; margin-top: 1px; }

.audit-filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.compliance-pass  { color: var(--primary); font-weight: 600; font-size: 12px; }
.compliance-fail  { color: var(--red); font-weight: 600; font-size: 12px; }
.compliance-pending { color: var(--amber); font-weight: 600; font-size: 12px; }

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar, .topbar, .page-header .btn, .td-actions,
  #add-new-btn, #menu-toggle, #notification-btn,
  .audit-filter-bar .btn { display: none !important; }

  #app-container { display: block; }
  .main-wrapper { overflow: visible; }
  .page-content { padding: 0; overflow: visible; }

  .table-wrap { box-shadow: none; border: 1px solid #ccc; }
  table { font-size: 11px; }
  thead th { background: #f0f0f0 !important; }

  .audit-summary-grid { grid-template-columns: repeat(4, 1fr); }

  .print-header {
    display: block !important;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #333;
  }

  body { font-size: 12px; color: #000; }
}

.print-header { display: none; }

/* ===== ORDER ITEMS ===== */
.order-items-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.order-items-table td { padding: 4px 8px; color: var(--text-2); }
.order-items-table td:last-child { text-align: right; font-weight: 600; }

/* ===== VIEW TOGGLE ===== */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle-btn {
  padding: 6px 10px;
  border: none;
  background: var(--card);
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.view-toggle-btn:hover { background: var(--bg); }
.view-toggle-btn.active { background: var(--primary); color: white; }
.view-toggle-btn svg { width: 16px; height: 16px; }

/* ===== QUICK STATS SECTION ===== */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ===== GROW LOCATIONS ===== */
.location-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.location-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.location-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.location-card-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.location-type-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.location-type-icon svg { width: 20px; height: 20px; }
.location-type-icon.field      { background: var(--primary-xlight); color: var(--primary); }
.location-type-icon.hightunnel { background: var(--blue-light); color: var(--blue); }
.location-type-icon.bed        { background: var(--amber-light); color: var(--amber); }
.location-type-icon.greenhouse { background: var(--teal-light); color: var(--teal); }
.location-type-icon.indoor     { background: var(--purple-light); color: var(--purple); }

.location-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.location-dim  { font-size: 12px; color: var(--text-3); }

.location-address {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-4);
  margin-top: 4px;
  line-height: 1.4;
}

/* Map button */
.btn-map {
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-map:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Google Maps embed iframe inside modal */
.location-map-embed {
  width: 100%;
  height: 380px;
  border: none;
  border-radius: var(--radius-sm);
  display: block;
}

.location-card-body { padding: 14px 18px; }

.condition-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.condition-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--border-light);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.condition-pill svg { width: 12px; height: 12px; color: var(--text-3); }

.water-pill { grid-column: 1 / -1; }
.water-pass { background: #d8f3dc; color: #1b4332; border-color: #b7e4c7; }
.water-fail { background: #fde8e8; color: #c0392b; border-color: #f5c6c6; }

.location-card-footer {
  padding: 10px 18px;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
}

/* ===== AUDIT TABS ===== */
.audit-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.audit-tab {
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}

.audit-tab:hover { color: var(--text); }
.audit-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ===== REPORT GENERATOR ===== */
.report-generator {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 0 40px;
}

.report-gen-header {
  margin-bottom: 28px;
}
.report-gen-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.report-gen-sub {
  font-size: 14px;
  color: var(--text-3);
}

/* Filter option cards */
.report-filter-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.report-filter-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
}
.report-filter-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.report-filter-card.active {
  border-color: var(--primary);
  background: rgba(64,145,108,0.05);
}
.report-filter-card.active .rfc-icon {
  background: var(--primary);
  color: #fff;
}
.rfc-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-xlight);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  transition: background 0.15s, color 0.15s;
}
.rfc-icon svg { width: 22px; height: 22px; }
.rfc-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.rfc-desc {
  font-size: 11.5px;
  color: var(--text-3);
}

/* Filter input panel */
.report-filter-input-wrap {
  margin-bottom: 28px;
  min-height: 80px;
}
.rfi-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.rfi-all {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
  background: rgba(64,145,108,0.04);
  border-color: var(--primary-light);
}
.rfi-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.rfi-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Lot / Batch checkbox grid */
.rpt-search-box { margin: 12px 0 14px; max-width: 340px; }

.report-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}
.report-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  background: var(--bg);
}
.report-check-item:hover {
  background: var(--primary-xlight);
  border-color: var(--primary-light);
}
.report-check-item input[type=checkbox] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Generate button */
.report-gen-actions {
  display: flex;
  justify-content: center;
}
.report-gen-btn {
  padding: 13px 40px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(64,145,108,0.3);
}
.report-gen-btn:hover {
  box-shadow: 0 6px 20px rgba(64,145,108,0.4);
  transform: translateY(-1px);
}

/* ===== INSPECTOR REPORT ===== */
.crop-select-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.crop-select-table thead th {
  background: var(--border-light);
  padding: 10px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.crop-select-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
  vertical-align: middle;
}
.crop-select-table tbody tr:last-child td { border-bottom: none; }
.crop-select-table tbody tr:hover td { background: var(--border-light); }
.crop-select-table tbody tr.selected td { background: rgba(64,145,108,0.06); }

.crop-checkbox {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.report-actions .selection-count {
  font-size: 12.5px;
  color: var(--text-3);
  margin-left: auto;
}

/* ===== INSPECTOR PRINT REPORT ===== */
.inspector-report-preview {
  display: none;
}

/* Inspector report print — landscape, compact, headers repeat */
@page { size: landscape; margin: 10mm 12mm; }

@media print {
  /* Hide all app chrome */
  .sidebar, .topbar, .page-header, .audit-tabs,
  .audit-filter-bar, .report-actions, .audit-summary-grid,
  #add-new-btn, #menu-toggle, .td-actions,
  .btn-icon, .notification-wrap,
  .report-preview-toolbar, .report-preview-scroll,
  #inspector-crop-select-section,
  .inspector-report-preview ~ *:not(#inspector-sig-block) { display: none !important; }

  /* Make body and layout print-friendly */
  html, body { margin: 0 !important; padding: 0 !important; background: white !important; overflow: visible !important; }
  #app-container { display: block !important; }
  .main-wrapper  { overflow: visible !important; display: block !important; }
  .page-content  { padding: 0 !important; overflow: visible !important; }

  /* Show report elements */
  .inspector-report-preview { display: block !important; }
  .report-farm-header { display: block !important; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid #1b4332; }

  /* Table — landscape + tight + color-accurate; reset min-width so table fits the printed page */
  table { width: 100% !important; min-width: 0 !important; border-collapse: collapse !important; font-size: 7.5px !important; table-layout: auto !important; }
  .report-table-scroll { overflow: visible !important; }
  th, td { padding: 3px 4px !important; border: 1px solid #bbb !important; vertical-align: top !important; word-break: break-word; }
  thead { display: table-header-group; }          /* repeat header on every page */
  tr    { page-break-inside: avoid; }
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  thead th { background: #d8f3dc !important; color: #1b4332 !important; font-size: 7px !important; }

  /* Signature block */
  #inspector-sig-block { display: block !important; margin-top: 24px; page-break-inside: avoid; }
}

.print-header { display: none; }
.report-farm-header { display: none; }

/* ===== REPORT PREVIEW OVERLAY ===== */
.report-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #525659;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.report-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #3c4043;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.3);
}

.report-preview-toolbar .btn-secondary {
  background: rgba(255,255,255,0.1);
  color: #e8eaed;
  border-color: rgba(255,255,255,0.25);
}
.report-preview-toolbar .btn-secondary:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

.report-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: #e8eaed;
  letter-spacing: 0.2px;
}

.report-preview-hint {
  font-size: 12px;
  color: #9aa0a6;
  white-space: nowrap;
}

.report-preview-scroll {
  flex: 1;
  overflow: auto;           /* scroll both axes if paper wider than viewport */
  padding: 32px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.report-preview-paper {
  background: #ffffff;
  width: 100%;
  max-width: 1400px;
  padding: 40px 48px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.25);
  border-radius: 2px;
  font-size: 9px;
  color: #111;
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

/* Scroll wrapper — table scrolls horizontally inside the white paper */
.report-table-scroll {
  overflow-x: auto;
  width: 100%;
}

/* Main report table — wide enough to hold all 17 FSMA columns */
.report-main-table {
  min-width: 1400px;
  width: 100%;
  border-collapse: collapse;
  font-size: 8px;
}

/* Fallback: any other table inside preview */
.report-preview-paper table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 8px;
}
.report-preview-paper th,
.report-preview-paper td {
  padding: 3px 5px;
  border: 1px solid #ccc;
  vertical-align: top;
  word-break: break-word;
}
.report-preview-paper thead th {
  background: #d8f3dc;
  color: #1b4332;
  font-weight: 700;
  font-size: 7.5px;
  white-space: nowrap;
}

.report-preview-header-block {
  margin-bottom: 16px;
  padding-bottom: 12px;
}

/* Hide overlay toolbar when printing (print from preview uses window.print()) */
@media print {
  .report-preview-overlay { display: none !important; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .dashboard-row-3 { grid-template-columns: 1fr 1fr; }
}

/* ===== BOTTOM NAV (mobile only) ===== */
.bottom-nav {
  display: none;
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 299;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  /* Sidebar — slides in from left as overlay */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    z-index: 300; transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px !important; min-width: 260px !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  /* Ensure collapsed class doesn't shrink sidebar on mobile */
  .sidebar.collapsed { width: 260px !important; min-width: 260px !important; }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .brand-name,
  .sidebar.collapsed .farm-name-text,
  .sidebar.collapsed .farm-role-text { opacity: 1 !important; pointer-events: auto !important; }
  .sidebar.collapsed .brand-logo-img { width: 110px !important; object-fit: unset !important; }

  /* Main wrapper takes full width */
  .main-wrapper { margin-left: 0 !important; width: 100% !important; }

  /* Topbar */
  .topbar-date { display: none; }
  #add-new-btn .btn-label { display: none; }
  #add-new-btn svg { margin-right: 0; }
  #add-new-btn { padding: 8px 12px; min-width: 40px; }

  /* Page content — extra bottom padding for bottom nav */
  .page-content { padding: 12px 12px 80px; }

  /* Stat cards — 2 columns */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Dashboard rows — single column */
  .dashboard-row { grid-template-columns: 1fr; }
  .dashboard-row-3 { grid-template-columns: 1fr; }

  /* Forms — single column */
  .form-grid-2 { grid-template-columns: 1fr; }

  /* Cards — single column */
  .crop-cards-grid { grid-template-columns: 1fr; }
  .contact-cards-grid { grid-template-columns: 1fr; }

  /* Tables — horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 580px; }

  /* Modal — bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 82vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    /* No position:fixed here — let flexbox handle it */
  }
  .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .modal-header { padding: 16px 18px 12px; }
  .modal-footer { padding: 12px 18px; }
  /* Ensure header/footer never get squeezed */
  .modal-header { flex-shrink: 0; }
  .modal-footer { flex-shrink: 0; }

  /* AI chat — hidden by default on mobile; shown when user taps AI button in sidebar */
  #ai-chat-widget { display: none; bottom: 76px; right: 16px; }
  .ai-chat-panel { width: calc(100vw - 32px); max-width: 400px; }
  .ai-chat-panel.open { max-height: 60vh; }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px; z-index: 200;
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; border: none; background: none;
    color: var(--text-3); font-size: 10px; font-family: var(--font);
    font-weight: 500; cursor: pointer; padding: 6px 4px;
    transition: color 0.15s;
  }
  .bottom-nav-item svg { width: 20px; height: 20px; }
  .bottom-nav-item.active { color: var(--primary); }
  .bottom-nav-item.active svg { stroke: var(--primary); }
}

/* ===== MISC ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.color-green { color: var(--primary); }
.color-red { color: var(--red); }
.color-amber { color: var(--amber); }
.color-blue { color: var(--blue); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.clickable { cursor: pointer; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* Tooltip */
[title] { position: relative; }

/* ── AI CHAT WIDGET ─────────────────────────── */
#ai-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.ai-chat-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(64,145,108,0.4);
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.ai-chat-toggle:hover { background: var(--primary-dark); transform: scale(1.07); }
.ai-chat-toggle svg { width: 22px; height: 22px; }
.ai-chat-toggle.open .ai-chat-toggle-close { display: flex !important; }
.ai-chat-toggle.open > svg:first-child { display: none; }

.ai-chat-panel {
  width: 340px;
  max-height: 520px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.22s, transform 0.22s;
}
.ai-chat-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
  animation: aiPanelIn 0.22s ease;
}

.ai-chat-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-chat-avatar svg { width: 18px; height: 18px; }
.ai-chat-name { font-weight: 600; font-size: 0.9rem; }
.ai-chat-status { font-size: 0.72rem; opacity: 0.85; margin-top: 1px; }
.ai-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.ai-chat-close:hover { opacity: 1; }
.ai-chat-close svg { width: 18px; height: 18px; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ai-chat-msg { display: flex; }
.ai-chat-msg.user { justify-content: flex-end; }
.ai-chat-msg.ai  { justify-content: flex-start; }

.ai-chat-bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  word-break: break-word;
}
.ai-chat-msg.user .ai-chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg.ai .ai-chat-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.ai-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}
.ai-typing-bubble span {
  width: 7px;
  height: 7px;
  background: var(--text-3);
  border-radius: 50%;
  display: inline-block;
  animation: aiTypingDot 1.2s infinite ease-in-out;
}
.ai-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiTypingDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.84rem;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  font-family: inherit;
}
.ai-chat-input:focus { border-color: var(--primary); }
.ai-chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-chat-input::placeholder { color: var(--text-4); }

.ai-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ai-chat-send:hover { background: var(--primary-dark); }
.ai-chat-send svg { width: 15px; height: 15px; }

@keyframes aiPanelIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  #ai-chat-widget { bottom: 16px; right: 16px; }
  .ai-chat-panel { width: calc(100vw - 32px); }
}

/* ═══════════════════════════════════════════
   ORG DASHBOARD
   ═══════════════════════════════════════════ */

/* Auth signup toggle */
.auth-toggle-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13.5px; font-weight: 500;
  color: var(--text-1);
}
.auth-toggle-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.auth-type-hint { font-size: 11.5px; color: var(--text-4); margin-top: 4px; }

/* Org container layout */
#org-container {
  width: 100%; height: 100vh;
  flex-direction: row;
  background: var(--bg);
}

/* Org sidebar */
/* Org dashboard uses a blue sidebar palette (scoped — farmer stays green) */
#org-container {
  --sidebar-bg: #2d4c94;
  --sidebar-hover: #3a5aa8;
  --sidebar-active: #4664b8;
  --sidebar-text: #cdd9f2;
  --sidebar-text-muted: #93a8d8;
}

.org-sidebar {
  width: 240px; min-width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.org-sidebar-top {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.org-sidebar-org-name {
  font-size: 13px; font-weight: 600;
  color: var(--sidebar-text);
  margin-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-nav {
  flex: 1; padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.org-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  border: none; background: none;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  font-family: var(--font); cursor: pointer; width: 100%;
  text-align: left; transition: background 0.15s, color 0.15s;
}
.org-nav-item svg { width: 17px; height: 17px; flex-shrink: 0; stroke: var(--sidebar-text); }
.org-nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.org-nav-item:hover svg { stroke: #fff; }
.org-nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.org-nav-item.active svg { stroke: #fff; }
.org-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 8px;
}
.org-name-display {
  flex: 1; font-size: 13px; font-weight: 600;
  color: var(--sidebar-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Org main area */
.org-main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  min-width: 0;
}
.org-topbar {
  height: 56px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
}
.org-topbar h1 { font-size: 17px; font-weight: 600; color: var(--text-1); }
.org-page { max-width: 1100px; }
.org-section-title {
  font-size: 16px; font-weight: 600;
  color: var(--text-1); margin-bottom: 16px;
}

/* Farm cards */
.org-farm-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.org-farm-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.org-farm-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); border-color: var(--primary); }
.org-farm-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.org-farm-name  { font-size: 14px; font-weight: 600; color: var(--text-1); }
.org-farm-owner { font-size: 12px; color: var(--text-3); }
.org-farm-stats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.org-farm-contact { font-size: 12px; color: var(--text-3); margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.org-farm-footer { border-top: 1px solid var(--border); padding-top: 10px; }

/* Farm detail */
.org-farm-detail-header {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 20px;
}

/* Tabs */
.org-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.org-tab {
  padding: 8px 16px; border: none; background: none;
  font-size: 13.5px; font-weight: 500; font-family: var(--font);
  color: var(--text-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s;
}
.org-tab:hover { color: var(--text-1); }
.org-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Status filter pills */
.org-status-filter {
  padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 99px; background: none;
  font-size: 12px; font-weight: 500; font-family: var(--font);
  color: var(--text-2); cursor: pointer; transition: all 0.15s;
}
.org-status-filter:hover { border-color: var(--primary); color: var(--primary); }
.org-status-filter.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Supply feed — per-farm blocks */
.org-supply-farm-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.org-supply-farm-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.org-supply-subsection { padding: 14px 18px; }
.org-supply-subsection + .org-supply-subsection { border-top: 1px solid var(--border); }
.org-supply-subsection-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 10px;
  display: flex; align-items: center;
}

/* Invite code display */
.org-invite-code {
  font-family: monospace; font-size: 13px; font-weight: 700;
  background: var(--bg); padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.1em; color: var(--primary-dark);
}

/* Farmer-side invite banner */
.org-invite-banner {
  background: var(--primary-light);
  border-bottom: 2px solid var(--primary);
  padding: 12px 20px; z-index: 50;
}
.org-invite-content {
  display: flex; align-items: center; gap: 14px;
  max-width: 860px; flex-wrap: wrap;
}

/* Farm Settings — certification rows */
.cert-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 150px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.cert-row .cert-custom { grid-column: 1 / -1; }
.cert-row .btn-icon { width: 32px; height: 32px; }
@media (max-width: 768px) {
  .cert-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .cert-row .cert-type   { grid-column: 1 / -1; }
  .cert-row .cert-custom { grid-column: 1 / -1; }
  .cert-row .btn-icon { justify-self: end; }
}

/* Farm Settings — "you're a member of X" badge */
.fs-org-member-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(64,145,108,0.12);
  color: var(--primary-dark);
  border: 1px solid rgba(64,145,108,0.35);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* Utility */
.link-btn {
  background: none; border: none; color: var(--primary);
  font-size: inherit; font-family: var(--font);
  cursor: pointer; padding: 0; text-decoration: underline;
}

/* Org responsive */
@media (max-width: 768px) {
  #org-container { flex-direction: column; }
  .org-sidebar { width: 100%; min-width: unset; flex-direction: row; flex-wrap: wrap; height: auto; }
  .org-sidebar-top { padding: 10px 12px; border-bottom: none; border-right: 1px solid var(--border); }
  .org-nav { flex-direction: row; padding: 6px 8px; flex: 1; overflow-x: auto; gap: 2px; }
  .org-nav-item { white-space: nowrap; padding: 7px 10px; font-size: 12px; }
  .org-sidebar-footer { padding: 8px 12px; }
  .org-name-display { display: none; }
  .org-topbar { padding: 0 14px; }
  .org-topbar h1 { font-size: 15px; }
  #org-page-content { padding: 14px 14px 80px; }
  .org-farm-cards { grid-template-columns: 1fr; }
  .org-invite-content { flex-direction: column; align-items: flex-start; gap: 10px; }
}
