/* ===== 관리자 페이지 ===== */
:root {
    --primary-color: #0066cc;
    --primary-dark: #004d99;
    --primary-light: #e6f0ff;
    --text-color: #1f2937;
    --text-light: #4b5563;
    --text-muted: #8b95a5;
    --bg-color: #ffffff;
    --bg-light: #f4f6f9;
    --bg-dark: #1a1a2e;
    --border-color: #e3e7ee;
    --danger: #dc2626;
    --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;

    /* 차트 토큰 (단일 계열: 사이트 기본 블루) */
    --viz-surface: #ffffff;
    --viz-series-1: #2a78d6;
    --viz-series-1-hover: #1c5cab;
    --viz-grid: #eceff4;
    --viz-axis: #d5dae3;
    --viz-text: #52514e;
}

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

html { font-size: 15px; }
body {
    font-family: var(--font-family);
    line-height: 1.5;
    color: var(--text-color);
    background: var(--bg-light);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ===== 로그인 ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, #0b2a4a 0%, #0066cc 100%);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-logo {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--bg-dark);
}
.login-logo span { color: var(--primary-color); }
.login-logo small { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.login-desc { color: var(--text-light); font-size: 14px; }
.login-card input {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light); }
.login-error { color: var(--danger); font-size: 13px; }
.login-back { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 4px; }
.login-back:hover { color: var(--primary-color); }

/* ===== 버튼 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
}
.btn-ghost:hover { border-color: var(--primary-color); color: var(--primary-color); }
.btn-danger {
    background: transparent;
    border: 1px solid #f3c2c2;
    color: var(--danger);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
}
.btn-danger:hover { background: #fef2f2; }

/* ===== 헤더 ===== */
.top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--bg-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.top-header .logo { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.top-header .logo span { color: #5aa9ff; }
.top-header .logo small { font-size: 12px; font-weight: 400; color: rgba(255,255,255,0.6); margin-left: 6px; }
.header-link { font-size: 13px; color: rgba(255,255,255,0.75); }
.header-link:hover { color: #fff; }
.btn-logout {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,0.22); }

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px; height: 36px;
    background: none; border: none;
}
.mobile-menu-btn span { display: block; width: 100%; height: 2px; background: #fff; transition: all 0.3s; }
.mobile-menu-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== 레이아웃 ===== */
.app-container { display: flex; padding-top: 60px; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 60px; bottom: 0; left: 0;
    overflow-y: auto;
    padding: 16px 0;
}
.sidebar-overlay { display: none; position: fixed; top: 60px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 998; }
.sidebar-overlay.active { display: block; }
.menu-category {
    padding: 14px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-light);
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.menu-item:hover { background: var(--bg-light); color: var(--text-color); }
.menu-item.active { color: var(--primary-color); background: var(--primary-light); border-left-color: var(--primary-color); font-weight: 500; }
.menu-badge {
    margin-left: auto;
    font-style: normal;
    font-size: 11px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
}

.main-content { flex: 1; margin-left: 220px; padding: 28px 32px 48px; min-width: 0; }
.page-content { display: none; }
.page-content.active { display: block; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.page-sub { font-size: 13px; color: var(--text-muted); }

/* ===== 카드 / 그리드 ===== */
.card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.card-head h2 { font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== 스탯 타일 ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-tile {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 12px; color: var(--text-light); margin-top: 6px; }

/* ===== 필터 칩 ===== */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-light);
}
.chip:hover { border-color: var(--primary-color); color: var(--primary-color); }
.chip.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }

/* ===== 차트 ===== */
.chart { position: relative; width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--viz-grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--viz-axis); stroke-width: 1; }
.chart .tick-text { fill: var(--viz-text); font-size: 11px; font-family: var(--font-family); }
.chart .bar { fill: var(--viz-series-1); transition: fill 0.1s; }
.chart .bar-hit { fill: transparent; }
.chart .bar-hit:hover + .bar, .chart .bar.hover { fill: var(--viz-series-1-hover); }
.chart .bar-label { fill: var(--viz-text); font-size: 11px; font-family: var(--font-family); text-anchor: middle; }
.chart .chart-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 13px;
}
.chart-tooltip {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    padding: 7px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    white-space: nowrap;
}
.chart-tooltip strong { font-weight: 600; }
.chart-table { display: none; }
.chart.table-mode svg, .chart.table-mode .chart-empty { display: none; }
.chart.table-mode .chart-table { display: block; max-height: 320px; overflow-y: auto; }

/* ===== 테이블 ===== */
.table-wrap { overflow-x: auto; }

/* 접속 위치 지도 */
.card-tools { display: flex; align-items: center; gap: 10px; }
.geo-wrap { position: relative; }
.geo-map { width: 100%; height: 420px; border-radius: 8px; border: 1px solid var(--border-color); background: #eef2f6; z-index: 0; }
.geo-map .leaflet-popup-content { font-family: var(--font-family); font-size: 13px; line-height: 1.5; margin: 10px 14px; }
.geo-map .leaflet-popup-content strong { font-weight: 600; }
.geo-map .leaflet-container { font-family: var(--font-family); }
.geo-map .geo-dot { fill: var(--viz-series-1); fill-opacity: 0.45; stroke: var(--viz-series-1-hover); stroke-width: 1.5; transition: fill-opacity 0.1s; }
.geo-map .geo-dot:hover { fill-opacity: 0.75; }
.geo-table { display: none; max-height: 420px; overflow-y: auto; }
.geo-wrap.table-mode .geo-map { display: none; }
.geo-wrap.table-mode .geo-table { display: block; }
.geo-empty {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px; background: rgba(255,255,255,0.7); border-radius: 8px; z-index: 500; pointer-events: none;
}
.geo-help { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    white-space: nowrap;
}
.table th { font-weight: 600; color: var(--text-light); font-size: 12px; background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.wrap { white-space: normal; word-break: break-all; max-width: 420px; }
.table td.muted { color: var(--text-muted); }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover td { background: var(--bg-light); }
.table .empty { text-align: center; color: var(--text-muted); padding: 24px; white-space: normal; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary-dark);
}
.badge-gray { background: #eef1f5; color: var(--text-light); }
.badge-green { background: #e6f7f1; color: #0b7a55; }
.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager button {
    min-width: 32px; height: 32px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-light);
}
.pager button.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.pager button:disabled { opacity: 0.4; cursor: default; }

/* ===== 폼 ===== */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-light); }
.form-group input, .form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light); }
.form-group input[type="file"] { padding: 8px; }
.form-actions { display: flex; justify-content: flex-end; }

/* ===== 토스트 ===== */
.toast {
    position: fixed;
    left: 50%; bottom: 28px;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); }
.toast.success { background: #0b7a55; }

/* ===== 모달 ===== */
.modal { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--text-muted); }
.modal-close:hover { color: var(--text-color); }
.modal-body { padding: 20px; }
.detail-list { display: grid; grid-template-columns: 90px 1fr; row-gap: 10px; column-gap: 12px; font-size: 14px; }
.detail-list dt { color: var(--text-muted); font-size: 13px; }
.detail-list dd { word-break: break-all; }
.detail-list dd.note { white-space: pre-wrap; background: var(--bg-light); padding: 12px; border-radius: 8px; line-height: 1.6; }

/* ===== 반응형 ===== */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .geo-map { height: 300px; }
}
@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }
    .sidebar { transform: translateX(-100%); z-index: 999; transition: transform 0.3s ease; }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px 16px 40px; }
    .header-link { display: none; }
    .stat-grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .card { padding: 16px; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 22px; }
}
