/* GeoAnalytics — minimal analytics UI (Plausible/Fathom tone) */

:root {
    --bg: #ffffff;
    --bg-soft: #f8f9fb;
    --bg-mute: #f1f3f7;
    --border: #e6e8ee;
    --border-soft: #eef0f4;
    --text: #1a1b1f;
    --text-mute: #5b6068;
    --text-faint: #8e93a0;
    --primary: #5850EC;
    --primary-hover: #4338CA;
    --primary-soft: #EEF2FF;
    --success: #0d9f5e;
    --warn: #c97a0a;
    --danger: #d24747;

    --font-sans: 'Inter', 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --radius: 6px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; background: var(--bg); color: var(--text);
    font-family: var(--font-sans); -webkit-font-smoothing: antialiased;
    max-width: 100%; overflow-x: hidden;
}
body { font-size: 14px; line-height: 1.5; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--primary); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ============ Layout: app ============ */
.page-app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
    border-right: 1px solid var(--border);
    background: #e9ebf1;   /* 흰색 눈부심 완화 — 본문(#fff)과 대비되는 부드러운 그레이 */
    padding: 24px 16px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 4px 8px 24px; }
.brand-mark { color: var(--primary); font-size: 18px; }
.brand-name { letter-spacing: -0.01em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a {
    padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-mute); font-size: 13.5px; font-weight: 500;
}
.side-nav a:hover { background: #dee1ea; color: var(--text); }
.side-nav a.is-active { background: #fff; color: var(--text); font-weight: 600; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16,24,40,0.05); }
.side-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); padding: 18px 10px 4px; font-weight: 600; }
.side-foot { padding-top: 12px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 6px; }
.user-email { font-size: 12px; color: var(--text-faint); padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--text-mute); font-size: 13px; padding: 6px 10px; text-align: left; border-radius: var(--radius-sm); }
.link-btn:hover { background: var(--bg-mute); color: var(--text); }
.logout-form { margin: 0; }

.app-main { padding: 32px 40px; max-width: 1180px; }

/* ============ Layout: auth ============ */
.page-auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-soft); }
.page-auth .mkt-header { background: rgba(255,255,255,0.92); }
.page-auth .auth-main { flex: 1; display: flex; align-items: center; justify-content: center; margin: 0 auto; width: 100%; max-width: 380px; padding: 32px 24px; }
.auth-main { width: 100%; max-width: 380px; padding: 24px; }
.auth-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-sm); }
.auth-card .brand { padding: 0 0 24px; justify-content: center; }
.auth-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.auth-sub { color: var(--text-mute); font-size: 13px; margin: 0 0 24px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-mute); }
.auth-terms-agree { font-size: 11.5px; color: var(--text-faint); text-align: center; margin: 10px 0 14px; line-height: 1.5; }
.auth-terms-agree a { color: var(--text-mute); text-decoration: underline; }
.auth-terms-agree a:hover { color: var(--primary); }
.auth-foot a { color: var(--primary); font-weight: 500; }
.auth-foot a:hover { text-decoration: underline; }

/* ============ Headings ============ */
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.page-sub { color: var(--text-mute); margin: 0 0 28px; font-size: 13.5px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); margin: 0 0 12px; }

/* ============ Forms ============ */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 12.5px; font-weight: 500; color: var(--text-mute); }
.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 80ms;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-hint { font-size: 12px; color: var(--text-faint); }
.form-error { font-size: 13px; color: var(--danger); background: #fef2f2; border: 1px solid #fecaca; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.form-ok { font-size: 13px; color: var(--success); background: #f0fdf4; border: 1px solid #bbf7d0; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent;
    font-weight: 500; font-size: 13.5px; transition: background 80ms, border 80ms;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-soft); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { background: var(--bg); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }

/* ============ Cards / Stats ============ */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); margin-bottom: 6px; font-weight: 600; }
.stat-val { font-family: var(--font-mono); font-size: 24px; font-weight: 500; letter-spacing: -0.01em; }
.stat-delta { font-size: 12px; color: var(--text-mute); margin-top: 2px; font-family: var(--font-mono); }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.table th { font-weight: 600; font-size: 11.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; }
.table td.num { font-family: var(--font-mono); text-align: right; }

/* ============ Code blocks ============ */
.code-block {
    background: var(--bg-mute);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    color: var(--text);
}
.copyable { position: relative; }
.copy-btn { position: absolute; top: 8px; right: 8px; padding: 4px 8px; font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-mute); }
.copy-btn:hover { color: var(--text); background: var(--bg-soft); }

/* ============ Empty state ============ */
.empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    color: var(--text-mute);
}
.empty .empty-title { color: var(--text); font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.empty .empty-sub { font-size: 13px; margin-bottom: 16px; }

/* ============ 대시보드 공통 헤더 (사이트 선택 — 페이지 최상단 한 줄) ============ */
.dash-header {
    display: flex; align-items: center; gap: 12px;
    padding: 0 0 16px; margin-bottom: 20px; border-bottom: 1px solid var(--border-soft);
}
@media (max-width: 720px) { .dash-header { padding-bottom: 12px; margin-bottom: 16px; } }

/* ============ Toolbar (site selector + range) ============ */
.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0 24px; border-bottom: 1px solid var(--border-soft); margin-bottom: 24px; gap: 12px;
}
.toolbar-left { display: flex; align-items: center; gap: 16px; }
.site-selector { display: inline-flex; align-items: center; gap: 9px; }
.site-selector-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-mute); white-space: nowrap;
}
.site-selector select {
    padding: 10px 36px 10px 36px; border: 1px solid var(--border); border-radius: 9px;
    background:
        url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2C8 2 5 5 5 9c0 5 7 13 7 13s7-8 7-13c0-4-3-7-7-7zm0 9.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z' fill='%235850EC'/%3E%3C/svg%3E") no-repeat left 12px center,
        url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239096a3' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 13px center,
        var(--bg);
    color: var(--text); font-weight: 600; font-size: 13.5px;
    appearance: none; -webkit-appearance: none; min-width: 250px; cursor: pointer;
    box-shadow: 0 1px 2px rgba(16,24,40,0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.site-selector select:hover { border-color: #b9bdf0; }
.site-selector select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(88,80,236,0.15); }
.range-picker { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; background: var(--bg); }
.range-opt { padding: 5px 10px; font-size: 12.5px; border-radius: 3px; color: var(--text-mute); }
.range-opt:hover { color: var(--text); }
.range-opt.is-active { background: var(--primary); color: #fff; }
.range-opt.is-active:hover { color: #fff; }

/* ============ Bar (가로 비율) ============ */
.hbar-wrap { position: relative; height: 22px; display: flex; align-items: center; padding-right: 8px; min-width: 80px; }
.hbar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary-soft); border-radius: 3px; }
.hbar-val { position: relative; font-size: 12.5px; padding-left: 8px; color: var(--text); }

/* ============ Heatmap ============ */
.heatmap { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-mono); font-size: 10px; }
.heatmap-cols, .heatmap-row { display: grid; grid-template-columns: 28px repeat(24, 1fr); gap: 2px; }
.heatmap-hr { text-align: center; color: var(--text-faint); font-size: 9px; }
.heatmap-day { color: var(--text-mute); font-size: 11px; line-height: 18px; text-align: right; padding-right: 4px; font-family: var(--font-sans); }
.heatmap-cell { aspect-ratio: 1 / 1; border-radius: 2px; background: var(--bg-mute); }

/* ============ Chart container ============ */
.chart-card { padding: 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; }
.chart-title-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-title { font-size: 14px; font-weight: 600; }
.chart-meta { font-size: 11.5px; color: var(--text-mute); font-family: var(--font-mono); }

/* ============ Layout grids ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ============ Page head (visits.php 톤) ============ */
.page-head { margin-bottom: 28px; }
.page-eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--primary); font-weight: 700; margin-bottom: 8px; }
.page-title-xl { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.1; }
.page-desc { color: var(--text-mute); font-size: 16px; margin: 0; }

.toolbar-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; background: var(--bg); }
.period-btn { padding: 6px 14px; font-size: 13px; border-radius: 4px; color: var(--text-mute); font-weight: 500; }
.period-btn:hover { color: var(--text); }
.period-btn.is-active { background: var(--primary); color: #fff; }
.period-btn.is-active:hover { color: #fff; }
/* 플랜 한도를 넘는 기간 — 숨기지 않고 잠금으로 보여준다 (업그레이드 유인) */
.period-btn.is-locked { color: var(--text-faint); cursor: not-allowed; opacity: .55; }
.period-btn.is-locked:hover { color: var(--text-faint); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #097a47; color: #fff; }
.btn-light { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--bg-soft); }

/* ============ Stat grid (4 cards with rich subtitle) ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 20px 22px; box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.stat-card-highlight { border-color: rgba(13,159,94,0.35); }
.stat-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card-label { font-size: 12px; font-weight: 600; color: var(--text-mute); margin-bottom: 6px; }
.stat-card-val { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; font-family: var(--font-mono); line-height: 1.1; }
.stat-card-sub { margin-top: 14px; font-size: 12.5px; color: var(--text-mute); line-height: 1.45; }
.stat-card-sub strong { color: var(--text); font-family: var(--font-mono); }
.stat-card-sub a { color: var(--primary); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.icon-primary { background: rgba(88,80,236,0.1); }
.icon-success { background: rgba(13,159,94,0.1); }
.icon-bot     { background: rgba(99,102,241,0.1); }
.icon-cite    { background: rgba(13,159,94,0.12); color: var(--success); font-family: serif; }

@media (max-width: 1024px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 580px)  { .stat-grid { grid-template-columns: 1fr; } }

/* ============ Panel (table-wrap) ============ */
.panel {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.panel-head {
    padding: 18px 22px; border-bottom: 1px solid var(--border-soft);
    display: flex; justify-content: space-between; align-items: center;
    background: #fff;
}
.panel-title { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.panel-body { padding: 22px; }
.panel-legend { display: flex; gap: 8px; }
.legend-chip { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }

/* ============ Data table ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td {
    padding: 11px 16px; border-bottom: 1px solid var(--border-soft); text-align: left;
}
.data-table th {
    font-size: 11.5px; font-weight: 600; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--bg-soft);
}
.data-table tbody tr:hover { background: var(--bg-soft); }
.data-table.data-table-sm th, .data-table.data-table-sm td { padding: 9px 14px; font-size: 12.5px; }
.data-table .row-total { background: var(--bg-soft); border-top: 2px solid var(--border); }
.data-table .table-foot-note {
    background: var(--bg-mute); color: var(--text-mute);
    font-size: 11.5px; line-height: 1.7; padding: 12px 16px;
}
.data-table a { color: var(--text); }
.data-table a:hover { color: var(--primary); }

.ta-c { text-align: center; }
.ta-r { text-align: right; }
.fw-b { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-success { color: var(--success) !important; }
.text-bad     { color: var(--danger); }
.p-5 { padding: 32px !important; }

/* ============ Vertical stacked bar chart ============ */
.vchart { position: relative; }
.vchart-bars {
    display: flex; align-items: flex-end; gap: 4px; height: 180px;
}
.vchart-col {
    flex: 1; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    min-width: 0;
    cursor: pointer;
}
.vchart-col:hover { opacity: 0.85; }

/* 사람 미측정 구간 — "0명"과 "안 쟀다"를 눈으로 구분한다 (2026-08-29).
   봇 막대는 그대로 보이고, 칸 배경에만 빗금을 깔아 사람 축이 비어 있는 이유를 밝힌다. */
.vchart-col-unmeasured {
    background-image: repeating-linear-gradient(
        45deg, rgba(180,83,9,0.10) 0 3px, transparent 3px 6px);
    border-radius: 2px;
}
.vchart-stack { width: 70%; border-radius: 3px 3px 0 0; min-height: 0; transition: opacity 100ms; }
.vchart-axis {
    display: flex; justify-content: space-between;
    margin-top: 8px; font-size: 11px; color: var(--text-faint); font-family: var(--font-mono);
}

/* ============ Badges (Overview용) ============ */
.cat-badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
}
.cat-ai     { background: rgba(99,102,241,0.13); color: #6366f1; }
.cat-search { background: rgba(37,99,235,0.12); color: #2563eb; }
.cat-tool   { background: #f1f3f5; color: #868e96; }

.badge-bot { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
    background: rgba(88,80,236,0.1); color: var(--primary); margin-right: 4px; }
.badge-role { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600; }
.badge-role-ai_cite { background: rgba(13,159,94,0.12); color: var(--success); }
.badge-role-ai_crawl, .badge-role-search { background: #f1f3f5; color: var(--text-mute); }

.badge-bad { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600;
    background: rgba(239,68,68,0.12); color: var(--danger); }
.row-total td { border-top: 2px solid var(--border); background: var(--bg-soft); }
.panel-alert { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(210,71,71,0.08); }
.badge-muted { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600;
    background: var(--bg-mute); color: var(--text-mute); }
.badge-human { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
    background: rgba(13,159,94,0.12); color: var(--success); margin-right: 4px; }
.badge-first { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600;
    background: #fff; color: var(--success); border: 1px solid rgba(13,159,94,0.3); }
.badge-ai { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
    background: rgba(13,159,94,0.12); color: var(--success); margin-left: 6px; }

/* ============ Share bar (국가 % 진행바) ============ */
.share-bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.share-track { width: 80px; height: 6px; border-radius: 999px; background: var(--bg-mute); }
.share-fill { height: 6px; border-radius: 999px; background: #2563eb; }
.share-pct { font-size: 11.5px; color: var(--text-mute); min-width: 36px; text-align: right; font-family: var(--font-mono); }

/* ============ Row layouts ============ */
.row-83 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.row-66 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-57 { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; }
@media (max-width: 1024px) { .row-83, .row-66, .row-57 { grid-template-columns: 1fr; } }

/* ============ Engine pages grid (AI 페이지) ============ */
.ep-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .ep-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .ep-grid { grid-template-columns: 1fr; } }
.ep-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; background: #fff; }
.ep-card-head { font-size: 13.5px; margin-bottom: 8px; }
.ep-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.7; }
.ep-list li { margin-bottom: 3px; }
.ep-list a { color: var(--text); }
.ep-list a:hover { color: var(--primary); }

/* ============ Goal chip + 전환·이탈 badge (visits_journey.php) ============ */
.goal-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(13,159,94,0.1); color: var(--success);
    padding: 6px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
}
.goal-chip-x {
    background: none; border: none; color: var(--success); cursor: pointer;
    font-size: 14px; padding: 0; margin-left: 2px; opacity: 0.6;
}
.goal-chip-x:hover { opacity: 1; color: var(--danger); }
.goal-add-form {
    display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px;
    align-items: end;
}
@media (max-width: 720px) { .goal-add-form { grid-template-columns: 1fr; } }

.badge-conv { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600;
    background: var(--success); color: #fff; }
.badge-exit { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600;
    background: var(--bg-mute); color: var(--text-mute); }

/* ============ Log filter (visits_log.php) ============ */
.log-filter-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1024px) { .log-filter-grid { grid-template-columns: repeat(2, 1fr); } }
.log-filter-grid .form-row { margin-bottom: 0; }
.log-filter-grid .form-label { font-size: 11.5px; }
.log-filter-grid .form-input { font-size: 13px; padding: 6px 10px; }

/* Pagination */
.pgn { display: inline-block; padding: 5px 11px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-mute); font-size: 12.5px; font-family: var(--font-mono); }
.pgn:hover { color: var(--text); background: var(--bg-soft); }
.pgn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pgn.is-active:hover { color: #fff; }
.pgn.is-disabled { color: var(--text-faint); pointer-events: none; opacity: 0.6; }

/* vlog detail grid */
.vlog-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; font-size: 12.5px; }
@media (max-width: 900px) { .vlog-grid { grid-template-columns: repeat(2, 1fr); } }
.vlog-grid .text-mute.fw-b { margin-bottom: 4px; }
.vlog-caret { display: inline-block; width: 12px; color: var(--text-faint); font-size: 9px; margin-right: 4px; }

/* ============ Heatmap (visits_heatmap.php) ============ */
.hm-table { border-collapse: separate; border-spacing: 2px; font-size: 10.5px; }
.hm-cell { height: 30px; min-width: 28px; border-radius: 4px; }

/* ============ Mobile bar (햄버거 헤더 — 모바일에서만 표시) ============ */
.mobile-bar { display: none; }
.hamb { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
    /* 모바일에서: 상단 햄버거 바 + drawer 사이드바 + backdrop */
    .page-app { grid-template-columns: 1fr; max-width: 100%; }
    body.nav-open { overflow: hidden; }

    .mobile-bar {
        display: flex; justify-content: space-between; align-items: center;
        height: 56px; padding: 0 16px;
        background: #fff;
        border-bottom: 1px solid var(--border);
        position: sticky; top: 0; z-index: 30;
    }
    .mobile-bar .brand { padding: 0; gap: 8px; font-size: 16px; }

    .hamb {
        display: flex; flex-direction: column; gap: 5px;
        width: 44px; height: 44px; padding: 0;
        background: none; border: none; cursor: pointer;
        align-items: center; justify-content: center;
    }
    .hamb span {
        display: block; width: 22px; height: 2px; background: var(--text); border-radius: 1px;
        transition: transform 150ms, opacity 150ms;
    }
    body.nav-open .hamb span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    body.nav-open .hamb span:nth-child(2) { opacity: 0; }
    body.nav-open .hamb span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 40;
        background: rgba(0,0,0,0.45); opacity: 0; pointer-events: none;
        transition: opacity 180ms;
    }
    .sidebar-backdrop.is-on { opacity: 1; pointer-events: auto; }

    /* 사이드바 = drawer (오른쪽에서 슬라이드 인) */
    .sidebar {
        position: fixed; right: 0; top: 0; bottom: 0;
        width: 84%; max-width: 320px; height: 100vh;
        flex-direction: column;
        padding: 24px 18px;
        background: #fff;
        border-left: 1px solid var(--border);
        border-right: none; border-bottom: none;
        box-shadow: -20px 0 40px rgba(16,24,40,0.12);
        transform: translateX(100%);
        transition: transform 200ms ease-out;
        z-index: 50;
        overflow-y: auto;
    }
    .sidebar.is-open { transform: translateX(0); }

    .sidebar .brand { display: none; }     /* 모바일 헤더에 이미 있음 */
    .side-nav {
        flex-direction: column; flex: 1;
        gap: 2px;
        margin-top: 12px;
    }
    .side-nav a {
        padding: 14px 16px; font-size: 15px; font-weight: 500;
        border-radius: 8px; line-height: 1.4;
    }
    .side-nav a.is-active { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-soft); font-weight: 600; }
    .side-section {
        font-size: 11px; padding: 24px 16px 8px;
        font-weight: 700; color: var(--text-faint); letter-spacing: 0.08em;
    }
    .side-foot {
        padding: 16px 0 0; border-top: 1px solid var(--border-soft); margin-top: 16px;
        flex-direction: column; align-items: stretch; gap: 4px;
    }
    .user-email { font-size: 13px; padding: 6px 16px; color: var(--text-mute); }
    .link-btn { padding: 12px 16px; font-size: 14px; font-weight: 500; border-radius: 8px; }
    .logout-form { width: 100%; }
    .logout-form .link-btn { width: 100%; }

    .app-main { padding: 20px 16px; max-width: 100%; width: 100%; min-width: 0; }
    .page-head, .toolbar-row, .panel, .stat-grid, .row-83, .row-66, .row-57, .grid-2, .grid-3, .ep-grid {
        max-width: 100%; min-width: 0;
    }
    .stat-card, .panel { max-width: 100%; min-width: 0; }
    .stat-card-val { word-break: break-all; }

    /* 스크롤은 표가 담당한다 (위 .data-table 규칙). 패널은 밀리지 않는다 */
    .panel { overflow-x: clip; }

    /* select width 강제 — 태그는 고정, select가 남은 폭을 채운다 */
    .site-selector { width: 100%; max-width: 100%; display: flex; }
    .site-selector select { min-width: 0 !important; width: auto !important; flex: 1 1 auto; }

    /* 페이지 헤드 */
    .page-title-xl { font-size: 24px; }
    .page-desc { font-size: 13.5px; }
    .toolbar-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .toolbar-actions { width: 100%; flex-wrap: wrap; }
    /* 기간 탭은 가로 스크롤보다 줄바꿈이 낫다 — 스크롤은 있는 줄 모르고 지나친다 */
    .period-group { flex-wrap: wrap; overflow-x: visible; white-space: normal; }
    .period-btn { padding: 6px 11px; font-size: 12.5px; }

    /* 통계 카드 */
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-card-val { font-size: 22px; }
    .stat-card-label { font-size: 11px; }
    .stat-icon { width: 36px; height: 36px; font-size: 18px; }

    /* 패널·테이블 */
    .panel-head { padding: 14px 16px; }
    .panel-title { font-size: 14px; }
    .panel-body { padding: 16px; }
    .data-table { font-size: 12.5px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .data-table .truncate { max-width: 160px !important; }

    /* 차트 */
    .vchart-bars { height: 140px; }
    .vchart-stack { width: 80% !important; }

    /* 그리드 → 1열 */
    .row-83, .row-66, .row-57 { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .ep-grid { grid-template-columns: 1fr; }

    /* 로그 필터 */
    .log-filter-grid { grid-template-columns: 1fr 1fr; }
    .log-filter-grid > .form-row[style*="span 2"],
    .log-filter-grid > .form-row[style*="span 3"] { grid-column: span 2 !important; }

    /* vlog 상세 */
    .vlog-grid { grid-template-columns: 1fr 1fr; }
    .vlog-grid > div[style*="span 4"] { grid-column: span 2 !important; }
    .vlog-grid > div[style*="span 2"] { grid-column: span 2 !important; }

    /* 히트맵 — 작게 + 가로 스크롤 */
    .hm-table { font-size: 9.5px; }
    .hm-cell { height: 24px; min-width: 22px; }

    /* 최근방문 — 모바일에서 UA 칼럼 숨기기 */
    .data-table thead th:nth-child(7),
    .data-table tbody td:nth-child(7) { display: none; }

    /* 마케팅 페이지 */
    .mkt-nav { height: 56px; gap: 12px; }
    .mkt-nav-links { display: none; }
    .feature-grid, .price-grid { grid-template-columns: 1fr; }

    /* Goal 추가 폼 */
    .goal-add-form { grid-template-columns: 1fr; }

    /* 페이지 헤드 액션 */
    .flex-between { flex-direction: column; gap: 12px; align-items: stretch; }

    /* 어드민 toolbar 안의 form (검색 + select) 모바일에서 세로 배치 */
    .toolbar-row form { flex-wrap: wrap; width: 100%; gap: 8px; }
    .toolbar-row form > *,
    form.toolbar-row > * { flex: 1 1 auto; min-width: 0; }
    .toolbar-row form input[type="text"],
    .toolbar-row form input[type="date"],
    .toolbar-row form select,
    form.toolbar-row > input[type="text"],
    form.toolbar-row > input[type="date"],
    form.toolbar-row > select { width: 100% !important; min-width: 0 !important; }
    .toolbar-row form button,
    form.toolbar-row > button,
    form.toolbar-row > .btn { flex-shrink: 0; }
    /* form 자체가 toolbar-row인 경우 부모 flex stretch 보장 */
    form.toolbar-row { align-items: stretch !important; justify-content: flex-start !important; }
    .toolbar-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .log-filter-grid { grid-template-columns: 1fr; }
    .log-filter-grid > .form-row { grid-column: span 1 !important; }

    /* 히트맵 — 더 작게 */
    .hm-table { font-size: 8px; }
    .hm-cell { height: 22px; min-width: 18px; }

    /* 데이터 테이블 — 표 자체가 스크롤 컨테이너 */
    .data-table { min-width: 100%; }

    /* 추가로 referer 칼럼 숨기기 (Log 화면) */
    .data-table thead th:nth-child(6),
    .data-table tbody td:nth-child(6) { display: none; }
}

/* ★ 패널을 통째로 가로 스크롤시키지 않는다.
   그러면 표뿐 아니라 **각주·설명 문단까지 함께 밀려** 화면 밖으로 잘린다
   (모바일에서 "· 실시간 = …" 각주가 잘려 보이던 원인 — 2026-07-22).
   넓은 건 표뿐이므로 **표만** 자기 스크롤 영역을 갖게 한다. */
.panel { overflow-x: clip; }
.data-table, .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
/* display:block이면 thead/tbody가 폭을 잃으므로 내부는 table로 되돌린다 */
.data-table thead, .data-table tbody,
.table thead, .table tbody { display: table; width: 100%; min-width: max-content; }

/* ============ Misc ============ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mono { font-family: var(--font-mono); }
.text-mute { color: var(--text-mute); }
.text-faint { color: var(--text-faint); }

/* Admin shared UI */
.page-lead { color: var(--text-mute); font-size: 14px; margin: 0; }
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
    background: var(--bg-soft); color: var(--text-mute);
}
.badge-ok   { background: rgba(16,185,129,0.12); color: #047857; }
.badge-warn { background: rgba(245,158,11,0.12); color: #b45309; }
.badge-err  { background: rgba(239,68,68,0.12);  color: #b91c1c; }
.alert {
    padding: 12px 16px; border-radius: 6px;
    font-size: 13.5px; margin-bottom: 16px;
    border-left: 3px solid currentColor;
}
.alert-ok  { background: rgba(16,185,129,0.08); color: #047857; }
.alert-err { background: rgba(239,68,68,0.08);  color: #b91c1c; }
