/* ============================================================
   ReadingBee ERP — 공통 디자인 시스템 (claude.ai/design 목업 기반)
   - 토큰(:root 변수) + 전역 리셋 + 셸(유틸바/GNB/서브내비) + 공통 헬퍼
   - 페이지별 컴포넌트는 각 페이지 CSS에서 이 변수들을 사용해 재스킨한다.
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');

:root {
  /* 브랜드 */
  --accent: #3a5a8c; --accent-d: #2d4a78; --accent-soft: #eef2f8;
  /* 표면 */
  --bg: #f4f5f7; --card: #fff; --card-2: #f7f8fa;
  /* 다크 유틸바 */
  --util-bg: #171b24; --util-chip: #262b36; --util-chip-2: #23282f;
  --util-border: #313844; --util-fg: #c3cad4; --util-fg-dim: #8a93a3; --util-fg-strong: #e7eaef;
  /* 텍스트 */
  --ink: #14181f; --ink-2: #2b313c; --ink-3: #5b6573; --muted: #8a93a3; --muted-2: #9aa2ad;
  /* 라인 */
  --line: #e7e9ee; --line-2: #e0e3e9; --line-input: #dfe2e8; --line-row: #f0f1f4; --line-soft: #eef0f3;
  /* 3단계(접속/책읽기/러닝완료) */
  --stage-access: #3a5a8c; --stage-reading: #7a5bbf; --stage-done: #1f9d76;
  /* 의미색 */
  --ok: #2f7d5b; --ok-fg: #2f6b4a; --ok-bg: #e9f0ea;
  --danger: #b54141; --danger-fg: #b54141; --danger-bg: #f4e3e3;
  --warn: #8a5a2a; --warn-strong: #c08043; --warn-bg: #f6efe6;
  --info: #3a5a8c; --info-bg: #eaf1f8;
  /* 5등급 pill (vgood/good/ok/bad/vbad) */
  --g-vgood-bg: #e3efe8; --g-vgood-fg: #1f5c40; --g-vgood-dot: #2f7d5b;
  --g-good-bg:  #eaf3ec; --g-good-fg:  #2f6b4a; --g-good-dot:  #4a9b6e;
  --g-ok-bg:    #f4efdb; --g-ok-fg:    #7a6418; --g-ok-dot:    #b89a3c;
  --g-bad-bg:   #f6ebde; --g-bad-fg:   #8a5a2a; --g-bad-dot:   #c08043;
  --g-vbad-bg:  #f4e3e3; --g-vbad-fg:  #8a3838; --g-vbad-dot:  #b54141;
  /* 형태 */
  --radius: 14px; --radius-sm: 8px; --radius-xs: 6px; --radius-pill: 99px;
  --shadow: 0 1px 2px rgba(20,24,31,.03);
  --shadow-card: 0 1px 2px rgba(20,24,31,.04);
  --shadow-pop: 0 24px 60px rgba(0,0,0,.30);
  --maxw: 1320px;
  --c-pad: 22px 24px; --th-pad: 12px 14px; --td-pad: 13px 14px;
  --font: 'Pretendard', 'Pretendard Variable', 'Malgun Gothic', -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #cdd8e8; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d3d8e0; border-radius: 8px; border: 2px solid #f4f5f7; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }
input::placeholder, textarea::placeholder { color: #aab2bf; }
a { color: inherit; text-decoration: none; }

/* ============================================================
   셸 1 — 다크 유틸리티 바
   ============================================================ */
.rb-util { background: var(--util-bg); color: #fff; height: 48px; position: relative; z-index: 30; }
.rb-util-in {
  max-width: var(--maxw); margin: 0 auto; height: 100%; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.rb-util-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.rb-logo { display: flex; align-items: center; gap: 9px; }
.rb-logo-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.5px; color: #fff;
}
.rb-logo b { font-size: 16.5px; letter-spacing: -.4px; color: #fff; }
.rb-logo-sub { font-size: 12px; color: var(--util-fg-dim); font-weight: 600; letter-spacing: .5px; }
.rb-rolechip {
  margin-left: 6px; font-size: 11.5px; color: #cbd3df; background: var(--util-chip);
  padding: 3px 9px; border-radius: var(--radius-pill); font-weight: 600; white-space: nowrap;
}
.rb-rolechip:empty { display: none; }
.rb-util-right { display: flex; align-items: center; gap: 14px; }
.rb-util-link {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  color: var(--util-fg); font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 7px 4px; border: none; background: none; font-family: inherit;
}
.rb-util-link:hover { color: var(--util-fg-strong); }
.rb-dot-badge {
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
  border-radius: var(--radius-pill); min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.rb-util-div { width: 1px; height: 22px; background: var(--util-border); }
.rb-user { display: flex; align-items: center; gap: 9px; }
.rb-user-ava {
  width: 30px; height: 30px; border-radius: 50%; background: #3a4150; color: var(--util-fg-strong);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.rb-user-meta { line-height: 1.25; }
.rb-user-meta b { font-size: 12.5px; font-weight: 700; color: #fff; display: block; }
.rb-user-meta span { font-size: 11px; color: var(--util-fg-dim); }

/* 로그아웃 버튼 (#logoutBtn .logout) — 유틸바 안에 배치 */
.logout {
  background: var(--util-chip); color: var(--util-fg); border: 1px solid var(--util-border);
  border-radius: 7px; padding: 7px 12px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.logout:hover { background: #2f3540; color: var(--util-fg-strong); }

/* ============================================================
   셸 2 — 흰색 상단 메뉴 (GNB, sticky)
   ============================================================ */
.rb-gnb {
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 2px rgba(20,24,31,.03);
}
.rb-gnb-in {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.rb-gnb-nav { display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; }
.rb-gnb-nav::-webkit-scrollbar { display: none; }
.rb-nav {
  height: 54px; padding: 0 2px; margin-right: 30px; background: none; border: none;
  border-bottom: 2px solid transparent; color: #6b7480; font-size: 14.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 7px;
  letter-spacing: -.2px; white-space: nowrap; text-decoration: none;
}
.rb-nav:last-child { margin-right: 0; }
.rb-nav:hover { color: var(--ink-2); }
.rb-nav.on { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.rb-nav-badge {
  background: #f0e0e0; color: var(--danger); font-size: 11px; font-weight: 700;
  border-radius: var(--radius-pill); padding: 1px 7px; line-height: 1.4;
}
.rb-gnb-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.rb-gnb-meta .rb-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ============================================================
   셸 3 — 서브 내비게이션(페이지 콘텐츠 상단 pill 행)
   ============================================================ */
.rb-subnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.rb-sub {
  display: inline-flex; align-items: center; gap: 7px; background: transparent; color: #6b7480;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 7px 14px;
  font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  letter-spacing: -.2px; text-decoration: none;
}
.rb-sub:hover { color: var(--ink-2); }
.rb-sub.on { background: #fff; color: var(--ink); border-color: var(--line-2); box-shadow: 0 1px 2px rgba(20,24,31,.06); }
.rb-sub-badge {
  background: #f0e0e0; color: var(--danger); font-size: 10.5px; font-weight: 700;
  border-radius: var(--radius-pill); padding: 1px 6px;
}

/* ============================================================
   공통 콘텐츠 래퍼 & 페이지 헤더
   ============================================================ */
.rb-wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px 24px 56px; }
.rb-phead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.rb-phead-crumb { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.rb-phead-crumb i { color: #c5ccd5; margin: 0 6px; font-style: normal; }
.rb-phead h1 { font-size: 23px; font-weight: 800; letter-spacing: -.6px; line-height: 1.2; color: var(--ink); }
.rb-phead-desc { font-size: 13.5px; color: var(--ink-3); margin-top: 5px; }
.rb-phead-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ============================================================
   공통 헬퍼
   ============================================================ */
.muted { color: var(--muted); }
.back-link { color: var(--util-fg); font-size: 12.5px; font-weight: 600; }
.back-link:hover { color: var(--util-fg-strong); }
.user-scope { /* 구 클래스 별칭 — 유틸바 역할칩과 동일 톤 */ }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 720px) {
  .rb-util-in, .rb-gnb-in, .rb-wrap { padding-left: 16px; padding-right: 16px; }
  .rb-util-link { font-size: 0; gap: 0; }       /* 좁은 화면: 텍스트 숨기고 배지만 */
  .rb-util-link .rb-dot-badge { font-size: 10px; }
  .rb-user-meta { display: none; }
  .rb-logo-sub { display: none; }
  .rb-nav { margin-right: 20px; font-size: 14px; }
  .rb-phead h1 { font-size: 20px; }
}

/* ============================================================
   공통 스타일 모달 (window.rbModal — confirm/prompt/alert)
   ============================================================ */
.rb-modal-overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(20,24,31,.45);
}
.rb-modal-overlay.on { display: flex; }
.rb-modal-box {
  background: var(--card); border-radius: 16px; width: 460px; max-width: 100%;
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-pop);
  animation: rbModalIn .14s ease;
}
@keyframes rbModalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.rb-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line-soft);
}
.rb-modal-title { font-size: 16.5px; font-weight: 800; letter-spacing: -.3px; color: var(--ink); }
.rb-modal-x {
  width: 30px; height: 30px; border: none; background: #f1f3f6; border-radius: 8px;
  cursor: pointer; font-size: 17px; color: var(--ink-3); font-family: inherit; line-height: 1;
}
.rb-modal-x:hover { background: #e9ecf1; }
.rb-modal-body { padding: 20px 22px; }
.rb-modal-msg { font-size: 14px; color: var(--ink-2); line-height: 1.6; white-space: pre-wrap; }
.rb-modal-input, .rb-modal-textarea {
  width: 100%; margin-top: 14px; border: 1px solid var(--line-input); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--ink-2);
  background: #fff; outline: none; resize: vertical;
}
.rb-modal-input:focus, .rb-modal-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,90,140,.12); }
.rb-modal-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(181,65,65,.12) !important; }
.rb-modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}
.rb-modal-btn {
  border-radius: var(--radius-sm); padding: 10px 20px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; border: 1px solid transparent;
}
.rb-modal-cancel { background: #fff; color: var(--ink-3); border-color: var(--line-input); }
.rb-modal-cancel:hover { background: #f7f8fa; }
.rb-modal-ok { background: var(--accent); color: #fff; }
.rb-modal-ok:hover { background: var(--accent-d); }
.rb-modal-ok.danger { background: var(--danger); }
.rb-modal-ok.danger:hover { background: #9e3636; }

/* ============================================================
   계정 드롭다운 — 유틸바 우측 '내 계정' 메뉴 (shell.js 가 주입)
   ============================================================ */
.rb-user {                                   /* 트리거화: 클릭 가능 + 캐럿 자리 */
  position: relative; cursor: pointer; user-select: none;
  padding: 4px 8px; border-radius: 8px; border: 1px solid transparent;
}
.rb-user:hover { background: var(--util-chip-2); border-color: var(--util-border); }
.rb-user.on { background: var(--util-chip-2); border-color: var(--util-border); }
.rb-acct-caret { display: inline-flex; color: var(--util-fg-dim); transition: transform .15s ease; }
.rb-user.on .rb-acct-caret { transform: rotate(180deg); }
.rb-acct-menu {
  position: absolute; top: calc(100% + 9px); right: 0; min-width: 210px;
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow-pop);
  padding: 6px; display: none; z-index: 50;
}
.rb-acct-menu.on { display: block; animation: rbModalIn .12s ease; }
.rb-acct-head { padding: 9px 12px 11px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.rb-acct-head b { display: block; font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: -.2px; }
.rb-acct-head span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rb-acct-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: none; background: none; border-radius: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; text-align: left; letter-spacing: -.2px;
}
.rb-acct-item:hover { background: var(--accent-soft); color: var(--accent-d); }
.rb-acct-item svg { width: 16px; height: 16px; flex: none; }
.rb-acct-item.danger { color: var(--ink-3); }
.rb-acct-item.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   모달 폼 필드 — 라벨 + 비밀번호 입력(표시 토글) + 힌트/에러
   ============================================================ */
.rb-field { margin-top: 16px; }
.rb-field:first-child { margin-top: 0; }
.rb-field-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 7px; }
.rb-pw-wrap {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 1px solid var(--line-input); border-radius: var(--radius-sm); padding: 0 10px 0 12px;
}
.rb-pw-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,90,140,.12); }
.rb-pw-wrap.rb-field-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(181,65,65,.12); }
.rb-pw-wrap input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  padding: 11px 0; font-size: 14px; font-family: inherit; color: var(--ink-2);
}
.rb-pw-eye {
  border: none; background: none; cursor: pointer; color: var(--muted-2);
  padding: 5px; display: inline-flex; border-radius: 6px; line-height: 1;
}
.rb-pw-eye:hover { color: var(--ink-3); background: #f1f3f6; }
.rb-pw-eye svg { width: 18px; height: 18px; display: block; }
.rb-field-hint { font-size: 11.5px; color: var(--muted); margin-top: 7px; }
.rb-field-err { font-size: 12px; color: var(--danger); font-weight: 600; margin-top: 8px; display: none; }
.rb-field-err.on { display: block; }
/* 완료(성공) 상태 — 모달 본문 교체용(rbModal 미로드 페이지 대비) */
.rb-modal-done { text-align: center; padding: 14px 0 6px; }
.rb-modal-done-ic {
  width: 52px; height: 52px; border-radius: 50%; background: var(--ok-bg); color: var(--ok);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
}
.rb-modal-done-ic svg { width: 28px; height: 28px; }
.rb-modal-done b { font-size: 15.5px; font-weight: 800; color: var(--ink); letter-spacing: -.2px; }
.rb-modal-done p { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
