:root {
  --bg: #f7f6f3;
  --bg-sidebar: #fbfbfa;
  --surface: #ffffff;
  --text: #37352f;
  --text-secondary: rgba(55, 53, 47, 0.65);
  --text-tertiary: rgba(55, 53, 47, 0.45);
  --border: rgba(55, 53, 47, 0.09);
  --border-strong: rgba(55, 53, 47, 0.16);
  --hover: rgba(55, 53, 47, 0.06);
  --active: rgba(55, 53, 47, 0.08);
  --primary: #2383e2;
  --primary-hover: #1a73d1;
  --danger: #eb5757;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 15, 15, 0.12);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--primary);
}

/* ── App shell (Notion-like sidebar) ── */

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 14px;
  font-weight: 600;
  font-size: 14px;
}

.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.brand-icon {
  display: block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-config {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: auto;
}

.nav-section {
  margin: 8px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.12s ease;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nav-item.active .nav-count {
  color: var(--text-secondary);
}

.nav-button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.sidebar-user-link {
  display: block;
  padding: 6px 10px 10px;
  margin: 0 4px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background 0.12s ease;
}

.sidebar-user-link:hover {
  background: var(--hover);
}

.sidebar-user-link.active {
  background: var(--active);
}

.sidebar-user-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-user-email {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 48px 64px;
  max-width: 1400px;
}

/* ── Page header ── */

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

.page-header h1 {
  margin: 4px 0 6px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-title-icon {
  font-size: 1.75rem !important;
}

.breadcrumb {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.breadcrumb-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-link:hover {
  color: var(--text);
}

.page-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.title-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Toolbar & search ── */

.toolbar {
  margin-bottom: 16px;
}

.search-form {
  position: relative;
  margin-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
  flex-shrink: 0;
}

.search-form .search-input {
  width: 100%;
  padding: 8px 36px 8px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.search-form .search-input:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.search-form .search-input::placeholder {
  color: var(--text-tertiary);
}

.search-form .search-input::-webkit-search-cancel-button,
.search-form .search-input::-webkit-search-decoration {
  -webkit-appearance: none;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-tertiary);
}

.search-clear:hover {
  background: var(--hover);
  color: var(--text);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.filter-chips-sortable {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chips-reorderable .chip-draggable {
  cursor: grab;
  user-select: none;
}

.filter-chips-reorderable .chip-draggable:active {
  cursor: grabbing;
}

.chip-dragging {
  opacity: 0.45;
}

.chip-drag-handle {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1;
  letter-spacing: -0.08em;
}

.chip-count {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.chip-active .chip-count {
  color: var(--text-secondary);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.12s ease;
}

.chip:hover {
  background: var(--hover);
  color: var(--text);
}

.chip-active {
  background: var(--active);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 500;
}

/* ── Database table (Notion DB view) ── */

.leads-table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.leads-status-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.leads-status-mobile-select {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
}

.leads-status-select-wrap {
  position: relative;
}

.leads-status-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.leads-status-select-trigger:hover {
  border-color: var(--border-strong);
}

.leads-status-select-trigger:focus-visible {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.leads-status-select-preview {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.leads-status-select-preview .tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leads-status-select-all {
  background: var(--hover);
  color: var(--text-secondary);
}

.leads-status-select-chevron {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.leads-status-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1100;
  max-height: min(320px, 50vh);
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.leads-status-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.leads-status-select-option:hover,
.leads-status-select-option.is-selected {
  background: var(--hover);
}

.leads-status-select-option .tag {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leads-status-select-count {
  flex-shrink: 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.leads-status-filters-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.leads-status-filters-track {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.leads-status-filters-track .chip {
  flex-shrink: 0;
  max-width: none;
}

.chip-label {
  max-width: 220px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leads-status-filters-track .chip .status-dot,
.leads-status-filters-track .chip .chip-count {
  flex-shrink: 0;
}

.leads-status-overflow {
  position: relative;
  flex-shrink: 0;
}

.chip-overflow-trigger {
  cursor: pointer;
  white-space: nowrap;
}

.leads-status-overflow-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1100;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 24px));
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.leads-status-overflow-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
}

.leads-status-overflow-item:hover,
.leads-status-overflow-item.is-active {
  background: var(--hover);
  color: var(--text);
}

.leads-status-overflow-item.is-active {
  font-weight: 500;
}

.leads-table-controls-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.leads-table-controls .search-form {
  margin-bottom: 0;
  width: min(280px, 42vw);
  flex: 0 1 280px;
}

.leads-table-controls .search-form .search-input {
  padding-right: 10px;
}

.leads-table-controls .search-form:has(.search-clear) .search-input {
  padding-right: 34px;
}

.leads-table-settings-menu {
  position: relative;
  flex-shrink: 0;
}

.leads-table-settings-btn {
  position: relative;
  color: var(--text-tertiary);
}

.leads-table-settings-filter-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  border: 1.5px solid var(--bg);
  pointer-events: none;
}

.leads-table-settings-filter-dot[hidden] {
  display: none;
}

.leads-table-settings-btn:hover {
  color: var(--text-secondary);
}

.leads-table-settings-menu .notion-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  width: min(380px, calc(100vw - 24px));
}

.database {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.notion-popover {
  z-index: 1200;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.notion-popover-panel {
  display: flex;
  flex-direction: column;
}

.notion-popover-header {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.notion-popover-header-simple {
  grid-template-columns: 1fr;
}

.notion-popover-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.notion-popover-back,
.notion-popover-action {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.notion-popover-back:hover,
.notion-popover-action:hover {
  background: var(--hover);
  color: var(--text);
}

.notion-popover-action {
  color: var(--accent, #2383e2);
  white-space: nowrap;
}

.notion-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.notion-popover-item-label {
  flex: 1;
  min-width: 0;
}

.notion-popover-item-chevron {
  margin-left: auto;
}

.notion-popover-item:has(.notion-popover-item-meta) .notion-popover-item-chevron {
  margin-left: 0;
}

.notion-popover-item:hover {
  background: var(--hover);
}

.notion-popover-item-icon,
.notion-popover-item-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.notion-popover-item-meta {
  font-size: 12px;
  color: var(--primary);
  flex-shrink: 0;
}

.notion-filter-property-list {
  padding: 0;
}

.notion-filter-property-item {
  border-radius: 0;
}

.notion-filter-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
}

.notion-filter-option-row:hover {
  background: var(--hover);
}

.notion-filter-option-tag {
  flex: 1;
  min-width: 0;
}

.notion-popover-empty {
  margin: 0;
  padding: 16px 14px 18px;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.45;
}

.notion-popover-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notion-column-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.notion-column-row {
  display: grid;
  grid-template-columns: 18px 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
}

.notion-column-row:hover {
  background: var(--hover);
}

.notion-drag-handle {
  display: inline-flex;
  align-items: center;
  color: var(--text-tertiary);
  line-height: 1;
  cursor: grab;
  user-select: none;
}

.notion-drag-handle:active {
  cursor: grabbing;
}

.notion-column-dragging {
  opacity: 0.45;
}

.notion-column-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  background: rgba(55, 53, 47, 0.06);
}

.notion-column-type-text {
  font-weight: 600;
  letter-spacing: -0.04em;
}

.notion-column-label {
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notion-visibility-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.notion-visibility-toggle:hover {
  background: rgba(55, 53, 47, 0.08);
}

.notion-column-row.is-hidden-column .notion-visibility-toggle,
.notion-filter-option-row.is-hidden-column .notion-visibility-toggle {
  color: var(--text-tertiary);
  opacity: 0.45;
}

.database-scroll {
  overflow-x: auto;
}

.database-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.database-table thead th {
  text-align: left;
  padding: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 246, 243, 0.6);
  white-space: nowrap;
}

.database-table-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
  transition: color 0.1s ease, background 0.1s ease;
}

.database-table-sort-link:hover {
  color: var(--text-secondary);
  background: rgba(55, 53, 47, 0.04);
}

.database-table-sortable.is-sorted .database-table-sort-link {
  color: var(--text-secondary);
}

.database-table-sort-label {
  min-width: 0;
}

.database-table-sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  line-height: 1;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.database-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.database-row {
  cursor: pointer;
  transition: background 0.1s ease;
}

.leads-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(247, 246, 243, 0.5);
}

.leads-pagination-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.leads-pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.leads-page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.leads-page-size-select {
  width: auto;
  min-width: 72px;
  padding: 4px 8px;
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn,
.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pagination-btn:hover,
.pagination-page:hover {
  background: var(--hover);
  color: var(--text);
}

.pagination-page.is-current {
  background: var(--active);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

.pagination-btn.is-disabled,
.pagination-page.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pagination-ellipsis {
  min-width: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.database-row:hover {
  background: var(--hover);
}

.database-row.row-active {
  background: rgba(35, 131, 226, 0.08);
}

.database-row.row-active:hover {
  background: rgba(35, 131, 226, 0.1);
}

.database-row:last-child td {
  border-bottom: none;
}

/* ── Lead peek panel (Notion-style overlay) ── */

.lead-peek-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  visibility: hidden;
  pointer-events: none;
  z-index: 400;
}

.lead-peek-backdrop.visible {
  visibility: visible;
  pointer-events: auto;
}

.lead-peek {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 48px rgba(15, 15, 15, 0.12);
  z-index: 401;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  visibility: hidden;
}

.lead-peek.open {
  transform: translateX(0);
  visibility: visible;
}

.lead-peek-body {
  height: 100%;
}

.peek-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100vh;
}

.peek-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 28px 12px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.peek-close-btn {
  flex-shrink: 0;
  margin-top: 6px;
  color: var(--text-tertiary);
}

.peek-close-btn:hover {
  color: var(--text);
}

.peek-close-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.peek-header-body {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-left: 28px;
}

.peek-header-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}

.peek-header h2 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1.2;
}

.property-readonly {
  color: var(--text-secondary);
  font-size: 14px;
}

.peek-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.peek-header-actions .actions-menu {
  display: flex;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  line-height: 1;
}

.actions-menu {
  position: relative;
}

.actions-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 168px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
  z-index: 500;
}

.actions-menu-form {
  margin: 0;
}

.actions-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.actions-menu-item:hover {
  background: var(--hover);
}

.actions-menu-item-danger {
  color: var(--danger);
}

.actions-menu-item-danger:hover {
  background: rgba(235, 87, 87, 0.08);
}

.peek-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 32px 48px;
}

.peek-content .panel {
  margin-bottom: 12px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.panel-compact {
  padding: 14px 16px;
}

.peek-content .panel-compact {
  padding: 0;
}

.panel-compact .property {
  grid-template-columns: 200px 1fr;
  padding: 8px 0;
}

.peek-content .page-grid {
  gap: 12px;
}

body.lead-peek-open {
  overflow: hidden;
}

/* ── Mobile top bar & burger (hidden on desktop) ── */

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.burger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.row-title-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-title {
  font-weight: 500;
  color: var(--text);
}

.row-title:hover {
  color: var(--primary);
}

.lead-row-nuevo .row-title {
  font-weight: 600;
  color: #1a1917;
}

.lead-row-nuevo td[data-label="Email"],
.lead-row-nuevo td[data-label="Teléfono"] {
  font-weight: 600;
  color: #1a1917;
  font-size: 13px;
}

.cell-muted {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Status tags (Notion select style) ── */

.tag,
.status-dot {
  display: inline-block;
}

.tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-nuevo, .status-nuevo { background: #ddebf1; color: #28456c; }
.status-nuevo { background: #6b9cb8; }
.tag-contactado, .status-contactado { background: #fadec9; color: #712b12; }
.status-contactado { background: #d9730d; }
.tag-en_conversacion, .status-en_conversacion { background: #e8deee; color: #412454; }
.status-en_conversacion { background: #9065b0; }
.tag-cerrado, .status-cerrado { background: #dbeddb; color: #1c3829; }
.status-cerrado { background: #448361; }
.tag-perdido, .status-perdido { background: #ffe2dd; color: #6e3630; }
.status-perdido { background: #d44c47; }
.tag-historico_pd, .status-historico_pd { background: #e3e2e0; color: #44403c; }
.status-historico_pd { background: #9b9a97; }

/* ── Detail page panels ── */

.page-grid {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.panel-narrow {
  max-width: 560px;
}

/* ── App modal ── */

.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 15, 15, 0.35);
}

.app-modal-backdrop:not(.visible) {
  display: none;
}

.property-option-add-modal {
  z-index: 700;
}

.property-option-add-modal .field + .field,
.property-option-add-modal .field + .color-tag-select {
  margin-top: 12px;
}

.app-modal {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px 24px 16px;
}

.app-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.app-modal-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.app-modal-body {
  margin-top: 16px;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.export-status-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.export-status-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(50vh, 320px);
  overflow-y: auto;
}

.export-status-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
}

.export-status-option:hover {
  background: var(--hover);
}

.export-status-option input {
  margin: 0;
  flex-shrink: 0;
}

.export-status-label {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

.export-status-count {
  font-size: 12px;
  color: var(--text-tertiary);
}

.export-status-error {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.panel-import {
  max-width: min(100%, 1040px);
}

.import-preview-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.import-header-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

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

.form-grid .field {
  margin-bottom: 14px;
}

.textarea-sm {
  min-height: 72px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.properties {
  margin: 0 0 20px;
  display: grid;
  gap: 0;
}

.property {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.property:last-child {
  border-bottom: none;
}

.property-full {
  grid-template-columns: 1fr;
  gap: 6px;
}

.panel-compact .property.property-full {
  grid-template-columns: 1fr;
}

.property dt {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  padding-top: 1px;
}

.property dd {
  margin: 0;
  font-size: 14px;
}

.properties-form .property-field dd input,
.properties-form .property-field dd select,
.properties-form .property-field dd textarea {
  width: 100%;
  margin: 0;
}

.properties-form .property-field dt label {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.property-editable .property-value {
  position: relative;
  border-radius: 4px;
  cursor: pointer;
}

.property-editable.is-editing .property-display.is-hidden {
  visibility: hidden;
}

.property-empty {
  color: var(--text-tertiary);
  font-style: italic;
}

.property-popover {
  display: none;
  position: fixed;
  z-index: 600;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(15, 15, 15, 0.14);
}

.property-popover.is-open {
  display: block;
}

.property-popover-float {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.property-popover .property-input {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.property-popover .property-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.property-popover-float .property-input {
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
}

.property-popover-float .property-input:focus {
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
}

.property-popover-textarea .property-textarea {
  min-height: 0 !important;
  height: auto;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
  vertical-align: top;
  text-align: left;
  field-sizing: content;
  padding: 8px 10px;
  box-sizing: border-box;
}

.property-status-menu.is-open {
  display: grid;
  padding: 4px;
  gap: 2px;
}

.status-menu-sortable {
  display: grid;
  gap: 2px;
}

.status-menu-reorder-hint {
  margin: 0;
  padding: 4px 8px 2px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.status-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.property-status-menu-reorderable .status-option-draggable {
  gap: 6px;
}

.status-option-drag-handle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-tertiary);
  line-height: 1;
  cursor: grab;
  user-select: none;
}

.status-option-drag-handle:active {
  cursor: grabbing;
}

.status-option-dragging {
  opacity: 0.45;
}

.status-option:hover,
.status-option.is-selected {
  background: var(--hover);
}

.property-select-options {
  display: grid;
  gap: 2px;
}

.property-select-add-option {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 8px 8px 6px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 4px 4px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.property-select-add-option:hover {
  color: var(--text-secondary);
  background: var(--hover);
}

.lead-title-editable {
  display: inline-block;
  min-width: 1ch;
  cursor: text;
  outline: none;
  border-radius: 4px;
}

.peek-header h2 .lead-title-editable {
  max-width: 100%;
}

.property-text {
  display: block;
  line-height: 1.5;
  text-align: left;
  vertical-align: top;
}

.property-editable[data-field="message"] .property-value,
.property-editable[data-field="message"] .property-display {
  display: block;
  align-self: start;
  min-height: 0;
}

.property-grid {
  display: grid;
  gap: 8px;
}

.property-kv {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
}

.kv-key {
  color: var(--text-tertiary);
  min-width: 100px;
}

.kv-value {
  color: var(--text);
}

/* ── Notes ── */

.notes-list {
  margin-bottom: 20px;
}

.note-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 8px;
  border: 1px solid transparent;
}

.note-card:hover {
  border-color: var(--border);
}

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.note-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.note-actions-menu {
  flex-shrink: 0;
}

.note-author {
  font-weight: 500;
  color: var(--text-secondary);
}

.note-meta-sep {
  opacity: 0.7;
}

.note-card-meta time {
  font-size: inherit;
  color: inherit;
}

.note-card p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty-inline {
  color: var(--text-secondary);
  margin: 0 0 16px;
  font-size: 14px;
}

/* ── Forms ── */

.field {
  margin-bottom: 14px;
}

.form-label,
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
.select,
.textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.inline-form,
.status-field {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.status-field .select {
  max-width: 280px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-row .select {
  flex: 1;
  margin-bottom: 0;
}

.note-form .textarea {
  margin-bottom: 12px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--hover);
  color: var(--text);
}

.btn-block {
  width: 100%;
  padding: 10px 12px;
}

/* ── Login ── */

.login-page {
  background: var(--bg);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-stack {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-sm);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 4px;
}

.login-logo {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.login-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
  line-height: 1.4;
}

.login-form .field:last-of-type {
  margin-bottom: 20px;
}

.login-forgot-link {
  display: block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
  text-decoration: none;
  text-align: center;
}

.login-forgot-link:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}

.auth-back-link:hover {
  color: var(--text);
}

.auth-success-state {
  text-align: center;
}

.auth-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: #dbeddb;
  color: #1c3829;
}

.auth-success-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.auth-success-text {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.auth-success-hint {
  margin: 0 0 20px;
  color: var(--text-tertiary, #9b9a97);
  font-size: 13px;
  text-align: left;
}

.auth-secondary-action {
  margin-top: 8px;
}

/* ── Alerts & empty states ── */

.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: #ffe2dd;
  color: #6e3630;
  border: 1px solid #ffc8c0;
}

.alert-success {
  background: #dbeddb;
  color: #1c3829;
  border: 1px solid #c2e0c2;
  margin-bottom: 16px;
}

.alert-warning {
  background: #fdecc8;
  color: #402c1b;
  border: 1px solid #f5d782;
  margin-bottom: 16px;
}

.alert-link {
  display: inline-block;
  margin-top: 6px;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.field-readonly {
  margin: 0;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.inline-test-form {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.panel-subtitle {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.status-settings-list {
  display: flex;
  flex-direction: column;
}

.status-settings-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.status-settings-row:last-child {
  border-bottom: none;
}

.status-settings-fields {
  flex: 1;
  margin-bottom: 0;
}

.status-settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.personalization-statuses .section-hint {
  margin-bottom: 10px;
}

.status-settings-compact {
  gap: 4px;
}

.status-settings-compact .status-settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 8px 10px;
  align-items: center;
  padding: 3px 0;
  border: none;
}

.status-settings-compact .status-settings-row-has-menu,
.status-settings-compact .status-settings-row-add {
  grid-template-columns: minmax(0, 1fr) 148px 32px;
}

.settings-row-actions-menu {
  justify-self: end;
}

.settings-row-actions-menu .actions-menu-trigger {
  color: var(--text-tertiary);
}

.property-def-row-has-menu {
  grid-template-columns: minmax(0, 1fr) auto 32px;
}

.status-settings-compact .status-settings-title-field,
.status-settings-compact .status-settings-color-field,
.status-settings-compact .status-settings-color-field .color-tag-select {
  margin: 0;
}

.status-settings-compact .status-settings-title-field label,
.status-settings-compact .status-settings-color-field label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-settings-compact .status-settings-title-field input[type="text"],
.personalization-section .property-def-field input[type="text"],
.personalization-section .property-add-row .status-settings-title-field input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.status-settings-compact .status-settings-title-field input[type="text"]:focus,
.personalization-section .property-def-field input[type="text"]:focus,
.personalization-section .property-add-row .status-settings-title-field input[type="text"]:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.status-settings-compact .color-tag-select-trigger {
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.status-settings-compact .color-tag-select-trigger:hover {
  border-color: var(--border-strong);
}

.status-settings-compact .color-tag-select-trigger:focus-visible {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.status-settings-compact .status-settings-delete {
  padding: 4px 8px;
  font-size: 12px;
}

.personalization-statuses .panel-subtitle-sm {
  margin-top: 14px;
  margin-bottom: 8px;
}

.personalization-statuses .status-add-form {
  margin: 0;
}

.status-save-toast {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #dbeddb;
  color: #1c3829;
  border: 1px solid #c2e0c2;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(15, 15, 15, 0.08);
}

.status-save-toast-error {
  background: #ffe2dd;
  color: #6e3630;
  border-color: #ffc8c0;
}

.log-type-badge {
  display: inline-block;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
}

.log-type-api {
  background: #e8e8e8;
  color: #37352f;
}

.log-type-email {
  background: #e8deee;
  color: #402c6d;
}

.log-email-kind {
  font-size: 13px;
  color: var(--text-secondary);
}

.log-email-detail .log-email-meta {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}

.log-email-detail .log-email-meta > div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  font-size: 13px;
}

.log-email-detail .log-email-meta dt {
  margin: 0;
  color: var(--text-tertiary);
}

.log-email-detail .log-email-meta dd {
  margin: 0;
}

.log-email-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #ffe2dd;
  color: #6e3630;
  font-size: 13px;
}

.log-detail-label {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.api-log-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.api-log-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.api-log-summary::-webkit-details-marker {
  display: none;
}

.api-log-method {
  display: inline-block;
  min-width: 52px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
}

.api-log-method-get { background: #ddebf1; color: #28456c; }
.api-log-method-post { background: #dbeddb; color: #1c3829; }
.api-log-method-patch { background: #fadec9; color: #712b12; }
.api-log-method-delete { background: #ffe2dd; color: #6e3630; }

.api-log-status {
  display: inline-block;
  min-width: 36px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.api-log-status-2xx { background: #dbeddb; color: #1c3829; }
.api-log-status-4xx { background: #fdecc8; color: #402c1b; }
.api-log-status-5xx { background: #ffe2dd; color: #6e3630; }

.api-log-path code {
  font-size: 13px;
}

.api-log-query {
  color: var(--text-secondary);
  font-size: 12px;
}

.api-log-meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.api-log-detail {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.api-log-pre {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: var(--radius);
  background: #f7f6f3;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 700px) {
  .api-log-meta {
    margin-left: 0;
    width: 100%;
  }
}

.docs-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.docs-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.docs-section > p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.docs-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.docs-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.docs-card p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.docs-card p:last-child {
  margin-bottom: 0;
}

.docs-pre {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: var(--radius);
  background: #f7f6f3;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.docs-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.docs-endpoint {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.docs-endpoint:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.docs-endpoint-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.docs-endpoint p {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.docs-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #ddebf1;
  color: #28456c;
}

.docs-badge-muted {
  background: #f1f1ef;
  color: var(--text-secondary);
}

.docs-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.import-mapping-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.import-mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.import-mapping-table th,
.import-mapping-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.import-mapping-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.import-mapping-select {
  min-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.import-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.import-sample {
  display: inline-block;
  max-width: 180px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f5f5f4;
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-sample-muted {
  color: var(--text-muted);
}

.settings-section + .settings-section {
  margin-top: 24px;
}

.settings-wipe-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
  font-size: 14px;
}

.settings-danger-zone {
  border-color: #f1c4c0;
}

.settings-wipe-form {
  margin-top: 8px;
}

.personalization-section + .personalization-section {
  margin-top: 20px;
}

.section-hint {
  margin: 0 0 16px;
}

.panel-subtitle-sm {
  margin: 20px 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.property-def-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.property-def-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.property-def-row-readonly {
  background: var(--surface);
}

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

.property-def-field {
  margin: 0;
}

.personalization-section .property-def-field label,
.personalization-section label[for="new-property-title"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.personalization-section .property-add-form {
  margin: 0;
}

.personalization-section .property-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(148px, 200px) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 3px 0;
  border: none;
}

.personalization-section .status-settings-type-field {
  margin: 0;
}

.personalization-section .property-type-select {
  width: 100%;
  min-height: 36px;
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2337352f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border-radius: var(--radius);
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.personalization-section .property-type-select:hover {
  border-color: var(--border-strong);
}

.personalization-section .property-type-select:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.property-def-title {
  font-weight: 600;
}

.property-def-badge,
.property-def-type {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.property-def-badge {
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f1ef;
}

.property-def-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.property-def-card .property-def-row {
  border: none;
  border-radius: 0;
}

.property-options-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-top: 1px solid var(--border);
  background: #fafaf9;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.property-options-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.property-options-toggle-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  transition: transform 0.15s ease;
}

.property-options-collapse.is-open .property-options-toggle-icon {
  transform: rotate(90deg);
}

.property-options-count {
  color: var(--text-tertiary);
  font-weight: 400;
}

.property-options-panel {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: #fafaf9;
}

.property-options-panel .status-settings-list {
  margin-bottom: 8px;
}

.property-options-panel .property-options-add-title,
.property-options-panel .panel-subtitle-sm {
  margin-top: 10px;
  margin-bottom: 6px;
}

.property-options-panel .status-add-form {
  margin: 0;
}

@media (max-width: 720px) {
  .property-def-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .status-settings-row {
    flex-direction: column;
    align-items: stretch;
  }

  .status-settings-actions {
    justify-content: flex-end;
    padding-bottom: 0;
  }

  .status-settings-compact .status-settings-row,
  .status-settings-compact .status-settings-row-has-menu,
  .status-settings-compact .status-settings-row-add,
  .personalization-section .property-add-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

.color-tag-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.color-tag-select-wrap {
  position: relative;
}

.color-tag-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.color-tag-select-trigger:hover {
  border-color: var(--border-strong);
}

.color-tag-select-trigger:focus-visible {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12);
}

.color-tag-select-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.color-tag-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
}

.color-tag-select-option {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.color-tag-select-option:hover,
.color-tag-select-option.is-selected {
  background: var(--bg);
}

.tag-you {
  background: #f1f1ef;
  color: var(--text-secondary);
  margin-left: 6px;
  font-size: 11px;
}

.tag-role-admin { background: #e8deee; color: #412454; }
.tag-role-member { background: #f1f1ef; color: var(--text-secondary); }

.tag-user-active { background: #dbeddb; color: #1c3829; }
.tag-user-invited { background: #ddebf1; color: #28456c; }
.tag-user-disabled { background: #f1f1ef; color: var(--text-tertiary); }

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-danger-text {
  color: var(--danger) !important;
}

.inline-form-btn {
  display: inline;
}

.database-table tbody tr:not(.database-row) td {
  vertical-align: middle;
}

.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-tertiary);
  opacity: 0.6;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 320px;
  margin-inline: auto;
}

.meta {
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 10px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
  }

  .mobile-brand {
    font-weight: 600;
    font-size: 15px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 450;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    height: 100vh;
    z-index: 460;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 32px rgba(15, 15, 15, 0.12);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav {
    display: block;
    padding-top: 8px;
  }

  .nav-item {
    width: 100%;
  }

  .main {
    padding: 16px 12px 40px;
    max-width: none;
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }

  .page-description {
    font-size: 13px;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .toolbar {
    margin-bottom: 12px;
  }

  .leads-table-controls {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
  }

  .leads-status-filters {
    flex: 1 1 100%;
    width: 100%;
  }

  .leads-status-filters-chips {
    display: none;
  }

  .leads-status-mobile-select {
    display: block;
    width: 100%;
  }

  .leads-table-controls-actions {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .leads-table-controls .search-form {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .leads-table-settings-menu .notion-popover {
    position: fixed;
    overflow-y: auto;
  }

  .database {
    border-radius: var(--radius);
  }

  .database-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .database-table {
    min-width: 520px;
    font-size: 13px;
  }

  .database-table thead th {
    padding: 0;
    font-size: 11px;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .database-table-sort-link {
    padding: 8px 10px;
  }

  .database-table tbody td {
    padding: 10px;
    white-space: nowrap;
  }

  .database-row td::before {
    display: none;
  }

  .row-title-cell {
    max-width: 140px;
  }

  .row-title {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
  }

  .property {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .panel-compact .property {
    grid-template-columns: 200px 1fr;
  }

  .lead-peek.open {
    width: 100vw;
  }

  .lead-peek-backdrop {
    left: 0;
  }
}
