:root {
  --green-deep:   #1B4332;
  --green-dark:   #2D6A4F;
  --green-mid:    #40916C;
  --green-light:  #8DC63F;
  --green-pale:   #E8F5E9;
  --bg-page:      #F5F7F5;
  --bg-white:     #FFFFFF;
  --sidebar-w:    240px;
  --header-h:     60px;
  --text-primary:   #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --border:         #e5e7eb;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ───────────────────────────────────────────
   LAYOUT
─────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ───────────────────────────────────────────
   SIDEBAR
─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-deep);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.sidebar-logo span {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo .admin-badge {
  font-size: 10px;
  background: var(--green-light);
  color: var(--green-deep);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.15s;
  position: relative;
}

.nav-item i { font-size: 18px; flex-shrink: 0; }

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.nav-item.active {
  background: rgba(141,198,63,0.15);
  color: var(--green-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--green-light);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  background: var(--green-mid);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-footer .info { flex: 1; min-width: 0; }
.sidebar-footer .info .name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .info .role {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.sidebar-footer .logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 18px;
  padding: 4px;
  transition: color 0.15s;
}
.sidebar-footer .logout-btn:hover { color: #fff; }


#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  display: none;
}
#sidebar-overlay.open {
  display: block;
}


/* ───────────────────────────────────────────
   MAIN CONTENT
─────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ───────────────────────────────────────────
   HEADER
─────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: all 0.15s;
  position: relative;
}
.topbar-btn:hover { background: var(--bg-page); color: var(--text-primary); }

.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid #fff;
}

.hamburger {
  display: none;
  width: 36px; height: 36px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
}

/* ───────────────────────────────────────────
   PAGE CONTENT
─────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ───────────────────────────────────────────
   CARDS
─────────────────────────────────────────── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ───────────────────────────────────────────
   STAT CARDS
─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card .icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.change.up { color: var(--green-dark); }
.change.down { color: #ef4444; }

/* ───────────────────────────────────────────
   TABLE
─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
thead th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-page); }

tbody td {
  padding: 12px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ───────────────────────────────────────────
   BADGES
─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-pale); color: var(--green-deep); }
.badge-lime   { background: #f0f9e0; color: #3a6b0e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-gray   { background: #f3f4f6; color: #4b5563; }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* ───────────────────────────────────────────
   BUTTONS
─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn i { font-size: 16px; }

.btn-primary {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
}
.btn-primary:hover { background: var(--green-deep); border-color: var(--green-deep); }

.btn-outline {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-page); }

.btn-danger {
  background: #fff;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-sm i { font-size: 14px; }

/* ───────────────────────────────────────────
   FORM
─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-muted);
}
.search-wrap input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus { border-color: var(--green-dark); }

/* ───────────────────────────────────────────
   TOOLBAR (table 상단 검색/필터)
─────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ───────────────────────────────────────────
   PAGINATION
─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-page); color: var(--text-primary); }
.page-btn.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff;
  font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ───────────────────────────────────────────
   FOOTER
─────────────────────────────────────────── */
.admin-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* ───────────────────────────────────────────
   MODAL
─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border: none;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ───────────────────────────────────────────
   TOAST
─────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1a1a1a;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s ease;
}
.toast.success { background: var(--green-deep); }
.toast.error   { background: #b91c1c; }
.toast i { font-size: 16px; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ───────────────────────────────────────────
   RESPONSIVE
─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .main-wrap {
    margin-left: 0;
    min-height: 100vh;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .admin-layout {
    min-height: unset;
    overflow-x: hidden;
  }
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .hamburger {
    display: flex;
  }
  .page-content {
    padding: 16px;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* 필터 영역 세로 정렬 */
  .card > div[style*="display:flex"] {
    flex-direction: column;
    align-items: stretch !important;
  }
  .card > div[style*="display:flex"] > div {
    width: 100% !important;
  }
  .card > div[style*="display:flex"] input,
  .card > div[style*="display:flex"] select {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
