*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-light: #EFF6FF;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --sidebar-w: 220px;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ─── 레이아웃 ─── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: #1E293B; color: #CBD5E1;
  display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100;
}
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid #334155; }
.sidebar-logo h2 { font-size: 15px; color: #F8FAFC; font-weight: 700; line-height: 1.4; }
.sidebar-logo span { font-size: 11px; color: #64748B; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  cursor: pointer; border-radius: 0; transition: background .15s; text-decoration: none; color: #94A3B8;
  font-size: 13.5px;
}
.nav-item:hover { background: #334155; color: #F1F5F9; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid #334155; font-size: 12px; }
.sidebar-footer .user-name { color: #F1F5F9; font-weight: 600; }
.sidebar-footer .plan-badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; margin-left: 6px; }
.badge-pro { background: #22C55E; color: #fff; }
.badge-free { background: #64748B; color: #fff; }
.btn-logout { margin-top: 8px; font-size: 12px; color: #64748B; cursor: pointer; background: none; border: none; padding: 0; }
.btn-logout:hover { color: #EF4444; }

.main { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-width: 0; }

/* ─── 페이지 헤더 ─── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ─── 카드 ─── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ─── 통계 카드 ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-icon { font-size: 22px; float: right; opacity: .4; }

/* ─── 버튼 ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 7px;
  font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── 폼 ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13.5px; color: var(--text); background: #fff; transition: border .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.form-control::placeholder { color: #CBD5E1; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 12px; }
.form-row.col2 { grid-template-columns: 1fr 1fr; }
.form-row.col3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── 테이블 ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #F8FAFC; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 10px 14px;
  text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFC; }
.td-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* ─── 배지 ─── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-blue { background: #DBEAFE; color: #1D4ED8; }
.badge-green { background: #DCFCE7; color: #166534; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-gray { background: #F1F5F9; color: #475569; }
.badge-yellow { background: #FEF3C7; color: #92400E; }

/* ─── 검색/필터 바 ─── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
  background: #fff; min-width: 220px; }
.search-input:focus { outline: none; border-color: var(--primary); }

/* ─── 페이지네이션 ─── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 16px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  background: #fff; font-size: 13px; transition: all .15s; }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── 모달 ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15); max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 640px; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.hidden { display: none !important; }

/* ─── 알림 토스트 ─── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); animation: slideIn .2s ease; max-width: 340px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── 태그 입력 ─── */
.tag-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--border);
  border-radius: 7px; background: #fff; min-height: 42px; align-items: center; cursor: text; }
.tag-container:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.tag-item { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-light);
  color: var(--primary-dark); border-radius: 5px; padding: 2px 8px; font-size: 12px; font-weight: 500; }
.tag-remove { cursor: pointer; font-size: 14px; line-height: 1; color: var(--primary); }
.tag-remove:hover { color: var(--danger); }
.tag-input-field { border: none; outline: none; font-size: 13px; flex: 1; min-width: 80px; padding: 2px 4px; }

/* ─── 로그인 페이지 ─── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: #fff; border-radius: 14px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 4px 30px rgba(0,0,0,.1); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.auth-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.auth-tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; font-size: 14px;
  font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── 스위치 ─── */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #CBD5E1; border-radius: 22px; transition: .2s; }
.slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; }
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(18px); }

/* ─── 빈 상태 ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ─── 로딩 ─── */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ─── 구독 만료 배너 ─── */
.expired-banner { background: #FEF3C7; border: 1px solid #FDE68A; border-radius: 8px; padding: 12px 16px;
  margin-bottom: 20px; font-size: 13px; color: #92400E; display: flex; align-items: center; gap: 8px; }

/* 반응형 */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 20px 16px; }
}
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row.col2, .form-row.col3 { grid-template-columns: 1fr; }
}
