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

:root {
  --primary: #1a3cff;
  --primary-light: #eef0ff;
  --sidebar-w: 240px;
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f6;
  --gray-200: #e4e7ed;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --purple: #7c3aed;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e8eaf0;
  --text-muted: #8b93a7;
}

body {
  font-family: 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
}

/* ── 사이드바 ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: none;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo img { height: 32px; width: auto; max-width: 160px; }

.store-selector {
  margin: 12px 12px 4px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.store-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.store-name { font-size: 13px; font-weight: 600; flex: 1; }
.store-arrow { color: var(--gray-400); font-size: 11px; }

.sidebar-section-label {
  padding: 14px 20px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px;
}

.sidebar-nav { flex: 1; padding: 4px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 20px;
  color: var(--gray-600); text-decoration: none;
  transition: background .12s, color .12s;
  border-radius: 8px; margin: 1px 10px;
  font-size: 13.5px; font-weight: 500;
  position: relative;
}
.sidebar-nav a:hover { background: var(--gray-100); color: var(--gray-800); }
.sidebar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-nav a .nav-icon {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  opacity: .7;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--primary); color: #fff;
  border-radius: 10px; padding: 1px 7px;
  font-size: 11px; font-weight: 600;
}
.sidebar-nav a.active .nav-badge { background: var(--primary); }
.sidebar-nav a:not(.active) .nav-badge { background: var(--gray-200); color: var(--gray-600); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  background: var(--gray-100); border: none; color: var(--gray-600);
  cursor: pointer; font-size: 11px; padding: 5px 9px;
  border-radius: 6px; font-weight: 600; transition: all .12s;
  white-space: nowrap;
}
.logout-btn:hover { background: var(--gray-200); color: var(--danger); }

/* ── 메인 ── */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-breadcrumb { font-size: 13px; color: var(--text-muted); }
.topbar-breadcrumb span { color: var(--gray-800); font-weight: 600; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 7px 12px;
  font-size: 13px; color: var(--text-muted);
  cursor: pointer; min-width: 220px;
}
.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-500); font-size: 16px;
}
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; cursor: pointer;
}

.content { padding: 24px 28px; }

/* ── 프로모 배너 ── */
.promo-banner {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: 12px;
  padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  color: #fff;
}
.promo-banner .promo-left { display: flex; align-items: center; gap: 12px; }
.promo-banner .promo-icon {
  width: 36px; height: 36px; background: rgba(255,255,255,.2);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.promo-banner .promo-title { font-weight: 700; font-size: 15px; }
.promo-banner .promo-sub { font-size: 13px; opacity: .85; }
.promo-btn {
  background: #fff; color: var(--purple);
  border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.promo-btn:hover { background: #f5f3ff; }

/* ── 섹션 헤더 ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.section-title { font-size: 16px; font-weight: 700; }
.section-actions { display: flex; align-items: center; gap: 8px; }
.date-picker-btn {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 7px 12px;
  font-size: 13px; color: var(--gray-600);
  cursor: pointer;
}

/* ── 통계 카드 ── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width:960px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }

.stat-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 20px 22px;
}
.stat-card .s-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.stat-card .s-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.stat-card .s-label .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.stat-card .s-label .info-icon {
  font-size: 13px; color: var(--gray-400); cursor: help; margin-left: 4px; display: inline-flex; align-items: center;
}
.stat-card .s-info { color: var(--gray-300); cursor: pointer; font-size: 14px; }
.stat-card .s-value { font-size: 26px; font-weight: 800; color: var(--gray-800); margin-bottom: 6px; }
.stat-card .s-change {
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.s-change.up { color: var(--success); }
.s-change.down { color: var(--danger); }
.s-change .trend { font-size: 10px; }

/* ── 차트 그리드 ── */
.chart-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width:900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 20px 22px;
}
.chart-card .chart-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.chart-card .chart-title { font-size: 14px; font-weight: 700; }
.chart-box { position: relative; height: 200px; }
.chart-big-value { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.chart-sub-value { font-size: 12px; color: var(--text-muted); }

/* ── 테이블 섹션 ── */
.table-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 0; overflow: hidden;
}
.table-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}
.table-card-title { font-size: 15px; font-weight: 700; }

/* ── 탭 ── */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 22px; margin-top: 14px;
}
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--gray-500); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-badge {
  background: var(--primary); color: #fff;
  border-radius: 10px; padding: 1px 6px; font-size: 10px; font-weight: 700;
}

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

/* ── 배지 ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-completed::before { background: #22c55e; }
.badge-pending { background: #fef9c3; color: #a16207; }
.badge-pending::before { background: #f59e0b; }
.badge-progress { background: #dbeafe; color: #1d4ed8; }
.badge-progress::before { background: #3b82f6; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-cancelled::before { background: #ef4444; }
.badge-unread { background: #fee2e2; color: #b91c1c; }
.badge-unread::before { background: #ef4444; }
.badge-read { background: #dbeafe; color: #1d4ed8; }
.badge-read::before { background: #3b82f6; }
.badge-replied { background: #dcfce7; color: #15803d; }
.badge-replied::before { background: #22c55e; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1232d4; }
.btn-secondary { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-export {
  background: #fff; border: 1px solid var(--gray-200);
  color: var(--gray-600); border-radius: 8px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gray-700); }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-200); border-radius: 8px;
  font-size: 14px; color: var(--gray-800); background: #fff; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,60,255,.08);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.input-row { display: flex; gap: 10px; }
.input-row > * { flex: 1; }

/* ── 툴바/검색 ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 36px; }
.search-box .s-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 15px; }

/* ── 페이지네이션 ── */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: flex-end; padding: 14px 22px; }
.pagination button {
  min-width: 32px; height: 32px; padding: 0 10px;
  border-radius: 7px; border: 1px solid var(--gray-200);
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 14px;
  padding: 28px; width: 90%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.hidden { display: none !important; }

/* ── 토스트 ── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e293b; color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: 13px; z-index: 999;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: #166534; }
#toast.error { background: #991b1b; }

/* ── 로그인 ── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a3cff 0%, #4f46e5 100%);
}
.login-box {
  background: #fff; border-radius: 16px;
  padding: 44px 40px; width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
}
.login-logo { margin-bottom: 28px; }
.login-logo img { height: 32px; }
.login-box h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-box p { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; display: none; }

/* ── 카드 (일반) ── */
.card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 22px; margin-bottom: 20px;
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; }

/* ── 빈 상태 ── */
.empty-state { text-align: center; padding: 48px; color: var(--gray-400); font-size: 13px; }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 8px; }

/* ── 차트 캔버스 ── */
.chart-box canvas { width: 100% !important; }

/* ── 메일 미리보기 ── */
.mail-preview {
  border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 20px; background: var(--gray-50); min-height: 200px;
  font-size: 14px; line-height: 1.8;
}

/* ── 액션 도트 메뉴 ── */
.action-dots {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 18px; padding: 2px 6px;
  border-radius: 6px;
}
.action-dots:hover { background: var(--gray-100); }

/* ── 스켈레톤 로딩 ── */
.skeleton {
  background: linear-gradient(90deg, #f1f3f6 25%, #e4e7ed 50%, #f1f3f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }
.skeleton-card { height: 100px; border-radius: 12px; }
.skeleton-chart { height: 240px; border-radius: 12px; }
.skeleton-row { height: 20px; margin-bottom: 10px; }
.skeleton-row:last-child { width: 70%; }

/* ── 목업 뱃지 ── */
.mock-badge {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  background: #fef3c7; color: #92400e;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
}

/* ── 날짜 셀렉터 탭 ── */
.days-tabs { display: flex; gap: 4px; }
.days-tab {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--gray-200);
  background: #fff; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--gray-600); transition: all .12s;
}
.days-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 수평 바 (트래픽 소스 / 상위 페이지) ── */
.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.bar-item-label { font-size: 13px; font-weight: 500; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 65%; }
.bar-item-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.bar-item-count { font-weight: 600; color: var(--gray-800); }
.bar-track { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }

/* ── 도넛 차트 중앙 라벨 ── */
.donut-wrap { position: relative; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center .dc-value { font-size: 22px; font-weight: 800; color: var(--gray-800); }
.donut-center .dc-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── 체류시간 포맷 ── */
.duration-value { font-size: 26px; font-weight: 800; }

/* ── 2열 그리드 (소스 + 페이지) ── */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 860px) { .two-col-grid { grid-template-columns: 1fr; } }
