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

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

.modal__content {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
  background: white;
  border-radius: 24px 24px 0 0;
}

#change-amount {
  display: block;
  margin: 24px 0;
  color: var(--color-primary);
  font-size: 44px;
  text-align: center;
}
.amount-modal-content,
.change-modal-content {
  max-height: 92dvh;
  overflow-y: auto;
}

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

.modal-header h2 {
  margin: 0;
}

.modal-header button {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 30px;
}

#amount-input-display {
  display: block;
  margin: 24px 0;
  font-size: 40px;
  text-align: right;
}

.amount-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.amount-keypad button {
  min-height: 64px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.amount-keypad .key-clear {
  color: #ef4444;
}

.change-modal-content {
  text-align: center;
}

.success-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--color-primary);
  font-size: 34px;
  font-weight: 800;
}

.change-summary {
  margin-top: 24px;
  text-align: left;
}

.change-summary div {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
/* ===== Modales entièrement scrollables ===== */
.modal[hidden] {
  display: none !important;
}

.modal {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
}

.modal__content {
  position: relative;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: 1;
  width: min(620px, 100%);
  max-height: calc(100dvh - env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.modal-action-button,
.change-modal-content .primary-button {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 20px;
  box-shadow: 0 -10px 20px rgba(255, 255, 255, 0.92);
}

@media (min-width: 761px) {
  .modal {
    align-items: center;
    padding: 24px;
  }

  .modal__content {
    max-height: calc(100dvh - 48px);
    border-radius: 24px;
  }
}
