/* ═══════════════════════════════════════════════ */
/* CLIENT LIST MODAL                              */
/* ═══════════════════════════════════════════════ */
.modal.client-list-modal {
  width: min(94vw, 820px);
  max-width: 820px;
  max-height: 90vh;
  padding: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}
.cl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-secondary) 94%, var(--bg-card));
  flex-shrink: 0;
}
.cl-header-left,
.cl-header-right {
  display: flex;
  align-items: center;
  min-width: 0;
}
.cl-header-left { gap: 10px; }
.cl-header-right { gap: 8px; flex-shrink: 0; }
.cl-title {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}
.cl-count {
  margin-top: 2px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.cl-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  flex: 0 0 auto;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cl-icon-btn:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--text-primary);
}
.cl-header-right .modal-close {
  position: static;
  font-size: 0;
}
.cl-icon-btn svg,
.cl-new-btn svg,
.cl-tools-item svg,
.cl-menu-item svg,
.cl-tag-remove svg,
.cl-avatar-edit-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cl-new-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.05s;
}
.cl-new-btn:hover { opacity: 0.9; }
.cl-new-btn:active,
.cl-icon-btn:active,
.cl-tools-item:active,
.cl-menu-item:active { transform: translateY(1px); }
.cl-tools-wrap {
  position: relative;
}
.cl-tools-menu,
.cl-row-menu {
  display: none;
  z-index: 220;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
}
.cl-tools-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
}
.cl-tools-menu.show,
.cl-row-menu.show {
  display: grid;
  gap: 2px;
}
.cl-tools-item,
.cl-menu-item {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.cl-tools-item:hover,
.cl-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.cl-menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.cl-menu-danger:hover { color: var(--red); }
.cl-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  flex-shrink: 0;
}
.cl-search-wrap {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
}
.cl-search-wrap:focus-within {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 26%, transparent);
  outline-offset: 1px;
}
.cl-search-wrap svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}
.cl-search {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.cl-filter-group {
  display: flex;
  gap: 8px;
}
.cl-sort,
.cl-status-filter {
  min-height: 38px;
  padding: 0 30px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.cl-sort:focus,
.cl-status-filter:focus {
  border-color: var(--accent);
}
.cl-tag-filters {
  display: flex;
  gap: 6px;
  padding: 0 18px 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.cl-tag-chip {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cl-tag-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.cl-tag-clear { color: var(--text-muted); font-style: italic; }
.cl-list {
  min-height: 120px;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px 12px 12px;
}
.cl-empty { padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: 14px; }
.cl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
  box-sizing: border-box;
}
.cl-row:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.cl-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cl-row-active {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.cl-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.cl-avatar-img { object-fit: cover; }
.cl-row-info { flex: 1 1 auto; min-width: 0; }
.cl-row-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.cl-row-name {
  min-width: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cl-row-tag,
.cl-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
}
.cl-row-tag {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.cl-badge {
  text-transform: uppercase;
  letter-spacing: 0;
}
.cl-badge-flagged { background: var(--yellow-bg); color: var(--yellow); }
.cl-badge-pinned { background: var(--green-bg); color: var(--green); }
.cl-row-bottom {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}
.cl-row-time,
.cl-row-sep,
.cl-row-note {
  font-size: 12px;
  color: var(--text-muted);
}
.cl-row-time { flex: 0 0 auto; font-family: var(--font-mono); }
.cl-row-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cl-row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.cl-row:hover .cl-row-actions,
.cl-row:focus-within .cl-row-actions {
  opacity: 1;
}
.cl-row-edit,
.cl-row-menu-btn {
  width: 32px;
  height: 32px;
}
.cl-row-menu {
  position: absolute;
}
.cl-archived-section { margin-top: 4px; }
.cl-archived-header {
  padding: 10px 12px;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.cl-archived-header::-webkit-details-marker { display: none; }
.cl-archived-header::before { content: '\25B8 '; }
details[open] > .cl-archived-header::before { content: '\25BE '; }
/* Client form */
.cl-form {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cl-form-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 14px;
  padding: 16px 20px;
}
.cl-form-section {
  display: grid;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.cl-form-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.cl-section-title {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.cl-avatar-row { display: flex; align-items: center; gap: 12px; }
.cl-avatar-picker {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}
.cl-avatar-picker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.cl-avatar-picker:hover .cl-avatar-edit-icon,
.cl-avatar-picker:focus-visible .cl-avatar-edit-icon {
  opacity: 1;
}
.cl-avatar-preview-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.cl-avatar-preview-initial {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}
.cl-avatar-edit-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 50%;
}
.cl-avatar-remove {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.cl-avatar-remove:hover { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.cl-form-row {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin: 0;
}
.cl-form-row-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cl-form-col { min-width: 0; }
.cl-form-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.cl-label-detail {
  font-weight: 500;
  color: var(--text-muted);
}
.cl-required { color: var(--red); }
.cl-form-input,
.cl-form-textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}
.cl-form-input:focus,
.cl-form-textarea:focus,
.cl-tags-wrap:focus-within {
  border-color: var(--accent);
}
.cl-form-date { max-width: 190px; }
.cl-sex-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.cl-lat-display,
.cl-health-note,
.cl-hg-coupling {
  color: var(--text-muted);
  font-size: 11px;
}
.cl-health-link {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cl-health-link:hover { color: var(--accent); }
.cl-bmi-display {
  min-height: 38px;
  display: flex;
  align-items: center;
}
.cl-haplogroup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cl-haplogroup-select { max-width: 170px; }
.cl-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: text;
}
.cl-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 6px 2px 9px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
}
.cl-tag-remove {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.cl-tag-remove svg {
  width: 12px;
  height: 12px;
}
.cl-tag-remove:hover { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.cl-tag-input {
  min-width: 100px;
  flex: 1;
  border: 0;
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.cl-form-textarea {
  min-height: 92px;
  resize: vertical;
}
.cl-status-radios { display: flex; gap: 12px; flex-wrap: wrap; }
.cl-radio {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.cl-radio input { accent-color: var(--accent); }
.cl-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-secondary) 94%, var(--bg-card));
  flex-shrink: 0;
}
.cl-form-cancel,
.cl-form-save {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.cl-form-cancel {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
}
.cl-form-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }
.cl-form-save {
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
}
.cl-form-save:hover { opacity: 0.9; }
@media (min-width: 1400px) {
  .modal.client-list-modal { width: min(92vw, 860px); max-width: 860px; }
}
@media (max-width: 768px) {
  .modal.client-list-modal { max-height: 92vh; }
  .cl-header { padding: 12px 16px; }
  .cl-toolbar { grid-template-columns: 1fr; padding: 10px 16px; }
  .cl-filter-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-tag-filters { padding: 0 16px 8px; }
  .cl-list { padding: 8px 10px 12px; }
  .cl-row-actions { opacity: 1; }
  .cl-form-body { padding: 14px 16px; }
  .cl-form-actions { padding: 12px 16px; }
}
@media (max-width: 480px) {
  #client-list-overlay.modal-overlay.show {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }
  .modal.client-list-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .cl-header {
    min-height: 58px;
    padding: 10px 12px;
    gap: 10px;
  }
  .cl-title { font-size: 17px; }
  .cl-count { font-size: 10px; }
  .cl-header-right { gap: 6px; }
  .cl-new-btn {
    width: 36px;
    min-width: 36px;
    padding: 0;
  }
  .cl-new-btn span { display: none; }
  .cl-tools-menu { right: -42px; }
  .cl-tag-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
  }
  .cl-tag-chip { flex: 0 0 auto; }
  .cl-row {
    min-height: 70px;
    gap: 10px;
    padding: 10px;
  }
  .cl-row-edit { display: none; }
  .cl-row-name { max-width: 100%; }
  .cl-row-tag,
  .cl-badge { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cl-form-row-split { grid-template-columns: 1fr; }
  .cl-form-date,
  .cl-haplogroup-select { max-width: none; }
  .cl-haplogroup-row { align-items: stretch; flex-direction: column; }
  .cl-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
@media (pointer: coarse) {
  .cl-row-actions { opacity: 1; }
  .cl-row-edit,
  .cl-row-menu-btn,
  .cl-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .cl-new-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .cl-row-edit,
  .cl-row-menu-btn {
    width: 44px;
    height: 44px;
  }
  .cl-menu-item,
  .cl-tools-item {
    min-height: 44px;
  }
}
