* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    margin: 0; background: #f5f6f8; color: #1f2937;
}
/* ── 좌측 사이드바 레이아웃 ─────────────────────────────── */
/* 펼침 224px / 접힘 52px(햄버거만 보이는 레일). 폭은 변수 하나로만 바꾼다 */
:root { --sidebar-w: 224px; }
html.sidebar-collapsed { --sidebar-w: 52px; }

/* .layout 은 기프티콘 화면이 자체 2단 레이아웃에 이미 쓰고 있어 이름을 분리한다 */
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: #111827; color: #cbd5e1; display: flex; flex-direction: column;
    overflow-x: hidden; overflow-y: auto; z-index: 20;
    transition: width .16s ease;
}
.sidebar .side-top {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 10px 12px 12px; border-bottom: 1px solid #1f2937;
}
.side-toggle {
    flex: none; width: 30px; height: 30px; line-height: 1; cursor: pointer;
    background: none; border: 1px solid #374151; border-radius: 7px;
    color: #cbd5e1; font-size: 15px;
}
.side-toggle:hover { background: #1f2937; color: #fff; }
.sidebar .brand {
    font-weight: 700; font-size: 16px; color: #fff; text-decoration: none; white-space: nowrap;
}
.sidebar .who { padding: 12px 20px; border-bottom: 1px solid #1f2937; font-size: 12.5px; white-space: nowrap; }
.sidebar .who .name { color: #fff; font-weight: 600; }
.sidebar .who .role { color: #94a3b8; margin-top: 3px; }
.sidebar nav { padding: 10px 0; flex: 1; }
.sidebar .group {
    padding: 14px 20px 6px; font-size: 11px; font-weight: 700; color: #64748b;
    letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.sidebar nav a {
    display: block; padding: 8px 20px; color: #cbd5e1; text-decoration: none; font-size: 13.5px;
    border-left: 3px solid transparent; white-space: nowrap;
}
.sidebar nav a:hover { color: #fff; background: #1f2937; }
.sidebar nav a.active { color: #fff; background: #1f2937; border-left-color: #3b82f6; font-weight: 600; }
.sidebar .foot { padding: 12px 16px; border-top: 1px solid #1f2937; }
.sidebar .foot button {
    width: 100%; background: none; border: 1px solid #374151; color: #cbd5e1;
    border-radius: 7px; padding: 7px 0; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.sidebar .foot button:hover { background: #1f2937; color: #fff; }

/* 접힘 상태 — 햄버거만 남기고 모두 감춘다 */
html.sidebar-collapsed .sidebar .brand,
html.sidebar-collapsed .sidebar .who,
html.sidebar-collapsed .sidebar nav,
html.sidebar-collapsed .sidebar .foot { display: none; }
html.sidebar-collapsed .sidebar .side-top { border-bottom: none; padding: 12px 10px; }

.main { margin-left: var(--sidebar-w); transition: margin-left .16s ease; }
/* 모든 화면의 내용 영역 폭을 통일한다 */
.container { width: 95%; max-width: none; margin: 24px auto; padding: 0; }

@media (max-width: 900px) {
    :root, html.sidebar-collapsed { --sidebar-w: 0px; }
    .sidebar { width: 224px; transform: translateX(-100%); transition: transform .16s ease; }
    html:not(.sidebar-collapsed) .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
    /* 좁은 화면에서는 기본이 접힘. 햄버거는 내용 위에 떠 있게 둔다 */
    html.sidebar-collapsed .sidebar { width: 52px; transform: none; }
    html.sidebar-collapsed .sidebar .side-top { background: #111827; }
    .main { margin-left: 52px; }
    .container { width: calc(100% - 24px); }
}
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 20px 24px; margin-bottom: 20px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 16px; }
.sub { color: #6b7280; font-size: 13px; margin-bottom: 18px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input, select {
    width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 7px; font-size: 14px;
    background: #fff;
}
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .col { flex: 1; min-width: 160px; }
.btn {
    display: inline-block; background: #2563eb; color: #fff; border: none; border-radius: 7px;
    padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1d4ed8; }
.btn.gray { background: #6b7280; }
.btn.gray:hover { background: #4b5563; }
.btn.red { background: #dc2626; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
th { color: #6b7280; font-weight: 600; background: #fafbfc; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #f3f4f6; color: #6b7280; }
.badge.rocket { background: #eff6ff; color: #1d4ed8; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.product { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
.product img { width: 100%; height: 170px; object-fit: contain; background: #fafafa; }
.product .body { padding: 10px 12px; }
.product .name { font-size: 13px; line-height: 1.35; height: 54px; overflow: hidden; }
.product .price { font-weight: 700; margin-top: 6px; }
.product .meta { margin-top: 6px; display: flex; gap: 6px; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ── 리포트 표 ───────────────────────────────────────────── */
/* 숫자는 오른쪽 정렬 + 고정폭 숫자로 자릿수를 눈으로 맞춘다 */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { white-space: nowrap; }
.report-table td.tag-name { white-space: normal; word-break: break-all; min-width: 260px; }
/* 업체 묶음 셀 — rowspan 으로 합쳐지므로 위쪽 정렬이 읽기 좋다 */
.report-table td.group-cell {
    vertical-align: top; font-weight: 600; background: #fafbfc;
    border-right: 1px solid #eef0f3;
}
.report-table tfoot th { background: #f3f4f6; color: #0b0b0b; font-weight: 700; }
.report-table tr.no-data td { color: #c3c2b7; }
.report-table a { color: #1d4ed8; text-decoration: none; font-weight: 600; }
.report-table a:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }

/* ── KPI 타일 ────────────────────────────────────────────── */
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi { flex: 1 1 190px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; background: #fff; }
.kpi .k-label { font-size: 12.5px; color: #52514e; margin-bottom: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 700; color: #0b0b0b; line-height: 1.15; }
.kpi .k-unit { font-size: 14px; font-weight: 600; color: #52514e; margin-left: 3px; }

/* ── 기간 필터 ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar input[type=date] { width: 175px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.presets a {
    font-size: 12px; color: #374151; text-decoration: none; background: #f3f4f6;
    border: 1px solid #e5e7eb; border-radius: 999px; padding: 4px 12px; font-weight: 500;
}
.presets a:hover { background: #e5e7eb; }

/* ── 차트 ────────────────────────────────────────────────── */
.chart-wrap svg { display: block; width: 100%; height: auto; }
.axis-text { font-size: 12px; fill: #898781; }
.axis-text.x { text-anchor: middle; }
.gridline { stroke: #e1e0d9; stroke-width: 1; }
.baseline { stroke: #c3c2b7; stroke-width: 1; }
.legend { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #0b0b0b; }
.legend-line { width: 16px; height: 3px; border-radius: 2px; flex: none; }
.empty-note { font-size: 13px; fill: #898781; text-anchor: middle; }
