:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
  font-size: 14px;
  background: var(--body-bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── 사이드바 ── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

#sidebar .brand {
  padding: 20px 16px 16px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sidebar .brand .icon { font-size: 20px; }

#sidebar .nav-section {
  padding: 12px 12px 4px;
  font-size: 11px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}

#sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 8px;
  transition: all .15s;
  font-size: 13.5px;
}

#sidebar .nav-item:hover { background: #334155; color: #fff; }
#sidebar .nav-item.active { background: var(--sidebar-active); color: #fff; }
#sidebar .nav-item .nav-icon { width: 18px; text-align: center; }

#sidebar .sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid #334155;
}

/* ── 메인 영역 ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  height: 52px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}

#topbar .page-title { font-size: 16px; font-weight: 600; flex: 1; }
#topbar .user-info { color: var(--text-muted); font-size: 13px; }

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── 카드 ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title { font-size: 15px; font-weight: 600; }

/* ── 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--body-bg); }

/* ── 폼 ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text-muted); }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; font-family: monospace; }

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

/* ── 배지 ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
/* -- 
.badge-init { background: #f1f5f9; color: #64748b; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-read { background: #dcfce7; color: #15803d; }
.badge-infect { background: #fef3c7; color: #b45309; }
.badge-report { background: #fce7f3; color: #9d174d; }
.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-finished { background: #dcfce7; color: #15803d; }
.badge-stopped { background: #fee2e2; color: #dc2626; }
 */

.badge-init { background: #e5e7eb; color: #4b5563; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-read { background: #ffedd5; color: #c2410c; }
.badge-infect { background: #fee2e2; color: #b91c1c; }
.badge-report { background: #dcfce7; color: #15803d; }
.badge-running { background: #1e3a8a; color: #ffffff; }
.badge-finished { background: #dbeafe; color: #1e40af; }
.badge-stopped { background: #7f1d1d; color: #ffffff; }

/* ── 검색바 ── */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.search-bar .form-control { max-width: 280px; }

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

/* ── 모달 ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 520px;
  max-width: 95vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-lg { width: 760px; }
.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: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── 통계 카드 ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  text-align: center;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: var(--success); }
.stat-yellow .stat-value { color: var(--warning); }
.stat-red .stat-value { color: var(--danger); }

/* ── 로그 터미널 ── */
.log-terminal {
  background: #0f172a;
  color: #94a3b8;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  padding: 16px;
  border-radius: 8px;
  height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-terminal .log-success { color: #4ade80; }
.log-terminal .log-error { color: #f87171; }
.log-terminal .log-info { color: #60a5fa; }

/* ── 알림 토스트 ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  min-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: slide-in .2s ease;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #0284c7; }

@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 로그인 ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-box h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.login-box p { color: var(--text-muted); margin: 0 0 28px; font-size: 13px; }

/* ── 반응형 ── */
@media (max-width: 768px) {
  #sidebar { width: 60px; min-width: 60px; }
  #sidebar .nav-item span, #sidebar .brand span, #sidebar .nav-section { display: none; }
  #sidebar .nav-item { justify-content: center; padding: 10px; }
}

/* ── 유틸 ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }
