:root {
  --bg: #f5f7ff;
  --surface: #ffffff;
  --ink: #17203a;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --line: #e4e7ec;
  --gold: #fff4c2;
  --gold-line: #f5c542;
  --blue: #e7f1ff;
  --blue-line: #60a5fa;
  --purple: #f1eaff;
  --purple-line: #a78bfa;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 10px 30px rgba(62, 72, 120, .09);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(100%, 680px); margin: 0 auto; padding: 0 16px 90px; }

.auth-card {
  width: min(100%, 430px);
  margin: 10vh auto 0;
  padding: 34px 28px;
  text-align: center;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.auth-card.compact { margin-top: 14vh; }
.auth-card h1 { margin: 10px 0 8px; font-size: 2rem; }
.auth-card > p { color: var(--muted); line-height: 1.6; }
.brand-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: auto; border-radius: 24px; font-size: 2.2rem; background: #e8e7ff; }
.stack { display: grid; gap: 15px; margin-top: 24px; text-align: left; }
label { display: grid; gap: 7px; color: #344054; font-weight: 700; }
input, textarea, select {
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
textarea { min-height: 92px; resize: vertical; }
small { color: var(--muted); font-weight: 500; }
.primary, .secondary, .danger {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  font-weight: 800;
}
.primary { color: #fff; background: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.secondary { color: var(--primary-dark); background: #eeedff; }
.danger { color: #fff; background: var(--danger); }
.big { min-height: 54px; font-size: 1.05rem; }
.text-link { display: inline-block; margin-top: 24px; color: var(--primary); font-weight: 800; }
.error { min-height: 1.3em; color: var(--danger) !important; font-weight: 700; }

.app-header { display: flex; align-items: center; justify-content: space-between; min-height: 70px; }
.logo { text-decoration: none; font-size: 1.08rem; font-weight: 900; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: #e9eafd; color: var(--primary-dark); text-decoration: none; font-weight: 900; }

.hero-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 190px;
  padding: 28px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero-card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -70px; top: -70px; border-radius: 50%; background: rgba(255,255,255,.11); }
.avatar-button { position: relative; z-index: 1; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; }
.avatar { display: grid; place-items: center; flex: none; width: 54px; height: 54px; overflow: hidden; border-radius: 50%; background: #eef0ff; font-size: 1.65rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xl { width: 92px; height: 92px; border: 4px solid rgba(255,255,255,.8); font-size: 2.3rem; }
.camera-dot { position: absolute; right: -2px; bottom: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #fff; font-size: .9rem; }
.eyebrow { margin: 0 0 5px; font-size: .85rem; font-weight: 900; letter-spacing: .04em; opacity: .85; }
.balance { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.balance strong { font-size: clamp(2.65rem, 10vw, 4.3rem); line-height: 1.05; letter-spacing: -.05em; }
.challenge { margin: 10px 0 0; font-weight: 800; }
.badge-row { display: flex; gap: 8px; padding: 12px 3px 2px; overflow-x: auto; }
.badge { flex: none; padding: 7px 11px; border: 1px solid #f5c542; border-radius: 999px; background: #fff8d8; color: #7a4d00; font-size: .82rem; font-weight: 800; }

.pending-summary { display: grid; gap: 7px; margin: 16px 0; padding: 18px 20px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.pending-summary > div { display: flex; justify-content: space-between; align-items: center; }
.pending-summary span { color: var(--muted); font-size: .9rem; font-weight: 700; }
.pending-summary strong { font-size: 1.4rem; color: var(--primary-dark); }
.pending-summary p { margin: 0; color: var(--primary-dark); font-size: .88rem; font-weight: 700; }
.action-button { display: flex; justify-content: center; align-items: center; gap: 12px; width: 100%; min-height: 72px; margin: 16px 0 28px; border-radius: 20px; font-size: 1.6rem; box-shadow: 0 9px 22px rgba(79, 70, 229, .24); }
.action-button span:last-child { display: grid; text-align: left; }
.action-button strong { font-size: 1.08rem; }
.action-button small { color: #deddff; }

.section { margin: 24px 0; }
.section-title { margin-bottom: 12px; }
.section-title > div { display: flex; align-items: center; gap: 8px; }
.section-title h2 { margin: 0; font-size: 1.18rem; }
.section-title p { margin: 5px 0 0 35px; color: var(--muted); font-size: .83rem; }
.section-icon { font-size: 1.25rem; }
.section-action { width: 100%; margin: 0 0 10px; }
.transfer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.ranking-list { display: grid; gap: 10px; }
.rank-card {
  display: grid;
  grid-template-columns: 42px 52px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: 20px;
}
.rank-card.rank-1 { background: var(--gold); border-color: var(--gold-line); }
.rank-card.rank-2 { background: var(--blue); border-color: var(--blue-line); }
.rank-card.rank-3 { background: var(--purple); border-color: var(--purple-line); }
.rank-number { font-size: 1.3rem; font-weight: 950; }
.rank-name { display: grid; gap: 3px; min-width: 0; }
.rank-name strong { overflow: hidden; text-overflow: ellipsis; }
.rank-name small { font-weight: 800; }
.rank-value { text-align: right; font-size: 1.25rem; font-weight: 950; white-space: nowrap; }

.record-list { display: grid; gap: 10px; }
.record-card { padding: 16px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); }
.record-main { display: flex; justify-content: space-between; gap: 12px; }
.record-main strong { display: block; }
.record-main p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.record-minutes { color: var(--primary-dark); font-weight: 900; white-space: nowrap; }
.record-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.record-actions button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; font-weight: 800; }
.edit-button { color: var(--primary-dark); background: #eeedff; }
.cancel-button, .danger-link { color: var(--danger); background: #fff0ee; }
.danger-link { min-height: 42px; border: 0; border-radius: 10px; font-weight: 800; }
.empty { padding: 22px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #cfd4dc; border-radius: 16px; }

.message-list { display: grid; gap: 10px; }
.message-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.message-card.unread { border-color: #f5c542; background: #fffdf1; }
.message-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.message-head strong { display: block; }
.message-head small { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; }
.message-card p { margin: 0; color: #344054; line-height: 1.55; white-space: pre-wrap; }
.message-card button { justify-self: end; }
.message-badge { flex: none; padding: 5px 8px; color: #7a4d00; background: #fff4c2; border-radius: 999px; font-size: .72rem; font-weight: 900; }
.message-badge.read { color: var(--muted); background: #f2f4f7; }

.history-list { overflow: hidden; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.history-row { display: grid; grid-template-columns: 1fr repeat(3, auto); gap: 12px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); font-size: .87rem; }
.history-row:last-child { border-bottom: 0; }
.history-date { display: grid; gap: 3px; }
.history-date small { color: var(--muted); font-size: .72rem; line-height: 1.35; }
.plus { color: var(--success); font-weight: 800; }
.minus { color: var(--danger); font-weight: 800; }
.weekly-study-chart { display: grid; gap: 10px; min-height: 176px; margin-bottom: 12px; padding: 14px 12px 9px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.weekly-chart-legend, .chart-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: .75rem; font-weight: 800; }
.weekly-chart-legend span, .chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.weekly-user-1 { background: #f59e0b; }
.weekly-user-2 { background: #3b82f6; }
.weekly-user-3 { background: #8b5cf6; }
.weekly-user-4 { background: #10b981; }
.weekly-user-5 { background: #ef4444; }
.weekly-user-6 { background: #64748b; }
.earned-dot, .earned-bar { background: #12b76a; }
.used-dot, .used-bar { background: #f04438; }
.adjusted-dot, .adjusted-bar { background: #2563eb; }
.adjusted-bar.negative { background: #9333ea; }
.weekly-chart-days, .trend-columns { display: flex; align-items: end; gap: 7px; height: 118px; min-height: 118px; }
.weekly-chart-day { display: grid; flex: 1; height: 100%; grid-template-rows: 1fr auto; justify-items: center; gap: 5px; }
.weekly-chart-bars { display: flex; align-items: end; justify-content: center; gap: 3px; width: 100%; height: 100%; }
.weekly-chart-bar { width: 8px; min-height: 0; border-radius: 8px 8px 3px 3px; }
.trend-chart { display: grid; grid-template-rows: auto 1fr; gap: 8px; height: 150px; margin-bottom: 10px; padding: 13px 12px 7px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.trend-column { display: grid; flex: 1; height: 100%; grid-template-rows: 1fr auto; justify-items: center; gap: 5px; }
.trend-bar-wrap { display: flex; align-items: end; width: 100%; height: 100%; }
.activity-pair { display: flex; align-items: end; justify-content: center; gap: 3px; width: 100%; height: 100%; }
.activity-bar { width: 10px; min-height: 0; border-radius: 8px 8px 3px 3px; }
.trend-label { font-size: .7rem; color: var(--muted); }
.support-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.support-card h2 { margin: 0; font-size: 1rem; }
.support-card p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }

dialog { width: min(calc(100% - 24px), 520px); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 24px; box-shadow: 0 25px 70px rgba(23, 32, 58, .3); }
dialog::backdrop { background: rgba(17, 24, 39, .58); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 16px; padding: 24px; overflow-y: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.dialog-head h2 { margin: 0; }
.close-button { flex: none; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: #f0f1f5; font-size: 1.7rem; line-height: 1; }
.minute-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.study-input { padding: 13px; border-radius: 15px; }
.study-input span { font-size: .72rem; font-weight: 600; }
.study-input input { margin-top: 5px; background: rgba(255,255,255,.8); }
.study-input.seoul { background: #e8f2ff; }
.study-input.malhae { background: #f4eaff; }
.estimate { display: flex; justify-content: space-between; align-items: center; padding: 16px; color: var(--primary-dark); background: #efefff; border-radius: 14px; font-weight: 800; }
.estimate strong { font-size: 1.4rem; }
.photo-preview { display: grid; place-items: center; width: 110px; height: 110px; margin: auto; border-radius: 50%; background: #efefff; font-size: 2.7rem; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translate(-50%, 130px); width: max-content; max-width: calc(100% - 30px); padding: 13px 18px; color: #fff; background: #17203a; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transition: .25s; font-weight: 700; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.celebrate { animation: celebrate .7s ease; }
@keyframes celebrate { 0%,100% { transform: scale(1); } 40% { transform: scale(1.045) rotate(-1deg); } 70% { transform: scale(1.02) rotate(1deg); } }

.guide-shell { width: min(100% - 28px, 760px); margin: auto; padding: 24px 0 60px; }
.back-link { display: inline-block; margin-bottom: 22px; color: var(--primary); font-weight: 800; text-decoration: none; }
.guide-hero { padding: 30px; text-align: center; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed); border-radius: 26px; }
.guide-hero span { font-size: 3rem; }
.guide-hero h1 { margin: 7px 0; }
.guide-hero p { margin: 0; }
.guide-step { display: grid; grid-template-columns: 48px 1fr; gap: 15px; margin-top: 16px; padding: 22px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.guide-step > b { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--primary); border-radius: 50%; font-size: 1.25rem; }
.guide-step h2 { margin: 5px 0 8px; font-size: 1.14rem; }
.guide-step p { margin: 0; color: var(--muted); line-height: 1.65; }
.guide-picture { font-size: 2.1rem; }
.install-card { margin-top: 20px; padding: 24px; background: #fff8d8; border: 2px solid #f5c542; border-radius: 22px; }
.install-card > h2 { margin-top: 0; text-align: center; }
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.install-grid > div { padding: 18px; background: #fff; border-radius: 15px; }
.install-grid span { font-size: 2rem; }
.install-grid h3 { margin: 8px 0; font-size: 1rem; }
.install-grid ol { padding-left: 20px; color: var(--muted); line-height: 1.8; }
.help-note { display: flex; gap: 12px; margin-top: 16px; padding: 18px; background: #e8f2ff; border-radius: 18px; }
.help-note p { margin: 0; line-height: 1.6; }

.admin-body { background: #eef1f8; }
.admin-shell { width: min(100% - 32px, 1180px); margin: 0 auto; padding: 28px 0 70px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-header h1 { margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { padding: 18px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: .84rem; }
.stat strong { display: block; margin-top: 5px; font-size: 1.6rem; }
.admin-tabs { display: flex; gap: 7px; margin-bottom: 16px; overflow-x: auto; }
.admin-tabs button { flex: none; padding: 11px 16px; border: 0; border-radius: 12px; color: #475467; background: #fff; font-weight: 800; }
.admin-tabs button.active { color: #fff; background: #172554; }
.admin-panel { padding: 22px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0 0 15px; }
.admin-list { display: grid; gap: 10px; }
.admin-card { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 17px; }
.admin-card h2 { margin-top: 0; font-size: 1.1rem; }
.approval-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 17px; border: 1px solid var(--line); border-radius: 15px; }
.approval-card h3 { margin: 0 0 5px; }
.approval-card p { margin: 3px 0; color: var(--muted); font-size: .88rem; }
.approval-card strong { color: var(--primary-dark); }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.three-column { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.button-row { display: flex; justify-content: flex-end; gap: 10px; }
.notice { padding: 13px; background: #f2f4f7; border-radius: 12px; line-height: 1.5; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.inline-form label { min-width: 150px; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border: 0; }
.user-row p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.audit-list { max-height: 380px; overflow-y: auto; }
.audit-row { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.audit-row p { margin: 3px 0; color: var(--muted); }
.ledger-grid-wrap { overflow-x: auto; padding-bottom: 8px; }
.ledger-grid { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .82rem; }
.ledger-grid th, .ledger-grid td { padding: 8px; border: 1px solid var(--line); text-align: center; white-space: nowrap; }
.ledger-grid thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; }
.ledger-grid tbody th { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; }
.ledger-grid input { width: 92px; padding: 8px 9px; border-radius: 8px; text-align: right; }
.ledger-grid input.dirty { border-color: var(--primary); background: #eeedff; }
.balance-cell { color: var(--primary-dark); font-weight: 900; background: #f8fafc; }

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-column, .three-column { grid-template-columns: 1fr; }
  .admin-panel { padding: 14px; }
  .approval-card { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .shell { padding-inline: 12px; }
  .auth-card { margin-top: 5vh; padding: 28px 20px; }
  .hero-card { min-height: 174px; padding: 22px 18px; gap: 13px; }
  .avatar-xl { width: 78px; height: 78px; }
  .balance strong { font-size: 2.85rem; }
  .rank-card { grid-template-columns: 34px 46px 1fr auto; padding: 11px; }
  .minute-grid, .install-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr repeat(3, auto); gap: 7px; font-size: .78rem; }
  .support-card { align-items: end; }
  .transfer-actions { grid-template-columns: 1fr; }
  .guide-step { grid-template-columns: 40px 1fr; padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
