:root {
  --ink: #242235;
  --ink-soft: #3a344f;
  --muted: #7e7a8b;
  --line: #dedde5;
  --line-soft: #eeeeef;
  --paper: #ffffff;
  --page: #eeeeea;
  --purple: #302a45;
  --purple-2: #464061;
  --accent: #7566c8;
  --accent-soft: #ebe8ff;
  --green: #8ab98b;
  --red: #ef6674;
  --yellow: #f2bf62;
  --blue: #a7d6dd;
  --shadow: 0 18px 48px rgba(35, 33, 52, .1);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}

input,
select {
  height: 40px;
  padding: 0 13px;
}

textarea {
  min-height: 104px;
  resize: vertical;
  padding: 12px 13px;
}

select option {
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(117, 102, 200, .13);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 64px;
  display: grid;
  grid-template-columns: 300px minmax(260px, 680px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 0 28px;
  background: #232231;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 12px 26px rgba(24, 22, 34, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  flex: 0 0 auto;
}

.brand-title {
  font-weight: 800;
  letter-spacing: .02em;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
}

.top-search input {
  height: 38px;
  background: #3a354f;
  color: #fff;
  border: 1px solid #514b6f;
}

.top-search input::placeholder {
  color: rgba(255, 255, 255, .58);
}

.top-search input:focus {
  box-shadow: 0 0 0 4px rgba(117, 102, 200, .23);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 20px 88px;
  width: 100%;
}

.left-panel,
.metric-card,
.context-bar,
.filter-card,
.contacts-panel,
.detail-panel,
.profile-card,
.empty-card,
.modal-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(40, 38, 54, .055);
}

.left-panel {
  position: sticky;
  top: 82px;
  height: calc(100vh - 100px);
  padding: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 14px;
  background: #f4f3f1;
}

.mode-tabs button {
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mode-tabs button.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 10px 20px rgba(48, 42, 69, .2);
}

.nav-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 8px;
  margin: 12px 0;
}

.sidebar-action {
  height: 40px;
  border: 1px solid #d8d5e9;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--purple);
  font-weight: 850;
  margin-bottom: 10px;
}

.nav-list {
  overflow: auto;
  padding-right: 2px;
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  min-height: 58px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-align: left;
}

.nav-item:hover {
  background: #f7f6f3;
  border-color: #eeeae4;
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: #cbc4ff;
}

.nav-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #eceaf3;
  font-size: 19px;
}

.nav-name {
  display: block;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.count-pill {
  min-width: 34px;
  border-radius: 999px;
  background: #f0eff4;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  padding: 5px 8px;
}

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 15px 18px;
}

.metric-card span {
  display: block;
  font-size: 25px;
  line-height: 1;
  font-weight: 900;
}

.metric-card small {
  display: block;
  color: var(--muted);
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
}

.context-bar {
  min-height: 62px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.context-title {
  font-size: 18px;
  font-weight: 900;
}

.context-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.context-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.filter-card {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 280px) minmax(130px, 160px) minmax(190px, 240px) minmax(320px, 1.6fr);
  gap: 10px;
  align-items: center;
}

.field-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.field-toggles label {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: #f5f4f0;
  border: 1px solid #e8e5dc;
  padding: 0 10px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.field-toggles input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(380px, .85fr);
  gap: 14px;
  align-items: start;
}

.contacts-panel {
  padding: 10px;
  min-height: 560px;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-card {
  border: 1px solid var(--line-soft);
  background: #fff;
  border-radius: 15px;
  padding: 12px 13px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  transition: transform .14s ease, border .14s ease, box-shadow .14s ease, background .14s ease;
}

.contact-card:hover {
  transform: translateY(-1px);
  border-color: #d7d2f3;
  box-shadow: 0 12px 28px rgba(48, 42, 69, .08);
}

.contact-card.active {
  background: #fbfaff;
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(117, 102, 200, .16);
}

.contact-card input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--purple);
}

.contact-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contact-name {
  font-size: 14px;
  font-weight: 900;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contact-sub,
.contact-meta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  border-radius: 999px;
  background: #f0eef8;
  color: var(--purple);
  border: 1px solid #e0ddef;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.contact-tags,
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-badge,
.color-label {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 8px;
  padding: 3px 8px;
  background: #e9f3f5;
  color: #44616a;
  font-size: 11px;
  font-weight: 850;
}

.tag-badge.muted {
  background: #eeeef1;
  color: var(--muted);
}

.tag-badge.warning {
  background: #fff3d9;
  color: #8b6120;
}

.tag-badge.list {
  background: var(--accent-soft);
  color: var(--purple);
}

.contact-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-label.vip,
.color-label.partner {
  background: #dcebdc;
  color: #476f4e;
}

.color-label.hot {
  background: #ffe2e7;
  color: #a33b49;
}

.color-label.followup {
  background: #fff0cf;
  color: #8b6120;
}

.color-label.later {
  background: #e8e7ef;
  color: var(--purple);
}

.detail-panel {
  min-height: 560px;
  position: sticky;
  top: 82px;
  overflow: hidden;
}

.empty-card {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-card.compact {
  box-shadow: none;
  border: 0;
  background: #f7f6f3;
  padding: 16px;
}

.profile-card {
  box-shadow: none;
  border: 0;
  padding: 18px;
}

.profile-top {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  color: #fff;
  font-size: 20px;
  font-weight: 950;
  box-shadow: 0 14px 26px rgba(48, 42, 69, .2);
}

.detail-title {
  font-size: 20px;
  font-weight: 950;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.detail-email,
.detail-muted,
.muted-text {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.profile-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger-icon:hover {
  border-color: var(--red);
  color: var(--red);
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.info-row {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8f7f4;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.info-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.info-row strong {
  color: var(--ink);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.info-row a {
  color: var(--accent);
  text-decoration: none;
}

.section-block {
  margin-top: 18px;
}

.section-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notes-box {
  background: #f8f7f4;
  border-radius: 13px;
  min-height: 76px;
  padding: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: pre-wrap;
}

.detail-actions,
.modal-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
}

.primary-btn,
.dark-btn,
.light-btn,
.ghost-btn,
.danger-btn,
.tiny-btn {
  min-height: 38px;
  border-radius: 12px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(117, 102, 200, .25);
}

.primary-btn:hover {
  background: #6959bd;
}

.dark-btn {
  background: var(--purple);
  color: #fff;
}

.light-btn,
.ghost-btn {
  background: #fff;
  color: var(--purple);
  border-color: var(--line);
}

.light-btn:hover,
.ghost-btn:hover {
  border-color: #bdb5ef;
  background: #fbfaff;
}

.danger-btn {
  background: #fff1f3;
  color: #b23745;
  border-color: #ffd0d7;
}

.danger-btn:hover {
  background: #ffe4e8;
}

.tiny-btn {
  min-height: 32px;
  border-radius: 10px;
  background: #f6f5f1;
  color: var(--purple);
  border-color: var(--line);
  font-size: 12px;
}

.load-more {
  width: 100%;
  margin-top: 10px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--purple);
  font-weight: 900;
}

.selection-dock {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 120%);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  min-width: min(980px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(35, 34, 49, .96);
  color: #fff;
  box-shadow: 0 24px 80px rgba(24, 22, 34, .32);
  transition: transform .2s ease, opacity .2s ease;
}

.selection-dock.visible {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.selection-title {
  font-weight: 950;
  padding-left: 6px;
  white-space: nowrap;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.selection-actions .light-btn {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border-color: rgba(255, 255, 255, .18);
}

.selection-actions .dark-btn {
  background: rgba(255, 255, 255, .14);
}

[hidden] {
  display: none !important;
}

.modal-host[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 19, 30, .58);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell {
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-card {
  padding: 20px;
  box-shadow: var(--shadow);
}

.small-modal-card {
  width: min(520px, 100%);
  margin: 0 auto;
}

.editor-modal-card {
  width: min(860px, 100%);
}

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

.modal-title {
  font-size: 20px;
  font-weight: 950;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.custom-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 36px;
  gap: 8px;
  margin-bottom: 8px;
}

.copy-box {
  min-height: 170px;
  width: 100%;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  background: #232231;
  color: #fff;
  border-radius: 14px;
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 18px 42px rgba(24, 22, 34, .24);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1240px) {
  .layout {
    grid-template-columns: 290px minmax(0, 1fr);
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .detail-panel {
    position: static;
  }
  .filter-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    height: auto;
    padding: 12px;
    grid-template-columns: 1fr;
  }
  .top-actions {
    justify-content: flex-start;
  }
  .layout {
    grid-template-columns: 1fr;
    padding: 12px 12px 96px;
  }
  .left-panel {
    position: static;
    height: auto;
    max-height: 420px;
  }
  .metric-row,
  .filter-card,
  .form-row {
    grid-template-columns: 1fr;
  }
  .selection-dock {
    align-items: flex-start;
    flex-direction: column;
  }
  .selection-actions {
    justify-content: flex-start;
  }
}


html,
body {
  height: 100%;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 64px;
  grid-template-columns: 300px minmax(320px, 760px) 1fr;
  justify-content: stretch;
  padding: 0 20px;
}

.top-search {
  min-width: 0;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 10px;
}

.sidebar-actions .primary-btn,
.sidebar-actions .dark-btn {
  width: 100%;
  min-height: 42px;
}

.layout {
  flex: 1 1 auto;
  height: calc(100vh - 64px);
  min-height: 0;
  overflow: hidden;
  grid-template-columns: 320px minmax(0, 1fr);
  padding: 14px 16px 18px;
}

.left-panel {
  position: static;
  top: auto;
  height: 100%;
  min-height: 0;
}

.nav-tools {
  grid-template-columns: minmax(0, 1fr) 158px;
}

.nav-tools select {
  min-width: 158px;
}

.main-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.metric-row,
.context-bar,
.filter-card {
  flex: 0 0 auto;
}

.metric-row {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.filter-card {
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 160px) minmax(140px, 170px) minmax(190px, 230px) minmax(430px, 1.8fr);
}

.field-toggles label,
.field-toggles input {
  cursor: pointer;
}

.field-toggles label:has(input:checked) {
  background: var(--accent-soft);
  border-color: #c7c0f4;
  color: var(--purple);
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
  align-items: stretch;
  grid-template-columns: minmax(520px, 1.45fr) minmax(380px, .85fr);
}

.contacts-panel,
.detail-panel {
  min-height: 0;
  height: 100%;
  overscroll-behavior: contain;
}

.contacts-panel {
  overflow-y: auto;
  padding-right: 8px;
}

.detail-panel {
  position: static;
  top: auto;
  overflow-y: auto;
}

.profile-card {
  min-height: 100%;
}

.contacts-panel::-webkit-scrollbar,
.detail-panel::-webkit-scrollbar,
.nav-list::-webkit-scrollbar {
  width: 10px;
}

.contacts-panel::-webkit-scrollbar-thumb,
.detail-panel::-webkit-scrollbar-thumb,
.nav-list::-webkit-scrollbar-thumb {
  background: #d8d5df;
  border-radius: 999px;
  border: 3px solid #fff;
}

@media (max-width: 1240px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .layout {
    height: auto;
    overflow: visible;
  }

  .main-panel,
  .workspace,
  .contacts-panel,
  .detail-panel {
    height: auto;
    overflow: visible;
  }
}

.top-link-btn {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-weight: 900;
  padding: 0 14px;
}

.top-link-btn:hover {
  background: rgba(255, 255, 255, .14);
}

.auth-page {
  min-height: 100vh;
  overflow: auto;
  background: radial-gradient(circle at 18% 10%, rgba(117, 102, 200, .2), transparent 30%), var(--page);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(430px, 100%);
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 24px;
  color: var(--ink);
}

.auth-brand .brand-subtitle {
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.remember-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.auth-submit {
  width: 100%;
  min-height: 44px;
}

.auth-submit:disabled {
  opacity: .7;
  cursor: wait;
}

.auth-error {
  border: 1px solid #ffd0d7;
  background: #fff1f3;
  color: #b23745;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .24));
}

.filter-card {
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 280px) minmax(130px, 160px) minmax(190px, 240px) minmax(430px, 1.8fr);
}

.custom-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .01em;
}

.custom-badge.purple { background: #ebe8ff; color: #463c8f; }
.custom-badge.blue { background: #e5f1ff; color: #285b91; }
.custom-badge.green { background: #e4f3e4; color: #3f7445; }
.custom-badge.yellow { background: #fff2ce; color: #8a6119; }
.custom-badge.red { background: #ffe5ea; color: #a73748; }
.custom-badge.gray { background: #ececf1; color: #555264; }
.custom-badge.pink { background: #ffe5f2; color: #a33170; }
.custom-badge.teal { background: #ddf4f1; color: #31736c; }

.custom-badge-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 140px 36px;
  gap: 8px;
  margin-bottom: 8px;
}

.import-drop {
  position: relative;
  border: 1.5px dashed #c8c1f1;
  background: linear-gradient(180deg, #fbfaff, #f6f4ff);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  overflow: hidden;
}

.import-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  height: 100%;
}

.import-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  background: var(--purple);
  color: #fff;
  font-size: 26px;
  font-weight: 950;
}

.import-title {
  font-size: 17px;
  font-weight: 950;
}

.import-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.import-result {
  margin-top: 14px;
  border-radius: 14px;
  background: #e9f5ea;
  color: #3f7445;
  padding: 12px;
  font-weight: 800;
}

.admin-modal-card {
  width: min(1100px, 100%);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, .86fr) minmax(420px, 1.14fr);
  gap: 16px;
  align-items: start;
}

.admin-section {
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 14px;
  background: #fbfaf7;
}

.account-card {
  border: 1px solid #ece8dd;
  background: #fff;
  border-radius: 15px;
  padding: 12px;
  margin-bottom: 10px;
}

.account-title {
  font-weight: 950;
  margin-bottom: 10px;
}

.logs-list {
  max-height: 520px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.log-row {
  border: 1px solid #eee9df;
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
}

.log-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.log-main strong {
  color: var(--purple);
  font-size: 13px;
}

.log-main span {
  color: var(--ink-soft);
  font-size: 12px;
  text-align: right;
}

.log-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.log-details {
  margin-top: 10px;
  display: grid;
  gap: 9px;
}

.log-contact,
.log-contact-chip,
.log-block,
.log-mini-grid {
  border: 1px solid #eee9df;
  background: #fbfaf7;
  border-radius: 12px;
}

.log-contact,
.log-contact-chip {
  padding: 8px 10px;
}

.log-contact-title {
  font-weight: 900;
  color: var(--ink);
  font-size: 12px;
}

.log-contact-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.log-block {
  padding: 9px;
}

.log-block-title {
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 950;
}

.log-field-grid {
  display: grid;
  grid-template-columns: minmax(110px, .55fr) 1fr;
  gap: 5px 10px;
}

.log-field-name {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.log-field-value {
  color: var(--ink-soft);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.log-change-list,
.log-updated-list {
  display: grid;
  gap: 6px;
}

.log-change-row {
  display: grid;
  grid-template-columns: minmax(110px, .55fr) 1fr;
  gap: 10px;
  align-items: start;
}

.log-change-field {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.log-change-values {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.log-change-values span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.log-change-values b {
  color: var(--purple);
}

.log-contact-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.log-updated-item {
  display: grid;
  gap: 6px;
}

.log-mini-grid {
  padding: 8px 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
}

.log-mini-grid span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: capitalize;
}

.log-mini-grid b {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.top-actions .top-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-actions #importButton {
  background: #f6f2ff;
  color: var(--purple);
  border-color: #cbc4ff;
}

.top-actions #adminButton {
  background: rgba(117, 102, 200, .3);
  border-color: rgba(255, 255, 255, .18);
}

@media (max-width: 1480px) {
  .filter-card {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
  .field-toggles {
    grid-column: 1 / -1;
  }
}

@media (max-width: 960px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .custom-badge-row {
    grid-template-columns: 1fr;
  }
}

.import-file-name {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(35, 34, 49, .08);
  color: #232231;
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-result.error {
  border-color: #ffd1d8;
  background: #fff5f6;
  color: #9d2839;
}

.import-progress {
  margin-top: 10px;
  color: #6a667a;
  font-size: 12px;
  font-weight: 800;
}

html {
  scroll-behavior: smooth;
}

button,
.contact-card,
.nav-item,
.metric-card,
.context-bar,
.filter-card,
.profile-card,
.modal-card,
.import-drop,
.info-row {
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, border-color .18s ease, background .18s ease, color .18s ease, opacity .18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0) scale(.99);
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(117, 102, 200, .25);
  outline-offset: 2px;
}

.metric-card:hover,
.context-bar:hover,
.filter-card:hover,
.profile-card:hover {
  box-shadow: 0 16px 38px rgba(40, 38, 54, .08);
}

.nav-item:hover {
  transform: translateX(2px);
}

.contacts-toolbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 4px 12px;
  background: linear-gradient(180deg, #fff 76%, rgba(255, 255, 255, 0));
}

.contacts-toolbar-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contacts-toolbar-copy strong {
  font-size: 14px;
  font-weight: 950;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contacts-toolbar-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contacts-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-btn {
  min-height: 34px;
  border-radius: 11px;
  padding: 0 12px;
  font-size: 12px;
}

.contact-card {
  animation: cardIn .2s ease both;
}

.contact-card:nth-child(2n) {
  animation-delay: .015s;
}

.contact-card:nth-child(3n) {
  animation-delay: .03s;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-backdrop {
  animation: fadeIn .16s ease both;
}

.modal-shell {
  animation: modalIn .2s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.import-drop:hover {
  border-color: var(--accent);
  box-shadow: 0 18px 42px rgba(117, 102, 200, .14);
  transform: translateY(-1px);
}

.top-link-btn:hover,
.primary-btn:hover,
.dark-btn:hover,
.light-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.tiny-btn:hover,
.load-more:hover,
.sidebar-action:hover {
  box-shadow: 0 14px 30px rgba(48, 42, 69, .12);
}

.tag-badge,
.custom-badge,
.color-label,
.country-chip,
.count-pill {
  transition: transform .15s ease, box-shadow .15s ease;
}

.tag-badge:hover,
.custom-badge:hover,
.color-label:hover,
.country-chip:hover {
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  body {
    background: #f3f2ef;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    height: auto;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px 12px;
    flex: 0 0 auto;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .top-search input {
    height: 42px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .top-link-btn {
    min-width: 0;
    padding: 0 8px;
    font-size: 12px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 10px 10px 108px;
    gap: 10px;
  }

  .left-panel {
    height: auto;
    max-height: none;
    overflow: visible;
    border-radius: 18px;
  }

  .sidebar-actions {
    grid-template-columns: 1fr 1fr;
  }

  .mode-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: auto;
  }

  .mode-tabs button {
    min-width: 84px;
    font-size: 12px;
  }

  .nav-tools {
    grid-template-columns: 1fr;
  }

  .nav-tools select {
    min-width: 0;
  }

  .nav-list {
    max-height: 260px;
  }

  .main-panel {
    height: auto;
    overflow: visible;
    gap: 10px;
  }

  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-card {
    padding: 13px;
  }

  .metric-card span {
    font-size: 22px;
  }

  .context-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .context-actions {
    width: 100%;
    justify-content: stretch;
  }

  .context-actions button {
    flex: 1 1 auto;
  }

  .filter-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .field-toggles {
    gap: 6px;
  }

  .field-toggles label {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    gap: 10px;
  }

  .contacts-panel,
  .detail-panel {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 8px;
  }

  .contacts-toolbar {
    position: sticky;
    top: 137px;
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 2px 10px;
  }

  .contacts-toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .contact-card {
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: flex-start;
    padding: 12px;
  }

  .contact-side {
    grid-column: 2;
    justify-content: flex-start;
  }

  .contact-name-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .contact-name,
  .contact-sub,
  .contact-meta {
    white-space: normal;
  }

  .detail-panel {
    order: 2;
  }

  .profile-card {
    padding: 14px;
  }

  .profile-top {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .profile-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 17px;
  }

  .detail-title {
    font-size: 18px;
  }

  .info-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .info-row strong {
    text-align: left;
  }

  .selection-dock {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    min-width: 0;
    max-width: none;
    transform: translateY(120%);
    border-radius: 18px;
  }

  .selection-dock.visible {
    transform: translateY(0);
  }

  .selection-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .selection-actions button {
    min-width: 0;
    font-size: 12px;
    padding: 0 8px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-shell {
    width: 100%;
    max-height: calc(100vh - 20px);
  }

  .modal-card {
    border-radius: 22px;
    padding: 16px;
  }

  .form-row,
  .custom-field-row,
  .custom-badge-row,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .logs-list {
    max-height: 360px;
  }
}

@media (max-width: 460px) {
  .metric-row,
  .top-actions,
  .contacts-toolbar-actions,
  .selection-actions {
    grid-template-columns: 1fr;
  }

  .sidebar-actions {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-toggles label {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}


/* v9 polish */
:root {
  --page: #f4f3ef;
  --paper: #ffffff;
  --ink: #222033;
  --ink-soft: #3d3854;
  --muted: #817d8d;
  --line: #e2e0e8;
  --line-soft: #eceaf1;
  --purple: #252336;
  --purple-2: #37314d;
  --accent: #7b6ad7;
  --accent-2: #5f52b5;
  --accent-soft: #f0edff;
  --shadow: 0 16px 45px rgba(30, 28, 42, .085);
  --shadow-soft: 0 8px 24px rgba(30, 28, 42, .055);
}

body {
  background:
    radial-gradient(circle at 8% 0%, rgba(123, 106, 215, .09), transparent 28%),
    linear-gradient(180deg, #f7f6f2 0%, #efeee9 100%);
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: linear-gradient(90deg, #201f30 0%, #29253d 55%, #211f31 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 32px rgba(24, 22, 34, .22);
}

.brand-title {
  letter-spacing: .01em;
}

.top-search input {
  background: rgba(255,255,255,.095);
  border-color: rgba(255,255,255,.16);
  border-radius: 14px;
}

.top-search input:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.24);
}

.left-panel,
.metric-card,
.context-bar,
.filter-card,
.contacts-panel,
.detail-panel,
.modal-card,
.auth-card {
  border-color: rgba(35, 32, 53, .075);
  box-shadow: var(--shadow-soft);
}

.left-panel,
.contacts-panel,
.detail-panel {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
}

.metric-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fff, #fbfaf8);
}


.metric-card span {
  letter-spacing: -.03em;
}

.context-bar,
.filter-card {
  background: rgba(255,255,255,.94);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #cbc6dc;
}

.mode-tabs,
.field-toggles label {
  background: #f3f1ed;
}

.mode-tabs button,
.nav-item,
.contact-card,
.primary-btn,
.dark-btn,
.light-btn,
.ghost-btn,
.danger-btn,
.tiny-btn,
.top-link-btn,
.sidebar-action,
.icon-btn,
.load-more {
  transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.primary-btn {
  background: linear-gradient(180deg, #8575e3, #6f5fd1);
  box-shadow: 0 10px 20px rgba(123, 106, 215, .22);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #8f80ec, #7160d4);
  box-shadow: 0 12px 24px rgba(123, 106, 215, .28);
}

.dark-btn:hover,
.sidebar-action:hover,
.light-btn:hover,
.ghost-btn:hover,
.top-link-btn:hover,
.icon-btn:hover {
  box-shadow: 0 8px 18px rgba(35, 32, 53, .1);
}

.nav-item {
  min-height: 54px;
}

.nav-item:hover {
  background: #f8f6f1;
  border-color: #e8e4dc;
}

.nav-item.active {
  background: linear-gradient(180deg, #f4f1ff, #eeeaff);
  border-color: #c9c1ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.contacts-toolbar {
  border-bottom: 1px solid rgba(35, 32, 53, .055);
  margin-bottom: 8px;
}

.contact-card {
  animation: none !important;
  transform: none !important;
  border-color: #edeaf2;
  background: linear-gradient(180deg, #fff, #fffdfb);
  box-shadow: 0 1px 0 rgba(35, 32, 53, .03);
  position: relative;
}

.contact-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
}

.contact-card:hover {
  transform: none !important;
  border-color: #d7d1f4;
  background: #fff;
  box-shadow: 0 10px 24px rgba(35, 32, 53, .075);
}

.contact-card.active {
  background: linear-gradient(180deg, #fbfaff, #f8f5ff);
  border-color: #bfb6fb;
  box-shadow: 0 12px 28px rgba(123, 106, 215, .14);
}

.contact-card.active::before {
  background: var(--accent);
}

.contact-card[data-color="vip"]::before,
.contact-card[data-color="partner"]::before { background: #8ab98b; }
.contact-card[data-color="hot"]::before { background: #ef6674; }
.contact-card[data-color="followup"]::before { background: #f2bf62; }
.contact-card[data-color="later"]::before { background: #8e86a6; }

.contact-name {
  letter-spacing: -.01em;
}

.country-chip,
.tag-badge,
.custom-badge,
.color-label {
  border-radius: 999px;
}

.tag-badge.warning {
  background: #fff4d8;
  color: #795315;
  border: 1px solid #f2d59b;
}

.profile-card {
  background: #fff;
  border-radius: 20px;
}

.profile-top {
  padding-bottom: 14px;
  border-bottom: 1px solid #efedf3;
}

.info-row {
  background: #f8f7f3;
  border: 1px solid transparent;
}

.info-row:hover {
  border-color: #e8e5dc;
  background: #fbfaf7;
}

.notes-box {
  border: 1px solid #ece9df;
  background: #fbfaf7;
}

.mobile-detail-close {
  display: none;
}

.modal-card {
  box-shadow: 0 24px 70px rgba(24, 22, 34, .24);
}

.modal-backdrop {
  backdrop-filter: blur(8px);
}

@media (min-width: 1241px) {
  .workspace {
    grid-template-columns: minmax(580px, 1.55fr) minmax(430px, .85fr);
  }
  .contacts-list {
    padding-bottom: 8px;
  }
}

@media (max-width: 760px) {
  body.detail-open {
    overflow: hidden;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .brand {
    min-height: 40px;
  }

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

  .layout {
    padding: 10px 10px 104px;
  }

  .left-panel,
  .contacts-panel,
  .filter-card,
  .context-bar,
  .metric-card {
    border-radius: 18px;
  }

  .metric-row {
    display: none;
  }

  .nav-list {
    max-height: 220px;
  }

  .contacts-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(180deg, rgba(255,255,255,.98) 78%, rgba(255,255,255,0));
  }

  .contact-card {
    min-height: 92px;
    border-radius: 16px;
    padding: 13px 12px;
  }

  .contact-card:hover {
    box-shadow: 0 1px 0 rgba(35, 32, 53, .03);
  }

  .contact-card:active {
    background: #f8f5ff;
    border-color: #c8bfff;
  }

  .contact-tags {
    margin-top: 2px;
  }

  .detail-panel {
    display: none;
  }

  .detail-panel.mobile-open {
    display: block;
    position: fixed;
    z-index: 120;
    inset: 0;
    height: 100dvh;
    max-height: none;
    overflow-y: auto;
    padding: 12px;
    border: 0;
    border-radius: 0;
    background: rgba(244, 243, 239, .98);
    box-shadow: none;
    overscroll-behavior: contain;
  }

  .detail-panel.mobile-open .profile-card {
    min-height: calc(100dvh - 24px);
    border: 1px solid rgba(35, 32, 53, .075);
    box-shadow: 0 16px 45px rgba(30, 28, 42, .14);
  }

  .mobile-detail-close {
    width: 100%;
    min-height: 42px;
    margin-bottom: 12px;
    border: 1px solid #ded9f6;
    border-radius: 14px;
    background: #f4f1ff;
    color: var(--purple);
    font-weight: 950;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .profile-top {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    align-items: start;
  }

  .profile-actions {
    grid-column: auto;
    justify-content: flex-end;
  }

  .detail-actions .primary-btn {
    width: 100%;
  }

  .modal-shell {
    max-height: calc(100dvh - 20px);
  }

  .modal-card {
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
  }
}

@media (max-width: 430px) {
  .profile-top {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .profile-actions {
    grid-column: 1 / -1;
  }
}

.clearable-search {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.clearable-search input[type="search"] {
  padding-right: 38px;
}

.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 26px;
  height: 26px;
  transform: translateY(-50%) scale(.88);
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, background .14s ease, color .14s ease;
}

.clearable-search.has-value .search-clear {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.search-clear:hover {
  background: rgba(117, 102, 200, .12);
  color: var(--accent);
}

.top-search .search-clear {
  color: rgba(255, 255, 255, .68);
}

.top-search .search-clear:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.nav-item {
  cursor: pointer;
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.nav-rename-btn {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 950;
  opacity: 0;
  transform: translateX(3px);
  transition: opacity .14s ease, transform .14s ease, background .14s ease, color .14s ease, border .14s ease;
}

.nav-item:hover .nav-rename-btn,
.nav-item.active .nav-rename-btn,
.nav-rename-btn:focus-visible {
  opacity: 1;
  transform: translateX(0);
}

.nav-rename-btn:hover {
  background: #fff;
  border-color: #d5cff7;
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(48, 42, 69, .08);
}

.metric-card {
  position: relative;
  overflow: hidden;
}


.metric-card span,
.metric-card small {
  position: relative;
  z-index: 1;
}

@media (max-width: 760px) {
  .nav-rename-btn {
    opacity: 1;
    transform: none;
  }
}


.metric-card::after {
  content: none !important;
  display: none !important;
}

.metric-card {
  background: #fff;
}

.badge-filter {
  position: relative;
  min-width: 0;
}

.badge-filter-toggle {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 760;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.32);
  transition: border .16s ease, box-shadow .16s ease, transform .16s ease;
}

.badge-filter-toggle:hover,
.badge-filter.open .badge-filter-toggle {
  border-color: #c7c0ef;
  box-shadow: 0 10px 22px rgba(86, 72, 145, .08);
}

.badge-filter-caret {
  color: var(--muted);
  font-size: 14px;
}

.badge-filter-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  width: min(420px, 92vw);
  max-height: 430px;
  overflow: hidden;
  border: 1px solid #d9d5ec;
  border-radius: 18px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 24px 60px rgba(42, 37, 62, .18);
  padding: 10px;
  backdrop-filter: blur(16px);
}

.badge-filter-menu input[type=search] {
  width: 100%;
  margin-bottom: 8px;
}

.badge-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 8px;
}

.badge-mode-switch label {
  height: 32px;
  border: 1px solid #e4e0f3;
  border-radius: 999px;
  background: #f8f7fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 850;
  color: var(--ink-soft);
}

.badge-mode-switch input {
  accent-color: var(--purple);
}

.badge-filter-options {
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 2px;
}

.badge-filter-option {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  cursor: pointer;
}

.badge-filter-option:hover {
  background: #f5f3ff;
  border-color: #e2def7;
}

.badge-filter-option input {
  accent-color: var(--purple);
}

.badge-filter-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 850;
}

.badge-filter-count {
  min-width: 28px;
  text-align: center;
  border-radius: 999px;
  background: #efedf8;
  color: var(--purple);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
}

.badge-filter-empty {
  padding: 22px 10px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.badge-filter-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid #eeebf5;
}

@media (max-width: 760px) {
  .badge-filter-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 88px;
    width: auto;
    max-height: min(560px, calc(100vh - 120px));
  }
  .badge-mode-switch {
    grid-template-columns: 1fr;
  }
}

.badge-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.badge-filter-chips button {
  min-height: 24px;
  max-width: 100%;
  border: 1px solid #dcd7ef;
  border-radius: 999px;
  background: #f4f2ff;
  color: var(--purple);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
}

.badge-filter-chips span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-filter-chips b {
  font-size: 13px;
  line-height: 1;
}

/* v15 badge filter polish */
.badge-filter {
  position: relative;
  min-width: 0;
}

.badge-filter-toggle {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  font-weight: 500;
  letter-spacing: 0;
  box-shadow: none;
  transform: none !important;
}

.badge-filter-toggle:hover,
.badge-filter.open .badge-filter-toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(117, 102, 200, .12);
  background: #fff;
}

.badge-filter-caret {
  font-size: 13px;
  color: var(--muted);
  line-height: 1;
}

.badge-filter-menu {
  top: calc(100% + 6px);
  width: min(360px, 92vw);
  max-height: 380px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 18px 48px rgba(35, 33, 52, .16);
  padding: 8px;
  overflow: hidden;
  backdrop-filter: none;
}

.badge-filter-menu input[type=search] {
  height: 38px;
  margin: 0 0 8px;
  border-radius: 10px;
  font-weight: 400;
}

.badge-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 3px;
  margin: 0 0 8px;
  border: 1px solid #e7e4ef;
  border-radius: 11px;
  background: #f6f5fa;
}

.badge-mode-switch label {
  position: relative;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}

.badge-mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.badge-mode-switch label:has(input:checked) {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(35, 33, 52, .08);
}

.badge-filter-options {
  max-height: 246px;
  gap: 2px;
  padding: 2px 2px 2px 0;
}

.badge-filter-option {
  min-height: 34px;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--ink);
}

.badge-filter-option:hover {
  background: #f7f6fb;
  border-color: transparent;
}

.badge-filter-option input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.badge-filter-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.badge-filter-count {
  min-width: 0;
  background: #f0eef6;
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 650;
}

.badge-filter-footer {
  justify-content: flex-start;
  border-top: 1px solid #efedf4;
  margin-top: 8px;
  padding-top: 8px;
}

.badge-filter-chips {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.badge-filter-chips button {
  border-color: #e1def1;
  background: #f7f5ff;
  color: var(--ink-soft);
  font-weight: 650;
}

@media (max-width: 760px) {
  .badge-filter-menu {
    left: 10px;
    right: 10px;
    bottom: 78px;
    width: auto;
    max-height: min(480px, calc(100vh - 120px));
    border-radius: 14px;
  }
  .badge-mode-switch {
    grid-template-columns: 1fr 1fr;
  }
}

/* v16 unified tag/badge filters */
.filter-card {
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) minmax(130px, 160px) minmax(190px, 240px) minmax(320px, 1.6fr);
  align-items: start;
}

.badge-filter.compact-filter {
  position: relative;
  min-width: 0;
  height: 40px;
}

.badge-filter.compact-filter .badge-filter-toggle {
  height: 40px;
  min-height: 40px;
  width: 100%;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.badge-filter.compact-filter .badge-filter-toggle span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-filter.compact-filter .badge-filter-menu {
  top: calc(100% + 6px);
  width: min(360px, 92vw);
  max-height: 384px;
  z-index: 80;
}

.badge-filter.compact-filter .clearable-search {
  display: block;
  width: 100%;
  margin: 0 0 8px;
}

.badge-filter.compact-filter .badge-filter-menu input[type=search] {
  margin: 0;
  width: 100%;
}

.badge-mode-switch,
.badge-filter-chips {
  display: none !important;
}

.badge-filter-option {
  font-weight: 500;
}

.badge-filter-option input {
  flex: 0 0 auto;
}

.badge-filter-name {
  font-weight: 500 !important;
}

.badge-filter-count {
  font-weight: 650 !important;
}

@media (max-width: 1180px) {
  .filter-card {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
  .field-toggles {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .filter-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .badge-filter.compact-filter .badge-filter-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 78px;
    top: auto;
    width: auto;
    max-height: min(480px, calc(100vh - 120px));
  }
}

/* v17 polish: consistent filter arrows, copyable details */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5.25L7 8.25L10 5.25' fill='none' stroke='%237e7a8b' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 36px;
}

.badge-filter.compact-filter .badge-filter-toggle,
.badge-filter-toggle {
  position: relative;
  padding-right: 36px;
}

.badge-filter-caret {
  display: none !important;
}

.badge-filter-toggle::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.7px solid var(--muted);
  border-bottom: 1.7px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.copy-value {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  padding: 0;
  margin: 0;
  max-width: 100%;
  cursor: copy;
  border-radius: 7px;
  transition: color .14s ease, background .14s ease, box-shadow .14s ease;
}

.copy-value:hover {
  color: var(--accent);
  background: rgba(117, 102, 200, .08);
  box-shadow: 0 0 0 4px rgba(117, 102, 200, .08);
}

.detail-email.copy-value {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-copy {
  font-weight: inherit;
  overflow-wrap: anywhere;
}

.info-row a {
  color: var(--accent);
  text-decoration: none;
  border-radius: 7px;
  transition: color .14s ease, background .14s ease, box-shadow .14s ease;
}

.info-row a:hover {
  color: var(--purple);
  background: rgba(117, 102, 200, .08);
  box-shadow: 0 0 0 4px rgba(117, 102, 200, .08);
}

.contact-email-list {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* v18 sidebar mode tabs borders */
.mode-tabs {
  gap: 7px;
  padding: 6px;
  background: #f3f1ed;
  border: 1px solid #e5e1d8;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.mode-tabs button {
  border: 1px solid rgba(42, 38, 58, .12);
  background: rgba(255,255,255,.54);
  color: #7b7688;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.mode-tabs button:hover {
  border-color: rgba(117, 102, 200, .34);
  background: #ffffff;
  color: var(--ink);
}

.mode-tabs button.active {
  border-color: var(--purple);
  background: linear-gradient(180deg, #332d49, #28233a);
  color: #fff;
  box-shadow: 0 10px 20px rgba(48,42,69,.2), inset 0 1px 0 rgba(255,255,255,.1);
}
.inline-editor-card {
  padding-bottom: 12px;
}

.inline-editor-top {
  align-items: flex-start;
}

.inline-editor-head-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-action {
  min-height: 36px;
  padding-inline: 14px;
}


.inline-contact-form {
  gap: 14px;
}

.inline-contact-form .field {
  min-width: 0;
}

.inline-contact-form input,
.inline-contact-form select,
.inline-contact-form textarea {
  background: #fbfaf8;
}

.inline-contact-form input:hover,
.inline-contact-form select:hover,
.inline-contact-form textarea:hover {
  border-color: #d8d0ff;
  background: #fff;
}

.inline-contact-form textarea[name="notes"] {
  min-height: 132px;
}

.custom-badge-row,
.custom-field-row {
  align-items: center;
}

.custom-badge-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(120px, .7fr) 36px;
  gap: 8px;
  margin-bottom: 8px;
}

.editor-floating-actions {
  position: sticky;
  bottom: 12px;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 12px;
  border: 1px solid rgba(222, 217, 246, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 18px 40px rgba(35, 32, 53, .13);
  backdrop-filter: blur(18px);
}

.editor-floating-actions .primary-btn,
.editor-floating-actions .light-btn {
  min-height: 42px;
  padding-inline: 20px;
}

.inline-editor-card .avatar {
  box-shadow: 0 14px 28px rgba(117, 102, 200, .23);
}

@media (max-width: 760px) {
  .inline-editor-top {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .inline-editor-head-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: stretch;
  }

  .inline-editor-head-actions .primary-btn,
  .inline-editor-head-actions .light-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .inline-contact-form .form-row,
  .custom-badge-row,
  .custom-field-row {
    grid-template-columns: 1fr;
  }

  .custom-badge-row .icon-btn,
  .custom-field-row .icon-btn {
    width: 100%;
  }

  .editor-floating-actions {
    bottom: 10px;
    justify-content: stretch;
  }

  .editor-floating-actions .primary-btn,
  .editor-floating-actions .light-btn {
    flex: 1 1 0;
    justify-content: center;
  }
}

/* v21 compact view card and floating edit actions */
.contact-view-card {
  position: relative;
  padding-bottom: 28px;
}

.contact-view-top {
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(222, 221, 229, .78);
}

.contact-floating-actions {
  position: sticky;
  top: 12px;
  z-index: 18;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  width: fit-content;
  margin: -2px 0 12px auto;
  padding: 6px;
  border: 1px solid rgba(222, 217, 246, .92);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 16px 34px rgba(35, 32, 53, .12);
  backdrop-filter: blur(16px);
}

.floating-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(222, 221, 229, .95);
  border-radius: 13px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--ink);
  font-weight: 950;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85);
}

.floating-icon-btn:hover {
  border-color: rgba(117, 102, 200, .45);
  color: var(--accent);
  background: #fbfaff;
}

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

.detail-value-field {
  min-width: 0;
}

.detail-value-field.full {
  grid-column: 1 / -1;
}

.detail-value-label {
  margin: 0 0 6px;
  color: #7b7688;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.detail-value-body {
  min-height: 41px;
  width: 100%;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfaf8;
  color: var(--ink);
  overflow: hidden;
}

.detail-value-copy,
.detail-value-link,
.detail-value-empty {
  width: 100%;
  min-height: 39px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.detail-value-copy:hover {
  background: rgba(117, 102, 200, .075);
  color: var(--purple);
}

.detail-value-link {
  color: var(--accent);
  text-decoration: none;
}

.detail-value-link:hover {
  background: rgba(117, 102, 200, .075);
  color: var(--purple);
}

.detail-value-empty {
  color: #a8a3b2;
}

.compact-section {
  margin-top: 16px;
}

.custom-value-grid {
  margin-top: 4px;
}

.notes-copy {
  width: 100%;
  border: 1px solid rgba(222, 221, 229, .95);
  text-align: left;
}

.notes-copy:hover {
  background: #fff;
  border-color: rgba(117, 102, 200, .35);
}

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

@media (max-width: 760px) {
  .contact-floating-actions {
    top: 10px;
    margin-right: 0;
  }

  .contact-view-top {
    grid-template-columns: 50px minmax(0, 1fr);
  }
}

/* v22 sticky detail header and cleaner notes spacing */
.contact-view-card,
.inline-editor-card {
  position: relative;
  overflow: visible;
}

.sticky-detail-header {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -18px -18px 18px;
  padding: 18px;
  border-bottom: 1px solid rgba(222, 221, 229, .86);
  border-radius: 20px 20px 0 0;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 24px rgba(35, 32, 53, .055);
  backdrop-filter: blur(18px);
}

.contact-view-top,
.inline-editor-top {
  min-height: 88px;
}

.header-contact-actions,
.header-editor-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  align-self: center;
}

.header-contact-actions {
  padding: 6px;
  border: 1px solid rgba(222, 217, 246, .95);
  border-radius: 16px;
  background: rgba(255, 255, 255, .76);
  box-shadow: 0 12px 30px rgba(35, 32, 53, .09);
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(222, 221, 229, .95);
  border-radius: 13px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(180deg, #fff, #fbfaf8);
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .95), 0 8px 18px rgba(35, 32, 53, .045);
  transition: transform .14s ease, border-color .14s ease, color .14s ease, background .14s ease, box-shadow .14s ease;
}

.header-icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(117, 102, 200, .45);
  color: var(--accent);
  background: #fbfaff;
  box-shadow: 0 10px 22px rgba(117, 102, 200, .14);
}

.header-icon-btn.danger-icon:hover {
  border-color: rgba(239, 102, 116, .48);
  color: var(--red);
  background: #fff7f8;
  box-shadow: 0 10px 22px rgba(239, 102, 116, .13);
}

.header-editor-actions .primary-btn,
.header-editor-actions .light-btn {
  min-height: 40px;
  padding-inline: 18px;
  box-shadow: 0 10px 22px rgba(35, 32, 53, .075);
}

.notes-box.notes-copy,
button.notes-box.notes-copy {
  display: block;
  width: 100%;
  min-height: 78px;
  padding: 16px 18px;
  line-height: 1.45;
  text-align: left;
}

@media (max-width: 760px) {
  .sticky-detail-header {
    margin: -12px -12px 14px;
    padding: 14px 12px;
    border-radius: 18px 18px 0 0;
  }

  .contact-view-top,
  .inline-editor-top {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 74px;
  }

  .header-contact-actions {
    padding: 4px;
    gap: 5px;
    border-radius: 14px;
  }

  .header-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .header-editor-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .header-editor-actions .primary-btn,
  .header-editor-actions .light-btn {
    width: 100%;
    justify-content: center;
  }
}


/* v23 sticky header actions: no extra wrapper panel */
.header-contact-actions {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.header-icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(222, 221, 229, .9);
  border-radius: 14px;
  background: rgba(255, 255, 255, .62);
  box-shadow: none;
}

.header-icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(247, 245, 255, .92);
  border-color: rgba(117, 102, 200, .45);
  box-shadow: 0 8px 18px rgba(117, 102, 200, .12);
}

.header-icon-btn.danger-icon:hover {
  background: rgba(255, 247, 248, .94);
  border-color: rgba(239, 102, 116, .45);
  box-shadow: 0 8px 18px rgba(239, 102, 116, .12);
}

@media (max-width: 720px) {
  .header-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 13px;
  }
}

.flag-icon {
  width: 21px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(30, 27, 48, .12);
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}

.flag-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.flag-placeholder {
  background: #f4f2ef;
}

.nav-icon .flag-icon {
  width: 24px;
  height: 18px;
  border-radius: 4px;
}

.country-chip .flag-icon,
.country-value-copy .flag-icon {
  width: 19px;
  height: 14px;
}

.country-value-copy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Business card OCR import */
.wide-import-modal-card {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.import-drop.drag-over {
  border-color: var(--accent);
  background: #fbfaff;
}

.scan-summary {
  margin-bottom: 12px;
  color: var(--purple);
}

.scan-errors {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid #ffd0d7;
  background: #fff1f3;
  color: #a73748;
  border-radius: 12px;
  font-size: 13px;
}

.scan-result-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scan-card-item {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.scan-card-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scan-card-preview img,
.scan-card-no-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f7f6f1;
}

.scan-card-no-preview {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
}

.scan-skip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.scan-card-edit {
  min-width: 0;
}

.scan-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.scan-card-head span {
  color: var(--muted);
  font-size: 13px;
}

.scan-card-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.ocr-details {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: #faf9f5;
}

.ocr-details summary {
  cursor: pointer;
  color: var(--purple);
  font-weight: 900;
}

.ocr-details pre {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 180px;
  margin: 8px 0 0;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.scan-save-status {
  min-height: 18px;
  margin-top: 8px;
  color: #31736c;
  font-weight: 900;
  font-size: 13px;
}

.scan-save-status.error {
  color: #b23745;
}

.sticky-scan-actions {
  position: sticky;
  bottom: -20px;
  background: rgba(255,255,255,.94);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

@media (max-width: 760px) {
  .scan-card-item {
    grid-template-columns: 1fr;
  }
}

.modal-shell:has(.wide-import-modal-card) {
  width: min(1160px, 100%);
}


/* Business card review refinements */
.field textarea[name="phone"] {
  min-height: 74px;
  line-height: 1.45;
}

.detail-value-copy.multiline-value {
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.45;
}

.scan-card-image-button {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
  text-align: center;
}

.scan-card-image-button img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f7f6f1;
  transition: border .15s ease, transform .15s ease, box-shadow .15s ease;
}

.scan-card-image-button:hover img {
  border-color: #cfc5ff;
  box-shadow: 0 10px 28px rgba(40, 35, 57, .11);
  transform: translateY(-1px);
}

.scan-skip-input {
  display: none;
}

.scan-skip-button {
  width: fit-content;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #faf9f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.scan-skip-button:hover {
  border-color: #cfc5ff;
  color: var(--purple);
  background: #fff;
}

.scan-skip-button.active {
  border-color: #f0c0c8;
  background: #fff1f3;
  color: #a73748;
}

.scan-card-item.is-skipped .scan-card-edit {
  opacity: .56;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(19, 18, 29, .78);
}

.image-lightbox img {
  max-width: min(1200px, 96vw);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .32);
}

.image-lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}

@media (max-width: 760px) {
  .image-lightbox {
    padding: 14px;
  }

  .image-lightbox-close {
    top: 10px;
    right: 10px;
  }
}

/* Data quality and contact merge workspace */
.quality-button {
  gap: 8px;
}

.top-count-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #f3c66c;
  color: #302a45;
  font-size: 11px;
  font-weight: 900;
}

.data-quality-modal,
.merge-editor-modal {
  width: min(1180px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 0;
}

.quality-header,
.merge-editor-header {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 22px 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(18px);
}

.quality-loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  font-weight: 750;
}

.quality-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 24px 0;
}

.quality-metrics > div {
  min-height: 88px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: #faf9f6;
}

.quality-metrics > div.safe {
  background: #f1f8f1;
  border-color: #cfe3cf;
}

.quality-metrics strong {
  font-size: 25px;
  line-height: 1;
}

.quality-metrics span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.quality-toolbar {
  position: sticky;
  top: 85px;
  z-index: 7;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 16px 24px 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 30px rgba(35, 33, 52, .06);
  backdrop-filter: blur(16px);
}

.quality-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #efedf4;
}

.quality-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.quality-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(35, 33, 52, .08);
}

.quality-actions {
  display: flex;
  gap: 8px;
}

.duplicate-groups-list {
  display: grid;
  gap: 14px;
  padding: 16px 24px 22px;
}

.duplicate-group-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(35, 33, 52, .045);
}

.duplicate-group-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.duplicate-group-title-row {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.duplicate-group-title {
  font-size: 15px;
  font-weight: 900;
}

.duplicate-select {
  width: 24px;
  flex: 0 0 24px;
}

.duplicate-select input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.duplicate-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.duplicate-reasons span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--purple-2);
  font-size: 10px;
  font-weight: 850;
}

.duplicate-confidence {
  min-width: 92px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border-radius: 12px;
  background: #fff4e8;
  color: #8e5c23;
}

.duplicate-confidence.safe {
  background: #edf7ed;
  color: #376f3b;
}

.duplicate-confidence strong {
  font-size: 15px;
}

.duplicate-confidence span {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 850;
}

.duplicate-contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.duplicate-contact-line {
  min-width: 0;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: #f8f7f3;
}

.duplicate-contact-line strong,
.duplicate-contact-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duplicate-contact-line strong {
  font-size: 13px;
}

.duplicate-contact-line span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.duplicate-group-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.duplicate-empty {
  min-height: 160px;
}

.merge-history-panel {
  margin: 0 24px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #faf9f6;
}

.merge-history-panel summary {
  padding: 15px 17px;
  cursor: pointer;
  font-weight: 900;
}

.merge-history-panel summary span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
}

.merge-history-list {
  border-top: 1px solid var(--line-soft);
}

.merge-history-row {
  min-height: 62px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.merge-history-row:last-child {
  border-bottom: 0;
}

.merge-history-row > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.merge-history-row strong {
  font-size: 13px;
}

.merge-history-row span,
.history-undone {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.merge-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  padding: 18px 24px 0;
}

.merge-source-card {
  position: relative;
  min-width: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf9f6;
}

.merge-source-card > input[data-merge-include] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.merge-source-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-right: 70px;
}

.merge-source-copy strong,
.merge-source-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-source-copy small {
  margin-top: 4px;
  color: var(--muted);
}

.merge-primary-choice {
  position: absolute;
  top: 11px;
  right: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.merge-primary-choice input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.merge-recalculate-row {
  margin: 12px 24px 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  background: #f1eff8;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.merge-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 24px 22px;
}

.merge-field {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #fff;
}

.merge-field.has-conflict {
  border-color: #ead6aa;
  background: #fffdf7;
}

.merge-field label {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 900;
}

.merge-field textarea {
  min-height: 76px;
}

.merge-conflict {
  color: #a36a25;
  font-size: 10px;
}

.merge-source-values {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.merge-source-values button {
  max-width: 100%;
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid #ddd8ef;
  border-radius: 8px;
  background: #f5f2ff;
  color: var(--purple-2);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
}

.merge-preserved-note {
  margin: 0 24px 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: #eef7ef;
  color: #3b6940;
}

.merge-preserved-note span {
  margin-top: 4px;
  font-size: 11px;
}

.sticky-merge-actions {
  position: sticky;
  bottom: 0;
  z-index: 8;
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(18px);
}

@media (max-width: 980px) {
  .quality-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quality-toolbar {
    grid-template-columns: 1fr;
    top: 84px;
  }

  .quality-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  .data-quality-modal,
  .merge-editor-modal {
    width: 100vw;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .quality-metrics,
  .duplicate-groups-list,
  .merge-source-grid,
  .merge-field-grid {
    padding-left: 14px;
    padding-right: 14px;
  }

  .quality-toolbar,
  .merge-history-panel,
  .merge-recalculate-row,
  .merge-preserved-note {
    margin-left: 14px;
    margin-right: 14px;
  }

  .merge-field-grid {
    grid-template-columns: 1fr;
  }

  .duplicate-group-head,
  .merge-recalculate-row {
    align-items: stretch;
    flex-direction: column;
  }

  .duplicate-confidence {
    align-items: flex-start;
  }

  .quality-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .top-search {
    grid-column: 1 / -1;
  }
}

.modal-shell:has(.data-quality-modal),
.modal-shell:has(.merge-editor-modal) {
  width: min(1228px, 100%);
  overflow: visible;
}

.modal-shell:has(.data-quality-modal) .data-quality-modal,
.modal-shell:has(.merge-editor-modal) .merge-editor-modal {
  width: 100%;
}

@media (max-width: 720px) {
  .modal-backdrop:has(.data-quality-modal),
  .modal-backdrop:has(.merge-editor-modal) {
    padding: 0;
  }

  .modal-shell:has(.data-quality-modal),
  .modal-shell:has(.merge-editor-modal) {
    width: 100%;
    max-height: 100vh;
  }
}

.merge-source-check {
  display: none;
}

.merge-source-copy {
  grid-column: 2;
  grid-row: 1;
}

/* Data management v3 */
.data-hub-modal {
  min-height: min(760px, calc(100vh - 48px));
}

.data-hub-header {
  padding-bottom: 12px;
}

.data-hub-tabs {
  display: flex;
  gap: 4px;
  padding: 0 26px 16px;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}

.data-hub-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 9px 15px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.data-hub-tabs button.active {
  color: var(--ink);
  background: var(--accent-soft);
}

#dataHubContent {
  min-height: 520px;
}

.hub-skeleton {
  padding: 24px 26px 32px;
}

.skeleton-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.skeleton-block,
.skeleton-line,
.skeleton-card span {
  display: block;
  border-radius: 12px;
  background: linear-gradient(90deg, #ecebf0 25%, #f7f6f9 45%, #ecebf0 65%);
  background-size: 240% 100%;
  animation: contact-skeleton 1.25s ease-in-out infinite;
}

.skeleton-block {
  height: 82px;
}

.skeleton-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 0 16px;
}

.skeleton-line {
  width: 220px;
  height: 38px;
}

.skeleton-line.wide {
  width: 420px;
}

.skeleton-list {
  display: grid;
  gap: 10px;
}

.skeleton-card {
  display: grid;
  grid-template-columns: 1fr 180px 90px;
  gap: 16px;
  align-items: center;
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
}

.skeleton-card span {
  height: 16px;
}

.skeleton-card span:first-child {
  height: 32px;
}

@keyframes contact-skeleton {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.inline-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #dedce8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate .75s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.import-progress {
  min-height: 84px;
  display: grid;
  place-items: center;
  color: transparent;
}

.import-preview-head {
  display: grid;
  gap: 16px;
}

.import-preview-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.import-preview-head > div:first-child span {
  color: var(--muted);
}

.import-preview-metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.import-preview-metrics button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
}

.import-preview-metrics button strong {
  font-size: 20px;
}

.import-preview-metrics button span {
  color: var(--muted);
  font-size: 12px;
}

.import-preview-toolbar,
.hub-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 14px;
}

.import-preview-toolbar input,
.hub-toolbar input {
  max-width: 340px;
}

.compact-tabs {
  flex-wrap: wrap;
}

.import-preview-table {
  display: grid;
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
}

.import-preview-row {
  display: grid;
  grid-template-columns: 52px 92px minmax(220px, 1.1fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.import-preview-row:last-child {
  border-bottom: 0;
}

.import-row-number,
.import-preview-detail {
  color: var(--muted);
  font-size: 12px;
}

.import-status-pill {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: #efedf5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.status-new .import-status-pill { background: #e7f5ea; color: #2c7140; }
.status-update .import-status-pill { background: #e9f2fb; color: #30668e; }
.status-conflict .import-status-pill { background: #fff0d8; color: #8a5d18; }
.status-error .import-status-pill { background: #fde9eb; color: #9c3845; }

.import-preview-contact {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-preview-contact strong,
.import-preview-contact small,
.import-preview-detail {
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-preview-contact small {
  color: var(--muted);
  white-space: nowrap;
}

.import-preview-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.sticky-import-actions {
  position: sticky;
  bottom: -1px;
  background: #fff;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.import-complete-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  border: 1px solid #dceadd;
  border-radius: 16px;
  background: #f4faf4;
}

.bulk-edit-modal {
  width: min(1050px, 100%);
}

.bulk-edit-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  padding: 0 2px;
}

.bulk-fields {
  display: grid;
  gap: 8px;
}

.bulk-field-row {
  display: grid;
  grid-template-columns: 22px 140px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fafafa;
}

.bulk-field-row > input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.bulk-operation-card {
  display: grid;
  grid-template-columns: 110px 120px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
}

.bulk-operation-card label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 750;
}

.bulk-operation-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.bulk-operation-card #bulkBadgeColor {
  grid-column: 2 / -1;
}

.bulk-lists-title {
  margin-top: 20px;
}

.bulk-list-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bulk-list-columns select {
  min-height: 122px;
  padding: 8px;
}

.hub-toolbar {
  padding: 18px 26px 0;
}

.hub-toolbar > span {
  color: var(--muted);
  font-size: 13px;
}

.company-grid,
.segment-grid,
.activity-list,
.trash-list {
  display: grid;
  gap: 10px;
  padding: 16px 26px 28px;
}

.company-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 70px;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.company-card:hover {
  transform: translateY(-1px);
  border-color: #cfc9eb;
  box-shadow: 0 10px 24px rgba(43, 38, 67, .08);
}

.company-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.company-card-main strong,
.company-card-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-card-main small {
  color: var(--muted);
}

.company-card-tags {
  display: flex;
  gap: 5px;
}

.company-card-tags b {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 11px;
}

.company-card-count {
  justify-self: end;
  font-weight: 850;
  font-size: 18px;
}

.company-editor-modal {
  width: min(1160px, 100%);
  background: linear-gradient(180deg, #ffffff 0%, #fcfbff 100%);
}

.company-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .8fr);
  gap: 24px;
}

.company-profile-form,
.company-people-panel {
  min-width: 0;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}

.company-events {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.company-event-row {
  display: grid;
  grid-template-columns: 1.2fr 150px 1fr 34px;
  gap: 8px;
  align-items: center;
}

.company-people-panel {
  padding-left: 20px;
  border-left: 1px solid var(--line-soft);
}

.company-people-list,
.company-mini-history {
  display: grid;
  gap: 7px;
  max-height: 300px;
  overflow: auto;
  margin-top: 10px;
}

.company-people-list button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
}

.company-people-list button span,
.company-mini-history span {
  color: var(--muted);
  font-size: 12px;
}

.company-history-title {
  margin-top: 22px;
}

.company-mini-history > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.segment-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
}

.segment-card > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.segment-card span {
  color: var(--muted);
  font-size: 12px;
}

.segment-card > b {
  font-size: 20px;
  text-align: right;
}

.segment-card-actions {
  display: flex;
  gap: 6px;
}

.segment-editor-modal {
  width: min(760px, 100%);
}

.activity-row,
.trash-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
}

.activity-row > div,
.trash-row > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.activity-row small,
.trash-row span,
.trash-row small,
.activity-row > span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.trash-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.contact-history-modal {
  width: min(860px, 100%);
}

.contact-history-list {
  max-height: 65vh;
  overflow: auto;
}

.history-icon {
  font-size: 17px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 12px;
}

.permission-grid input {
  width: 16px;
  height: 16px;
}

.admin-permission-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.compact-only {
  justify-content: flex-end;
}

.compact-preserved {
  min-height: auto;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .skeleton-metrics,
  .import-preview-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .bulk-edit-grid,
  .company-editor-grid {
    grid-template-columns: 1fr;
  }

  .company-people-panel {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-top: 18px;
  }

  .import-preview-row {
    grid-template-columns: 44px 82px minmax(0, 1fr);
  }

  .import-preview-detail {
    grid-column: 3;
  }
}

@media (max-width: 640px) {
  .data-hub-tabs,
  .hub-toolbar,
  .company-grid,
  .segment-grid,
  .activity-list,
  .trash-list {
    padding-left: 14px;
    padding-right: 14px;
  }

  .skeleton-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .skeleton-card {
    grid-template-columns: 1fr;
  }

  .import-preview-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .import-preview-toolbar,
  .hub-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .import-preview-toolbar input,
  .hub-toolbar input {
    max-width: none;
  }

  .import-preview-row {
    grid-template-columns: 38px 78px minmax(0, 1fr);
    padding: 10px;
  }

  .company-card,
  .segment-card,
  .activity-row,
  .trash-row {
    grid-template-columns: 1fr;
  }

  .company-card-count,
  .segment-card > b {
    justify-self: start;
    text-align: left;
  }

  .company-event-row,
  .bulk-field-row,
  .bulk-operation-card,
  .bulk-list-columns {
    grid-template-columns: 1fr;
  }

  .bulk-field-row > input[type="checkbox"] {
    position: absolute;
  }

  .permission-grid {
    grid-template-columns: 1fr;
  }
}

/* Keep the data-management workspace visually separate from the page below. */
.data-quality-modal,
.data-hub-modal,
.merge-editor-modal,
.bulk-edit-modal,
.company-editor-modal,
.segment-editor-modal,
.contact-history-modal,
.wide-import-modal-card {
  background: #fff;
  opacity: 1;
  isolation: isolate;
}

.modal-backdrop:has(.data-quality-modal),
.modal-backdrop:has(.merge-editor-modal),
.modal-backdrop:has(.bulk-edit-modal),
.modal-backdrop:has(.company-editor-modal),
.modal-backdrop:has(.segment-editor-modal),
.modal-backdrop:has(.contact-history-modal),
.modal-backdrop:has(.wide-import-modal-card) {
  background: rgba(24, 22, 34, .64);
}

/* Contact workspace v5 — smoother modal updates and a softer, more polished look */
.modal-shell-swapping {
  animation: modalShellSwap .14s ease both;
}

@keyframes modalShellSwap {
  from { opacity: .78; transform: scale(.995); }
  to { opacity: 1; transform: scale(1); }
}

.modal-shell:has(.company-editor-modal) {
  width: min(1160px, calc(100vw - 56px));
}

/* Contact workspace v4 — calmer CRM-style layout and stable tab transitions */
.modal-shell:has(.data-hub-modal) {
  width: min(1240px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.modal-shell:has(.data-hub-modal) .data-hub-modal {
  width: 100%;
}

.data-hub-modal {
  height: min(820px, calc(100vh - 48px));
  min-height: 620px;
  padding: 0;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(222, 221, 229, .9);
  border-radius: 24px;
  background: linear-gradient(180deg, #fff 0%, #fcfbff 100%);
  box-shadow: 0 34px 96px rgba(24, 22, 34, .20);
}

.data-hub-header {
  position: relative;
  inset: auto;
  z-index: 10;
  min-height: 68px;
  margin: 0;
  padding: 0 18px 0 24px;
  align-items: center;
  border-bottom: 1px solid #e9e7ed;
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(18px);
}

.data-hub-header .modal-title {
  font-size: 19px;
  letter-spacing: -.02em;
}

.data-hub-header .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: #f4f3f1;
}

.data-hub-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  background: #fbfbfa;
}

.data-hub-tabs {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px;
  border: 0;
  border-right: 1px solid #e7e5eb;
  background: linear-gradient(180deg, #f6f3fb 0%, #fbfaf7 100%);
  overflow: hidden auto;
}

.data-hub-tabs button {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #6f6a7c;
  font-size: 13px;
  font-weight: 790;
  text-align: left;
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.data-hub-tabs button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, .68);
}

.data-hub-tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, #312a47 0%, #5f53a7 100%);
  box-shadow: 0 12px 24px rgba(48, 42, 69, .18);
}

.data-hub-tabs button:active {
  transform: scale(.985);
}

.data-hub-tabs svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.data-hub-tabs b {
  min-width: 25px;
  height: 22px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(48, 42, 69, .08);
  color: inherit;
  font-size: 10px;
  font-weight: 850;
}

.data-hub-tabs button.active b {
  background: rgba(255, 255, 255, .17);
}

#dataHubContent {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #fcfbff 0%, #fafaf8 100%);
  scrollbar-gutter: stable;
  transition: opacity .14s ease, transform .14s ease;
}

#dataHubContent.hub-content-switching {
  opacity: .72;
  transform: translateY(2px);
}

#dataHubContent.hub-content-ready > * {
  animation: dataHubContentIn .22s cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes dataHubContentIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-skeleton {
  padding: 26px 28px 34px;
}

.skeleton-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.skeleton-heading span,
.skeleton-line,
.skeleton-card span {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, #eceaf0 22%, #f7f6f8 45%, #eceaf0 68%);
  background-size: 230% 100%;
  animation: contact-skeleton 1.05s ease-in-out infinite;
}

.skeleton-heading span:first-child {
  width: 230px;
  height: 28px;
}

.skeleton-heading span:last-child {
  width: 170px;
  height: 28px;
}

.skeleton-toolbar {
  margin: 0 0 18px;
}

.skeleton-list {
  gap: 12px;
}

.skeleton-card {
  min-height: 132px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 96px;
  padding: 18px;
  border-color: #e9e7ec;
  border-radius: 18px;
  background: #fff;
}

.skeleton-card span:first-child {
  height: 58px;
}

.skeleton-card span:nth-child(2) {
  height: 58px;
}

.skeleton-card span:last-child {
  height: 34px;
}

.duplicates-overview {
  position: sticky;
  top: 0;
  z-index: 7;
  padding: 24px 28px 16px;
  border-bottom: 1px solid rgba(231, 229, 235, .92);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(18px);
}

.hub-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.hub-section-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -.035em;
}

.hub-section-heading > div:first-child > span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.quality-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quality-summary > span {
  min-height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #e4e1e8;
  border-radius: 999px;
  background: #fff;
  color: #6f6a7c;
  font-size: 11px;
  font-weight: 760;
}

.quality-summary > span.safe {
  border-color: #d4e8d6;
  background: #f1f8f1;
  color: #3d7242;
}

.quality-summary strong {
  color: inherit;
  font-size: 13px;
}

.quality-toolbar {
  position: static;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.quality-toolbar input {
  height: 38px;
  border-color: #e2e0e6;
  background: #fff;
}

.quality-tabs {
  min-height: 38px;
  padding: 3px;
  gap: 2px;
  border: 1px solid #e2e0e6;
  border-radius: 12px;
  background: #f0eef3;
}

.quality-tabs button {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 11px;
}

.quality-actions {
  gap: 7px;
}

.quality-actions .primary-btn,
.quality-actions .light-btn {
  min-height: 38px;
  padding-left: 13px;
  padding-right: 13px;
  border-radius: 11px;
  white-space: nowrap;
}

.duplicate-groups-list {
  gap: 12px;
  padding: 18px 28px 22px;
}

.duplicate-group-card {
  padding: 16px 17px 14px;
  border: 1px solid #ebe8f0;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff 0%, #fcfbff 100%);
  box-shadow: 0 10px 28px rgba(35, 33, 52, .05);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.duplicate-group-card:hover {
  border-color: #cec9de;
  box-shadow: 0 13px 30px rgba(35, 33, 52, .075);
  transform: translateY(-1px);
}

.duplicate-group-card.is-ready {
  border-left: 3px solid #9ac69e;
}

.duplicate-group-card.is-review {
  border-left: 3px solid #e7bd75;
}

.duplicate-group-head {
  align-items: center;
}

.duplicate-group-title-row {
  align-items: center;
  gap: 10px;
}

.duplicate-group-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.duplicate-group-heading strong {
  font-size: 14px;
  letter-spacing: -.01em;
}

.duplicate-record-count {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0eef4;
  color: #6e6879;
  font-size: 10px;
  font-weight: 820;
}

.duplicate-select {
  width: 20px;
  flex-basis: 20px;
}

.duplicate-select input {
  width: 17px;
  height: 17px;
  margin: 0;
}

.duplicate-confidence {
  min-width: auto;
  padding: 0;
  flex-direction: row;
  gap: 6px;
  align-items: baseline;
  background: transparent;
  color: #8b6730;
}

.duplicate-confidence.safe {
  background: transparent;
  color: #3d7643;
}

.duplicate-confidence strong {
  font-size: 14px;
}

.duplicate-confidence span {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.duplicate-reasons {
  gap: 10px;
  margin: 10px 0 0 30px;
}

.duplicate-reasons span {
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 0;
  background: transparent;
  color: #777180;
  font-size: 10px;
  font-weight: 720;
}

.duplicate-reasons i {
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #efedf5;
  color: #655b9d;
  font-size: 9px;
  font-style: normal;
}

.duplicate-contact-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 9px;
  margin-top: 13px;
}

.duplicate-contact-line {
  min-height: 76px;
  padding: 12px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  border: 1px solid #edeaf2;
  border-radius: 15px;
  background: #fff;
}

.duplicate-contact-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eae6f7;
  color: #4e466f;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
}

.duplicate-contact-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.duplicate-contact-copy strong,
.duplicate-contact-copy small,
.duplicate-contact-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duplicate-contact-copy strong {
  font-size: 13px;
}

.duplicate-contact-copy small {
  color: #5f596a;
  font-size: 10px;
  font-weight: 690;
}

.duplicate-contact-copy em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.duplicate-group-actions {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #efedf0;
}

.duplicate-group-actions .compact-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 11px;
}

.duplicate-dismiss-btn {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #746f7c;
}

.duplicate-dismiss-btn:hover {
  background: #f3f1f4;
  box-shadow: none;
}

.merge-history-panel {
  margin: 0 28px 28px;
  border-color: #e4e2e8;
  border-radius: 15px;
  background: #fff;
}

.merge-history-panel summary {
  padding: 13px 16px;
  font-size: 12px;
}

.hub-toolbar {
  margin: 0;
  padding: 24px 28px 0;
}

.company-grid,
.segment-grid,
.trash-list {
  padding: 16px 28px 30px;
}

@media (max-width: 900px) {
  .modal-shell:has(.data-hub-modal) {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .data-hub-modal {
    height: calc(100vh - 24px);
    min-height: 0;
  }

  .data-hub-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .data-hub-tabs {
    flex-direction: row;
    gap: 6px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #e7e5eb;
    overflow-x: auto;
  }

  .data-hub-tabs button {
    width: auto;
    min-width: max-content;
    min-height: 40px;
    grid-template-columns: 19px auto auto;
  }

  .data-hub-tabs svg {
    width: 18px;
    height: 18px;
  }

  .quality-toolbar {
    grid-template-columns: 1fr;
  }

  .quality-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .modal-backdrop:has(.data-hub-modal) {
    padding: 0;
  }

  .modal-shell:has(.data-hub-modal) {
    width: 100%;
    max-height: 100vh;
  }

  .data-hub-modal {
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .data-hub-header {
    min-height: 58px;
    padding: 0 12px 0 16px;
  }

  .data-hub-tabs button {
    padding: 0 10px;
  }

  .data-hub-tabs b {
    display: none;
  }

  .duplicates-overview {
    padding: 18px 14px 14px;
  }

  .hub-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .hub-section-heading h2 {
    font-size: 19px;
  }

  .quality-summary {
    width: 100%;
  }

  .quality-summary > span {
    flex: 1;
    justify-content: center;
  }

  .quality-tabs {
    width: 100%;
  }

  .quality-tabs button {
    flex: 1;
  }

  .quality-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .duplicate-groups-list {
    padding: 14px;
  }

  .duplicate-group-card {
    padding: 14px;
  }

  .duplicate-group-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .duplicate-reasons {
    margin-left: 0;
  }

  .duplicate-contact-list {
    grid-template-columns: 1fr;
  }

  .duplicate-group-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .merge-history-panel {
    margin: 0 14px 20px;
  }

  .hub-toolbar,
  .company-grid,
  .segment-grid,
  .trash-list {
    padding-left: 14px;
    padding-right: 14px;
  }
}


/* Company editor v6: stays inside Contact tools, with no modal recreation. */
#dataHubContent.hub-content-busy {
  cursor: progress;
}

.hub-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(252, 251, 255, .18);
  pointer-events: none;
  backdrop-filter: blur(1px);
}

.hub-loading-overlay span {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(101, 87, 174, .16);
  border-top-color: #6557ae;
  border-radius: 50%;
  animation: companyEditorSpin .7s linear infinite;
  box-shadow: 0 6px 18px rgba(60, 48, 110, .12);
}

@keyframes companyEditorSpin {
  to { transform: rotate(360deg); }
}

.company-editor-view {
  min-height: 100%;
  padding: 24px 28px 28px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 20px;
  background: linear-gradient(180deg, #fff 0%, #fcfbff 100%);
  animation: companyEditorViewIn .16s ease both;
}

@keyframes companyEditorViewIn {
  from { opacity: .76; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.company-editor-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid #ece9f1;
}

.company-editor-view-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -.025em;
}

.company-editor-view-header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.company-editor-back {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid #e4e0eb;
  border-radius: 11px;
  background: #fff;
  color: #5d5668;
  font-size: 12px;
  font-weight: 780;
  box-shadow: 0 5px 14px rgba(35, 33, 52, .04);
}

.company-editor-back:hover {
  border-color: #d3cce2;
  background: #f8f6fc;
  color: #342d47;
}

.company-editor-view .company-editor-grid {
  min-height: 0;
  align-content: start;
}

.company-editor-actions {
  position: sticky;
  bottom: -28px;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin: 0 -28px -28px;
  padding: 15px 28px;
  border-top: 1px solid #e9e6ee;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px);
}

.companies-toolbar {
  position: sticky;
  top: 0;
  z-index: 6;
  padding-bottom: 14px;
  background: rgba(252, 251, 255, .94);
  backdrop-filter: blur(14px);
}

@media (max-width: 760px) {
  .company-editor-view {
    padding: 18px;
  }

  .company-editor-view-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .company-editor-actions {
    bottom: -18px;
    margin: 0 -18px -18px;
    padding: 13px 18px;
  }
}
