.contacts-page {
  --contacts-blue: #2563eb;
  --contacts-green: #22c55e;
  --contacts-ink: var(--text, #171717);
  --contacts-muted: var(--text-secondary, #737373);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface, #fff);
}
.contacts-page.hidden { display: none; }

.contacts-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px 8px;
}
.contacts-header h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--contacts-ink);
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 600;
}
.contacts-header h1 svg { width: 20px; color: var(--contacts-blue); }
.contacts-header h1 span {
  font-family: "Geist", sans-serif;
  color: var(--contacts-muted);
  font-size: 14px;
  font-weight: 500;
}
.contacts-header p {
  margin: 3px 0 0;
  color: var(--contacts-muted);
  font-size: 13px;
}
.contacts-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.contacts-toolbar input,
.contacts-filters select,
.contacts-form input,
.contacts-form select,
.contacts-pane-head input {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 7px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.contacts-toolbar input { min-width: 240px; }
.contacts-toolbar input:focus,
.contacts-filters select:focus,
.contacts-form input:focus,
.contacts-form select:focus,
.contacts-pane-head input:focus {
  border-color: var(--contacts-blue);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 10%);
}

.contacts-viewbar {
  display: flex;
  align-items: stretch;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  overflow: hidden;
}
.contacts-viewtabs {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.contacts-viewtabs::-webkit-scrollbar { display: none; }
.contacts-view-tab,
.contacts-new-view,
.contacts-save-view {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 13px;
  border: 0;
  border-right: 1px solid var(--border, #e5e7eb);
  background: transparent;
  color: var(--contacts-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.contacts-view-tab:hover,
.contacts-new-view:hover { background: var(--surface-hover, #f7f7f7); color: var(--contacts-ink); }
.contacts-view-tab.is-active {
  color: var(--contacts-blue);
  font-weight: 650;
  box-shadow: inset 0 -2px var(--contacts-blue);
}
.contacts-view-tab small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  color: var(--contacts-muted);
  font-size: 15px;
}
.contacts-view-tab small:hover { background: rgb(0 0 0 / 6%); color: var(--contacts-ink); }
.contacts-new-view { margin-left: auto; border-left: 1px solid var(--border, #e5e7eb); }
.contacts-save-view {
  color: #92400e;
  background: #fef3c7;
  border: 0;
}
.contacts-save-view.hidden { display: none; }

.contacts-global-search {
  position: relative;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
}
.contacts-global-search > svg {
  position: absolute;
  left: 32px;
  width: 20px;
  height: 20px;
  color: #64748b;
  pointer-events: none;
}
.contacts-global-search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 150px 10px 48px;
  border: 1px solid #bdcbd6;
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 15px;
  outline: none;
  box-shadow: 0 1px 2px rgb(15 23 42 / 3%);
}
.contacts-global-search input:focus {
  border-color: var(--contacts-blue);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 12%);
}
.contacts-global-search > span {
  position: absolute;
  right: 32px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-hover, #f3f4f6);
  color: var(--contacts-muted);
  font-size: 11px;
  pointer-events: none;
}

.contacts-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
}
.contacts-filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.contacts-filters label > span {
  color: var(--contacts-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.contacts-filters select { min-width: 140px; }
#contactsRangeNote { align-self: center; color: var(--contacts-muted); font-size: 12px; }
#contactsArchivedBtn.is-active { color: #b45309; border-color: #f59e0b; background: #fffbeb; }

.contacts-advanced-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 1px solid #c7d2fe;
  background: #eef2ff;
}
.contacts-advanced-summary.hidden { display: none; }
.contacts-filter-chip {
  padding: 4px 9px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #fff;
  color: #3730a3;
  font-size: 12px;
}

.contacts-bulk {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
  box-shadow: 0 6px 18px rgb(15 23 42 / 8%);
}
.contacts-bulk.hidden { display: none; }
.contacts-bulk button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.contacts-bulk button svg { width: 14px; }
.contacts-bulk button:hover { background: var(--surface-hover, #f7f7f7); }
.contacts-bulk .contacts-bulk-primary { background: var(--contacts-green); border-color: var(--contacts-green); color: #fff; }
.contacts-bulk-spacer { flex: 1; }

.contacts-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 16px;
}
.contacts-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--contacts-ink);
  font-size: 12px;
}
.contacts-table.hidden { display: none; }
.contacts-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  min-width: 130px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface-sunken, #fafafa);
  color: #5f6368;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .035em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.contacts-table th:first-child { min-width: 40px; width: 40px; }
.contacts-table th[data-column="name"] { min-width: 290px; }
.contacts-table th[data-column="phone"] { min-width: 190px; }
.contacts-sort {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}
.contacts-sort:hover,
.contacts-sort.is-active { color: var(--contacts-blue); }
.contacts-table td {
  height: 40px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border, #eceff3);
  background: var(--surface, #fff);
  vertical-align: middle;
}
.contacts-table tr:hover td { background: var(--surface-hover, #fafafa); }
.contacts-table tbody tr { cursor: pointer; }
.contacts-table tbody tr:focus-visible {
  outline: 2px solid var(--contacts-blue);
  outline-offset: -2px;
}
.contacts-table .contacts-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.contacts-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0ecff;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 750;
}
.contacts-name strong {
  flex: 1;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contacts-name-edit {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--contacts-muted);
  cursor: pointer;
  opacity: 0;
}
.contacts-name-edit svg { width: 13px; height: 13px; }
.contacts-table tr:hover .contacts-name-edit,
.contacts-name-edit:focus-visible { opacity: 1; }
.contacts-name-edit:hover { background: #dbeafe; color: #1d4ed8; }
.contacts-phone-actions { display: flex; align-items: center; gap: 8px; }
.contacts-phone-actions button {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: transparent;
  color: #00b95a;
  cursor: pointer;
}
.contacts-phone-actions button + button { color: #0ea5e9; }
.contacts-phone-actions svg { width: 17px; height: 17px; }
.contacts-phone {
  padding: 3px 6px;
  border: 1px solid #a7c4b1;
  background: #f1fbf5;
  color: #159447;
  line-height: 1;
}
.contact-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 220px;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: #f1f3f5;
  color: #4b5563;
  font: inherit;
  font-size: 11px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.contact-pill { cursor: pointer; }
button.contact-pill:hover { box-shadow: 0 0 0 1px #94a3b8; }
.contact-pill.is-empty { color: #8b8f96; font-style: italic; font-weight: 450; }
.contact-pill.status-new { background: #dbeafe; color: #1d4ed8; }
.contact-pill.status-positive { background: #dcfce7; color: #166534; }
.contact-pill.status-pending { background: #fef3c7; color: #92400e; }
.contact-pill.status-negative { background: #fee2e2; color: #991b1b; }
.contacts-cell-text {
  display: block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contacts-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 180px;
  color: var(--contacts-muted);
}
.contacts-state.hidden { display: none; }
.contacts-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #dbeafe;
  border-top-color: var(--contacts-blue);
  border-radius: 50%;
  animation: contacts-spin .7s linear infinite;
}
@keyframes contacts-spin { to { transform: rotate(360deg); } }
.contacts-pager { display: flex; justify-content: center; padding: 10px; }

.contacts-modal,
.contacts-drawer {
  position: fixed;
  inset: 0;
  z-index: 220;
}
/* The Properties picker is opened FROM the record drawer (z-index 1400), so a
   modal has to outrank it — otherwise its buttons sit under the drawer and
   silently swallow every click. Inline editors (1500) still win over both. */
.contacts-modal { z-index: 1450; }
.contacts-modal.hidden,
.contacts-drawer.hidden { display: none; }
.contacts-modal-backdrop,
.contacts-drawer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgb(15 23 42 / 46%);
}
.contacts-modal-card {
  position: relative;
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 24px 80px rgb(15 23 42 / 22%);
  overflow: hidden;
}
.contacts-modal-wide { width: min(920px, calc(100vw - 32px)); }
.contacts-modal-card > header,
.contacts-modal-card > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
/* Opaque so nothing scrolls through it behind the buttons. */
.contacts-modal-card > footer { justify-content: flex-end; border-top: 1px solid var(--border, #e5e7eb); border-bottom: 0; background: var(--surface, #fff); }
.contacts-modal-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 20px;
}
.contacts-modal-card header > button,
.contacts-drawer header > button {
  display: inline-flex;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--contacts-muted);
  cursor: pointer;
}
.contacts-modal-card header > button:hover,
.contacts-drawer header > button:hover { background: rgb(0 0 0 / 6%); }

.contacts-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: min(560px, calc(100vh - 180px));
  background: var(--border, #e5e7eb);
  gap: 1px;
}
/* min-height: 0 — without it a flex column refuses to shrink past its content, so
   .contacts-column-list never scrolls: a long property list overflows the pane and
   paints straight over the modal footer (the Save button reads as unclickable). */
.contacts-columns-grid > section { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface, #fff); }
.contacts-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  color: var(--contacts-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.contacts-pane-head input { min-height: 30px; max-width: 180px; text-transform: none; }
.contacts-column-list { flex: 1; overflow: auto; padding: 7px; }
.contacts-column-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
}
.contacts-column-row:hover { border-color: var(--border, #e5e7eb); background: var(--surface-hover, #fafafa); }
.contacts-column-row span:first-child { flex: 1; }
.contacts-column-row small { color: var(--contacts-muted); }
.contacts-column-row button {
  border: 0;
  background: transparent;
  color: var(--contacts-muted);
  cursor: pointer;
}
.contacts-column-row button:hover { color: var(--contacts-blue); }
.contacts-column-group {
  padding: 9px 8px 3px;
  color: var(--contacts-muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.contacts-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.contacts-form label { display: flex; flex-direction: column; gap: 5px; }
.contacts-form label > span { color: var(--contacts-ink); font-size: 12px; font-weight: 650; }
.contacts-form input,
.contacts-form select { width: 100%; }
.contacts-form-error { margin: 0; color: #dc2626; font-size: 12px; }
.contacts-form-error.hidden { display: none; }

.contacts-drawer > aside {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  background: var(--surface, #fff);
  box-shadow: -8px 0 32px rgb(15 23 42 / 18%);
}
.contacts-drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #14b8a6, #10b981);
  color: #fff;
}
.contacts-drawer header h2 { margin: 0; font-size: 18px; }
.contacts-drawer header > button { color: #fff; }
.contacts-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 22px 20px 28px;
  background: var(--surface, #fff);
}
.contacts-drawer-body h3 {
  margin: 0 0 18px;
  color: var(--contacts-ink);
  font-size: 17px;
  font-weight: 750;
}
.contacts-drawer footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
}
.contacts-filter-groups {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.contacts-filter-group {
  overflow: visible;
  border: 1px solid #d7e2e9;
  border-radius: 15px;
  background: var(--surface, #fff);
  box-shadow: 0 1px 2px rgb(15 23 42 / 3%);
}
.contacts-drawer .contacts-filter-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 14px 18px;
  background: transparent;
  color: var(--contacts-ink);
}
.contacts-filter-group > header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
}
.contacts-filter-group-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.contacts-filter-group-actions button,
.contacts-filter-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #078da5;
  cursor: pointer;
}
.contacts-filter-group-actions button:hover,
.contacts-filter-remove:hover { background: #e7f5f7; }
.contacts-filter-group-actions svg,
.contacts-filter-remove svg { width: 17px; height: 17px; }
.contacts-filter-group-body {
  padding: 12px;
  border-radius: 0 0 15px 15px;
  background: #f4f7f9;
}
.contacts-filter-condition {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: start;
  padding: 0;
}
.contacts-filter-condition-controls {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}
.contacts-filter-control {
  min-width: 0;
  width: 100%;
  height: 43px;
  padding: 8px 12px;
  border: 1px solid #cbd8e1;
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.contacts-filter-control:focus {
  border-color: #00a4bd;
  box-shadow: 0 0 0 1px #00a4bd;
}
.contacts-property-picker {
  position: relative;
  min-width: 0;
  z-index: 12;
}
.contacts-property-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}
.contacts-property-trigger > span {
  overflow: hidden;
  flex: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contacts-property-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #078da5;
}
.contacts-property-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  overflow: hidden;
  border: 1px solid #b9cbd6;
  border-radius: 8px;
  background: var(--surface, #fff);
  box-shadow: 0 14px 34px rgb(15 23 42 / 22%);
}
.contacts-property-menu.hidden { display: none; }
.contacts-property-search {
  position: relative;
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #dbe4ea;
  background: var(--surface, #fff);
}
.contacts-property-search svg {
  position: absolute;
  left: 22px;
  width: 16px;
  height: 16px;
  color: #64748b;
  pointer-events: none;
}
.contacts-property-search input {
  width: 100%;
  height: 39px;
  padding: 7px 10px 7px 36px;
  border: 1px solid #aebfcb;
  border-radius: 5px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.contacts-property-search input:focus {
  border-color: #00a4bd;
  box-shadow: 0 0 0 1px #00a4bd;
}
.contacts-property-results {
  max-height: 310px;
  overflow-y: auto;
  padding: 5px;
}
.contacts-property-option {
  display: flex;
  width: 100%;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--contacts-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.contacts-property-option:hover,
.contacts-property-option.is-selected { background: #e7f5f7; }
.contacts-property-option strong { font-size: 13px; font-weight: 650; }
.contacts-property-option small { color: var(--contacts-muted); font-size: 10px; }
.contacts-property-no-results,
.contacts-property-more {
  padding: 16px 10px;
  color: var(--contacts-muted);
  font-size: 11px;
  text-align: center;
}
.contacts-property-more {
  padding: 9px 10px;
  border-top: 1px solid #e5edf1;
}
.contacts-filter-remove {
  margin-top: 4px;
  color: #078da5;
}
.contacts-filter-and {
  margin: 10px 0 9px 8px;
  color: var(--contacts-muted);
  font-size: 13px;
  font-weight: 650;
}
.contacts-filter-date-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 4px 4px;
  color: #536c7d;
  font-size: 11px;
  line-height: 1.4;
}
.contacts-filter-date-hint svg { width: 14px; height: 14px; color: #6d91a5; }
.contacts-filter-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid #b9d1df;
  border-radius: 5px;
  background: #eef5f8;
  color: #087e91;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.contacts-filter-add:hover,
.contacts-filter-add-group-row button:hover { background: #dff1f5; }
.contacts-filter-add svg,
.contacts-filter-add-group-row button svg { width: 14px; height: 14px; }
.contacts-filter-or {
  align-self: center;
  margin: -1px 0;
  padding: 10px 13px;
  border: 1px solid #d7e2e9;
  border-radius: 7px;
  background: var(--surface, #fff);
  color: var(--contacts-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
  z-index: 1;
}
.contacts-filter-add-group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0 12px;
}
.contacts-filter-add-group-row > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border: 1px solid #d7e2e9;
  border-radius: 7px;
  color: var(--contacts-muted);
  font-size: 12px;
  font-weight: 700;
}
.contacts-filter-add-group-row button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border: 1px solid #b9d1df;
  border-radius: 5px;
  background: #eef5f8;
  color: #087e91;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.contacts-filter-empty {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  border: 1px dashed #cbd8e1;
  border-radius: 12px;
  color: var(--contacts-muted);
  text-align: center;
}
.contacts-filter-empty svg { width: 24px; height: 24px; color: #00a4bd; }
.contacts-filter-empty strong { color: var(--contacts-ink); font-size: 13px; }
.contacts-filter-empty span { font-size: 11px; }
.contacts-filter-summary-or {
  color: #64748b;
  font-size: 10px;
  font-weight: 750;
}

.contacts-inline-editor {
  position: fixed;
  /* Above .contacts-record-layer (1400) — the About panel opens this editor too. */
  z-index: 1500;
  width: 260px;
  max-height: 360px;
  padding: 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 9px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 32px rgb(15 23 42 / 18%);
  overflow: auto;
}
.contacts-inline-editor input,
.contacts-inline-editor select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 12px;
}
.contacts-inline-editor button {
  width: 100%;
  margin-top: 5px;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-hover, #f5f5f5);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.contacts-inline-editor button:hover { background: #e0ecff; color: #1d4ed8; }
.contacts-inline-editor button.is-save { background: var(--contacts-blue); color: #fff; text-align: center; }

.contacts-record-layer {
  position: fixed;
  inset: 0;
  z-index: 1400;
}
.contacts-record-layer.hidden { display: none; }
.contacts-record-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgb(15 23 42 / 48%);
  backdrop-filter: blur(1px);
}
.contacts-record-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(840px, 94vw);
  background: var(--surface, #fff);
  box-shadow: -18px 0 56px rgb(15 23 42 / 24%);
  animation: contacts-record-in .18s ease-out;
}
@keyframes contacts-record-in {
  from { transform: translateX(24px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}
.contacts-record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-height: 104px;
  padding: 22px 28px 20px;
  background: linear-gradient(120deg, #0596a6 0%, #0ab8aa 100%);
  color: #fff;
}
.contacts-record-header > div { min-width: 0; }
.contacts-record-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: rgb(255 255 255 / 72%);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .11em;
}
.contacts-record-header h2 {
  margin: 0;
  overflow: hidden;
  font-family: "Fraunces", serif;
  font-size: 24px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contacts-record-header p {
  margin: 5px 0 0;
  color: rgb(255 255 255 / 80%);
  font-size: 12px;
}
.contacts-record-header > button {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.contacts-record-header > button:hover { background: rgb(255 255 255 / 14%); }
.contacts-record-header > button svg { width: 23px; height: 23px; }

.contacts-record-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border, #dbe2ea);
  background: var(--surface, #fff);
}
.contacts-record-tabs { display: flex; align-self: stretch; }
.contacts-record-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--contacts-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.contacts-record-tabs button svg { width: 16px; height: 16px; }
.contacts-record-tabs button:hover { color: #078aa0; }
.contacts-record-tabs button.is-active {
  border-bottom-color: #08a2b4;
  color: #087e91;
  font-weight: 700;
}
.contacts-record-hubspot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #078aa0;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}
.contacts-record-hubspot.hidden { display: none; }
.contacts-record-hubspot svg { width: 14px; height: 14px; }
.contacts-record-hubspot:hover { text-decoration: underline; }

.contacts-record-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.contacts-record-panel.hidden { display: none; }
.contacts-record-identity {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 26px 28px 18px;
}
.contacts-record-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #dff5f7;
  color: #087e91;
  font-size: 19px;
  font-weight: 800;
}
.contacts-record-identity h3 { margin: 0 0 3px; font-family: "Fraunces", serif; font-size: 25px; }
.contacts-record-identity p { margin: 0; color: var(--contacts-muted); font-size: 13px; }
.contacts-record-actions {
  display: flex;
  gap: 24px;
  padding: 0 28px 24px;
  border-bottom: 1px solid var(--border, #dbe2ea);
}
.contacts-record-actions button,
.contacts-record-actions a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid #c8d9e5;
  border-radius: 999px;
  background: #f5fafc;
  color: #31516b;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.contacts-record-actions button:hover,
.contacts-record-actions a:hover { border-color: #08a2b4; background: #ecfeff; color: #087e91; }
.contacts-record-actions svg { width: 15px; height: 15px; }
.contacts-record-about { padding: 24px 28px 38px; }
.contacts-record-about > h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 20px;
  font-size: 16px;
}
.contacts-record-about > h3 svg { width: 18px; color: #078aa0; }
.contacts-record-about dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 32px;
  margin: 0;
}
.contacts-record-field { min-width: 0; }
.contacts-record-field dt {
  margin-bottom: 5px;
  color: #52708c;
  font-size: 11px;
  font-weight: 650;
}
.contacts-record-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--contacts-ink);
  font-size: 14px;
}
.contacts-record-field dd.is-empty { color: #9aa8b5; }
/* Editable values: the affordance only shows on hover/focus so the panel still
   reads as a record, not a form. Read-only props (HubSpot-calculated) get none. */
.contacts-record-field dd.is-editable {
  margin: -3px -7px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.contacts-record-field dd.is-editable:hover,
.contacts-record-field dd.is-editable:focus-visible {
  border-color: #08a2b4;
  background: #ecfeff;
  outline: none;
}
.contacts-record-about > h3 .contacts-fields-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 11px;
  border: 1px solid var(--contacts-line, #dbe3ea);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--contacts-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.contacts-record-about > h3 .contacts-fields-btn:hover {
  border-color: #08a2b4;
  background: #ecfeff;
  color: #087e91;
}
.contacts-record-about > h3 .contacts-fields-btn svg { width: 14px; }
[data-theme="dark"] .contacts-record-field dd.is-editable:hover,
[data-theme="dark"] .contacts-record-field dd.is-editable:focus-visible {
  border-color: #2f7d8c;
  background: rgba(8, 162, 180, .14);
}
[data-theme="dark"] .contacts-record-about > h3 .contacts-fields-btn:hover {
  border-color: #2f7d8c;
  background: rgba(8, 162, 180, .16);
  color: #7fd7e4;
}

.contacts-record-history-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.contacts-history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
}
.contacts-history-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 60%);
  padding: 8px 11px;
  border: 1px solid #b8cad8;
  border-radius: 6px;
  background: var(--surface, #fff);
}
.contacts-history-search:focus-within {
  border-color: #08a2b4;
  box-shadow: 0 0 0 3px rgb(8 162 180 / 11%);
}
.contacts-history-search svg { width: 16px; color: #6b8398; }
.contacts-history-search input {
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--contacts-ink);
  font: inherit;
  font-size: 13px;
}
.contacts-history-meta { display: flex; align-items: center; gap: 9px; color: var(--contacts-muted); font-size: 11px; }
.contacts-history-meta button {
  display: inline-flex;
  padding: 6px;
  border: 1px solid var(--border, #dbe2ea);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: #52708c;
  cursor: pointer;
}
.contacts-history-meta button:hover { border-color: #08a2b4; color: #087e91; }
.contacts-history-meta button svg { width: 15px; height: 15px; }
.contacts-history-table-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 24px;
  border: 1px solid #d5e0e8;
  overflow: auto;
}
.contacts-history-table {
  width: 100%;
  border-collapse: collapse;
  color: #2d455b;
  font-size: 12px;
  table-layout: fixed;
}
.contacts-history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  border-bottom: 1px solid #c9d7e1;
  background: #eaf1f6;
  color: #344b5f;
  font-size: 10px;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
}
.contacts-history-table th:nth-child(1) { width: 25%; }
.contacts-history-table th:nth-child(2) { width: 31%; }
.contacts-history-table th:nth-child(3) { width: 22%; }
.contacts-history-table th:nth-child(4) { width: 22%; }
.contacts-history-table td {
  padding: 15px 14px;
  border-bottom: 1px solid #dce5eb;
  background: var(--surface, #fff);
  line-height: 1.35;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.contacts-history-table tr:last-child td { border-bottom: 0; }
.contacts-history-table tr:hover td { background: #f1fbfc; }
.contacts-history-property strong { display: block; color: #2d455b; font-weight: 650; }
.contacts-history-property small { display: block; margin-top: 3px; color: #8a9baa; font-size: 10px; }
.contacts-history-value { color: #263d51; }
.contacts-history-source strong { display: block; color: #3f5d77; font-weight: 550; }
.contacts-history-source small { display: block; margin-top: 3px; color: #8798a8; font-size: 10px; }
.contacts-history-date { color: #3f5d77; }
.contacts-history-date small { display: block; margin-top: 2px; color: #8094a6; font-size: 10px; }
.contacts-history-state {
  position: absolute;
  inset: 39px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 220px;
  padding: 24px;
  background: var(--surface, #fff);
  color: #52708c;
  text-align: left;
}
.contacts-history-state.hidden { display: none; }
.contacts-history-state > svg { width: 25px; color: #08a2b4; }
.contacts-history-state strong,
.contacts-history-state small { display: block; }
.contacts-history-state strong { margin-bottom: 3px; color: var(--contacts-ink); font-size: 13px; }
.contacts-history-state small { font-size: 11px; }
.contacts-history-error { color: #b91c1c; text-align: center; }
.contacts-history-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px 18px;
  color: var(--contacts-muted);
  font-size: 11px;
}
.contacts-history-pager > div { display: flex; align-items: center; gap: 9px; }
.contacts-history-pager button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: #087e91;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.contacts-history-pager button:disabled { color: #aebac4; cursor: default; }
.contacts-history-pager button svg { width: 14px; }
.contacts-history-pager strong {
  padding: 5px 8px;
  border: 1px solid #a8d9df;
  border-radius: 5px;
  background: #eafdff;
  color: #087e91;
  font-size: 11px;
}

[data-theme="dark"] .contacts-advanced-summary { background: #20253d; border-color: #3d4778; }
[data-theme="dark"] .contacts-filter-chip { background: #272b3d; border-color: #3d4778; color: #c7d2fe; }
[data-theme="dark"] .contacts-filter-group,
[data-theme="dark"] .contacts-filter-or,
[data-theme="dark"] .contacts-filter-add-group-row > span { border-color: #41515d; }
[data-theme="dark"] .contacts-filter-group-body { background: #202930; }
[data-theme="dark"] .contacts-filter-control { border-color: #4b5c68; background: #172027; }
[data-theme="dark"] .contacts-global-search input,
[data-theme="dark"] .contacts-property-menu,
[data-theme="dark"] .contacts-property-search,
[data-theme="dark"] .contacts-property-search input { border-color: #4b5c68; background: #172027; }
[data-theme="dark"] .contacts-property-search { border-bottom-color: #41515d; }
[data-theme="dark"] .contacts-property-option:hover,
[data-theme="dark"] .contacts-property-option.is-selected { background: #17343a; }
[data-theme="dark"] .contacts-property-more { border-top-color: #41515d; }
[data-theme="dark"] .contacts-filter-add,
[data-theme="dark"] .contacts-filter-add-group-row button { border-color: #356b76; background: #17343a; color: #7dd3df; }
[data-theme="dark"] .contacts-filter-group-actions button:hover,
[data-theme="dark"] .contacts-filter-remove:hover { background: #17343a; }
[data-theme="dark"] .contacts-filter-date-hint { color: #a9bac5; }
[data-theme="dark"] .contacts-filter-empty { border-color: #41515d; }
[data-theme="dark"] .contacts-phone { background: #10251a; }
[data-theme="dark"] .contact-pill { background: #2a2d32; color: #d4d4d8; }
[data-theme="dark"] .contacts-view-tab.is-active { color: #93c5fd; }
[data-theme="dark"] .contacts-history-table th { background: #252d35; color: #d6e0e8; }
[data-theme="dark"] .contacts-history-table td { color: #d6e0e8; }
[data-theme="dark"] .contacts-history-table tr:hover td { background: #182f33; }
[data-theme="dark"] .contacts-history-property strong,
[data-theme="dark"] .contacts-history-value,
[data-theme="dark"] .contacts-history-source strong,
[data-theme="dark"] .contacts-history-date { color: #e4edf3; }
[data-theme="dark"] .contacts-record-actions button,
[data-theme="dark"] .contacts-record-actions a { background: #25323b; border-color: #41525f; color: #d6e0e8; }

@media (max-width: 900px) {
  .contacts-header { flex-direction: column; }
  .contacts-toolbar { width: 100%; }
  .contacts-toolbar input { flex: 1; min-width: 190px; }
  .contacts-global-search input { padding-right: 48px; }
  .contacts-global-search > span { display: none; }
  .contacts-columns-grid { grid-template-columns: 1fr; height: min(650px, calc(100vh - 180px)); }
  .contacts-columns-grid > section { min-height: 260px; }
  .contacts-drawer-body { padding: 18px 14px 24px; }
  .contacts-filter-condition { grid-template-columns: minmax(0, 1fr) 32px; gap: 5px; }
  .contacts-record-drawer { width: min(760px, 100vw); }
  .contacts-record-header { padding: 18px 20px; }
  .contacts-record-nav { padding: 0 12px; }
  .contacts-record-tabs button { padding: 0 10px; }
  .contacts-record-hubspot { font-size: 0; }
  .contacts-record-hubspot svg { width: 17px; height: 17px; }
  .contacts-history-controls { align-items: stretch; flex-direction: column; padding: 14px; }
  .contacts-history-search { width: 100%; }
  .contacts-history-meta { justify-content: space-between; }
  .contacts-history-table-wrap { margin: 0 14px; }
  .contacts-history-table { min-width: 660px; }
  .contacts-history-pager { padding: 12px 14px; }
  .contacts-record-about dl { grid-template-columns: 1fr; }
}
