/* ============================================================
   AgroAI — interactive field map
   Dark, earthy "precision monitoring instrument" theme.
   Visual layer only — no IDs/classes the app logic relies on
   are renamed (.armed, .spin,
   .status.info/ok/error, .sw, .sar-overlay all preserved).
   Design tokens (palette/type/spacing/shadows) live in tokens.css,
   which this page loads first.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* The page now scrolls: analysis up top, the 7-day forecast below it. */
  min-height: 100%;
}
/* The Leaflet map fills its framed container in the dashboard grid. */
#map { position: absolute; inset: 0; z-index: 0; background: var(--bg); }

/* Ambient aurora — a slow drifting colour wash, FIXED behind the page so it
   stays put as the document scrolls (above the bg, below all content). */
body::before {
  content: ""; position: fixed; inset: -10%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 38% at 82% 6%, rgba(46, 125, 50, 0.14), transparent 70%),
    radial-gradient(38% 40% at 8% 92%, rgba(46, 111, 176, 0.10), transparent 70%);
  opacity: 0.85;
  animation: aurora 16s var(--ease) infinite;
  will-change: transform, opacity;
}

/* Tabular figures everywhere numbers appear, so data stays aligned */
.result-date, .result-meta, .legend, .wordmark .tag {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Small eyebrow/label type roles (this page is self-contained on the dark theme) */
.t-micro { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

/* Accessible focus for every interactive element */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   Top bar — sticky full-width header for the scrolling dashboard
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: var(--s4);
  padding: 10px clamp(16px, 4vw, 36px);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--glass-edge);
  animation: rise 0.5s var(--ease) both;
}
.topbar .mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.4s var(--ease);
}
.topbar:hover .mark { transform: scale(1.04); }
.topbar .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* push the nav + live status to the right edge */
.topbar .brand-nav { margin-left: auto; }
.wordmark { display: flex; flex-direction: column; line-height: 1; }
.wordmark .name {
  font-family: var(--font-head);
  font-size: 19px; font-weight: 600; letter-spacing: -0.01em; color: var(--text);
}
.wordmark .name b { color: var(--accent); font-weight: 700; }
.wordmark .tag {
  font-size: 9px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); margin-top: 4px;
}
.live {
  display: inline-flex; align-items: center; gap: 7px; margin-left: var(--s1);
  padding-left: var(--s3); border-left: 1px solid var(--border);
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.55); animation: ping 1.8s infinite;
}
@keyframes ping { 75%, 100% { box-shadow: 0 0 0 7px rgba(46, 125, 50, 0); } }

/* logo doubles as the "back to site" link; nav links interconnect the pages */
.brand-home { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; }
.brand-nav { display: flex; align-items: center; gap: var(--s4); margin-left: var(--s2); padding-left: var(--s4); border-left: 1px solid var(--border); }
.brand-nav a {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; transition: color 0.15s var(--ease);
}
.brand-nav a:hover { color: var(--accent); }


/* ---- Location (optional map recentre) ---- */
.locate-block { margin-bottom: var(--s4); }
.locate-hint {
  margin: 0 0 var(--s2); font-size: 13px; line-height: 1.5; color: var(--text);
}
.locate-hint strong { color: var(--accent); font-weight: 600; }
/* larger, more prominent than the draw/clear row so the ask reads clearly */
.btn-locate { margin: 0; padding: 14px 16px; font-size: 14px; }
.btn-locate svg { width: 17px; height: 17px; }
.locate-priv {
  margin: var(--s2) 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted);
}
.locate-priv a { color: var(--accent); text-decoration: underline; }
.locate-priv a:hover { color: var(--accent-hover); }

/* ---- Buttons ---- */
.btn-row { display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.btn-row .btn { flex: 1; }
.btn {
  position: relative; overflow: hidden;
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 11px 14px; border-radius: var(--r-md);
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease),
              transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.btn svg { width: 15px; height: 15px; position: relative; z-index: 1; }
.btn:not(:disabled):hover { transform: translateY(-2px); }
.btn:not(:disabled):active { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* light sheen that sweeps across the high-emphasis actions on hover */
.btn-emerald::after, .btn-ghost.armed::after {
  content: ""; position: absolute; top: 0; left: -75%; width: 55%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.30), transparent);
  transform: skewX(-18deg); transition: left 0.6s var(--ease); pointer-events: none;
}
.btn-emerald:not(:disabled):hover::after, .btn-ghost.armed:not(:disabled):hover::after { left: 135%; }

/* primary — the single most important action; bright green reserved for this */
.btn-emerald { background: var(--accent-grad); color: var(--accent-ink); box-shadow: var(--glass-edge), var(--shadow-glow); }
.btn-emerald:not(:disabled):hover { box-shadow: var(--glass-edge), var(--shadow-glow-lg); }
/* secondary — elevated dark surface */
.btn-dark { background: var(--surface-sheen), var(--surface-2); color: var(--text); border-color: var(--border-strong); box-shadow: var(--glass-edge); }
.btn-dark:not(:disabled):hover { background: var(--surface-sheen), #E4EEDE; border-color: var(--accent-line); box-shadow: var(--glass-edge), var(--shadow-chrome); }
/* ghost — outlined accent */
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--accent-line); }
.btn-ghost:not(:disabled):hover { background: var(--accent-weak); border-color: var(--accent); }
.btn-ghost.armed { background: var(--accent-grad); color: var(--accent-ink); border-color: var(--accent); box-shadow: var(--glass-edge), var(--shadow-glow); }
/* quiet — low-emphasis */
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.btn-quiet:not(:disabled):hover { background: var(--surface-2); color: var(--text); }

/* ============================================================
   Status banner
   ============================================================ */
.status {
  margin: var(--s1) 0 var(--s2); padding: 11px var(--s3); border-radius: var(--r-md);
  font-size: 12.5px; line-height: 1.5; display: flex; gap: var(--s2); align-items: flex-start;
  border: 1px solid var(--border);
  animation: rise 0.3s var(--ease) both;
}
.status .spin {
  width: 15px; height: 15px; flex: none; margin-top: 1px;
  border: 2px solid rgba(20, 54, 26, 0.15); border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.status.info  { background: var(--water-weak);  border-color: var(--water-line);  color: var(--water); }
.status.ok    { background: var(--accent-weak);  border-color: var(--accent-line);  color: var(--accent); }
.status.warn  { background: var(--wheat-weak);   border-color: var(--wheat-line);   color: var(--wheat); }
.status.error { background: var(--danger-weak);  border-color: var(--danger-line);  color: var(--danger); }

/* ============================================================
   Result readout
   ============================================================ */
.result {
  margin-top: var(--s2); padding: var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-sheen), var(--surface-2);
  box-shadow: var(--glass-edge);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.result:hover { transform: translateY(-2px); box-shadow: var(--glass-edge), var(--shadow-lift); }
.result:not([hidden]) { animation: rise3d 0.45s var(--ease) both; }
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.result-date { font-family: var(--font-head); font-size: 13px; font-weight: 600; color: var(--text); }

/* Stacked bar of the actual per-class shares, dry → wet (left → right) */
.distribution {
  flex: 1; display: flex; height: 9px; border-radius: var(--r-pill);
  overflow: hidden; background: var(--surface); box-shadow: 0 0 0 1px var(--border) inset;
}
.distribution i { height: 100%; min-width: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 7px var(--s3); margin: 0; font-size: 11px; font-weight: 500; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18) inset; }

/* Discrete SAR overlay — keep 20 m cells as crisp blocks, never browser-smoothed */
.sar-overlay { image-rendering: pixelated; image-rendering: crisp-edges; }

.opacity { display: flex; flex-direction: column; gap: 7px; margin-top: var(--s3); }
.opacity input {
  width: 100%; cursor: pointer; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent) 0%, var(--border-strong) 100%);
}
.opacity input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-grad); border: 2px solid var(--surface);
  box-shadow: var(--glass-edge), var(--shadow-glow); transition: transform 0.12s var(--ease);
}
.opacity input::-webkit-slider-thumb:hover { transform: scale(1.12); }
.opacity input::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface);
  background: #2E7D32; box-shadow: var(--shadow-glow);
}
.result-meta { margin: var(--s3) 0 0; font-size: 11px; color: var(--muted-2); line-height: 1.5; }

/* ============================================================
   Leaflet chrome — frame the data, don't compete with it
   ============================================================ */
.leaflet-container { font-family: var(--font-body); background: var(--bg); }
.leaflet-control-zoom,
.leaflet-bar {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-chrome) !important;
  overflow: hidden;
}
.leaflet-control-zoom a,
.leaflet-bar a {
  background: var(--surface-glass) !important;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--muted) !important;
  border-bottom: 1px solid var(--border) !important;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.leaflet-control-zoom a:hover,
.leaflet-bar a:hover { color: var(--accent) !important; background: var(--surface-2) !important; }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.82) !important;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--muted-2) !important; font-size: 10px !important;
  border-top-left-radius: var(--r-sm); padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ============================================================
   Motion primitives
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
/* 3D entrance — element tips back into place, giving the panel/cards depth */
@keyframes rise3d {
  from { opacity: 0; transform: perspective(900px) translateY(18px) rotateX(8deg); }
  to   { opacity: 1; transform: perspective(900px) translateY(0) rotateX(0); }
}
/* slow ambient drift for the aurora wash */
@keyframes aurora {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
  50%      { transform: translate3d(1.5%, -2%, 0) scale(1.08); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .wordmark .tag, .live, .brand-nav { display: none; }
}

/* ============================================================
   Dashboard — single scrolling page (analysis up top, forecast below)
   ============================================================ */
.dash {
  position: relative; z-index: 2;
  max-width: 1280px; margin: 0 auto;
  padding: var(--s6) clamp(16px, 4vw, 28px) 56px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ---- Page head: field title + neutral trend headline ---- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.dash-h1 { margin: 0; font-family: var(--font-head); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }

.headline { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; max-width: 400px; animation: rise 0.4s var(--ease) both; }
.headline-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.headline-pill svg { width: 16px; height: 16px; }
.headline-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }
.headline-sub b { color: var(--text); font-weight: 600; }

/* ---- Stat tiles (Field Area · Average Soil Moisture · You are losing · …) ---- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.tile {
  background: var(--surface-sheen), var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--glass-edge); padding: 17px 18px;
  min-height: 110px; display: flex; flex-direction: column; justify-content: space-between;
}
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-top span { font-size: 13px; font-weight: 500; color: var(--muted); }
.tile-top svg { width: 18px; height: 18px; opacity: 0.9; }
.tile-val { font-family: var(--font-head); font-size: 30px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.tile-val small { font-size: 13px; font-weight: 500; color: var(--muted-2); margin-left: 5px; font-family: var(--font-body); }
.tile-val .note { font-size: 13px; font-weight: 600; margin-left: 7px; font-family: var(--font-body); }
.tile-val .sub { display: block; font-size: 12px; font-weight: 500; color: var(--muted-2); margin-top: 4px; font-family: var(--font-body); }
.tile-val.small { font-size: 19px; }

/* ---- Map + side column (controls before processing, readout after) ---- */
.mapgrid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.mapframe {
  position: relative; height: 540px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--glass-edge);
}
.mapframe #map { border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); }

/* floating chrome over the map */
.map-daylabel {
  position: absolute; top: 16px; left: 16px; z-index: 500;
  display: flex; align-items: center; gap: 8px;
  /* Near-solid so the current date stays legible over any satellite imagery. */
  background: rgba(255, 255, 255, 0.97); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 8px 13px; border-radius: var(--r-md); border: 1px solid var(--accent-line);
  box-shadow: var(--shadow-chrome), var(--glass-edge);
  font-size: 13px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.map-legend {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 500;
  display: flex; gap: 13px;
  background: var(--surface-glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-chrome), var(--glass-edge);
  font-size: 11px; font-weight: 600; color: var(--muted-2);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.sidecol { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.controls {
  background: var(--surface-sheen), var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--glass-edge); padding: var(--s6);
}

/* ---- Save / register the drawn field (signed-in "My Fields") ---- */
.register-block {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  display: grid;
  gap: var(--s3);
}
.register-block[hidden] { display: none; }   /* `display: grid` above would beat [hidden] */
/* "Replace your saved field?" (one field per account) */
.register-name { display: grid; gap: 5px; }
.register-name input {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.register-name input::placeholder { color: var(--muted-2); }
.register-name input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-weak); }
.register-name input:disabled { opacity: 0.6; cursor: default; }
.register-block .btn svg { width: 16px; height: 16px; }
.register-hint {
  margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted);
}
.register-hint a { color: var(--accent); font-weight: 600; }

/* ---- Per-day readout panel (analysis only) ---- */
.result-headings { min-width: 0; }
.r-kicker { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.r-title { margin: 3px 0 0; font-family: var(--font-head); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.r-date { font-family: var(--font-body); font-weight: 500; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.r-pill { padding: 4px 11px; border-radius: var(--r-pill); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.r-cap { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.r-moist {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 16px; margin-top: var(--s4); border: 1px solid; border-radius: var(--r-md);
}
.r-big { font-family: var(--font-head); font-size: 38px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.r-big small { font-size: 18px; }
.r-right { text-align: right; }
.r-mid { font-family: var(--font-head); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.r-mid small { font-size: 13px; }
.r-sub { display: block; font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.r-dist-wrap { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.result .distribution { height: 14px; }
.r-wx { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: var(--s4); }
.r-wxcell { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.r-wxval { display: flex; align-items: center; gap: 7px; font-family: var(--font-head); font-size: 18px; font-weight: 600; color: var(--text); margin-top: 5px; font-variant-numeric: tabular-nums; }
.r-wxval svg { width: 16px; height: 16px; }

/* ============================================================
   7-day forecast — day toolbar + the three graphs
   ============================================================ */
.forecast {
  background: var(--surface-sheen), var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--glass-edge); overflow: hidden;
  animation: rise 0.45s var(--ease) both;
}
.forecast-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.forecast-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.forecast-title svg { width: 16px; height: 16px; color: var(--accent); }
.forecast-note { margin: 0; padding: 10px 18px 0; font-size: 11.5px; color: var(--muted-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.forecast-note .seg { display: inline-flex; align-items: center; gap: 6px; }
.forecast-note .seg i { width: 18px; height: 0; border-top: 2px solid var(--muted); display: inline-block; }
.forecast-note .seg.fcst i { border-top-style: dashed; }

.day-strip { display: flex; gap: 12px; padding: 14px 18px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.day-strip::-webkit-scrollbar { height: 8px; }
.day-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); }
.day-divider { flex: 0 0 1px; align-self: stretch; margin: 4px 2px; background: linear-gradient(var(--border-strong), transparent); position: relative; }
.day-divider::after { content: "NOW"; position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font-size: 8px; font-weight: 700; letter-spacing: 0.1em; color: var(--muted-2); white-space: nowrap; }

.daycard {
  flex: 0 0 122px; scroll-snap-align: start; cursor: pointer;
  display: flex; flex-direction: column; gap: 9px; padding: 13px; text-align: left;
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.daycard:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.daycard.sel { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line), var(--shadow-glow); transform: translateY(-2px); }
.daycard-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.daycard-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.daycard-tag { font-size: 8.5px; font-weight: 700; letter-spacing: 0.06em; border-radius: 5px; padding: 1px 5px; white-space: nowrap; }
.daycard-tag.now { color: var(--accent); background: var(--accent-weak); border: 1px solid var(--accent-line); }
.daycard-wx { display: flex; align-items: center; gap: 8px; }
.daycard-wx svg { width: 20px; height: 20px; }
.daycard-temp { font-family: var(--font-head); font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.daycard-precip { display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.daycard-precip svg { width: 11px; height: 11px; color: var(--water); }
.daycard-bar { height: 6px; border-radius: var(--r-pill); background: var(--bg); overflow: hidden; }
.daycard-bar i { display: block; height: 100%; border-radius: var(--r-pill); transition: width 0.3s var(--ease); }
.daycard-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.daycard-foot .pct { font-family: var(--font-head); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.daycard-cls { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-2); }

/* ---- the three graphs (temperature · precipitation · soil moisture) ---- */
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 4px 18px 18px; }
.chart-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px 16px; }
.chart-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-h .ico { flex: none; width: 34px; height: 34px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--surface); }
.chart-h .ico svg { width: 17px; height: 17px; }
.chart-h h3 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text); letter-spacing: 0.06em; }
.chart-h p { margin: 2px 0 0; font-size: 11px; color: var(--muted-2); }
.chart-card svg { display: block; width: 100%; }

/* ============================================================
   Feedback popup — floating card, bottom-left of the map
   ============================================================ */
.feedback-popup {
  position: fixed; top: 68px; left: 24px; z-index: 1100;
  width: 280px;
  background: var(--surface-sheen), var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--glass-edge), var(--shadow-chrome);
  padding: 20px;
  overflow: hidden;
  max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0;
  pointer-events: none;
  transform-origin: top center;
  transition: max-height 0.7s var(--ease), opacity 0.7s var(--ease), padding 0.7s var(--ease);
}
.feedback-popup.is-visible {
  max-height: 300px; opacity: 1; padding-top: 20px; padding-bottom: 20px;
  pointer-events: auto;
}
.feedback-popup.is-hidden {
  max-height: 0 !important; opacity: 0; padding-top: 0; padding-bottom: 0;
  pointer-events: none;
}

.feedback-popup .fb-close {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.feedback-popup .fb-close:hover { background: var(--accent-weak); color: var(--accent); }
.feedback-popup .fb-close svg { width: 15px; height: 15px; }

.feedback-popup .fb-title {
  margin: 0 0 4px; font-family: var(--font-head);
  font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.35;
  padding-right: 20px;
}
.feedback-popup .fb-sub {
  margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.feedback-popup .fb-textarea {
  width: 100%; min-height: 40px; max-height: 200px;
  padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font-family: var(--font-body); font-size: 13px; line-height: 1.5;
  resize: none; outline: none;
  transition: min-height 0.35s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.feedback-popup .fb-textarea::placeholder {
  color: var(--muted-2); opacity: 0.7;
  transition: opacity 0.2s var(--ease);
}
.feedback-popup .fb-textarea:focus::placeholder { opacity: 0.4; }
.feedback-popup .fb-textarea:focus {
  min-height: 100px;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.feedback-popup .fb-actions {
  display: flex; justify-content: flex-end; margin-top: 10px;
  opacity: 0; max-height: 0; overflow: hidden;
  transition: opacity 0.3s var(--ease), max-height 0.35s var(--ease), margin-top 0.35s var(--ease);
}
.feedback-popup.is-expanded .fb-actions {
  opacity: 1; max-height: 50px;
}
.feedback-popup .fb-submit {
  padding: 8px 18px; border-radius: var(--r-sm);
  background: var(--accent-grad); color: var(--accent-ink);
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  border: none; cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.feedback-popup .fb-submit:hover {
  transform: translateY(-1px); box-shadow: var(--shadow-glow-lg);
}
.feedback-popup .fb-submit:active { transform: translateY(0) scale(0.97); }

/* ---- My Field: soil-moisture map | actionable insights, side by side ----
   Saved field only (draw mode keeps map | side column). Row 1: the two linked
   maps at the same height; row 2: the moisture readout | what to do now. */
.mapgrid.has-insights {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "map ins" "side panel";
}
.mapgrid.has-insights > .mapframe:first-child { grid-area: map; }
.mapgrid.has-insights > .ins-frame { grid-area: ins; }
.mapgrid.has-insights > .sidecol { grid-area: side; }
.mapgrid.has-insights > .ins-panel { grid-area: panel; }
#ins-map { position: absolute; inset: 0; z-index: 0; background: var(--bg); border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); }
#ins-map, #ins-map .leaflet-interactive { cursor: default; }
#ins-map.is-zoomed { cursor: grab; }
#ins-map:focus { outline: none; }
#ins-map img { -webkit-user-drag: none; pointer-events: none; }
.ins-dim { image-rendering: pixelated; }
.ins-chip svg { width: 15px; height: 15px; color: #D55E00; }
.ins-chip b { font-variant-numeric: tabular-nums; }
.ins-chip b:empty { display: none; }

/* block labels on the insights map */
.zl { background: none; border: 0; }
.zl span {
  position: absolute; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: #fff; color: #16211A; border-radius: var(--r-pill); padding: 6px 11px;
  font: 600 13.5px/1 var(--font-body); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.zl i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.zl em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.zl.is-dim span { opacity: 0.45; }
.zl.is-sel span { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6), 0 2px 10px rgba(0, 0, 0, 0.45); }

/* what to do now */
.ins-panel {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--surface-sheen), var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--glass-edge); padding: var(--s6);
}
.ins-total { font-family: var(--font-head); font-size: 38px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.ins-sub { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.ins-rows { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ins-rows li {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.ins-rows li:hover, .ins-rows li.sel { border-color: var(--accent-line); background: var(--accent-weak); }
.ins-rows li.urgent { border-color: rgba(213, 94, 0, 0.35); background: rgba(213, 94, 0, 0.06); }
.ins-rows li.urgent.sel, .ins-rows li.urgent:hover { border-color: #D55E00; }
.ins-rows .dot { width: 14px; height: 14px; border-radius: 50%; }
.ins-rows .t { font-weight: 700; font-size: 14.5px; color: var(--text); }
.ins-rows .m { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ins-rows .amt { font-family: var(--font-head); font-weight: 600; font-size: 17px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.ins-updated { margin: 2px 0 0; font-size: 12px; color: var(--muted-2); }
.ins-updated.is-old { color: #B23B2E; }
.ins-cost { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.cost-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cost-when { font-size: 12px; color: var(--muted-2); }
.cost-row { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 10px; font-size: 13.5px; }
.cost-name { color: var(--muted); font-weight: 600; }
.cost-bar { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.cost-bar i { display: block; height: 100%; border-radius: inherit; min-width: 2px; transition: width .3s ease; }
.cost-bar i.is-flood { background: #8A6310; }
.cost-bar i.is-ours { background: var(--accent); }
.cost-row b { font-family: var(--font-head); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; text-align: right; }
.cost-save { margin: 2px 0 0; font-size: 15px; font-weight: 700; color: var(--accent); }
.cost-save.is-short { color: var(--danger); font-weight: 600; font-size: 14px; }
.cost-detail { margin: 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cost-how { font-size: 12.5px; color: var(--muted); }
.cost-how summary { cursor: pointer; color: var(--muted-2); }
.cost-how p { margin: 6px 0 0; line-height: 1.5; }

@media (max-width: 900px) {
  .mapgrid.has-insights { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "ins" "panel" "side"; }
  .zl span { font-size: 11.5px; padding: 4px 8px; gap: 5px; }
  .zl i { width: 9px; height: 9px; }
}

/* ---- Dashboard responsiveness ---- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .mapgrid { grid-template-columns: 1fr; }
  .mapframe { height: 420px; }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { gap: var(--s3); }
  .topbar .wordmark .tag, .topbar .brand-nav { display: none; }
  .dash-head { flex-direction: column; align-items: flex-start; }
  .headline { align-items: flex-start; text-align: left; }
  .mapframe { height: 340px; }
  .feedback-popup { left: 12px; right: 12px; width: auto; }
}
