/* ══════════════════════════════════════════════════════════════
   YJBN Work UI — 공통 디자인 시스템 v1 (2026-11-06)
   허브(work.yjbn.kr)와 재고현황이 같은 파일을 쓴다. 수정 시 두 곳에 복사.
   원칙: 빠른 판독 · 할 일 먼저 · 숫자마다 기준 시각 · 모바일 1열
   ══════════════════════════════════════════════════════════════ */

:root {
  /* ── Hydrangea 팔레트 (2026-11-06 사용자 지정: #FF8DA1 · #FFC2BA · #FF9CE9 · #AD56C4) ── */
  /* 바탕·면: 블러시 바탕 + 흰 카드 + 연분홍 선 */
  --bg: #fff8f9;
  --surface: #ffffff;
  --surface-2: #fff1f3;   /* 카드 안 보조 타일 — 연한 블러시 */
  --line: #f6e2e8;
  --line-strong: #ebc8d3;
  /* 글자: 따뜻한 자두빛 먹색 */
  --ink: #2e2330;
  --ink-2: #4f4053;
  --muted: #86738a;
  --faint: #b6a3b9;
  /* 포인트: 수국 보라 (#AD56C4) — 흰 글자 버튼에 쓸 수 있는 유일한 진한 색 */
  --primary: #ad56c4;
  --primary-ink: #ffffff;
  --primary-soft: #f6e8fa;
  --focus: #c47ad8;
  /* 상태 (파스텔 바탕 + 읽히는 글자색) */
  --good: #2f8f5f;  --good-soft: #e5f6ec;
  --warn: #c27215;  --warn-soft: #fff0d9;
  --danger: #d1493f; --danger-soft: #ffe7e3;
  --neutral-soft: #f9eef1;
  /* 시스템 구분색 (아이콘 칩 전용) — Hydrangea 4색. 밝은 3색은 진한 아이콘, 보라만 흰 아이콘 */
  --sys-stock: #ff8da1;   --sys-stock-ink: #5c1f33;   /* 핑크 */
  --sys-buyer: #ad56c4;   --sys-buyer-ink: #ffffff;   /* 보라 */
  --sys-label: #ffc2ba;   --sys-label-ink: #6a2f2a;   /* 피치 */
  --sys-ads: #ff9ce9;     --sys-ads-ink: #5e1d55;     /* 오키드 */
  /* 바탕 은은한 빛 (핑크·오키드) */
  --glow: radial-gradient(1100px 420px at 0% -8%, #ffe2e8 0%, rgba(255, 226, 232, 0) 62%),
          radial-gradient(900px 380px at 100% -4%, #fbe3f7 0%, rgba(251, 227, 247, 0) 58%);
  /* 형태 */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(110, 40, 90, .05), 0 2px 8px rgba(110, 40, 90, .05);
  --shadow-lg: 0 10px 28px rgba(110, 40, 90, .12);
  --gutter: 16px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  /* 서체 */
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --surface-2: #1d222c;
    --line: #2a303c; --line-strong: #394150;
    --ink: #eef1f6; --ink-2: #cfd5df; --muted: #98a2b3; --faint: #6b7586;
    --primary: #7fa3e6; --primary-ink: #0f1218; --primary-soft: #1d2a42; --focus: #8fb0f0;
    --good: #4cc38a; --good-soft: #15291f;
    --warn: #f0a457; --warn-soft: #2e2214;
    --danger: #f17c7f; --danger-soft: #331a1c;
    --neutral-soft: #222833; --glow: none;
    --shadow: none; --shadow-lg: 0 8px 24px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --surface-2: #1d222c;
  --line: #2a303c; --line-strong: #394150;
  --ink: #eef1f6; --ink-2: #cfd5df; --muted: #98a2b3; --faint: #6b7586;
  --primary: #7fa3e6; --primary-ink: #0f1218; --primary-soft: #1d2a42; --focus: #8fb0f0;
  --good: #4cc38a; --good-soft: #15291f;
  --warn: #f0a457; --warn-soft: #2e2214;
  --danger: #f17c7f; --danger-soft: #331a1c;
  --neutral-soft: #222833; --glow: none;
  --shadow: none; --shadow-lg: 0 8px 24px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* ── 기본 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--glow), var(--bg); background-repeat: no-repeat; background-color: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── 상단 바 ──────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
.topbar::before { /* blur 는 ::before 에 — fixed 자손 가둠 방지 */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px); backdrop-filter: saturate(160%) blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topnav { display: flex; gap: 2px; }
.topnav a {
  padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.topnav a:hover { background: var(--neutral-soft); }
.topnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }

/* ── 레이아웃 ─────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 20px var(--gutter) 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.section-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-2); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page { padding-top: 14px; padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 20px; }
  .topnav { display: none; }
}

/* ── 카드 ─────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card-link { display: block; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.card-link:active { transform: scale(.995); }

/* ── 버튼 ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--neutral-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 입력 ─────────────────────────────────────────── */
.input, .select {
  min-height: 42px; width: 100%; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.search { position: relative; }
.search .input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }

/* ── 칩·배지 ──────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip .count { font-weight: 700; opacity: .75; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ── 지표 타일 ────────────────────────────────────── */
.metric-value { font-size: 30px; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-unit { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.metric-label { font-size: 13px; color: var(--muted); font-weight: 550; }
.tone-good { color: var(--good); }
.tone-warn { color: var(--warn); }
.tone-danger { color: var(--danger); }
.asof { font-size: 12px; color: var(--faint); display: inline-flex; align-items: center; gap: 5px; }
.asof.stale { color: var(--warn); }

/* ── 시스템 아이콘 칩 ─────────────────────────────── */
.sys-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  color: #fff;
}
.sys-icon svg { width: 20px; height: 20px; }
.sys-stock { background: var(--sys-stock); color: var(--sys-stock-ink, #fff); }
.sys-buyer { background: var(--sys-buyer); color: var(--sys-buyer-ink, #fff); }
.sys-label { background: var(--sys-label); color: var(--sys-label-ink, #fff); }
.sys-ads { background: var(--sys-ads); color: var(--sys-ads-ink, #fff); }

/* ── 표 ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface-2);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .r { text-align: right; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }

/* ── 리스트 (모바일 카드형) ───────────────────────── */
/* minmax(0,1fr): 긴 품목명·규격이 grid 칸을 늘려 화면을 옆으로 밀지 않게 (2026-11-06 실데이터 이슈) */
.list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 하단 탭 (모바일) ─────────────────────────────── */
.tabbar { display: none; }
@media (max-width: 640px) {
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    display: grid; place-items: center; align-content: center; gap: 3px; border: 0; background: none;
    font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--primary); }
}

/* ── 시트 (모바일 하단 / PC 우측 패널) ────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(70, 45, 30, .32); z-index: 60; }
.sheet {
  position: fixed; z-index: 61; background: var(--surface); box-shadow: var(--shadow-lg);
  top: 0; right: 0; bottom: 0; width: min(440px, 100%); overflow-y: auto; padding: 20px;
}
@media (max-width: 640px) {
  .sheet { top: auto; left: 0; width: 100%; max-height: 86vh; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-title { margin: 0; font-size: 18px; font-weight: 750; }

/* ── 상태 표시 ────────────────────────────────────── */
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--neutral-soft), var(--surface-2), var(--neutral-soft)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.notice-bar {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--primary-soft); color: var(--ink-2); font-size: 14px;
}
.notice-bar.warn { background: var(--warn-soft); }
.notice-bar.danger { background: var(--danger-soft); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #3a2638; color: #fff8f9; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 80;
  box-shadow: var(--shadow-lg);
}
@media (max-width: 640px) { .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }

/* ── 로그인 ───────────────────────────────────────── */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { margin-bottom: 22px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
