/* S9 styles (s9-records) -- consumes pomio.css tokens only; no new global tokens here. */

/* ---------------------------------------------------------------- phone slots (crm.html modal slots are .field already) */
/* the slot is itself a .field and the widget brings its own .field: one bottom margin, not two (as #nl-phone-slot in s9-deals.css) */
#co-new-phone-slot, #pp-new-phone-slot { margin-bottom: 0; min-width: 0; }
#co-new-phone-slot > .field.s9-phone, #pp-new-phone-slot > .field.s9-phone { margin-bottom: 14px; }
.field-row > .field.s9-phone { flex: 1; min-width: 0; }
.s9-rec-call-row { margin: -6px 0 14px; min-height: 0; }
.s9-rec-call-row:empty { display: none; }
.s9-rec-call {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 2px;
  font-size: 13px; font-weight: 600; color: var(--accent-text); max-width: 100%;
}
.s9-rec-call-num { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.s9-phone-text { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- owner (accountmanager) */
.s9-owner.is-unassigned, select.is-unassigned { color: var(--muted); font-style: italic; }
select.is-unassigned option { font-style: normal; color: var(--text); }

/* ---------------------------------------------------------------- category chips (read-only) */
.s9-cat-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; max-width: 100%; min-width: 0; vertical-align: middle; }
.s9-cat-chip {
  display: inline-block; max-width: 160px; padding: 2px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 600; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.s9-cat-chip.is-archived { color: var(--muted); border-style: dashed; font-weight: 500; }
.s9-cat-chip.is-more { background: none; color: var(--muted); }
.s9-cat-empty { color: var(--muted); font-size: 13px; }
.s9-co-table td.s9-cat-cell { max-width: 260px; }

/* ---------------------------------------------------------------- category picker (categoryPicker.js) */
.s9-catpick { border: 0; margin: 0; padding: 0; min-width: 0; }
.s9-catpick-legend {
  display: block; padding: 0; margin-bottom: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.s9-catpick-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.s9-catchip, .field label.s9-catchip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 36px; padding: 4px 12px 4px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; margin: 0; letter-spacing: 0;
}
.field label.s9-catchip { color: var(--text); }
.field label.s9-catchip.is-archived { color: var(--muted); }
.s9-catchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.s9-catchip input, .field .s9-catchip input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent-text); cursor: inherit; }
.s9-catchip:hover { border-color: var(--accent-text); }
.s9-catchip:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent-text); }
.s9-catchip.is-checked { background: var(--accent-soft); border-color: var(--accent-text); }
.s9-catchip.is-archived { border-style: dashed; color: var(--muted); }
.s9-catchip:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.s9-catchip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-text); }
.s9-catchip:has(input:disabled):hover { border-color: var(--border-strong); }
.s9-catpick-hint { margin: 6px 0 0; font-size: 12.5px; color: var(--warning-text); }
.s9-catpick-hint[hidden] { display: none; }
.s9-catpick-empty { margin: 0; }
.s9-catpick.is-readonly .s9-catpick-list { min-height: 24px; align-items: center; }
.s9-catpick .s9-cat-chip { max-width: 100%; }

/* ---------------------------------------------------------------- company list filter bar (companies.js) */
.s9-co-filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; min-width: 0; }
.s9-owner-filter {
  min-height: var(--tap); padding: 6px 30px 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-control);
  font-size: 13px; background: var(--input-bg); color: var(--text); max-width: 100%; min-width: 0;
}
.s9-owner-filter.is-active { border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text) inset; }
.s9-filter-pop { position: relative; min-width: 0; }
.s9-filter-pop-btn {
  list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 6px 30px 6px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--input-bg); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; position: relative; white-space: nowrap;
}
.s9-filter-pop-btn::-webkit-details-marker { display: none; }
.s9-filter-pop-btn::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg);
}
.s9-filter-pop[open] > .s9-filter-pop-btn::after { transform: rotate(-135deg); margin-top: -1px; }
.s9-filter-pop-btn:focus-visible { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.s9-filter-pop.is-active > .s9-filter-pop-btn { border-color: var(--accent-text); background: var(--accent-soft); }
.s9-filter-pop-panel {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: max-content; min-width: 240px; max-width: min(360px, 90vw);
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface-raised, var(--surface)); box-shadow: var(--shadow-pop);
}
.s9-filter-pop-panel .hint { margin: 0 0 8px; font-size: 12px; }
.s9-filter-pop-list { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }
.s9-filter-opt {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 4px 6px; border-radius: var(--radius-control);
  font-size: 14px; color: var(--text); cursor: pointer; min-width: 0;
}
.s9-filter-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.s9-filter-opt input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent-text); }
.s9-filter-opt:hover, .s9-filter-opt:focus-within { background: var(--surface-2); }

/* ---------------------------------------------------------------- communications panel slot */
.s9-comms-slot[hidden] { display: none; }
.s9-comms-slot { margin-top: 12px; min-width: 0; }

/* ---------------------------------------------------------------- phone / 375px */
@media (max-width: 720px) {
  .s9-co-filterbar > .s9-filter-pop, .s9-co-filterbar > .s9-owner-filter { flex: 1 1 calc(50% - 4px); }
  .s9-filter-pop-btn { width: 100%; }
  /* inline (not floating) on a phone: never wider than the screen */
  .s9-filter-pop-panel { position: static; width: auto; min-width: 0; max-width: none; margin-top: 6px; box-shadow: var(--shadow-sm); }
  .s9-co-filterbar .filter-count { flex: 1 1 100%; }
  .s9-catchip { min-height: var(--tap); }
  .s9-co-table td.s9-cat-cell { max-width: none; }
  .s9-cat-chip { max-width: 140px; }
}
@media (max-width: 400px) {
  .s9-co-filterbar > .s9-filter-pop, .s9-co-filterbar > .s9-owner-filter { flex: 1 1 100%; }
}

/* S9-polish (01-10-2026): company document folder link */
.s9-docs-open:empty { display: none; }
.s9-docs-open { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.s9-docs-link { font-weight: 600; color: var(--accent-text, var(--text)); overflow-wrap: anywhere; }
.s9-docs-host { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- SCALE-1 P4: paged companies / people lists */
.rs-filterbar-gap { flex: 1 1 auto; }
.rs-summary { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.rs-summary.is-unknown { color: var(--muted); font-weight: 500; }
.rs-sort { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); }
.rs-sort select {
  min-height: var(--tap); padding: 6px 30px 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-control);
  font-size: 13px; background: var(--input-bg); color: var(--text); max-width: 100%; min-width: 0;
}
.rs-note { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.rs-note[hidden] { display: none; }
.rs-list-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rs-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 12px 0 4px; min-height: var(--tap); }
.rs-more .hint { margin: 0; font-size: 12.5px; }
.rs-more[hidden] { display: none; }
.rs-sentinel { height: 1px; }
.rs-loading { padding: 16px 4px; color: var(--muted); font-size: 13px; }
.rs-new-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: var(--radius-pill); vertical-align: middle;
  background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700;
}
.rs-stat { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rs-stat.is-loading { color: var(--muted); }
.rs-stat.is-loading::after { content: '…'; }
.rs-stat.is-stale { opacity: .7; }
.rs-dash { color: var(--muted); cursor: help; }
.rs-tab-n { font-variant-numeric: tabular-nums; }
/* drawer: search inside a company's contact persons + paged relation lists */
.rs-dr-search { width: 100%; min-height: var(--tap); margin: 4px 0 6px; box-sizing: border-box; }
.rs-dr-search[hidden] { display: none; }
.rs-dr-more { margin-top: 6px; }
.rs-dr-meta { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 720px) {
  .rs-filterbar-gap { display: none; }
  .rs-sort { flex: 1 1 100%; }
  .rs-sort select { flex: 1 1 auto; }
  .rs-summary { flex: 1 1 100%; white-space: normal; }
  .rs-more .btn-ghost { width: 100%; }
}
.rs-company-filter { flex: 0 1 240px; min-width: 180px; }
@media (max-width: 720px) { .rs-company-filter { flex: 1 1 100%; min-width: 0; } }

/* ---------------------------------------------------------------- SCALE-1 P5: relationship status + services */
/* status badge: one colour family per class (prospect / customer / former customer / other) */
.rship-badge {
  display: inline-flex; align-items: center; max-width: 180px; padding: 1px 8px; border-radius: var(--radius-pill);
  border: 1px solid transparent; font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.rship-badge.is-prospect { background: var(--trust-soft); color: var(--trust-text); }
.rship-badge.is-customer { background: var(--success-soft); color: var(--success-text); }
.rship-badge.is-former_customer { background: var(--warning-soft); color: var(--warning-text); }
.rship-badge.is-other { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.rship-badge.is-none { background: none; color: var(--muted); border: 1px dashed var(--border-strong); font-weight: 500; }
.rship-badge.is-archived { border-style: dashed; border-color: currentColor; }
.rship-badge.is-compact { font-size: 11px; padding: 0 7px; max-width: 140px; }
.rship-badge.is-class { font-weight: 600; }
.rship-dot { flex: none; width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--border-strong); }
.rship-dot.is-prospect { background: var(--trust-text); }
.rship-dot.is-customer { background: var(--success-text); }
.rship-dot.is-former_customer { background: var(--warning-text); }
/* service chips (read-only list / drawer) */
.rship-svc-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; max-width: 100%; min-width: 0; vertical-align: middle; margin: 0; padding: 0; list-style: none; }
.rship-svc-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 170px; padding: 2px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 600; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rship-svc-chip.is-archived { color: var(--muted); border-style: dashed; font-weight: 500; }
.rship-svc-chip.is-more { background: none; color: var(--muted); }
.rship-svc-empty { color: var(--muted); font-size: 13px; }
.s9-co-table td.rship-status-cell { min-width: 96px; max-width: 200px; }
.rship-svc-line { margin-top: 4px; min-width: 0; }
.rship-svc-line .rship-svc-chip { max-width: 100%; }
/* drawer: status select + badge, services chip combobox */
.rship-drawer { min-width: 0; }
.rship-status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rship-status-row select { flex: 1 1 200px; min-width: 0; }
.rship-svc-edit { display: flex; margin-bottom: 6px; }
.rship-svc-chip.is-editable { max-width: 100%; padding-right: 2px; min-height: 32px; }
.rship-svc-chip.is-editable > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rship-svc-remove {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
}
.rship-svc-remove:hover, .rship-svc-remove:focus-visible { background: var(--surface-3); color: var(--text); }
.rship-svc-remove:disabled { opacity: .5; cursor: not-allowed; }
.rship-combo { position: relative; min-width: 0; }
.rship-combo input { width: 100%; box-sizing: border-box; }
.rship-combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface-raised, var(--surface)); box-shadow: var(--shadow-pop);
}
.rship-combo-list[hidden] { display: none; }
.rship-combo-list [role=option] {
  display: flex; align-items: center; min-height: var(--tap); padding: 4px 8px; border-radius: var(--radius-control);
  font-size: 14px; color: var(--text); cursor: pointer; overflow-wrap: anywhere;
}
.rship-combo-list [role=option]:hover, .rship-combo-list [role=option].is-active { background: var(--accent-soft); }
.rship-combo-empty { padding: 8px; font-size: 13px; color: var(--muted); }
/* settings section */
.rship-settings h4 { margin: 18px 0 8px; font-size: 14px; }
.rship-auto-toggle { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 4px; font-weight: 600; }
.rship-auto-toggle input { margin-top: 3px; }
.rship-system-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 6px; }
.rship-desc { margin: 2px 0 0; font-size: 12.5px; overflow-wrap: anywhere; }
.rship-new textarea, .st9-cat-edit textarea { flex: 1 1 100%; min-width: 0; min-height: 0; }
.rship-new select { min-height: var(--tap); }
.rship-sug { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.rship-sug-body { margin-top: 8px; }
.rship-sug-list { margin: 6px 0 10px; padding-left: 18px; max-height: 260px; overflow-y: auto; font-size: 13.5px; }
.rship-sug-list li { margin: 2px 0; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  /* a phone shows the status badge only (no service chips column) */
  .s9-co-table .rship-svc-line { display: none; }
  .s9-co-table td.rship-status-cell { max-width: none; }
  .s9-co-filterbar > .rship-status-filter, .s9-co-filterbar > .rship-service-filter { flex: 1 1 calc(50% - 4px); }
  .rship-svc-remove { width: var(--tap); height: var(--tap); }
}
@media (max-width: 400px) {
  .s9-co-filterbar > .rship-status-filter, .s9-co-filterbar > .rship-service-filter { flex: 1 1 100%; }
}
