/* 다운그레이드 4단계 모달 (STEP D1) */

body.dg-modal-open { overflow: hidden; }

.dg-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
}

.dg-modal {
    max-width: 720px;
    width: 100%;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    animation: dgPop .18s ease-out;
}

@keyframes dgPop {
    from { transform: translateY(12px) scale(.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.dg-progress {
    display: flex;
    gap: 8px;
    padding: 20px 32px 0;
}
.dg-progress-dot {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    transition: background .2s;
}
.dg-progress-dot.active { background: #6d28d9; }

.dg-modal-step {
    padding: 24px 32px 28px;
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.dg-title {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
    margin: 4px 0 6px;
}
.dg-desc {
    font-size: 14px;
    color: #475569;
    margin: 0 0 16px;
}

/* Step 1 — 플랜 카드 */
.dg-plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}
.dg-plan-card {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.dg-plan-card:hover { border-color: #cbd5e1; }
.dg-plan-card:focus-visible {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 3px rgba(109, 40, 217, .18);
}
.dg-plan-card.selected { border-color: #6d28d9; background: #faf5ff; }
.dg-plan-card.disabled {
    opacity: .55;
    cursor: not-allowed;
    background: #f8fafc;
}
.dg-plan-name { font-size: 16px; font-weight: 700; color: #0f172a; }
.dg-plan-price { font-size: 22px; font-weight: 800; color: #0f172a; margin-top: 8px; }
.dg-plan-sub { font-size: 12px; color: #64748b; margin-top: 8px; line-height: 1.5; }

/* Step 2 — 만류 */
.dg-loss-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 4px 0 20px;
}
.dg-loss-title { font-weight: 700; color: #92400e; margin-bottom: 12px; }
.dg-loss-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: #78350f;
    font-size: 14px;
    padding: 6px 0;
    border-top: 1px solid rgba(146, 64, 14, .12);
}
.dg-loss-item:first-of-type { border-top: none; }
.dg-loss-item.strong { color: #b91c1c; font-weight: 600; }
.dg-loss-label { flex: 0 0 auto; }
.dg-loss-change { text-align: right; }
.dg-loss-change em { font-style: normal; color: #a16207; margin: 0 4px; }

.dg-cycle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}
.dg-cycle-label { font-size: 14px; font-weight: 600; color: #334155; }
.dg-cycle-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}
.dg-cycle-btn {
    padding: 9px 22px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #64748b;
}
.dg-cycle-btn.active {
    background: #fff;
    color: #6d28d9;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

/* Step 3 — 적용 옵션 */
.dg-apply-option {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dg-apply-option:hover { border-color: #cbd5e1; }
.dg-apply-option.selected { border-color: #6d28d9; background: #faf5ff; }
.dg-apply-option.disabled {
    opacity: .55;
    cursor: not-allowed;
    background: #f8fafc;
}
.dg-apply-option-title {
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dg-apply-option-desc { font-size: 13px; color: #475569; margin-top: 6px; line-height: 1.6; }
.dg-refund-amount { color: #16a34a; }
.dg-tag {
    font-size: 11px;
    font-weight: 700;
    color: #6d28d9;
    background: #ede9fe;
    border-radius: 6px;
    padding: 2px 8px;
}

.dg-reason-row { margin-top: 8px; }
.dg-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}
.dg-select,
.dg-textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    color: #0f172a;
    font-family: inherit;
    box-sizing: border-box;
}
.dg-select:focus,
.dg-textarea:focus {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 3px rgba(109, 40, 217, .15);
}
.dg-textarea { margin-top: 10px; min-height: 72px; resize: vertical; }

/* Step 4 — 확인 */
.dg-summary-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 8px 20px;
    margin-bottom: 16px;
}
.dg-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 11px 0;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
}
.dg-summary-row:first-child { border-top: none; }
.dg-summary-row span { color: #64748b; }
.dg-summary-row strong { color: #0f172a; text-align: right; }
.dg-pay-desc { font-size: 13px; color: #475569; line-height: 1.6; margin: 0 0 12px; }
.dg-warn {
    font-size: 13px;
    color: #b91c1c;
    background: #fef2f2;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 12px;
}
.dg-agree {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
}
.dg-agree input { width: 18px; height: 18px; accent-color: #6d28d9; }

/* 완료 */
.dg-done {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
}
.dg-done-msg { font-size: 16px; font-weight: 600; color: #0f172a; line-height: 1.6; }

/* 공통 */
.dg-loading,
.dg-empty,
.dg-error {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
    text-align: center;
}
.dg-error { color: #b91c1c; }

.dg-step-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 24px;
}
.dg-btn {
    flex: 1;
    padding: 13px 20px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.dg-btn.primary { background: #6d28d9; color: #fff; }
.dg-btn.primary:hover:not(:disabled) { background: #5b21b6; }
.dg-btn.secondary { background: #f1f5f9; color: #475569; }
.dg-btn.secondary:hover:not(:disabled) { background: #e2e8f0; }
.dg-btn:disabled { opacity: .5; cursor: not-allowed; }

.dg-shake { animation: dgShake .3s; border-color: #ef4444 !important; }
@keyframes dgShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@media (max-width: 600px) {
    .dg-plan-grid { grid-template-columns: 1fr; }
    .dg-modal-step { padding: 20px; min-height: 0; }
    .dg-progress { padding: 16px 20px 0; }
    .dg-cycle-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}
