.global-search-wrap {
  min-width: 0;
}

.search-toggle {
  display: none;
}

/* Leaflet tiles must keep their original colours. */
.leaflet-container img.leaflet-tile {
  mix-blend-mode: normal !important;
  filter: none !important;
  opacity: 1 !important;
}

.property-row {
  color: var(--text);
  font: inherit;
  grid-template-columns: 44px minmax(0, 1fr) auto 88px 18px auto;
}

.property-quick-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.property-quick-actions button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
}

.property-quick-actions button:hover,
.property-quick-actions button:focus-visible,
.property-quick-actions button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.property-quick-actions button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.smart-overview {
  position: relative;
  overflow: hidden;
}

.smart-overview::after {
  content: "AI";
  position: absolute;
  top: 10px;
  right: 13px;
  color: var(--primary);
  opacity: 0.5;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.expert-contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.expert-contact-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.expert-contact-card > div:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.expert-contact-card b,
.expert-contact-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expert-contact-card span {
  color: var(--text-soft);
  font-size: 11px;
}

.expert-contact-card .primary-button {
  min-height: 38px;
  padding: 0 11px;
  text-decoration: none;
}

.expert-facebook-missing {
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 8px 10px;
  color: var(--text-faint) !important;
  font-weight: 700;
}

.ai-assistant-page {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr);
  gap: 14px;
}

.crm-chat-panel {
  overflow: hidden;
}

.crm-chat-messages {
  display: flex;
  min-height: 320px;
  max-height: 56vh;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface-subtle);
}

.crm-chat-message {
  width: fit-content;
  max-width: 86%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 10px 12px;
}

.crm-chat-message.user {
  align-self: flex-end;
  border-color: var(--primary);
  background: var(--primary-soft);
}

.crm-chat-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.chat-property-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chat-property-links button {
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 7px 9px;
  cursor: pointer;
  font-weight: 750;
}

.chat-empty {
  margin: auto;
  color: var(--text-soft);
  text-align: center;
}

.crm-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
}

.crm-chat-compose textarea {
  min-height: 52px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.admin-link-audit {
  align-self: start;
  padding: 18px;
}

.admin-link-audit h2 {
  margin: 7px 0;
  font-size: 18px;
}

.admin-link-audit p {
  color: var(--text-soft);
  line-height: 1.55;
}

.admin-link-audit strong {
  display: block;
  margin: 10px 0;
  color: var(--primary);
}

.admin-link-audit button {
  width: 100%;
}

@media (width <= 767px) {
  .topbar {
    box-sizing: border-box;
    height: calc(62px + env(safe-area-inset-top));
    min-height: calc(62px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(9px, env(safe-area-inset-right)) 0
      max(9px, env(safe-area-inset-left));
    grid-template-columns: 44px minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .topbar h1 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }

  .menu-button {
    margin-left: 0;
  }

  .global-search-wrap {
    position: relative;
    width: 44px;
    height: 44px;
  }

  .search-toggle {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
  }

  .global-search-wrap .global-search {
    display: none;
  }

  .global-search-wrap.search-open {
    position: absolute;
    z-index: 80;
    top: calc(env(safe-area-inset-top) + 7px);
    left: max(62px, calc(env(safe-area-inset-left) + 62px));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
  }

  .global-search-wrap.search-open .search-toggle {
    display: none;
  }

  .global-search-wrap.search-open .global-search {
    display: flex;
    position: static;
    width: 100%;
    height: 46px;
    box-shadow: var(--shadow-raised);
  }

  .global-search-wrap.search-open .global-search input {
    min-width: 0;
  }

  .top-actions {
    min-width: 44px;
  }

  .top-actions .theme-toggle {
    display: none;
  }

  .property-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    row-gap: 7px;
  }

  .property-quick-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .property-quick-actions::-webkit-scrollbar {
    display: none;
  }

  .property-quick-actions button {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
  }

  .expert-contact-grid {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .expert-contact-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .expert-contact-card > a,
  .expert-contact-card > .expert-facebook-missing {
    grid-column: 2;
    width: 100%;
    justify-content: center;
  }

  .ai-assistant-page {
    grid-template-columns: 1fr;
  }

  .crm-chat-messages {
    min-height: 48vh;
    max-height: 58vh;
  }

  .crm-chat-message {
    max-width: 94%;
  }

  .crm-chat-compose {
    grid-template-columns: 1fr;
  }

  .crm-chat-compose button {
    min-height: 48px;
  }
}
