/* ==========================================================================
   „Založiť farmu“ (views/zalozit.js, #/zalozit) and the Návrh screen of a farm (views/navrh.js,
   #/s/:id/farma/navrh) — prefix .zf- (shared proposal cards) and .nv- (Návrh page only).
   Designs: docs/design-v2/Zalozenie.dc.html (wizard step), docs/design-v2/Navrh.dc.html (proposal).
   Colours only through tokens (v2.css Nova 2 light / dark, app.css classic): paper, white cards radius
   14 px with a hairline, green = farm and income, brown = costs and community, grey = other.
   Phone first: one column, ≥ 44 px targets, inputs ≥ 16 px on touch, the primary action sticks to the
   bottom of the screen (thumb reach) and steps out of the way while the keyboard is open.
   ========================================================================== */

.zf {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  min-width: 0;
  margin-inline: auto;
}
.zf > *, .zf-body > * { min-width: 0; }
.zf-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---------- Head: back · „Krok 1 z 5“ · progress · eyebrow · title · lead ---------- */
.zf-head { display: flex; flex-direction: column; gap: 10px; padding: 0 4px 2px; }
.zf-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.zf-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zf-back:hover { color: var(--green-text); text-decoration: none; }
.zf-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.zf-count { color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.zf-progress { display: flex; gap: 6px; }
.zf-progress-seg { flex: 1 1 0; height: 5px; border-radius: 999px; background: var(--border); }
.zf-progress-seg.is-done { background: var(--green); }
.zf-eyebrow { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.zf-title { margin: 6px 0 0; }
.zf-eyebrow + .zf-title { margin-top: 0; }
.zf-lead { margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.45; }

/* ---------- Cards and rows ---------- */
.zf-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.zf-card-title { font-weight: 600; }
.zf-card-note { color: var(--text-2); font-size: 13px; line-height: 1.4; }
.zf-mt { margin-top: 6px; }

.zf-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.zf-row[hidden] { display: none; }
.zf-row-text { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.zf-row-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.zf-row-sub { color: var(--text-2); font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }
.zf-row-sub-line { padding-left: 0; }
.zf-row-sub-line > .zf-row-sub { flex: 1 1 auto; }

/* Number fields of the design: 44 px, 17 px semibold, unit on the right. */
.zf-num { flex: none; width: 132px; }
.zf-num-wide { width: 160px; }
.zf-num .input,
.zf-text,
.zf-select {
  height: 44px;
  border-radius: var(--radius);
  font-size: 17px;
}
.zf-num .input { font-weight: 600; }
.zf-num .input-suffix { font-size: 14px; color: var(--text-2); }
.zf-num .input::placeholder { font-weight: 500; }
.zf-select-short { flex: none; width: 116px; }
.zf-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.zf-field-label { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.zf-field-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }

.zf-error {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 14px;
  font-weight: 600;
}
.zf-error[hidden] { display: none; }

/* ---------- Chips (region, water and buildings, filters of the proposal) ---------- */
.zf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.zf-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zf-chip:hover { border-color: var(--axis); }
.zf-chip.is-active { border-color: var(--green); background: var(--green-soft); color: var(--green-text); }
.zf-chip:focus-visible, .zf-chip:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.zf-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* „Iný kraj…“: the native picker lies over the chip (tap opens it); 16 px so iOS does not zoom. */
.zf-chip-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font-size: 16px;
  cursor: pointer;
}

/* Segmented controls in the wizard: 44 px items. */
.zf-seg { flex: none; padding: 2px; }
.zf-seg .segmented-item { min-height: 44px; padding: 0 14px; font-size: 14px; }
.zf-seg-wide { display: flex; width: 100%; }
.zf-seg-wide .segmented-item { flex: 1 1 0; justify-content: center; }

/* Checkbox lines: the whole line is the target (≥ 44 px). */
.zf-check-input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--green); cursor: pointer; }
.zf-check-input:disabled { cursor: not-allowed; }
.zf-checkline { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.zf-checkline-text { display: flex; flex-direction: column; min-width: 0; }

/* Folded options („Vlastníctvo, voda a budovy“). */
.zf-more { gap: 0; padding: 0; }
.zf-more-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.zf-more-summary::-webkit-details-marker { display: none; }
.zf-more-summary .icon { flex: none; color: var(--muted); transition: transform 0.15s; }
.zf-more[open] > .zf-more-summary .icon { transform: rotate(180deg); }
.zf-more-body { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 14px; }

/* Hint card with the leaf (design): green tint, first sentence bold. */
.zf-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--green-soft);
  color: var(--green-text);
}
.zf-hint.is-warn { background: var(--warning-soft); color: var(--warning-text); }
.zf-hint > svg { flex: none; margin-top: 1px; }
.zf-hint-text { min-width: 0; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }

/* Warnings and notes. */
.zf-warnings { display: flex; flex-direction: column; gap: 8px; }
.zf-warnings:empty, .zf-warnings[hidden] { display: none; }
.zf-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 13.5px;
  line-height: 1.4;
}
.zf-warn.is-info { background: var(--grey-soft); color: var(--grey-text); }
.zf-warn > .icon { flex: none; margin-top: 1px; }
.zf-warn > span { min-width: 0; overflow-wrap: anywhere; }
.zf-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.zf-notes-summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.zf-notes-list { margin: 0; padding: 0 16px 12px 34px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.zf-notes-list li { margin: 4px 0; overflow-wrap: anywhere; }

/* ---------- Animals (step 2) ---------- */
.zf-species { gap: 12px; }
.zf-pill {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.zf-pill.is-none { background: var(--grey-soft); color: var(--text-2); font-weight: 600; }
.zf-pill[hidden], .zf-num[hidden] { display: none; }

/* ---------- People (step 3) ---------- */
.zf-stepper { display: inline-flex; flex: none; align-items: center; gap: 4px; }
.zf-step-btn, .zf-icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zf-step-btn:hover:not(:disabled), .zf-icon-btn:hover:not(:disabled) { border-color: var(--axis); background: var(--surface-2); }
.zf-step-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.zf-icon-btn { border-color: transparent; background: transparent; color: var(--text-2); }
.zf-stepper-value { min-width: 32px; font-size: 17px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.zf-group-head { margin: 4px 4px 0; }
.zf-members { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.zf-member-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.zf-member-label { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.zf-member-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 380px) {
  .zf-member-fields { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Footer: primary action at thumb reach ---------- */
.zf-foot {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) max(16px, env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}
.zf-foot-caption { color: var(--text-2); font-size: 12.5px; text-align: center; }
.zf-primary, .zf-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zf-primary:hover:not(:disabled) { background: var(--primary-hover); }
.zf-primary:focus-visible, .zf-secondary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.zf-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.zf-secondary { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.zf-secondary:hover { background: var(--surface-2); }
.zf-restart { display: flex; justify-content: center; }
.zf-link {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.zf-link:hover { text-decoration: underline; }

/* ---------- Proposal (step 5 and the Návrh screen) ---------- */
.zf-proposal { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.zf-filters {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter) 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.zf-filters::-webkit-scrollbar { display: none; }
.zf-filters .zf-chip { flex: none; font-size: 13.5px; white-space: nowrap; }
.zf-plist { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.zf-pcard {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--grey);
  border-radius: var(--radius-lg);
}
.zf-pcard[hidden] { display: none; }
.zf-pcard.zf-tone-green { border-left-color: var(--green); }
.zf-pcard.zf-tone-brown { border-left-color: var(--brown); }
.zf-pcard.is-off { border-left-color: var(--border-strong); }
.zf-pcard.is-off .zf-pcard-title, .zf-pcard.is-off .zf-pcard-money { color: var(--text-2); }
.zf-pcard-main { display: flex; align-items: center; gap: 12px; padding: 14px 12px 8px 16px; }
.zf-pcard-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.zf-pcard-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.zf-pcard-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.zf-pcard-text { color: var(--text-2); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.zf-pcard-money { font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.zf-pcard-money[hidden] { display: none; }
.zf-money-green { color: var(--green-text); }
.zf-money-brown { color: var(--brown-text); }
.zf-pcard-check {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  min-height: 44px;
  cursor: pointer;
}
.zf-badge {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.zf-badge[hidden] { display: none; }

.zf-pcard-more { border-top: 1px solid var(--grid); }
.zf-pcard-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  color: var(--link);
  font-size: 13.5px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.zf-pcard-summary::-webkit-details-marker { display: none; }
.zf-pcard-summary .icon { flex: none; transition: transform 0.15s; }
.zf-pcard-more[open] > .zf-pcard-summary .icon { transform: rotate(180deg); }
.zf-entries { margin: 0; padding: 0 8px 8px; list-style: none; }
.zf-entry { border-top: 1px solid var(--grid); }
.zf-entry:first-child { border-top: 0; }
.zf-entry-check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 8px; cursor: pointer; }
.zf-entry-check > .zf-check-input { margin-top: 1px; }
.zf-entry-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.zf-entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.zf-entry-title { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.zf-entry-meta { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.zf-entry-meta[hidden], .zf-entry-note[hidden] { display: none; }
.zf-entry-why { color: var(--text-2); font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }
.zf-entry-note { color: var(--warning-text); font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.zf-entry.is-inactive .zf-entry-title { color: var(--text-2); }

/* Totals bar of the design: Investície · Zisk / rok · Práca / týždeň + the action. */
.zf-totals {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) max(16px, env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.zf-total-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.zf-total { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.zf-total-label { color: var(--text-2); font-size: 12px; }
.zf-total-value { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; transition: opacity 0.15s; }
.zf-total-value.is-negative { color: var(--critical); }
.zf-totals.is-busy .zf-total-value { opacity: 0.55; }
/* Návrh of a farm (#/s/:id/farma/navrh) has the phone tab bar: the totals stick right above it. */
html[data-tabbar] .zf-totals { bottom: var(--tabbar-space, 0px); padding-bottom: 12px; }
/* What is missing for the start (own money + loan below the investments, cash below zero): red, under the figures. */
.zf-total-gap {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--critical-soft);
  color: var(--critical-text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.zf-total-gap[hidden] { display: none; }
.zf-total-status { color: var(--text-2); font-size: 12.5px; min-height: 0; }
.zf-total-status:empty { display: none; }
.zf-name-card .zf-text { width: 100%; }

/* Phone: the page uses the full width; while the keyboard is open the sticky bars step back into the flow
   (sticky → static keeps the layout, nothing moves) so they never cover the field being typed in. */
@media (pointer: coarse) {
  .zf-num .input, .zf-text, .zf-select { font-size: 17px; }
  .zf:has(:is(input:not([type="checkbox"]):not([type="radio"]), select:not(.zf-chip-select), textarea):focus) :is(.zf-foot, .zf-totals) { position: static; }
}
@media (min-width: 769px) {
  .zf { padding-top: 8px; }
  .zf-foot, .zf-totals { margin-inline: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .zf-totals { border: 1px solid var(--border); border-bottom: 0; }
  .zf-filters { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; overflow: visible; }
}

/* ---------- Návrh screen of a farm (views/navrh.js) ---------- */
.v2-page.nv { max-width: 640px; margin-inline: auto; width: 100%; }
.nv-actions { display: flex; flex-direction: column; gap: 8px; }
.nv-note { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.nv-ro {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--grey-soft);
  color: var(--grey-text);
  font-size: 13.5px;
}

/* Money alerts above the proposal cards (capital / cash) with „Odložiť, čo môže počkať“. */
.zf-money { display: flex; flex-direction: column; gap: 8px; }
.zf-money[hidden], .zf-defer[hidden], .zf-defer-note[hidden] { display: none; }
.zf-defer { align-self: flex-start; }
/* Wage of an employee + the note that phase 1 does not count it yet. */
.zf-wage { display: flex; flex-direction: column; gap: 6px; }
.zf-wage[hidden] { display: none; }
