/* 매입가 계산 · 디자인 시스템 v4 (라이트 기본 + 다크) */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #fafbfc; --line: #e6e8ec; --line-2: #eff1f4;
  --text: #16181d; --text-2: #4b5563; --muted: #7b8494; --faint: #a3abb8;
  --accent: #2f6bff; --accent-2: #eaf0ff; --accent-3: #d7e2ff;
  --best: #12805c; --best-bg: #e6f6ef; --best-line: #bfe6d3;
  --warn: #b45309; --warn-bg: #fff4e5; --rule: #6d28d9; --rule-bg: #f1ecff;
  --danger: #d92d20; --danger-bg: #fee4e2; --hover: #f3f5f8; --thumb: #eef0f3;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-2: 0 12px 32px rgba(16, 24, 40, .16);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --focus: 0 0 0 3px var(--accent-3);
  --mascot-face: #ffd66b; --mascot-line: #7c4a03; --mascot-cheek: #ffb3a7;
}
[data-theme="dark"] {
  --bg: #0d1117; --panel: #151a22; --panel-2: #1a2029; --line: #262d38; --line-2: #1f2630;
  --text: #e8ebf0; --text-2: #b8c0cc; --muted: #8e98a8; --faint: #6b7584;
  --accent: #7ea2ff; --accent-2: #1c2a4d; --accent-3: #2a3f75;
  --best: #4ade80; --best-bg: #0f2a1d; --best-line: #1d4a31;
  --warn: #fbbf24; --warn-bg: #3a2a08; --rule: #c4b5fd; --rule-bg: #261f45;
  --danger: #f87171; --danger-bg: #3b1616; --hover: #1c222c; --thumb: #232a35;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 16px 40px rgba(0, 0, 0, .6);
  --mascot-face: #f7c948; --mascot-line: #3b2a06; --mascot-cheek: #f28b82;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 13.5px/1.45 "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent-3); }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
code { background: var(--hover); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; font-family: ui-monospace, Menlo, monospace; }
a { color: var(--accent); }

/* ---------- 상단 바 ---------- */
.top { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.top > .spacer { display: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 800; box-shadow: var(--shadow-1); }
.brand .ver { color: var(--faint); font-weight: 500; font-size: 11px; }
.tabs { display: flex; gap: 2px; margin-left: 6px; padding: 3px; background: var(--hover); border-radius: 10px; }
.tabs button { font: inherit; font-weight: 600; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: .12s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-1); }
.tabs button .cnt { font-weight: 500; font-size: 11px; margin-left: 5px; color: var(--faint); }
.search { display: flex; align-items: center; gap: 8px; width: 320px; height: 36px; margin: 0 auto; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); transition: .12s; }
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus); background: var(--panel); }
.search svg { flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; font: inherit; color: var(--text); outline: none; box-shadow: none; }
.search kbd { font: 10.5px/1 ui-monospace, Menlo, monospace; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; }
.switch { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; cursor: pointer; white-space: nowrap; user-select: none; }
.switch input { display: none; }
.switch .track { width: 32px; height: 18px; border-radius: 999px; background: var(--line); position: relative; transition: .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 16px; }

/* ---------- 툴바 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 9px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar .status { flex: none; }
.seg { display: flex; padding: 3px; background: var(--hover); border-radius: 9px; gap: 2px; }
.seg button { font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: .12s; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-1); }
.seg button .cnt { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.seg button .cnt:empty { display: none; }
.chips { display: flex; gap: 4px; flex: 1; min-width: 120px; overflow-x: auto; scrollbar-width: thin; padding: 2px 0; }
.chips button { font: inherit; font-size: 12.5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer; transition: .12s; white-space: nowrap; flex: none; }
.chips button:hover { border-color: var(--faint); }
.chips button.active { background: var(--accent-2); color: var(--accent); border-color: var(--accent-3); font-weight: 600; }
.chips button .n { color: var(--faint); margin-left: 4px; font-size: 11px; }
.chips button.active .n { color: inherit; opacity: .75; }
.status { color: var(--muted); font-size: 12px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 8px 20px; background: var(--accent-2); color: var(--accent); border-bottom: 1px solid var(--accent-3); font-weight: 600; }
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 20px; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); font-size: 12.5px; }
.banner[hidden] { display: none; }

/* ---------- 입력/버튼 ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; transition: .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[readonly] { background: var(--panel-2); color: var(--text-2); }
select { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8494' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.btn { font: inherit; font-weight: 600; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: .12s; box-shadow: var(--shadow-1); }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .badge-n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.btn .badge-n:empty { display: none; }
.btn svg { flex: none; }

/* ---------- 본문 / 표 ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.table-wrap { flex: 1; overflow: auto; padding: 0 20px 0; min-width: 0; }
.table-card { padding-top: 14px; }
/* 표는 열 넓이 합만큼만 (화면이 넓어도 열을 억지로 늘리지 않음). 헤더는 낮고 조용하게. */
.table-card { display: inline-block; min-width: 0; max-width: 100%; }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.grid th, .grid td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }
.grid th { position: sticky; top: 0; z-index: 4; background: var(--panel-2); background-clip: padding-box; box-shadow: inset 0 -1px 0 var(--line); text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); letter-spacing: .01em; height: 40px; padding-top: 5px; padding-bottom: 5px; }
.grid thead th:first-child { border-top-left-radius: var(--r-lg); }
.grid thead th:last-child { border-top-right-radius: var(--r-lg); }
.grid th .h { position: relative; display: block; line-height: 1.25; }
.grid th .rz { position: absolute; top: -10px; right: -12px; width: 9px; height: 40px; cursor: col-resize; z-index: 3; }
.grid th .rz::after { content: ""; position: absolute; left: 4px; top: 11px; height: 18px; width: 1px; background: var(--line); transition: .12s; }
.grid th .rz:hover::after, .grid th .rz.on::after { background: var(--accent); width: 2px; }
.grid th.v { text-align: right; color: var(--vc, var(--text)); cursor: pointer; font-size: 12px; }
.grid th.v:hover { filter: brightness(.85); }
.grid th.v small, .grid th.c small { display: block; font-weight: 500; color: var(--faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.grid th.c { text-align: center; color: var(--text-2); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--vc, var(--muted)); margin-right: 5px; vertical-align: 1px; }
.grid th.num, .grid td.num { text-align: right; }
/* content-visibility: auto 는 고정 헤더와 섞이면 헤더가 행 사이에 밀려 그려지는 문제가 있어 쓰지 않는다 (500행은 그냥 그려도 빠름) */
.grid tbody tr:hover td { background: var(--hover); }
.grid tbody tr.selected td { background: var(--accent-2); }
.grid tbody tr.hid td { opacity: .45; }
.grid tbody tr.variant td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.grid tbody tr.variant td.name { padding-left: 30px; }
.grid tbody tr.variant td.name .nm::before { content: "└"; color: var(--faint); margin-right: 6px; font-size: 11px; }
.grid tbody tr.variant.d2 td.name { padding-left: 50px; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
.grid tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-lg); }
.grid td.sel { text-align: center; padding: 0; user-select: none; }
.grid td.sel input, #selAll { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
.grid td.thumb { padding: 5px 6px 5px 10px; }
.thumb img, .thumb .noimg { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--thumb); display: block; border: 1px solid var(--line-2); }
.grid td.name { cursor: pointer; line-height: 1.3; }
.grid td.name .nm { display: block; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--text); }
.grid td.name:hover .nm { color: var(--accent); }
.grid td.name .sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; margin-right: 6px; vertical-align: 1px; line-height: 1.5; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.set { background: var(--accent-2); color: var(--accent); }
.badge.promo, .badge.promo_extra { background: var(--warn-bg); color: var(--warn); }
.badge.gone { background: var(--danger-bg); color: var(--danger); }
.grid td.comp { color: var(--muted); font-size: 12px; text-align: center; }
.grid td.pv, .grid td.pvr { color: var(--text-2); }
.grid td.pvr { font-size: 12.5px; }
.grid td.price { cursor: pointer; text-align: right; line-height: 1.25; }
.grid td.price .p { font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.grid td.price small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 2px; }
.grid td.price.best { background: var(--vc-bg, var(--best-bg)); box-shadow: inset 0 0 0 1px var(--vc-line, var(--best-line)); }
.grid td.price.best .p { color: var(--vc, var(--best)); font-weight: 700; }
.grid tbody tr:hover td.price.best { background: var(--vc-bg, var(--best-bg)); }
.grid td.price.ov { box-shadow: inset 3px 0 0 var(--warn); }
.grid td.price.rule { box-shadow: inset 3px 0 0 var(--rule); }
.grid td.price.err { color: var(--danger); }
.diff { font-size: 10.5px; font-weight: 600; padding: 0 5px; border-radius: 5px; margin-left: 3px; }
.diff.down { color: var(--best); background: var(--best-bg); }
.diff.up { color: var(--danger); background: var(--danger-bg); }
.grid td.act { text-align: center; padding: 0; }
.grid td.act button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; opacity: 0; padding: 4px 8px; border-radius: 6px; }
.grid tr:hover td.act button, .grid tr.hid td.act button { opacity: 1; }
.grid td.act button:hover { background: var(--line-2); color: var(--text); }
.empty { display: none; padding: 80px 20px; text-align: center; color: var(--muted); }
.legend { padding: 8px 20px 12px; color: var(--muted); font-size: 11.5px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.tag.best { background: var(--best-bg); color: var(--best); }
.tag.ov { background: var(--warn-bg); color: var(--warn); }
.tag.rule { background: var(--rule-bg); color: var(--rule); }

/* 두 방식 비교 (가운데 열) + 캐릭터 */
.grid td.cmp { text-align: center; padding: 4px 10px; cursor: default; }
/* 알약은 항상 칸 넓이를 꽉 채운다 (금액 길이와 무관하게 가로가 일정) */
.cmp-box { display: flex; width: 100%; box-sizing: border-box; align-items: center; gap: 8px; padding: 3px 12px 3px 7px; border-radius: 999px; background: var(--vc-bg, var(--best-bg)); color: var(--vc, var(--best)); border: 1px solid var(--vc-line, var(--best-line)); }
.cmp-box.tie { background: var(--hover); color: var(--muted); border-color: var(--line); justify-content: center; }
.cmp-box.right { flex-direction: row-reverse; padding: 3px 7px 3px 12px; }
.cmp-box .txt { display: flex; flex: 1; flex-direction: column; align-items: flex-start; min-width: 0; text-align: left; }
.cmp-box.right .txt { align-items: flex-end; text-align: right; }
.cmp-box .amt { font-weight: 700; font-size: 13px; line-height: 1.15; white-space: nowrap; }
.cmp-box .amt em { font-style: normal; font-weight: 600; font-size: 10.5px; opacity: .8; }
.cmp-box .who { display: block; font-size: 10px; font-weight: 600; opacity: .8; line-height: 1.2; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.mascot { width: 32px; height: 32px; flex: none; display: block; overflow: visible; }
.cmp-box.right .mascot { transform: scaleX(-1); }
.mascot .face { fill: var(--mascot-face); stroke: var(--mascot-line); stroke-width: 1.3; }
.mascot .sclera { fill: #fff; stroke: var(--mascot-line); stroke-width: .8; }
.mascot .eye { fill: var(--mascot-line); }
.mascot .brow { fill: none; stroke: var(--mascot-line); stroke-width: 1.6; stroke-linecap: round; }
.mascot .mouth { fill: none; stroke: var(--mascot-line); stroke-width: 1.7; stroke-linecap: round; }
.mascot .cheek { fill: var(--mascot-cheek); opacity: .85; }
.mascot .arm { fill: none; stroke: var(--mascot-line); stroke-width: 2.2; stroke-linecap: round; }
.mascot .hand { fill: var(--mascot-face); stroke: var(--mascot-line); stroke-width: 1.1; stroke-linejoin: round; }
.cmp-box.tie .mascot .face { fill: color-mix(in srgb, var(--mascot-face) 55%, var(--panel)); }
.grid tbody tr:hover .cmp-box:not(.right) .mascot { animation: nod .5s ease-in-out; }
.grid tbody tr:hover .cmp-box.right .mascot { animation: nodr .5s ease-in-out; }
@keyframes nod { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes nodr { 0%, 100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-3px); } }

/* ---------- 우측 상세 패널 ---------- */
.drawer { width: 420px; flex: none; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; padding: 16px 18px 28px; box-shadow: -8px 0 24px rgba(16, 24, 40, .04); }
.drawer[hidden] { display: none; }
.drawer .d-head { display: flex; align-items: flex-start; gap: 10px; }
.drawer .d-head h3 { margin: 0; font-size: 15px; line-height: 1.35; flex: 1; letter-spacing: -.01em; }
.drawer .x, .dlg .x { border: 0; background: none; font-size: 15px; cursor: pointer; color: var(--muted); width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; }
.drawer .x:hover, .dlg .x:hover { background: var(--hover); color: var(--text); }
.drawer .d-img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--thumb); border-radius: var(--r-md); margin: 12px 0; border: 1px solid var(--line-2); }
.drawer .d-meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px 10px; flex-wrap: wrap; }
.drawer .d-meta a { text-decoration: none; }
.drawer .d-sec { margin-top: 18px; }
.drawer .d-sec h4 { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.drawer .d-sec h4 .spacer { flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tile { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 8px 10px; }
.tile b { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.tile span { font-size: 13.5px; font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin-top: 8px; }
.kv b { color: var(--muted); font-weight: 500; }
.vcalc { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; background: var(--panel); border-left: 3px solid var(--vc, var(--line)); }
.vcalc.best { border-color: var(--vc-line, var(--best-line)); border-left-color: var(--vc, var(--best)); background: var(--vc-bg, var(--best-bg)); }
.vcalc .vc-head { display: flex; align-items: baseline; gap: 8px; }
.vcalc .vc-head b { flex: 1; color: var(--vc, var(--text)); }
.vcalc .vc-price { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.vcalc .vc-price.best { color: var(--vc, var(--best)); }
.vcalc .vc-formula { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--muted); margin-top: 6px; word-break: break-all; line-height: 1.6; }
.vcalc .vc-formula b { color: var(--text); font-weight: 600; }
.vcalc .vc-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.vcalc .vc-src { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.vcalc .vc-src.override { background: var(--warn-bg); color: var(--warn); }
.vcalc .vc-src.rule { background: var(--rule-bg); color: var(--rule); }
.vcalc .vc-src.vendor { background: var(--hover); color: var(--muted); }
.vcalc .ov-form { display: flex; gap: 6px; margin-top: 8px; }
.vcalc .ov-form select { flex: none; }
.vcalc .ov-form input { flex: 1; min-width: 0; }
.vlist2 { list-style: none; margin: 0; padding: 0; }
.vlist2 li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; cursor: pointer; }
.vlist2 li:hover { color: var(--accent); }
.vlist2 li .spacer { flex: 1; }
.d-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 대화상자 ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow-2); max-height: 90vh; }
dialog::backdrop { background: rgba(10, 14, 20, .5); backdrop-filter: blur(2px); }
.dlg { padding: 18px 22px 20px; width: 500px; display: flex; flex-direction: column; gap: 12px; max-height: 88vh; overflow: auto; }
.dlg.wide { width: 760px; }
.dlg-head { display: flex; align-items: center; }
.dlg-head h3 { margin: 0; font-size: 16px; flex: 1; letter-spacing: -.01em; }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.dlg label input, .dlg label select, .dlg label textarea { font-size: 13.5px; color: var(--text); font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 4px; align-items: center; }
.help { font-size: 12px; color: var(--muted); line-height: 1.7; }
.builder { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--panel-2); }
.builder .bf[hidden] { display: none; }
.rules { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.rules-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rules-head .muted { flex: 1; }
.rule-row { display: grid; grid-template-columns: 120px 1fr 1.4fr auto; gap: 6px; margin-bottom: 6px; }
.rule-row input, .rule-row select { font-size: 12.5px; }
.tester { border: 1px dashed var(--line); border-radius: var(--r-md); padding: 12px; font-size: 12px; }
.tester .row { display: flex; gap: 6px; margin-top: 8px; }
.tester .row input { width: 84px; font-size: 12.5px; }
.tester .row input[name="t_category"] { width: 120px; }
.test-out { margin-top: 8px; font-family: ui-monospace, Menlo, monospace; min-height: 18px; white-space: pre-wrap; line-height: 1.6; }
.test-out.err { color: var(--danger); }
.vlist { list-style: none; margin: 0; padding: 0; }
.vlist li { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line-2); cursor: pointer; border-radius: 8px; }
.vlist li:hover { background: var(--hover); }
.vlist li .vinfo { flex: 1; min-width: 0; }
.vlist li .vinfo b { display: block; }
.vlist li .vinfo .f { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vlist li .ord button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; padding: 2px 7px; color: var(--muted); }
.vlist.pick { max-height: 50vh; overflow: auto; }
.vlist.pick li img, .vlist.pick li .noimg { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: var(--thumb); flex: none; }
.vlist.pick li .vinfo .muted { display: block; font-size: 11px; }
.grid.sets { font-size: 12.5px; box-shadow: none; table-layout: auto; }
.grid.sets th { position: static; height: auto; }
.grid.sets td { white-space: normal; }
.grid.sets td .nm { font-weight: 600; }
.grid.sets td.st { min-width: 260px; }
.grid.sets td.st .cand { margin: 2px 0; white-space: normal; text-align: left; height: auto; padding: 4px 10px; }
.grid.sets td.act2 { width: 74px; text-align: right; }
.log { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 12px; font-size: 11.5px; max-height: 240px; overflow: auto; margin: 0; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; line-height: 1.6; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* 계정 메뉴 */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; min-width: 150px; display: flex; flex-direction: column; z-index: 20; }
.menu-list[hidden] { display: none; }
.menu-list button { font: inherit; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: var(--text); }
.menu-list button:hover { background: var(--hover); }
.acct-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.acct-row b { font-family: ui-monospace, Menlo, monospace; }
.acct-row .spacer { flex: 1; }

/* ---------- 주문서 ---------- */
.page-tabs { margin-left: 4px; }
.tabs .cnt:empty { display: none; }
.page-tabs .cnt { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 10.5px; font-weight: 700; margin-left: 5px; }
.orders { flex: 1; display: flex; min-height: 0; }
.orders[hidden] { display: none; }
.o-list { width: 320px; flex: none; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.o-filters { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; align-items: center; }
.o-filters > button:not(.btn) { font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer; }
.o-filters > button.active { background: var(--accent-2); color: var(--accent); border-color: var(--accent-3); font-weight: 600; }
.o-items { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.o-items li { padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.o-items li:hover { background: var(--hover); }
.o-items li.active { background: var(--accent-2); border-color: var(--accent-3); }
.o-items li.unread .o-row1 b::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-right: 6px; vertical-align: 1px; }
.o-row1, .o-row2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.o-row2 { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.o-status { font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.o-status.s-sent { background: var(--accent-2); color: var(--accent); }
.o-status.s-replied { background: var(--warn-bg); color: var(--warn); }
.o-status.s-approved { background: var(--best-bg); color: var(--best); }
.o-status.s-done { background: var(--best-bg); color: var(--best); }
.o-status.s-canceled { background: var(--danger-bg); color: var(--danger); }
.o-detail { flex: 1; overflow: auto; padding: 16px 20px 30px; min-width: 0; }
.o-head { display: flex; align-items: flex-start; gap: 12px; }
.o-head h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.o-head > div:first-child { flex: 1; min-width: 0; }
.o-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.o-title { display: flex; gap: 6px; margin: 12px 0; }
.o-title input { flex: 1; }
.o-note { margin: 12px 0; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 12.5px; white-space: pre-wrap; }
.otable { width: 100%; table-layout: auto; margin-top: 8px; }
.otable th, .otable td { white-space: normal; }
.otable th { position: static; height: auto; }
.otable td.thumb img, .otable td.thumb .noimg { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--thumb); display: block; }
.otable td .nm { font-weight: 500; }
.otable td.n, .otable th.n { text-align: right; }
.otable td.c, .otable th.c { text-align: center; }
.otable input.qty, .otable input.vqty { width: 72px; text-align: right; padding: 4px 8px; }
.otable input.vnote { width: 140px; padding: 4px 8px; }
.otable select.vst { padding: 4px 26px 4px 8px; font-size: 12.5px; }
.otable tr.soldout td { color: var(--danger); }
.otable tr.soldout td .nm { text-decoration: line-through; }
.otable tr.partial td { color: var(--warn); }
.otable td.vs-soldout { color: var(--danger); font-weight: 600; }
.otable td.vs-partial { color: var(--warn); font-weight: 600; }
.otable tfoot td { background: var(--panel-2); font-weight: 600; }
.o-reply { margin-top: 10px; }
.o-reply textarea { width: 100%; }
.o-chat { margin-top: 18px; }
.o-chat h4 { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.o-msgs { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; }
.msg { display: flex; flex-direction: column; max-width: 78%; padding: 7px 11px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.msg.admin { align-self: flex-end; background: var(--accent-2); border-color: var(--accent-3); }
.msg.vendor { align-self: flex-start; background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 11.5px; max-width: 100%; }
.msg .who { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.msg .when { font-size: 10px; color: var(--faint); align-self: flex-end; }
.o-send { display: flex; gap: 6px; margin-top: 8px; }
.o-send input { flex: 1; }
.cart-items { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow: auto; }
.cart-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.cart-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-row input { width: 64px; text-align: right; padding: 4px 8px; }
.cart-row .pr { width: 90px; text-align: right; color: var(--text-2); }
