/* ── Header ── */
.uc-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.uc-header h2 { margin: 0; font-size: 1rem; flex: 1; }
.btn-invite {
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-invite:disabled {
  background: var(--border, #d6e0ea);
  color: var(--muted, #94a3b8);
  cursor: not-allowed;
}

/* ── Member count bar ── */
.uc-member-count {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted, #64748b);
  background: var(--surface, #f8fafc);
  border-bottom: 1px solid var(--border, #d6e0ea);
}
.uc-member-count.at-cap {
  background: #fff7ed;
  color: #9a3412;
  border-bottom-color: #fed7aa;
}
.uc-cap-label {
  font-weight: 700;
}

/* ── Members table ── */
.members-table-wrap {
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}
.members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.members-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.members-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.members-table tr:last-child td { border-bottom: none; }
.members-table tr:hover td { background: var(--surface-soft); }
.member-name  { font-weight: 600; }
.member-email { font-size: 0.78rem; color: var(--muted); }

/* ── Editable member name ──
   Reads as text until you interact with it. A row of obvious input boxes turns
   a roster into a form and invites edits that were not the reason anyone opened
   this page; the affordance appears on hover and focus, where it is wanted.
   The role control beside it is an inline <select> for the same reason. */
.member-name-input {
  font: inherit;
  font-weight: 600;
  color: inherit;
  width: 100%;
  max-width: 15rem;
  padding: 3px 6px;
  margin: -3px -6px 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}

.member-name-input::placeholder {
  color: var(--muted, #64748b);
  font-weight: 500;
  font-style: italic;
}

.member-name-input:hover:not(:disabled) {
  border-color: var(--border, #d7e1ec);
  background: var(--surface, #fff);
}

.member-name-input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  background: var(--surface, #fff);
  /* 3:1 against the surface, so the focused field is identifiable without
     relying on the border colour alone (WCAG 1.4.11). */
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.member-name-input:disabled {
  cursor: progress;
  opacity: 0.65;
}

/* Momentary result of a save. Colour is a reinforcement, not the message —
   the value in the field is already the answer. */
.member-name-input.saved  { border-color: #16a34a; background: #f0fdf4; }
.member-name-input.failed { border-color: #b91c1c; background: #fef2f2; }

/* ── Role badge ── */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.role-badge.admin   { background: #ede9fe; color: #7c3aed; }
.role-badge.manager { background: #dbeafe; color: #1d4ed8; }
.role-badge.member  { background: #f0fdf4; color: #15803d; }

/* ── Role select ── */
.role-select {
  padding: 0.35rem 0.6rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
}

/* ── Actions ── */
.btn-remove {
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #fca5a5;
  background: #fff5f5;
  color: #b91c1c;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Loading / empty ── */
.uc-loading { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.88rem; }
.uc-status  { font-size: 0.78rem; padding: 0.25rem 0.6rem; border-radius: 8px; }
.uc-status.is-error   { background: #fef2f2; color: #b91c1c; }
.uc-status.is-success { background: #f0fdf4; color: #15803d; }

/* ── Invite modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.5rem;
  width: min(420px, calc(100vw - 2rem));
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
}
.modal-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; }
.modal-header h3 { margin: 0; flex: 1; font-size: 1.05rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; }
.modal-close:hover { background: var(--surface-soft); }
.form-field { margin-bottom: 0.85rem; }
.form-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.form-field input, .form-field select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  outline: none;
  color: var(--text);
}
.form-field input:focus, .form-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}
.modal-actions { display: flex; gap: 0.65rem; margin-top: 1.25rem; }
.btn-modal-save {
  flex: 1;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-modal-save:disabled { opacity: 0.55; cursor: default; }
.btn-modal-cancel {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.88rem;
  cursor: pointer;
}
.invite-status { margin-top: 0.65rem; font-size: 0.8rem; min-height: 1.2em; }
.invite-status.is-error   { color: #b91c1c; }
.invite-status.is-success { color: #15803d; }

@media (max-width: 640px) {
  .members-table th:nth-child(3), .members-table td:nth-child(3) { display: none; }
}

/* ── Org Branding Section ── */
.uc-section {
  margin-top: 2rem;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.uc-section-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.uc-section-header h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.uc-admin-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ede9fe;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.uc-branding-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.5rem;
  padding: 1.25rem;
}
@media (max-width: 600px) {
  .uc-branding-grid { grid-template-columns: 1fr; }
}
.uc-brand-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.uc-logo-preview-wrap {
  width: 140px;
  height: 80px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.65rem;
  overflow: hidden;
}
.uc-logo-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.uc-logo-placeholder {
  font-size: 0.72rem;
  color: var(--muted);
}
.btn-upload-logo {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.btn-upload-logo:hover { background: var(--surface-soft); }
.uc-upload-status {
  font-size: 0.75rem;
  margin-top: 0.35rem;
  min-height: 1em;
  color: var(--muted);
}
.uc-branding-desc-area { display: flex; flex-direction: column; }
.uc-desc-input {
  flex: 1;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.uc-desc-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}
.uc-nav-logo-row {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.uc-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
}
.uc-toggle-input { display: none; }
.uc-toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.uc-toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.uc-toggle-input:checked + .uc-toggle-track { background: var(--primary); }
.uc-toggle-input:checked + .uc-toggle-track .uc-toggle-thumb { left: 21px; }
.uc-nav-logo-note {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  padding-left: calc(40px + 0.65rem);
}
.uc-branding-actions {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.btn-save-branding {
  padding: 0.5rem 1.2rem;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-save-branding:disabled { opacity: 0.55; cursor: default; }
.uc-branding-status { font-size: 0.8rem; }
.uc-branding-status.is-error   { color: #b91c1c; }
.uc-branding-status.is-success { color: #15803d; }

/* ── Billing Section ── */
.uc-billing-body { padding: 1.25rem; }
.uc-plan-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.uc-plan-info { flex: 1; min-width: 0; }
.uc-plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.uc-plan-detail {
  font-size: 0.78rem;
  color: var(--muted);
}
.uc-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.uc-plan-badge.free { background: #f1f5f9; color: #64748b; border: 1px solid var(--border-strong); }
.uc-plan-badge.pro  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.uc-plan-badge.past-due { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.btn-upgrade {
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-upgrade:disabled { opacity: 0.55; cursor: default; }
.btn-manage-billing {
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-manage-billing:disabled { opacity: 0.55; cursor: default; }
.uc-billing-status { font-size: 0.78rem; margin-top: 0.6rem; min-height: 1em; }
.uc-billing-status.is-error   { color: #b91c1c; }
.uc-billing-status.is-success { color: #15803d; }

/* ── Contact field definitions ────────────────────────────────
 *
 * Part of Organization settings, so it borrows that block's vocabulary rather
 * than inventing one: .uc-section for the card, .uc-section-header for the
 * title bar, .uc-brand-label for field labels, .btn-save-branding for the
 * action. The first version reused the contacts page's .ct-field, and
 * /settings does not load contacts.css — so the inputs had no border, no
 * radius and no spacing, and the section read as if it belonged to a different
 * product.
 */
.uc-cfd-body { padding: 1.25rem; }

.uc-cfd-lead {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

.uc-cfd-field { margin-bottom: 0.9rem; }

/* Same box as .uc-desc-input, so a text field here and the organization
   description above it are visibly the same control. */
.uc-cfd-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.uc-cfd-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}
textarea.uc-cfd-input { resize: vertical; }

.cfd-add-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 0.9rem;
}
@media (max-width: 560px) {
  .cfd-add-row { grid-template-columns: minmax(0, 1fr); }
}

/* The list of fields already defined. */
.cfd-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.1rem; }

.cfd-list:empty { display: none; }

.cfd-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
}
.cfd-row-main { display: flex; align-items: baseline; gap: 0.55rem; flex: 1; min-width: 0; }
.cfd-row-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}
.cfd-row-type {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
}

/* The choices of a select field, shown so an admin can see them without
   reopening anything. */
.cfd-row-opts { display: flex; flex-wrap: wrap; gap: 0.3rem; width: 100%; }
.cfd-opt {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #e8f0fb;
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 600;
}

/* The empty state, which loadContactFieldDefs renders as .uc-loading. */
.uc-cfd-body .uc-loading {
  padding: 0.85rem;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  text-align: center;
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

/* ── Assistant capabilities ────────────────────────────────────────────────
   The list an admin ticks to decide what the assistant may do. Rendered from
   ASSISTANT_CAPABILITIES in js/assistant-capabilities.js, so this styles
   whatever that registry contains rather than a fixed set of rows. */
.uc-assist-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.9rem;
  cursor: pointer;
}

.uc-assist-caps {
  border-top: 1px solid var(--border, #d6e0ea);
  padding-top: 0.9rem;
  margin-bottom: 0.9rem;
}

.uc-assist-cap {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border, #d6e0ea);
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.5;
}

.uc-assist-cap:last-child { border-bottom: none; }

.uc-assist-cap input { margin-top: 0.2rem; flex-shrink: 0; }
.uc-assist-cap small { color: var(--muted, #64748b); }

/* A capability whose prerequisite is off: still listed, visibly unavailable,
   with the reason underneath. Removing the row entirely would read as a bug. */
.uc-assist-cap.is-blocked { opacity: 0.55; cursor: not-allowed; }
.uc-assist-blocked { color: #b45309; font-weight: 600; }

.uc-assist-flag {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b45309;
  background: rgba(180, 83, 9, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  margin-left: 0.35rem;
  vertical-align: 1px;
}

.uc-assist-note {
  font-size: 0.8rem;
  color: var(--muted, #64748b);
  margin: 0.8rem 0 0;
  line-height: 1.55;
}
