/* Record sidebar field rows (B-027): Filter fields, collapsible sections, 32px rows that edit in place. */
.btn.btn-sm { height: 28px; padding: 0 var(--sp-5); font-size: var(--fs-sm); }

.fields { display: flex; flex-direction: column; gap: var(--sp-4); }
.fields-filter {
  display: flex; align-items: center; gap: var(--sp-3); height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-surface); cursor: text;
  transition: border-color var(--t-fast) var(--ease);
}
.fields-filter:focus-within { border-color: var(--border-focus); }
.fields-filter-ic { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.fields-filter-input.input { flex: 1; min-width: 0; height: 30px; padding: 0; border: 0; background: none; }
.fields-filter-input::-webkit-search-cancel-button { cursor: pointer; }

.fields-section { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
.fields-section:last-child { border-bottom: 0; }
.fields-section[hidden] { display: none; }
.fields-section-head {
  display: flex; align-items: center; gap: var(--sp-4); width: 100%; height: 40px; padding: 0 var(--sp-2);
  border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; border-radius: var(--r-md);
}
.fields-section-head:hover { background: var(--bg-hover); }
.fields-section-head:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.fields-section-caret { width: 16px; height: 16px; color: var(--text-2); transition: transform var(--t-med) var(--ease); }
.fields-section-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.fields-section.is-collapsed .fields-section-caret { transform: rotate(180deg); }
.fields-section.is-collapsed .fields-section-body { display: none; }
.fields.is-filtering .fields-section.is-collapsed .fields-section-body { display: flex; }
.fields-section-body { display: flex; flex-direction: column; gap: 1px; }

.field-row {
  position: relative; display: grid; grid-template-columns: 120px minmax(0, 1fr) 28px; align-items: center;
  gap: var(--sp-5); min-height: 32px; padding: 0 var(--sp-2) 0 var(--sp-4); border-radius: var(--r-md); cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.field-row.is-compact { grid-template-columns: 16px minmax(0, 1fr) 28px; }
.field-row[hidden] { display: none; }
.field-row:hover:not(.is-editing):not(.is-readonly) { background: var(--bg-hover); }
.field-row.is-readonly { cursor: default; grid-template-columns: 120px minmax(0, 1fr); }
.field-row.is-compact.is-readonly { grid-template-columns: 16px minmax(0, 1fr); }
.field-ic { width: 16px; height: 16px; color: var(--text-2); }
.field-ic svg { width: 16px; height: 16px; display: block; }
.field-label { font-size: var(--fs-sm); color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-value { min-width: 0; padding: var(--sp-3) 0; line-height: var(--lh-md); overflow-wrap: anywhere; }
.field-value.is-empty { color: var(--text-muted); }
.field-row:not(.is-compact) .field-value { white-space: pre-wrap; max-height: 120px; overflow: hidden; }
.field-link { color: var(--link); text-decoration: none; }
.field-link:hover { text-decoration: underline; }
.field-add {
  display: inline-flex; align-items: center; gap: var(--sp-2); padding: 0; border: 0; background: none;
  color: var(--link); font: inherit; cursor: pointer;
}
.field-add .ic, .field-add svg { width: 14px; height: 14px; }
.field-add:hover { text-decoration: underline; }
.field-edit {
  visibility: hidden; display: grid; place-items: center; width: 28px; height: 24px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-surface); color: var(--text-2);
  box-shadow: var(--shadow-button); cursor: pointer;
}
.field-edit .ic, .field-edit svg { width: 14px; height: 14px; display: block; }
.field-row:hover .field-edit, .field-edit:focus-visible { visibility: visible; }
.field-edit:hover { color: var(--text); border-color: var(--border-strong); }
.field-edit:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }

.field-pills { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.field-pill, .field-flag, .field-label-pill {
  display: inline-flex; align-items: center; gap: var(--sp-3); height: 22px; padding: 0 var(--sp-4);
  border-radius: var(--r-pill); background: var(--bg-hover); font-size: var(--fs-sm); line-height: 22px;
}
.field-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.quality-hot .field-pill-dot { background: var(--quality-hot); }
.quality-medium .field-pill-dot { background: var(--quality-medium); }
.quality-unsure .field-pill-dot { background: var(--quality-unsure); }
.quality-low .field-pill-dot { background: var(--quality-low); }
.quality-not_good .field-pill-dot { background: var(--quality-not-good); }
.field-label-pill { color: var(--text-inverse); background: var(--label-darkgrey); }
.field-label-pill.label-blue { background: var(--label-blue); }
.field-label-pill.label-green { background: var(--label-green); color: var(--text); }
.field-label-pill.label-yellow { background: var(--label-yellow); color: var(--text); }
.field-label-pill.label-red { background: var(--label-red); }
.field-label-pill.label-purple { background: var(--label-purple); }
.field-label-pill.label-grey { background: var(--label-grey); color: var(--text); }
.field-label-pill.label-brown { background: var(--label-brown); }
.field-label-pill.label-orange { background: var(--label-orange); color: var(--text); }
.field-label-pill.label-pink { background: var(--label-pink); color: var(--text); }

/* Participants under the person row (B-028, UX-045): one 34px line per person at the field-row pitch,
   the group icon on the first line, "+ Participants" right-aligned on the contact person row. */
.field-row.is-custom { cursor: default; }
.field-row.is-custom:hover:not(.is-editing) { background: none; }
.field-row:has(> .field-value > .participants.is-empty) { display: none; }
.field-row:has(> .field-value > .participants) { align-items: start; }
.field-row:has(> .field-value > .participants) > .field-ic { margin-top: 9px; }
.field-row:has(> .field-value > .participants) > .field-value { padding: 0; }
.field-value:has(> .participants-add.is-inline) {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-height: 34px; padding: 0;
}
.field-value:has(> .participants-add.is-inline) > .field-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participants-add.is-inline { flex: none; font-weight: var(--fw-semibold); }
.participants { display: flex; flex-direction: column; gap: 1px; }
.participant, .participants-slot { display: flex; align-items: center; gap: var(--sp-3); min-height: 34px; }
.participants.is-picking .participants-slot { display: none; }
.participant-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-remove {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0; flex: none; border: 0;
  border-radius: var(--r-tile, 6px); background: none; color: var(--text-2); cursor: pointer;
  opacity: 0; transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.participant-remove .ic, .participant-remove svg { width: 16px; height: 16px; display: block; }
.participant:hover .participant-remove, .participant-remove:focus-visible { opacity: 1; }
.participant-remove:hover { background: var(--bg-hover); color: var(--text); }
.participant-remove:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.participant-remove:disabled { cursor: default; opacity: 0.5; }
.participants-pick { display: flex; flex-direction: column; gap: var(--sp-2); padding: 0 0 var(--sp-2); animation: field-open var(--t-med) var(--ease-enter); }
.participants-input.input { height: var(--control-h); }
.participants-input.input:disabled { background: var(--bg-app); color: var(--text-2); }
.participants-none { padding: var(--sp-3) var(--sp-6); color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-md); }
.field-label-pill.label-darkgrey { background: var(--label-darkgrey); }

/* Inline editor */
.field-row.is-editing { display: block; padding: var(--sp-4); background: var(--bg-app); cursor: default; }
.field-editor { display: flex; flex-direction: column; gap: var(--sp-4); animation: field-open var(--t-med) var(--ease-enter); }
.field-editor-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); }
.field-editor .input, .field-editor .select-trigger { width: 100%; background: var(--bg-surface); }
.field-textarea.input { height: auto; min-height: 96px; padding: var(--sp-4); resize: vertical; line-height: var(--lh-md); font: inherit; }
.field-money { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: var(--sp-4); }
.field-multi { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-surface); }
.field-multi-row { display: flex; align-items: center; gap: var(--sp-4); min-height: 28px; cursor: pointer; }
.field-multi-row input { width: 16px; height: 16px; accent-color: var(--blue-bright); }
.field-error { font-size: var(--fs-sm); color: var(--red); }
.field-error:empty { display: none; }
.field-row.has-error .input { border-color: var(--red); }
.field-editor-actions { display: flex; justify-content: flex-end; gap: var(--sp-4); }
@keyframes field-open { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .field-editor { animation: none; } .fields-section-caret { transition: none; } }

/* Custom fields (B-064): sidebar editors for checkbox / set, and the block in the Add modals. */
.field-check { display: inline-flex; align-items: center; gap: var(--sp-4); min-height: 28px; cursor: pointer; }
.field-check-input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue-bright); cursor: pointer; }
.cf-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-custom:has(> .cf-add[hidden]) { display: none; }
.cf-add { display: flex; flex-direction: column; gap: var(--sp-5); }
.cf-add[hidden] { display: none; }
.cf-add-field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.cf-add-label { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); }
.cf-required { color: var(--red); }
.cf-add-field > .input, .cf-add-field > .select-trigger { width: 100%; }
.cf-add-field .field-textarea.input { min-height: 72px; }
.cf-add-field.is-invalid .input, .cf-add-field.is-invalid .select-trigger,
.cf-add-field.is-invalid .field-multi { border-color: var(--red); }
.cf-multi { max-height: 168px; overflow-y: auto; }
/* BUG-123: an error on a custom field with no input in this form, named ('Case number: Required'). */
.cf-form-error { display: flex; flex-direction: column; gap: var(--sp-1); line-height: var(--lh-sm); }
.cf-form-error[hidden] { display: none; }
