/* ======================================================
   Profile modal
   ====================================================== */

/*.profile-modal-card {
  width: min(820px, calc(100vw - 240px));
}

/* Two-pane shell */
.profile-modal-shell {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  align-items: start;
  min-height: 460px;
}

/* ── Sidebar ─────────────────────────────────────────── */
.profile-modal-sidebar {
  padding: 12px 10px;
  border-right: 1px solid var(--border);
  display: grid;
  gap: 8px;
  align-content: start;
  background: color-mix(in srgb, var(--surface-2) 40%, transparent);
}

.profile-modal-avatar {
  position: relative;
  width: 52px; height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-primary) 18%, transparent);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; flex-shrink: 0;
  cursor: pointer;
}
.profile-modal-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.profile-modal-avatar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #fff;
  border-radius: 50%;
}
.profile-modal-avatar:hover .profile-modal-avatar-overlay { opacity: 1; }
.profile-modal-avatar-input { display: none; }

.profile-modal-name  { font-size: 13px; font-weight: 700; margin: 0; word-break: break-word; line-height: 1.3; }
.profile-modal-email { font-size: 11px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.profile-modal-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 1px; }
.profile-modal-chip {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 99px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--text);
}
.profile-modal-chip.is-good { border-color: color-mix(in srgb,var(--color-success) 50%,transparent); background: color-mix(in srgb,var(--color-success) 14%,transparent); color: var(--color-success); }
.profile-modal-chip.is-muted { color: var(--muted); }

/* Stat tiles — perf-spec style */
.profile-modal-stats { display: grid; gap: 4px; }
.profile-modal-stat {
  display: grid; gap: 1px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.profile-modal-stat-label {
  font-size: 9px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.profile-modal-stat-value { font-size: 11px; color: var(--text); overflow-wrap: anywhere; font-weight: 500; }

/* Linked contact block */
.profile-modal-linked {
  padding: 8px; border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
  display: grid; gap: 5px;
}
.profile-modal-linked-title {
  font-size: 9px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.profile-modal-linked-name { font-size: 12px; font-weight: 600; color: var(--text); }
.profile-modal-linked-facts { display: grid; gap: 2px; }
.profile-modal-linked-fact {
  display: grid; grid-template-columns: 50px 1fr;
  gap: 4px; align-items: baseline; font-size: 11px;
}
.profile-modal-linked-fact span { font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* ── Tab nav ─────────────────────────────────────────── */
.profile-modal-main { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

.profile-modal-tabs-nav {
  display: flex; gap: 1px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.profile-modal-tabs-nav::-webkit-scrollbar { display: none; }

.profile-modal-tab-btn {
  padding: 6px 12px;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent; border-bottom: none;
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: transparent; cursor: pointer; white-space: nowrap;
  transition: color .14s, background .14s;
  position: relative; bottom: -1px;
}
.profile-modal-tab-btn:hover { color: var(--text); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.profile-modal-tab-btn.is-active {
  color: var(--text); background: var(--surface);
  border-color: var(--border); border-bottom-color: var(--surface);
}

/* ── Tab panels ──────────────────────────────────────── */
.profile-modal-panels { overflow: hidden; }
.profile-modal-panel {
  display: none;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(var(--app-vh, 1vh) * 100 - 220px);
  min-height: 380px;
}
.profile-modal-panel.is-active { display: grid; gap: 8px; align-content: start; }

/* Reuse contacts form-card pattern */
.profile-modal-panel .contacts-form-card { margin: 0; }

/* ── Actions bar ─────────────────────────────────────── */
.profile-modal-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
 }
.profile-modal-actions .hint { margin-right: auto; font-size: 12px; }

/* ── Country selector ────────────────────────────────── */
.profile-op-country { display: grid; gap: 8px; }
.profile-op-search-row { display: flex; gap: 6px; align-items: center; }
.profile-op-search-wrap { position: relative; flex: 1; }
.profile-op-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  max-height: 200px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 0 0 6px 6px;
  display: none;
}
.profile-op-dropdown.show { display: block; }
.profile-op-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  transition: background .1s;
}
.profile-op-row:hover, .profile-op-row.is-on { background: color-mix(in srgb, var(--color-primary) 10%, transparent); }
.profile-op-row.is-on { font-weight: 600; color: var(--color-primary); }
.profile-op-row.is-disabled { opacity: .4; pointer-events: none; }
.profile-op-row-code { font-size: 10px; font-weight: 700; color: var(--muted); }
.profile-op-chips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 28px; align-items: center; }
.profile-op-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
}
.profile-op-chip button {
  background: none; border: none; padding: 0;
  cursor: pointer; font-size: 12px; line-height: 1;
  color: var(--color-primary); opacity: .7;
}
.profile-op-chip button:hover { opacity: 1; }
.profile-op-placeholder { font-size: 12px; color: var(--muted); }
.profile-op-meta { font-size: 11px; color: var(--muted); }
.profile-op-status { font-size: 11px; }
.profile-op-status.ok    { color: var(--color-success); }
.profile-op-status.error { color: var(--color-danger); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  .profile-modal-card {
    height: calc((var(--app-vh, 1vh) * 100) - 16px);
  }

  #profileModal .modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .profile-modal-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .profile-modal-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 42%;
    overflow-y: auto;
  }

  .profile-modal-main {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
  }

  .profile-modal-panels {
    min-height: 0;
  }

  .profile-modal-panel {
    min-height: 0;
    max-height: none;
  }

  .profile-modal-actions {
    flex: 0 0 auto;
    flex-wrap: wrap;
  }

  .profile-modal-actions .hint {
    width: 100%;
  }

  .profile-modal-actions .btn {
    min-height: 44px;
  }
}
