/* ═══════════════════════════════════════════════════════════════
   별오점 순이익 대시보드 — 디자인 시스템 v2 (사이드바 레이아웃)
   디자인 정책 문서 기반 전면 재작성
   ═══════════════════════════════════════════════════════════════ */

/* ── Pretendard Variable 웹폰트 ── */
@font-face {
  font-family: 'Pretendard';
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/woff2/PretendardVariable.woff2') format('woff2-variations');
}

/* ── 토큰 ── */
:root {
  /* Brand Palette */
  --brand-red: #EF4023;
  --brand-red-hover: #F05A3E;
  --brand-black: #231F20;
  --brand-burgundy: #7A262B;
  --brand-teal: #6AC8C7;
  --brand-light-gray: #DCDCD7;
  --brand-medium-gray: #9E9F9C;
  --brand-dark-gray: #585958;
  --brand-blue: #1C5BFF;
  --brand-blue-hover: #3D72FF;
  --brand-blue-ink: #1543C4;

  /* Surface (Light) */
  --bg: #ECECE8;
  --surface: #FFFFFF;
  --surface-2: #F7F7F5;
  --surface-elevated: #FFFFFF;
  --border: #DCDCD7;
  --border-strong: #C7C7C1;
  --border-subtle: rgba(35, 31, 32, 0.08);

  /* Text 위계 */
  --text-primary: #231F20;
  --text-secondary: #585958;
  --text-muted: #8A8A85;
  --text-disabled: #C9C9C3;

  /* Accent = 레드 (인터랙션·링크·주요 액션) */
  --accent: #EF4023;
  --accent-hover: #D63418;
  --accent-active: #B82C12;
  --accent-soft: rgba(239, 64, 35, 0.10);

  /* Selected = 블루 (선택/현재 위치 전용 — 인터랙션에 쓰지 말 것) */
  --selected: #1C5BFF;
  --selected-hover: #3D72FF;
  --selected-soft: #E9EFFE;

  /* Status 정본 (--st-*) */
  --st-ok: #1E9E54;
  --st-ok-soft: #DCFCE7;
  --st-caution: #B07A0E;
  --st-caution-soft: #FDF3DF;
  --st-danger: #E03A1E;
  --st-danger-soft: #FCE4DF;
  --st-info: #00677B;
  --st-info-soft: #E0EFF1;

  /* Focus ring (accent 기반) */
  --ring: rgba(239, 64, 35, 0.40);

  /* Chart (Multi color 팔레트) — 정책: 순이익 #3E5A80, 광고비 #F5843C, 효율 #6AC8C7 */
  --chart-grid: rgba(35, 31, 32, 0.10);
  --chart-axis: #77776F;
  --chart-1: #3E5A80;
  --chart-2: #F5843C;
  --chart-3: #6AC8C7;
  --chart-4: #4CAF82;
  --chart-5: #F2B705;

  /* Radius */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Shadow — 정책: 그림자는 팝오버·모달에만. 카드는 border만 */
  --shadow-sm: 0 1px 3px rgba(15, 30, 50, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 30, 50, 0.10), 0 6px 18px rgba(15, 30, 50, 0.10);
  --shadow-lg: 0 4px 8px rgba(15, 30, 50, 0.08), 0 12px 32px rgba(15, 30, 50, 0.20);

  /* Typography */
  --font-sans: 'Pretendard', 'Pretendard Variable', -apple-system, BlinkMacSystemFont,
               'Apple SD Gothic Neo', 'Segoe UI', 'Malgun Gothic', sans-serif;
  --font-mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  --font-num: 'Pretendard', 'Pretendard Variable', -apple-system, 'Apple SD Gothic Neo', 'Segoe UI', sans-serif;

  /* Font size 위계 (최소 12px) */
  --fs-caption: 12px;
  --fs-label: 13px;
  --fs-body: 14px;
  --fs-section: 15px;
  --fs-subtitle: 16px;
  --fs-heading: 20px;
  --fs-title: 24px;
  --fs-hero: 42px;
  --fs-kpi: 27px;

  /* Font weight */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extra: 800;
  --fw-black: 900;

  /* Sidebar */
  --sidebar-w: 236px;
  --sidebar-bg: #231F20;
  --sidebar-text: #D4D0CB;
  --sidebar-muted: #77776F;
  --sidebar-border: #3A3637;
  --sidebar-hover: #2C2829;

  /* Legacy alias (템플릿 호환) */
  --brand-primary: var(--accent);
  --brand-primary-hover: var(--accent-hover);
  --brand-primary-ink: var(--brand-blue-ink);
}

/* ── Minimal Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
a { color: inherit; text-decoration: inherit; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; border-spacing: 0; }

/* ── Base ── */
html, body {
  font-family: var(--font-sans) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  background: var(--bg) !important;
  color: var(--text-primary) !important;
  font-size: var(--fs-body) !important;
  line-height: 1.5 !important;
  font-variant-numeric: tabular-nums;
}
input, button, select, textarea, optgroup {
  font-family: var(--font-sans) !important;
}

/* ── 타이포그래피 위계 ── */
h1, .ds-h1 {
  font-size: var(--fs-title) !important;
  font-weight: var(--fw-extra) !important;
  letter-spacing: -0.8px !important;
  line-height: 1.2 !important;
  color: var(--text-primary);
}
h2, .ds-h2 {
  font-size: var(--fs-section) !important;
  font-weight: var(--fw-extra) !important;
  letter-spacing: -0.3px;
  line-height: 1.3 !important;
  color: var(--text-primary);
}
h3, .ds-h3 {
  font-size: var(--fs-body) !important;
  font-weight: var(--fw-bold) !important;
  line-height: 1.4;
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════
   레이아웃 — 사이드바 + 메인
   ══════════════════════════════════════════════════════════════ */

.ds-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ── 사이드바 ── */
.ds-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  overflow-y: auto;
}

.ds-sidebar-brand {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ds-sidebar-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ds-sidebar-brand-name {
  font-size: 14px;
  font-weight: var(--fw-extra);
  color: #fff;
  letter-spacing: -0.4px;
}
.ds-sidebar-brand-sub {
  font-size: 12px;
  color: var(--sidebar-muted);
}

.ds-sidebar-store {
  margin: 0 18px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 7px;
  background: var(--sidebar-hover);
  font-size: 12px;
}
.ds-sidebar-store-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--st-ok);
  flex-shrink: 0;
}
.ds-sidebar-store-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ds-sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ds-sidebar-group-label {
  font-size: 12px;
  color: var(--sidebar-muted);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.4px;
  padding: 0 10px 6px;
}
.ds-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border: 0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  background: transparent;
  color: #BFBBB3;
  transition: background 0.15s, color 0.15s;
}
.ds-sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.ds-sidebar-link.active {
  background: var(--accent);
  color: #fff;
}
.ds-sidebar-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.ds-sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ds-sidebar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sidebar-border);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--sidebar-text);
  flex-shrink: 0;
}
.ds-sidebar-user-name {
  font-size: 12px;
  color: var(--sidebar-text);
  font-weight: var(--fw-medium);
}

/* ── 모바일 헤더 (사이드바 토글) ── */
.ds-mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--sidebar-bg);
  color: #fff;
  z-index: 40;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.ds-mobile-menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.ds-mobile-title {
  font-size: 14px;
  font-weight: var(--fw-extra);
  letter-spacing: -0.3px;
}
.ds-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
}
.ds-sidebar-overlay.open { display: block; }

/* ── 메인 영역 ── */
.ds-main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

/* ── 페이지 헤더 ── */
.ds-page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.ds-page-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px 12px;
}
.ds-page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.ds-page-title {
  margin: 0;
  font-size: var(--fs-title) !important;
  font-weight: var(--fw-extra) !important;
  letter-spacing: -0.8px !important;
  line-height: 1;
}
.ds-page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.ds-page-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── 페이지 탭 ── */
.ds-page-tabs {
  display: flex;
  gap: 22px;
  padding: 0 28px;
}
.ds-page-tab {
  padding: 0 0 11px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  text-decoration: none;
}
.ds-page-tab:hover { color: var(--text-primary); }
.ds-page-tab.active {
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ── 콘텐츠 영역 ── */
.ds-content {
  padding: 22px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── 수집 상태 바 ── */
.ds-status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 22px;
  font-size: 12px;
  color: var(--text-muted);
}
.ds-status-bar b {
  color: var(--text-secondary);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
}
.ds-status-bar .ds-status-sep {
  color: var(--border);
}

/* ══════════════════════════════════════════════════════════════
   KPI 카드 시스템
   정책: 4단 구조 (라벨 → 값+단위 → 증감 → 미니차트)
   ══════════════════════════════════════════════════════════════ */

/* KPI 그리드 */
.ds-kpi-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.6fr) repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: stretch;
}

/* Hero KPI (화면당 1개, 1.6배 폭) */
.ds-kpi-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}
.ds-kpi-hero-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ds-kpi-hero-label-text {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
.ds-kpi-hero-label-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}
.ds-kpi-hero-value {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.ds-kpi-hero-number {
  font-size: var(--fs-hero);
  font-weight: var(--fw-black);
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
}
.ds-kpi-hero-unit {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: var(--fw-semibold);
  padding-bottom: 3px;
}
.ds-kpi-hero-delta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  font-size: 15px;
}
.ds-kpi-hero-delta-pct {
  font-weight: var(--fw-extra);
  letter-spacing: -0.3px;
}
.ds-kpi-hero-delta-abs {
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
}
.ds-kpi-hero-spark {
  margin-top: auto;
  padding-top: 14px;
}

/* Regular KPI Card */
.ds-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-kpi-label {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
.ds-kpi-value {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}
.ds-kpi-number {
  font-size: var(--fs-kpi);
  font-weight: var(--fw-extra);
  line-height: 1.1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
}
.ds-kpi-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: var(--fw-semibold);
  padding-bottom: 2px;
}
.ds-kpi-delta {
  font-size: 14px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.2px;
}
.ds-kpi-foot {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.ds-kpi-spark {
  margin-top: auto;
  padding-top: 12px;
}

/* ── 기간 선택기 (헤더 내부) ── */
.ds-period-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
}
.ds-period-btn {
  padding: 7px 13px;
  border: none;
  border-left: 1px solid var(--border);
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.ds-period-btn:first-child { border-left: none; }
.ds-period-btn:hover { background: var(--border); }
.ds-period-btn.active {
  background: var(--text-primary);
  color: #fff;
}

.ds-date-display {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
}
.ds-date-display .muted { color: var(--text-muted); }
.ds-date-display .value {
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
}

/* ══════════════════════════════════════════════════════════════
   Card — 정책: 1px #DCDCD7, radius 8, 그림자 없음
   ══════════════════════════════════════════════════════════════ */

.ds-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ds-card-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.ds-card-header h2 {
  margin: 0;
  font-size: var(--fs-section);
  font-weight: var(--fw-extra);
  letter-spacing: -0.3px;
}
.ds-card-header .ds-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 10px;
}
.ds-card-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ds-card-body {
  padding: 20px;
}

/* ── Card accent bar modifier ── */
.ds-card--accent-left {
  border-left: 4px solid var(--accent);
}

/* ══════════════════════════════════════════════════════════════
   Table — 정책 04
   헤더: 배경 없음. 12px/500 #8A8A85 + 하단 1.5px #231F20
   수치: 가운데 정렬. 행: 상하 16px, 구분선 1px #F2F2EF
   합계: 상단 1.5px #231F20만. 배경색 없음.
   ══════════════════════════════════════════════════════════════ */

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 600px;
}
.ds-table thead { background: none; }
.ds-table th {
  padding: 12px 12px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--text-primary);
  white-space: nowrap;
}
.ds-table th .sort-icon { color: var(--text-disabled); }
.ds-table th.sorted {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}
.ds-table th.right, .ds-table td.right { text-align: right; }
.ds-table th.center, .ds-table td.center { text-align: center; }
.ds-table td {
  padding: 16px 12px;
  border-bottom: 1px solid #F2F2EF;
  color: var(--text-primary);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.ds-table tbody tr { transition: background-color 0.1s ease; }
.ds-table tbody tr:hover { background: #FAFAF8; }
.ds-table tbody tr.clickable { cursor: pointer; }

/* 합계 행 — 정책: 배경 없음, 상단 1.5px 검정선 */
.ds-table tfoot td {
  padding: 15px 12px;
  border-top: 1.5px solid var(--text-primary);
  border-bottom: none;
  font-weight: var(--fw-bold);
}

/* 상위 강조 — 정책: 상위 3행만 이름·수치 700 */
.ds-table .rank-top { font-weight: var(--fw-bold); color: var(--text-primary); }
.ds-table .rank-rest { color: var(--text-disabled); }

/* ── 필터 칩 — 정책 04-1 ── */
.ds-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.ds-chip:hover { background: var(--surface-2); }
.ds-chip.active {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
}
.ds-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-chip b { font-weight: var(--fw-bold); }

/* ── 표 요약 문구 ── */
.ds-table-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 14px;
}
.ds-table-summary b {
  color: var(--text-primary);
  font-weight: var(--fw-bold);
}

/* ── 표 각주 ── */
.ds-table-footnote {
  padding: 14px 0 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.85;
}
.ds-table-footnote b {
  color: var(--text-secondary);
  font-weight: var(--fw-bold);
}

/* ══════════════════════════════════════════════════════════════
   Buttons
   ══════════════════════════════════════════════════════════════ */

.ds-btn {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 8px 16px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1.4;
}
.ds-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.ds-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.ds-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.ds-btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.ds-btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.ds-btn--secondary:hover:not(:disabled) {
  background: var(--surface-2);
}
.ds-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.ds-btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-primary);
}
.ds-btn--danger {
  background: var(--surface);
  color: var(--st-danger);
  border-color: var(--st-danger);
}
.ds-btn--danger:hover:not(:disabled) {
  background: var(--st-danger-soft);
}
.ds-btn--ok {
  background: var(--st-ok);
  color: #fff;
  border-color: var(--st-ok);
}
.ds-btn--ok:hover:not(:disabled) {
  background: #1a8a49;
}
.ds-btn--sm { padding: 5px 12px; font-size: var(--fs-caption); }
.ds-btn--lg { padding: 11px 22px; font-size: 15px; }

/* ── Badge ── */
.ds-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  padding: 2px 8px;
  border-radius: 5px;
}
.ds-badge--ok { background: var(--st-ok-soft); color: var(--st-ok); }
.ds-badge--caution { background: var(--st-caution-soft); color: var(--st-caution); }
.ds-badge--danger { background: var(--st-danger-soft); color: var(--st-danger); }
.ds-badge--info { background: var(--st-info-soft); color: var(--st-info); }
.ds-badge--neutral { background: #F0F0EC; color: var(--text-muted); }

/* ── Status text ── */
.st-positive { color: var(--st-ok); font-weight: var(--fw-semibold); }
.st-negative { color: var(--st-danger); font-weight: var(--fw-semibold); }
.st-neutral  { color: var(--text-muted); }

/* ── Numeric emphasis ── */
.num-negative { color: var(--st-danger) !important; font-weight: var(--fw-semibold); }
.num-positive { color: var(--st-ok) !important; font-weight: var(--fw-semibold); }
.num-primary  { color: var(--text-primary) !important; font-weight: var(--fw-bold); }

/* ── Form inputs ── */
.ds-input {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-label);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  outline: none;
}
.ds-input:focus {
  border-color: var(--text-primary);
  box-shadow: none;
}
.ds-input::placeholder { color: var(--text-muted); }
.ds-input--sm { padding: 7px 11px; font-size: var(--fs-label); }

.ds-label {
  display: block;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ── Select ── */
.ds-select {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-label);
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238A8A85' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-primary);
  cursor: pointer;
}
.ds-select:focus {
  outline: none;
  border-color: var(--text-primary);
}

/* ── Info banner ── */
.ds-banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: var(--fs-label);
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.ds-banner--info { background: var(--st-info-soft); color: var(--st-info); border: 1px solid rgba(0,103,123,0.15); }
.ds-banner--ok { background: var(--st-ok-soft); color: var(--st-ok); border: 1px solid rgba(30,158,84,0.15); }
.ds-banner--caution { background: var(--st-caution-soft); color: var(--st-caution); border: 1px solid rgba(176,122,14,0.15); }
.ds-banner--danger { background: var(--st-danger-soft); color: var(--st-danger); border: 1px solid rgba(224,58,30,0.15); }

/* ── Tabs ── */
.ds-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.ds-tab {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px;
  margin-right: 18px;
  cursor: pointer;
  transition: color 0.15s;
}
.ds-tab:hover { color: var(--text-primary); }
.ds-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  font-weight: var(--fw-bold);
}

/* ── Pill filter ── */
.ds-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-label);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}
.ds-pill:hover { background: var(--surface-2); }
.ds-pill.active {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
}

/* ── Modal / Overlay ── */
.ds-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.ds-overlay.open { display: flex; }
.ds-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: ds-modal-in 0.2s ease;
}
@keyframes ds-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.ds-modal-header h3 {
  font-size: var(--fs-subtitle);
  font-weight: var(--fw-bold);
  margin: 0;
}
.ds-modal-body {
  padding: 20px;
  font-size: var(--fs-body);
  color: var(--text-secondary);
}
.ds-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Empty state ── */
.ds-empty {
  padding: 52px 20px 56px;
  text-align: center;
}
.ds-empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 11px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 20px;
  opacity: 0.7;
}
.ds-empty-title {
  font-size: 15px;
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.ds-empty-desc {
  font-size: var(--fs-label);
  color: var(--text-muted);
  margin-top: 7px;
  line-height: 1.6;
}

/* ── File input ── */
input[type="file"]::file-selector-button {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.15s;
}
input[type="file"]::file-selector-button:hover {
  background: var(--border);
}

/* ── Mobile card ── */
.ds-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease;
}
.ds-mobile-card:active { transform: scale(0.995); }
.ds-mobile-card--positive { border-left-color: var(--st-ok); }
.ds-mobile-card--negative { border-left-color: var(--st-danger); }
.ds-mobile-card--neutral  { border-left-color: var(--text-muted); }

/* ── Upload dropzone ── */
.ds-dropzone {
  border: 1.5px dashed #C9C9C3;
  border-radius: var(--radius);
  background: #F9F9F7;
  padding: 44px 24px;
  text-align: center;
}

/* ── Utility ── */
.ds-mono { font-family: var(--font-mono) !important; }
.ds-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-divider { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C9C9C3; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }

/* ══════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
  .ds-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .ds-sidebar.open {
    transform: translateX(0);
  }
  .ds-mobile-header { display: flex; }
  .ds-main-area {
    margin-left: 0;
    padding-top: 50px;
  }
  .ds-page-header-inner { padding: 14px 16px 10px; }
  .ds-content { padding: 16px 16px 32px; gap: 14px; }
  .ds-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ds-kpi-hero { grid-column: 1 / -1; }
  .ds-kpi-hero-number { font-size: 32px; }
  .ds-kpi-number { font-size: 22px; }
  .ds-page-tabs { padding: 0 16px; }
}

@media (max-width: 767px) {
  .ds-kpi-grid {
    grid-template-columns: 1fr;
  }
  .ds-page-header-inner { flex-wrap: wrap; }
  .ds-page-header-right { width: 100%; }
  .ds-kpi-hero-number { font-size: 28px; }
  .ds-kpi-number { font-size: 20px; }
}

/* ══════════════════════════════════════════════════════════════
   Token-mapped utility classes
   ══════════════════════════════════════════════════════════════ */

/* ── Text colors ── */
.text-ink     { color: var(--text-primary) !important; }
.text-ink-2   { color: var(--text-secondary) !important; }
.text-ink-3   { color: var(--text-muted) !important; }
.text-ok      { color: var(--st-ok) !important; }
.text-danger  { color: var(--st-danger) !important; }
.text-caution { color: var(--st-caution) !important; }
.text-info    { color: var(--st-info) !important; }
.text-accent     { color: var(--accent) !important; }
.text-accent-ink { color: var(--brand-blue-ink) !important; }
.text-selected   { color: var(--selected) !important; }

/* ── Background colors ── */
.bg-surface      { background-color: var(--surface) !important; }
.bg-surface-2    { background-color: var(--surface-2) !important; }
.bg-bg           { background-color: var(--bg) !important; }
.bg-accent       { background-color: var(--accent) !important; }
.bg-accent-soft  { background-color: var(--accent-soft) !important; }
.bg-selected-soft { background-color: var(--selected-soft) !important; }
.bg-ok-soft      { background-color: var(--st-ok-soft) !important; }
.bg-danger-soft  { background-color: var(--st-danger-soft) !important; }
.bg-caution-soft { background-color: var(--st-caution-soft) !important; }
.bg-info-soft    { background-color: var(--st-info-soft) !important; }

/* ── Border colors ── */
.border-line     { border-color: var(--border) !important; }
.border-accent   { border-color: var(--accent) !important; }
.border-l-accent { border-left-color: var(--accent) !important; }
.border-ok       { border-color: var(--st-ok) !important; }
.border-danger   { border-color: var(--st-danger) !important; }
.border-line\/50 { border-color: rgba(220, 220, 215, 0.5) !important; }

/* ── Hover utilities ── */
.hover\:bg-surface-2:hover { background-color: var(--surface-2) !important; }
.hover\:text-ink:hover     { color: var(--text-primary) !important; }

/* ═══════════════════════════════════════════════════════════════
   기간별 분석 — 캘린더 + 랭킹
   ═══════════════════════════════════════════════════════════════ */

/* 캘린더 래퍼 */
.period-calendar-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.period-calendar {
  min-width: 600px;
}

/* 요일 헤더 */
.period-cal-header,
.period-cal-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.period-cal-header {
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.period-cal-hdr {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.period-cal-row {
  margin-bottom: 8px;
}

/* 셀 — 흰 배경 + 얇은 border (ds-card와 동일한 톤) */
.period-cal-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  min-height: 80px;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.period-cal-cell:hover:not(.period-cal-out) {
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}

/* 오늘 */
.period-cal-today {
  border: 2px solid var(--accent) !important;
  background: var(--accent-soft);
}

/* 범위 밖 날짜 */
.period-cal-out {
  background: var(--surface-2);
  opacity: .3;
}

/* 날짜 */
.period-cal-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: auto;
  font-variant-numeric: tabular-nums;
}

/* 순이익 (축약 숫자) */
.period-cal-profit {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  margin-top: 4px;
}

/* 판매량 */
.period-cal-units {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

/* 랭킹 2열 그리드 */
.period-ranking-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* 랭킹 메달 */
.period-rank-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.period-rank-medal--gold   { background: #FFF3CD; color: #856404; }
.period-rank-medal--silver { background: #E8E8E4; color: #585958; }
.period-rank-medal--bronze { background: #FFE5D5; color: #9C4221; }

/* ═══════════════════════════════════════════════════════════════
   원가 스프레드시트 — 인라인 편집
   ═══════════════════════════════════════════════════════════════ */

/* 툴바 */
.cost-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.cost-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.cost-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cost-common-fields {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 스프레드시트 카드: 패딩 없이 테이블 꽉 채움 */
.cost-sheet-card { overflow: hidden; }
.cost-sheet-card .overflow-x-auto { overflow-x: auto; }

/* 잠금 셀 */
.cost-cell-lock {
  background: var(--surface-2);
  cursor: default;
  user-select: text;
}

/* 편집 셀 */
.cost-cell-edit {
  position: relative;
  cursor: text;
  padding: 0 !important;
}
.cost-cell-edit .cell-display {
  display: block;
  padding: 16px 12px;
  min-height: 49px;
  cursor: text;
  font-variant-numeric: tabular-nums;
}
.cost-cell-edit .cell-input {
  display: none;
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 14px 10px;
  font-size: 13px;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--accent);
  font-variant-numeric: tabular-nums;
}
.cost-cell-edit .cell-input:focus {
  outline: none;
  border: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.cost-cell-edit:hover {
  background: var(--accent-soft);
}

/* 변경된 셀 */
.cost-cell-dirty {
  background: var(--st-caution-soft) !important;
}
.cost-cell-dirty .cell-display {
  font-weight: var(--fw-semibold);
}

/* 상태 아이콘 (원형) */
.cost-status-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  line-height: 20px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}
.cost-status--ok {
  background: var(--st-ok-soft);
  color: var(--st-ok);
}
.cost-status--ok::before { content: '\2713'; }  /* ✓ */
.cost-status--caution {
  background: var(--st-caution-soft);
  color: var(--st-caution);
}
.cost-status--caution::before { content: '\26A0'; font-size: 11px; }  /* ⚠ */
.cost-status--dirty {
  background: var(--accent-soft);
  color: var(--accent);
}
.cost-status--dirty::before { content: '\270E'; }  /* ✎ */

/* 하단 sticky 액션 바 */
.cost-action-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  transform: translateY(100%);
  transition: transform .25s ease;
  z-index: 30;
}
.cost-action-bar.visible {
  transform: translateY(0);
}
.cost-action-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
}
.cost-action-count {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
}
.cost-action-count b {
  color: var(--accent);
  font-weight: var(--fw-extra);
}

/* 스프레드시트 테이블 밀도 */
.cost-sheet th { padding: 10px 12px 8px; }
.cost-sheet td { padding: 0; }
.cost-sheet .cost-cell-lock { padding: 16px 12px; }
.cost-sheet .cost-status-cell { padding: 12px 8px; }
.cost-sheet td.center:last-child { padding: 12px 8px; }

@media (max-width: 1023px) {
  .cost-action-bar { left: 0; }
  .cost-action-bar-inner { padding: 12px 16px; }
  .cost-toolbar { flex-direction: column; align-items: stretch; }
  .cost-toolbar-left { flex-wrap: wrap; }
  .cost-toolbar-right { justify-content: flex-end; }
  .cost-common-fields { flex-wrap: wrap; }
}

@media (max-width: 1023px) {
  .period-ranking-grid {
    grid-template-columns: 1fr;
  }
  .period-cal-cell {
    min-height: 64px;
    padding: 8px 6px;
  }
  .period-cal-profit { font-size: 12px; }
  .period-cal-units  { font-size: 10px; }
  .period-cal-header,
  .period-cal-row { gap: 4px; }
}
