/* ============================================================
   LicenseHub 콘솔 — GROVE DS 토큰 바인딩 (DS §3.1)
   Layer 1(primitive) + Layer 2(semantic) · 라이트 :root / 다크 .dark
   ============================================================ */

:root {
  /* primitive: Slate 뉴트럴 램프 (DS §4.1) */
  --slate-50:  #F8FAFC;  --slate-100: #F1F5F9;  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;  --slate-400: #94A3B8;  --slate-500: #64748B;
  --slate-600: #475569;  --slate-700: #334155;  --slate-800: #1E293B;
  --slate-900: #0F172A;  --slate-950: #020617;

  /* semantic: 서피스·텍스트 */
  --background: #FFFFFF;
  --foreground: var(--slate-900);
  --card: #FFFFFF;
  --popover: #FFFFFF;
  --muted: var(--slate-100);
  --muted-foreground: var(--slate-500);
  --border: var(--slate-200);
  --input: var(--slate-300);

  /* semantic: 상태색 (전 서비스 공통 고정, DS §4.4) */
  --success: #15803D;  --success-soft: #F0FDF4;
  --warning: #B45309;  --warning-soft: #FFFBEB;
  --destructive: #B91C1C;  --destructive-soft: #FEF2F2;
  --info: #0369A1;     --info-soft: #F0F9FF;

  /* semantic: 셸 */
  --sidebar: var(--slate-50);
  --sidebar-foreground: var(--slate-700);
  --sidebar-border: var(--slate-200);
  --topbar: color-mix(in oklab, var(--background) 88%, transparent);
  --overlay-scrim: rgba(15, 23, 42, 0.45);

  /* semantic: 데이터 시각화 램프 (DS §4.5) */
  --chart-2: #0E7490;  --chart-3: #B45309;
  --chart-4: #6D28D9;  --chart-5: #BE185D;
  --chart-grid: var(--slate-200);

  /* primitive: 앱 스위처용 서비스 액센트 (DS §4.3 배정표) */
  --svc-mdm: #2563EB;      --svc-sso: #4F46E5;   --svc-crm: #DC2626;
  --svc-forms: #0F766E;    --svc-hr: #15803D;    --svc-sendrail: #166534;
  --svc-edith: #0E7490;    --svc-grove: #0F172A;

  /* primitive: 라디우스·모션·엘리베이션 (DS §6) */
  --radius: 8px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px;
  --duration-fast: 120ms; --duration-base: 180ms; --duration-slow: 280ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 4px 12px -2px rgba(15, 23, 42, 0.10), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow-3: 0 16px 40px -8px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.04);

  --font-sans: "Inter", "Pretendard Variable", "Pretendard",
               -apple-system, "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

/* 서비스 액센트 주입 — <html data-service="license"> (DS §4.2, 가이드 §1) */
[data-service="license"] {
  --primary: #0369A1;
  --primary-foreground: #FFFFFF;
  --primary-soft: color-mix(in oklab, var(--primary) 9%, var(--background));
  --primary-hover: color-mix(in oklab, var(--primary) 88%, black);
  --ring: var(--primary);
  --chart-1: var(--primary);
  --sidebar-active: var(--primary-soft);
  --sidebar-active-foreground: var(--primary);
}

.dark {
  --background: var(--slate-950);
  --foreground: var(--slate-50);
  --card: var(--slate-900);
  --popover: var(--slate-900);
  --muted: var(--slate-800);
  --muted-foreground: var(--slate-400);
  --border: rgba(148, 163, 184, 0.16);
  --input: rgba(148, 163, 184, 0.28);

  --success: #4ADE80;  --success-soft: rgba(74, 222, 128, 0.12);
  --warning: #FBBF24;  --warning-soft: rgba(251, 191, 36, 0.12);
  --destructive: #F87171; --destructive-soft: rgba(248, 113, 113, 0.12);
  --info: #38BDF8;     --info-soft: rgba(56, 189, 248, 0.12);

  --sidebar: var(--slate-900);
  --sidebar-foreground: var(--slate-300);
  --sidebar-border: rgba(148, 163, 184, 0.12);
  --topbar: color-mix(in oklab, var(--background) 80%, transparent);
  --overlay-scrim: rgba(2, 6, 23, 0.65);

  --chart-2: #22D3EE;  --chart-3: #FBBF24;
  --chart-4: #A78BFA;  --chart-5: #F472B6;
  --chart-grid: rgba(148, 163, 184, 0.14);

  /* 다크 엘리베이션: 그림자 대신 명도 상승 + 헤어라인 (DS §6.3) */
  --shadow-1: 0 0 0 1px rgba(148, 163, 184, 0.10);
  --shadow-2: 0 0 0 1px rgba(148, 163, 184, 0.14), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 0 0 1px rgba(148, 163, 184, 0.16), 0 20px 48px -12px rgba(0, 0, 0, 0.65);
}

.dark[data-service="license"], .dark [data-service="license"] {
  --primary: #38BDF8;
  --primary-foreground: var(--slate-900);
  --primary-soft: color-mix(in oklab, var(--primary) 14%, var(--background));
  --primary-hover: color-mix(in oklab, var(--primary) 88%, white);
}

/* ============================================================
   베이스
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px; line-height: 20px;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex: none; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: inherit;
}

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 200;
  background: var(--card); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: var(--radius-md);
  transition: top var(--duration-fast);
}
.skip-link:focus-visible { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   셸 레이아웃 (DS §7)
   ============================================================ */
.console { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- 사이드바 240 / 64 (DS §7.1) ---------- */
.sidebar {
  width: 240px; flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-foreground);
  transition: width var(--duration-slow) var(--ease-out);
  overflow: hidden;
}
.console.collapsed .sidebar { width: 64px; }

.logo-zone {
  height: 56px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 16px;
}
.logo-mark {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-foreground);
}
.logo-name { font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--foreground); }
.app-switch-btn {
  margin-left: auto;
  width: 28px; height: 28px; border-radius: var(--radius-md);
  display: grid; place-items: center;
  color: var(--muted-foreground);
}
.app-switch-btn:hover { background: var(--muted); }
.console.collapsed .logo-name,
.console.collapsed .app-switch-btn { display: none; }

.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.nav-group-label {
  font-size: 12px; line-height: 16px; letter-spacing: 0.04em; font-weight: 500;
  color: var(--muted-foreground);
  padding: 14px 8px 6px; white-space: nowrap;
}
.console.collapsed .nav-group-label { visibility: hidden; height: 8px; padding: 8px 0 0; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 8px; margin-bottom: 2px;
  border-radius: var(--radius-md);
  font-weight: 500; white-space: nowrap;
}
.nav-item:hover { background: var(--muted); }
.nav-item[aria-current="page"] {
  background: var(--sidebar-active);
  color: var(--sidebar-active-foreground);
}
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 2px; background: var(--primary); border-radius: 1px;
}
.nav-item svg { color: currentColor; opacity: 0.85; }
.nav-badge {
  margin-left: auto;
  font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.02em;
  background: var(--muted); color: var(--muted-foreground);
  border-radius: 999px; padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.console.collapsed .nav-item { justify-content: center; padding: 0; }
.console.collapsed .nav-item span, .console.collapsed .nav-badge { display: none; }

.sidebar-bottom { flex: none; border-top: 1px solid var(--sidebar-border); padding: 8px 12px 10px; }
.account-block {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border-radius: var(--radius-md); text-align: left;
}
.account-block:hover { background: var(--muted); }
.avatar {
  width: 24px; height: 24px; flex: none; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 600;
}
.account-meta { min-width: 0; white-space: nowrap; }
.account-name { font-size: 13px; font-weight: 500; color: var(--foreground); }
.account-tenant { font-size: 11px; color: var(--muted-foreground); }
.console.collapsed .account-meta { display: none; }
.console.collapsed .sidebar-bottom .nav-item { justify-content: center; }

/* ---------- 톱바 56 (DS §7.2) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 56px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 24px;
  background: var(--topbar);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: grid; place-items: center;
  color: var(--muted-foreground);
  position: relative;
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.hamburger { display: none; }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); }
.breadcrumb .crumb-current { color: var(--foreground); font-weight: 500; }
.breadcrumb svg { opacity: 0.5; }

.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: 240px; height: 36px; padding: 0 10px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  color: var(--muted-foreground); font-size: 13px;
  background: var(--card);
}
.search-trigger:hover { border-color: var(--slate-400); }
.search-trigger kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--muted); border-radius: var(--radius-sm); padding: 1px 5px;
}
.unread-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--background);
}

/* ---------- 콘텐츠 (DS §7.4) ---------- */
.content {
  width: 100%; max-width: 1280px; margin: 0 auto;
  padding: 24px 32px 64px;
}
.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; line-height: 30px; letter-spacing: -0.01em; font-weight: 600; }
.page-desc { font-size: 13px; line-height: 18px; color: var(--muted-foreground); margin-top: 2px; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ============================================================
   컴포넌트
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--muted); color: var(--foreground); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { border: 1px solid var(--input); background: var(--card); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost:hover { background: var(--muted); }
.btn[disabled] { opacity: 0.5; cursor: default; pointer-events: none; }
.btn .spinner {
  width: 14px; height: 14px; border-radius: 999px;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 24px 0;
}
.card-head h3 { font-size: 15px; line-height: 22px; font-weight: 600; }
.card-head .head-side { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 24px 24px; }

/* 배지 (DS §8.6) */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 999px; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-destructive { background: var(--destructive-soft); color: var(--destructive); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--muted); color: var(--muted-foreground); }
.badge-plain::before { display: none; }
.badge.mono { font-family: var(--font-mono); letter-spacing: 0; }

/* 스탯 카드 (DS §8.6) */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-bottom: 24px; }
.stat-card { padding: 20px 24px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.stat-row { display: flex; align-items: flex-end; gap: 12px; }
.stat-value { font-size: 28px; line-height: 36px; letter-spacing: -0.02em; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-spark { margin-left: auto; color: var(--chart-1); }
.stat-delta { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.delta-up { color: var(--success); font-weight: 500; }
.delta-down { color: var(--destructive); font-weight: 500; }
.stat-delta .vs { color: var(--muted-foreground); font-weight: 400; }

/* 2행 그리드 */
.row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 24px; }

/* 탭 (밑줄형) */
.seg-tabs { display: flex; gap: 2px; background: var(--muted); border-radius: var(--radius-md); padding: 2px; }
.seg-tabs button {
  height: 26px; padding: 0 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; color: var(--muted-foreground);
}
.seg-tabs button[aria-selected="true"] { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-1); }

/* 플랜 분포 스택 바 */
.dist-block { margin-bottom: 20px; }
.dist-caption { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.dist-caption .t { font-size: 12px; color: var(--muted-foreground); }
.dist-bar { display: flex; gap: 2px; height: 14px; border-radius: var(--radius-sm); overflow: hidden; }
.dist-seg { position: relative; min-width: 4px; cursor: default; transition: opacity var(--duration-fast); }
.dist-seg:hover { opacity: 0.85; }
.dist-seg:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dist-seg:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); }
.legend-item .sw { width: 8px; height: 8px; border-radius: 2px; }
.legend-item b { color: var(--foreground); font-weight: 500; font-variant-numeric: tabular-nums; }

/* 라인 차트 */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; margin-bottom: 8px; }
.chart-tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-2);
  padding: 8px 10px; font-size: 12px; line-height: 18px;
  min-width: 132px; display: none;
}
.chart-tooltip .tt-title { color: var(--muted-foreground); margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-row .sw { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip .tt-row b { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }

/* 알림 리스트 */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: 0; }
.alert-ico {
  width: 28px; height: 28px; flex: none; margin-top: 1px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
}
.alert-ico.warn { background: var(--warning-soft); color: var(--warning); }
.alert-ico.destr { background: var(--destructive-soft); color: var(--destructive); }
.alert-ico.neutral { background: var(--muted); color: var(--muted-foreground); }
.alert-body { min-width: 0; flex: 1; }
.alert-title { font-size: 13px; font-weight: 500; line-height: 18px; }
.alert-sub { font-size: 12px; color: var(--muted-foreground); line-height: 16px; margin-top: 2px; }
.alert-item .badge { margin-top: 2px; }
.card-foot-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; color: var(--primary);
  margin-top: 12px; border-radius: var(--radius-sm);
}
.card-foot-link:hover { text-decoration: underline; }

/* 미니 쿼터바 */
.quota-mini { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.quota-track { flex: 1; height: 5px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 999px; }
.quota-fill.ok { background: var(--primary); } /* <70% — 진행 표시 (액센트 화이트리스트) */
.quota-fill.warn { background: var(--warning); }
.quota-fill.destr { background: var(--destructive); }
.quota-mini .pct { font-size: 11px; font-weight: 500; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* 서비스 식별 아바타 — 상표색 없이 서비스 토큰색 이니셜 */
.svc-avatar {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600; line-height: 1;
  color: #fff; background: var(--c, var(--muted-foreground));
}
.svc-avatar.sm { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }

/* 테이블 (DS §8.2) */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: 0.04em; color: var(--muted-foreground);
  height: 40px; padding: 0 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  height: 44px; padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px; white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--muted); }
td.t-time { color: var(--muted-foreground); font-size: 13px; cursor: default; }
td .actor { display: inline-flex; align-items: center; gap: 8px; }
.event-code { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); }

/* ============================================================
   오버레이 — 팝오버 · 다이얼로그 · 팔레트 · 토스트 · 바텀시트
   ============================================================ */
.scrim {
  position: fixed; inset: 0; z-index: 80;
  background: var(--overlay-scrim);
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-base);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.popover {
  position: fixed; z-index: 85;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  display: none;
}
.popover.open { display: block; animation: pop-in var(--duration-base) var(--ease-out); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* 알림 팝오버 */
.notif-pop { width: 340px; }
.notif-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-head h4 { font-size: 14px; font-weight: 600; }
.notif-head button { margin-left: auto; font-size: 12px; color: var(--primary); border-radius: var(--radius-sm); }
.notif-head button:hover { text-decoration: underline; }
.notif-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-dot { width: 7px; height: 7px; border-radius: 999px; margin-top: 6px; flex: none; background: var(--primary); }
.notif-item.read .notif-dot { background: transparent; }
.notif-text { font-size: 13px; line-height: 18px; }
.notif-time { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }

/* 앱 스위처 (DS §7.3) */
.switcher-pop { width: 336px; padding: 12px; }
.switcher-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.switcher-app {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border-radius: var(--radius-md);
  font-size: 11px; color: var(--muted-foreground); text-align: center;
}
.switcher-app:hover { background: var(--muted); }
.switcher-app .app-ico {
  width: 36px; height: 36px; border-radius: 999px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
  background: color-mix(in oklab, var(--app-c) 10%, var(--background));
  color: var(--app-c);
}
.switcher-app[aria-current="true"] .app-ico { box-shadow: 0 0 0 2px var(--primary); }
.switcher-foot { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.switcher-foot a { font-size: 13px; font-weight: 500; color: var(--primary); border-radius: var(--radius-sm); }

/* 다이얼로그 (DS §8.4 — 560) */
.dialog {
  position: fixed; z-index: 90; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  display: none; flex-direction: column;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-3);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}
.dialog.open { display: flex; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.dialog-head { padding: 20px 24px 0; }
.dialog-head h2 { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-head p { font-size: 13px; color: var(--muted-foreground); margin-top: 4px; }
.dialog-body { padding: 20px 24px; overflow-y: auto; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px 20px; border-top: 1px solid var(--border);
}

/* 폼 (DS §8.3) */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.field .req { color: var(--destructive); }
.field input[type="text"], .field input[type="date"], .field select {
  width: 100%; height: 36px; padding: 0 10px;
  font: inherit; color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--input); border-radius: var(--radius-md);
}
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; border-color: transparent; }
.field .hint { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }
.field.invalid input, .field.invalid select { border-color: var(--destructive); }
.field .err { display: none; align-items: center; gap: 4px; font-size: 12px; color: var(--destructive); margin-top: 4px; }
.field.invalid .err { display: flex; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-row { display: flex; gap: 16px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400; cursor: pointer; }
.radio-row input { accent-color: var(--primary); width: 15px; height: 15px; }

/* 아코디언 (정책 상세) */
.accordion { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 16px; }
.accordion > button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; font-size: 13px; font-weight: 500;
  border-radius: var(--radius-md);
}
.accordion > button svg { margin-left: auto; transition: transform var(--duration-base); color: var(--muted-foreground); }
.accordion.open > button svg { transform: rotate(180deg); }
.accordion-body { display: none; padding: 4px 12px 12px; }
.accordion.open .accordion-body { display: block; }

/* Alert (인라인) */
.alert-box {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-md);
  font-size: 13px; line-height: 18px;
}
.alert-box.warning { background: var(--warning-soft); color: var(--warning); }
.alert-box.info { background: var(--info-soft); color: var(--info); }
.alert-box svg { flex: none; margin-top: 1px; }

/* LicenseKeyDisplay — revealed (가이드 §4) */
.key-display {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  background: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 14px; letter-spacing: 0.02em;
  margin: 12px 0;
  overflow-x: auto;
}
.key-display .copy-btn {
  margin-left: auto; flex: none;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: grid; place-items: center; color: var(--muted-foreground);
}
.key-display .copy-btn:hover { background: var(--border); color: var(--foreground); }
.propagation-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); margin-top: 10px; }

/* 커맨드 팔레트 (DS §7.2 — 640, elevation-3) */
.cmdk {
  position: fixed; z-index: 95; left: 50%; top: 14vh;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px));
  display: none; flex-direction: column;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-3);
  overflow: hidden;
}
.cmdk.open { display: flex; animation: pop-in var(--duration-base) var(--ease-out); }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted-foreground); }
.cmdk-input-row input {
  flex: 1; border: 0; background: none; font: inherit; font-size: 15px;
  color: var(--foreground); outline: none;
}
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmdk-group-label { font-size: 11px; letter-spacing: 0.04em; font-weight: 500; color: var(--muted-foreground); padding: 8px 10px 4px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-md);
  font-size: 14px; cursor: pointer;
}
.cmdk-item svg { color: var(--muted-foreground); }
.cmdk-item[aria-selected="true"] { background: var(--muted); }
.cmdk-item .cmdk-kbd { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); }
.cmdk-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--muted-foreground); }

/* 토스트 (DS §8.5 — 우측 하단) */
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 360px;
  padding: 12px 14px;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  font-size: 13px; line-height: 18px;
  animation: toast-in var(--duration-base) var(--ease-out);
}
.toast svg { flex: none; }
.toast.success svg { color: var(--success); }
.toast.info svg { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 바텀시트 내비 (모바일, DS §7.5) */
.bottom-sheet {
  position: fixed; z-index: 90; left: 0; right: 0; bottom: 0;
  max-height: 78vh; overflow-y: auto;
  background: var(--popover);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border); border-bottom: 0;
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  padding: 8px 16px 24px;
}
.bottom-sheet.open { transform: none; }
.sheet-grabber { width: 36px; height: 4px; border-radius: 999px; background: var(--border); margin: 6px auto 10px; }
.bottom-sheet .nav-item { height: 44px; }
.bottom-sheet .nav-group-label { padding: 12px 8px 4px; }

/* 스켈레톤 (DS §8.7) */
.skeleton { position: relative; overflow: hidden; background: var(--muted); border-radius: var(--radius-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--foreground) 4%, transparent), transparent);
  animation: shimmer 1.8s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
[data-loading] .real { display: none; }
[data-loading] .sk-block { display: block; }
.sk-block { display: none; }

/* 절대시간 툴팁 */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 60;
  background: var(--slate-900); color: var(--slate-50);
  font-size: 11px; line-height: 14px; padding: 5px 8px;
  border-radius: var(--radius-sm); white-space: nowrap;
  box-shadow: var(--shadow-2);
}
.dark [data-tip]:hover::after { background: var(--slate-100); color: var(--slate-900); }

/* ============================================================
   반응형 (DS §7.5 — 360 / 768 / 1280 / 1920)
   ============================================================ */
@media (max-width: 1279px) {
  .content { padding: 24px 24px 56px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .sidebar, .sidebar-scrim { display: none; }
  .hamburger { display: grid; }
  .search-trigger { width: 36px; padding: 0; justify-content: center; border: 0; background: none; }
  .search-trigger .st-text, .search-trigger kbd { display: none; }
  .content { padding: 16px 16px 48px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 24px; line-height: 30px; }
  .page-header { flex-wrap: wrap; }
  .page-header h1 { font-size: 20px; line-height: 28px; }
  /* 테이블 → 카드형 축약: 보조 컬럼 숨김 (DS §8.2 모바일 규칙) */
  .hide-sm { display: none; }
  table.data td { height: 48px; }
  .breadcrumb .crumb-root { display: none; }
  .breadcrumb svg { display: none; }
}
@media (min-width: 768px) and (max-width: 1279px) {
  /* 태블릿: 접힘 64px 기본 — JS가 collapsed 클래스 부여 */
}

/* ============================================================
   자체 디자인 셀렉트 (od-select) — 네이티브 셀렉트 대체
   네이티브 <select class="od-select">를 시각 숨김(포커스 가능) 후
   버튼+리스트박스로 대체, 값·change 이벤트는 네이티브에 동기화
   ============================================================ */
.od-sel { position: relative; }
.od-sel > select.od-select {
  position: absolute; opacity: 0; width: 1px; height: 1px;
  pointer-events: none; margin: 0; padding: 0; border: 0;
}
.od-sel-btn {
  width: 100%; height: 36px; padding: 0 10px;
  display: flex; align-items: center; gap: 8px;
  font: inherit; text-align: left; color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--input); border-radius: var(--radius-md);
  cursor: pointer;
}
.od-sel-btn:hover { border-color: var(--slate-400); }
.od-sel-btn .od-sel-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.od-sel-btn .od-sel-value.placeholder { color: var(--muted-foreground); }
.od-sel-btn > svg { color: var(--muted-foreground); transition: transform var(--duration-base); }
.od-sel.open .od-sel-btn > svg { transform: rotate(180deg); }
.od-sel-list {
  position: absolute; z-index: 96; top: calc(100% + 4px); left: 0; min-width: 100%;
  max-height: 240px; overflow-y: auto;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-2);
  padding: 4px; display: none;
}
.od-sel.open .od-sel-list { display: block; animation: pop-in var(--duration-base) var(--ease-out); }
.od-sel-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.od-sel-opt.active { background: var(--muted); }
.od-sel-opt[aria-selected="true"] { font-weight: 500; }
.od-sel-opt[aria-selected="true"]::after {
  content: ""; margin-left: auto; width: 6px; height: 10px;
  border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary);
  transform: rotate(45deg) translateY(-2px);
}
.field.invalid .od-sel-btn { border-color: var(--destructive); }

/* 계정 드롭업 메뉴 — 사이드바 하단 계정 블록 (DS §7.1) */
.account-menu {
  position: fixed; z-index: 85; min-width: 200px;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-2);
  padding: 4px; display: none;
}
.account-menu.open { display: block; animation: pop-in var(--duration-base) var(--ease-out); }
.account-menu .am-head {
  padding: 8px 10px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted-foreground); line-height: 16px;
}
.account-menu .am-head b { display: block; font-size: 13px; font-weight: 600; color: var(--foreground); }
.account-menu button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; text-align: left;
}
.account-menu button:hover { background: var(--muted); }
.account-menu button svg { color: var(--muted-foreground); }
.account-menu .am-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* 테이블 행 내 쿼터 미니바 — 공용 (시트·미터 소진율) */
td .row-quota { display: flex; align-items: center; gap: 8px; min-width: 140px; }
td .row-quota .quota-track { flex: 1; height: 5px; border-radius: 999px; background: var(--muted); overflow: hidden; }
td .row-quota .quota-fill { height: 100%; border-radius: 999px; }
td .row-quota .pct { font-size: 11px; font-weight: 500; color: var(--muted-foreground); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============================================================
   빈 상태 — 공용 패턴 (DS §8.7): 일러스트 + 제목 + 설명 + CTA 1개
   ============================================================ */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px 64px; }
.empty-state svg { color: var(--muted-foreground); opacity: 0.6; margin-bottom: 16px; }
.empty-state .es-accent { color: var(--primary); opacity: 1; }
.empty-state h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty-state p { font-size: 13px; color: var(--muted-foreground); max-width: 320px; margin-bottom: 16px; }
