:root {
  --bg: #f4f8f6;
  --panel: rgba(255, 255, 255, .86);
  --panel-2: #ffffff;
  --line: rgba(23, 48, 56, .1);
  --line-2: rgba(23, 48, 56, .16);
  --text: #173038;
  --text-2: #3d5560;
  --muted: #6d828c;
  --gold: #c9872e;
  --violet: #0f8f82;
  --blue: #2a5a8c;
  --ok: #2f9e62;
  --no: #e06b4a;
  --grad: linear-gradient(120deg, var(--gold), var(--violet) 50%, var(--blue));
  --ease: cubic-bezier(.2, .8, .2, 1);
  --num: "Inter", "Pretendard Variable", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(120px); }
.b1 { width: 560px; height: 560px; background: #1aa89a; top: -280px; left: -160px; opacity: .18; }
.b2 { width: 480px; height: 480px; background: #e06b4a; top: -220px; right: -160px; opacity: .12; }

.eyebrow { font-family: var(--num); font-size: 11.5px; font-weight: 600; letter-spacing: .2em; color: var(--muted); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .1s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: #fff; color: #0b0c12; }
.btn-primary:hover { box-shadow: 0 8px 30px rgba(183, 156, 255, .35); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: var(--panel); border: 1px solid var(--line-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-text { color: var(--text-2); padding: 0 12px; }
.btn-text:hover { color: #fff; background: var(--panel); }
.btn-danger { color: var(--no); border: 1px solid rgba(255, 122, 138, .3); background: rgba(255, 122, 138, .06); }
.btn-danger:hover { background: rgba(255, 122, 138, .14); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; height: 50px; font-size: 15px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: var(--panel-2); color: #fff; }

/* ---------- 로그인 ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; padding: 44px 32px 28px; border-radius: 28px; text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
  border: 1px solid var(--line-2);
  box-shadow: 0 50px 120px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(24px);
  animation: rise .6s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-logo { width: 56px; filter: drop-shadow(0 10px 30px rgba(183, 156, 255, .45)); }
.login-card .eyebrow { margin-top: 22px; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; }
.login-id {
  display: flex; align-items: center; gap: 12px; margin-top: 28px; height: 50px; padding: 0 16px;
  border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line);
}
.login-id span { font-family: var(--num); font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--muted); }
.login-id b { font-family: var(--num); font-weight: 600; color: var(--text-2); }
.login-pw {
  width: 100%; height: 54px; margin-top: 10px; padding: 0 16px; border-radius: 14px;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line-2); font-size: 18px; letter-spacing: .2em;
  text-align: center; transition: border-color .2s, box-shadow .2s;
}
.login-pw::placeholder { letter-spacing: 0; font-size: 15px; color: #555a6c; }
.login-pw:focus { outline: none; border-color: rgba(183, 156, 255, .6); box-shadow: 0 0 0 4px rgba(183, 156, 255, .15); }
.login-error { min-height: 22px; margin: 8px 0 6px; font-size: 13px; color: var(--no); }
.login-card.shake { animation: shake .4s var(--ease); }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.login-back { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-back:hover { color: var(--text); }

/* ---------- 앱 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(7, 8, 13, .7); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.03em; }
.brand img { width: 30px; }
.brand em {
  font-style: normal; font-family: var(--num); font-size: 11px; font-weight: 700; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 999px; background: var(--grad); color: #11121a;
}
.top-actions { display: flex; align-items: center; gap: 4px; }

.main { max-width: 1320px; margin: 0 auto; padding: 32px 28px 80px; animation: rise .5s var(--ease) both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-size: 30px; font-weight: 800; letter-spacing: -.04em; margin-top: 6px; }
.updated { font-family: var(--num); font-size: 12.5px; color: var(--muted); }

.card { border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { padding: 22px; border-radius: 20px; background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015)); border: 1px solid var(--line); }
.kpi dt { font-size: 13px; color: var(--muted); }
.kpi dd { font-family: var(--num); font-size: 36px; font-weight: 700; letter-spacing: -.04em; margin-top: 10px; }
.kpi dd small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi p { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.kpi p b { color: var(--ok); font-weight: 600; }

.charts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.charts .card { padding: 20px; min-height: 220px; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.card > header b { font-size: 14px; }
.card > header span { font-size: 12px; color: var(--muted); }

.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 70px 1fr 28px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar > span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar > b { font-family: var(--num); text-align: right; }
.hbar .track { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .05); overflow: hidden; }
.hbar .fill { height: 100%; width: 0; border-radius: 6px; background: var(--grad); transition: width 1s var(--ease); }

.stack { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: rgba(255, 255, 255, .05); }
.stack i { height: 100%; transition: width 1s var(--ease); }
.stack-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; margin-top: 20px; }
.stack-legend div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.stack-legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.stack-legend b { margin-left: auto; font-family: var(--num); color: var(--text); }

.spark { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; align-items: end; height: 140px; }
.spark div { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.spark i { width: 100%; min-height: 2px; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--violet), rgba(110, 168, 255, .5)); transition: height .9s var(--ease); }
.spark i.zero { background: rgba(255, 255, 255, .08); }
.spark span { font-family: var(--num); font-size: 9.5px; color: var(--muted); margin-top: 6px; }
.spark div:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); white-space: nowrap;
  font-size: 11px; padding: 4px 8px; border-radius: 6px; background: #1a1b29; border: 1px solid var(--line-2);
}

/* 테이블 */
.table-card { margin-top: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px; border-bottom: 1px solid var(--line); }
.search { flex: 1; min-width: 220px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 12px; font-size: 14px;
  background: rgba(0, 0, 0, .25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8196' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 12px center / 16px;
  border: 1px solid var(--line-2);
}
.search input:focus, .select:focus, .f input:focus, .f textarea:focus, .modal-card input:focus {
  outline: none; border-color: rgba(183, 156, 255, .6); box-shadow: 0 0 0 3px rgba(183, 156, 255, .15);
}
.seg { display: flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.select {
  height: 40px; padding: 0 34px 0 12px; border-radius: 12px; font-size: 13.5px; appearance: none;
  background: rgba(0, 0, 0, .25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8196' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  border: 1px solid var(--line-2);
}
.select option { background: #14151f; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle span { position: relative; width: 34px; height: 20px; border-radius: 999px; background: rgba(255, 255, 255, .12); transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.toggle input:checked + span { background: var(--violet); }
.toggle input:checked + span::after { transform: translateX(14px); }
.count { margin-left: auto; font-family: var(--num); font-size: 12.5px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--text); }
.table th.sorted { color: var(--text); }
.table th.sorted::after { content: " ↓"; color: var(--violet); }
.table th.sorted.asc::after { content: " ↑"; }
.table td { padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .045); white-space: nowrap; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .15s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .03); }
.table .num { text-align: right; font-family: var(--num); }

.who { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #11121a; background: var(--grad);
}
.avatar.guest { background: rgba(255, 255, 255, .1); color: var(--text-2); }
.who b { display: block; font-weight: 600; }
.who small { font-family: var(--num); font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; margin-left: 6px; background: rgba(255, 255, 255, .08); color: var(--muted); vertical-align: 1px; }
.tag.paid { background: rgba(95, 227, 176, .18); color: #5fe3b0; }
.f.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 14px; }
.f.check input { width: 16px; height: 16px; }
.school small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.lv { display: inline-flex; align-items: center; gap: 8px; }
.lv b { font-family: var(--num); font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: rgba(183, 156, 255, .12); color: var(--violet); border: 1px solid rgba(183, 156, 255, .25); }
.lv b.master { background: var(--grad); color: #11121a; border: none; }
.lv span { font-size: 12px; color: var(--muted); }
.bests { display: flex; gap: 4px; }
.bests i {
  width: 30px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-style: normal;
  font-family: var(--num); font-size: 11.5px; font-weight: 700; background: rgba(255, 255, 255, .04); color: #4e5264; border: 1px solid var(--line);
}
.bests i.pass { background: rgba(95, 227, 176, .12); color: var(--ok); border-color: rgba(95, 227, 176, .3); }
.bests i.fail { background: rgba(255, 122, 138, .08); color: var(--no); border-color: rgba(255, 122, 138, .25); }
.date { font-family: var(--num); font-size: 12.5px; color: var(--text-2); }
.date small { display: block; font-size: 11px; color: var(--muted); }
.edit-link { font-size: 12.5px; color: var(--muted); }
tr:hover .edit-link { color: var(--violet); }
.empty { padding: 48px; text-align: center; color: var(--muted); font-size: 14px; }

/* 드로어 */
.drawer-bg { position: fixed; inset: 0; z-index: 40; background: rgba(3, 4, 8, .55); backdrop-filter: blur(4px); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(520px, 100%);
  background: #0e0f17; border-left: 1px solid var(--line-2); box-shadow: -40px 0 100px rgba(0, 0, 0, .5);
  transform: translateX(100%); transition: transform .35s var(--ease);
}
.drawer.open { transform: none; }
.drawer form { height: 100%; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.drawer-head .avatar { width: 46px; height: 46px; font-size: 18px; }
.drawer-head h3 { font-size: 18px; letter-spacing: -.02em; }
.drawer-head p { font-family: var(--num); font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 24px 24px; }
.drawer-body h4 { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.mini-stats dl { padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.mini-stats dt { font-size: 11.5px; color: var(--muted); }
.mini-stats dd { font-family: var(--num); font-size: 18px; font-weight: 700; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f { display: block; margin-bottom: 10px; }
.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.f > span em { font-style: normal; font-weight: 500; color: var(--muted); margin-left: 4px; }
.f input, .f textarea, .f .select, .modal-card input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 11px; font-size: 14px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line-2);
}
.f textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.level-edit { display: grid; grid-template-columns: 42px 1fr 42px; gap: 6px; }
.level-edit input { text-align: center; font-family: var(--num); font-size: 16px; font-weight: 700; }
.step-btn { height: 42px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 18px; }
.step-btn:hover { background: rgba(255, 255, 255, .1); }
.best-edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.best-edit label { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.best-edit span { display: block; font-family: var(--num); font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.best-edit input { width: 100%; height: 34px; border-radius: 8px; padding: 0 8px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line-2); font-family: var(--num); font-weight: 700; }
.form-error { min-height: 18px; margin-top: 8px; font-size: 13px; color: var(--no); }
.drawer-foot { display: grid; grid-template-columns: auto 1fr 1.4fr; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.drawer-foot .btn { height: 46px; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(3, 4, 8, .6); backdrop-filter: blur(6px); }
.modal-card { width: 100%; max-width: 380px; padding: 28px; border-radius: 22px; background: #12131c; border: 1px solid var(--line-2); box-shadow: 0 40px 100px rgba(0, 0, 0, .6); animation: rise .3s var(--ease) both; }
.modal-card h3 { font-size: 18px; margin-bottom: 18px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 8px; }
.modal-actions .btn { height: 44px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 16px);
  padding: 12px 18px; border-radius: 12px; background: #1a1b29; border: 1px solid var(--line-2);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .charts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .top-actions .btn-text { display: none; }
  .main { padding: 24px 16px 60px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi dd { font-size: 28px; }
  .charts { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
}
