.app-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(18px + var(--safe-bottom));
}

.app-modal.is-open {
  display: flex;
}

.app-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 27, 38, 0.42);
  backdrop-filter: blur(8px);
}

.app-modal__panel {
  position: relative;
  width: min(100%, 520px, var(--max-app));
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(23, 27, 38, 0.18);
  padding: 18px 18px 16px;
  animation: modal-in 280ms cubic-bezier(.22, .8, .32, 1);
}

.app-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.app-modal__head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.app-modal__hero {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-modal__hero img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

.app-modal__close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f7;
  color: #808794;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.app-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 8px;
}

.app-modal__foot .btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
}

.app-modal__foot .btn-primary,
.app-modal__foot .btn-save {
  background: var(--blue);
  color: #fff;
}

.modal-form .field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.modal-form .field label {
  font-size: 13px;
  font-weight: 650;
  color: #5d6470;
}

.modal-form .input,
.modal-form textarea,
.modal-form select {
  width: 100%;
  background: #f4f5f8;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 46px;
}

@media (min-width: 420px) {
  .app-modal {
    align-items: center;
  }
  .modal-form .field {
    grid-template-columns: 110px 1fr;
    align-items: center;
    gap: 12px;
  }
  .modal-form .field label { margin: 0; }
}

@keyframes modal-in {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .app-modal__panel { animation: none; }
}

body.modal-open { overflow: hidden; }
