:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-light: #66bb6a;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #1f2a24;
  --muted: #6b7770;
  --border: #e0e5e0;
  --amber: #f9a825;
  --red: #d32f2f;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 500;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.3px; }
.brand p { margin: 0; font-size: 12px; opacity: 0.85; }
.badge {
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
}
.badge-live { background: #fff; color: var(--green-dark); }
.badge-demo { background: rgba(255, 255, 255, 0.2); }

/* Layout */
.layout { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.sidebar {
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px;
  background: var(--bg); border-right: 1px solid var(--border);
}
.panel { background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { margin: 0 0 8px; font-size: 15px; }
.pill { background: var(--green); color: #fff; border-radius: 12px;
  padding: 1px 9px; font-size: 12px; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; line-height: 1.5; }

/* Field list */
.field-list { list-style: none; margin: 0; padding: 0; }
.field-list li {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent; transition: background 0.15s;
}
.field-list li:hover { background: #eef4ee; }
.field-list li.active { background: #e6f0e6; border-color: var(--green-light); }
.field-list li.li-loading { position: relative; }
.field-list li.li-loading::after {
  content: ""; position: absolute; right: 10px; top: calc(50% - 7px);
  width: 14px; height: 14px; border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite;
}
.field-list .fname { font-weight: 600; font-size: 14px; }
.field-list .fmeta { font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 6px; background: #ccc; vertical-align: middle; }

/* Form */
.field-form { display: flex; flex-direction: column; gap: 8px; }
.field-form label { font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; }
.field-form input, .field-form select {
  padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; color: var(--ink); background: #fff;
}
.field-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.draw-status { font-size: 12px; padding: 7px 9px; border-radius: 6px;
  background: #fff7e6; border: 1px solid #ffe0a3; color: #8a6d1a; }
.draw-status.ready { background: #e8f5e9; border-color: #a5d6a7; color: var(--green-dark); }
button {
  cursor: pointer; border: none; border-radius: 7px; padding: 9px 14px;
  font-size: 14px; font-weight: 600; background: var(--green); color: #fff;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: var(--green-dark); }
button:disabled { background: #b7c4b8; cursor: not-allowed; }
button.danger { background: #fff; color: var(--red); border: 1px solid #f3c1c1; }
button.danger:hover { background: #fdeaea; }

/* Map */
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }

/* Find-my-farm search overlay */
.map-search {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 700; width: min(460px, calc(100% - 90px));
}
.search-box {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 1px solid var(--border); border-radius: 24px; padding: 4px 6px 4px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.search-icon { font-size: 14px; opacity: 0.6; }
.search-box input {
  flex: 1; border: none; outline: none; font-size: 14px; padding: 7px 4px;
  color: var(--ink); background: transparent;
}
#locate-btn {
  background: var(--bg); border-radius: 50%; width: 34px; height: 34px; padding: 0;
  font-size: 16px; line-height: 1; flex-shrink: 0;
}
#locate-btn:hover:not(:disabled) { background: #e6f0e6; }
#locate-btn.locating { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.search-results {
  list-style: none; margin: 6px 0 0; padding: 6px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto;
}
.search-results.hidden { display: none; }
.search-results li {
  padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13px;
  line-height: 1.35;
}
.search-results li:hover, .search-results li.hl { background: #eef4ee; }
.search-results li .r-main { font-weight: 600; }
.search-results li .r-sub { font-size: 11px; color: var(--muted); }
.search-results li.msg { color: var(--muted); cursor: default; }
.search-results li.msg:hover { background: transparent; }

/* Detail panel */
.detail {
  position: absolute; top: 0; right: 0; height: 100%; width: 380px;
  background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08); padding: 18px; overflow-y: auto;
  z-index: 600;
}
.detail.hidden { display: none; }

/* Compact sidebar vs. full-screen expanded dashboard */
#detail-full { display: none; }

.expand-btn {
  width: 100%; margin-top: 6px; background: var(--green-dark); color: #fff;
  font-size: 13.5px; padding: 11px; border-radius: 8px;
}
.expand-btn:hover { background: #144016; }

.report-btn { width: 100%; margin-top: 8px; font-size: 13px; padding: 10px;
  border-radius: 8px; background: #6a4a9c; color: #fff; }
.report-btn:hover:not(:disabled) { background: #563a80; }
.report-btn:disabled { background: #b3a6cc; cursor: wait; }

.detail.expanded {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none;
  z-index: 2000; padding: 22px clamp(20px, 5vw, 64px); border-left: none;
  box-shadow: none;
}
.detail.expanded #d-name { font-size: 24px; margin-right: 44px; }
.detail.expanded .status-row,
.detail.expanded #d-alerts { max-width: 1240px; margin-left: auto; margin-right: auto; }
.detail.expanded .expand-btn { max-width: 300px; display: block; margin: 12px auto 4px; }
.detail.expanded .status-row { max-width: 820px; }
/* Balanced masonry: CSS columns pack variable-height cards with no dead space. */
.detail.expanded #detail-full {
  display: block;   /* override the compact `display:none` */
  columns: 380px; column-gap: 16px; max-width: 1320px; margin: 18px auto 0;
}
.detail.expanded #detail-full > * {
  break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
  margin: 0 0 16px !important; display: block; width: 100%;
}
/* Delete lives in the compact sidebar only. */
.detail.expanded #delete-btn { display: none; }

/* Loading indicators */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: middle;
  border: 2px solid rgba(0, 0, 0, 0.12); border-top-color: var(--green);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.loading-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  color: var(--muted); padding: 6px 2px; }

/* A section awaiting data: dim its content and float a spinner over it. */
.loading { position: relative; min-height: 96px; }
.loading::before {
  content: ""; position: absolute; inset: 0; border-radius: 12px; z-index: 5;
  background: rgba(255, 255, 255, 0.74); backdrop-filter: blur(1px);
}
.loading::after {
  content: ""; position: absolute; top: calc(50% - 15px); left: calc(50% - 15px);
  width: 30px; height: 30px; z-index: 6;
  border: 3px solid rgba(0, 0, 0, 0.12); border-top-color: var(--green);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

/* Index switcher */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; }
.idx-toggle { display: flex; gap: 3px; }
.idx-toggle button { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 10px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.idx-toggle button.on { background: var(--green); color: #fff; border-color: var(--green); }
.idx-note { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin: 6px 0 0; }

/* Damage / claim */
.damage { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fdf1ee, #ffffff); border: 1px solid #eccdc5; }
.dmg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dmg-head h3 { margin: 0; font-size: 15px; }
.dmg-badge { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 5px 11px; border-radius: 14px; background: #e8f5e9; color: var(--green-dark); }
.dmg-badge.d-minor { background: #fff8e1; color: #8a6d1a; }
.dmg-badge.d-moderate { background: #fff1e0; color: #c15600; }
.dmg-badge.d-severe { background: #fdeaea; color: var(--red); }
.dmg-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 10px; color: var(--ink); }
.dmg-evidence { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.dmg-evidence:empty { display: none; }
.dmg-ev { font-size: 11.5px; color: var(--muted); line-height: 1.45; padding-left: 14px;
  position: relative; }
.dmg-ev::before { content: "•"; position: absolute; left: 3px; }
.claim-btn { display: block; text-align: center; text-decoration: none; font-size: 12.5px;
  font-weight: 600; padding: 10px; border-radius: 8px; background: #c0392b; color: #fff; }
.claim-btn:hover { background: #a03024; }
.dmg-note { font-size: 10px; color: var(--muted); font-style: italic; line-height: 1.4;
  margin: 8px 0 0; }

/* Season history */
.history { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #f2f6fb, #ffffff); border: 1px solid #cfdcea; }
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hist-head h3 { margin: 0; font-size: 15px; }
.hist-head select { font-size: 11.5px; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; }
.hist-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 10px; color: var(--ink); }
.hist-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.hist-stats .stat-cell .big { font-size: 17px; }
.hist-seasons { display: flex; flex-direction: column; gap: 5px; }
.hs-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 7px 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; }
.hs-row.best { border-left: 3px solid var(--green); }
.hs-row.worst { border-left: 3px solid #ef6c00; }
.hs-row.ongoing { border-left: 3px solid #1e88e5; background: #f5faff; }
.hs-label { font-weight: 700; }
.hs-meta { font-size: 10.5px; color: var(--muted); }
.hs-yield { font-weight: 700; color: var(--green-dark); text-align: right; white-space: nowrap; }
.hs-tag { font-size: 9px; font-weight: 800; text-transform: uppercase; padding: 1px 6px;
  border-radius: 8px; margin-left: 5px; }
.hs-tag.best { background: #e8f5e9; color: var(--green-dark); }
.hs-tag.worst { background: #fff1e0; color: #c15600; }
.hs-tag.ongoing { background: #e3f2fd; color: #1565c0; }

.chart-section { margin: 16px 0; }
.chart-section h3 { margin: 0 0 8px; font-size: 14px; }
.detail.expanded .chart-section { background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; }
.close { position: absolute; top: 12px; right: 12px; background: #eee; color: #555;
  width: 30px; height: 30px; border-radius: 50%; padding: 0; font-size: 14px; }
.close:hover { background: #ddd; }
.detail h2 { margin: 0 30px 4px 0; font-size: 18px; }
.detail h3 { font-size: 14px; margin: 20px 0 8px; }
.meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.status-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-card { background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.status-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; }
.status-card .big { font-size: 24px; font-weight: 700; }
.status-card .sub { font-size: 11px; color: var(--muted); }
.status-badge { font-size: 17px !important; }

.alerts { margin: 14px 0; display: flex; flex-direction: column; gap: 7px; }
.alert { font-size: 12.5px; line-height: 1.45; padding: 9px 11px; border-radius: 8px;
  background: #fff8e1; border-left: 3px solid var(--amber); color: #7a5c00; }
.alert.ok { background: #e8f5e9; border-color: var(--green); color: var(--green-dark); }
.alert.bad { background: #fdeaea; border-color: var(--red); color: #a02020; }

/* Weather & agro-met */
.weather { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #eef6fc, #ffffff); border: 1px solid #cfe3f2; }
.weather h3 { margin: 0 0 8px; font-size: 15px; }
.weather-summary { font-size: 12.5px; line-height: 1.5; margin: 0 0 12px; color: var(--ink); }

.w-current { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.w-current .wc-icon { font-size: 34px; line-height: 1; }
.w-current .wc-temp { font-size: 26px; font-weight: 700; }
.w-current .wc-meta { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.w-forecast { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.wf-day { flex: 0 0 auto; width: 62px; text-align: center; background: #fff;
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 4px; }
.wf-day .wf-dow { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.wf-day .wf-ic { font-size: 20px; margin: 2px 0; }
.wf-day .wf-t { font-size: 11px; font-weight: 600; }
.wf-day .wf-t .lo { color: var(--muted); font-weight: 400; }
.wf-day .wf-rain { font-size: 10px; color: #1e88e5; margin-top: 2px; }

.agromet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.am-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.am-top { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.am-top .am-ic { font-size: 16px; }
.am-top .am-title { font-size: 12px; font-weight: 700; flex: 1; }
.am-badge { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 7px; border-radius: 9px; background: #eef; color: #556; }
.am-detail { font-size: 11px; color: var(--muted); line-height: 1.45; }
.am-badge.b-good, .am-badge.b-low { background: #e8f5e9; color: var(--green-dark); }
.am-badge.b-adequate, .am-badge.b-moderate, .am-badge.b-watch { background: #fff4e0; color: #b26a00; }
.am-badge.b-deficit, .am-badge.b-high, .am-badge.b-surplus { background: #fdeaea; color: var(--red); }
.am-badge.b-surplus { background: #e3f2fd; color: #1565c0; }

.weather-alerts { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.w-alert { font-size: 12px; line-height: 1.45; padding: 9px 11px; border-radius: 8px;
  border-left: 3px solid var(--amber); background: #fff8e1; color: #7a5c00; }
.w-alert.warning { border-color: var(--red); background: #fdeaea; color: #a02020; }
.w-alert.watch { border-color: var(--amber); background: #fff8e1; color: #7a5c00; }

/* Irrigation scheduler */
.irrigation { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #eaf4fb, #ffffff); border: 1px solid #c5dced; }
.irr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.irr-head h3 { margin: 0; font-size: 15px; }
.irr-controls { display: flex; gap: 6px; }
.irr-controls select { font-size: 11.5px; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--ink); }
.irr-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; color: var(--ink); }

.irr-hero { display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.irr-big { font-size: 28px; font-weight: 800; color: #1565c0; }
.irr-unit { font-size: 12px; color: var(--muted); margin-left: 4px; }
.irr-status-badge { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 5px 11px; border-radius: 14px; }
.st-well_watered { background: #e3f2fd; color: #1565c0; }
.st-adequate { background: #e8f5e9; color: var(--green-dark); }
.st-due_soon { background: #fff4e0; color: #b26a00; }
.st-irrigate_now { background: #fdeaea; color: var(--red); }

.irr-bar { position: relative; height: 12px; border-radius: 6px; margin: 12px 0 3px;
  background: #e5ebf0; overflow: visible; }
.irr-bar-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 6px;
  background: #1565c0; transition: width 0.3s; }
.irr-bar-fill.warn { background: #f9a825; }
.irr-bar-fill.crit { background: #e53935; }
.irr-bar-raw { position: absolute; top: -4px; width: 0; height: 20px; border-left: 2px dashed #b26a00; }
.irr-bar-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.irr-raw-lbl { color: #b26a00; font-weight: 600; }

.irr-next { margin: 12px 0; padding: 11px 12px; border-radius: 9px; font-size: 12.5px;
  background: #e3f2fd; color: #0d47a1; line-height: 1.5; }
.irr-next.now { background: #fdeaea; color: #a02020; }
.irr-next b { font-size: 14px; }

.irr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.irr-stat { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  text-align: center; }
.irr-stat .v { font-size: 15px; font-weight: 700; }
.irr-stat .k { font-size: 10px; color: var(--muted); }

.irr-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 8px; }
.irr-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px;
  border-bottom: 1px solid var(--border); font-size: 10.5px; }
.irr-table td { padding: 4px 6px; border-bottom: 1px solid #f0f2f0; }
.irr-table tr.irr-day-go td { background: #e3f2fd; font-weight: 600; }
.irr-drop { color: #1565c0; font-weight: 700; }
.irr-assume { font-size: 10px; color: var(--muted); line-height: 1.4; font-style: italic; margin: 4px 0 0; }

/* Sentinel-1 radar */
.radar { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #eef0f7, #ffffff); border: 1px solid #cdd3e6; }
.radar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.radar-head h3 { margin: 0; font-size: 15px; }
.rd-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 12px;
  background: #e8eaf6; color: #3949ab; white-space: nowrap; }
.radar-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 10px; color: var(--ink); }
.radar-note { font-size: 10.5px; color: var(--muted); font-style: italic; line-height: 1.45; margin: 8px 0 0; }

.rd-flood { font-size: 12.5px; line-height: 1.5; padding: 9px 11px; border-radius: 8px;
  background: #fdeaea; color: #a02020; border-left: 3px solid var(--red); margin-bottom: 10px; }
.rd-flood:empty { display: none; }
.rd-gap { font-size: 12px; padding: 8px 11px; border-radius: 8px; margin-bottom: 10px;
  background: #e8eaf6; color: #283593; }
.rd-gap:empty { display: none; }
.rd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.rd-stats .stat-cell .big { font-size: 18px; }
.rd-soil { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.45; }
.rd-soil:empty { display: none; }

/* Crop detection */
.cropdetect { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #eef7f3, #ffffff); border: 1px solid #c9e4d8; }
.cd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cd-head h3 { margin: 0; font-size: 15px; }
.cd-badge { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 5px 11px; border-radius: 14px; background: #e0e0e0; color: #555; }
.cd-badge.c-high { background: #e8f5e9; color: var(--green-dark); }
.cd-badge.c-medium { background: #fff4e0; color: #b26a00; }
.cd-badge.c-low, .cd-badge.c-none { background: #eceff1; color: #607d8b; }
.cd-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; color: var(--ink); }
.cd-summary b { color: var(--green-dark); }

.cd-best { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.cd-best .cd-crop { font-size: 22px; font-weight: 800; text-transform: capitalize; color: var(--green-dark); }
.cd-apply { margin-left: auto; font-size: 12.5px; padding: 8px 14px; }
.cd-applied { margin-left: auto; font-size: 12px; color: var(--green-dark); font-weight: 700; }

.cd-candidates { display: flex; flex-direction: column; gap: 8px; }
.cd-cand { padding: 8px 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.cd-cand-top { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.cd-cand-name { font-weight: 600; text-transform: capitalize; }
.cd-cand-score { font-size: 11px; color: var(--muted); }
.cd-bar { height: 5px; border-radius: 3px; background: #e5ebe5; margin: 5px 0; overflow: hidden; }
.cd-bar-fill { height: 100%; border-radius: 3px; background: var(--green); }
.cd-reasons { font-size: 10.5px; color: var(--muted); line-height: 1.4; }

/* Pest & disease early warning */
.pest { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fbf0ee, #ffffff); border: 1px solid #eccfc7; }
.pest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pest-head h3 { margin: 0; font-size: 15px; }
.pest-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; color: var(--ink); }
.pest-assume { font-size: 10px; color: var(--muted); font-style: italic; line-height: 1.4; margin: 10px 0 0; }

.pr-badge { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 5px 11px; border-radius: 14px; white-space: nowrap; }
.pr-low { background: #e8f5e9; color: var(--green-dark); }
.pr-moderate { background: #f7f8e3; color: #7a7a12; }
.pr-high { background: #fff1e0; color: #c15600; }
.pr-severe { background: #fdeaea; color: var(--red); }

.pr-threats { display: flex; flex-direction: column; gap: 9px; }
.pr-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 11px;
  border-left: 4px solid var(--border); }
.pr-card.lv-moderate { border-left-color: #cddc39; }
.pr-card.lv-high { border-left-color: #fb8c00; }
.pr-card.lv-severe { border-left-color: var(--red); }
.pr-card-top { display: flex; align-items: center; gap: 8px; }
.pr-ic { font-size: 18px; }
.pr-name { font-weight: 700; font-size: 13px; flex: 1; }
.pr-name .pr-type { font-weight: 400; font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  margin-left: 5px; letter-spacing: 0.4px; }
.pr-score-bar { height: 6px; border-radius: 3px; background: #ebe5e3; margin: 8px 0; overflow: hidden; }
.pr-score-fill { height: 100%; border-radius: 3px; }
.pr-drivers { list-style: none; margin: 6px 0; padding: 0; }
.pr-drivers li { font-size: 11.5px; color: var(--muted); line-height: 1.5; padding-left: 14px;
  position: relative; }
.pr-drivers li::before { content: "•"; position: absolute; left: 3px; }
.pr-drivers li.confirm { color: var(--red); font-weight: 600; }
.pr-days { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.pr-day { font-size: 10px; background: #fff1e0; color: #c15600; padding: 2px 7px; border-radius: 8px; }
.pr-action { font-size: 11.5px; color: var(--ink); line-height: 1.45; margin-top: 6px;
  padding-top: 6px; border-top: 1px dashed var(--border); }

/* Crop advisory */
.advisory {
  margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #f2f8f2, #ffffff);
  border: 1px solid #d6e6d6;
}
.advisory-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.advisory-head h3 { margin: 0; font-size: 15px; }
.stage-chip {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 12px;
  background: var(--green); color: #fff; white-space: nowrap;
}
.vigor-bar { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 12px; }
.vigor-bar .track { flex: 1; height: 7px; border-radius: 4px; overflow: hidden;
  background: #e5ebe5; position: relative; }
.vigor-bar .fill { height: 100%; border-radius: 4px; }
.vigor-bar .vlabel { font-weight: 700; }
.advisory-summary { font-size: 13px; line-height: 1.5; color: var(--ink); margin: 8px 0 12px; }

.advisory-items { display: flex; flex-direction: column; gap: 8px; }
.adv-item {
  display: grid; grid-template-columns: 30px 1fr; gap: 8px;
  padding: 10px; border-radius: 9px; background: #fff; border: 1px solid var(--border);
  border-left-width: 4px;
}
.adv-item.p-high { border-left-color: var(--red); }
.adv-item.p-medium { border-left-color: var(--amber); }
.adv-item.p-info { border-left-color: var(--green-light); }
.adv-item .adv-icon { font-size: 20px; text-align: center; line-height: 1.2; }
.adv-item .adv-title { font-weight: 600; font-size: 13px; display: flex;
  align-items: center; gap: 6px; flex-wrap: wrap; }
.adv-item .adv-detail { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.pri-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 1px 6px; border-radius: 8px; }
.pri-tag.p-high { background: #fdeaea; color: var(--red); }
.pri-tag.p-medium { background: #fff4e0; color: #b26a00; }
.pri-tag.p-info { background: #e8f5e9; color: var(--green-dark); }
.advisory-foot { font-size: 10.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.4;
  font-style: italic; }

/* Yield estimate & benchmarking */
.yield { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #f3f8ee, #ffffff); border: 1px solid #d9e6c8; }
.yield-head { display: flex; align-items: center; justify-content: space-between; }
.yield-head h3 { margin: 0; font-size: 15px; }
.yield-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; color: var(--ink); }

.y-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.y-main { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; }
.y-main .y-big { font-size: 30px; font-weight: 800; color: var(--green-dark); }
.y-main .y-unit { font-size: 13px; color: var(--muted); margin-left: 4px; }
.y-main .y-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.y-total { text-align: center; background: var(--green); color: #fff; border-radius: 10px;
  padding: 12px 16px; min-width: 92px; }
.y-total .y-total-val { font-size: 22px; font-weight: 800; }
.y-total .y-total-lbl { font-size: 10px; opacity: 0.9; }

.y-attain { margin-bottom: 12px; }
.y-attain-lbl { display: flex; justify-content: space-between; font-size: 11.5px;
  color: var(--muted); margin-bottom: 4px; }
.y-attain-lbl #y-attain-pct { font-weight: 700; color: var(--ink); }
.y-bar { height: 9px; border-radius: 5px; background: #e5ebe0; overflow: hidden; }
.y-bar-fill { height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--green-light), var(--green-dark)); }

.y-bench { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.y-bench .stat-cell .big { font-size: 18px; }
.y-vs-pos { color: var(--green-dark); }
.y-vs-neg { color: var(--red); }

.y-peers { font-size: 12px; padding: 9px 11px; border-radius: 8px; background: #eef4ea;
  color: var(--green-dark); margin-bottom: 8px; }
.y-peers:empty { display: none; }
.y-revenue { font-size: 12.5px; padding: 9px 11px; border-radius: 8px; background: #fff8ec;
  color: #8a6d1a; margin-bottom: 8px; font-weight: 600; }
.y-revenue:empty { display: none; }
.y-note { font-size: 10.5px; color: var(--muted); line-height: 1.45; font-style: italic; margin: 6px 0 0; }
#y-body.dim { opacity: 0.55; }

/* Market price & profit */
.market { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fff8ec, #ffffff); border: 1px solid #f0e0c0; }
.market-head { display: flex; align-items: center; justify-content: space-between; }
.market-head h3 { margin: 0; font-size: 15px; }
.market-summary { font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; color: var(--ink); }
.mk-price-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.mk-price-row .stat-cell .big { font-size: 18px; }

.mk-markets { margin-bottom: 12px; font-size: 12px; }
.mk-markets summary { cursor: pointer; font-weight: 600; color: var(--green-dark);
  padding: 6px 0; }
.mk-markets-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.mk-mrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 6px 9px;
  background: #fff; border: 1px solid var(--border); border-radius: 7px; }
.mk-mrow .mk-m-name { font-weight: 600; }
.mk-mrow .mk-m-loc { font-size: 10.5px; color: var(--muted); }
.mk-mrow .mk-m-price { font-weight: 700; color: var(--green-dark); text-align: right; }
.mk-mrow .mk-m-range { font-size: 10px; color: var(--muted); text-align: right; }

.mk-calc { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.mk-calc h4 { margin: 0 0 10px; font-size: 13px; }
.mk-hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.mk-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.mk-inputs label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.mk-inputs input { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink); }
.mk-inputs input[readonly] { background: var(--bg); color: var(--muted); }

.mk-results { display: flex; flex-direction: column; gap: 8px; }
.mk-net { text-align: center; padding: 12px; border-radius: 10px; background: var(--bg); }
.mk-net .mk-net-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); }
.mk-net .mk-net-val { font-size: 26px; font-weight: 800; display: block; }
.mk-net.pos .mk-net-val { color: var(--green-dark); }
.mk-net.neg .mk-net-val { color: var(--red); }
.mk-net .mk-net-sub { font-size: 12px; color: var(--muted); }
.mk-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.mk-breakdown .kv { display: flex; justify-content: space-between; padding: 5px 9px;
  background: var(--bg); border-radius: 6px; }
.mk-breakdown .kv .k { color: var(--muted); }
.mk-breakdown .kv .v { font-weight: 700; }
.mk-msp-note { font-size: 11.5px; line-height: 1.45; padding: 8px 10px; border-radius: 7px;
  background: #e8f5e9; color: var(--green-dark); }
.mk-msp-note.below { background: #fff4e0; color: #b26a00; }

/* Field scouting log */
.scout { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fbf6ee, #ffffff); border: 1px solid #ecdfc7; }
.scout-head { display: flex; align-items: center; justify-content: space-between; }
.scout-head h3 { margin: 0; font-size: 15px; }
.scout-hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 10px; line-height: 1.45; }

.scout-form { display: flex; flex-direction: column; gap: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.scout-form.hidden { display: none; }
.scout-form label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.scout-form input, .scout-form select, .scout-form textarea {
  padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
  color: var(--ink); font-family: inherit; }
.sc-loc-row, .sc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc-loc-pick { display: flex; gap: 8px; align-items: center; }
.sc-loc-pick select { flex: 1; font-size: 12px; padding: 6px; }
.sc-photo-lbl input { padding: 5px; font-size: 12px; }
.sc-form-actions { display: flex; gap: 8px; }
.sc-form-actions button { flex: 1; }
button.ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--border); }
button.ghost:hover { background: #e9ede9; }
.sc-error { font-size: 11.5px; color: var(--red); }
.sc-error:empty { display: none; }

.scout-list { display: flex; flex-direction: column; gap: 7px; }
.scout-list:empty::after { content: "No observations yet."; font-size: 12px; color: var(--muted); }
.sc-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: start;
  padding: 9px 10px; background: #fff; border: 1px solid var(--border); border-radius: 9px; }
.sc-cat-dot { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: #fff; }
.sc-line { font-size: 12.5px; }
.sc-line .sc-sev { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 6px;
  border-radius: 8px; margin-left: 4px; }
.sev-low { background: #e8f5e9; color: var(--green-dark); }
.sev-medium { background: #fff4e0; color: #b26a00; }
.sev-high { background: #fdeaea; color: var(--red); }
.sc-date { font-size: 10.5px; color: var(--muted); float: right; }
.sc-note { font-size: 12px; color: var(--ink); margin: 2px 0; line-height: 1.4; }
.sc-gps { font-size: 10px; color: var(--muted); font-family: monospace; cursor: pointer; }
.sc-gps:hover { color: var(--green-dark); text-decoration: underline; }
.sc-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); }
.sc-del { background: none; color: var(--muted); padding: 2px 6px; font-size: 13px; align-self: start; }
.sc-del:hover { color: var(--red); background: #fdeaea; }

/* Scouting observation map pin */
.obs-pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.obs-pin span { transform: rotate(45deg); font-size: 13px; }

/* Action plan — compact sidebar insight */
.rx-compact { margin: 12px 0 4px; padding: 12px; border-radius: 10px;
  background: #f6f2fb; border: 1px solid #ddd0ec; }
.rx-compact h4 { margin: 0 0 6px; font-size: 13px; }
.rxc-summary { font-size: 12px; line-height: 1.45; margin: 0 0 8px; color: var(--ink); }
.rxc-scout { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.rxc-scout-head { font-size: 11px; font-weight: 700; color: var(--muted); }
.rxc-row { display: flex; align-items: center; gap: 7px; padding: 5px 7px; background: #fff;
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer; font-size: 11.5px; }
.rxc-row:hover { background: #faf7ff; }
.rxc-row-txt b { text-transform: capitalize; }
.rxc-more { font-size: 11px; color: #6a4a9c; font-weight: 600; padding: 2px; }
.rxc-none { font-size: 12px; color: var(--green-dark); }
/* In the full-screen dashboard the complete section is shown instead. */
.detail.expanded #rx-compact { display: none; }

/* Action plan / prescription */
.rx { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #f6f2fb, #ffffff); border: 1px solid #ddd0ec; }
.rx h3 { margin: 0 0 8px; font-size: 15px; }
.rx-summary { font-size: 12.5px; line-height: 1.5; margin: 0 0 10px; color: var(--ink); }
.rx-totals { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.rx-chip { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 12px;
  background: #efe7f7; color: #5b3a86; }

.rx-scout-title { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.rx-scout-item { display: grid; grid-template-columns: 26px 1fr; gap: 9px; align-items: start;
  padding: 8px 10px; background: #fff; border: 1px solid var(--border); border-radius: 9px;
  margin-bottom: 6px; cursor: pointer; }
.rx-scout-item:hover { background: #faf7ff; }
.rx-pin { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 12px;
  font-weight: 800; display: flex; align-items: center; justify-content: center; }
.rx-scout-meta { font-size: 12px; }
.rx-gps { font-size: 10.5px; color: var(--muted); font-family: monospace; }
.rx-scout-action { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.rx-none { font-size: 12.5px; color: var(--green-dark); background: #e8f5e9;
  padding: 9px 11px; border-radius: 8px; }

.rx-downloads { display: flex; gap: 8px; margin-top: 12px; }
.dl-btn { flex: 1; text-align: center; text-decoration: none; font-size: 12.5px; font-weight: 600;
  padding: 9px; border-radius: 8px; background: #6a4a9c; color: #fff; }
.dl-btn:hover { background: #563a80; }

/* Numbered scouting map pin */
.scout-pin { width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center;
  justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45); }

/* Vigour & stress zones */
.vigor { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: #fafdfa; border: 1px solid var(--border); }
.vigor-head { display: flex; align-items: center; justify-content: space-between; }
.vigor-head h3 { margin: 0; font-size: 15px; }
.mini-btn { background: var(--bg); color: var(--green-dark); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 14px; }
.mini-btn:hover { background: #e6f0e6; }
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.stat-cell { background: #fff; border: 1px solid var(--border); border-radius: 9px;
  padding: 9px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stat-cell .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); }
.stat-cell .big { font-size: 19px; font-weight: 700; }
.stat-cell .sub { font-size: 10.5px; color: var(--muted); }
.vigor-summary { font-size: 12.5px; line-height: 1.5; margin: 10px 0 8px; color: var(--ink); }
.zone-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--muted); }
.zone-legend span { display: inline-flex; align-items: center; gap: 5px; }
.zone-legend .lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-none { background: rgba(67,160,71,0.55); }
.lg-mild { background: rgba(192,202,51,0.7); }
.lg-moderate { background: rgba(251,140,0,0.75); }
.lg-severe { background: rgba(229,57,53,0.8); }

.chart-box { position: relative; height: 200px; }
.ndvi-image-box img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.ndvi-image-box.hidden { display: none; }
.hidden { display: none; }

#delete-btn { margin-top: 20px; width: 100%; }

/* Status colours */
.s-excellent { color: var(--green-dark); }
.s-healthy { color: var(--green); }
.s-moderate { color: var(--amber); }
.s-stressed { color: #ef6c00; }
.s-bare { color: var(--red); }
.s-unknown { color: var(--muted); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 40vh; }
  .detail { width: 100%; }
}

/* Farm credit-readiness */
.credit { margin: 16px 0; padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, #eef7f1, #ffffff); border: 1px solid #c8e2d2; }
.cr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cr-head h3 { margin: 0; font-size: 15px; }
.cr-grade { font-size: 12px; font-weight: 800; padding: 5px 12px; border-radius: 14px;
  background: #eceff1; color: #607d8b; }
.cr-grade.g-A { background: #e8f5e9; color: var(--green-dark); }
.cr-grade.g-B { background: #f1f8e9; color: #558b2f; }
.cr-grade.g-C { background: #fff4e0; color: #b26a00; }
.cr-grade.g-D { background: #fdeaea; color: var(--red); }
.cr-score-wrap { display: flex; align-items: center; gap: 12px; margin: 10px 0 8px; }
.cr-score { font-size: 30px; font-weight: 800; color: var(--green-dark); white-space: nowrap; }
.cr-score small { font-size: 13px; color: var(--muted); font-weight: 600; }
.cr-bar { flex: 1; height: 10px; border-radius: 5px; background: #e2ebe4; overflow: hidden; }
.cr-bar-fill { height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--green-light), var(--green-dark)); transition: width .4s; }
.cr-summary { font-size: 12.5px; line-height: 1.5; margin: 6px 0 10px; color: var(--ink); }
.cr-components { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.cr-comp { padding: 7px 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.cr-comp-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; }
.cr-comp-top .w { color: var(--muted); font-weight: 400; font-size: 10.5px; }
.cr-comp-bar { height: 4px; border-radius: 2px; background: #e5ebe5; margin: 4px 0; overflow: hidden; }
.cr-comp-fill { height: 100%; border-radius: 2px; background: var(--green); }
.cr-comp-detail { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
.cr-kcc { font-size: 12.5px; padding: 10px 11px; border-radius: 8px; background: #fff8ec;
  color: #8a6d1a; margin-bottom: 10px; line-height: 1.5; }
.cr-kcc:empty { display: none; }
.cr-pdf { display: block; text-align: center; text-decoration: none; font-size: 12.5px;
  font-weight: 600; padding: 10px; border-radius: 8px; background: #1b5e20; color: #fff; }
.cr-pdf:hover { background: #144016; }
.cr-note { font-size: 10px; color: var(--muted); line-height: 1.45; margin: 8px 0 0; }

/* ---- Action buttons: consistent sizing in both views ---------------------- */
.detail-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.detail-actions button { width: 100%; margin: 0; }
/* Expanded: one centred row of equal-width buttons (no full-width purple bar). */
.detail.expanded .detail-actions {
  flex-direction: row; justify-content: center; gap: 10px;
  max-width: 660px; margin: 16px auto 0;
}
.detail.expanded .detail-actions button { flex: 1 1 0; max-width: 320px; margin: 0; }
.detail.expanded .expand-btn { max-width: 320px; margin: 0; }  /* override earlier rule */

/* ---- Tabs (expanded view only) ------------------------------------------- */
.detail-tabs { display: none; }
.detail.expanded .detail-tabs {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 6px;
  max-width: 1320px; margin: 18px auto 0;
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.detail-tabs button {
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 20px;
}
.detail-tabs button:hover { background: #e9efe9; color: var(--ink); }
.detail-tabs button.on {
  background: var(--green); color: #fff; border-color: var(--green);
}
/* Panels outside the active tab are removed from the masonry flow. */
#detail-full > [data-tab].tab-hidden { display: none !important; }

/* NDVI map panel: match the other dashboard cards */
.detail.expanded .ndvi-image-box {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.ndvi-image-box h3 { margin: 0 0 8px; font-size: 14px; }

/* ---- One contained page column ------------------------------------------
   Previously each block had its own max-width (name full, cards 820, alerts
   1240, buttons 660, grid 1320) so nothing shared an edge. Now every block
   sits in the same centred column and lines up. */
.detail.expanded { --page: 1320px; }
.detail.expanded > h2,
.detail.expanded > .meta,
.detail.expanded > .status-row,
.detail.expanded > #d-alerts,
.detail.expanded > #rx-compact,
.detail.expanded > .detail-actions,
.detail.expanded > .detail-tabs,
.detail.expanded > #detail-full {
  max-width: var(--page);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
/* Header sits on the column's left edge (close button is absolute, top-right). */
.detail.expanded #d-name { margin-right: auto; padding-right: 48px; }
/* Status cards keep a sane size but start at the column's left edge. */
.detail.expanded .status-row {
  grid-template-columns: repeat(2, minmax(0, 320px));
  justify-content: start;
}
/* Buttons and tabs centre within that same column. */
.detail.expanded .detail-actions { justify-content: center; }
.detail.expanded .detail-tabs { justify-content: center; }

/* ---- Status row: 4 cards (NDVI, Health, Weather, Pest) -------------------- */
.status-row { grid-template-columns: 1fr 1fr; }          /* compact: 2 x 2 */
.c-w-line { display: flex; align-items: center; gap: 6px; }
.c-w-icon { font-size: 20px; line-height: 1; }
#c-p-level { text-transform: capitalize; }
.p-low { color: var(--green-dark); }
.p-moderate { color: #b26a00; }
.p-high { color: #c15600; }
.p-severe { color: var(--red); }

/* ---- Expanded: alert sits BELOW the tabs, full column width ---------------
   Reordered with flex so the compact sidebar keeps its natural DOM order. */
.detail.expanded { display: flex; flex-direction: column; }
.detail.expanded > h2            { order: 1; }
.detail.expanded > .meta         { order: 2; }
.detail.expanded > .status-row   { order: 3; }
.detail.expanded > #rx-compact   { order: 4; }   /* hidden in expanded */
.detail.expanded > .detail-actions { order: 5; }
.detail.expanded > .detail-tabs  { order: 6; }
.detail.expanded > #d-alerts     { order: 7; margin-top: 14px; }
.detail.expanded > #detail-full  { order: 8; }
.detail.expanded > * { flex: 0 0 auto; }

/* Four cards across, packed to the column's left edge. */
.detail.expanded .status-row {
  grid-template-columns: repeat(4, minmax(0, 320px));
  justify-content: start;
}
