*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f7;
  color: #1a1a2e;
  min-height: 100vh;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }

:root {
  --primary: #1a6b8a;
  --primary-dark: #125270;
  --primary-light: #e8f4f8;
  --green: #3a7c4e;
  --green-light: #eaf4ee;
  --red: #e53935;
  --orange: #f0a500;
  --purple: #7c4dab;
  --text: #1a1a2e;
  --text-sub: #5a6278;
  --border: #e2e6ee;
  --card: #ffffff;
  --sidebar-w: 240px;
}

/* ── 로그인 화면 ─────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a6b8a 0%, #125270 100%);
}
.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-icon-wrap {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #1a6b8a, #3a7c4e);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin: 0 auto 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.login-logo p  { font-size: 13px; color: #5a6278; margin-top: 4px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; font-weight: 600; color: #5a6278; margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 12px 16px;
  border: 1.5px solid #e2e6ee; border-radius: 10px;
  font-size: 15px; font-family: inherit;
  transition: border-color .2s;
  outline: none;
}
.login-field input:focus { border-color: #1a6b8a; }
.login-err { font-size: 13px; color: #e53935; margin-bottom: 12px; min-height: 18px; }
.login-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #1a6b8a, #125270);
  color: #fff; border-radius: 12px;
  font-size: 15px; font-weight: 700;
  transition: opacity .2s;
}
.login-btn:hover { opacity: .9; }

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

/* ── 사이드바 ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1a1a2e;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .s-logo-row {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .s-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #1a6b8a, #3a7c4e);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-logo .s-title { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-logo .s-sub   { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 700; color: rgba(255,255,255,.3);
  letter-spacing: .08em; text-transform: uppercase;
  padding: 0 8px; margin: 16px 0 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 14px; color: rgba(255,255,255,.65);
  cursor: pointer; transition: all .2s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: #1a6b8a; color: #fff; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: #1a6b8a; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-admin-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  margin-bottom: 8px;
}
.admin-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1a6b8a, #3a7c4e);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.admin-name { font-size: 13px; font-weight: 600; color: #fff; }
.admin-role { font-size: 11px; color: rgba(255,255,255,.4); }
.logout-btn {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.5); font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.logout-btn:hover { background: rgba(255,0,0,.12); color: #ff6b6b; }

/* ── 메인 콘텐츠 ──────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 13px; color: #5a6278; }
.refresh-btn {
  padding: 8px 16px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  font-size: 13px; font-weight: 600;
  transition: background .2s;
}
.refresh-btn:hover { background: #d0e8f0; }

.content-body { padding: 28px 32px; flex: 1; }

/* ── 탭 패널 ──────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 통계 카드 ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff; border-radius: 16px;
  padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,.06);
  display: flex; align-items: center; gap: 16px;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.blue   { background: #e8f4f8; }
.stat-icon.green  { background: #eaf4ee; }
.stat-icon.orange { background: #fff4e0; }
.stat-icon.purple { background: #f3eefb; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: #5a6278; margin-top: 4px; }
.stat-change { font-size: 12px; color: #3a7c4e; margin-top: 6px; font-weight: 600; }

/* ── 섹션 헤더 ────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 16px; font-weight: 700; }
.section-count { font-size: 13px; color: #5a6278; margin-left: 8px; font-weight: 400; }

/* ── 검색 + 필터 바 ───────────────────────────────── */
.table-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.search-wrap {
  flex: 1; position: relative;
}
.search-wrap input {
  width: 100%; padding: 10px 16px 10px 38px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: var(--primary); }
.search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #aab; font-size: 15px; pointer-events: none;
}
.export-btn {
  padding: 10px 18px; border-radius: 10px;
  background: #1a1a2e; color: #fff;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: opacity .2s;
}
.export-btn:hover { opacity: .85; }

/* ── 테이블 ───────────────────────────────────────── */
.table-wrap {
  background: #fff; border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr { background: #f7f8fa; }
th {
  padding: 13px 16px;
  text-align: left; font-size: 12px; font-weight: 700;
  color: #5a6278; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  font-size: 14px; border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-consumer { background: #e8f4f8; color: #1a6b8a; }
.badge-producer { background: #eaf4ee; color: #3a7c4e; }
.badge-new      { background: #fff4e0; color: #c88400; }

.empty-row td {
  text-align: center; padding: 48px;
  color: #aab; font-size: 14px;
}

/* ── 최근 가입 카드 ───────────────────────────────── */
.recent-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin-top: 24px;
}
.recent-card {
  background: #fff; border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  overflow: hidden;
}
.recent-card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.recent-card-header h3 { font-size: 15px; font-weight: 700; }
.view-all {
  font-size: 12px; color: var(--primary); font-weight: 600; cursor: pointer;
}
.view-all:hover { text-decoration: underline; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #f0f2f5;
}
.recent-item:last-child { border-bottom: none; }
.recent-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.recent-avatar.consumer { background: linear-gradient(135deg, #1a6b8a, #1d8eb5); }
.recent-avatar.producer { background: linear-gradient(135deg, #3a7c4e, #4ea165); }
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: 14px; font-weight: 600; }
.recent-sub  { font-size: 12px; color: #5a6278; margin-top: 2px; }
.recent-time { font-size: 11px; color: #aab; white-space: nowrap; }

/* ── 토스트 ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1a2e; color: #fff;
  padding: 12px 24px; border-radius: 50px;
  font-size: 14px; font-weight: 500;
  opacity: 0; transition: all .3s; pointer-events: none;
  z-index: 9999; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 로딩 ─────────────────────────────────────────── */
.loading-row td {
  text-align: center; padding: 40px; color: #aab;
}
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid #e2e6ee; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .recent-grid { grid-template-columns: 1fr; }
}
