/* Surkora components: the daily brief, verdict rows, folds, facts, lists and generated markup. */

/* Cards: plain white blocks, used for tools and forms, not for every number. */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-head h2 .ic { width: 18px; height: 18px; color: var(--olive); }
.card > .prov { align-self: flex-start; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.attr { color: var(--muted); font-size: 12px; }
.attr a { color: inherit; }

/* Daily brief hero: deep pine, the mark's bands as a field horizon, the parcel's own outline. */
.brief {
  position: relative;
  display: block;
  padding: 18px 18px 58px;
  overflow: hidden;
  border-radius: var(--leaf-r);
  background: var(--pine) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0 30C140 22 280 10 400 0V9C280 19 140 30 0 38Z' fill='%23f3d36b'/%3E%3Cpath d='M0 45C140 36 280 22 400 14V60H0Z' fill='%23177245'/%3E%3Cpath d='M0 60C150 54 290 42 400 34V60Z' fill='%237fc79b'/%3E%3C/svg%3E") no-repeat left bottom / 100% 46px;
  color: var(--cream);
}
.brief :focus-visible { outline-color: var(--gold); }
#briefDate { color: rgba(246, 243, 236, 0.74); font-size: 13.5px; }
#briefHead {
  margin-top: 8px;
  color: var(--cream);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
#briefCounts { margin-top: 10px; color: var(--gold); font-size: 14.5px; font-weight: 600; }
#briefCounts:empty { display: none; }
.brief-shape {
  float: right;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: -6px -6px 4px 12px;
  padding: 6px;
  border: 0;
  border-radius: 18px 4px 18px 4px;
  background: none;
  color: var(--gold);
}
.brief-shape[hidden] { display: none; }
.brief-shape svg { width: 100%; height: 100%; overflow: visible; }
.brief-shape path {
  fill: rgba(243, 211, 107, 0.2);
  stroke: currentColor;
  stroke-width: 4.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brief-shape:hover { background: rgba(246, 243, 236, 0.08); }
@media (min-width: 900px) {
  #briefHead { font-size: 29px; }
}

/* The day's decisions: four tiles to scan, then full-width rows; any tile opens to full width. */
.vrow-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.vrow {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--leaf-r-sm);
  background: var(--surface);
  transition: border-color 0.15s;
}
.vrow[data-row="env"],
.vrow[data-row="book"],
.vrow[data-row="pac"],
.vrow:has(> .vrow-head[aria-expanded="true"]) { grid-column: 1 / -1; }
@media (hover: hover) {
  .vrow:hover { border-color: var(--line-strong); }
}

.vrow-head {
  display: grid;
  grid-template-areas: "mark topic chev" "answer answer answer";
  grid-template-columns: 16px minmax(0, 1fr) 18px;
  grid-template-rows: auto 1fr;
  align-items: center;
  flex: 1 0 auto;
  gap: 12px 8px;
  width: 100%;
  min-height: 118px;
  padding: 14px 14px 16px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  text-align: left;
}
/* Mark and chevron line up with the first line of the topic, even when it wraps. */
.vrow-head .mark { grid-area: mark; align-self: start; margin-top: 2px; }
.vrow-topic {
  display: block;
  grid-area: topic;
  align-self: start;
  min-width: 0;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 20px;
}
/* In the scan, provenance is only its glyph, flowing after the last word; the word comes back when open.
   The small negative right margin lets the glyph use half the column gap, never the chevron's space. */
.vrow-topic .prov { gap: 0; margin: 0 -4px 0 5px; font-size: 0; vertical-align: -1px; }
.vrow-head[aria-expanded="true"] .vrow-topic .prov { gap: 5px; margin: 0 0 0 8px; font-size: 12.5px; vertical-align: 0; }
.vrow-answer {
  grid-area: answer;
  align-self: end;
  color: var(--ink);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.vrow-head > .ic { grid-area: chev; align-self: start; width: 18px; height: 18px; margin-top: 1px; color: var(--muted); transition: transform 0.2s var(--spring); }
.vrow-head[aria-expanded="true"] > .ic { transform: rotate(180deg); }
/* Open: the head keeps its natural height and the detail follows right under it. */
.vrow-head[aria-expanded="true"] { flex-grow: 0; min-height: 0; grid-template-rows: auto auto; }

/* Full-width rows: a standing condition, the notebook, the aid estimate. */
.vrow[data-row="env"] .vrow-head,
.vrow[data-row="book"] .vrow-head,
.vrow[data-row="pac"] .vrow-head {
  grid-template-areas: "mark topic chev" "mark answer chev";
  grid-template-columns: 16px minmax(0, 1fr) 18px;
  grid-template-rows: auto auto;
  gap: 3px 12px;
  min-height: 66px;
  padding: 12px 14px;
}
.vrow[data-row="env"] .vrow-answer,
.vrow[data-row="book"] .vrow-answer,
.vrow[data-row="pac"] .vrow-answer {
  font-family: var(--font);
  font-size: 15.5px;
  font-weight: 400;
  letter-spacing: 0;
}
.vrow[data-row="env"] .vrow-head > .ic,
.vrow[data-row="book"] .vrow-head > .ic,
.vrow[data-row="pac"] .vrow-head > .ic { align-self: center; margin-top: 0; }

/* Tone: the mark carries it, the tile colour repeats it for a fast scan. */
.vrow[data-tone="act"] { border-color: #bfe0cb; background: var(--mint-tint); }
.vrow[data-tone="act"] .vrow-answer { color: var(--emerald); }
.vrow[data-tone="warn"] { border-color: #ebd27a; background: var(--gold-tint); }
.vrow[data-tone="risk"] { border-color: #f1c0ba; background: var(--risk-tint); }
.vrow[data-tone="risk"] .vrow-answer { color: var(--risk); }
.vrow[data-tone="act"] .vrow-topic,
.vrow[data-tone="warn"] .vrow-topic,
.vrow[data-tone="risk"] .vrow-topic { color: var(--ink); }

.vrow-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 6px 6px;
  padding: 14px 12px 16px;
  border-radius: 14px 4px 14px 4px;
  background: var(--surface);
  font-size: 14.5px;
}
.vrow-body[hidden] { display: none; }
.vrow-body > p { max-width: 62ch; }
.vrow-body h3 { margin-top: 2px; color: var(--ink); font-size: 13.5px; font-weight: 600; }

/* Before the first answer: each row's answer is a bone (painted in skeleton.css), widths varied so it reads like text. */
html:not([data-loaded]) .vrow-answer { width: 72%; min-height: 14px; color: transparent; }
html:not([data-loaded]) .vrow:nth-child(3n+2) .vrow-answer { width: 58%; }
html:not([data-loaded]) .vrow:nth-child(3n) .vrow-answer { width: 84%; }

/* Folds: secondary detail inside a view (history table, forms, solar). */
.fold {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .ic { color: var(--olive); }
.fold > summary small { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 400; }
.fold > summary::after {
  width: 8px;
  height: 8px;
  flex: none;
  margin: -3px 4px 0 auto;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  content: "";
  transform: rotate(45deg);
  transition: transform 0.2s var(--spring);
}
.fold > summary:has(small)::after { margin-left: 4px; }
.fold[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
.fold[open] > summary { border-bottom: 1px solid var(--line); }
.fold-body { display: flex; flex-direction: column; gap: 12px; padding: 14px; }

/* Facts: label over value, two per row on phones. */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
}
.facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.facts dd small { color: var(--muted); font-size: 13px; }
.facts .prov { margin-top: 2px; }
@media (min-width: 600px) { .facts.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Spray windows: quiet tags, not pills. */
.window-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 2px 10px;
  border: 1px solid #bfe0cb;
  border-radius: 999px;
  background: var(--mint-tint);
  color: var(--olive-deep);
  font-size: 14px;
}

/* Charts */
.chart { min-height: 112px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { width: 12px; height: 12px; content: ""; }
.lg-rain::before { background: var(--water); }
.lg-etc::before { height: 3px; background: var(--gold-deep); }

/* Flags (environment and weather alerts) */
.flag-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.flag {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  font-size: 14px;
}
.flag .ic { width: 18px; height: 18px; margin-top: 1px; }
.flag-high { border-color: #f1c0ba; background: var(--risk-tint); color: var(--risk); }
.flag-medium { border-color: #ebd27a; background: var(--albero-tint); color: var(--albero-text); }
.flag-ok { border-color: #bfe0cb; background: var(--olive-tint); color: var(--olive-deep); }
.alert-list .flag span { display: flex; flex-direction: column; gap: 2px; }
.alert-list .flag small { font-size: 12.5px; }
html[data-contrast="sun"] .flag { border-width: 2px; border-color: #000; }

.env-grid { display: grid; margin: 0; }
.env-grid div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.env-grid dt { color: var(--muted); font-size: 13px; }
.env-grid dd { margin: 0; font-size: 14px; }
.env-grid small { display: block; color: var(--muted); }
.aq { display: block; font-weight: 600; }
.st { display: inline-block; margin: 3px 6px 0 0; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; }
.st-bad { background: var(--risk-tint); color: var(--risk); }
.st-good { background: var(--olive-tint); color: var(--olive-deep); }
.st-unk { background: var(--sunken); color: var(--muted); }

/* Generic rows (satellite passes, saved parcels) */
.list-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.list-row:first-child { border-top: 0; }
.list-row .ic { width: 18px; height: 18px; color: var(--olive); }
.list-row span:last-child { color: var(--muted); text-align: right; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  min-height: 48px;
  padding: 6px 12px;
  border: 0;
  background: none;
  text-align: left;
}
.row-main strong { font-size: 15px; font-weight: 600; }
.row-main small { overflow: hidden; max-width: 100%; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }

/* Data sources footer */
.sources { margin-top: 8px; padding: 14px 2px 0; border-top: 1px solid var(--line); }
.sources h2 { margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.sources ul { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sources li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.sources a { color: var(--ink); }
.src-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.src-terms { color: var(--muted); font-size: 12px; line-height: 1.35; }
.src-chip { flex: none; padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.src-chip.ok { background: var(--olive-tint); color: var(--olive-deep); }
.src-chip.todo { background: var(--albero-tint); color: var(--albero-text); }

/* Map HUD */
.hud-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.hud-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.hud-stats dt { overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.hud-stats dd { overflow: hidden; margin: 0; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.hud-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 899px) {
  .hud-stats div:nth-child(4) { display: none; }
  .hud-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .hud-stats { flex: 1; grid-template-columns: repeat(3, minmax(0, 1fr)) max-content; min-width: 340px; }
  .hud-actions { display: flex; }
}

.anomaly-pin-wrapper { border: 0; background: none; }
.anomaly-pin {
  display: block;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--risk);
  box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.35), 0 2px 6px rgba(16, 35, 26, 0.35);
}

.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 11px; }
.leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; }

/* Sheet content */
.fleet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 4px 0 0; }
.fleet div { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunken); }
.fleet dt { color: var(--muted); font-size: 12.5px; }
.fleet dd { margin: 0; font-size: 17px; }

.seg-buttons { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: var(--sunken); }
.seg-buttons button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 14px;
}
.seg-buttons button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 35, 26, 0.14); }

.toggle-list { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); }
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  border: 0;
  background: var(--surface);
  font-size: 15px;
  text-align: left;
}
.toggle-list .toggle + .toggle { border-top: 1px solid var(--line); }
#sunModeToggle { border: 1px solid var(--line); border-radius: var(--radius); }
.toggle span strong { display: block; font-weight: 600; }
.toggle span small { display: block; color: var(--muted); font-size: 13px; }
.toggle i {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.2s;
}
.toggle i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  content: "";
  transition: transform 0.25s var(--spring);
}
.toggle.active i { background: var(--leaf); }
.toggle.active i::after { transform: translateX(18px); }

.legend-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.legend-list li { display: grid; grid-template-columns: 104px 1fr; align-items: baseline; gap: 10px; font-size: 13.5px; }
.legend-list .prov { justify-self: start; }

/* Method sheet and validation rows */
.method-item { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.method-item summary { font-weight: 600; cursor: pointer; }
.method-item p { margin: 8px 0 0; font-size: 14px; line-height: 1.45; }
.method-thresholds li { grid-template-columns: minmax(0, 1fr) auto; overflow-wrap: anywhere; }
.valid-row { align-items: center; gap: 8px; }
.valid-row .tag { max-width: 45%; text-align: right; white-space: normal; }
#validationForm [hidden] { display: none; }

/* Official station block inside the irrigation row; list heading outside a card */
.station { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunken); }
.station h3 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.list-head { margin-top: 4px; }
