/* Self-contained components: card, table, drawer, modal, form, bulk bar,
   settings, history. Each block is independent — adding a component here
   should never require touching layout.css. */

/* ── Object card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; cursor: pointer;
  box-shadow: var(--sh-xs);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--border2); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 70, 229, .18), var(--sh); }

.card-img { height: 156px; position: relative; overflow: hidden; background: var(--bg2); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .card-img img { transform: scale(1.04); }
.card-ph {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
}
.card-ph-i { font-size: 2rem; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.card-ph-l {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255, 255, 255, .92); background: rgba(0, 0, 0, .22);
  padding: 3px 10px; border-radius: 99px;
}
.card-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 4px 9px; border-radius: 7px;
  background: var(--accent); color: #fff; box-shadow: var(--sh-xs);
  max-width: calc(100% - 60px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-count {
  position: absolute; bottom: 10px; right: 10px;
  font-size: .66rem; font-weight: 700;
  padding: 4px 9px; border-radius: 99px;
  background: rgba(13, 17, 23, .82); color: #fff;
}
.card-status {
  position: absolute; bottom: 10px; left: 10px;
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 4px 9px; border-radius: 99px; color: #fff; box-shadow: var(--sh-xs);
}
.card-status.pending { background: var(--amber); }
.card-status.flagged { background: var(--red); }
.card-cb {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255, 255, 255, .92); box-shadow: var(--sh-xs);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-cb, .card.sel .card-cb, .selecting .card-cb { opacity: 1; }
.card-cb input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.card-body { padding: 12px 14px 14px; }
.card-name {
  font-size: .9rem; font-weight: 600; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-num { font-size: .76rem; color: var(--text3); font-weight: 500; margin-top: 3px; }
.card-loc {
  display: flex; align-items: center; gap: 5px; margin-top: 9px;
  font-size: .75rem; color: var(--text2);
  background: var(--bg2); border-radius: 8px; padding: 5px 9px;
}
.card-loc svg { width: 12px; height: 12px; flex-shrink: 0; fill: var(--text3); }
.card-loc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; background: var(--surface); }
.tbl th {
  padding: 10px 12px; text-align: left;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); border-bottom: 2px solid var(--border);
  white-space: nowrap; user-select: none; background: var(--surface);
  position: sticky; top: 0; z-index: 2;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text2); }
.tbl th.sorted { color: var(--accent); }
.sort-arr { margin-left: 4px; font-size: .6rem; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--bg); }
.tbl tbody tr.sel td { background: var(--accent-dim); }
/* CSV import preview — a row with a validation problem, at a glance rather
 * than having to read every chip in the Status column. */
.tbl tbody tr.imp-row-err td { background: var(--red-dim); }
.td-cb { width: 36px; }
.td-num, .td-nowrap { white-space: nowrap; }
.td-muted { color: var(--text3); }
.yn-y { color: var(--green); font-weight: 700; }
.yn-n { color: var(--text3); }

/* ── Drawer ──────────────────────────────────────────────────────────────── */
.drawer-bg {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(9, 14, 26, .5); backdrop-filter: blur(3px);
}
.drawer-bg.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 210;
  width: min(480px, 100vw); background: var(--surface);
  box-shadow: var(--sh-xl); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.drawer.open { transform: none; }
.drawer-hd { position: relative; flex-shrink: 0; background: var(--bg2); }
.drawer-hd img { width: 100%; height: 230px; object-fit: cover; display: block; }
.drawer-ph {
  height: 230px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.drawer-ph-i { font-size: 2.6rem; }
.drawer-ph-l {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255, 255, 255, .92); background: rgba(0, 0, 0, .22);
  padding: 4px 12px; border-radius: 99px;
}
.drawer-tb {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 7px;
}
.drawer-tb button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 9px; border: none; cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  background: rgba(255, 255, 255, .92); color: var(--text);
  box-shadow: var(--sh-xs); transition: background .15s;
}
.drawer-tb button:hover { background: #fff; }
.drawer-tb button.danger { color: var(--red); }
.drawer-title {
  padding: 16px 22px 0; font-size: 1.05rem; font-weight: 700;
  letter-spacing: -.02em; color: var(--text); line-height: 1.3;
}
.drawer-sub { padding: 3px 22px 0; font-size: .8rem; color: var(--text3); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 22px 32px; }
.drawer-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer-gallery-thumb {
  width: 64px; height: 64px; border-radius: 8px; overflow: hidden;
  display: block; border: 1px solid var(--border);
}
.drawer-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Review queue */
.review-section { margin-bottom: 18px; }
.review-section:last-child { margin-bottom: 0; }
.review-section-h {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin-bottom: 9px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
.review-count {
  background: var(--bg2); color: var(--text2); border-radius: 99px;
  padding: 1px 8px; font-size: .68rem;
}
.review-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.review-row:last-child { border-bottom: none; }
.review-row-main { flex: 1; min-width: 0; cursor: pointer; }
/* Same layout, no pointer cursor — for rows with nothing to click through to
 * (a missing number has no record behind it to jump to). */
.review-row-static { flex: 1; min-width: 0; }
.review-row-name { font-size: .86rem; font-weight: 600; color: var(--text); }
.review-row-sub { font-size: .76rem; color: var(--text3); margin-top: 2px; }
.review-empty { font-size: .82rem; color: var(--text3); padding: 6px 4px 2px; }

/* Members */
.member-list { margin-bottom: 18px; }
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-row-main { flex: 1; min-width: 0; }
.member-row-email { font-size: .86rem; font-weight: 600; color: var(--text); word-break: break-word; }
.member-you { font-weight: 500; color: var(--text3); }
.member-role { width: auto; min-width: 140px; }
.member-invite {
  border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px;
}
.member-invite-h { font-size: .82rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.member-invite-p { font-size: .78rem; color: var(--text3); line-height: 1.5; margin: 0 0 12px; }
.member-cmd {
  margin-top: 12px; display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border-radius: 8px; padding: 8px 10px;
}
.member-cmd code {
  flex: 1; font-size: .78rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); overflow-x: auto; white-space: nowrap;
}
.member-invite-actions { flex-wrap: wrap; }
.member-invite-result { margin-top: 12px; }

/* Detail sections */
.ds { margin-bottom: 20px; }
.ds-h {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin-bottom: 9px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.ds-b { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.ds-b.c1 { grid-template-columns: 1fr; }
.df { min-width: 0; }
.df.wide { grid-column: 1 / -1; }
.df-l { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 3px; }
.df-v { font-size: .875rem; color: var(--text); word-break: break-word; line-height: 1.5; }
.df-v.em { color: var(--text3); font-style: italic; }
.df-v a { color: var(--accent); }
.df-v pre { font-family: inherit; white-space: pre-wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  /* Neutral default so a bare .chip (multiselect/link values, no y/n/warn/
   * danger verdict to show) still reads as a chip rather than plain text. */
  background: var(--bg2); color: var(--text2);
}
.chip.y { background: var(--green-dim); color: var(--green); }
.chip.n { background: var(--bg2); color: var(--text3); }
.chip.warn { background: var(--amber-dim); color: #b45309; }
.chip.danger { background: var(--red-dim); color: var(--red); }
.drawer-status { margin: 0 0 16px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(9, 14, 26, .55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-xl); width: 100%; max-width: 720px;
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
}
.modal.sm { max-width: 440px; }
.modal-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-hd h3 { flex: 1; font-size: 1.02rem; font-weight: 700; letter-spacing: -.02em; }
.modal-x {
  width: 30px; height: 30px; border: none; background: var(--bg2);
  border-radius: 8px; cursor: pointer; color: var(--text3);
  font-size: 1rem; line-height: 1; transition: background .15s, color .15s;
}
.modal-x:hover { background: var(--border); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal-ft {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px;
  padding: 15px 22px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.modal-ft .spacer { flex: 1; }

/* ── Confirm dialog ──────────────────────────────────────────────────────── */
/* z-index sits above .modal-bg (300) so it can guard closing a form modal. */
.confirm-bg {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: rgba(9, 14, 26, .5); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 24px;
}
.confirm-bg.open { display: flex; }
.confirm {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--sh-xl); width: 100%; max-width: 400px; padding: 22px;
}
.confirm-title { font-size: .98rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 7px; }
.confirm-msg { font-size: .855rem; color: var(--text2); line-height: 1.55; }
.confirm-ft { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ── Form ────────────────────────────────────────────────────────────────── */
.fs { margin-bottom: 20px; }
.fs:last-child { margin-bottom: 0; }
.fs-h {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin-bottom: 11px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.fr { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Photos */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 10px;
}
.photo-thumb {
  position: relative; border-radius: 10px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 90px; object-fit: cover; display: block; }
.photo-thumb.primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.photo-badge {
  position: absolute; top: 6px; left: 6px;
  font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 6px; background: var(--accent); color: #fff;
}
.photo-star, .photo-rm {
  position: absolute; top: 6px; width: 22px; height: 22px; border: none; border-radius: 6px;
  background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .74rem;
  transition: background .15s;
}
.photo-star:hover, .photo-rm:hover { background: rgba(0, 0, 0, .75); }
.photo-star { left: 6px; }
.photo-rm { right: 6px; }
.photo-cap {
  width: 100%; border: none; border-top: 1px solid var(--border);
  padding: 5px 7px; font-family: inherit; font-size: .72rem; color: var(--text);
  background: var(--surface);
}
.photo-cap:focus { outline: none; background: var(--bg2); }
.photo-thumb.uploading { display: flex; align-items: center; justify-content: center; }
.photo-thumb.uploading img { opacity: .45; }
.photo-spin {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff;
  animation: photo-spin .7s linear infinite;
}
@keyframes photo-spin { to { transform: rotate(360deg); } }
.photo-add {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1.5px dashed var(--border2); border-radius: 10px;
  font-size: .82rem; font-weight: 600; color: var(--text2); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.fg { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fg.wide { grid-column: 1 / -1; }
.fg label { font-size: .76rem; font-weight: 600; color: var(--text2); }
.fg label .req { color: var(--red); margin-left: 2px; }
.fg-help { font-size: .72rem; color: var(--text3); line-height: 1.45; }
.fg-err { font-size: .74rem; color: var(--red); font-weight: 500; min-height: 0; }

/* multiselect: a wrapped grid of checkboxes, same visual weight as the
 * .rpt-field-grid checkbox list in Reports. */
.ms-group {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 14px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
}

/* link: chips of what's already picked, a search box, and a results list
 * that only exists in the DOM while there's a query. */
.link-field {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
}
.link-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.link-chips:empty { display: none; }
.link-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 7px; padding: 4px 6px 4px 10px; font-size: .78rem; font-weight: 500;
}
.link-chip-rm {
  background: none; border: none; cursor: pointer; color: inherit; opacity: .7;
  font-size: .9rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  /* 24x24 minimum tap target, same fix .set-tag-rm and .fld-ud both needed. */
  min-width: 24px; min-height: 24px; margin: -4px -4px -4px 0; padding: 0;
}
.link-chip-rm:hover { opacity: 1; }
.link-results {
  display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto;
}
.link-results:empty { display: none; }
.link-result {
  display: block; width: 100%; text-align: left; padding: 7px 9px;
  border: none; border-radius: 7px; background: var(--bg2); color: var(--text);
  font-family: inherit; font-size: .8rem; cursor: pointer;
}
.link-result:hover { background: var(--border2); }
.link-result strong { font-weight: 700; }
.link-result-empty { font-size: .78rem; color: var(--text3); padding: 6px 2px; font-style: italic; }

/* The read-only reference chip in the drawer/report table — clickable, so it
 * needs a hover state a display-only .chip never did. */
.link-chip-ref { cursor: pointer; transition: background .12s; }
.link-chip-ref:hover { background: var(--border2); }
.form-errors {
  background: var(--red-dim); border: 1px solid #fecaca; border-radius: 10px;
  padding: 11px 14px; margin-bottom: 18px;
}
.form-errors ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.form-errors li { font-size: .8rem; color: #991b1b; }
.form-warn {
  background: var(--amber-dim); border: 1px solid #fde68a; border-radius: 10px;
  padding: 11px 14px; margin-bottom: 18px; font-size: .8rem; color: #92400e;
}

/* ── Bulk action bar ─────────────────────────────────────────────────────── */
.bulk-bar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%);
  z-index: 180; display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-radius: 14px;
  background: #0d1117; box-shadow: var(--sh-xl);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s, visibility .2s;
  max-width: calc(100vw - 32px); flex-wrap: wrap;
  /* Hidden state also sets opacity/visibility: a translate alone leaves an
     empty bar (height = padding only) peeking above the viewport edge. */
  opacity: 0; visibility: hidden;
}
.bulk-bar.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.bulk-count { font-size: .84rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; }
.bulk-txt {
  font-size: .78rem; font-weight: 500; color: #64748b; cursor: pointer;
  background: none; border: none; font-family: inherit; padding: 0;
  white-space: nowrap; transition: color .15s;
}
.bulk-txt:hover { color: #94a3b8; }
.bulk-txt.red:hover { color: #f87171; }
.bulk-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, .12); flex-shrink: 0; }
.bulk-grp { display: flex; align-items: center; gap: 5px; }
.bulk-lbl {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #475569; white-space: nowrap;
}
.bba {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 8px;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  border: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.bba:active { transform: scale(.96); }
.bba.y { background: rgba(5, 150, 105, .18); color: #34d399; }
.bba.y:hover { background: rgba(5, 150, 105, .3); }
.bba.n { background: rgba(239, 68, 68, .15); color: #f87171; }
.bba.n:hover { background: rgba(239, 68, 68, .28); }
.bulk-sel {
  padding: 5px 11px; border-radius: 8px;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  border: none; cursor: pointer;
  background: rgba(99, 102, 241, .18); color: #a5b4fc;
  transition: background .15s;
}
.bulk-sel:hover { background: rgba(99, 102, 241, .3); }
.bulk-sel option { background: #1a2035; color: #e2e8f0; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.set-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.set-tab {
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: .82rem; font-weight: 600; color: var(--text3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.set-tab:hover { color: var(--text2); }
.set-tab.act { color: var(--accent); border-bottom-color: var(--accent); }
.set-sec { margin-bottom: 24px; }
.set-sec:last-child { margin-bottom: 0; }
.set-h {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin-bottom: 10px;
}
.set-hint { font-size: .76rem; color: var(--text3); line-height: 1.5; margin-bottom: 10px; }
.set-div { height: 1px; background: var(--border); margin: 22px 0; }
.set-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 8px; }
.set-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 7px;
  padding: 4px 10px; font-size: .78rem; color: var(--text);
}
.set-tag-rm {
  background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  /* The glyph itself can stay small; the tappable box can't — 16x16 (padding
   * alone) measured under any reasonable touch-target minimum during mobile
   * testing. */
  min-width: 24px; min-height: 24px; margin: -4px -6px -4px 0;
  transition: color .12s;
}
.set-tag-rm:hover { color: var(--red); }
.set-add { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.set-add input { flex: 1; }
.set-msg { font-size: .76rem; min-height: 1.2em; margin-top: 6px; }
.set-msg.ok { color: var(--green); }
.set-msg.err { color: var(--red); }
.set-row { display: flex; justify-content: flex-end; margin-top: 10px; gap: 8px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.set-stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.set-stat-v { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.set-stat-l { font-size: .7rem; color: var(--text3); margin-top: 2px; }
.set-meta { margin-top: 12px; font-size: .76rem; color: var(--text3); line-height: 1.8; }
.set-meta span { color: var(--text2); font-weight: 500; }

/* Field editor rows */
.fld-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); margin-bottom: 7px;
}
.fld-row.core { background: var(--surface2); }
.fld-name { font-size: .84rem; font-weight: 600; }
.fld-key { font-size: .7rem; color: var(--text3); font-family: ui-monospace, monospace; }
.fld-tags { display: flex; gap: 5px; align-items: center; }
.fld-pill {
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 5px; background: var(--bg2); color: var(--text3);
}
.fld-pill.req { background: var(--red-dim); color: var(--red); }
.fld-pill.core { background: var(--accent-dim); color: var(--accent); }

/* A field row plus its help-text input below — same wrapper shape as
 * .cf-item, just for the built-in Field labels & order section. */
.fld-item { margin-bottom: 7px; }
.fld-item .fld-row { margin-bottom: 0; }
.fld-help {
  margin-top: 4px; font-size: .78rem; padding: 6px 10px;
  border-color: transparent; background: transparent; color: var(--text2);
}
.fld-help:hover { border-color: var(--border); background: var(--surface); }
.fld-help:focus { background: var(--surface); }

/* Reorder arrows — kept as plain icon buttons rather than drag-and-drop,
 * which is unreliable on touch and inaccessible without a mouse. */
.fld-reorder { display: flex; flex-direction: column; gap: 2px; }
.fld-ud {
  /* Visually compact (fits two stacked in one input's height), but the
   * tappable area is grown to the 24x24 minimum via padding rather than
   * shrinking the glyph further — the same fix .set-tag-rm needed after
   * mobile testing measured it under that minimum. */
  width: 24px; height: 24px; padding: 0; border: none; border-radius: 4px;
  background: var(--bg2); color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .55rem; line-height: 1;
  margin: -4px 0; transition: background .12s, color .12s;
}
.fld-ud:hover:not(:disabled) { background: var(--border2); color: var(--text); }
.fld-ud:disabled { opacity: .3; cursor: not-allowed; }

/* Custom field rows and their per-field option editor */
.cf-item { margin-bottom: 7px; }
.cf-item .fld-row { margin-bottom: 0; }
.cf-group { width: auto; min-width: 130px; flex-shrink: 0; }
.cf-opts {
  margin: 6px 0 0; padding: 8px 0 2px 14px;
  border-left: 2px solid var(--border);
}
.cf-opts .set-list { margin-bottom: 8px; }
.cf-add { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.cf-add input { flex: 1; min-width: 160px; }
.cf-add select { flex-shrink: 0; width: auto; min-width: 130px; }
.set-cat-icon { width: 40px; text-align: center; padding: 7px 4px; flex-shrink: 0; }
.set-cat-label, .set-fld-label { width: 140px; flex-shrink: 0; }
.set-cat-color {
  width: 30px; height: 30px; padding: 2px; border: 1.5px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--surface); flex-shrink: 0;
}

/* ── Display preferences ─────────────────────────────────────────────────── */
/* Text size / colour theme picker (js/prefs.js). Bigger touch targets and a
   clearer selected-state than .set-tab / .vbtn on purpose — this is the one
   settings screen every role sees, including volunteers who most need large,
   unambiguous controls, so it doesn't reuse the compact admin-screen style. */
.prefs-sec { margin-bottom: 24px; }
.prefs-sec:last-child { margin-bottom: 0; }
.prefs-h { font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.prefs-p { font-size: .82rem; color: var(--text2); margin-bottom: 12px; line-height: 1.5; }
.prefs-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.prefs-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; min-height: 44px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.prefs-opt:hover { border-color: var(--border2); background: var(--bg2); }
.prefs-opt.act { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.prefs-opt-tick { display: none; }
.prefs-opt.act .prefs-opt-tick { display: inline; }
.prefs-swatches { display: inline-flex; gap: 3px; margin-right: 2px; }
.prefs-swatch { width: 9px; height: 9px; border-radius: 50%; }

/* ── History / change log ────────────────────────────────────────────────── */
.log-day {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text3); margin: 14px 0 8px;
}
.log-entry { display: flex; gap: 10px; padding: 8px 0; }
.log-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; background: var(--bg2);
}
.log-dot.move { background: var(--accent-dim); }
.log-dot.create { background: var(--green-dim); }
.log-dot.audit { background: var(--amber-dim); }
.log-main { flex: 1; min-width: 0; }
.log-title { font-size: .82rem; font-weight: 600; color: var(--text); }
.log-chg { font-size: .78rem; color: var(--text2); margin-top: 2px; line-height: 1.5; }
.log-chg .from { color: var(--text3); text-decoration: line-through; }
.log-time { font-size: .7rem; color: var(--text3); margin-top: 3px; }
.log-empty { font-size: .8rem; color: var(--text3); font-style: italic; padding: 8px 0; }

/* ── Reports ─────────────────────────────────────────────────────────────── */
/* #overlay-host had no styling at all before this — Audit, the other module
 * once planned to use it, was never built, so this is the first thing to
 * actually turn it into a full-screen surface rather than an empty div that
 * would render its content inline in the normal page flow. */
#overlay-host:not(:empty) {
  position: fixed; inset: 0; z-index: 150;
  background: var(--bg); overflow-y: auto;
}
.rpt-field-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 14px; margin-bottom: 10px;
}
.rpt-count { font-size: .8rem; color: var(--text3); margin-top: 4px; }
.rpt-actions {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.rpt-actions-r { display: flex; gap: 8px; }
.rpt-print { max-width: 900px; margin: 0 auto; padding: 32px; }
.rpt-hd { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid var(--text); }
.rpt-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.rpt-meta { font-size: .78rem; color: var(--text3); margin-top: 4px; }
.rpt-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rpt-table th {
  text-align: left; padding: 8px 10px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text3);
  border-bottom: 2px solid var(--border);
}
.rpt-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
.rpt-table td pre { font-family: inherit; white-space: pre-wrap; }

/* "Print" here means THIS content, not the app shell around it — the report
 * makes no sense on paper with the header/toolbar/buttons still attached. */
@media print {
  body * { visibility: hidden; }
  .rpt-print, .rpt-print * { visibility: visible; }
  .rpt-print { position: absolute; top: 0; left: 0; width: 100%; max-width: none; margin: 0; padding: 0; }
  .rpt-actions { display: none !important; }
}

@media (max-width: 560px) {
  .fr, .ds-b, .set-grid { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  /* Category rows pack two fixed-width inputs (icon + label) alongside a
   * colour swatch and a Remove button — comfortable at desktop widths, but
   * the two halves together need more room than a narrow modal has. Stack
   * them instead of measuring exactly how narrow is too narrow. */
  .fld-row { grid-template-columns: 1fr; gap: 8px 10px; }
  .fld-tags { flex-wrap: wrap; }
  .set-cat-label, .set-fld-label { width: auto; flex: 1; min-width: 90px; }

  /* Three buttons ("Back", "Download CSV", "Print") in one sticky row don't
   * fit a phone's width at 32px side padding — the row was measured pushing
   * "Print" 24px past the right edge. Wrap instead of shrinking the buttons,
   * which would just make them harder to tap. */
  .rpt-actions { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .rpt-actions-r { flex-wrap: wrap; }
  .rpt-print { padding: 20px 14px; }
}
