/* ══ 판매 고객 화면 공통 모달(11/27) — 모든 창이 같은 모양 ══
   규칙(DESIGN.md '모달'): 흰 판 · 모서리 16 · 안쪽 28 · 제목 20/700 · 오른쪽 위 × 단추(36 원) · 아래 단추 줄은 오른쪽 정렬, 높이 48 · 모서리 12.
   주 단추 = 보라(P500), 보조 = 흰 바탕 선, 위험(탈퇴·취소) = 빨강. 뒤 가림 = 짙은 반투명. 휴대폰(640 이하)은 아래에서 올라오는 시트.
   새 창을 만들 때: <dialog class="iru-modal"> + <h2> + 본문 + <div class="iru-modal-foot"> — × 단추는 modal.js 가 넣는다.
   예전 창(확인창 ask·약관·링크 복사법·공유 링크·순위 기록·사진 확대·회원 탈퇴)은 아래 묶음 선택자로 같은 모양을 입힌다. 관리자 화면은 건드리지 않는다(:root.sales-customer 만). */

:root.sales-customer {
  --modal-pad: 28px;
  --modal-radius: 16px;
  --modal-shadow: 0 24px 60px rgba(20, 16, 30, .24);
  --modal-backdrop: rgba(20, 16, 30, .5);
}

/* ── 판 ── */
:root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer) {
  position: fixed; inset: 0; box-sizing: border-box;
  width: min(480px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 48px);
  margin: auto; padding: var(--modal-pad); overflow: auto;
  border: 0; border-radius: var(--modal-radius) !important;
  background: var(--surface); color: var(--ink); box-shadow: var(--modal-shadow);
  font-size: 16px; line-height: 1.6;
}
:root.sales-customer :is(dialog.iru-modal.lg, dialog.box.lg, dialog.ox-howto) { width: min(880px, calc(100vw - 32px)); }
:root.sales-customer dialog.image-viewer { width: min(920px, calc(100vw - 32px)); }
:root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer)::backdrop { background: var(--modal-backdrop); }
:root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer)[open] { animation: iru-modal-in .18s ease-out; }
:root.sales-customer dialog.ox-howto[open] { display: flex; padding: 0; }   /* 링크 복사법은 머리·몸·발이 따로 스크롤 — 안쪽 여백은 각 칸이 */
@keyframes iru-modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── 제목·설명 ── */
:root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ac-withdraw) > h2,
:root.sales-customer :is(dialog.sh-dlg, dialog.ac-withdraw) > form > h2,
:root.sales-customer :is(.ox-howto-hd, .rk-dlg-hd, .image-viewer-head) h2 {
  margin: 0 0 8px; padding-right: 44px; font-size: 20px; font-weight: 700; line-height: 1.4; letter-spacing: -.02em; color: var(--ink-strong);
}
:root.sales-customer dialog.box > p, :root.sales-customer .sh-dlg-sub, :root.sales-customer .rk-dlg-sub { margin: 0 0 4px; font-size: 16px; line-height: 1.6; color: var(--ink2); }
:root.sales-customer .ox-howto-hd { padding: var(--modal-pad) var(--modal-pad) 4px; }
:root.sales-customer .ox-howto-body { padding: 8px var(--modal-pad) 20px; }
:root.sales-customer .ox-howto-ft { padding: 16px var(--modal-pad); }
:root.sales-customer .rk-dlg-hd, :root.sales-customer .image-viewer-head { display: block; margin: 0; }

/* 요약 표(ask rows) · 입력 칸 */
:root.sales-customer dialog .ask-rows { margin: 16px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--soft); }
:root.sales-customer dialog .ask-rows > div { font-size: 14px; }
:root.sales-customer dialog .ask-rows dd { font-weight: 700; }
:root.sales-customer dialog .ask-rows > div.total dd { font-weight: 700; color: var(--primary-ink); }
:root.sales-customer :is(dialog.sh-dlg, dialog.ac-withdraw, dialog.iru-modal) :is(input[type=text], input[type=password], input:not([type]), textarea) {
  box-sizing: border-box; width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
:root.sales-customer :is(dialog.sh-dlg, dialog.ac-withdraw, dialog.iru-modal) :is(input, textarea):focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
:root.sales-customer :is(.sh-field > span, .sh-field > legend, .ac-withdraw-field) { font-size: 14px; font-weight: 700; color: var(--ink-strong); }

/* ── 아래 단추 줄 ── */
:root.sales-customer :is(dialog.box .foot, .sh-dlg-foot, .ac-withdraw-acts, .ox-howto-ft, .iru-modal-foot) {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 24px;
}
:root.sales-customer dialog.ox-howto .ox-howto-ft { justify-content: space-between; margin-top: 0; border-top: 1px solid var(--line); }
:root.sales-customer :is(dialog.box .foot, .sh-dlg-foot, .ac-withdraw-acts, .ox-howto-ft, .iru-modal-foot) :is(button, .btn, .ap-btn) {
  display: inline-flex; align-items: center; justify-content: center; height: 48px; min-width: 96px; padding: 0 20px;
  border: 0; border-radius: 12px !important; box-shadow: none; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  background: var(--primary) !important; color: #fff;
}
:root.sales-customer :is(dialog.box .foot, .sh-dlg-foot, .ac-withdraw-acts, .ox-howto-ft, .iru-modal-foot) :is(button, .btn, .ap-btn):hover { background: var(--primary-strong) !important; filter: none; }
/* 보조(닫기·그만두기·수정하기) */
:root.sales-customer :is(dialog.box .foot .btn.line, .sh-dlg-foot .ap-btn--line, .ac-withdraw-cancel, .iru-modal-foot .is-line) {
  background: var(--surface) !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--line) !important;
}
:root.sales-customer :is(dialog.box .foot .btn.line, .sh-dlg-foot .ap-btn--line, .ac-withdraw-cancel, .iru-modal-foot .is-line):hover { background: var(--soft) !important; }
/* 위험(취소·탈퇴·삭제) */
:root.sales-customer :is(dialog.box .foot .btn.danger, .ac-withdraw-go, .iru-modal-foot .is-danger) { background: var(--red) !important; color: #fff; }
:root.sales-customer :is(dialog.box .foot .btn.danger, .ac-withdraw-go, .iru-modal-foot .is-danger):hover { background: #b42318 !important; }
:root.sales-customer .ox-howto-ft a { font-size: 14px; }

/* ── 오른쪽 위 × (modal.js 가 넣는다) — 예전 글자 닫기 단추는 숨긴다 ── */
:root.sales-customer .iru-modal-x, :root.sales-customer .ox-howto-x {
  position: absolute; top: 18px; right: 18px; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50% !important; background: transparent; color: var(--ink3); font: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
:root.sales-customer :is(.iru-modal-x, .ox-howto-x):hover { background: var(--soft); color: var(--ink); }
:root.sales-customer :is(.iru-modal-x, .ox-howto-x):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
:root.sales-customer dialog.ox-howto { position: fixed; }
:root.sales-customer :is([data-rk-close], [data-close-image]) { display: none !important; }

/* 로그인·가입 창(div 오버레이 — auth-join-modal)도 같은 판 모양 */
:root.sales-customer .login-join-dimmed { background: var(--modal-backdrop) !important; }
:root.sales-customer .login-join-popup { border-radius: var(--modal-radius) !important; box-shadow: var(--modal-shadow) !important; }
:root.sales-customer .login-join-close { top: 18px !important; right: 18px !important; width: 36px; height: 36px; border-radius: 50% !important; color: var(--ink3); font-size: 22px; }
:root.sales-customer .login-join-close:hover { background: var(--soft); color: var(--ink); }

/* ── 휴대폰: 아래 시트 ── */
@media (max-width: 640px) {
  :root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer) {
    inset: auto 0 0 0; width: 100%; max-height: 88vh; margin: 0;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0 !important;
  }
  :root.sales-customer dialog.ox-howto { padding: 0; }
  :root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer)[open] { animation: iru-sheet-up .22s ease-out; }
  :root.sales-customer :is(dialog.box .foot, .sh-dlg-foot, .ac-withdraw-acts, .iru-modal-foot) :is(button, .btn, .ap-btn) { flex: 1; min-width: 0; }
  :root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ac-withdraw) > h2,
  :root.sales-customer :is(dialog.sh-dlg, dialog.ac-withdraw) > form > h2,
  :root.sales-customer :is(.ox-howto-hd, .rk-dlg-hd, .image-viewer-head) h2 { font-size: 18px; }
  :root.sales-customer .iru-modal-x, :root.sales-customer .ox-howto-x { top: 12px; right: 12px; }
}
@keyframes iru-sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* 약관 창: 머리(× )·발은 고정, 본문만 스크롤 — 열릴 때 '닫기'에 초점이 가도 맨 아래로 내려가지 않게 */
:root.sales-customer dialog.legal-dlg[open] { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
:root.sales-customer dialog.legal-dlg .legal-dlg-body { flex: 1; min-height: 0; overflow: auto; padding: var(--modal-pad) var(--modal-pad) 8px; }
:root.sales-customer dialog.legal-dlg.box .foot { margin: 0; padding: 16px var(--modal-pad); border-top: 1px solid var(--line); }
/* 단추 초점 테두리 — 두껍게 겹쳐 보이지 않게 한 줄 */
:root.sales-customer dialog :is(button, .btn, .ap-btn):focus-visible { outline: 2px solid var(--primary-line); outline-offset: 2px; }

/* ── 바텀시트 다듬기(11/29): 휴대폰에서 아래서 올라오는 창은 위에 손잡이 막대 + 아래로 쓸어내리면 닫힘(modal.js).
   환불 신청 창(rf-dlg)·순위 기록 서랍(rk-dlg)도 휴대폰에서는 같은 바텀시트. PC 는 그대로 가운데 모달·오른쪽 서랍 ── */
@media (max-width: 640px) {
  :root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ac-withdraw, dialog.image-viewer, dialog.rf-dlg) { padding-top: 28px; }
  :root.sales-customer :is(dialog.iru-modal, dialog.box, dialog.sh-dlg, dialog.ox-howto, dialog.ac-withdraw, dialog.image-viewer, dialog.rf-dlg)[open]::before {
    content: ''; position: absolute; top: 10px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line);
  }
  :root.sales-customer dialog.rf-dlg { position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: 88vh; margin: 0; padding: 28px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; overflow: auto; }
  :root.sales-customer dialog.rf-dlg[open] { animation: iru-sheet-up .22s ease-out; }
  :root.sales-customer dialog.box.rk-dlg { inset: auto 0 0 0 !important; width: 100% !important; height: auto !important; max-height: 88vh !important; border-radius: 16px 16px 0 0 !important; }
  :root.sales-customer dialog.box.rk-dlg[open] { animation: iru-sheet-up .22s ease-out !important; }
  :root.sales-customer dialog.is-dragging { transition: none !important; animation: none !important; }
}
