/* ===== 테마 토큰 (billing_react 방식) =====
   html.theme-* 에만 토큰을 두어 :root 와 충돌하지 않게 한다. */
html.theme-light {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --on-primary: #ffffff;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #ffffff;
  --elevated: #eff6ff;

  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --danger: #dc2626;
  --success: #16a34a;

  --highlight-bg: #fffbe6;
  --highlight-bg-strong: #fff3bf;
  --highlight-text: #0f172a;

  --shadow: 0 8px 24px rgba(0,0,0,.14);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.3);
  --focus-ring: #bfdbfe;

  --navy: #152536;
  --blue: #1769aa;
  --line: var(--border);
}

html.theme-dark {
  --primary: #7aa2f7;
  --primary-dark: #5a7dc7;
  --on-primary: #0b1020;

  --bg: #16181e;
  --surface: #24283b;
  --surface-2: #1f2335;
  --surface-3: #1a1b26;
  --elevated: #2a2f45;

  --text: #c0caf5;
  --muted: #8a93b8;
  --border: rgba(122, 162, 247, 0.16);

  --danger: #f7768e;
  --success: #9ece6a;

  --highlight-bg: #2f3650;
  --highlight-bg-strong: #3a4463;
  --highlight-text: #c0caf5;

  --shadow: 0 8px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.45);
  --focus-ring: rgba(122, 162, 247, 0.5);
}

html.theme-blue {
  /* 버튼·강조: 흰 글씨가 읽히도록 채도 높은 중청색 */
  --primary: #1e8ad4;
  --primary-dark: #1670ad;
  --on-primary: #ffffff;

  --bg: #0a1522;
  --surface: #15273d;
  --surface-2: #0f1e30;
  --surface-3: #0c1929;
  --elevated: #1e3a5f;

  --text: #e8f4ff;
  --muted: #8fbbe0;
  --border: rgba(94, 181, 255, 0.16);

  --danger: #ff6b6b;
  --success: #5ce0a0;

  --highlight-bg: #1a3352;
  --highlight-bg-strong: #21406a;
  --highlight-text: #e8f4ff;

  --shadow: 0 8px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.45);
  --focus-ring: rgba(30, 138, 212, 0.45);
}

/* 테마 클래스 적용 전 깜빡임 방지용 기본값 = 라이트 (:root 는 theme-* 보다 특이도가 낮음) */
html:not(.theme-light):not(.theme-dark):not(.theme-blue),
:root:not(.theme-light):not(.theme-dark):not(.theme-blue) {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --on-primary: #ffffff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #ffffff;
  --elevated: #eff6ff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --highlight-bg: #fffbe6;
  --highlight-bg-strong: #fff3bf;
  --highlight-text: #0f172a;
  --shadow: 0 8px 24px rgba(0,0,0,.14);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.3);
  --focus-ring: #bfdbfe;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
#root { min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ===== App shell (billing_react Layout) ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.topbar {
  height: 52px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  z-index: 30;
}
.topbar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  background: var(--surface-3);
  overflow: hidden;
  flex-shrink: 0;
}
.topbar-brand.is-collapsed {
  width: 0 !important;
  padding: 0;
  border-right: none;
}
.brand-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
}
.topbar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
}
.topbar-left-tools { min-width: 0; overflow: hidden; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.topbar-user { font-size: 12px; white-space: nowrap; }
.muted { color: var(--muted); }

.theme-select {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.leftpanel {
  flex-shrink: 0;
  background: var(--surface-3);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary) 45%, var(--muted)) var(--surface-2);
}
.leftpanel::-webkit-scrollbar {
  width: 8px;
}
.leftpanel::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 8px;
}
.leftpanel::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary) 40%, var(--muted));
  border-radius: 8px;
  border: 2px solid var(--surface-2);
}
.leftpanel::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--primary) 70%, var(--muted));
}

.main-area .content,
.content {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary) 40%, var(--muted)) var(--surface-2);
}
.main-area .content::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.main-area .content::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: var(--bg);
}
.main-area .content::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary) 35%, var(--muted));
  border-radius: 8px;
  border: 2px solid var(--bg);
}
.main-area .content::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--primary) 65%, var(--muted));
}
.lp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.lp-card.is-active {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}
.lp-card-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  text-align: left;
}
.lp-card:has(.lp-card-body) .lp-card-title,
.lp-card-title[aria-expanded="true"] {
  border-bottom-color: var(--border);
}
.lp-card-chevron {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}
.lp-card-body { padding: 6px; }
.leftpanel a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 7px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leftpanel a:hover { background: var(--surface-2); color: var(--text); }
.leftpanel a.active {
  color: var(--on-primary);
  background: var(--primary);
  font-weight: 600;
}

.panel-resizer {
  width: 3px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--surface-3);
  border-right: 1px solid var(--border);
}
.panel-resizer:hover,
.panel-resizer.dragging {
  background: var(--primary);
  border-right-color: var(--primary);
}
.panel-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 15px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.panel-toggle:hover { color: var(--primary); background: var(--elevated); }

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.main-area .content {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 20px;
}

/* legacy stubs kept for pages that still reference them */
.admin-layout { min-height: 100vh; }
.side { background: var(--surface-3) !important; }
.brand {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
}
.brand span { color: var(--primary); margin-left: 5px; }
.header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  padding: 0 28px !important;
}
.content { padding: 26px; overflow: auto; }
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  color: var(--text);
}
.page-title .ant-typography { margin: 0; font-weight: 700; color: var(--text) !important; }
.filter-card { margin-bottom: 16px; background: var(--surface-2); }
.dashboard-row { margin-top: 16px; }
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #2563eb);
  padding: 24px;
}
.login-box { width: 400px; max-width: 100%; }
.login-demo { color: #64748b; font-size: 12px; margin-top: 16px; text-align: center; }

@media (max-width: 640px) {
  .main-area .content { padding: 16px; }
  .content { padding: 16px; }
  .page-title { align-items: flex-start; gap: 10px; flex-direction: column; }
}
