/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(160deg, #e8eaf6 0%, #c5cae9 30%, #d1c4e9 70%, #e8eaf6 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #333;
}

.container {
  width: 100%;
  max-width: 460px;
}

/* ===== Code Gate ===== */
.code-gate {
  text-align: center;
  padding: 48px 32px 36px;
}

.code-gate-icon {
  margin-bottom: 16px;
}

.code-gate-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.code-gate-desc {
  font-size: 13px;
  color: #888;
  margin-bottom: 28px;
}

.code-input-wrap {
  display: flex;
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}

.code-input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.2s;
}

.code-input-wrap input:focus {
  border-color: #302b63;
  box-shadow: 0 0 0 3px rgba(48,43,99,0.1);
}

.code-submit-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #302b63, #24243e);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.code-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(48,43,99,0.4);
}

.code-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.code-error {
  color: #e53935;
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== Form ===== */
.card-form {
  background: #fff;
  border-radius: 24px;
  padding: 28px 32px 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.03);
}

/* ===== Step Indicator ===== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 8px;
}

.step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #d0d0d0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #bbb;
  background: #fff;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.step-dot.active {
  border-color: #302b63;
  background: #302b63;
  color: #fff;
}

.step-dot.done {
  border-color: #4CAF50;
  background: #4CAF50;
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  background: #e0e0e0;
  max-width: 50px;
  transition: background 0.3s ease;
}

.step-line.done {
  background: #4CAF50;
}

.step-label {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #302b63;
  margin-bottom: 24px;
}

/* ===== Steps ===== */
.step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Card Preview ===== */
.card-preview-wrap {
  padding: 0 0 20px;
  display: flex;
  justify-content: center;
}

.card-preview {
  perspective: 1000px;
  height: 200px;
  width: 100%;
  max-width: 380px;
  position: relative;
  cursor: pointer;
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 200px;
  border-radius: 16px;
  padding: 22px;
  backface-visibility: hidden;
  transition: all 0.6s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.card-front {
  background: linear-gradient(135deg, #2c3e50, #34495e, #4a6274);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 12px 35px rgba(0,0,0,0.2);
}

.card-front::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.card-back {
  background: linear-gradient(135deg, #34495e, #2c3e50, #4a6274);
  transform: rotateY(180deg);
  box-shadow: 0 12px 35px rgba(0,0,0,0.2);
}

/* 카드사 테마 */
.card-preview.brand-visa .card-front { background: linear-gradient(135deg, #1a1f71, #1a237e, #283593); }
.card-preview.brand-visa .card-back { background: linear-gradient(135deg, #1a237e, #1a1f71, #283593); }
.card-preview.brand-mastercard .card-front { background: linear-gradient(135deg, #1a1a2e, #2d1b3d, #4a1942); }
.card-preview.brand-mastercard .card-back { background: linear-gradient(135deg, #2d1b3d, #1a1a2e, #4a1942); }
.card-preview.brand-amex .card-front { background: linear-gradient(135deg, #004d40, #00695c, #00897b); }
.card-preview.brand-amex .card-back { background: linear-gradient(135deg, #00695c, #004d40, #00897b); }
.card-preview.brand-bc .card-front { background: linear-gradient(135deg, #b71c1c, #c62828, #d32f2f); }
.card-preview.brand-bc .card-back { background: linear-gradient(135deg, #c62828, #b71c1c, #d32f2f); }

.card-preview.flipped .card-front { transform: rotateY(-180deg); }
.card-preview.flipped .card-back { transform: rotateY(0deg); }

.card-top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.card-chip { flex-shrink: 0; }
.card-brand { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.card-brand-logo { display: flex; align-items: center; opacity: 0; transform: scale(0.8); transition: all 0.3s ease; }
.card-brand-logo.active { opacity: 1; transform: scale(1); }

.card-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 19px;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.card-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.card-bottom .label { display: block; font-size: 8px; letter-spacing: 1px; color: rgba(255,255,255,0.5); margin-bottom: 3px; text-transform: uppercase; }
.card-bottom .value { display: block; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #fff; letter-spacing: 1px; text-transform: uppercase; }

.card-stripe { position: absolute; top: 28px; left: 0; width: 100%; height: 40px; background: #1a1a1a; }
.card-cvv-area { position: absolute; top: 90px; right: 22px; text-align: right; }
.cvv-label { display: block; font-size: 10px; color: rgba(255,255,255,0.5); letter-spacing: 1px; margin-bottom: 5px; }
.cvv-display { background: rgba(255,255,255,0.15); border-radius: 6px; padding: 7px 14px; font-family: 'JetBrains Mono', monospace; font-size: 15px; letter-spacing: 4px; color: #fff; min-width: 70px; text-align: center; }

/* ===== Form Fields ===== */
.form-group { margin-bottom: 16px; flex: 1; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: #555; margin-bottom: 6px; letter-spacing: 0.3px; }

.input-wrapper { position: relative; }

.input-wrapper input,
.input-wrapper select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Noto Sans KR', sans-serif;
  color: #333;
  background: #fafafa;
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input-wrapper input[inputmode="numeric"],
.input-wrapper input[type="password"],
.input-wrapper input#cardNumber,
.input-wrapper input#accountNumber {
  font-family: 'JetBrains Mono', monospace;
}

.input-wrapper select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.input-wrapper input::placeholder { color: #bbb; }
.input-wrapper input:focus, .input-wrapper select:focus { border-color: #302b63; background: #fff; box-shadow: 0 0 0 3px rgba(48,43,99,0.1); }
.input-wrapper input.error, .input-wrapper select.error { border-color: #e53935; background: #fff5f5; }
.input-wrapper input.valid, .input-wrapper select.valid { border-color: #4CAF50; background: #f5fff5; }

.input-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 20px; pointer-events: none; }

.error-msg { display: block; font-size: 11px; color: #e53935; margin-top: 4px; min-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { min-width: 0; }
.form-row-3 { gap: 10px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.section-desc { font-size: 13px; color: #888; margin-bottom: 18px; }

/* ===== Limit Notice ===== */
.limit-notice {
  background: linear-gradient(135deg, #f5f3ff, #ede7f6);
  border: 1px solid #d1c4e9;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.limit-notice-inner { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.limit-label { font-size: 12px; font-weight: 500; color: #555; }
.limit-value { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; color: #302b63; }
.limit-desc { font-size: 11px; color: #888; }

.installment-info {
  font-size: 12px; color: #555; background: #f9f9f9; border-radius: 8px;
  padding: 0; max-height: 0; overflow: hidden; transition: all 0.3s ease;
}
.installment-info.active { padding: 10px 14px; max-height: 60px; margin-top: -8px; }
.installment-info .monthly-amount { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: #302b63; }

/* ===== Photo Upload ===== */
.photo-upload-row { display: flex; gap: 12px; }
.photo-upload-group { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.photo-upload {
  position: relative;
  border: 2px dashed #d0d0d0;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  aspect-ratio: 1.6 / 1;
  background: #fafafa;
}
.photo-upload:hover { border-color: #302b63; background: #f5f4ff; }
.photo-upload.has-photo { border-style: solid; border-color: #4CAF50; }

.photo-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: #aaa; font-size: 12px; transition: opacity 0.2s;
}
.photo-upload.has-photo .photo-placeholder { opacity: 0; pointer-events: none; }

.photo-preview { width: 100%; height: 100%; object-fit: cover; display: none; }
.photo-upload.has-photo .photo-preview { display: block; }

.photo-remove {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  border: none; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.photo-remove:hover { background: rgba(229,57,53,0.85); }
.photo-upload.has-photo .photo-remove { display: flex; }

.photo-actions { display: flex; gap: 6px; }
.photo-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 6px; border: 1.5px solid #e0e0e0; border-radius: 8px;
  background: #fafafa; color: #555; font-size: 12px;
  font-family: 'Noto Sans KR', sans-serif; font-weight: 500; cursor: pointer; transition: all 0.2s ease;
}
.photo-action-btn:hover { border-color: #302b63; background: #f5f4ff; color: #302b63; }
.photo-action-btn:active { transform: scale(0.97); }
.photo-action-btn svg { flex-shrink: 0; }

/* ===== Step Navigation ===== */
.step-nav {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.nav-btn {
  flex: 1;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.nav-prev {
  background: #f0f0f0;
  color: #555;
  flex: 0.4;
}
.nav-prev:hover { background: #e4e4e4; }
.nav-prev.hidden { display: none; }

.nav-next {
  background: linear-gradient(135deg, #302b63, #24243e);
  color: #fff;
}
.nav-next:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(48,43,99,0.4); }
.nav-next.hidden { display: none; }

.nav-submit {
  background: linear-gradient(135deg, #302b63, #24243e);
  color: #fff;
  display: none;
}
.nav-submit.visible { display: flex; }
.nav-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(48,43,99,0.4); }
.nav-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; box-shadow: none; }
.nav-submit.loading .btn-text { opacity: 0; }
.nav-submit.loading .btn-loader { display: block; }

.btn-loader {
  display: none; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ===== Security Notice ===== */
.security-notice {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px; padding: 10px 14px;
  background: #f0faf0; border-radius: 8px;
  font-size: 11px; color: #2e7d32;
}
.security-notice svg { flex-shrink: 0; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
  z-index: 100; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: #fff; border-radius: 20px; padding: 36px 32px;
  text-align: center; max-width: 340px; width: 90%;
  transform: scale(0.9) translateY(20px); transition: transform 0.3s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-icon { margin-bottom: 14px; }
.modal h3 { font-size: 20px; font-weight: 700; color: #1a1a2e; margin-bottom: 6px; }
.modal p { font-size: 14px; color: #666; margin-bottom: 16px; line-height: 1.5; }

.processing-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: #e8eaf6; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 20px; text-align: left;
}
.processing-notice svg { flex-shrink: 0; margin-top: 2px; }
.processing-text {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px; color: #3949ab; line-height: 1.5;
}
.processing-text strong { font-weight: 700; }

.modal-btn {
  padding: 12px 40px; background: linear-gradient(135deg, #302b63, #24243e);
  color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 500;
  font-family: 'Noto Sans KR', sans-serif; cursor: pointer; transition: all 0.2s ease;
}
.modal-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(48,43,99,0.3); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  body {
    padding: 0;
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
    background: #fff;
  }

  .container {
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  /* 코드 게이트 - 화면 중앙 배치 */
  .code-gate {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    box-shadow: none;
    padding: 40px 24px;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .code-gate-icon svg { width: 56px; height: 56px; }
  .code-gate-title { font-size: 22px; }
  .code-gate-desc { font-size: 14px; margin-bottom: 32px; }

  .code-input-wrap {
    max-width: 100%;
    width: 100%;
    flex-direction: column;
    gap: 12px;
  }

  .code-input-wrap input {
    font-size: 18px;
    padding: 14px 16px;
  }

  .code-submit-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
  }

  /* 메인 폼 */
  .card-form {
    flex: 1;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
  }

  .step-indicator { margin-bottom: 6px; }
  .step-label { font-size: 14px; margin-bottom: 18px; }

  /* 카드 미리보기 */
  .card-preview-wrap { padding: 0 0 16px; }
  .card-preview { height: 170px; }
  .card-front, .card-back { height: 170px; padding: 16px; }
  .card-number { font-size: 15px; letter-spacing: 2px; }

  /* 폼 필드 */
  .form-row, .form-row-3 { flex-direction: column; gap: 0; }

  .input-wrapper input,
  .input-wrapper select {
    font-size: 16px;
    padding: 12px 14px;
  }

  /* 사진 업로드 */
  .photo-upload-row { flex-direction: column; gap: 14px; }
  .photo-upload { aspect-ratio: 1.8 / 1; }
  .photo-action-btn { padding: 10px 8px; font-size: 13px; }

  /* 네비게이션 */
  .step-nav { margin-top: 20px; }
  .nav-btn { padding: 14px 16px; font-size: 16px; }
  .nav-prev { flex: 0.45; }

  /* 보안 안내 */
  .security-notice { margin-top: 14px; margin-bottom: 8px; }

  /* 한도 안내 */
  .limit-value { font-size: 15px; }

  /* 모달 */
  .modal { padding: 32px 24px; width: 92%; }
}
