/* ============================================================
   Venkateshwara Farms — Irrigation Log
   Design: Swiss Modernism / Executive Dashboard
   Font: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ────────────────────────────────────────── */
:root {
  /* Brand greens — unchanged */
  --green-900: #0D2318;
  --green-800: #1C3829;
  --green-700: #2E7D32;
  --green-500: #4CAF50;
  --green-400: #66BB6A;
  --green-100: #E8F5E9;
  --green-50:  #F0FBF1;

  /* Semantic aliases */
  --primary:        var(--green-700);
  --primary-dark:   var(--green-800);
  --accent:         var(--green-500);
  --accent-hover:   #388E3C;

  /* Surfaces */
  --bg:       #F8FAFC;  /* near-neutral, not greenish */
  --surface:  #FFFFFF;
  --surface-2: #F8FAFC;

  /* Typography */
  --text:       #0F1A16;
  --text-muted: #5A6A64;
  --text-light: #8FA399;

  /* Borders */
  --border:    rgba(0, 0, 0, .08);
  --border-md: rgba(0, 0, 0, .12);

  /* Elevation — 2-layer system (ring + blur) */
  --shadow-sm:  0 0 0 1px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.05);
  --shadow:     0 0 0 1px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.06), 0 8px 20px rgba(0,0,0,.04);
  --shadow-hover: 0 0 0 1px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.08), 0 16px 32px rgba(0,0,0,.06);
  --shadow-deep: 0 0 0 1px rgba(0,0,0,.10), 0 8px 24px rgba(0,0,0,.12), 0 24px 48px rgba(0,0,0,.08);

  /* Shape */
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Sidebar */
  --sidebar-w: 240px;

  /* Danger */
  --danger:       #DC2626;
  --danger-hover: #B91C1C;
}

/* ── Reset ──────────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .3rem;
}

.sidebar-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.10);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.12);
}
.sidebar-icon svg { width: 16px; height: 16px; }

.sidebar-title {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: #fff;
}

.sidebar-subtitle {
  font-size: .72rem;
  color: rgba(255,255,255,.38);
  letter-spacing: .01em;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .625rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .6rem .75rem;
  color: rgba(255,255,255,.60);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  cursor: pointer;
  letter-spacing: .005em;
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.90);
}

.nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: .5rem .625rem .875rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

.logout-link { color: rgba(255,255,255,.42); }
.logout-link:hover { color: #FCA5A5; background: rgba(220,38,38,.12); }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.75rem 2rem;
  min-width: 0;
  max-width: 1400px;
}

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none;
  position: fixed;
  top: .875rem; left: .875rem;
  z-index: 200;
  background: var(--green-900);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.375rem;
  margin-bottom: 1.25rem;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

.month-badge {
  font-size: .72rem;
  font-weight: 600;
  background: var(--green-100);
  color: var(--green-700);
  padding: .2rem .65rem;
  border-radius: 20px;
  margin-left: .5rem;
  vertical-align: middle;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════
   KPI CARDS
══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.375rem;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  transition: box-shadow .2s;
  cursor: default;
}

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

.kpi-body { display: flex; flex-direction: column; gap: .25rem; }

.kpi-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1;
}

.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: .1rem;
}

.kpi-icon {
  width: 40px; height: 40px;
  background: var(--green-100);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: .1rem;
}
.kpi-icon svg { width: 20px; height: 20px; color: var(--green-700); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.chart-card { padding: 1.25rem; }
.chart-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: .875rem;
}

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

.section-header h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}

.link-sm {
  font-size: .8rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.link-sm:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: .55rem .875rem;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-md);
}

.data-table td {
  padding: .625rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F5FBF6; }

/* Settings table */
.settings-table {
  width: auto;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: .5rem;
}
.settings-table th {
  text-align: left;
  padding: .5rem .875rem;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--border-md);
}
.settings-table td {
  padding: .575rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.settings-table tr:last-child td { border-bottom: none; }

/* ── Settings tabs ── */
.settings-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-md);
  padding-bottom: .5rem;
}

.stab {
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .45rem 1.1rem;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
  letter-spacing: .005em;
}
.stab:hover { background: var(--bg); color: var(--text); }
.stab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

/* Settings helpers */
.settings-hint { color: var(--text-muted); font-size: .875rem; margin-bottom: .625rem; line-height: 1.5; }
.badge-row { display: flex; flex-wrap: wrap; gap: .375rem; margin-bottom: .5rem; }
.inline-add-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.settings-hr { margin: 1.25rem 0; border: none; border-top: 1px solid var(--border); }
.fert-textarea {
  width: 100%;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .84rem;
  padding: .625rem .75rem;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  resize: vertical;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.fert-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,175,80,.12);
}

.duration-cell { font-weight: 700; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fert-cell { max-width: 220px; font-size: 12px; color: var(--text-muted); }
.actions-cell { white-space: nowrap; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--green-100);
  color: var(--green-800);
  border-radius: 6px;
  padding: .15rem .55rem;
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background .15s, color .15s, box-shadow .15s;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: .01em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,.16), 0 4px 12px rgba(76,175,80,.30);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border-md);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-full  { width: 100%; justify-content: center; padding: .7rem 1rem; font-size: .9rem; }
.btn-sm    { padding: .375rem .8rem; font-size: .79rem; }
.btn-xs    { padding: .25rem .6rem; font-size: .75rem; }

/* ══════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════ */
.form-card { max-width: 780px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: .79rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: .6rem .8rem;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;           /* match site font for textarea too */
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-group textarea {
  resize: vertical;
  min-height: 68px;
  line-height: 1.45;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,175,80,.12);
}

.form-group input[readonly] {
  background: var(--bg);
  color: var(--primary);
  cursor: default;
  font-weight: 700;
}

.duration-field { font-variant-numeric: tabular-nums; }
.req { color: var(--danger); font-size: .9em; }

.form-actions {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .625rem;
}

/* ── Filter bar ── */
.filter-card { padding: 1.125rem; margin-bottom: .875rem; }

.filter-form .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}

.filter-form .form-group { min-width: 140px; flex: 1; }
.filter-actions { display: flex; gap: .5rem; align-items: flex-end; padding-bottom: 1px; }

/* ── Export row ── */
.export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.record-count {
  font-size: .84rem;
  color: var(--text-muted);
  font-weight: 500;
}
.export-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════
   FLASH MESSAGES
══════════════════════════════════════════════════════════ */
.flash-container { margin-bottom: 1.25rem; }

.flash {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1.125rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  animation: slideDown .2s ease;
}

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

.flash-success {
  background: #F0FDF4;
  color: #14532D;
  border: 1px solid #BBF7D0;
}

.flash-error {
  background: #FEF2F2;
  color: #7F1D1D;
  border: 1px solid #FECACA;
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state p { font-size: .95rem; line-height: 1.7; }
.empty-state a { color: var(--primary); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }
.empty-state-sm {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-light);
  font-size: .875rem;
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-900);
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 60%, rgba(46,125,50,.25) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(76,175,80,.12) 0%, transparent 60%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-deep);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo-wrap {
  width: 60px; height: 60px;
  background: linear-gradient(145deg, var(--green-700), var(--green-500));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 16px rgba(46,125,50,.35);
}
.login-logo-wrap svg { width: 28px; height: 28px; color: #fff; }

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  margin-bottom: .3rem;
}
.login-subtitle {
  font-size: .84rem;
  color: var(--text-muted);
}

.login-card .form-group { margin-bottom: 1rem; }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .hamburger { display: flex; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 3.75rem;
  }

  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid  { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .page-header { flex-wrap: wrap; gap: .6rem; }
  .page-header h2 { font-size: 1.15rem; }
  .export-row { flex-direction: column; align-items: flex-start; }
  .settings-tabs { gap: .25rem; }
  .stab { padding: .4rem .85rem; font-size: .8rem; }
  .filter-form .form-group { min-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ══════════════════════════════════════════════════════════
   GRAPE REGISTER — additive styles
══════════════════════════════════════════════════════════ */

/* Sidebar nav grouped by module — each group gets its own accent color
   so supervisors can't confuse Irrigation vs Grape Register at a glance. */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: .25rem 0 .5rem .5rem;
  margin: .15rem 0;
  border-left: 3px solid transparent;
}
.nav-group + .nav-group { margin-top: .6rem; }

.nav-group-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: .35rem .25rem .35rem 0;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.nav-group-label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}

/* Irrigation — water blue */
.nav-group--irrigation        { border-left-color: #4fc3f7; }
.nav-group--irrigation .nav-group-label { color: #7fd4f7; }
.nav-group--irrigation .nav-link.active {
  background: rgba(79,195,247,.16);
  box-shadow: inset 2px 0 0 #4fc3f7;
}

/* Grape Register — grape purple */
.nav-group--grape             { border-left-color: #c084fc; }
.nav-group--grape .nav-group-label { color: #d8b4fe; }
.nav-group--grape .nav-link.active {
  background: rgba(192,132,252,.18);
  box-shadow: inset 2px 0 0 #c084fc;
}

/* Admin — amber */
.nav-group--admin             { border-left-color: #fbbf24; }
.nav-group--admin .nav-group-label { color: #fcd48a; }
.nav-group--admin .nav-link.active {
  background: rgba(251,191,36,.16);
  box-shadow: inset 2px 0 0 #fbbf24;
}

.section-card { margin-bottom: 1.1rem; }

/* Top of each card — biggest, boldest heading.
   Higher-specificity override so it wins over the older `.section-header h3`
   rule (at ~line 320) whenever .section-title lives inside a .section-header. */
.section-title,
.section-header h3.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin: 0 0 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

/* The .section-header wrapper puts the "+ Add …" button inline with the title;
   reset its margin so the title doesn't double-space when inside the header. */
.section-header { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.section-header h3.section-title { flex: 1; }

/* Short explanatory / helper lines below inputs or section titles */
.section-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .35rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
}

/* The per-field label (e.g. OBSERVATION) — .form-group label already handles
   uppercase + tracking, but we bump weight slightly so the hierarchy reads
   section-title > field-label > hint at a glance. Applied in both form cards
   and the filter bar so records + add screens stay visually consistent. */
.section-card .form-group > label,
.filter-card  .form-group > label { font-weight: 700; color: var(--text); }

.info-card { background: #f9fbfa; border-left: 3px solid var(--primary); }
.irrigation-panel .data-table { font-size: 12px; }

/* Repeatable child rows (spray / fert / cult) */
.spray-row, .fert-row, .cult-row {
  padding: .65rem .75rem;
  margin-bottom: .6rem;
  background: #fafbfa;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.child-row-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1fr .8fr .8fr .8fr 1fr auto;
  gap: .55rem;
  align-items: end;
}
.fert-row-grid { grid-template-columns: 2fr 1.2fr auto; }
.cult-row-grid { grid-template-columns: 1.2fr 2fr auto; }
.child-row-delete { justify-self: end; }

.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* Pest/disease quick tags */
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .35rem;
}
.form-group label.checkbox-pill,
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .8rem;
  background: #fff;
  border: 1px solid var(--border-md);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.2;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.checkbox-pill span {
  white-space: nowrap;         /* keep tag text on one line */
  text-transform: none;
  letter-spacing: 0;
  font-size: .85rem;
  color: var(--text);
}
/* Reset the global .form-group input styling so the checkbox renders as a tiny native box */
.checkbox-pill input[type="checkbox"] {
  width: 14px !important;
  height: 14px;
  padding: 0 !important;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  flex: 0 0 14px;
  accent-color: #b45309;
  appearance: auto;
  -webkit-appearance: checkbox;
}
.checkbox-pill:hover {
  background: #f7f8fa;
  border-color: #c7ccd2;
}
.checkbox-pill:has(input:checked) {
  background: #fff4d6;
  border-color: #e0a940;
  box-shadow: inset 0 0 0 1px #e0a940;
}
.checkbox-pill:has(input:checked) span { color: #7a4a00; }

.disease-badge {
  display: inline-block;
  padding: .15rem .5rem;
  background: #fde8e8;
  color: #b42318;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
}

/* Responsive child rows */
@media (max-width: 900px) {
  .child-row-grid,
  .fert-row-grid,
  .cult-row-grid {
    grid-template-columns: 1fr 1fr;
  }
  .child-row-delete { grid-column: 1 / -1; justify-self: start; }
}

/* ---------------------------------------------------------------------- */
/* Plot history page                                                      */
/* ---------------------------------------------------------------------- */

.plot-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.plot-summary-item {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.plot-summary-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.plot-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.chip {
  display: inline-block;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 999px;
  background: #f3e8ff;
  color: #6b21a8;
  letter-spacing: .02em;
}

.section-subtitle {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin: 1rem 0 .5rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pruning-history { border-top: 1px solid var(--border); padding-top: .75rem; }
.pruning-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.pruning-list li {
  font-size: .9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.pruning-list .muted { color: var(--text-muted); font-size: .82rem; }

.inline-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}
.inline-form .inline-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.inline-form select {
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
}

.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.timeline-entry {
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid #c084fc;
  border-radius: 8px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.timeline-entry--flagged { border-left-color: #dc2626; background: #fef2f2; }
.timeline-entry-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.timeline-date {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.timeline-entry-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--text-muted);
}
.timeline-entry-meta strong { color: var(--text); font-weight: 700; }
.timeline-obs {
  font-size: .88rem;
  color: var(--text);
  padding-top: .4rem;
  border-top: 1px dashed var(--border);
  line-height: 1.5;
}

.badge-link { text-decoration: none; }
.badge-link:hover .badge { filter: brightness(0.92); }

/* Audit badges */
.audit-badge {
  display: inline-block;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.audit-create { background: #dcfce7; color: #166534; }
.audit-update { background: #dbeafe; color: #1e40af; }
.audit-delete { background: #fee2e2; color: #991b1b; }

/* ---------------------------------------------------------------------- */
/* Settings — two-column shell with grouped vertical nav (Approach C)     */
/* ---------------------------------------------------------------------- */

.settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: .75rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding-left: .75rem;
  border-left: 3px solid var(--border);
}
.settings-group--irrigation { border-left-color: #4fc3f7; }
.settings-group--grape      { border-left-color: #c084fc; }

.settings-group-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.settings-group-label::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}
.settings-group--irrigation .settings-group-label { color: #0369a1; }
.settings-group--grape      .settings-group-label { color: #7e22ce; }

.snav {
  display: block;
  width: 100%;
  text-align: left;
  padding: .5rem .75rem;
  margin-left: -.75rem;      /* align left with group-label underline */
  padding-left: calc(.75rem + 3px);
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.snav:hover {
  background: #f3f4f6;
}
.snav.active {
  font-weight: 700;
  background: #f3f4f6;
}
.settings-group--irrigation .snav.active {
  border-left-color: #0284c7;
  background: #ecfeff;
  color: #075985;
}
.settings-group--grape .snav.active {
  border-left-color: #9333ea;
  background: #faf5ff;
  color: #6b21a8;
}

.settings-content { min-width: 0; }

/* Responsive: collapse to stacked layout on narrow screens */
@media (max-width: 768px) {
  .settings-shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .settings-nav {
    position: static;
    flex-direction: column;
    gap: 1rem;
  }
  .snav { font-size: .9rem; }
}
