/* StockSync 디자인 시스템
   - 라이트: '정밀 핀테크' 결 — 웜 오프화이트 바탕, 잉크 네이비 글자, 1px 헤어라인, 상단에만 이리데센트 파스텔 띠.
   - 다크: '발광 다크 벤토' 결 — 딥 차콜, 상단이 밝은 1px 발광 보더, 위쪽에만 자홍·인디고 글로우.
   - 색·크기·간격은 모두 토큰(:root)으로 관리한다. 컨트롤 높이는 40px(폰 44px)로 통일.
   - 라이트/다크는 기기 설정을 따른다. 인쇄(라벨)는 항상 흰 바탕·검은 글씨.
   - 인라인 style 을 쓰지 않는다(CSP). 간격·폭은 아래 보조 클래스를 쓴다. */
@font-face {
  font-family: "Pretendard Variable"; font-weight: 45 930; font-style: normal; font-display: swap;
  src: url("/static/fonts/PretendardVariable.woff2?v=2") format("woff2-variations");
}
:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #f1efeb;
  --ink: #1a2233;
  --ink-2: #384255;
  --muted: #5b6472;
  --line: #e4e2dd;
  --line-strong: #d2cfc8;
  --line-top: #e4e2dd;
  --pri: #4f46e5;
  --pri-text: #4338ca;
  --pri-hover: #4338ca;
  --pri-ink: #ffffff;
  --pri-soft: #eeeefc;
  --pri-btn: #4f46e5;
  --pri-btn-hover: #4338ca;
  --ok: #0c7a53;
  --ok-soft: #e3f5ec;
  --warn: #8f5400;
  --warn-soft: #fff1d6;
  --err: #c8302a;
  --err-soft: #fdebe8;
  --ring: rgba(79, 70, 229, .30);
  --tile: #ffffff;
  --side-bg: transparent;
  --field: #ffffff;
  --hero: linear-gradient(105deg, #fef6e4 0%, #fcd9c6 26%, #e6d6f5 58%, #cdd3f5 82%, #c3c9f0 100%);
  --hero-opacity: .85;
  --rim: none;
  --shadow-sm: 0 1px 2px rgba(26, 34, 51, .05);
  --shadow: 0 1px 2px rgba(26, 34, 51, .06), 0 4px 12px rgba(26, 34, 51, .05);
  --shadow-lg: 0 16px 40px rgba(26, 34, 51, .16), 0 2px 6px rgba(26, 34, 51, .06);
  --btn-shadow: 0 1px 2px rgba(79, 70, 229, .35), inset 0 1px 0 rgba(255, 255, 255, .18);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --h: 40px;
  --gap: 16px;
  --side-w: 248px;
  --tabbar-h: 60px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: light;
}
/* 다크 테마: 화면 테마를 '다크'로 직접 고르면 data-theme=dark, '시스템'이면 기기 설정을 따른다 */
:root[data-theme="dark"] {
  --bg: #08080b;
  --surface: #101015;
  --surface-2: #17171e;
  --ink: #f4f4f6;
  --ink-2: #d2d2d9;
  --muted: #a0a0aa;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .17);
  --line-top: rgba(255, 255, 255, .20);
  --pri: #6366f1;
  --pri-text: #a5a8fb;
  --pri-hover: #8b8ef7;
  --pri-soft: rgba(99, 102, 241, .16);
  --pri-btn: linear-gradient(135deg, #5457e8 0%, #a21caf 100%);
  --pri-btn-hover: linear-gradient(135deg, #6568f0 0%, #b52bc4 100%);
  --ok: #4ade9c;
  --ok-soft: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --err: #fb7f7f;
  --err-soft: rgba(248, 113, 113, .13);
  --ring: rgba(129, 140, 248, .5);
  --tile: linear-gradient(180deg, #16161d 0%, #0e0e12 100%);
  --side-bg: #0a0a0e;
  --field: #0b0b0f;
  --hero: radial-gradient(46% 100% at 28% 0%, rgba(192, 38, 211, .20) 0%, transparent 70%), radial-gradient(44% 90% at 74% 0%, rgba(99, 102, 241, .22) 0%, transparent 70%);
  --hero-opacity: 1;
  --rim: inset 0 1px 0 rgba(255, 255, 255, .05);
  --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, .04);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 8px 24px rgba(0, 0, 0, .40);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06);
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #08080b;
    --surface: #101015;
    --surface-2: #17171e;
    --ink: #f4f4f6;
    --ink-2: #d2d2d9;
    --muted: #a0a0aa;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .17);
    --line-top: rgba(255, 255, 255, .20);
    --pri: #6366f1;
    --pri-text: #a5a8fb;
    --pri-hover: #8b8ef7;
    --pri-soft: rgba(99, 102, 241, .16);
    --pri-btn: linear-gradient(135deg, #5457e8 0%, #a21caf 100%);
    --pri-btn-hover: linear-gradient(135deg, #6568f0 0%, #b52bc4 100%);
    --ok: #4ade9c;
    --ok-soft: rgba(52, 211, 153, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .12);
    --err: #fb7f7f;
    --err-soft: rgba(248, 113, 113, .13);
    --ring: rgba(129, 140, 248, .5);
    --tile: linear-gradient(180deg, #16161d 0%, #0e0e12 100%);
    --side-bg: #0a0a0e;
    --field: #0b0b0f;
    --hero: radial-gradient(46% 100% at 28% 0%, rgba(192, 38, 211, .20) 0%, transparent 70%), radial-gradient(44% 90% at 74% 0%, rgba(99, 102, 241, .22) 0%, transparent 70%);
    --hero-opacity: 1;
    --rim: inset 0 1px 0 rgba(255, 255, 255, .05);
    --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, .04);
    --shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 8px 24px rgba(0, 0, 0, .40);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06);
    --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--pri-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: clamp(25px, 2.6vw, 32px); line-height: 1.2; font-weight: 650; letter-spacing: -.035em; margin: 0; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 650; letter-spacing: -.02em; margin: 36px 0 12px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
td, th, .stat .value, dd, .chip, .sel-count, .count { font-variant-numeric: tabular-nums; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--line); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; }

/* ---------- 앱 틀 ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side-bg); border-right: 1px solid var(--line);
  padding: 20px 14px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; position: relative;
  background: linear-gradient(140deg, #6d70f5 0%, #4338ca 55%, #8a1fa0 130%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), inset 0 -1px 0 rgba(0, 0, 0, .18), 0 6px 16px rgba(79, 70, 229, .32);
}
.logo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(160deg, rgba(255, 255, 255, .22), transparent 45%); pointer-events: none; }
.logo .ic { width: 22px; height: 22px; }
.brand-name { display: block; font-weight: 750; font-size: 17px; letter-spacing: -.035em; line-height: 1.2; }
.brand-sub { display: block; font-size: 12px; color: var(--muted); }
.side-nav { flex: 1; }
.nav-group { font-size: 11px; font-weight: 650; letter-spacing: .08em; color: var(--muted); padding: 20px 12px 6px; text-transform: uppercase; }
.side a, .menu-pop a {
  display: flex; align-items: center; gap: 12px; color: var(--ink-2); padding: 0 12px; min-height: 40px;
  border-radius: 10px; font-weight: 500; position: relative; border: 1px solid transparent;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.side a .ic { color: var(--muted); }
.side a:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.side a.active { background: var(--surface); color: var(--ink); font-weight: 650; border-color: var(--line); box-shadow: var(--shadow-sm); }
.side a.active .ic { color: var(--pri); }
.side a.active::before { content: ""; position: absolute; left: -14px; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pri); }
.side-user { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: none; flex-direction: column; gap: 4px; }
.who { display: flex; align-items: center; gap: 10px; padding: 4px 8px 8px; }
.who strong, .uname strong { display: block; line-height: 1.25; }
.role { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--pri-soft); color: var(--pri-text); font-weight: 700; flex: none; border: 1px solid var(--line); }
.side-user form, .menu-pop form { margin: 0; }
.side-user button.ghost, .menu-pop button.ghost { width: 100%; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: 10px; font-weight: 500; color: var(--ink-2); }

.main-wrap { min-width: 0; display: flex; flex-direction: column; position: relative; isolation: isolate; }
/* 위쪽에만 깔리는 분위기 띠: 라이트=이리데센트 파스텔, 다크=자홍·인디고 글로우. 본문 영역까지 내려오지 않는다. */
.main-wrap::before, body:has(> main.auth)::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 340px; z-index: -1; pointer-events: none;
  background: var(--hero); opacity: var(--hero-opacity);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 35%, transparent 100%); mask-image: linear-gradient(180deg, #000 0%, #000 35%, transparent 100%);
}
body:has(> main.auth) { position: relative; min-height: 100vh; overflow-x: hidden; }
body:has(> main.auth)::before { height: 52vh; }
.topbar {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 12px 32px; min-height: 64px;
  background: transparent;
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent;
}
.usermenu { position: relative; }
.usermenu > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease);
}
.usermenu > summary:hover { border-color: var(--line-strong); }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu .avatar { width: 30px; height: 30px; font-size: 14px; }
.uname { font-size: 13px; text-align: left; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: 6px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.main { padding: 8px 32px 72px; width: 100%; max-width: 1240px; margin: 0 auto; position: relative; }
.auth { width: min(420px, 100%); margin: 0 auto; padding: 12vh 16px 40px; position: relative; }
.auth .card { padding: 32px 28px 28px; box-shadow: var(--shadow-lg); border-radius: 20px; backdrop-filter: blur(14px); }
.auth h1 { font-size: 28px; }
.auth-logo { width: 52px; height: 52px; border-radius: 15px; margin-bottom: 20px; }
.auth-logo .ic { width: 26px; height: 26px; }
.auth form label:first-child { margin-top: 18px; }

/* ---------- 페이지 머리말 · 도구줄 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-head .lead, .lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.page-head .actions { flex: 0 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--tile); border: 1px solid var(--line); border-top-color: var(--line-top); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: var(--gap); box-shadow: var(--shadow-sm); }
.toolbar .grow { flex: 3 1 280px; min-width: 0; }
.toolbar .field { flex: 1 1 160px; min-width: 0; }
.toolbar .fit { flex: 0 0 auto; }
.toolbar label { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; align-items: end; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid label { margin-top: 0; }

/* ---------- 구성 요소 ---------- */
.card { background: var(--tile); border: 1px solid var(--line); border-top-color: var(--line-top); border-radius: var(--r-lg); padding: 22px; margin-bottom: var(--gap); box-shadow: var(--shadow-sm); }
.card > h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 0 0 28px; }
.stat {
  --mx: 50%; --my: 0%;
  background: var(--tile); border: 1px solid var(--line); border-top-color: var(--line-top); border-radius: var(--r-lg); padding: 18px 20px 16px; display: flex; flex-direction: column; color: inherit;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.stat::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s; background: radial-gradient(260px circle at var(--mx) var(--my), rgba(129, 140, 248, .13), transparent 70%); }
a.stat:hover { border-color: var(--pri); border-top-color: var(--pri); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-2px); }
a.stat:hover::after { opacity: 1; }
.stat .label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .label .ic { width: 16px; height: 16px; stroke-width: 1.7; opacity: .9; }
.stat .value { font-size: 34px; font-weight: 600; line-height: 1.15; letter-spacing: -.04em; margin-top: 10px; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat.bad { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 28%, transparent); }
.stat.bad .value, .stat.bad .label { color: var(--err); }
.stat.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.stat.warn .value, .stat.warn .label { color: var(--warn); }

/* 대시보드 벤토: 큰 타일 하나 + 작은 타일들 (크기를 섞어 위계를 만든다) */
.cards.bento { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: dense; }
.stat.feature { grid-column: span 2; grid-row: span 2; padding: 24px 26px 22px; --accent-glow: rgba(99, 102, 241, .16); }
.stat.feature::before { content: ""; position: absolute; width: 360px; height: 360px; right: -140px; top: -170px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, var(--accent-glow) 0%, transparent 68%); }
.stat.feature .value { font-size: clamp(48px, 5.4vw, 68px); font-weight: 600; letter-spacing: -.05em; line-height: 1; margin-top: 18px; }
.stat.feature .sub { font-size: 13.5px; }
.health { margin-top: auto; padding-top: 22px; }
.health svg { display: block; width: 100%; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.health .seg-ok { fill: var(--ok); } .health .seg-low { fill: var(--warn); } .health .seg-out { fill: var(--err); }
.health ul { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--muted); }
.health li { display: inline-flex; align-items: center; gap: 7px; }
.health li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.health li.low::before { background: var(--warn); } .health li.out::before { background: var(--err); }
.health li b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.flash { padding: 12px 16px; border-radius: var(--r); margin: 12px 0 16px; font-weight: 600; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); }
.notice { background: var(--warn-soft); color: var(--warn); padding: 12px 16px; border-radius: var(--r); font-size: 14px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap; line-height: 1.6; border: 1px solid var(--line);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.low { background: var(--warn-soft); color: var(--warn); }
.chip.out, .chip.err { background: var(--err-soft); color: var(--err); }
.chip.pri { background: var(--pri-soft); color: var(--pri-text); }
.chip.ok::before, .chip.low::before, .chip.out::before, .chip.err::before, .chip.pri::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 버튼 */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); padding: 0 16px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s, box-shadow .15s;
}
.btn:hover, button:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line-strong) 70%, var(--ink)); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px) scale(.99); }
.btn.pri, button.pri { background: var(--pri-btn); border-color: transparent; color: var(--pri-ink); box-shadow: var(--btn-shadow); }
.btn.pri:hover, button.pri:hover { background: var(--pri-btn-hover); border-color: transparent; }
.btn.danger, button.danger { color: var(--err); }
.btn.danger:hover, button.danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn.small, button.small { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); }
.linkbtn { background: none; border: none; box-shadow: none; color: var(--pri-text); padding: 0; min-height: 0; font-weight: 500; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* 입력 */
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 14px 0 6px; letter-spacing: -.005em; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: var(--h); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; background: var(--field); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: color-mix(in srgb, var(--line-strong) 70%, var(--ink)); }
input[type=file] { font: inherit; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; margin-right: 12px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a90a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--ring); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--pri); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .fit { flex: 0 0 auto; }
.row label { margin-top: 0; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.checks label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin-right: 16px; }
.checks input { width: auto; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; background: var(--tile); border: 1px solid var(--line); border-top-color: var(--line-top); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: color-mix(in srgb, var(--surface-2) 70%, transparent); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; letter-spacing: .01em; padding-top: 11px; padding-bottom: 11px; }
tbody tr:hover td, table tr:not(.thead):hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
td a { font-weight: 600; color: var(--ink); }
td a:hover { color: var(--pri-text); }
tr.risk td { background: var(--warn-soft) !important; }
.pager-jump { display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; }
.pager-jump label { margin: 0; }
.pager-jump input { width: 96px; }
.pager { display: flex; gap: 6px; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2); font-weight: 600; transition: border-color .15s var(--ease); }
.pager a:hover { border-color: var(--line-strong); }
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager span.cur { background: var(--pri-btn); color: #fff; border-color: transparent; box-shadow: var(--btn-shadow); }
.pager span.gap { border: none; background: none; min-width: 0; padding: 0 4px; }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 스캔 화면 ---------- */
.scanbar {
  --accent: var(--pri);
  border: 1.5px solid var(--accent); border-radius: 20px; background: var(--tile); padding: 20px 22px; margin: 0 0 22px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 11%, transparent), var(--rim);
}
.scanbar.in { --accent: var(--ok); }
.scanbar.out { --accent: #e08a00; }
.scanbar label { margin-top: 0; }
.scanbar input[type=text] { font-size: 28px; min-height: 60px; padding: 10px 16px; letter-spacing: .06em; font-variant-numeric: tabular-nums; border-radius: 12px; }
.scanbar .hint { margin-top: 10px; font-size: 13px; color: var(--muted); }
.qty-input { width: 88px !important; text-align: right; }
.sticky-confirm {
  position: sticky; bottom: 0; z-index: 10; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 16px 0 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 12px 16px; box-shadow: var(--shadow-lg);
}
.sticky-confirm > strong { margin-right: auto; }
#result .report { margin-top: 12px; }
#result dl.kv { grid-template-columns: 220px 1fr; }

/* 인라인 style 을 쓰지 않기 위한 보조 클래스 (CSP: style-src 'self') */
.mt0 { margin-top: 0 !important; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt14 { margin-top: 14px; }
.mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; }
.ac { align-items: center !important; }
.mw420 { max-width: 420px; }
.mw560 { max-width: 560px; }
.mw640 { max-width: 640px; }
.wauto { width: auto; }
.w100 { width: 100%; }
.minw160 { min-width: 160px; }
.nowrap { flex-wrap: nowrap; }
.f1w { flex: 1 1 200px; width: auto; }
.f2 { flex: 2 1 240px; }
.f2s { flex: 2 1 200px; }
.f3 { flex: 3 1 260px; }
.checkline { margin: 0; display: inline-flex; gap: 8px; align-items: center; }
.helplist { margin: 0 0 10px; padding-left: 20px; color: var(--ink-2); }
.helplist li { margin-bottom: 4px; }

/* 라벨 인쇄 (화면 미리보기는 항상 흰 바탕) */
.labels { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.labels .label {
  background: #fff; color: #000; border: 1px dashed #b9bfce; border-radius: 4px; padding: 1.5mm; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.6mm;
  break-inside: avoid; page-break-inside: avoid;
}
.size-50x30 .label { width: 50mm; height: 30mm; }
.size-40x25 .label { width: 40mm; height: 25mm; }
.size-a4 .label { width: 62mm; height: 32mm; }
.label-price { font-size: 15pt; line-height: 1.1; font-weight: 800; text-align: center; color: #000; letter-spacing: -.01em; }
.label-name { font-size: 7.5pt; line-height: 1.15; font-weight: 700; max-height: 2.4em; overflow: hidden; color: #000; }
.label-opt { font-size: 6.5pt; line-height: 1.1; max-height: 1.2em; overflow: hidden; color: #000; }
.labels .label .barcode { width: 100%; height: auto; max-height: 62%; flex: 0 1 auto; }
.size-40x25 .label-name { font-size: 6.5pt; }
.label-code { font-size: 10pt; font-weight: 700; letter-spacing: .06em; color: #000; }
@media print {
  .noprint, .side, .topbar, .flash, .tabbar, .scrim { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .labels { display: block; margin: 0; }
  .labels .label { border: none; margin: 0; }
  .size-50x30 .label, .size-40x25 .label { break-after: page; page-break-after: always; }
  .labels.size-a4 { display: flex; flex-wrap: wrap; gap: 0; }
  .labels.size-a4 .label { border: 1px solid #ddd; }
  @page { margin: 0; }
}

/* 계정 관리 */
.temp-password {
  font: 700 28px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em;
  background: #14161f; color: #fff; padding: 18px 20px; border-radius: var(--r); text-align: center;
  margin: 14px 0; user-select: all; overflow-wrap: anywhere;
}
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { flex: 1 1 100%; }
.user-actions { align-items: flex-start; }
.danger-zone[open] > summary { margin-bottom: 4px; }
.user-card .small.muted { margin-top: 2px; }

/* ===================== 반응형 =====================
   >900px  : 왼쪽 메뉴 + 본문(사용자 메뉴는 오른쪽 위)
   ≤900px  : 메뉴는 서랍, 위에는 얇은 상단 바, 아래에는 빠른 이동 탭바
   ≤640px  : 목록 표는 카드로, 입력·버튼은 손가락 크기(44px), 폼은 세로로 쌓기
   인쇄(라벨)에는 모바일 규칙을 적용하지 않도록 screen 조건을 붙인다. */
.menu-btn, .scrim, .mbrand, .spacer, .tabbar { display: none; }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
@media screen and (min-width: 1500px) { .main { max-width: 1360px; } }

@media screen and (max-width: 900px) {
  .shell { display: block; }
  .side {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); height: auto; z-index: 50;
    transform: translateX(-100%); visibility: hidden; background: var(--drawer-bg, var(--surface));
    transition: transform .22s ease, visibility 0s linear .22s;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .nav-toggle:checked ~ .side { transform: none; visibility: visible; transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 14, 30, .5); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-toggle:checked ~ .scrim { opacity: 1; pointer-events: auto; }
  .nav-toggle:focus-visible ~ .main-wrap .menu-btn { outline: 3px solid var(--ring); outline-offset: 2px; }
  .side a { min-height: 46px; }
  .side-user { display: flex; position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--surface); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 14px; gap: 10px; justify-content: flex-start; min-height: 56px; border-bottom-color: var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); }
  .topbar .userinfo { display: none; }
  .menu-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; background: var(--surface); cursor: pointer; }
  .menu-text { display: none; }
  .mbrand { display: inline; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
  .spacer { display: block; flex: 1; }
  .main { padding: 8px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .auth { padding-top: 7vh; }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar .tab-more {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600;
    color: var(--muted); text-decoration: none; margin: 0; cursor: pointer; min-width: 0;
  }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--pri-text); }
  .tabbar a.active .ic { stroke-width: 2.2; }
  .sticky-confirm { bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)); }
}

@media screen and (max-width: 640px) {
  :root { --h: 44px; }
  h1 { font-size: 21px; }
  h2 { font-size: 16px; margin-top: 26px; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 calc(50% - 4px); }
  .page-head .actions > .pri { order: -1; flex-basis: 100%; }

  /* 입력·버튼: 손가락으로 누르기 쉬운 크기 (16px 이상이면 iOS 가 확대하지 않는다) */
  input[type=text], input[type=password], input[type=number], input[type=search], select, textarea { font-size: 16px; }
  .btn.small, button.small { min-height: 40px; padding: 0 14px; }
  .qty-input { width: 76px !important; }
  input[type=checkbox] { width: 22px; height: 22px; }
  .checks label { margin: 6px 16px 6px 0; }

  /* 폼은 세로로 쌓는다 */
  .row > * { flex: 1 1 100%; }
  .row > .fit { flex: 1 1 auto; }
  .row.ac > .fit.actions { flex: 1 1 100%; }
  .row.nowrap > * { flex: 1 1 auto; min-width: 0; }
  .toolbar { padding: 12px; gap: 10px; }
  .toolbar .grow, .toolbar .field { flex: 1 1 100%; }
  .toolbar .fit { flex: 1 1 100%; }
  .toolbar .fit button { width: 100%; }
  .actions { width: 100%; }
  .actions .btn, .actions button { flex: 1 1 auto; }
  .card { padding: 16px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 26px; }
  .pager a, .pager span { height: 40px; min-width: 40px; }
  dl.kv, #result dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dt { margin-top: 10px; font-size: 13px; }
  .scanbar { padding: 14px; }
  .scanbar input[type=text] { font-size: 24px; min-height: 56px; }
  .auth .card { padding: 22px 18px; }
  .temp-password { font-size: 22px; padding: 14px; }
  .inline-details { width: 100%; }
  .inline-details > summary { display: flex; width: 100%; }

  /* 스캔 표는 핵심 열만 */
  .hide-sm { display: none !important; }
  table.compact { min-width: 0; }
  table.stack.compact td.acts { border-top: 0; margin-top: 0; padding-top: 4px; }
  table.stack.compact .actions { flex-wrap: nowrap; align-items: center; }
  th, td { padding: 10px; }

  /* 목록 표 → 카드 (class="stack", 각 칸에 data-label) */
  .table-wrap:has(> table.stack) { border: none; background: none; overflow: visible; box-shadow: none; }
  table.stack, table.stack tbody { display: block; min-width: 0; }
  table.stack tr.thead { display: none; }
  table.stack tr {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; background: var(--tile); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
  }
  table.stack tr.risk { background: var(--warn-soft); }
  table.stack td { display: block; min-width: 0; padding: 5px 0; border: 0; text-align: left; overflow-wrap: anywhere; background: none !important; }
  table.stack td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.3; }
  table.stack td.title { grid-column: 1 / -1; font-weight: 650; font-size: 15px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  table.stack td.title::before { display: none; }
  table.stack td.acts { grid-column: 1 / -1; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
  table.stack td.acts::before { display: none; }
  table.stack td.acts:empty { display: none; }
  table.stack .num { text-align: left; }
  table:not(.stack):not(.compact) { min-width: 600px; }

  /* 확정 바: 엄지로 닿는 아래쪽에 붙여 둔다 */
  .sticky-confirm > * { flex: 1 1 100%; }
  .sticky-confirm > strong { flex: 1 1 auto; margin-right: 0; }
}

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

/* 테마 선택 (사용자 메뉴·서랍·로그인) */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { min-height: 32px; padding: 0 12px; border: 0; background: transparent; box-shadow: none; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button:hover { background: transparent; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.theme-row { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 8px 10px; }
.theme-row > .small { white-space: nowrap; font-weight: 600; }
.theme-row .seg { display: flex; }
.theme-row .seg button { flex: 1 1 0; padding: 0 8px; white-space: nowrap; }
.theme-login { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.menu-pop .theme-row { border-bottom: 1px solid var(--line); margin-bottom: 6px; padding-bottom: 10px; }
.side-user .theme-row { padding-left: 8px; }
@media screen and (max-width: 640px) { .seg button { min-height: 38px; } }

/* 주문 일괄 출고확정 */
td.sel, th.selcol { width: 44px; padding-right: 0; }
td.sel input, th.selcol input { margin: 0; }
.bulkbar form { margin: 0; }
.bulkbar { justify-content: space-between; }
.bulkbar .bulk-sel { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; white-space: nowrap; }
.bulkbar .bulk-sel .checkline { font-weight: 600; font-size: 13px; }
.bulkbar .count { font-variant-numeric: tabular-nums; font-weight: 700; }
@media screen and (max-width: 640px) {
  table.stack tr { position: relative; }
  table.stack td.sel { position: absolute; top: 12px; right: 12px; padding: 0; width: auto; }
  table.stack td.sel::before { display: none; }
  table.stack td.sel:empty { display: none; }
  table.stack tr:has(td.sel input) td.title { padding-right: 38px; }
  th.selcol { display: none; }
  .bulkbar { padding: 10px 12px; gap: 8px; }
  .bulkbar > form { flex: 1 1 100%; }
  .bulkbar .bulk-sel { gap: 10px; }
  .bulkbar .bulk-sel button { margin-left: auto; min-height: 40px; padding: 0 14px; }
  .bulkbar > form:last-child button { width: 100%; min-height: 40px; }
}

/* 안전재고 입력 */
.inline-edit { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-edit .qty-input { width: 110px !important; text-align: left; }
.help-line { font-weight: 400; margin-top: 4px; }
.bulk-safety > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.bulk-safety > summary::-webkit-details-marker { display: none; }
.bulk-safety > summary::before { content: "＋"; color: var(--pri-text); font-weight: 700; margin-right: 2px; }
.bulk-safety[open] > summary::before { content: "－"; }

/* 상품 목록 선택 바 */
.bulk-multi { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0; width: 100%; }
.bulk-multi .checkline { font-weight: 600; font-size: 13px; }
.bulk-multi .sel-count { white-space: nowrap; }
.bulk-multi .inline-edit .qty-input { width: 110px !important; text-align: left; }
@media screen and (max-width: 640px) {
  .bulk-multi { gap: 8px; }
  .bulk-multi > button { flex: 1 1 calc(50% - 4px); min-height: 40px; }
  .bulk-multi .inline-edit { flex: 1 1 100%; }
  .bulk-multi .inline-edit .qty-input { flex: 1 1 auto; }
  .bulk-multi .inline-edit button { flex: 1 1 auto; }
}

/* 사용 중지 상품: 목록에서 흐리게, 상태는 회색 칩 */
.chip.stopped { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }
tr.inactive td { opacity: .55; }
tr.inactive td.sel, tr.inactive td.sel * { opacity: 1; }

/* 프린터 직접 출력 */
.printer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.printer-card summary { cursor: pointer; }
.pr-msg { margin-top: 12px; padding: 10px 14px; border-radius: var(--r-sm); font-weight: 600; font-size: 14px; }
.pr-msg.ok { background: var(--ok-soft); color: var(--ok); }
.pr-msg.err { background: var(--err-soft); color: var(--err); }
.pr-msg[hidden] { display: none; }
.printer-card [data-mode][hidden] { display: none; }

/* 로고는 대시보드로 가는 링크 (메뉴 항목 스타일과 분리) */
.side a.brand { padding: 4px 8px 20px; min-height: 0; gap: 12px; color: var(--ink); border-radius: 0; font-weight: inherit; }
.side a.brand:hover { background: none; color: var(--ink); }
.side a.brand:hover .logo { filter: brightness(1.08); }
a.mbrand { color: var(--ink); text-decoration: none; }
a.mbrand:hover { text-decoration: none; }
.side a.brand .logo .ic { color: #fff; }

/* 상품 삭제 영역 */
.danger-card > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; color: var(--err); }
.danger-card > summary::-webkit-details-marker { display: none; }
.danger-card > summary::before { content: "＋"; font-weight: 700; margin-right: 2px; }
.danger-card[open] > summary::before { content: "－"; }

.pr-diag { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.pr-diag li { padding: 8px 12px; border-radius: var(--r-sm); line-height: 1.5; }
.pr-diag li.ok { background: var(--ok-soft); color: var(--ok); }
.pr-diag li.err { background: var(--err-soft); color: var(--err); }
.pr-diag[hidden] { display: none; }

/* ===================== 마감: 움직임·반응형 보정 ===================== */
@media screen and (max-width: 900px) {
  .cards.bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat.feature { grid-row: span 1; }
  .side a.active::before { left: -14px; }
  .main-wrap::before { height: 260px; }
}
@media screen and (max-width: 640px) {
  .cards { gap: 10px; }
  .stat.feature { padding: 20px 18px 18px; }
  .stat.feature .value { font-size: 52px; }
  .stat .value { font-size: 28px; margin-top: 8px; }
  .auth .card { padding: 26px 20px 22px; }
}
/* 화면이 열릴 때 위에서부터 차례로 나타난다 (1회, 짧게) */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media screen and (prefers-reduced-motion: no-preference) {
  .main > .page-head, .main > .toolbar, .main > .notice, .main > .card, .main > .cards > *, .main > .table-wrap, .main > .scanbar, .auth > .card {
    animation: rise .38s var(--ease) both;
  }
  .main > .cards > :nth-child(2) { animation-delay: 40ms; } .main > .cards > :nth-child(3) { animation-delay: 80ms; }
  .main > .cards > :nth-child(4) { animation-delay: 120ms; } .main > .cards > :nth-child(5) { animation-delay: 160ms; }
  .main > .cards > :nth-child(n+6) { animation-delay: 200ms; }
  .main > .page-head + * { animation-delay: 50ms; }
}
@media print { .main-wrap::before { display: none; } }

/* 모바일 서랍: 계정 영역은 한 줄로 접어 두고, 눌러야 테마·비밀번호·로그아웃이 펼쳐진다 (메뉴 영역을 넓게) */
.drawer-user > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.drawer-user > summary::-webkit-details-marker { display: none; }
.drawer-user > summary:hover { background: var(--surface-2); }
.drawer-user > summary .uname { flex: 1; min-width: 0; font-size: 14px; }
.drawer-user .chev { transform: rotate(180deg); color: var(--muted); transition: transform .18s var(--ease); }
.drawer-user[open] .chev { transform: none; }
.drawer-user-body { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.drawer-user-body form { margin: 0; }
@media screen and (max-width: 900px) {
  .side-user { margin-top: 8px; padding-top: 8px; gap: 0; }
  .side-user .theme-row { padding: 4px 8px 8px; }
}

.bulk-delete { border-top: 1px solid var(--line); padding-top: 14px; }
.danger-text { color: var(--err); }

/* 모든 입력·버튼은 본문과 같은 글꼴(Pretendard)을 쓴다 */
button, input, select, textarea, optgroup { font-family: inherit; }
