/* ── Advanced search modal ────────────────────────────────────────────────
   A personnel-query console: filter form on the left, live dossier cards on
   the right, saved-query presets in a bar above both. The modal is a fixed-
   height flex column — header + presets stay pinned, only the two panes scroll
   internally, so the body never drifts and leaves dead space. */
.search-modal {
  max-width: 900px; max-height: 88vh; overflow: hidden;
  display: flex; flex-direction: column; padding: 20px 22px 18px;
}
.search-modal > .modal-head { flex: none; }
.search-modal > .search-body { flex: 1; min-height: 0; }

.search-head-titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.search-modal .modal-head { align-items: flex-start; margin-bottom: 14px; }

/* Compact shell: a full-width text bar carrying the filter/preset openers, then
   the results pane owning the remaining height (it alone scrolls). The advanced
   filters and saved searches each open as a stacked sub-window. */
.search-body { display: flex; flex-direction: column; min-height: 0; gap: 16px; }
/* Hairline divider between the search bar and the results below it. */
.search-bar {
  flex: none; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1 1 320px; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 0 13px; background: var(--bg); border: 1px solid var(--border-bright);
  border-radius: var(--radius); transition: border-color .12s, box-shadow .12s;
}
.search-input:focus-within {
  border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 30%, transparent);
}
.search-input .icon { flex: none; width: 17px; height: 17px; color: var(--muted); }
.search-input input {
  flex: 1; min-width: 0; border: 0; background: none; padding: 11px 0; color: var(--text); font-size: 14px;
}
.search-input input:focus { outline: none; box-shadow: none; }

.search-bar-btns { display: flex; gap: 8px; flex: none; }
.search-tool { gap: 8px; padding: 10px 14px; white-space: nowrap; }
.search-tool.is-active { border-color: var(--accent-2); color: var(--text-strong); }
.search-tool-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; letter-spacing: 0;
}
.search-tool-clear { color: var(--muted); }

/* Hide the results scrollbar so it doesn't eat width and skew the list off-centre —
   the cards stay full-width, flush with the search bar above. Scroll still works via
   wheel/touch/keys. */
.search-results-pane { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.search-results-pane::-webkit-scrollbar { width: 0; height: 0; }
@media (max-width: 620px) {
  /* Keep the tool buttons on the same row as the text bar (no wrap), collapsed to
     icon-only squares to reclaim width; labels are clipped, the filter badge stays. */
  .search-bar { flex-wrap: nowrap; gap: 8px; }
  .search-input { flex: 1 1 auto; }
  .search-bar-btns { flex: none; }
  .search-tool { flex: none; padding: 0; width: 40px; height: 40px; justify-content: center; gap: 0; }
  /* Reuse the shared icon-only label clip (see `.btn.icon-only .btn-lbl`): hides the
     label visually but keeps it as the button's accessible name — no aria-label needed. */
  .search-tool .btn-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* With the label clipped the badge would collide with the icon — pin it to the corner. */
  .search-tool.is-active { position: relative; }
  .search-tool .search-tool-badge {
    position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px;
    padding: 0 4px; font-size: 10px; border: 1px solid var(--bg);
  }
}

/* ── Filter & preset sub-windows (pushed on top of the search modal) ─────────
   Comfortable readable widths; height is matched to the modal by js/windows/screens.js and the
   `.win-results` body scrolls, so the head + footer stay pinned. */
.modal-backdrop > .modal.win-search-filters { max-width: 620px; width: 100%; }
.modal-backdrop > .modal.win-search-presets { max-width: 480px; width: 100%; }
.win-search-filters .search-filters { padding-right: 4px; }
.win-filters-actions {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); align-items: center;
}
.win-filters-actions .spacer { flex: 1; }
.win-filters-actions #filter-count { font-variant-numeric: tabular-nums; }

/* Presets window body: a stacked list of load/delete rows over the save form. */
.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset-row {
  display: flex; align-items: stretch; overflow: hidden;
  border: 1px solid var(--border-bright); border-radius: var(--radius-sm); background: var(--panel-2);
  transition: border-color .12s;
}
.preset-row:hover { border-color: var(--accent-2); }
.preset-load {
  flex: 1; display: inline-flex; align-items: center; gap: 8px; text-align: left;
  background: none; border: 0; cursor: pointer; padding: 10px 12px; color: var(--text);
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .2px;
}
.preset-load .icon { width: 14px; height: 14px; color: var(--signal); flex: none; }
.preset-load:hover { color: var(--accent-2); }
.preset-del {
  flex: none; background: none; border: 0; border-left: 1px solid var(--border); cursor: pointer;
  padding: 0 12px; color: var(--muted-2); transition: color .12s, background .12s;
}
.preset-del .icon { width: 15px; height: 15px; }
.preset-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.preset-empty { margin: 4px 0 12px; font-size: 13px; line-height: 1.5; }
.preset-save {
  display: flex; gap: 8px; align-items: center; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.preset-save input { flex: 1; min-width: 0; }
.preset-save .btn { white-space: nowrap; flex: none; }

.search-section { margin-bottom: 18px; }
.search-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .search-grid { grid-template-columns: 1fr; } }

/* Multi-select chips (status + tags): the real checkbox is hidden, the chip dims
   when unchecked and gains a ring when checked. */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { cursor: pointer; display: inline-flex; position: relative; }
/* Visually hidden but focusable. The label above is position:relative so this
   stays inside it — focusing it on click never scrolls the modal to a stray box.
   `input[type]` (not bare `input`) so this out-specifies the global
   `input[type="checkbox"]` reset regardless of source order. */
.chip-check input[type] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chip-check .badge, .chip-check .tag-chip {
  cursor: pointer; opacity: .42; filter: saturate(.7); transition: opacity .12s, box-shadow .12s, filter .12s;
}
.chip-check:hover .badge, .chip-check:hover .tag-chip { opacity: .75; }
.chip-check input:checked + .badge, .chip-check input:checked + .tag-chip {
  opacity: 1; filter: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 55%, transparent);
}
.chip-check input:focus-visible + .badge, .chip-check input:focus-visible + .tag-chip {
  box-shadow: 0 0 0 2px var(--signal);
}

.filter-taglist {
  max-height: 168px; overflow-y: auto; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.filter-tag-cat {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted-2); margin: 12px 0 7px;
}
.filter-tag-cat:first-child { margin-top: 0; }

.filter-range { margin-bottom: 12px; }
.filter-range > label {
  display: block; margin-bottom: 5px; color: var(--muted); font-family: var(--font-mono);
  font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase;
}
/* `.range-inputs` — the от/до wrapper — moved to `base/helpers.css`: the journal's
   toolbar needs the same pair, and this was the only reason a generic idiom sat in a
   page file. */

/* Results pane: the count/export head stays pinned atop the scrolling cards. */
.search-results-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 1; padding-bottom: 12px; margin-bottom: 4px;
  background: linear-gradient(180deg, var(--panel) 65%, transparent);
}
.search-count {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.search-count::before { content: "▸"; color: var(--signal); }
.search-count b { color: var(--ok-glow); font-size: 15px; letter-spacing: 0; }

/* Phone: the results head is tight (count + "показано перші N" + export), so the
   export button collapses to its glyph — the same idiom the topbar uses
   (.btn:has(.btn-ico) label hidden), with title="Експорт" carrying the a11y name. */
@media (max-width: 560px) {
  .search-results-head .export-menu > summary {
    width: 36px; padding-left: 0; padding-right: 0; gap: 0; justify-content: center;
  }
  .search-results-head .export-menu > summary .btn-lbl { display: none; }
}

.search-cards { display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }

/* Field readout cells — a label stacked over its value — shared by every person
   card: the .pcard roster/search cards below and the picker result cards. */
.ro-l {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted-2);
}
.ro-v {
  font-size: 13.5px; color: var(--text); max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ro-v a { color: var(--accent-2); }
.ro-v a:hover { color: var(--text-strong); text-decoration: underline; }

/* Spine colour keyed to status — readiness at a glance, СЗЧ flagged in red.
   A person card (.pcard on search / roster / person list) sets `--spine` inline from
   its own «Стан» row's colour: the states are a catalogue an operator edits, so there
   is no fixed set of codes to write rules for. Movement statuses (.list-card, the
   movement mobile list) are a real enum and stay keyed by `data-status` below. */
.list-card[data-status="planned"]    { --spine: var(--warn); }
.list-card[data-status="in_transit"] { --spine: var(--info); }
.list-card[data-status="arrived"]    { --spine: var(--ok); }
.list-card[data-status="awol"]       { --spine: var(--danger); }  /* СЗЧ */
