/* v64 filter layout: priority rows + bottom sheet. Colours follow the active theme. */
body.farm-ui #filtersPanel{padding-bottom:14px}
body.farm-ui #filtersPanel #toggleFilters{display:none}
/* The primary rows stay visible even while the legacy panel is "collapsed". */
body.farm-ui[data-density] #filtersPanel>#fxRows{display:grid!important}
body.farm-ui[data-density] .inventory-search-bar{display:none!important}
.fx{display:grid;gap:10px;margin-top:10px}
.fx-row{display:flex;align-items:center;gap:8px;min-width:0}
.fx-label{flex:none;font-size:13px;font-weight:700;color:var(--deep,#273d35)}
.fx svg,.fx-sheet svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* 1. groups: pill chips */
.fx-scroll{display:flex;align-items:center;gap:8px;min-width:0;flex:1;flex-wrap:wrap}
body.farm-ui #filtersPanel .fx #groupPicker{display:contents}
body.farm-ui #filtersPanel .fx .group-choice{position:relative;display:inline-flex;align-items:center;gap:6px;min-height:36px;margin:0;padding:6px 14px;border:1.5px solid var(--line,#d9e4dc);border-radius:999px;background:var(--paper,#fff);color:var(--ink,#2f4339);font-size:14px;font-weight:600;white-space:nowrap;cursor:pointer;user-select:none;transition:background .15s,border-color .15s,color .15s}
body.farm-ui #filtersPanel .fx .group-choice input{position:absolute;opacity:0;width:1px;height:1px;pointer-events:none}
body.farm-ui #filtersPanel .fx .group-choice span{min-width:20px;padding:0 6px;border-radius:999px;background:var(--soft,#eaf1ec);color:var(--muted,#6b7a71);font-size:12px;line-height:20px;text-align:center}
body.farm-ui #filtersPanel .fx .group-choice:has(input:checked){background:var(--green,#537c65);border-color:var(--green,#537c65);color:#fff}
body.farm-ui #filtersPanel .fx .group-choice:has(input:checked) span{background:#ffffff33;color:#fff}
body.farm-ui #filtersPanel .fx .group-choice:has(input:focus-visible){outline:3px solid var(--green,#537c65);outline-offset:2px}
.fx-farm{display:inline-flex;align-items:stretch;max-width:100%;border-radius:999px}
.fx-farm-button{display:inline-flex;align-items:center;gap:6px;min-width:0;min-height:36px;margin:0;padding:6px 14px 6px 11px;border:1.5px solid color-mix(in srgb,var(--green,#537c65) 45%,transparent);border-radius:999px;background:color-mix(in srgb,var(--green,#537c65) 10%,var(--paper,#fff));color:var(--green,#537c65);font-size:14px;font-weight:700;white-space:nowrap;cursor:pointer;box-shadow:none;transition:background .15s}
.fx-farm-button:hover{background:color-mix(in srgb,var(--green,#537c65) 16%,var(--paper,#fff))}
.fx-farm-button svg{width:17px;height:17px}
.fx-farm-value{min-width:0;max-width:15em;overflow:hidden;text-overflow:ellipsis}
.fx-farm-value:empty{display:none}
.fx-farm.is-active .fx-farm-text{display:none}
.fx-farm.is-active .fx-farm-button{border-color:var(--green,#537c65);border-radius:999px 0 0 999px;background:var(--green,#537c65);color:#fff;padding-right:8px}
.fx-farm-clear{display:grid;place-items:center;width:34px;min-height:36px;margin:0;padding:0 4px 0 0;border:1.5px solid var(--green,#537c65);border-left:1px solid #ffffff55;border-radius:0 999px 999px 0;background:var(--green,#537c65);color:#fff;cursor:pointer;box-shadow:none}
.fx-farm-clear[hidden]{display:none}
.fx-farm-clear svg{width:14px;height:14px}
/* The selected tag is shown on the button itself; the legacy chip would repeat it. */
body.farm-ui[data-density] #filtersPanel>.single-farm-active{display:none!important}

/* 2. search */
.fx-search{position:relative}
.fx-search-icon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--muted,#6b7a71);display:flex;pointer-events:none}
body.farm-ui #filtersPanel .fx-search #filterSearch{width:100%;min-height:46px;margin:0;padding:10px 46px 10px 44px;border:1.5px solid var(--line,#d9e4dc);border-radius:14px;background:var(--paper,#fff);font-size:16px;box-shadow:none}
body.farm-ui #filtersPanel .fx-search #filterSearch:focus{border-color:var(--green,#537c65);box-shadow:0 0 0 4px color-mix(in srgb,var(--green,#537c65) 16%,transparent);outline:none}
.fx-search #filterSearch::-webkit-search-cancel-button{display:none}
.fx-clear{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:32px;height:32px;display:grid;place-items:center;padding:0;border:0;border-radius:50%;background:var(--soft,#eaf1ec);color:var(--muted,#6b7a71);cursor:pointer}
.fx-clear svg{width:15px;height:15px}

/* 3. condition pills (priority order left to right) */
.fx-pills{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
/* v66: inline reset ✕ sits just left of the chevron while a condition is active. */
.fx-pill-wrap{position:relative;display:flex;min-width:0}
.fx-pill-wrap>.fx-pill{flex:1;width:100%}
/* chevron stays at the right edge; the value text leaves room for the ✕ just before it */
.fx-pill-wrap.has-reset .fx-pill-value{margin-right:34px}
.fx-pill-reset{position:absolute;right:30px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:26px;height:26px;margin:0;padding:0;border:0;border-radius:50%;background:color-mix(in srgb,var(--green,#537c65) 16%,var(--paper,#fff));color:var(--green,#537c65);cursor:pointer;box-shadow:none}
.fx-pill-reset:hover{background:var(--green,#537c65);color:#fff}
.fx-pill-reset[hidden]{display:none}
.fx-pill-reset svg{width:13px;height:13px;stroke-width:2.4}
.fx-pill-reset:focus-visible{outline:3px solid var(--green,#537c65);outline-offset:2px}
.fx-pill{display:flex;align-items:center;gap:6px;min-width:0;min-height:44px;margin:0;padding:6px 10px;border:1.5px solid var(--line,#d9e4dc);border-radius:12px;background:var(--paper,#fff);color:var(--ink,#2f4339);font-size:14px;text-align:left;cursor:pointer;box-shadow:none}
.fx-pill>svg:first-child{color:var(--green,#537c65)}
.fx-pill>svg:last-child{width:14px;height:14px;margin-left:auto;color:var(--muted,#6b7a71)}
.fx-pill-name{flex:none;font-weight:700}
.fx-pill-value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted,#6b7a71);font-size:13px}
.fx-pill-value:empty{display:none}
.fx-pill.is-active{border-color:var(--green,#537c65);background:color-mix(in srgb,var(--green,#537c65) 9%,var(--paper,#fff))}
.fx-pill.is-active .fx-pill-value{color:var(--green,#537c65);font-weight:700}
.fx-pill[data-sheet="more"] .fx-pill-value{min-width:20px;padding:0 6px;border-radius:999px;background:var(--green,#537c65);color:#fff;font-size:12px;line-height:20px;text-align:center}

/* sheet: centred dialog on desktop, bottom sheet on phones */
.fx-sheet{width:min(560px,calc(100vw - 32px));max-height:min(80dvh,760px);padding:0;border:0;border-radius:20px;background:var(--paper,#fff);color:var(--ink,#2f4339);box-shadow:0 24px 80px #0005;overflow:hidden;font-family:inherit}
.fx-sheet[open]{display:flex;flex-direction:column}
.fx-sheet[data-pane="machine"],.fx-sheet[data-pane="more"]{width:min(760px,calc(100vw - 32px))}
.fx-sheet::backdrop{background:#0006}
.fx-sheet-grip{display:none}
.fx-sheet-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px 10px}
.fx-sheet-head h2{margin:0;font-size:19px;color:var(--deep,#273d35)}
.fx-icon{width:36px;height:36px;display:grid;place-items:center;padding:0;border:0;border-radius:10px;background:var(--soft,#eaf1ec);color:var(--ink,#2f4339);cursor:pointer}
.fx-sheet-body{flex:1;overflow:auto;overscroll-behavior:contain;padding:4px 18px 16px}
.fx-sheet-foot{display:flex;gap:10px;padding:12px 18px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--line,#d9e4dc);background:var(--paper,#fff)}
.fx-sheet-foot button{flex:1;min-height:44px;border-radius:12px;font-size:15px}
.fx-sheet-foot .primary{flex:2}
.fx-pane{display:grid;gap:12px}
.fx-hint{margin:0;font-size:13px;color:var(--muted,#6b7a71)}
.fx-empty{margin:8px 0;color:var(--muted,#6b7a71);text-align:center}

/* single-choice buttons */
.fx-choices{display:grid;grid-template-columns:1fr;gap:8px}
.fx-choices[data-columns="2"]{grid-template-columns:repeat(2,minmax(0,1fr))}
.fx-choice{min-height:48px;margin:0;padding:10px 14px;border:1.5px solid var(--line,#d9e4dc);border-radius:12px;background:var(--paper,#fff);color:var(--ink,#2f4339);font-size:15px;font-weight:600;text-align:left;cursor:pointer;box-shadow:none}
.fx-choice.is-on{border-color:var(--green,#537c65);background:var(--green,#537c65);color:#fff}
.fx-segment{gap:4px;padding:4px;border-radius:14px;background:var(--soft,#eaf1ec)}
.fx-segment .fx-choice{min-height:40px;border:0;background:transparent;text-align:center}
.fx-segment .fx-choice.is-on{background:var(--paper,#fff);color:var(--green,#537c65);box-shadow:0 2px 8px #0000001a}

/* machine pane */
.fx-machine-search{position:relative}
.fx-machine-search span{position:absolute;left:12px;top:50%;transform:translateY(-50%);display:flex;color:var(--muted,#6b7a71)}
body.farm-ui #fxSheet .fx-machine-search input{width:100%;min-height:42px;margin:0;padding:8px 12px 8px 40px!important;border:1.5px solid var(--line,#d9e4dc);border-radius:12px;font-size:16px}
.fx-sheet .machine-select-tools{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;margin:0;font-size:13px}
.fx-sheet .machine-select-tools span{display:none}
.fx-sheet #machinePicker{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;max-height:none;margin:0;padding:0;overflow:visible}
.fx-sheet #machinePicker .machine-option{position:relative;display:flex;align-items:center;gap:8px;min-height:48px;margin:0;padding:8px 10px;border:1.5px solid var(--line,#d9e4dc);border-radius:12px;background:var(--paper,#fff);font-size:14px;cursor:pointer;user-select:none}
.fx-sheet #machinePicker .machine-option[hidden]{display:none}
.fx-sheet #machinePicker .machine-option input{position:absolute;opacity:0;width:1px;height:1px;pointer-events:none}
.fx-sheet #machinePicker .machine-option img{width:30px;height:30px;object-fit:contain}
.fx-sheet #machinePicker .machine-option span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fx-sheet #machinePicker .machine-option:has(input:checked){border-color:var(--green,#537c65);background:color-mix(in srgb,var(--green,#537c65) 12%,var(--paper,#fff));font-weight:700}
.fx-sheet #machinePicker .machine-option:has(input:checked)::after{content:"✓";position:absolute;right:8px;top:6px;color:var(--green,#537c65);font-size:13px;font-weight:800}
.fx-sheet #machinePicker .machine-option:has(input:focus-visible){outline:3px solid var(--green,#537c65);outline-offset:2px}

/* more pane: reuse existing controls in a clean single column */
.fx-pane[data-pane="more"]>label{display:grid;gap:6px;font-size:13px;font-weight:600}
.fx-pane[data-pane="more"] .filter-extra,.fx-pane[data-pane="more"] .advanced{margin:0;border:0;padding:0}
.fx-pane[data-pane="more"] .advanced>summary{display:none}
.fx-pane[data-pane="more"] .advanced .filter-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.fx-pane[data-pane="more"] .bottom-toolbar,.fx-pane[data-pane="more"] .saved-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0;padding:12px 0 0;border-top:1px solid var(--line,#d9e4dc)}
.fx-pane[data-pane="farm"] .single-farm-picker{display:grid;gap:8px}
.fx-pane[data-pane="farm"] .single-farm-dropdown{position:static;max-height:none;box-shadow:none}

@media(max-width:700px){
 .fx-groups{align-items:flex-start;flex-direction:column;gap:6px}
 /* All groups visible at once: chips wrap onto extra lines instead of scrolling. */
 .fx-scroll{width:100%;gap:6px}
 body.farm-ui #filtersPanel .fx .group-choice,.fx-farm-button{min-height:34px;padding:5px 11px;font-size:13px}
 .fx-farm-clear{min-height:34px}
 .fx-pills{grid-template-columns:repeat(2,minmax(0,1fr))}
 /* phones: drop the leading icon while the ✕ is shown so the value stays readable */
 .fx-pill-wrap.has-reset .fx-pill>svg:first-child{display:none}
 .fx-pill-wrap.has-reset .fx-pill-value{margin-right:30px}
 .fx-pill-reset{right:28px}
 body.farm-ui dialog#fxSheet{inset:auto 0 0 0;width:100%!important;max-width:none!important;max-height:86dvh;margin:0;border-radius:20px 20px 0 0;animation:fx-up .2s ease-out}
 .fx-sheet-grip{display:block;width:40px;height:5px;margin:8px auto 0;border-radius:3px;background:var(--line,#d9e4dc)}
 .fx-sheet-head{padding:8px 16px 8px}
 .fx-sheet-body{padding:4px 16px 14px}
 .fx-sheet #machinePicker{grid-template-columns:repeat(2,minmax(0,1fr))}
 .fx-pane[data-pane="more"] .advanced .filter-grid{grid-template-columns:1fr}
}
@keyframes fx-up{from{transform:translateY(40px);opacity:.6}to{transform:none;opacity:1}}
@media(prefers-reduced-motion:reduce){.fx-sheet{animation:none}}
