body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f5f5f5;
  color: #222;
}

body.modal-open {
  overflow: hidden;
}

.wrap {
  width: 100%;
  max-width: none;
  padding: 16px 24px;
  box-sizing: border-box;
}

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

.page-header h1 {
  margin: 0 0 8px 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel {
  background: #fff;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin-bottom: 20px;
}

.status {
  font-weight: bold;
}

.contacts-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.results-count {
  margin-bottom: 16px;
  color: #555;
  font-size: 14px;
}

input,
textarea,
button {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  box-sizing: border-box;
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
}

.secondary-btn {
  background: #f3f3f3;
  border: 1px solid #ccc;
}

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

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

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  width: 100%;
}

.contact-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.contact-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.contact-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: #e6eefb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.contact-heading {
  min-width: 0;
  flex: 1;
}

.edit-icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  margin-top: 0;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #f7f7f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.edit-icon-btn:hover {
  background: #ececec;
}

.contact-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.contact-subtitle {
  color: #666;
  margin-top: 4px;
  font-size: 14px;
}

.contact-meta {
  margin-top: 10px;
}

.contact-line {
  font-size: 13px;
  line-height: 1.5;
  margin: 4px 0;
  word-break: break-word;
}

.contact-line .label {
  font-weight: 700;
}

.contact-notes {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #555;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.contact-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-dialog {
  position: relative;
  background: #fff;
  width: min(900px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: 24px auto;
  border-radius: 12px;
  border: 1px solid #ddd;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 0 16px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  width: auto;
  min-width: 40px;
  font-size: 24px;
  line-height: 1;
  padding: 4px 10px;
}

.modal-body {
  padding: 16px;
}

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

@media (max-width: 700px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
  }

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

.contact-notes-wrapper {
  position: relative;
}

.contact-notes {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #555;
  white-space: pre-wrap;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.contact-notes-tooltip {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 6px;

  background: #1f1f1f;
  color: #fff;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;

  max-width: 320px;
  white-space: pre-wrap;

  box-shadow: 0 6px 20px rgba(0,0,0,0.25);

  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;

  z-index: 100;
}

.contact-notes-wrapper:hover .contact-notes-tooltip {
  opacity: 1;
  transform: translateY(0);
}