/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0d0d10;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: #e91e63; }

/* ── Unlock Screen ────────────────────────────────────────────────────────── */
#unlock-box {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.unlock-icon {
  width: 52px; height: 52px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: #e91e63;
}

#unlock-box h2 { font-size: 1.2rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
#unlock-box > p { color: #aaa; font-size: .8rem; margin-bottom: 20px; }

.unlock-hint { color: #888; font-size: .78rem; margin-bottom: 12px; text-align: left; }

.unlock-input {
  width: 100%;
  padding: 10px 12px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  color: #fff;
  margin-bottom: 10px;
  outline: none;
  transition: border-color .15s;
}
.unlock-input:focus { border-color: #e91e63; }
.unlock-input::placeholder { color: #555; }

.unlock-error {
  color: #ef4444;
  font-size: .8rem;
  margin-bottom: 10px;
  text-align: left;
}

.unlock-btn {
  width: 100%;
  padding: 11px;
  background: #e91e63;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: .95rem;
  transition: background .15s;
}
.unlock-btn:hover { background: #c2185b; }

.unlock-spinner {
  width: 24px; height: 24px;
  border: 2px solid #333;
  border-top-color: #e91e63;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#unlock-loading { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; }
#unlock-loading span { color: #aaa; font-size: .82rem; }

/* ── Header ───────────────────────────────────────────────────────────────── */
#crm-header {
  position: sticky; top: 0; z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  background: #0d0d10;
  border-bottom: 1px solid #2a2a35;
}

/* Tabs — left side, auto-sized */
.header-center {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

/* View dropdown — always visible */
#view-select {
  display: inline-flex;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  color: #fff;
  padding: 6px 28px 6px 10px;
  font-size: .82rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
#view-select option { background: #1c1c22; }

.view-btn {
  padding: 6px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  color: #888;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.view-btn:hover { background: #1c1c22; color: #fff; }
.view-btn.active { background: #1c1c22; color: #fff; }

/* Controls — pushed to right via margin-left: auto */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .72rem;
  color: #aaa;
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  background: #e91e63;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 700;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: #c2185b; }
.btn-primary:disabled { background: #555; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px;
  background: none;
  color: #fff;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #1c1c22; border-color: #3a3a45; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: none;
  color: #fff;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  transition: background .15s, border-color .15s;
}
.btn-icon:hover { background: #1c1c22; border-color: #3a3a45; }
.btn-icon.btn-danger:hover { background: rgba(239,68,68,.15); border-color: #ef4444; color: #ef4444; }

.btn-small {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: #1c1c22;
  color: #fff;
  border: 1px solid #2a2a35;
  border-radius: 6px;
  font-size: .76rem;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn-small:hover { background: #242430; border-color: #3a3a45; }
.btn-small.active { background: #e91e63; border-color: #e91e63; color: #fff; }
.btn-small.active:hover { background: #c2185b; border-color: #c2185b; }

.btn-sm {
  padding: 5px 10px;
  font-size: .78rem;
  border-radius: 7px;
}

.g-toggle-label {
  display: flex; align-items: center; gap: 6px;
  color: #aaa; font-size: .8rem; cursor: pointer;
}
.g-toggle-label input { accent-color: #e91e63; }

/* ── Search + Status Filter ───────────────────────────────────────────────── */
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  color: #777;
}
.search-wrap input {
  background: none;
  border: none;
  outline: none;
  color: #fff;
  padding: 6px 0;
  width: 180px;
  font-size: .83rem;
}
.search-wrap input::placeholder { color: #555; }


/* ── Col View Bar ─────────────────────────────────────────────────────────── */
#col-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid #2a2a35;
  background: #0d0d10;
  gap: 10px;
}

#col-view-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.col-view-pill {
  padding: 3px 10px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  color: #aaa;
  font-size: .73rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.col-view-pill:hover { border-color: #3a3a45; color: #fff; }
.col-view-pill.active { border-color: #e91e63; color: #fff; background: rgba(233,30,99,.12); }

.col-view-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* Col-view-bar search (shown on narrow screens) */
.cvb-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  padding: 4px 10px;
}
.cvb-search-wrap svg { color: #888; flex-shrink: 0; }
#cvb-search-input {
  background: none; border: none; outline: none;
  color: #fff; font-size: .85rem; flex: 1; min-width: 0;
}
#cvb-search-input::placeholder { color: #555; }

/* View manager popup */
.view-manager-popup {
  position: fixed;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 6px;
  z-index: 800;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.vm-section { padding: 4px 2px; }
.vm-label { font-size: .7rem; color: #666; padding: 2px 6px 5px; text-transform: uppercase; letter-spacing: .5px; }
.vm-save-row { display: flex; gap: 5px; padding: 0 2px; }
.vm-inp {
  flex: 1; background: #141418; border: 1px solid #2a2a35; border-radius: 6px;
  color: #fff; padding: 5px 8px; font-size: .8rem; outline: none; min-width: 0;
}
.vm-divider { height: 1px; background: #2a2a35; margin: 4px 0; }
.vm-row {
  display: flex; align-items: center; gap: 4px;
  border-radius: 7px; padding: 2px 4px;
  transition: background .1s;
}
.vm-row:hover { background: #242430; }
.vm-row-active { background: rgba(233,30,99,.1); }
.vm-name-btn {
  flex: 1; text-align: left; background: none; border: none;
  color: #ddd; font-size: .82rem; padding: 5px 6px; border-radius: 5px; cursor: pointer;
}
.vm-row-active .vm-name-btn { color: #fff; font-weight: 600; }
.vm-row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.vm-star-btn, .vm-del-btn {
  background: none; border: none; color: #555; font-size: .8rem;
  width: 24px; height: 24px; border-radius: 5px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.vm-star-btn:hover { color: #f59e0b; background: rgba(245,158,11,.1); }
.vm-star-btn.is-default { color: #f59e0b; }
.vm-del-btn:hover { color: #ef4444; background: rgba(239,68,68,.1); }

/* Pill config bar (shown instead of column pills in pill mode) */
#pill-config-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}
.pcfg-label {
  display: flex; align-items: center; gap: 5px;
  font-size: .74rem; color: #888;
}
.pcfg-label select {
  background: #1c1c22; border: 1px solid #2a2a35; border-radius: 6px;
  color: #fff; padding: 3px 8px; font-size: .74rem; outline: none;
}
.pcfg-label select option { background: #1c1c22; }
.pcfg-check { gap: 5px; }
.pcfg-check input[type="checkbox"] { accent-color: #e91e63; }

/* ── Pill Grid ────────────────────────────────────────────────────────────── */
#pill-view-wrap {
  height: calc(100vh - 56px - 36px);
  overflow-y: auto;
  padding: 12px 14px;
}
.pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.pill-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pill-card:hover { background: #1c1c22; border-color: #3a3a45; }
.pill-av {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.pill-av-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pill-av-ini {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; border-radius: 50%;
}
.pill-info { flex: 1; min-width: 0; }
.pill-title {
  font-size: .88rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill-sub {
  font-size: .74rem; color: #888; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
#contact-table-wrap {
  overflow-x: auto;
  height: calc(100vh - 56px - 36px); /* header + colbar */
  position: relative;
}

/* sticky header row */
.ct-header-resizable {
  display: flex;
  position: sticky; top: 0; z-index: 10;
  background: #141418;
  border-bottom: 2px solid #2a2a35;
  user-select: none;
}
.ct-header-resizable::after {
  content: '';
  flex: 1;
  min-width: 0;
  background: #141418;
}

.cth-cell {
  position: relative;
  display: flex; align-items: center;
  padding: 0 10px;
  height: 36px;
  font-size: .72rem;
  font-weight: 700;
  color: #aaa;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
  touch-action: none;
  cursor: pointer;
}
.cth-cell:hover { color: #fff; }
.cth-label { display: flex; align-items: center; gap: 3px; pointer-events: none; }
.col-sort-arrow { font-size: .7rem; color: #e91e63; }
.col-filter-icon { color: #e91e63; flex-shrink: 0; }

/* ── Column filter popup ───────────────────────────────────────────────────── */
.col-filter-popup {
  position: fixed;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 8px;
  z-index: 600;
  width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,.55);
}
.cfp-sort-row { display: flex; gap: 5px; margin-bottom: 8px; }
.cfp-sort-btn {
  flex: 1; padding: 6px 0;
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 6px;
  color: #aaa; font-size: .78rem;
  cursor: pointer; transition: all .15s;
}
.cfp-sort-btn:hover { border-color: #3a3a45; color: #fff; }
.cfp-sort-btn.active { background: rgba(233,30,99,.15); border-color: #e91e63; color: #e91e63; }
.cfp-search-row {
  display: flex; align-items: center; gap: 6px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 6px 8px;
  transition: border-color .15s;
}
.cfp-search-row:focus-within { border-color: #e91e63; }
#cfp-input {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-size: .84rem; min-width: 0;
}
.cfp-clear-btn {
  background: none; border: none; color: #555;
  cursor: pointer; font-size: .75rem; padding: 0 2px;
  transition: color .15s; white-space: nowrap;
}
.cfp-clear-btn:hover { color: #ef4444; }

.cfp-all-none-row {
  display: flex; align-items: center; gap: 2px;
  padding: 5px 0 6px; border-bottom: 1px solid #1e1e28;
  margin-bottom: 2px;
}
.cfp-sel-all, .cfp-sel-none {
  background: none; border: none; color: #666;
  font-size: .72rem; cursor: pointer; padding: 2px 5px;
  border-radius: 4px; transition: color .12s, background .12s;
}
.cfp-sel-all:hover, .cfp-sel-none:hover { color: #e91e63; background: rgba(233,30,99,.08); }
.cfp-all-none-row .cfp-clear-btn { margin-left: auto; }

.cfp-value-list {
  max-height: 220px; overflow-y: auto;
  margin: 0 -8px; padding: 0 4px;
}
.cfp-val-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 5px; cursor: pointer;
  transition: background .1s;
}
.cfp-val-row:hover { background: #1a1a24; }
.cfp-val-row input[type="checkbox"] {
  flex-shrink: 0; width: 14px; height: 14px;
  accent-color: #e91e63; cursor: pointer;
}
.cfp-val-text {
  font-size: .8rem; color: #ccc;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}

.col-resize-handle {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 10px;
  cursor: col-resize;
  background: transparent;
  transition: background .15s;
  touch-action: none;
  z-index: 2;
}
.col-resize-handle:hover,
.col-resize-handle.dragging { background: #e91e63; }

/* body rows */
.ct-row {
  display: flex;
  align-items: stretch;
  cursor: pointer;
  transition: background .1s;
  min-height: 38px;
  background: var(--row-tint, transparent);
}
.ct-row:hover { background: var(--row-tint-hover, #141418); }
.ct-row.fill-highlight { background: rgba(59,130,246,.12) !important; }
.ct-row::after {
  content: '';
  flex: 1;
  min-width: 0;
  background: #1c1c22;
}
.ct-row:hover::after, .ct-row.fill-highlight::after { background: #1c1c22; }

.ct-cell {
  display: flex; align-items: center;
  padding: 0 10px;
  font-size: .83rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  min-height: 38px;
  border-right: 1px solid #1e1e26;
  border-bottom: 1px solid #1e1e26;
  position: relative;
}

.ct-name-val { font-weight: 600; }
.ct-date-val { color: #aaa; font-size: .78rem; }
.ct-status-empty { color: #444; }

.ct-cell[data-col="tags"] { white-space: normal; align-items: flex-start; padding-top: 7px; padding-bottom: 7px; }

.ct-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-content: flex-start;
  overflow: hidden;
  max-height: 46px;
}

.ct-tag {
  display: inline-block;
  padding: 1px 6px;
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 4px;
  font-size: .69rem;
  color: #bbb;
  white-space: nowrap;
}

.ct-tag-more {
  display: inline-block;
  padding: 1px 6px;
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 4px;
  font-size: .69rem;
  color: #666;
  cursor: pointer;
  vertical-align: middle;
}
.ct-tag-more:hover { color: #bbb; border-color: #444; }

.tag-overflow-popup {
  position: fixed;
  z-index: 700;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}

.ct-photo-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  margin-right: 2px;
  flex-shrink: 0;
}
.ct-photo-more {
  font-size: .72rem;
  color: #888;
  margin-left: 2px;
}

/* Cell edit input */
.cell-input {
  width: 100%; height: 100%;
  background: #1c1c22;
  border: 1.5px solid #e91e63;
  border-radius: 4px;
  color: #fff;
  padding: 2px 6px;
  outline: none;
  font-size: .83rem;
  position: absolute; inset: 0;
}

.fill-handle {
  position: absolute; right: 0; bottom: 0;
  width: 8px; height: 8px;
  background: #e91e63;
  border-radius: 2px 0 2px 0;
  cursor: ns-resize;
  z-index: 5;
}

/* ── Status Dots & Badges ─────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-aktiv, .status-badge.status-aktiv   { background: #22c55e; color: #0d0d10; }
.status-dot.status-lead, .status-badge.status-lead     { background: #3b82f6; color: #fff; }
.status-dot.status-pausiert, .status-badge.status-pausiert { background: #f59e0b; color: #0d0d10; }
.status-dot.status-inaktiv, .status-badge.status-inaktiv  { background: #555; color: #fff; }
.status-dot.status-none  { background: #333; }

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.status-badge.status-none { background: #222; color: #777; }

#status-dropdown {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 4px;
  z-index: 200;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.status-opt {
  display: block; width: 100%;
  padding: 7px 12px;
  text-align: left;
  background: none;
  border: none;
  color: #fff;
  font-size: .82rem;
  border-radius: 7px;
  transition: background .1s;
}
.status-opt:hover { background: #2a2a35; }

/* ── Modal Overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.7);
}
.modal-box-xl { max-width: 680px; }
.modal-box-sm { max-width: 420px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a35;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: #fff; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid #2a2a35;
  flex-shrink: 0;
}

.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: none;
  border: none;
  color: #888;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: #fff; background: #242430; }

/* ── Detail Modal Header ──────────────────────────────────────────────────── */
.detail-modal-header {
  align-items: flex-start;
  gap: 12px;
  flex-direction: column;
  padding: 0;
  border-bottom: none;
}

/* override for detail: header = full-width gradient top area */
#contact-detail-modal .modal-header {
  padding: 20px 20px 16px;
  background: linear-gradient(180deg, #1c1c22 0%, #141418 100%);
  border-bottom: 1px solid #2a2a35;
  flex-direction: row;
  align-items: flex-start;
}

.detail-modal-title-area {
  display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0;
}

.dm-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #1c1c22;
  border: 2px solid #2a2a35;
  flex-shrink: 0;
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}
.dm-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.detail-modal-name-wrap { min-width: 0; flex: 1; }
.detail-modal-name-wrap h2 { font-size: 1.1rem; font-weight: 700; color: #fff; }

#detail-meta { color: #fff; font-size: .76rem; margin-top: 3px; }

.dh-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}

#detail-name-edit { overflow: hidden; max-width: 100%; }
#detail-name-edit .inline-field-input { flex: 1; min-width: 0; }

.inline-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: none; border: none;
  color: rgba(255,255,255,.45);
  border-radius: 4px;
  transition: color .15s;
}
.inline-edit-btn:hover { color: #fff; }

.inline-field-input {
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 7px;
  color: #fff;
  padding: 6px 10px;
  outline: none;
  font-size: .85rem;
  transition: border-color .15s;
}
.inline-field-input:focus { border-color: #e91e63; }
.inline-field-input::placeholder { color: #555; }
.inline-field-input.flex-1 { flex: 1; }

.inline-save-btn {
  padding: 5px 10px;
  background: #e91e63;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: .8rem;
  font-weight: 700;
}
.inline-save-btn:hover { background: #c2185b; }

.inline-cancel-btn {
  padding: 5px 10px;
  background: #242430;
  color: #fff;
  border: 1px solid #2a2a35;
  border-radius: 7px;
  font-size: .8rem;
}
.inline-cancel-btn:hover { background: #2a2a35; }

/* ── Photos ───────────────────────────────────────────────────────────────── */
#photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.photo-thumb {
  width: auto;
  max-width: 200px;
  height: auto;
  border-radius: 8px;
  border: 1px solid #2a2a35;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.photo-thumb img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.photo-add-btn {
  width: 80px; height: 80px;
  border-radius: 8px;
  background: #1c1c22;
  border: 1.5px dashed #2a2a35;
  color: rgba(255,255,255,.5);
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.photo-add-btn:hover { border-color: #e91e63; color: #e91e63; }

#photo-grid.photo-drop-active {
  outline: 2px dashed #e91e63;
  outline-offset: 4px;
  border-radius: 10px;
  background: rgba(233, 30, 99, .06);
}
#photo-grid.photo-drop-active .photo-add-btn {
  border-color: #e91e63;
  color: #e91e63;
}

.photo-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,.7);
  border: none; border-radius: 50%;
  color: #fff; font-size: .8rem;
  display: none; align-items: center; justify-content: center;
}
.photo-thumb:hover .photo-del { display: flex; }

/* ── Fields ───────────────────────────────────────────────────────────────── */
.fields-box {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid #2a2a35;
  min-height: 40px;
}
.field-row:last-child { border-bottom: none; }
.field-row:hover { background: #1c1c22; }

.field-icon { color: #fff; flex-shrink: 0; width: 16px; text-align: center; }

.field-val-wrap { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.field-val { color: #fff; font-size: .85rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-val.link { color: #e91e63; text-decoration: none; }
.field-val.link:hover { text-decoration: underline; }
.field-val.field-empty { color: rgba(255,255,255,.28); font-style: italic; }

.field-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: none; border: none;
  color: rgba(255,255,255,.35); border-radius: 4px;
  transition: color .15s;
  flex-shrink: 0;
}
.field-edit-btn:hover { color: #fff; }

/* Empty fields: compact horizontal pills below the filled fields-box */
.empty-fields-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 2px 2px;
}

.empty-field-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: none;
  border: 1px dashed #2a2a35;
  border-radius: 20px;
  color: rgba(255,255,255,.5);
  font-size: .75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.empty-field-pill:hover {
  border-color: #e91e63;
  border-style: solid;
  color: #fff;
  background: rgba(233,30,99,.08);
}

/* ── Section Labels ───────────────────────────────────────────────────────── */
.section-label {
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.section-title-row .section-label { margin-bottom: 0; }

/* ── Tags ─────────────────────────────────────────────────────────────────── */
#detail-tags-section { margin-bottom: 16px; }

.tag-pill-wrap { display: flex; flex-wrap: wrap; gap: 5px; }

.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .76rem;
  color: #fff;
}

.tag-del {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: rgba(255,255,255,.6); font-size: .85rem;
  padding: 0 2px;
  transition: color .15s;
}
.tag-del:hover { color: #ef4444; }

.tag-add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: none;
  border: 1.5px dashed #2a2a35;
  border-radius: 20px;
  color: rgba(255,255,255,.6); font-size: .76rem;
  transition: border-color .15s, color .15s;
}
.tag-add-btn:hover { border-color: #e91e63; color: #fff; }

.tag-color-btn {
  background: none; border: none; padding: 0;
  color: inherit; cursor: pointer; font-size: inherit;
  transition: opacity .15s;
}
.tag-color-btn:hover { opacity: 0.75; }

/* ── Tag suggest dropdown ──────────────────────────────────────────────────── */
.tag-suggest-popup {
  position: fixed;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 4px;
  z-index: 1300;
  min-width: 140px;
  max-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 2px;
}
.tag-suggest-item {
  padding: 6px 10px;
  border-radius: 5px;
  font-size: .82rem;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s, color .1s;
}
.tag-suggest-item:hover,
.tag-suggest-item.active { background: rgba(233,30,99,.18); color: #fff; }

/* ── Tag picker (add-tag dropdown) ──────────────────────────────────────────── */
.tag-picker-popup {
  margin-top: 8px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.tag-picker-input {
  background: #12121a;
  border: 1px solid #2a2a35;
  border-radius: 6px;
  padding: 7px 10px;
  color: #fff;
  font-size: .82rem;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.tag-picker-input:focus { border-color: #e91e63; }

.tag-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 130px;
  overflow-y: auto;
}

.tag-picker-chip {
  display: inline-block;
  padding: 3px 10px;
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .76rem;
  color: #fff;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  user-select: none;
}
.tag-picker-chip:hover { border-color: #e91e63; color: #fff; }
.tag-picker-chip.active {
  background: rgba(233,30,99,.15);
  border-color: rgba(233,30,99,.5);
  color: #e91e63;
}

/* ── Tag color picker popup ────────────────────────────────────────────────── */
.tag-color-popup {
  position: fixed;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 8px;
  z-index: 1200;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  max-width: 218px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.tcp-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  flex-shrink: 0;
}
.tcp-swatch:hover { transform: scale(1.25); }
.tcp-swatch.tcp-active { box-shadow: 0 0 0 2px #fff; }
.tcp-none {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid #444;
  background: none;
  color: #fff;
  cursor: pointer;
  font-size: .72rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.tcp-none:hover { border-color: #fff; color: #fff; }
.tcp-none.tcp-active { border-color: #e91e63; color: #e91e63; }

.tag-chip {
  padding: 3px 9px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .73rem;
  color: #fff;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.tag-chip:hover, .tag-chip.active { border-color: #e91e63; color: #fff; }

/* ── Notes ────────────────────────────────────────────────────────────────── */
#detail-notes-section { margin-bottom: 20px; }

.notes-text {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: .85rem;
  white-space: pre-wrap;
  line-height: 1.6;
  cursor: pointer;
  min-height: 48px;
  transition: border-color .15s;
}
.notes-text:hover { border-color: #3a3a45; }
.notes-text.empty { color: rgba(255,255,255,.28); font-style: italic; }

/* ── Relationships ────────────────────────────────────────────────────────── */
#detail-rels-section { margin-bottom: 20px; }

.rel-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #2a2a35;
}
.rel-entry:last-child { border-bottom: none; }

.rel-icon { color: #fff; font-size: .9rem; flex-shrink: 0; }

.rel-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.rel-av-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rel-av-ini {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}

.rel-other {
  font-size: .84rem; color: #fff; font-weight: 600;
  cursor: pointer; transition: color .15s;
}
.rel-other:hover { color: #e91e63; }

.rel-other-btn {
  background: none; border: none; padding: 0;
  font-size: .84rem; color: #fff; font-weight: 600;
  cursor: pointer; transition: color .15s; text-align: left;
}
.rel-other-btn:hover { color: #e91e63; }

.rel-label-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .72rem;
  color: #fff;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.rel-label-pill:hover, .rel-label-pill.rel-label-display:hover { border-color: #3a3a45; color: #fff; }

.rel-edit-wrap {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.rel-edit-btn {
  background: none; border: none; color: rgba(255,255,255,.5);
  font-size: .75rem; padding: 2px 4px; cursor: pointer;
  transition: color .15s;
}
.rel-edit-btn:hover { color: #fff; }

.rel-label-inp, .rel-inv-inp {
  width: 100px;
}

.rel-cancel { background: #2a2a35 !important; }
.rel-save { background: #e91e63 !important; }

.rel-entry > button.act-delete {
  margin-left: auto;
  background: none; border: none; color: #444;
  font-size: .8rem; padding: 3px; cursor: pointer;
  border-radius: 4px; transition: color .15s;
}
.rel-entry > button.act-delete:hover { color: #ef4444; }

/* Rel modal chip row */
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip {
  padding: 4px 10px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .76rem; color: #fff;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.chip:hover, .chip.active { border-color: #e91e63; color: #fff; background: rgba(233,30,99,.1); }

.type-toggle {
  display: flex; gap: 4px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 3px;
}
.type-btn {
  flex: 1; padding: 5px 10px;
  background: none; border: none; border-radius: 6px;
  color: rgba(255,255,255,.6); font-size: .8rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.type-btn.active { background: #2a2a35; color: #fff; }

.rel-selected-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  font-size: .76rem; color: #fff;
}
.rel-selected-pill button {
  background: none; border: none; color: rgba(255,255,255,.5); font-size: .85rem; cursor: pointer;
  transition: color .15s;
}
.rel-selected-pill button:hover { color: #ef4444; }

.rm-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: rgba(233,30,99,.15);
  border: 1px solid rgba(233,30,99,.3);
  border-radius: 20px;
  font-size: .76rem; color: #e91e63;
}

/* ── Timeline / Activities ────────────────────────────────────────────────── */
#timeline-section { margin-bottom: 16px; }

.qa-box {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.qa-box textarea {
  display: block; width: 100%;
  background: none; border: none;
  color: #fff; padding: 12px 14px;
  font-size: .85rem; resize: none; outline: none;
  line-height: 1.5;
}
.qa-box textarea::placeholder { color: #444; }

.qa-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #2a2a35;
  background: #1c1c22;
}
.qa-footer select {
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 7px;
  color: #fff; padding: 4px 8px; outline: none; font-size: .78rem;
}
.qa-footer input[type="date"] {
  background: #242430;
  border: 1px solid #2a2a35;
  border-radius: 7px;
  color: #fff; padding: 4px 8px; outline: none;
  font-size: .78rem; color-scheme: dark;
}

.timeline-group { margin-bottom: 12px; }
.timeline-date {
  font-size: .71rem; font-weight: 700; color: #fff;
  letter-spacing: .05em; text-transform: uppercase;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a2a35;
}

.timeline-entry {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #1e1e26;
}
.timeline-entry:last-child { border-bottom: none; }

.tl-icon { color: #fff; flex-shrink: 0; padding-top: 2px; font-size: .85rem; }
.tl-body { flex: 1; min-width: 0; }
.tl-type { font-size: .7rem; color: #fff; font-weight: 600; text-transform: uppercase; margin-bottom: 2px; }
.tl-text { font-size: .84rem; color: #fff; white-space: pre-wrap; line-height: 1.5; }

.act-delete {
  background: none; border: none; color: #444;
  font-size: .8rem; padding: 3px; cursor: pointer;
  border-radius: 4px; transition: color .15s;
  flex-shrink: 0;
}
.act-delete:hover { color: #ef4444; }
.cf-del { font-size: .75rem; }

/* ── TR Profile ───────────────────────────────────────────────────────────── */
.tr-profile-linked {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 10px;
}
.tr-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #2a2a35;
}
.tr-avatar-placeholder {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; color: rgba(255,255,255,.6);
}
.tr-name { font-size: .85rem; color: #fff; font-weight: 600; flex: 1; }

.tr-unlink-btn {
  font-size: .72rem;
}

.search-results {
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 4px;
}

.sr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid #2a2a35;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: #242430; }

.sr-avatar {
  width: 28px; height: 28px;
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.sr-avatar-ph {
  width: 28px; height: 28px;
  border-radius: 50%; background: #2a2a35;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; color: #fff; flex-shrink: 0;
}
.sr-sub { color: #fff; font-size: .75rem; }
.sr-empty { padding: 12px; text-align: center; color: rgba(255,255,255,.5); font-size: .82rem; }

/* ── Birthday View ────────────────────────────────────────────────────────── */
.bd-group { margin-bottom: 28px; }

.bd-group-title {
  font-size: .72rem; font-weight: 700; color: #fff;
  letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #2a2a35;
}

.bd-entry {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #2a2a35;
  cursor: pointer;
}
.bd-entry:last-child { border-bottom: none; }
.bd-entry:hover .bd-info p { color: #e91e63; }

.bd-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.bd-avatar img { width: 100%; height: 100%; object-fit: cover; }

.bd-info { flex: 1; min-width: 0; }
.bd-info p { font-size: .87rem; font-weight: 600; color: #fff; transition: color .15s; }
.bd-info span { font-size: .75rem; color: #fff; }

.bd-days {
  font-size: .78rem; font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.bd-days.today { background: rgba(233,30,99,.2); border-color: #e91e63; color: #fff; }
.bd-days.soon  { background: rgba(245,158,11,.15); border-color: #f59e0b; color: #f59e0b; }

.btn-wa {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: #128c7e;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: .76rem;
  font-weight: 700;
  transition: background .15s;
  flex-shrink: 0;
}
.btn-wa:hover { background: #0d7066; }

.bd-open-btn { margin-right: 4px; }

/* WA Picker popup */
.wa-picker-popup {
  position: absolute;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 10px;
  z-index: 600;
  min-width: 220px;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
}
.wa-picker-title {
  font-size: .72rem; font-weight: 700; color: #fff;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 6px 8px;
  border-bottom: 1px solid #2a2a35;
  margin-bottom: 6px;
}
.wa-tmpl-btn {
  display: block; width: 100%;
  padding: 8px 10px;
  background: none;
  border: none; border-radius: 7px;
  color: #fff; font-size: .82rem;
  text-align: left;
  cursor: pointer;
  transition: background .1s;
}
.wa-tmpl-btn:hover { background: #242430; }
.wa-tmpl-btn.wa-tmpl-default { color: #128c7e; }

/* ── Graph View ───────────────────────────────────────────────────────────── */
#graph-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 56px);
  background: #080810;
}
#graph-svg {
  width: 100%; height: 100%;
  display: block;
}

#graph-info {
  position: absolute; top: 14px; right: 14px;
  width: 220px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 14px;
  z-index: 10;
}

.graph-info-close-btn {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: #888;
  cursor: pointer; border-radius: 4px;
  transition: color .15s;
}
.graph-info-close-btn:hover { color: #fff; }

.gi-name { font-size: .95rem; font-weight: 700; color: #fff; margin-bottom: 4px; }
.gi-meta { font-size: .76rem; color: #888; margin-bottom: 8px; }
.gi-rels-title { font-size: .7rem; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.gi-rel { font-size: .78rem; color: #aaa; padding: 2px 0; }
.gi-empty { color: #555; font-size: .8rem; padding: 8px 0; }
.gi-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 1px solid #2a2a35; margin-bottom: 8px;
}
.gi-event-icon { font-size: 1.2rem; margin-bottom: 6px; }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  border-bottom: 1px solid #2a2a35;
  padding: 0 20px;
  background: #0d0d10;
  gap: 2px;
  flex-shrink: 0;
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
  border: none;
  background: none;
  color: #555;
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.settings-tab:hover { color: #aaa; }
.settings-tab.active { color: #fff; border-bottom-color: #e91e63; }
.settings-tab svg { flex-shrink: 0; }

.settings-section {
  padding: 0 0 24px;
  border-bottom: none;
  margin-bottom: 4px;
}
.settings-section:last-child { padding-bottom: 8px; }

.settings-title {
  font-size: .68rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 -20px 16px;
  padding: 8px 20px;
  background: #0a0a0d;
  border-top: 1px solid #1e1e28;
  border-bottom: 1px solid #1e1e28;
}
.settings-section:first-child .settings-title {
  margin-top: -20px;
  border-top: none;
}

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: .76rem; font-weight: 600; color: #aaa;
  margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 9px 12px;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  color: #fff; outline: none;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus { border-color: #e91e63; }
.form-group input::placeholder { color: #555; }

/* Custom fields list */
.cf-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #2a2a35;
}
.cf-row:last-child { border-bottom: none; }
.cf-icon { font-size: 1rem; }
.cf-lbl { flex: 1; font-size: .84rem; color: #fff; }
.cf-type-lbl { font-size: .72rem; color: #777; }

.cf-form-row {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 6px;
}
.cf-input {
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 7px;
  color: #fff; padding: 7px 10px; outline: none;
  font-size: .82rem; transition: border-color .15s;
}
.cf-input:focus { border-color: #e91e63; }
.cf-input::placeholder { color: #555; }


/* ── Col Header Drag-to-Reorder ───────────────────────────────────────────── */
.col-drag-active { user-select: none; cursor: grabbing !important; }
.col-drag-active * { cursor: grabbing !important; }

.cth-cell.col-dragging {
  opacity: .35;
  background: rgba(233,30,99,.08);
}

.cth-cell.col-drop-target {
  background: rgba(233,30,99,.18);
  border-left: 2px solid #e91e63;
}

.col-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 900;
  padding: 6px 14px;
  background: #e91e63;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  border-radius: 20px;
  box-shadow: 0 6px 20px rgba(233,30,99,.5);
  white-space: nowrap;
  transform: rotate(-2deg);
  transition: background .15s, transform .15s;
}
.col-drag-ghost.ghost-delete {
  background: #ef4444;
  transform: rotate(0deg) scale(1.05);
  box-shadow: 0 6px 24px rgba(239,68,68,.6);
}

/* Delete zone at top of screen (shown during col drag) */
.col-delete-zone {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(239,68,68,.1);
  border-bottom: 2px solid rgba(239,68,68,.35);
  z-index: 890;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  color: rgba(239,68,68,.6);
  font-size: .85rem;
  font-weight: 700;
  pointer-events: none;
  transition: background .15s, border-color .15s, color .15s;
}
.col-delete-zone.active {
  background: rgba(239,68,68,.22);
  border-bottom-color: #ef4444;
  color: #ef4444;
}

/* "+" insert buttons on column dividers */
.cth-insert-btn {
  position: absolute;
  top: -9px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #e91e63;
  border: 2px solid #0d0d10;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.ct-header-resizable:hover .cth-insert-btn {
  opacity: 1;
  pointer-events: auto;
}
.cth-insert-btn:hover {
  transform: scale(1.2);
}

/* ── Col Picker Popup ─────────────────────────────────────────────────────── */
.col-picker-popup {
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 10px;
  z-index: 600;
  min-width: 210px;
  max-width: 260px;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
}
.col-picker-title {
  font-size: .7rem; font-weight: 700; color: #666;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 4px 8px;
  border-bottom: 1px solid #2a2a35;
  margin-bottom: 6px;
}

/* Picker rows (sortable) */
#cpl-list { display: flex; flex-direction: column; }

.cpl-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 4px;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: background .1s;
  cursor: grab;
}
.cpl-row:hover { background: #1c1c22; }
.cpl-row.cpl-dragging { opacity: .4; border-style: dashed; border-color: #2a2a35; }

.cpl-handle {
  color: #444; font-size: 1rem; cursor: grab; flex-shrink: 0;
  user-select: none;
}
.cpl-handle-fixed { cursor: default; color: #2a2a35; }

.cpl-label { flex: 1; font-size: .84rem; color: #fff; }

.cpl-del {
  background: none; border: none; color: #555;
  font-size: .8rem; padding: 2px 5px; cursor: pointer;
  border-radius: 4px; transition: color .15s;
  flex-shrink: 0;
}
.cpl-del:hover { color: #ef4444; }

/* "+" insert button between rows */
.cpl-insert-btn {
  display: block; width: 28px; height: 18px;
  margin: 1px auto;
  background: none;
  border: 1px dashed #2a2a35;
  border-radius: 20px;
  color: #444; font-size: .7rem; line-height: 1;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  text-align: center;
}
.cpl-insert-btn:hover { border-color: #e91e63; color: #e91e63; }

/* Insert submenu */
.cpl-ins-menu {
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 28px rgba(0,0,0,.7);
}
.cpl-ins-item {
  display: block; width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: none; border: none;
  color: rgba(255,255,255,.6); font-size: .83rem;
  border-radius: 7px; cursor: pointer;
  transition: background .1s, color .1s;
}
.cpl-ins-item:hover { background: #2a2a35; color: #fff; }

/* ── Empty / Loading States ───────────────────────────────────────────────── */
.list-empty {
  padding: 60px 20px;
  text-align: center;
  color: #555;
  font-size: .9rem;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
#lightbox {
  display: flex;
}
#lightbox-close {
  font-size: 1.5rem;
}

/* ── Workshop chips (detail view) ──────────────────────────────────────────── */
.ws-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 5px;
  font-size: .75rem; color: #999;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Import modal ──────────────────────────────────────────────────────────── */
.imp-steps { display: flex; align-items: center; gap: 0; }
.imp-step {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
  background: #2a2a35; color: #555; border: 1.5px solid #3a3a45;
  transition: all .2s; flex-shrink: 0;
}
.imp-step.active { background: #e91e63; color: #fff; border-color: #e91e63; }
.imp-step.done   { background: #22c55e22; color: #22c55e; border-color: #22c55e55; }
.imp-step-line   { flex: 1; height: 1.5px; background: #2a2a35; min-width: 16px; max-width: 32px; }

.imp-hint { font-size: .78rem; color: #666; margin-bottom: 12px; }

.imp-drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 28px 16px;
  border: 1.5px dashed #2a2a35; border-radius: 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
  text-align: center;
}
.imp-drop-zone:hover,
.imp-drop-zone.drag-over { border-color: #e91e63; background: rgba(233,30,99,.04); }
.imp-drop-zone.loading   { opacity: .6; pointer-events: none; }
.imp-drop-label { font-size: .9rem; color: #ccc; }
.imp-drop-sub   { font-size: .76rem; color: #555; }

.imp-as-details { margin-top: 14px; }
.imp-as-details summary {
  font-size: .8rem; color: #777; cursor: pointer;
  padding: 4px 0; user-select: none;
}
.imp-as-details summary:hover { color: #aaa; }
.imp-as-pre {
  background: #0d0d10; border: 1px solid #2a2a35; border-radius: 8px;
  padding: 12px 40px 12px 12px; font-size: .7rem; color: #aaa;
  white-space: pre; overflow-x: auto; line-height: 1.5;
  max-height: 200px; overflow-y: auto;
  font-family: 'Fira Mono', 'Cascadia Code', monospace;
}

.imp-stats {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px;
}
.imp-stat {
  flex: 1; min-width: 70px;
  background: #141418; border: 1px solid #2a2a35; border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.imp-stat-n { font-size: 1.3rem; font-weight: 700; color: #fff; line-height: 1; }
.imp-stat span:last-child { font-size: .7rem; color: #666; text-align: center; }
.imp-warn { font-size: .78rem; color: #f59e0b; margin-top: 10px; padding: 8px 10px; background: rgba(245,158,11,.08); border-radius: 6px; border: 1px solid rgba(245,158,11,.2); }

.imp-preview-table {
  border-collapse: collapse; font-size: .75rem; width: 100%;
}
.imp-preview-table th {
  padding: 6px 8px; text-align: left;
  background: #141418; color: #999;
  border-bottom: 1px solid #2a2a35; white-space: nowrap;
}
.imp-preview-table td {
  padding: 5px 8px; color: #ccc;
  border-bottom: 1px solid #1a1a22; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.imp-col-type { display: block; font-size: .65rem; color: #e91e63; margin-top: 1px; }
.imp-empty { color: #333; }

.imp-progress-bar {
  height: 6px; background: #1c1c22; border-radius: 3px; overflow: hidden;
}
#imp-progress-fill {
  height: 100%; background: #e91e63; border-radius: 3px;
  transition: width .3s ease;
}

.import-batch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid #1a1a22; gap: 8px;
}
.import-batch-row:last-child { border-bottom: none; }
.import-batch-date { font-size: .82rem; color: #ccc; }
.import-batch-count { font-size: .76rem; color: #666; margin-left: 6px; }

/* ── Responsive Header ─────────────────────────────────────────────────────── */

/* Always-circle add button */
#add-contact-btn { width: 32px; height: 32px; padding: 0; justify-content: center; gap: 0; border-radius: 50%; }

@media (max-width: 660px) {
  #crm-header {
    padding: 0 12px;
    gap: 8px;
    overflow: visible; /* iOS Safari: sticky + overflow:hidden breaks hit-testing */
  }
  .header-right { gap: 6px; }
  .count-badge { display: none; }
  .search-wrap { display: none; }
  #cvb-search-wrap { display: flex !important; }

  /* ── Tabelle: Einzeiliger Header 56px + col-bar 36px ── */
  #contact-table-wrap {
    height: calc(100vh - 56px - 36px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Größere Touch-Targets */
  .ct-row { min-height: 44px; }
  .ct-cell { min-height: 44px; font-size: .85rem; }
  .cth-cell { height: 38px; }

  /* ── Col-view-bar ── */
  #col-view-bar { padding: 0 10px; height: 36px; }
  #col-view-pills { display: none; } /* Nur Aktions-Buttons auf Mobile */

  /* ── Alle Modals: Bottom Sheet ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
  }
  /* Pull-Bar-Indikator */
  .modal-box::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #3a3a45;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
  .modal-header { padding: 12px 16px; }
  .modal-body { padding: 14px 16px; }

  /* ── Detail-Modal Header ── */
  #contact-detail-modal .modal-header { padding: 14px 14px 12px; }
  .detail-modal-title-area { gap: 10px; }
  .dm-avatar { width: 42px; height: 42px; font-size: 1.1rem; }
  .detail-modal-name-wrap h2 { font-size: 1rem; }
  .dh-actions { gap: 5px; }

  /* ── Fotos: kleinere Thumbs ── */
  .photo-thumb { max-width: 140px; }
  .photo-add-btn { width: 68px; height: 68px; }

  /* ── Felder: iOS verhindert Zoom bei font-size ≥ 16px ── */
  input, select, textarea,
  .inline-field-input, .unlock-input, .cf-input,
  .form-group input, .form-group select { font-size: 16px !important; }

  /* ── QA-Footer: umbrechen ── */
  .qa-footer { flex-wrap: wrap; }
  .qa-footer select { flex: 1; min-width: 0; }
  .qa-footer input[type="date"] { flex: 1; min-width: 0; }

  /* ── Rel-Edit-Wrap: vertikal stapeln ── */
  .rel-edit-wrap { flex-direction: column; align-items: flex-start; gap: 6px; }
  .rel-label-inp, .rel-inv-inp { width: 100%; }

  /* ── Bulk-Bar ── */

  /* ── Graph-Info-Panel: schmaler ── */
  #graph-info { width: 180px; }

  /* ── Geburtstags-View ── */
  .bd-entry { padding: 10px 0; }
  .bd-info p { font-size: .85rem; }

  /* ── Settings-Modal ── */
  .settings-section { padding: 14px 0; }

  /* ── Col-Picker + Ins-Menü: Bottom Sheet ── */
  .col-picker-popup,
  .cpl-ins-menu {
    position: fixed !important;
    bottom: 0; left: 0; right: 0; top: auto !important;
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 70vh;
    overflow-y: auto;
  }

  /* ── WA-Picker-Popup: Bottom Sheet ── */
  .wa-picker-popup {
    position: fixed !important;
    bottom: 0; left: 0; right: 0; top: auto !important;
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    overflow-y: auto;
  }

}

/* ══════════════════════════════════════════════════════════════════════════════
   ── Quiz ─────────────────────────────────────────────────────────────────── */

#quiz-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 56px);
  padding: 24px 16px 32px;
  overflow: hidden;
}

/* ── Setup ─────────────────────────────────────────────────────────────────── */
.quiz-setup-box {
  width: 100%;
  max-width: 440px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.quiz-setup-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.quiz-setup-sub   { color: #888; font-size: .85rem; }
.quiz-setup-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
}
.quiz-setup-section { display: flex; flex-direction: column; }

.quiz-count-row { display: flex; gap: 8px; }
.quiz-count-btn {
  flex: 1;
  padding: 8px 0;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  color: #888;
  font-size: .85rem;
  font-weight: 600;
  transition: all .15s;
}
.quiz-count-btn.active {
  background: rgba(233,30,99,.12);
  border-color: rgba(233,30,99,.5);
  color: #e91e63;
}

.quiz-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.quiz-filter-chip {
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid #2a2a35;
  background: #1c1c22;
  color: #888;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.quiz-filter-chip.active {
  background: rgba(233,30,99,.12);
  border-color: rgba(233,30,99,.5);
  color: #e91e63;
}

.quiz-toggle-row  { display: flex; align-items: center; justify-content: space-between; }
.quiz-toggle-label { font-size: .85rem; color: #ccc; }

.quiz-switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.quiz-switch input { opacity: 0; width: 0; height: 0; }
.quiz-switch-track {
  position: absolute; inset: 0;
  background: #2a2a35;
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s;
}
.quiz-switch-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #555;
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.quiz-switch input:checked + .quiz-switch-track { background: rgba(233,30,99,.3); }
.quiz-switch input:checked + .quiz-switch-track::before {
  transform: translateX(18px);
  background: #e91e63;
}

.quiz-pool-info { font-size: .78rem; color: #666; text-align: center; min-height: 1.2em; }

/* ── Card Phase ─────────────────────────────────────────────────────────────── */
#quiz-card-phase {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.quiz-top-bar {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-progress-bar {
  width: 100%;
  height: 3px;
  background: #2a2a35;
  border-radius: 2px;
  overflow: hidden;
}
#quiz-progress-fill {
  height: 100%;
  background: #e91e63;
  transition: width .3s ease;
  border-radius: 2px;
}
.quiz-counter {
  font-size: .75rem;
  color: #555;
  text-align: right;
}

.quiz-card-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
}

.quiz-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #1c1c22;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  will-change: transform;
}

.quiz-card-photo {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.quiz-card-initials {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem; font-weight: 700; color: #333;
}

.quiz-card-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 40px 18px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.82) 0%, transparent 100%);
}
.quiz-card-name      { font-size: 1.25rem; font-weight: 700; color: #fff; }
.quiz-card-meta      { font-size: .78rem; color: rgba(255,255,255,.55); margin-top: 2px; }
.quiz-card-tap-hint  { font-size: .78rem; color: rgba(255,255,255,.38); text-align: center; }

.quiz-box-badge {
  position: absolute;
  top: 12px; left: 12px;
  padding: 3px 9px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  font-size: .68rem;
  color: rgba(255,255,255,.5);
  pointer-events: none;
}

.quiz-hint-wrong,
.quiz-hint-right {
  position: absolute;
  top: 16px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s;
}
.quiz-hint-wrong { left: 14px;  background: rgba(239,68,68,.18);  border: 2px solid #ef4444; color: #ef4444; }
.quiz-hint-right { right: 14px; background: rgba(34,197,94,.18);  border: 2px solid #22c55e; color: #22c55e; }

.quiz-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}
.quiz-btn-wrong,
.quiz-btn-right {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.quiz-btn-wrong { background: rgba(239,68,68,.14); color: #ef4444; border: 1px solid rgba(239,68,68,.28); }
.quiz-btn-right { background: rgba(34,197,94,.14); color: #22c55e; border: 1px solid rgba(34,197,94,.28); }
.quiz-btn-wrong:hover { background: rgba(239,68,68,.24); }
.quiz-btn-right:hover { background: rgba(34,197,94,.24); }

/* ── Result ─────────────────────────────────────────────────────────────────── */
.quiz-result-box {
  width: 100%;
  max-width: 440px;
  background: #141418;
  border: 1px solid #2a2a35;
  border-radius: 16px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.quiz-result-score { font-size: 2.8rem; font-weight: 700; }
.quiz-result-msg   { color: #888; font-size: .88rem; }

.quiz-leitner-bars { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.quiz-leitner-row  { display: flex; align-items: center; gap: 8px; }
.quiz-leitner-label { font-size: .72rem; color: #666; width: 36px; text-align: right; flex-shrink: 0; }
.quiz-leitner-bar-bg {
  flex: 1; height: 6px;
  background: #2a2a35; border-radius: 3px; overflow: hidden;
}
.quiz-leitner-bar-fill {
  height: 100%; border-radius: 3px;
  background: #e91e63;
  transition: width .6s ease;
  min-width: 2px;
}
.quiz-leitner-count { font-size: .72rem; color: #555; width: 24px; text-align: left; flex-shrink: 0; }

.quiz-result-btns { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
