/* ── 리셋 & 베이스 ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #e2e4e9;
  --primary:   #1a56db;
  --primary-h: #1648c0;
  --danger:    #e02424;
  --success:   #057a55;
  --text:      #111928;
  --muted:     #6b7280;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── 사이드바 ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100;
  overflow-y: auto;
  transition: width .2s, min-width .2s;
  box-shadow: var(--shadow);
}
.sidebar.collapsed { width: 56px; min-width: 56px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .user-area { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; }

.sidebar-header {
  padding: 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
  text-decoration: none; white-space: nowrap;
}
.sidebar-brand:hover { color: var(--primary); text-decoration: none; }
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; border-radius: 4px;
  display: flex; align-items: center; flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-section-title {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 8px 4px; margin-top: 8px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
}
.sidebar-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar-item.active { background: #eff6ff; color: var(--primary); }
.sidebar-item-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-sub { margin-left: 28px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-sub a {
  display: block; padding: 6px 10px; border-radius: 6px;
  color: var(--muted); font-size: 12px; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
}
.sidebar-sub a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar-sub a.active { background: #eff6ff; color: var(--primary); }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.user-area { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; }
.username-label { font-size: 12px; font-weight: 600; color: var(--text); }
.logout-btn { font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 0; }
.logout-btn:hover { color: var(--primary); }
.main-content { flex: 1; margin-left: 220px; transition: margin-left .2s; min-width: 0; }
.main-content.expanded { margin-left: 56px; }
.navbar { display: none; }
.nav-links a.active { background: #eff6ff; color: var(--primary); }

/* ── 컨테이너 ──────────────────────────────────────────────────────────── */
.container { max-width: 1600px; margin: 0 auto; padding: 28px 20px; }

/* ── 페이지 헤더 ────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-header .subtitle { color: var(--muted); font-size: 13px; }

/* ── 카드 ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ── 폼 ────────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

input[type="text"],
input[type="date"],
select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  min-width: 200px;
}
input[type="text"]:focus,
input[type="date"]:focus,
select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }

/* ── 버튼 ──────────────────────────────────────────────────────────────── */
.btn {
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn-sm   { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { opacity: .88; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .88; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

/* ── 상태 박스 ─────────────────────────────────────────────────────────── */
.status-box {
  background: #1e2433;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  flex-direction: column;
  gap: 10px;
}
.status-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 13px;
}
.status-log {
  max-height: 180px;
  overflow-y: auto;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.8;
}
.status-log div:last-child { color: #cbd5e1; }

/* ── 스피너 ────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 결과 헤더 ─────────────────────────────────────────────────────────── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

/* ── 테이블 ────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f8f9fc;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .3px;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
tbody td { padding: 10px 14px; vertical-align: middle; }

td.num   { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.channel-link { font-weight: 600; color: var(--text); }
.channel-link:hover { color: var(--primary); }
.link-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  margin-right: 4px;
}
.link-btn:hover { background: #dbeafe; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── 배지 ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-cat { background: #ede9fe; color: #5b21b6; }

/* ── 단건 결과 카드 ─────────────────────────────────────────────────────── */
.result-card { margin-top: 8px; }
.result-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.result-card-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text); }
.video-links { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── 탭 ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover  { color: var(--text); }

/* ── 필터 바 ────────────────────────────────────────────────────────────── */
.filter-bar { padding: 14px 20px; }

/* ── 페이지네이션 ────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: center; padding: 12px 0; }
.page-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.page-btn:hover { background: var(--bg); color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { display: flex; align-items: center; color: var(--muted); font-size: 13px; }

.logout-btn {
  flex-shrink: 0;
  margin-left: 16px;
  padding: 6px 14px;
  background: #e74c3c;
  color: white !important;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.logout-btn:hover { background: #c0392b; text-decoration: none; }

.user-area {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.username-label {
  font-size: 13px;
  color: #888;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.tooltip-icon:hover::after {
  content: attr(data-tip);
  position: fixed;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e2e;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  min-width: 200px;
  text-align: center;
  line-height: 1.5;
}

.navbar {
  flex-wrap: nowrap;
  overflow: visible;
  position: relative;
  z-index: 100;
}
.nav-links {
  flex-shrink: 1;
  min-width: 0;
  overflow: visible;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a { white-space: nowrap; }

.nav-links-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: visible;
}




.contact-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.contact-btn:hover { opacity: 0.8; }

.contact-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.contact-btn:hover { opacity: 0.8; }

.contact-btn { min-width: 64px; }

#rank-table, #insta-rank-table { min-width: 1200px; }
.table-wrapper { overflow-x: auto; }

.container { padding-bottom: 80px; }

/* 필터 pill 버튼 */
.filter-check, .filter-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.filter-check:hover, .filter-radio:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-check input, .filter-radio input {
  display: none;
}
.filter-check:has(input:checked), .filter-radio:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
