.projects-page,
.project-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

main[data-active-nav="projects"] .topbar {
  display: none;
}

.projects-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.projects-toolbar input[type="search"] {
  flex: 1 1 280px;
}

.projects-table tr[data-project-id] {
  cursor: pointer;
}

.projects-table tr[data-project-id]:hover {
  background: rgba(37, 99, 235, 0.08);
}

.project-form {
  display: grid;
  grid-template-columns: minmax(220px, 240px) minmax(0, 1fr);
  gap: 18px;
  align-items: end;
}

.project-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  color: var(--fg-muted);
}

.project-field__label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-field__value {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
}

.project-field--wide {
  min-width: 0;
}

.project-field--wide input {
  width: 100%;
}

.project-section__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.project-section__header h2 {
  margin: 0;
}

.project-section__subtitle {
  margin: 4px 0 0;
  color: var(--fg-muted);
}

.project-leads-table tr[data-lead-id] {
  cursor: pointer;
}

.project-leads-table tr[data-lead-id]:hover {
  background: rgba(37, 99, 235, 0.08);
}

.project-lead-row__ref {
  font-weight: 800;
  color: #1d4ed8;
}

.project-lead-row__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.project-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

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

.project-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.project-modal__panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(82vh, 780px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.project-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.project-modal__header h2 {
  margin: 0;
}

.project-modal__header p {
  margin: 8px 0 0;
  color: var(--fg-muted);
}

.project-modal__body {
  display: grid;
  gap: 16px;
  padding: 18px 22px;
  overflow: hidden;
}

.project-modal__search-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.project-modal__search-input {
  width: 100%;
}

.project-modal__results {
  max-height: 260px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: #f8fafc;
}

.project-modal__result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.project-modal__result-item:last-child {
  border-bottom: 0;
}

.project-modal__result-item:hover,
.project-modal__result-item.is-selected {
  background: rgba(37, 99, 235, 0.08);
}

.project-modal__result-title {
  font-weight: 800;
  color: #1d4ed8;
}

.project-modal__result-meta {
  color: #64748b;
  font-size: 0.92rem;
}

.project-modal__selected {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 18px;
  background: rgba(239, 246, 255, 0.9);
}

.project-modal__selected[hidden] {
  display: none;
}

.project-modal__selected-title {
  font-weight: 900;
  color: #0f172a;
}

.project-modal__selected-meta {
  color: #475569;
}

.project-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 22px 22px;
}

.project-modal__empty {
  padding: 16px;
  color: #64748b;
}

@media (max-width: 720px) {
  .project-form {
    grid-template-columns: 1fr;
  }

  .project-modal__panel {
    max-height: calc(100vh - 32px);
  }
}
