/* =====================================================================
   디자인 토큰 — 골격 (테마 무관)  v1 / 2026-09-05
   정본 계약 = _Shared_Brain/design/TOKENS.md · 부품 문법 = COMPONENTS.md
   ---------------------------------------------------------------------
   쓰는 법 (페이지가 :root 를 다시 적지 않는다 — DG-3):
     <link rel="stylesheet" href="/design/tokens.base.css">
     <link rel="stylesheet" href="/design/themes/light.css">   <!-- 또는 dark.css -->
   색은 여기 없다. 색은 themes/*.css 에만 있다.
   ===================================================================== */

:root {
  /* ---- 글꼴 ------------------------------------------------------- */
  --font-sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo",
               "Malgun Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- 글자 크기 8단 (본문 = --fs-base) ---------------------------
     px 로 고정한다. rem 은 html 의 font-size 에 끌려다녀 22 대시보드에서
     실제로 6단계가 한 단계로 붕괴한 적이 있다(커밋 4346051c). */
  --fs-scale: 1;
  --fs-xs:   calc(12px * var(--fs-scale));   /* 캡션·배지 */
  --fs-sm:   calc(13px * var(--fs-scale));   /* 표 안 보조 */
  --fs-base: calc(15px * var(--fs-scale));   /* ★본문·입력칸·표 값 */
  --fs-md:   calc(16px * var(--fs-scale));   /* 카드 제목 */
  --fs-lg:   calc(18px * var(--fs-scale));   /* 섹션 제목 */
  --fs-xl:   calc(22px * var(--fs-scale));   /* 페이지 제목 */
  --fs-2xl:  calc(27px * var(--fs-scale));   /* KPI 숫자 */
  --fs-3xl:  calc(34px * var(--fs-scale));   /* 히어로 숫자 */
  --lh: 1.55;

  /* ---- 간격 (4px 배수만) ------------------------------------------ */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* ---- 모서리 ----------------------------------------------------- */
  --r-sm: 8px;  --r: 12px;  --r-lg: 16px;  --r-pill: 999px;

  /* ---- 레이아웃 --------------------------------------------------- */
  --sidebar-w: 256px;
  --content-max: 1180px;

  /* ---- 밀도 (한 벌로 교체. 개별 조정 금지) ------------------------ */
  --card-pad:  20px;
  --row-py:    13px;
  --stack-gap: 18px;

  /* ---- 움직임 (MOTION_AND_TASTE.md §2 · 2026-10-07) ---------------
     업무 화면은 «안 움직이는 게 기본». 움직임은 상태가 바뀐 걸 알릴 때만. */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);    /* 나타남·사라짐·누름 — 기본 */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);   /* 화면 안에서 자리 이동 */
  --dur-press: 140ms;   /* 단추 누름·체크 */
  --dur-pop:   180ms;   /* 툴팁·드롭다운·토스트 */
  --dur-panel: 240ms;   /* 모달·서랍 — 이보다 길게 쓰지 않는다 */
}

body.density-comfortable { --card-pad: 24px; --row-py: 16px; --stack-gap: 22px; }
body.density-compact     { --card-pad: 16px; --row-py:  9px; --stack-gap: 14px; }

/* ---- 골격 ---------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0; font-weight: 700; line-height: 1.25;
  color: var(--ink); letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-700); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary); color: var(--on-primary); }   /* 브라우저 기본 파랑 대신 우리 색 */

/* ---- 움직임 기본 (MOTION_AND_TASTE.md §2) --------------------------- */
button, .btn { transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-press) var(--ease-out); }
button:not([disabled]):active, .btn:not(.is-disabled):active { transform: scale(0.97); }   /* 누른 느낌 — 0.95~0.98 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important;
                           transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---- 유틸 (숫자 정렬 — COMPONENTS.md §0-3) ------------------------- */
.num     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; text-align: right; }
.t-right { text-align: right; }
.t-center{ text-align: center; }
.muted   { color: var(--muted); }
.faint   { color: var(--faint); }
.nowrap  { white-space: nowrap; }
.ellip   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 다섯 모습 (COMPONENTS.md §0-1) — 부품마다 다시 만들지 않는다 --- */
.state-skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-shift 1.4s ease infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  min-height: 1em;
}
@keyframes skeleton-shift { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .state-skeleton { animation: none; } }

.state-empty, .state-error, .state-denied {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4); text-align: center;
  font-size: var(--fs-sm);
}
.state-empty  { color: var(--faint); }
.state-error  { color: var(--danger); border: 1px solid var(--danger); background: var(--danger-soft); border-radius: var(--r); }
.state-denied { color: var(--muted);  border: 1px dashed var(--line);  background: var(--surface-2);  border-radius: var(--r); }
.state-empty .t, .state-error .t, .state-denied .t { font-weight: 600; font-size: var(--fs-base); color: var(--ink-2); }
.state-error .t { color: var(--danger); }

/* 비활성 — 왜 못 누르는지 title 을 반드시 함께 준다 */
[disabled], .is-disabled {
  color: var(--faint); cursor: not-allowed; opacity: .75;
}
