/* ============================================================
   MFRE Estate — Irrigation Management
   Design: Clean modern with coffee/earth tones
   Font: Inter (Google Fonts)
   ============================================================ */

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

/* -- Design tokens ------------------------------------------ */
:root {
  /* Coffee / earth palette */
  --brown-900: #1C1210;
  --brown-800: #2D1F1B;
  --brown-700: #4A3228;
  --brown-600: #6B4C3B;
  --brown-500: #8B6F5E;

  /* Accent — warm terracotta/copper */
  --primary:        #B85C38;
  --primary-dark:   #9A4A2E;
  --primary-light:  #D4845F;
  --accent:         #B85C38;
  --accent-hover:   #9A4A2E;

  /* Success — sage green */
  --sage-600: #5F7161;
  --sage-500: #6D8B74;
  --sage-100: #E8F0E4;

  /* Surfaces */
  --bg:       #FAF8F5;
  --surface:  #FFFFFF;
  --surface-2: #F5F2EE;

  /* Typography */
  --text:       #1A1110;
  --text-muted: #6B5E58;
  --text-light: #9A8E88;

  /* Borders */
  --border:    rgba(0, 0, 0, .07);
  --border-md: rgba(0, 0, 0, .11);

  /* Shadows — warm-tinted */
  --shadow-sm:  0 0 0 1px rgba(28,18,16,.04), 0 1px 3px rgba(28,18,16,.06);
  --shadow:     0 0 0 1px rgba(28,18,16,.04), 0 2px 8px rgba(28,18,16,.06), 0 8px 24px rgba(28,18,16,.04);
  --shadow-hover: 0 0 0 1px rgba(28,18,16,.06), 0 4px 16px rgba(28,18,16,.08), 0 16px 36px rgba(28,18,16,.06);
  --shadow-deep: 0 0 0 1px rgba(28,18,16,.08), 0 8px 28px rgba(28,18,16,.12), 0 24px 52px rgba(28,18,16,.08);

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

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

  /* Danger */
  --danger:       #C0392B;
  --danger-hover: #A93226;
}

/* -- 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: 15px;
  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(--brown-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,.03);
}

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

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

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

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

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

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

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: .75rem;
}

.nav-group-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: .4rem .75rem .3rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .625rem .75rem;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  cursor: pointer;
  letter-spacing: .005em;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

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

.nav-link.active {
  background: rgba(184,92,56,.25);
  color: #fff;
  font-weight: 600;
}

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

.logout-link { color: rgba(255,255,255,.38); }
.logout-link:hover { color: #FCA5A5; background: rgba(192,57,43,.15); }

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

/* -- Hamburger (mobile) ------------------------------------- */
.hamburger {
  display: none;
  position: fixed;
  top: .875rem; left: .875rem;
  z-index: 200;
  background: var(--brown-900);
  color: #fff;
  border: none;
  width: 42px; height: 42px;
  border-radius: var(--radius);
  font-size: 1.15rem;
  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.5rem;
  margin-bottom: 1.25rem;
}

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

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

.page-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.month-badge {
  font-size: .72rem;
  font-weight: 600;
  background: #F3ECE5;
  color: var(--brown-600);
  padding: .2rem .7rem;
  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(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

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

.kpi-value {
  font-size: 1.95rem;
  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: .15rem;
}

.kpi-icon {
  width: 42px; height: 42px;
  background: #F3ECE5;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 20px; height: 20px; color: var(--brown-600); }

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

.chart-card { padding: 1.375rem; }
.chart-container { position: relative; height: 250px; width: 100%; }
.chart-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 1rem;
}

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

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

.link-sm {
  font-size: .82rem;
  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: 13.5px;
}

.data-table th {
  text-align: left;
  padding: .6rem 1rem;
  background: var(--surface-2);
  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: .7rem 1rem;
  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: #FAF6F2; }

/* -- Records table — polished layout ------------------------ */
.records-card { padding: 0; overflow: hidden; }

.records-table td { padding: .85rem 1rem; vertical-align: top; }
.records-table th { padding: .7rem 1rem; }

/* Date cell */
.date-cell {
  white-space: nowrap;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: .88rem;
}

/* Plot + Crop combined column */
.crop-label {
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 5px;
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.type-drip {
  background: #E3F0FF;
  color: #1A5CB0;
}
.type-spr {
  background: #E8F0E4;
  color: #3D6B3D;
}

/* Head / Valve meta */
.meta-cell {
  white-space: nowrap;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}
.meta-sep {
  color: var(--text-light);
  margin: 0 .15rem;
}

/* Time cell with arrow */
td.time-cell {
  white-space: nowrap;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  width: 1%;
}
.time-cell span,
.time-cell svg { vertical-align: middle; }
.time-arrow { margin: 0 .25rem; color: var(--text-light); }

.duration-cell {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: .35rem;
  align-items: center;
}

.remarks-cell {
  font-size: .84rem;
  color: var(--text-muted);
  max-width: 160px;
}

.no-data { color: var(--text-light); font-size: .82rem; }

/* -- Record summary bar ------------------------------------- */
.record-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.record-stat {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: .25rem .7rem;
  border-radius: 6px;
}
.record-stat svg { color: var(--text-light); }

/* -- Fertiliser display in tables --------------------------- */
.fert-cell {
  max-width: 280px;
}

.fert-pills {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.fert-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #F3ECE5;
  color: var(--brown-700);
  padding: .25rem .65rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid rgba(74,50,40,.06);
}

.fert-pill-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fert-pill-qty {
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* -- KPI icon color variants -------------------------------- */
.kpi-icon--sessions { background: #FFF3E0; }
.kpi-icon--sessions svg { color: #E65100; }
.kpi-icon--duration { background: #E3F0FF; }
.kpi-icon--duration svg { color: #1565C0; }
.kpi-icon--plots { background: #E8F0E4; }
.kpi-icon--plots svg { color: #2E7D32; }
.kpi-icon--motor { background: #FFF8E1; }
.kpi-icon--motor svg { color: #F9A825; }

/* -- Badge -------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  background: #F3ECE5;
  color: var(--brown-700);
  border-radius: 6px;
  padding: .2rem .65rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(184,92,56,.25);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(184,92,56,.35);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 3px rgba(192,57,43,.25);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-success {
  background: var(--sage-600);
  color: #fff;
}
.btn-success:hover { background: var(--sage-500); }

.btn-full  { width: 100%; justify-content: center; padding: .75rem 1rem; font-size: .92rem; }
.btn-sm    { padding: .4rem .85rem; font-size: .82rem; }
.btn-xs    { padding: .275rem .65rem; font-size: .77rem; }

/* == FORMS ================================================== */
.form-card { max-width: 820px; }

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

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.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: .65rem .9rem;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  font-size: .92rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-group textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(184,92,56,.10);
}

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

/* Valve checkboxes */
.valve-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--surface);
}
.valve-check {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: .87rem;
  transition: background .15s, border-color .15s;
}
.valve-check:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.valve-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.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: .75rem;
}

/* -- Fertiliser dynamic rows -------------------------------- */
.fert-section {
  margin-top: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.fert-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.fert-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.fert-row {
  display: grid;
  grid-template-columns: 2fr 1fr .8fr auto;
  gap: .65rem;
  align-items: end;
  padding: .65rem .75rem;
  margin-bottom: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.fert-row .form-group { margin: 0; }
.fert-row .form-group label {
  font-size: .7rem;
}

.fert-remove {
  align-self: end;
  margin-bottom: .15rem;
}

/* -- Filter bar --------------------------------------------- */
.filter-card { padding: 1.25rem; margin-bottom: 1rem; }

.filter-form .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  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: .875rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.record-count {
  font-size: .86rem;
  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: .9rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  animation: slideDown .25s ease;
}

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

.flash-success {
  background: #F0F7F1;
  color: #2D5A3D;
  border: 1px solid #C4DEC8;
}

.flash-error {
  background: #FDF2F1;
  color: #7A1F1F;
  border: 1px solid #F5C7C2;
}

/* -- Empty states ------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3.5rem 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.75rem;
  color: var(--text-light);
  font-size: .9rem;
}

/* == LOGIN PAGE ============================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brown-900);
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 60%, rgba(184,92,56,.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(107,76,59,.12) 0%, transparent 60%);
}

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

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

.login-logo-wrap {
  width: 62px; height: 62px;
  background: linear-gradient(145deg, var(--brown-700), var(--primary));
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.1rem;
  box-shadow: 0 4px 20px rgba(184,92,56,.35);
}
.login-logo-wrap svg { width: 28px; height: 28px; color: #fff; }

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

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

/* == SETTINGS =============================================== */
.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: 1rem;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.settings-group-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .35rem;
  padding-left: .75rem;
}

.snav {
  display: block;
  width: 100%;
  text-align: left;
  padding: .5rem .75rem;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, color .12s;
  font-family: inherit;
}
.snav:hover { background: var(--surface-2); }
.snav.active {
  font-weight: 700;
  background: #F3ECE5;
  color: var(--primary);
}

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

.settings-hint {
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: .625rem;
  line-height: 1.5;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .5rem;
}

.inline-add-form {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.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(--surface-2);
  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; }

.fert-textarea {
  width: 100%;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .84rem;
  padding: .65rem .8rem;
  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(--primary-light);
  box-shadow: 0 0 0 3px rgba(184,92,56,.10);
}

.stab-panel { display: none; }
.stab-panel.active { display: block; }

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

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

  .main-content {
    margin-left: 0;
    padding: 1.1rem;
    padding-top: 4rem;
  }

  .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.2rem; }
  .export-row { flex-direction: column; align-items: flex-start; }
  .kpi-value { font-size: 1.55rem; }
  .kpi-label { font-size: .68rem; }
  .kpi-icon { width: 38px; height: 38px; }
  .kpi-icon svg { width: 18px; height: 18px; }
  .fert-row { grid-template-columns: 1fr 1fr; }
  .fert-remove { grid-column: 1 / -1; justify-self: start; }

  .settings-shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .settings-nav { position: static; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { flex-direction: row; align-items: center; }
  .kpi-value { font-size: 1.4rem; }
  .filter-form .form-group { min-width: 100%; }
}

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