:root {
  --bg: #f4f6f9; --panel: #ffffff; --text: #1b2330; --muted: #5d6b7e; --line: #dfe4ec;
  --brand: #2456d6; --brand-ink: #ffffff; --brand-soft: #e8eefc;
  --ok: #18794e; --ok-soft: #e3f4ea; --warn: #9a5b00; --warn-soft: #fdf1dc;
  --bad: #b42318; --bad-soft: #fde8e6; --info: #31527a; --info-soft: #e7eef7;
  --side: #121a2b; --side-ink: #c8d1e0; --side-active: #263453;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141d; --panel: #171e2a; --text: #e5eaf2; --muted: #9aa7ba; --line: #2a3446;
    --brand: #6f97ff; --brand-ink: #0b1220; --brand-soft: #1c2945;
    --ok: #4fd18b; --ok-soft: #13301f; --warn: #f0b252; --warn-soft: #34270f;
    --bad: #ff8a80; --bad-soft: #3a1714; --info: #9cc0ea; --info-soft: #1a2736;
    --side: #0a0f17; --side-ink: #aab6c8; --side-active: #1d2840;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.brand small { display: block; font-weight: 400; color: var(--side-ink); font-size: 12px; }
.side a { color: var(--side-ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; display: block; }
.side a:hover, .side a:focus-visible { background: var(--side-active); color: #fff; outline: none; }
.side a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.side .spacer { flex: 1; }
.main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .meta { color: var(--muted); font-size: 13px; text-align: right; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-105%); transition: transform .15s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 40px; }
}

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.stat .hint { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; }
@media (max-width: 520px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: 6px; } }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.danger.solid { background: var(--bad); color: #fff; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--brand-soft); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* notices */
.notice { border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; border: 1px solid transparent; }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--info-soft); color: var(--info); }
.secret-box { background: var(--bg); border: 1px dashed var(--brand); border-radius: 8px; padding: 14px; margin: 10px 0; }
.secret-box .mono { font-size: 18px; font-weight: 700; letter-spacing: .5px; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(10,15,25,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast-wrap { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth h1 { margin-bottom: 6px; }
.auth button.primary { width: 100%; margin-top: 16px; padding: 11px; }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.stat-link { color: inherit; text-decoration: none; display: block; }
.stat-link:hover { border-color: var(--brand); }
td:first-child { white-space: nowrap; }

.nowrap, .nowrap * { white-space: nowrap; word-break: normal; }
.nav-count { margin-left: 6px; }

/* ---------- 휴대폰·좁은 화면 ---------- */
.side-backdrop { display: none; }
@media (max-width: 860px) {
  .side { inset: 0 auto 0 0; width: min(280px, 82vw); overflow-y: auto; }
  .side-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(10,15,25,.45); z-index: 39; }
  .topbar { align-items: flex-start; }
  .topbar > div:first-child { width: 100%; }
  .topbar .menu-btn { margin-bottom: 10px; }
  .topbar .meta { text-align: left; }
}
@media (max-width: 700px) {
  html, body { font-size: 14px; }
  h1 { font-size: 19px; }
  .card { padding: 14px; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 22px; }
  .filters > * { flex: 1 1 100%; min-width: 0; }
  .row.end { justify-content: stretch; }
  .row.end > button, .row.end > .btn { flex: 1 1 auto; }
  .tabs { overflow-x: auto; }
  /* 표 → 카드: 한 줄이 한 카드, 칸 이름을 왼쪽에 표시 */
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 12px; box-shadow: var(--shadow); }
  .table-wrap td { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
  .table-wrap tr td:last-child { border-bottom: 0; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .table-wrap td > * { justify-self: start; max-width: 100%; }
  .table-wrap td.td-actions { display: flex; justify-content: flex-end; }
  .table-wrap td.td-actions::before { content: none; }
  .table-wrap .empty { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
  .pager { justify-content: space-between; flex-wrap: wrap; }
  .modal { padding: 16px; }
  .modal .actions { flex-wrap: wrap; }
  .modal .actions button { flex: 1 1 auto; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  dl.kv { grid-template-columns: 1fr; }
}

/* 사이드바 하위 메뉴 (가입 승인) */
.nav-group { margin-top: 6px; }
.nav-group-title { color: var(--side-ink); opacity: .75; font-size: 12px; font-weight: 700; padding: 8px 12px 4px; letter-spacing: .3px; }
.side a.sub { padding-left: 26px; font-size: 14px; position: relative; }
.side a.sub::before { content: ""; position: absolute; left: 14px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; }

/* 가입 승인 화면: 항목별 박스 */
.approval-box { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 18px; }
.approval-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.approval-head h2 { margin: 0; }
.approval-box > .card, .approval-box > div > .card { box-shadow: none; border: 0; padding: 0; margin: 12px 0 0; }
.approval-box .card h2 { font-size: 15px; }
.approval-box > .card > p.muted.small:first-child { display: none; }

/* 사이드바 '가입 승인' 드롭다운 */
.side .nav-toggle { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0;
  color: var(--side-ink); padding: 9px 12px; border-radius: 8px; font: inherit; font-weight: 400; cursor: pointer; text-align: left; }
.side .nav-toggle:hover, .side .nav-toggle:focus-visible { background: var(--side-active); color: #fff; outline: none; }
.side .nav-toggle.active { color: #fff; font-weight: 600; }
.nav-caret { font-size: 15px; opacity: .85; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.nav-sub.closed { display: none; }

/* 가입 승인: 글자 = 통합 화면 링크, 화살표 = 펼침 */
.nav-group-head { display: flex; align-items: center; gap: 2px; }
.nav-group-head .nav-head-link { flex: 1; }
.nav-group-head.in .nav-head-link { color: #fff; }
.side .nav-caret-btn { background: none; border: 0; color: var(--side-ink); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.side .nav-caret-btn:hover, .side .nav-caret-btn:focus-visible { background: var(--side-active); color: #fff; outline: none; }
/* 승인 대기 건수: 빨간 동그라미 안 숫자 */
.side .nav-count { background: #e5383b; color: #fff; border: 0; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px;
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; margin-left: 8px; vertical-align: middle;
  box-shadow: 0 0 0 2px var(--side); }

/* 설치 파일 > 업데이트 로그 */
.update-log { display: flex; flex-direction: column; gap: 10px; }
.update-log-item { border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 8px; padding: 10px 12px; }
.update-notes { white-space: pre-wrap; margin-top: 6px; font-size: 14px; }

/* 설치 파일: 사용자용 / 관리자용 탭 */
.edition-tabs button { font-size: 15px; padding: 8px 16px; }
