:root {
  --bg: #eef2f7;
  --card-bg: rgba(255, 255, 255, 0.72);
  --border: rgba(148, 163, 184, 0.28);
  --text-main: #1f2933;
  --text-muted: #6b7280;
  --accent: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #f7fbff 0, #eef2f7 55%, #e0e7f1 100%);
  color: var(--text-main);
}

body.bbdb-modal-open {
  overflow: hidden;
}

body.bbdb-embedded-body {
  padding: 12px;
  background: linear-gradient(180deg, #f5f8fc 0%, #e9eff7 100%);
  height: 100vh;
  overflow: hidden;
}

body.bbdb-public-body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 16px 32px;
}

.bb-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px;
  padding: 14px 24px 18px;
  margin: 0 !important;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  transition: box-shadow .18s ease;
}

.bb-header.is-scrolled {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.bb-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 12px;
  min-width: 0;
}

.bb-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.bb-logo {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
}

.bb-logo a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.bb-logo img {
  width: auto;
  height: 48px;
  display: block;
}

.bb-header-titles h1 {
  margin: 0;
  line-height: 1;
  font-size: 1.35rem;
  letter-spacing: .08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bb-header-spacer {
  height: var(--bb-header-h, 78px);
}

.bbdb-page {
  width: 100%;
}

.bbdb-page--full {
  max-width: none;
}

.bbdb-page--contact {
  max-width: 1200px;
  margin: 0 auto;
}

.bbdb-page--embedded {
  max-width: 100%;
}

.bbdb-page--public {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.bbdb-login-page {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.bbdb-login-card {
  padding: 22px;
}

.bbdb-login-brand {
  margin-bottom: 18px;
}

.bbdb-login-copy {
  margin: 10px 0 0;
  color: #475569;
  line-height: 1.5;
}

.bbdb-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.6),
    0 30px 90px rgba(15, 23, 42, 0.18);
}

.bbdb-card--table {
  width: 100%;
  padding: 18px;
}

.bbdb-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bbdb-section {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.bbdb-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bbdb-section-head--compact {
  margin-bottom: 14px;
}

.bbdb-section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.bbdb-grid {
  display: grid;
  gap: 12px;
}

.bbdb-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bbdb-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.bbdb-field > span {
  font-size: 1rem;
  font-weight: 600;
}

.bbdb-field--compact {
  min-width: 90px;
}

.bbdb-field--checkbox {
  justify-content: flex-end;
}

.bbdb-mt {
  margin-top: 12px;
}

.bbdb-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.bbdb-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 0, 0, .10);
  border: 1px solid rgba(255, 0, 0, .25);
  margin: 12px 0;
}

.bbdb-success {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.28);
  margin: 12px 0;
}

.bbdb-input,
.bbdb-textarea {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
  font-size: 1rem;
  line-height: 1.2;
}

.bbdb-input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.bbdb-textarea {
  min-height: 110px;
  resize: vertical;
}

.bbdb-input[readonly],
.bbdb-input:disabled,
.bbdb-textarea[readonly],
.bbdb-textarea:disabled {
  background: #f2f2f2;
  opacity: 1;
}

.bbdb-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
}

.bbdb-check input {
  margin-top: 3px;
}

.bbdb-btn,
.bbdb-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  color: #1a1a1a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}

.bbdb-btn:hover,
.bbdb-btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.75);
}

.bbdb-btn-primary {
  background: rgba(140, 200, 255, 0.25);
  border-color: rgba(80, 140, 220, 0.35);
}

.bbdb-icon-btn,
.bbdb-icon-btn:link,
.bbdb-icon-btn:visited,
.bbdb-icon-btn:hover,
.bbdb-icon-btn:active,
.bbdb-icon-btn:focus {
  color: #1a1a1a;
  text-decoration: none;
}

.bbdb-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}

.bbdb-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.75);
}

.bbdb-icon-btn:disabled,
.bbdb-icon-btn.is-active {
  opacity: .55;
  cursor: default;
  transform: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.bbdb-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.bbdb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  table-layout: fixed;
}

.bbdb-table--contacts {
  min-width: 100%;
}

.bbdb-table th,
.bbdb-table td {
  padding: 12px 14px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.bbdb-table--contacts th,
.bbdb-table--contacts td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bbdb-table thead th {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
  opacity: 0.85;
}

.bbdb-table--contacts thead th {
  background: rgba(226, 236, 248, 0.9);
  color: #1f2933;
}

.bbdb-table-actions-col,
.bbdb-table-actions-cell {
  width: 116px;
  text-align: right !important;
}

.bbdb-table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bbdb-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.35);
}

.bbdb-clickable-row {
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}

.bbdb-clickable-row:hover,
.bbdb-clickable-row:focus-visible {
  background: rgba(226, 236, 248, 0.75) !important;
  outline: none;
}

.bbdb-empty-cell {
  text-align: center !important;
  color: #6b7280;
}

.bbdb-contact-card {
  padding: 18px;
}

.bbdb-contact-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.bbdb-contact-hero-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1 1 auto;
  text-align: center;
}

.bbdb-avatar {
  --bb-photo-scale: 1;
  --bb-photo-pos-x: 50%;
  --bb-photo-pos-y: 50%;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(145deg, #dbe7f5, #f8fbff);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 12px 30px rgba(15, 23, 42, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-weight: 800;
  letter-spacing: .06em;
}

.bbdb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--bb-photo-pos-x) var(--bb-photo-pos-y);
  transform: scale(var(--bb-photo-scale));
  transform-origin: center center;
}

.bbdb-avatar span {
  pointer-events: none;
}

.bbdb-avatar--hero {
  width: 148px;
  height: 148px;
  font-size: 2.7rem;
}

.bbdb-avatar--editor {
  width: 180px;
  height: 180px;
  font-size: 2.4rem;
  margin: 0 auto;
}

.bbdb-contact-eyebrow {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: #6b7280;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.bbdb-contact-title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.1;
}

.bbdb-contact-headline {
  min-width: 0;
}

.bbdb-contact-company {
  margin-top: 10px;
  color: #334155;
  font-size: 1rem;
  font-weight: 700;
}

.bbdb-contact-role {
  margin-top: 4px;
  color: #64748b;
  font-size: .98rem;
}

.bbdb-contact-status {
  margin-top: 6px;
  color: #b91c1c;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.bbdb-contact-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bbdb-contact-actions.is-hidden {
  display: none;
}

.bbdb-public-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bbdb-public-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
}

.bbdb-public-brand img {
  display: block;
  width: auto;
  height: 42px;
}

.bbdb-public-card {
  padding: 20px;
}

.bbdb-contact-hero--public {
  margin-bottom: 18px;
}

.bbdb-contact-scroll--public {
  overflow: visible;
  padding: 0;
}

.bbdb-contact-scroll {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bbdb-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.bbdb-detail-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.bbdb-detail-item span,
.bbdb-contact-note span {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  color: #6b7280;
  text-transform: uppercase;
}

.bbdb-detail-item strong {
  color: #0f172a;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.bbdb-contact-note {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.bbdb-contact-note p {
  margin: 10px 0 0;
  color: #1f2937;
  line-height: 1.55;
}

.bbdb-collection {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bbdb-collection-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.bbdb-collection-item span {
  color: #64748b;
  font-size: .92rem;
  font-weight: 700;
}

.bbdb-collection-item strong {
  color: #0f172a;
  width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
}

.bbdb-collection-item--address {
  align-items: flex-start;
}

.bbdb-collection-item--address span,
.bbdb-collection-item--address strong {
  text-align: left;
}

.bbdb-detail-item {
  align-items: flex-start;
  text-align: left;
}

.bbdb-detail-item span {
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: 0;
  color: #64748b;
  text-transform: none;
}

.bbdb-detail-item strong {
  width: 100%;
  text-align: left;
}

.bbdb-empty-state {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px dashed rgba(148, 163, 184, 0.34);
  color: #6b7280;
}

.bbdb-photo-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: start;
}

.bbdb-photo-editor-preview {
  text-align: center;
  width: 100%;
}

.bbdb-photo-editor-toggle {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.bbdb-photo-editor-toggle .bbdb-avatar {
  transition: transform .12s ease, box-shadow .12s ease;
}

#photoPreviewAvatar {
  position: relative;
}

#photoPreviewImage {
  position: absolute;
  max-width: none;
  max-height: none;
}

#photoPreviewFallback {
  position: relative;
  z-index: 1;
}

.bbdb-photo-editor-toggle:hover .bbdb-avatar,
.bbdb-photo-editor-toggle:focus-visible .bbdb-avatar {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 18px 34px rgba(15, 23, 42, 0.14);
}

.bbdb-photo-editor-toggle:focus-visible {
  outline: none;
}

.bbdb-photo-editor-hint {
  margin: 12px 0 0;
  color: #64748b;
  font-size: .92rem;
  line-height: 1.45;
}

.bbdb-photo-editor-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.bbdb-photo-editor-controls.is-collapsed {
  display: none;
}

.bbdb-photo-sliders {
  display: grid;
  gap: 12px;
}

.bbdb-edit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bbdb-edit-row {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.bbdb-edit-row-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.bbdb-edit-row-grid--contact {
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr) 120px 40px;
}

.bbdb-edit-row-grid--address {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.bbdb-page--contact .bbdb-grid-3,
.bbdb-page--contact .bbdb-detail-grid,
.bbdb-page--public .bbdb-detail-grid,
.bbdb-page--contact .bbdb-edit-row-grid--contact,
.bbdb-page--contact .bbdb-edit-row-grid--address {
  grid-template-columns: 1fr;
}

.bbdb-edit-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bbdb-edit-row-actions .bbdb-field--compact {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bbdb-edit-row-actions .bbdb-field--compact > span {
  margin: 0;
}

.bbdb-contact-radio {
  width: 22px;
  height: 22px;
  margin-top: 0;
}

.bbdb-edit-row-remove {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  flex: 0 0 40px;
  align-self: center;
  margin-left: auto;
}

.bbdb-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.bbdb-modal[aria-hidden="false"],
.bbdb-modal.is-open {
  display: flex;
}

.bbdb-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(10px);
}

.bbdb-modal-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  max-height: min(92vh, 860px);
  margin: auto;
  padding: 10px;
  overflow: hidden;
  border-radius: 28px;
  background: rgba(238, 244, 251, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.40);
}

.bbdb-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 0 2px 10px;
}

.bbdb-modal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bbdb-modal-topbar-copy,
.bbdb-modal-title {
  display: none !important;
}

.bbdb-modal-frame {
  display: block;
  width: 100%;
  height: min(82vh, 780px);
  border: 0;
  border-radius: 22px;
  background: #f8fbff;
}

.bbdb-page--embedded .bbdb-contact-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.bbdb-page--embedded {
  height: 100%;
}

.bbdb-page--embedded .bbdb-contact-hero {
  position: sticky;
  top: 0;
  z-index: 10;
  flex: 0 0 auto;
  margin: 0;
  padding: 14px 14px 10px;
  background: linear-gradient(180deg, rgba(245, 248, 252, 0.98) 0%, rgba(237, 243, 250, 0.96) 100%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(10px);
}

.bbdb-page--embedded .bbdb-contact-hero-main {
  align-items: center;
}

.bbdb-page--embedded .bbdb-contact-title {
  font-size: 1.28rem;
}

.bbdb-page--embedded .bbdb-contact-company {
  margin-top: 8px;
  font-size: .98rem;
}

.bbdb-page--embedded .bbdb-contact-role {
  font-size: .94rem;
}

.bbdb-page--embedded .bbdb-contact-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px 18px;
}

@media (max-width: 900px) {
  body {
    padding: 14px;
  }

  body.bbdb-public-body {
    padding: 16px 12px 24px;
  }

  .bb-header {
    padding: 12px 14px 16px;
  }

  .bb-header-titles h1 {
    font-size: 1.15rem;
  }

  .bbdb-grid-3,
  .bbdb-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bbdb-photo-editor,
  .bbdb-edit-row-grid--contact,
  .bbdb-edit-row-grid--address {
    grid-template-columns: 1fr;
  }

  .bbdb-contact-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .bbdb-contact-hero-main {
    align-items: center;
  }

  .bbdb-edit-row-remove {
    width: 100%;
  }

}

@media (max-width: 640px) {
  .bbdb-detail-grid {
    grid-template-columns: 1fr;
  }

  .bbdb-collection-item {
    flex-direction: column;
  }

  .bbdb-collection-item strong {
    text-align: left;
  }

  .bbdb-modal {
    padding: 0;
  }

  .bbdb-modal-shell {
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    padding: 10px 10px 8px;
  }

  .bbdb-modal-frame {
    height: calc(100vh - 64px);
    border-radius: 20px 20px 0 0;
  }

  .bbdb-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .bbdb-edit-row-remove {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
  }
}
