/* ================================================================
   core-ui.css — Bibong.dev 관리 사이트 공통 UI (Pay · Account · Support …)
   기준: design-docs/ (Bibong.dev Design Docs 초안 0.1)
     · 기능 요소는 청록 단색 #0D9488, 그라데이션은 브랜드 영역에만
     · 반경 12px, 얇은 테두리, 평평한 화면 / SUIT Variable
     · 글자: 페이지 제목 28/700, 섹션 20/700, 본문 16/1.6, UI 14, 보조 12
   가이드라인에 없는 부분(푸터 필수 항목, 로고 락업)은 포털 코어 디자인 가이드라인을 따른다.
   잠정·미정 값(배경·테두리 토큰, 대비)은 design-docs 의 결정 목록을 볼 것.
================================================================ */

:root {
  color-scheme: light;
  --brand: #0D9488; --brand-hover: #0B8177;
  /* 배경·글자·테두리는 메인 사이트(index.html)·Support 와 같은 값 */
  --bg: #FFFFFF; --surface: #F7F9FC; --panel: #FFFFFF;
  --text: #0D1117; --muted: #4B5563; --border: #E5E7EB; --soft: #E9F5F2; --focus: #086D63;
  --success: #15803D; --error: #B91C1C; --error-hover: #991B1B; --warning: #A16207; --info: #1D4ED8;
  --radius: 12px; --header: 56px;
  --grad: linear-gradient(135deg, #1565C0 0%, #0D9488 50%, #3CB878 100%);   /* 브랜드 영역 전용 */
  /* user-menu.js 등 예전 토큰 이름을 쓰는 공용 조각용 별칭 */
  --t1: var(--text); --t2: var(--muted); --t3: var(--muted); --bg2: var(--surface); --bg-card: var(--panel);
  --blue: var(--brand); --green: var(--brand); --r-sm: 8px; --r-md: var(--radius);
  --shadow-h: 0 8px 24px rgba(0, 0, 0, .08);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07101F; --surface: #0D1928; --panel: #101F33;
  --text: #EDF2FF; --muted: #8BA3BF; --border: #1C2E45; --soft: #0F2E36; --focus: #66D7C4;
  --shadow-h: 0 8px 24px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: 'SUIT Variable', system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg);
  padding-top: var(--header);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.4; font-weight: 700; letter-spacing: -.035em; }
h2 { font-size: 20px; line-height: 1.4; font-weight: 700; letter-spacing: -.025em; }
h3 { font-size: 16px; font-weight: 700; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
input, textarea, button, [tabindex] { scroll-margin-top: 150px; }   /* 고정 헤더·제목 줄이 포커스를 가리지 않게 */
/* 스크롤바가 있는 전체 페이지와 내부 영역에 브랜드 색상을 적용해요. */
* { scrollbar-width: thin; scrollbar-color: var(--brand) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-hover); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip { position: fixed; top: -100px; left: 8px; z-index: 300; background: var(--panel); padding: 12px; border-radius: var(--radius); }
.skip:focus { top: 8px; }

/* ── 헤더 (core-ui.js 가 넣는다) ── */
.cu-header {
  position: fixed; inset: 0 0 auto; height: var(--header); z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.cu-brand-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cu-header:has(#cuNavToggle) { padding-left: 12px; }
.cu-brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.cu-brand img { width: 30px; height: auto; display: block; }
.cu-brand strong { font-size: 18px; letter-spacing: -.6px; }
.cu-brand strong span { color: var(--muted); font-weight: 600; }
.cu-divider { width: 1px; height: 16px; background: var(--border); }
.cu-service { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cu-header-right { display: flex; align-items: center; gap: 8px; }

/* 사용자 메뉴(user-menu.js) — 이 가이드라인 모양으로 */
.bbd-u-trigger, .bbd-h-login { border-radius: var(--radius) !important; min-height: 40px; }
.bbd-u-trigger:hover, .bbd-u.is-open .bbd-u-trigger { border-color: var(--border) !important; background: var(--surface) !important; }
.bbd-h-login:hover { border-color: var(--brand) !important; color: var(--focus) !important; background: var(--soft); }
.bbd-u-av { background: var(--brand) !important; }
.bbd-u-menu { border-radius: var(--radius) !important; }
.bbd-u-menu a, .bbd-u-menu button { min-height: 44px; font-size: 14px !important; border-radius: var(--radius) !important; }
.bbd-u-menu a:hover, .bbd-u-menu button:hover { background: var(--soft) !important; color: var(--focus) !important; }

/* ── 제목 줄: 헤더 아래 고정, 왼쪽 제목 · 오른쪽 주요 행동 ── */
.cu-pagebar {
  position: sticky; top: var(--header); z-index: 30; min-height: 72px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.cu-pagebar-in { width: 100%; max-width: 1112px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cu-main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 32px 24px 80px; }
.cu-main--narrow { max-width: 608px; }
.cu-main:focus { outline: none; }   /* 화면 전환 때 본문으로 옮긴 포커스는 테두리 없이 */
.cu-section { margin-top: 32px; }
.cu-section > h2 { margin-bottom: 14px; }
.cu-lead { font-size: 16px; color: var(--muted); }
.small { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }

/* ── 버튼 ── */
.button {
  min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; line-height: 1.4; transition: background .15s, color .15s, border-color .15s;
}
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--brand-hover); }
.button.secondary { background: transparent; border-color: var(--border); color: var(--text); }
.button.secondary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--soft); border-color: var(--focus); color: var(--focus); }
.button.quiet { background: transparent; color: var(--text); }
.button.quiet:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--soft); color: var(--focus); }
.button.danger { background: var(--error); color: #fff; }
.button.danger:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--error-hover); }
.button:disabled { cursor: wait; opacity: .55; }
.icon-button {
  width: 44px; min-width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--text);
}
.icon-button:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--soft); color: var(--focus); }
.actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 24px; }   /* 취소·이전 왼쪽, 실행 오른쪽 */
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: cu-spin .7s linear infinite; }
@keyframes cu-spin { to { transform: rotate(360deg); } }

/* ── 카드·안내·배지 ── */
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 24px; }
.note {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px; font-size: 14px; line-height: 1.7;
  border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: var(--radius); background: var(--surface);
}
.note svg { color: var(--focus); margin-top: 1px; }
.note.warning { border-left-color: var(--warning); } .note.warning svg { color: var(--warning); }
.note.error { border-left-color: var(--error); } .note.error svg { color: var(--error); }
.badge {
  display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px; border-radius: var(--radius); white-space: nowrap;   /* 반경 12px 이 알약이 되지 않는 높이 */
  font-size: 12px; font-weight: 600; line-height: 1.6; border: 1px solid var(--border); color: var(--muted);
}
.badge.success { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.badge.error   { color: var(--error);   border-color: color-mix(in srgb, var(--error) 35%, transparent); }
.badge.warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.badge.info    { color: var(--info);    border-color: color-mix(in srgb, var(--info) 35%, transparent); }
[data-theme="dark"] .badge.success { color: #4ADE80; } [data-theme="dark"] .badge.error { color: #F87171; }
[data-theme="dark"] .badge.warning { color: #FACC15; } [data-theme="dark"] .badge.info { color: #93C5FD; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14px; }
/* 불러오는 동안 — 화면을 처음 불러올 때는 창 가운데에, 표 하나만 기다릴 때는 그 자리에 */
.page-loading { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 5; }
.loading-inline { display: flex; justify-content: center; padding: 16px 0; }
.page-loading::after, .loading-inline::after { content: ""; border-style: solid; border-color: var(--brand); border-right-color: transparent; border-radius: 50%; animation: cu-spin .7s linear infinite; }
.page-loading::after { width: 36px; height: 36px; border-width: 3px; }
.loading-inline::after { width: 24px; height: 24px; border-width: 3px; }

/* ── 선택: 체크박스·라디오 줄 ── */
.check-line { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; font-size: 14px; line-height: 1.6; cursor: pointer; }
.check-line input { accent-color: var(--brand); width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; }
.check-line[aria-invalid="true"] { color: var(--error); }
.check-line[aria-invalid="true"] input { outline: 2px solid var(--error); outline-offset: 2px; }
.required { color: var(--error); }
input[type="radio"][aria-invalid="true"], input[type="checkbox"][aria-invalid="true"] { outline: 2px solid var(--error); outline-offset: 2px; }
.check-line a { color: var(--focus); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.radio-row { display: flex; gap: 4px 20px; flex-wrap: wrap; border: 0; padding: 0; margin: 0; }
.radio-row legend { font-size: 14px; font-weight: 600; margin-bottom: 4px; padding: 0; }
.radio-row .check-line { align-items: center; }

/* ── 입력: 레이블은 위, 값이 있으면 오른쪽 × , 비밀번호는 × 다음에 표시·숨기기 ── */
.field { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.field + .field { margin-top: 16px; }
.field > label { font-size: 14px; font-weight: 600; }
.field-help { font-size: 12px; color: var(--muted); }
/* 제목 + 도움말(?) 한 줄 */
.field-head { display: flex; align-items: center; gap: 6px; }
.field-head > label { font-size: 14px; font-weight: 600; }
.help { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.help-btn {
  width: 20px; height: 20px; min-width: 20px; padding: 0; border: 1px solid var(--border); border-radius: 50%;
  background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.help-btn:hover, .help-btn:focus-visible { border-color: var(--brand); color: var(--focus); }
.help-btn::before { content: ""; position: absolute; inset: -12px; }   /* 누르기 쉬운 크기 */
.help [role="tooltip"] {
  position: absolute; left: -8px; bottom: calc(100% + 8px); z-index: 40; width: max-content; max-width: min(280px, calc(100vw - 48px));
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-h);
  font-size: 12px; font-weight: 400; line-height: 1.6; color: var(--text); white-space: normal; text-align: left; word-break: keep-all;
}
.help [role="tooltip"]::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }   /* 도움말로 커서를 옮겨도 유지 */
/* 비밀번호 규칙 표 */
.pw-checks { list-style: none; margin: 0; padding: 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 12px; color: var(--muted); }
.pw-checks li { display: flex; align-items: center; gap: 8px; }
.pw-mark { width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--border); display: inline-flex; align-items: center; justify-content: center; }
.pw-mark svg { width: 10px; height: 10px; stroke-width: 3; }
.pw-checks li[data-ok="true"] { color: var(--success); }
.pw-checks li[data-ok="true"] .pw-mark { background: var(--success); border-color: var(--success); color: #fff; }
.pw-checks li[data-ok="false"] { color: var(--text); }
.pw-checks li[data-ok="false"] .pw-mark { border-color: var(--muted); }
[data-theme="dark"] .pw-checks li[data-ok="true"] { color: #4ADE80; }
@media (max-width: 480px) { .pw-checks { grid-template-columns: 1fr; } }
.input-shell {
  display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.input-shell:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.input-shell:has([aria-invalid="true"]) { border-color: var(--error); }
.input-shell input { flex: 1; min-width: 0; height: 42px; padding: 0 4px; border: 0; outline: none; background: transparent; color: var(--text); font-size: 14px; }
.input-shell .icon-button { width: 36px; min-width: 36px; height: 40px; color: var(--muted); }
.input-shell .icon-button svg { width: 16px; height: 16px; }
.switch-control { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; margin: 0; flex-shrink: 0; position: relative; cursor: pointer;
  border-radius: 30px; border: 1px solid var(--border); background: var(--border); }
.switch-control::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg); transition: translate .15s; }
.switch-control:checked { background: var(--brand); border-color: var(--brand); }
.switch-control:checked::after { translate: 16px; }
.switch-control:disabled { cursor: wait; opacity: .6; }

/* ── 표 ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.4; }
th { text-align: left; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
tbody tr:hover td { background: var(--surface); }
tbody tr:has(a[data-row-link]) { cursor: pointer; }   /* 행 전체 클릭(core-ui.js rowLink) */
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.pagination .button { min-height: 36px; padding: 0 12px; }

/* ── 하단 알림·모달 ── */
.cu-toasts { position: fixed; left: 50%; translate: -50% 0; bottom: 24px; z-index: 150; width: min(520px, calc(100vw - 100px)); display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: var(--radius); color: #fff; font-size: 14px; background: var(--info); }
.toast.success { background: var(--success); } .toast.error { background: var(--error); } .toast.warning { background: var(--warning); }
.toast > span { flex: 1; }
.toast .icon-button { width: 32px; min-width: 32px; height: 32px; color: #fff; }
.toast .icon-button:hover { background: #ffffff22; }
dialog.cu-dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text);
  padding: 24px; width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
}
dialog.cu-dialog::backdrop { background: #07161580; }
.cu-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cu-dialog-body { font-size: 14px; color: var(--muted); line-height: 1.8; }
.cu-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ── 플로팅 도구(언어·테마·맨 위로)는 메인 사이트·Support 와 같은 fab.js 를 쓴다(core-ui.js 가 불러온다) ── */

/* 테마를 바꿀 때 메인 사이트처럼 0.3초에 걸쳐 색이 바뀐다(core-ui.js 가 잠깐 붙이는 클래스) */
html.cu-theme-anim, html.cu-theme-anim *, html.cu-theme-anim *::before, html.cu-theme-anim *::after {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease, stroke .3s ease !important;
}

/* ── 사이드바: 펼침 240 / 접힘 64, 메뉴 14px · 행 44px. 800px 이하는 서랍 ── */
body.cu-has-sidebar { --sidebar: 240px; }
body.cu-has-sidebar.cu-collapsed { --sidebar: 64px; }
.cu-sidebar {
  position: fixed; top: var(--header); bottom: 0; left: 0; width: var(--sidebar); z-index: 55; overflow-y: auto;
  padding: 20px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
body.cu-has-sidebar .cu-pagebar, body.cu-has-sidebar .cu-main, body.cu-has-sidebar .cu-footer { margin-left: var(--sidebar); }
body.cu-has-sidebar .cu-main { max-width: none; width: auto; margin-right: 0; }
body.cu-has-sidebar .cu-main > * { max-width: 1112px; }
body.cu-has-sidebar .cu-pagebar-in { margin: 0; max-width: 1112px; }
body.cu-has-sidebar .cu-toasts { left: calc(50% + var(--sidebar) / 2); }
.cu-nav-group { margin: 24px 12px 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cu-nav-group:first-child { margin-top: 4px; }
.cu-nav-link {
  min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0;
  border-radius: var(--radius); font-size: 14px; line-height: 1.4; color: var(--text);
}
.cu-nav-link svg { width: 18px; height: 18px; }
.cu-nav-link [data-icon] { display: inline-flex; }
.cu-nav-link:hover { background: var(--border); }
.cu-nav-link[aria-current="page"] { background: var(--soft); color: var(--focus); font-weight: 600; }
.cu-nav-link.danger { color: var(--error); }
.cu-collapsed .cu-sidebar { padding: 16px 8px; }
.cu-collapsed .cu-nav-link { justify-content: center; padding: 12px; }
.cu-collapsed .cu-nav-link span:not([data-icon]), .cu-collapsed .cu-nav-group { display: none; }
.cu-nav-backdrop { position: fixed; inset: var(--header) 0 0; background: #0005; z-index: 54; }

/* ── 푸터 — 로고(서비스명 없이 Bibong.dev)·개인정보처리방침 굵게·이용약관·공지사항·고객지원·저작권 ── */
.cu-footer { border-top: 1px solid var(--border); background: var(--surface); }
.cu-footer-in { max-width: 1160px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; font-size: 12px; color: var(--muted); }
.cu-footer-brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.cu-footer-brand img { width: 22px; height: auto; display: block; }
.cu-footer-brand strong span { color: var(--muted); font-weight: 600; }
.cu-footer-links { display: flex; gap: 4px 20px; flex-wrap: wrap; }
.cu-footer-links a:hover { color: var(--text); }
.cu-footer-links a.bold { font-weight: 700; color: var(--text); }
.cu-footer-copy { margin-left: auto; }

@media (max-width: 800px) {
  .cu-header { padding: 0 12px; }
  .cu-pagebar { padding: 12px 16px; }
  .cu-pagebar h1 { font-size: 24px; }
  .cu-main { padding: 24px 16px 64px; }
  .cu-toasts, body.cu-has-sidebar .cu-toasts { left: 50%; width: calc(100vw - 32px); bottom: 16px; }
  /* 사이드바는 서랍으로 — 헤더의 메뉴 버튼으로 열고 닫기·Esc·배경 클릭으로 닫는다 */
  body.cu-has-sidebar, body.cu-has-sidebar.cu-collapsed { --sidebar: 0px; }
  .cu-sidebar { width: 240px; translate: -100% 0; transition: translate .18s; padding: 20px 12px; }
  .cu-nav-open .cu-sidebar { translate: 0; }
  .cu-collapsed .cu-nav-link { justify-content: flex-start; padding: 10px 12px; }
  .cu-collapsed .cu-nav-link span:not([data-icon]), .cu-collapsed .cu-nav-group { display: revert; }
  .input-shell input { font-size: 16px; }
  .cu-footer-in { padding: 18px 16px; }
  .cu-footer-copy { margin-left: 0; width: 100%; }
  input, textarea, select { font-size: 16px; }   /* 모바일 자동 확대 방지 */
}
@media (max-width: 480px) { .cu-brand-wrap { gap: 8px; } .cu-brand strong { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
