/* 클레임 보드 — 공통 스타일. 라이트 테마. 위쪽 앱바(로고 + 탭 + 계정 메뉴) · 둥근 카드 · 분절형 필터 · 모바일 하단 탭바. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --track: #eef0f4;
  --border: #e5e7eb;
  --border-strong: #cfd4dc;

  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ink: #ffffff;

  --green: #15803d;
  --green-soft: #e7f6ec;
  --red: #c62f3f;
  --red-soft: #fdeced;
  --amber: #a15c00;
  --amber-soft: #fff4dc;
  --teal: #0e7490;
  --teal-soft: #e0f2f1;

  /* 표준 사유 코드 색 */
  --r-buyer-change: #4f46e5;
  --r-buyer-mistake: #2f6fed;
  --r-info-mismatch: #c62f3f;
  --r-defect: #a15c00;
  --r-delay: #0e7490;
  --r-sold-out: #e8740c;
  --r-misdelivery: #b4306f;
  --r-exchange: #7b8794;
  --r-unmapped: #9aa1ad;
  --r-unknown: #cfd3da;

  /* 귀책 색 */
  --p-buyer: #4f46e5;
  --p-seller: #c62f3f;
  --p-supplier: #a15c00;
  --p-carrier: #0e7490;
  --p-unknown: #9aa1ad;

  --radius-frame: 20px;
  --radius-card: 16px;
  --radius-tile: 16px;
  --radius-input: 10px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 1px rgba(16, 24, 40, 0.03);
  --shadow-pop: 0 14px 36px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow-panel: -10px 0 36px rgba(16, 24, 40, 0.14);
  --maxw: 1240px;

  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -48px; background: var(--primary); color: #fff;
  padding: 8px 12px; border-radius: 8px; z-index: 100;
}
.skip:focus { top: 8px; }

/* ---------- 위쪽 앱바 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.hdr-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand-mark { display: block; width: 30px; height: 30px; border-radius: 8px; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 12.5px; font-weight: 500; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border-strong); line-height: 1.1; }
.hdr-nav { display: flex; align-items: center; gap: 2px; }
.hdr-nav a {
  padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.hdr-nav a:hover { background: var(--track); color: var(--text); }
.hdr-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.hdr-end { margin-left: auto; }

/* 계정 메뉴(details) */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--text-2);
}
.user-btn:hover, .user-menu[open] > .user-btn { border-color: var(--border-strong); background: var(--surface-2); }
.user-btn .icon { color: var(--faint); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none;
}
.avatar-lg { width: 42px; height: 42px; font-size: 17px; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); padding: 8px; z-index: 40;
}
.user-pop-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-pop-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-pop-id strong { font-size: 15px; }
.user-pop-sub { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.user-pop form { margin: 0; }
.pop-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent;
  font-weight: 500; font-size: 14px; color: var(--text-2); text-decoration: none; line-height: 1.4;
}
.pop-item:hover { background: var(--track); color: var(--text); }
.pop-item[aria-current="page"] { color: var(--primary); font-weight: 600; }

/* 모바일 하단 탭바(넓은 화면에서는 숨김) */
.bottom-nav { display: none; }
.icon { display: block; flex: none; }

/* ---------- 레이아웃 ---------- */
.shell { width: 100%; }
.main, .page {
  max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 64px;
  display: flex; flex-direction: column; gap: 20px; min-width: 0;
}
.page-narrow { max-width: 480px; }
/* 카드를 감싸는 묶음도 같은 세로 간격을 갖는다(없으면 카드가 서로 붙는다) */
#content, #admin-ui, #map-root { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- 타이틀바 ---------- */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.topbar h1 { font-size: 28px; font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 신선도 배지 */
.fresh {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 99px;
  font-weight: 600; font-size: 13px; background: var(--track); color: var(--muted);
}
.fresh.ok { background: var(--green-soft); color: var(--green); }
.fresh.warn { background: var(--amber-soft); color: var(--amber); }
.fresh.error { background: var(--red-soft); color: var(--red); }
.fresh .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.fresh.skeleton { min-width: 170px; height: 32px; }

/* 배너 */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--radius-tile);
  font-weight: 600; font-size: 14px; line-height: 1.45;
}
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.error { background: var(--red-soft); color: var(--red); }
.banner.info { background: var(--primary-soft); color: var(--primary); }
.partial { display: flex; flex-wrap: wrap; gap: 8px; }
.partial-item {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 500;
}
.partial-item .dash { color: var(--muted); font-weight: 700; font-size: 16px; line-height: 1; }

/* ---------- 칩·버튼 ---------- */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.35;
  background: var(--track); color: var(--text-2); border: 1px solid transparent; white-space: nowrap;
}
.chip-sm { padding: 1px 8px; font-size: 11px; }
.chip-primary { background: var(--primary-soft); color: var(--primary); }
.chip-dark { background: var(--text); color: #fff; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-teal { background: var(--teal-soft); color: var(--teal); }
.chip-gray { background: var(--track); color: var(--muted); }
.chip-outline { background: var(--surface); border-color: var(--border); }
.chip-naver { background: var(--green-soft); color: var(--green); }
.chip-coupang { background: var(--red-soft); color: var(--red); }
.chip-cafe24 { background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-input); font-weight: 600; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); line-height: 1.3;
  box-shadow: var(--shadow-card);
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--track); border-color: transparent; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); box-shadow: none; }
.btn-soft:hover:not(:disabled) { background: #e0e7ff; border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--track); color: var(--text); }

/* ---------- 필터 도구막대 ---------- */
.filters {
  display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 10px 12px; box-shadow: var(--shadow-card);
}
/* 분절형 선택(기간·채널): 회색 트랙 위에 선택 항목만 흰 알약으로 떠 있다 */
.seg, .chips {
  display: inline-flex; gap: 2px; padding: 3px; background: var(--track); border-radius: 12px;
}
.seg button, .chips .chip {
  padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 14px; line-height: 1.3; white-space: nowrap;
}
.seg button:hover, .chips .chip:hover:not(:disabled) { color: var(--text); }
.seg button[aria-pressed="true"], .chips .chip[aria-pressed="true"] {
  background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.14), 0 0 0 1px rgba(16, 24, 40, 0.04);
}
.seg button:focus-visible, .chips .chip:focus-visible { outline-offset: 0; border-radius: 9px; }
.filter-note { font-size: 12px; color: var(--faint); }

/* 스위치 */
.toggle { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 40px; height: 24px; border-radius: 99px; background: var(--border-strong); transition: background 0.15s;
}
.toggle input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.3); transition: transform 0.15s;
}
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 99px; }

.custom-dates { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.custom-dates input[type="date"] {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--surface);
  font-size: 14px; min-width: 0; max-width: 160px;
}
.custom-dates .tilde { color: var(--muted); }

/* ---------- KPI 타일 ---------- */
.kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-tile); box-shadow: var(--shadow-card);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.tile-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-value { font-size: 30px; font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; }
.tile-value.na { color: var(--muted); }
.tile-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-sub.up { color: var(--red); }
.tile-sub.down { color: var(--green); }
.tile-sub.flat { color: var(--muted); }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }
.delta.flat { color: var(--muted); }
.tile-note { font-size: 12.5px; color: var(--amber); font-weight: 600; }

/* 스켈레톤 */
.sk { background: var(--track); border-radius: 6px; display: block; }
.sk-line { height: 12px; width: 60%; }
.sk-value { height: 30px; width: 45%; margin: 4px 0; }
.sk-row { height: 12px; width: 100%; margin: 10px 0; }
.sk-w140 { width: 140px; }
.sk-w30 { width: 30%; }
.sk-w45 { width: 45%; }
.sk-w60 { width: 60%; }
.sk-w65 { width: 65%; }
.sk-w70 { width: 70%; }
.sk-w72 { width: 72%; }
.sk-w75 { width: 75%; }
.sk-w80 { width: 80%; }
.sk-w85 { width: 85%; }
.sk-w90 { width: 90%; }
.sk-h18 { height: 18px; }
.sk-h120 { height: 120px; }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: sk-pulse 1.4s ease-in-out infinite; }
  @keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
}
@media (prefers-reduced-motion: reduce) {
  .toggle input, .toggle input::after { transition: none; }
}

/* ---------- 카드 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-foot { font-size: 13px; color: var(--muted); }
.charts { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: stretch; }
.charts > .card { align-self: stretch; }
.charts .col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* 가로 막대 — 컨테이너가 그리드, 각 행은 subgrid 라서 라벨 열 너비가 행마다 같다 */
.bars { display: grid; grid-template-columns: fit-content(140px) minmax(0, 1fr) auto; column-gap: 12px; row-gap: 12px; align-items: center; }
.bars.with-amount { grid-template-columns: fit-content(140px) minmax(0, 1fr) auto auto; }
.bars > :not(.bar-row) { grid-column: 1 / -1; }
.bar-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; }
.bar-label { font-size: 14px; font-weight: 500; line-height: 1.2; }
.bar-track { display: block; height: 10px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; min-width: 3px; }
.bar-n { font-size: 14px; font-weight: 700; min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-amt { font-size: 13px; color: var(--muted); min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }
.bars.compact { column-gap: 10px; row-gap: 10px; }
.bars.compact .bar-track { height: 8px; }
.bars.compact .bar-n { min-width: 22px; }

/* 꺾은선 */
.linechart { width: 100%; max-width: 100%; height: auto; display: block; }
.linechart .grid { stroke: var(--track); stroke-width: 1; }
.linechart .axis-text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.linechart .raw { fill: none; stroke: #c7c4f5; stroke-width: 1.25; }
.linechart .ma { fill: none; stroke: var(--primary); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.linechart .gap { fill: none; stroke: var(--primary); stroke-width: 2.25; stroke-dasharray: 3 4; stroke-linecap: round; }
.linechart .pt { fill: var(--primary); }
.linechart .pt-gap { fill: var(--surface); stroke: var(--faint); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-line { width: 16px; height: 0; border-top: 2px solid var(--primary); display: inline-block; }
.legend-line.dash { border-top-style: dashed; }
.legend-line.raw { border-top-color: #c7c4f5; }

/* 누적 막대 */
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--track); gap: 2px; }
.stack > span { height: 100%; display: block; }

/* ---------- 표 ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.card > .table-wrap { border: 0; border-radius: 0; overflow: visible; }
table.tbl { width: 100%; border-collapse: collapse; table-layout: auto; }
.tbl th, .tbl td { padding: 14px 12px; text-align: left; vertical-align: middle; font-size: 14px; }
.tbl thead th { background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 8px 12px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tbl tbody td { border-top: 1px solid var(--track); }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .rate { font-weight: 700; }
.tbl td.num + td, .tbl th.num + th:not(.num) { padding-left: 28px; }
.tbl .muted { color: var(--muted); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--surface-2); }
.tbl tbody tr.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tbl tbody tr.is-off td { color: var(--faint); }
.product { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pname {
  font-weight: 600; line-height: 1.4; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.pname-none { color: var(--faint); font-weight: 500; }
.pmeta { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.pmeta .key { font-variant-numeric: tabular-nums; }
#top-table th:nth-child(2) { width: 38%; }
#top-table td:nth-child(2) { min-width: 260px; }
.tbl-sm th, .tbl-sm td { padding: 9px 8px; font-size: 13px; }
.tbl-sm thead th { padding: 8px; }
.tbl-sk td { padding: 14px 12px; }

/* 모바일 카드 목록 */
.top-cards { list-style: none; margin: 0; padding: 0; display: none; flex-direction: column; gap: 8px; }
.top-cards:not(.expanded) li.top-extra { display: none; }
.top-more { margin-top: 2px; }
.top-card {
  width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px;
}
.top-card:active { background: var(--track); }
.top-card .head { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.top-card .head .product { flex: 1 1 auto; }
.top-card .head .rank { margin-top: 1px; }
.top-card .rank {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 99px; background: var(--text); color: #fff; font-size: 11px; font-weight: 700;
}
.top-card .stats { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.top-card .stats .rate { font-weight: 800; font-size: 16px; color: var(--red); }
.top-card .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- 빈 상태 ---------- */
.empty {
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-card);
  padding: 40px 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.empty p { font-weight: 700; font-size: 16px; }
.empty .hint { font-weight: 400; font-size: 13px; color: var(--muted); }

/* ---------- 상품 상세 패널 ---------- */
.panel-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.38); z-index: 40; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; background: var(--surface);
  z-index: 41; box-shadow: var(--shadow-panel); display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius-frame) 0 0 var(--radius-frame);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.panel-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.35; overflow-wrap: anywhere; }
.panel-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.panel-body { padding: 16px 24px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.panel .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.panel .kpi.one { grid-template-columns: minmax(0, 1fr); }
.panel .tile { box-shadow: none; padding: 14px 16px; background: var(--surface-2); }
.panel .tile-value { font-size: 26px; }
.section-title { font-size: 15px; font-weight: 700; }
.note-box { background: var(--amber-soft); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.note-box .note-title { color: var(--amber); font-weight: 700; font-size: 14px; }
.note-box p { font-size: 13px; }
.panel-msg { color: var(--muted); padding: 8px 0; }

/* ---------- 폼 ---------- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(900px 420px at 50% -8%, #e0e7ff 0%, rgba(224, 231, 255, 0) 70%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  border-radius: var(--radius-frame); padding: 32px 28px; display: flex; flex-direction: column; gap: 18px;
}
.auth-logo { display: block; width: 48px; height: 48px; border-radius: 12px; }
.auth-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.auth-brand { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-input);
  background: var(--surface); font-size: 15px;
}
.field input:focus-visible { outline: 3px solid rgba(79, 70, 229, 0.22); outline-offset: 0; border-color: var(--primary); }
.help, .field .help { font-size: 13px; color: var(--muted); line-height: 1.5; }
.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.msg { padding: 11px 14px; border-radius: 12px; font-weight: 500; font-size: 14px; }
.msg.error { background: var(--red-soft); color: var(--red); }
.msg.ok { background: var(--green-soft); color: var(--green); }
.msg.info { background: var(--primary-soft); color: var(--primary); }
.msg.warn { background: var(--amber-soft); color: var(--amber); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 모달 ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius-frame); padding: 26px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-pop);
}
.modal h2 { font-size: 19px; font-weight: 800; }
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.code-box code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: 0.04em; overflow-wrap: anywhere; }

/* ---------- 코드표 ---------- */
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 6px; }
.group-title { font-size: 16px; font-weight: 700; margin-top: 6px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1100px) {
  .charts { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 1024px) {
  .hdr-inner { padding: 0 20px; gap: 20px; }
  .main, .page { padding: 24px 20px 48px; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .kpi { gap: 16px; }
  .tbl th, .tbl td { padding: 12px 8px; }
}
@media (max-width: 768px) {
  body { font-size: 14px; }
  body.has-bottom-nav { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .hdr-inner { height: 56px; padding: 0 16px; gap: 12px; }
  .hdr-nav, .brand-sub, .user-name, .user-btn .icon { display: none; }
  .user-btn { padding: 3px; }
  .user-pop { min-width: 240px; }
  .main, .page { padding: 20px 16px 28px; gap: 16px; }
  #content, #admin-ui, #map-root { gap: 16px; }
  .topbar { align-items: center; }
  .topbar h1 { font-size: 24px; }
  .topbar .sub { display: none; }
  .fresh { padding: 6px 12px; font-size: 12.5px; }

  /* 필터: 한 칸씩 가로 전체 폭 */
  .filters { padding: 10px; gap: 10px; }
  .seg, .chips { display: flex; width: 100%; }
  .seg button, .chips .chip { flex: 1 1 0; padding: 8px 4px; font-size: 14px; }
  .toggle { margin-left: 0; width: 100%; flex-direction: row-reverse; justify-content: space-between; padding: 2px 4px; }
  .custom-dates { width: 100%; }
  .custom-dates input[type="date"] { flex: 1 1 120px; max-width: none; }

  .kpi, .kpi.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px 16px; }
  .tile-value { font-size: 24px; }
  .card { padding: 16px; }
  .table-wrap.top, .card > .table-wrap.top { display: none; }
  .top-cards { display: flex; }
  .bars, .bars.with-amount { column-gap: 10px; row-gap: 12px; }
  .bars { grid-template-columns: fit-content(100px) minmax(0, 1fr) auto; }
  .bars.with-amount { grid-template-columns: fit-content(100px) minmax(0, 1fr) auto auto; }
  .bar-label { font-size: 13px; }
  .bar-amt { min-width: 50px; font-size: 12px; }
  .panel { width: 100vw; left: 0; border-radius: 0; }
  .panel-head { padding: 18px 16px 0; }
  .panel-body { padding: 14px 16px 28px; }
  .form-row { grid-template-columns: 1fr; }

  /* 아래 고정 탭바 */
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border-radius: 12px;
    font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none;
  }
  .bottom-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

  /* 넓은 표(사용자·코드표) → 세로 카드 */
  .tbl-stack thead { display: none; }
  .tbl-stack, .tbl-stack tbody, .tbl-stack tr, .tbl-stack td { display: block; width: 100%; }
  .tbl-stack tr { padding: 12px 14px; }
  .tbl-stack tr + tr { border-top: 1px solid var(--border); }
  .tbl-stack tbody td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 10px; text-align: right; }
  .tbl-stack td::before { content: attr(data-label); color: var(--muted); font-weight: 600; flex: none; text-align: left; }
  .tbl-stack td.actions-cell::before { content: none; }
  .tbl-stack td.actions-cell { justify-content: flex-start; padding-top: 8px; }
}
@media (max-width: 420px) {
  .bars { grid-template-columns: fit-content(84px) minmax(0, 1fr) auto; }
  .bars.with-amount { grid-template-columns: fit-content(84px) minmax(0, 1fr) auto auto; }
  .kpi .tile-value { font-size: 22px; }
  .tile-label { font-size: 12.5px; }
}
