/* ───────────────────────────────────────────────────────────────────────────
   Farmer-master & QC-decision screens (Addendum Update A & B).
   ADM-PROC-20…27. Loaded after app.css + proc.css. Built entirely on shared
   tokens. Page-specific one-offs still live in each HTML's <style>.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Sortable header (shared with the SortableTh helper) ── */
.tbl th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.th-sort .th-sort-inner { display: inline-flex; align-items: center; gap: 4px; }
.tbl th.th-sort.num .th-sort-inner { justify-content: flex-end; }
.tbl th.th-sort:hover, .tbl th.th-sort.on { color: var(--foreground); }
.tbl th.th-sort .th-caret { transition: transform .15s ease; flex-shrink: 0; }

/* ── Type pill (supplier type) ── */
.fm-type { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }

/* ── Summary stat strip ── */
.fm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.fm-stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 14px 16px; box-shadow: var(--shadow-xs); }
.fm-stat .k { font-size: 12px; color: var(--muted-foreground); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.fm-stat .v { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1; }
.fm-stat .v small { font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); margin-left: 5px; }

/* ── Tabs (list tabs + detail tabs) ── */
.fm-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.fm-tab { background: none; border: none; padding: 10px 2px; margin-right: 20px; font-size: 14px; font-weight: 500; color: var(--muted-foreground); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.fm-tab.on { color: var(--foreground); font-weight: 600; border-bottom-color: var(--avocado); }
.fm-tab-n { font-size: 11px; font-weight: 600; background: var(--muted); color: var(--muted-foreground); padding: 1px 7px; border-radius: 9999px; }
.fm-tab.on .fm-tab-n { background: var(--avocado-soft); color: var(--avocado-fg); }

/* ── Chip count in cells ── */
.fm-chipn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.fm-chipn .dotg { width: 6px; height: 6px; border-radius: 50%; background: var(--avocado); }

/* ── Response-rate mini bar ── */
.fm-rr { display: inline-flex; align-items: center; gap: 8px; }
.fm-rr .bar { width: 56px; height: 6px; border-radius: 3px; background: var(--muted); overflow: hidden; }
.fm-rr .bar > i { display: block; height: 100%; border-radius: 3px; background: var(--avocado); }
.fm-rr .n { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 30px; }

/* ── Right-rail preview ── */
.fm-split { display: grid; grid-template-columns: 1fr; gap: 16px; }
.fm-split.rail { grid-template-columns: minmax(0,1fr) 320px; }
@media (max-width: 1100px) { .fm-split.rail { grid-template-columns: 1fr; } }

/* ── Detail hero ── */
.fm-hero { display: flex; gap: 18px; align-items: flex-start; padding: 20px; flex-wrap: wrap; }
.fm-hero .id { font-size: 12px; }
.fm-hero-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; flex: 1; min-width: 260px; }
.fm-hero-meta .k { font-size: 11.5px; color: var(--muted-foreground); font-weight: 500; }
.fm-hero-meta .v { font-size: 13.5px; font-weight: 500; margin-top: 2px; display: flex; align-items: center; gap: 6px; }

/* ── KPI mini tiles ── */
.fm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.fm-kpi { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--surface); }
.fm-kpi .k { font-size: 11.5px; color: var(--muted-foreground); display: flex; align-items: center; gap: 5px; }
.fm-kpi .v { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.fm-kpi .v small { font-size: 11.5px; color: var(--muted-foreground); font-weight: 500; margin-left: 3px; }

/* ── Source-farmers panel ── */
.fm-src { display: flex; flex-direction: column; gap: 8px; }
.fm-src-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card); cursor: pointer; }
.fm-src-row:hover { background: var(--accent); }

/* ── Timeline / activity feed ── */
.fm-feed { display: flex; flex-direction: column; }
.fm-feed-row { display: flex; gap: 12px; padding: 0 0 16px; position: relative; }
.fm-feed-row:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 26px; bottom: 0; width: 1.5px; background: var(--border); }
.fm-feed-ic { width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; z-index: 1; }
.fm-feed-t { font-size: 13px; font-weight: 500; }
.fm-feed-d { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }

/* ── Chips (groups/tags inline add/remove) ── */
.fm-chips { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.fm-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 11px; border-radius: 9999px; border: 1px solid var(--border); background: var(--card); font-size: 12.5px; font-weight: 500; }
.fm-chip.tag { background: var(--surface); }
.fm-chip .rm { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; color: var(--muted-foreground); cursor: pointer; border: none; background: none; }
.fm-chip .rm:hover { background: var(--muted); color: var(--foreground); }
.fm-chip-add { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 9999px; border: 1.5px dashed var(--border); background: none; color: var(--muted-foreground); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.fm-chip-add:hover { border-color: var(--avocado); color: var(--avocado-fg); }

/* ── Banners (state) ── */
.fm-banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); margin-bottom: 16px; font-size: 13px; line-height: 1.45; }
.fm-banner .bi { flex-shrink: 0; margin-top: 1px; }
.fm-banner.info   { background: var(--info-soft);    border-color: oklch(from var(--info) l c h / 0.35);    color: var(--info-fg); }
.fm-banner.warn   { background: var(--warning-soft); border-color: oklch(from var(--warning) l c h / 0.4); color: var(--warning-fg); }
.fm-banner.danger { background: var(--danger-soft);  border-color: oklch(from var(--destructive) l c h / 0.4); color: var(--danger-fg); }
.fm-banner b { font-weight: 600; }

/* ── Form sections (create/edit, payment) ── */
.fm-form { max-width: 860px; }
.fm-section { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-xs); margin-bottom: 16px; overflow: hidden; }
.fm-section-head { padding: 16px 20px 4px; }
.fm-section-head .st { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.fm-section-head .sd { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.fm-section-body { padding: 16px 20px 20px; }
.fm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fm-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .fm-grid2, .fm-grid3, .fm-stats { grid-template-columns: 1fr; } }
.fm-field { display: flex; flex-direction: column; gap: 5px; }
.fm-field.col2 { grid-column: 1 / -1; }
.fm-field > span { font-size: 12.5px; font-weight: 500; }
.fm-field > span b { color: var(--destructive); font-weight: 500; margin-left: 2px; }
.fm-field .hint { font-size: 11.5px; color: var(--muted-foreground); font-weight: 400; }

/* ── Type radio cards ── */
.fm-typegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 720px) { .fm-typegrid { grid-template-columns: 1fr; } }
.fm-typecard { display: flex; gap: 11px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; }
.fm-typecard:hover { background: var(--accent); }
.fm-typecard.on { border-color: var(--avocado); background: var(--avocado-soft); box-shadow: 0 0 0 1px var(--avocado) inset; }
.fm-typecard .radio { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--input); flex-shrink: 0; margin-top: 1px; display: inline-flex; align-items: center; justify-content: center; }
.fm-typecard.on .radio { border-color: var(--avocado); }
.fm-typecard.on .radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--avocado); }
.fm-typecard .tt { font-size: 13.5px; font-weight: 600; }
.fm-typecard .td { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; line-height: 1.4; }

/* ── Stepper ── */
.fm-stepper { display: flex; align-items: center; gap: 0; margin-bottom: 20px; flex-wrap: wrap; }
.fm-step { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted-foreground); }
.fm-step .n { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.fm-step.on { color: var(--foreground); font-weight: 600; }
.fm-step.on .n { border-color: var(--avocado); background: var(--avocado); color: oklch(0.98 0.01 130); }
.fm-step.done .n { border-color: var(--avocado); background: var(--avocado-soft); color: var(--avocado-fg); }
.fm-step-line { flex: 1; min-width: 20px; height: 1.5px; background: var(--border); margin: 0 12px; }

/* ── Two-pane (groups manage) ── */
.fm-2pane { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; background: var(--card); box-shadow: var(--shadow-xs); min-height: 520px; }
@media (max-width: 900px) { .fm-2pane { grid-template-columns: 1fr; } }
.fm-2pane-l { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
@media (max-width: 900px) { .fm-2pane-l { border-right: none; border-bottom: 1px solid var(--border); } }
.fm-glist { overflow-y: auto; }
.fm-grow { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.fm-grow:hover { background: var(--accent); }
.fm-grow.on { background: var(--avocado-soft); box-shadow: inset 2px 0 0 var(--avocado); }
.fm-grow .gn { font-size: 13.5px; font-weight: 600; }
.fm-grow .gm { font-size: 11.5px; color: var(--muted-foreground); margin-top: 1px; }
.fm-2pane-r { padding: 20px; overflow-y: auto; }

/* ── Rule builder (smart group) ── */
.fm-rule { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); font-size: 12.5px; }
.fm-rule .rf { font-weight: 600; }
.fm-rule .rop { color: var(--muted-foreground); }

/* ── Threshold indicator (decision) ── */
.fm-thr { display: flex; flex-direction: column; gap: 8px; }
.fm-thr-row { display: grid; grid-template-columns: 90px 70px 1fr; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.fm-thr-row:last-child { border-bottom: none; }
.fm-thr .lab { font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); }
.fm-thr .val { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fm-thr .track { position: relative; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--danger-soft), var(--warning-soft), var(--success-soft)); }
.fm-thr .track .pin { position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px; background: var(--foreground); transform: translateX(-50%); }
.fm-band { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; }
.fm-band.green  { color: var(--success-fg); }
.fm-band.amber  { color: var(--warning-fg); }
.fm-band.red    { color: var(--danger-fg); }

/* ── Decision layout ── */
.fm-decision { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .fm-decision { grid-template-columns: 1fr; } }
.fm-panel { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-xs); }
.fm-panel-head { padding: 15px 18px 12px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.fm-panel-body { padding: 16px 18px; }
.fm-action-sticky { position: sticky; top: 16px; }
.fm-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.fm-photo { aspect-ratio: 4/3; border-radius: var(--radius-md); background: var(--muted); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--muted-foreground); }

/* ── Urgency clock ── */
.fm-clock { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 9999px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--muted); color: var(--muted-foreground); }
.fm-clock.warn   { background: var(--warning-soft); color: var(--warning-fg); }
.fm-clock.danger { background: var(--danger-soft); color: var(--danger-fg); }

/* ── Radio row (decision, payment) ── */
.fm-radio { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; margin-bottom: 8px; transition: border-color .12s, background .12s; }
.fm-radio:hover { background: var(--accent); }
.fm-radio.on { border-color: var(--avocado); background: var(--avocado-soft); box-shadow: 0 0 0 1px var(--avocado) inset; }
.fm-radio.on.reject { border-color: var(--destructive); background: var(--danger-soft); box-shadow: 0 0 0 1px var(--destructive) inset; }
.fm-radio .rc { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--input); flex-shrink: 0; margin-top: 1px; display: inline-flex; align-items: center; justify-content: center; }
.fm-radio.on .rc { border-color: var(--avocado); }
.fm-radio.on .rc::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--avocado); }
.fm-radio.on.reject .rc { border-color: var(--destructive); }
.fm-radio.on.reject .rc::after { background: var(--destructive); }
.fm-radio .rt { font-size: 13.5px; font-weight: 600; }
.fm-radio .rd { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }

/* ── Diff row (payment terms) ── */
.fm-diff { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.fm-diff .old { color: var(--muted-foreground); text-decoration: line-through; }
.fm-diff .new { font-weight: 600; }

/* ── Upload / dropzone ── */
.fm-drop { border: 1.5px dashed var(--border); border-radius: var(--radius-xl); background: var(--surface); padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fm-drop .di { width: 52px; height: 52px; border-radius: 14px; background: var(--avocado-soft); color: var(--avocado-fg); display: inline-flex; align-items: center; justify-content: center; }

/* ── Map placeholder ── */
.fm-map { height: 160px; border-radius: var(--radius-lg); border: 1px solid var(--border); background:
  linear-gradient(oklch(from var(--avocado) l c h / 0.06), oklch(from var(--avocado) l c h / 0.06)),
  repeating-linear-gradient(0deg, transparent, transparent 22px, var(--border) 22px, var(--border) 23px),
  repeating-linear-gradient(90deg, transparent, transparent 22px, var(--border) 22px, var(--border) 23px);
  display: flex; align-items: center; justify-content: center; color: var(--muted-foreground); font-size: 12.5px; gap: 7px; }
