/* 메인 컬러: 보라 */
:root {
  --primary: #7c3aed;  --primary-dark: #6d28d9;  --primary-soft: #f3eefe;  --primary-line: #ddd0fb;
  --nav: #24104f;      --nav-2: #3a1d78;          --nav-text: #d9cdf7;
  --bg: #f7f5fb;       --card: #ffffff;           --text: #1f1933;  --muted: #6e6886;  --line: #d9d3e6;
  --danger: #d03b3b;   --warn-bg: #fff6e6;        --warn-line: #f5d08a;  --ok-bg: #edf8f0;  --ok-line: #b6e2c7;
  /* 차트: 계열색(보라·주황, 색약 검사 통과) / 상태색(정상·부족·품절) */
  --series-1: #7c3aed; --series-2: #eb6834;
  /* 도넛·비율 막대 색 (이 순서 그대로, 색약 검사 통과 — 이웃한 조각끼리 구분됨). 나머지는 회색 '기타' */
  --cat-1: #7c3aed; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100; --cat-5: #2a78d6; --cat-other: #9e9aa8;
  --status-good: #0ca30c; --status-warning: #fab219; --status-critical: #d03b3b;
  --grid: #ece9f3;     --axis: #c9c3d9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(36, 16, 79, .06), 0 4px 16px rgba(36, 16, 79, .05);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: -.3px; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -.2px; }
small { font-weight: normal; font-size: 13px; }
.muted { color: var(--muted); }
p.small, .small { font-size: 12px; }

/* 상단 메뉴 */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 24px; min-height: 56px;
  background: linear-gradient(90deg, var(--nav), var(--nav-2)); color: #fff;
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgba(36, 16, 79, .25); }
.topbar a { color: var(--nav-text); }
.topbar .brand { color: #fff; font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .brand::before { content: ""; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 7px 11px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.topbar nav a.on { background: rgba(167, 139, 250, .28); color: #fff; }
.topbar .me { white-space: nowrap; color: #b7a8e0; }
.topbar .me a { color: #fff; }
.side-top { display: flex; align-items: center; gap: 8px; }
.side-toggle { display: none; }
.nav-title { display: none; }
.topbar nav a .ico { margin-right: 6px; }

/* 왼쪽 세로 메뉴 (넓은 화면, 찬대표 2026-10-30). 접으면(side-collapsed) 아이콘만 */
@media (min-width: 901px) {
  body.has-side { --side-w: 208px; padding-left: var(--side-w); }
  body.has-side.side-collapsed { --side-w: 60px; }
  .topbar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); box-sizing: border-box;
    flex-direction: column; align-items: stretch; gap: 0; padding: 14px 10px; min-height: 0; overflow-y: auto;
    background: linear-gradient(180deg, var(--nav), var(--nav-2)); box-shadow: 2px 0 10px rgba(36, 16, 79, .2); }
  .side-top { justify-content: space-between; padding: 0 4px 12px; }
  .side-toggle { display: inline-block; background: rgba(255, 255, 255, .1); color: #fff; border: 0; border-radius: 6px;
    padding: 2px 8px; font-size: 14px; cursor: pointer; }
  .side-toggle:hover { background: rgba(255, 255, 255, .2); }
  .topbar nav { flex-direction: column; flex-wrap: nowrap; flex: 1 0 auto; gap: 0; }
  .nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
  .nav-title { display: block; font-size: 11px; font-weight: 600; color: #9d8fcf; padding: 4px 10px; letter-spacing: .3px; }
  .topbar nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; white-space: nowrap; }
  .topbar nav a .ico { margin-right: 0; width: 20px; text-align: center; flex: none; }
  .topbar .me { padding: 12px 10px 4px; border-top: 1px solid rgba(255, 255, 255, .1); white-space: normal; font-size: 13px; }
  body.side-collapsed .topbar .label, body.side-collapsed .nav-title { display: none; }
  body.side-collapsed .nav-group { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 6px; }
  body.side-collapsed .topbar nav a { justify-content: center; padding: 8px 0; }
  body.side-collapsed .side-top { flex-direction: column; gap: 8px; }
  body.side-collapsed .side-toggle { transform: rotate(180deg); }
  body.side-collapsed .topbar .me { text-align: center; font-size: 11px; }
}

main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head h1 { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px; box-shadow: var(--shadow); }
table.card { padding: 0; overflow: hidden; }
.narrow { max-width: 520px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; min-width: 0; }

/* 숫자 카드 */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); }
.tile span { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.tile b { display: block; font-size: 24px; letter-spacing: -.5px; margin-top: 2px; }
.tile b small { margin-left: 3px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tile em { display: block; font-style: normal; color: var(--muted); font-size: 12px; margin-top: 4px; }
.tile.accent { background: linear-gradient(135deg, #7c3aed, #5b21b6); border-color: transparent; color: #fff; }
.tile.accent span, .tile.accent em, .tile.accent b small { color: #e4d9fe; }
.tile.warn { background: var(--warn-bg); border-color: var(--warn-line); }

/* 표 */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #faf8fd; white-space: nowrap;
     border-bottom: 2px solid var(--axis); }
th.sortable a { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
th.sortable a:hover { color: var(--primary); text-decoration: none; }
th.sortable i { font-style: normal; font-size: 10px; opacity: .45; }
th.sortable.on { color: var(--primary); }
th.sortable.on i { opacity: 1; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: #fcfbfe; }
.table-wrap { overflow-x: auto; }
td.nowrap { white-space: nowrap; }
td.product { min-width: 180px; }
td.product .muted { display: block; font-size: 12px; }
td.memo { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }
tr.inactive td { color: var(--muted); }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--primary); font-size: 13px; margin-bottom: 8px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: #efecf5; color: #4b4563; }
.badge.IN { background: #e6efff; color: #2456b3; }
.badge.OUT { background: #e8f6ee; color: #1f7a45; }
.badge.RETURN { background: #fff1e0; color: #a65c00; }
.badge.ADJUST { background: var(--primary-soft); color: var(--primary-dark); }

/* 입력·버튼 */
input, select, button, .btn { font: inherit; padding: 8px 11px; border: 1px solid #d6d0e4; border-radius: 8px;
  background: #fff; color: var(--text); }
input:focus, select:focus { outline: 3px solid #e3d8fd; border-color: var(--primary); }
button, .btn { cursor: pointer; display: inline-block; white-space: nowrap; font-weight: 500; }
button:hover, .btn:hover { background: var(--primary-soft); border-color: var(--primary-line); text-decoration: none; }
.primary, button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover, button.primary:hover, .btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.danger { color: var(--danger); }
.btn.small-btn, button.small-btn { padding: 3px 10px; font-size: 12px; }
button.link { border: 0; background: none; padding: 0; color: var(--primary); }
button.link.danger { color: var(--danger); }
form.inline { display: inline; }
input.short { width: 110px; }
td input:not([type=checkbox]) { width: 100%; }
/* 줄 맞춤 (찬대표 2026-10-30): 입력칸·선택칸 높이를 모두 같게 (날짜 칸이 더 커서 제목 줄이 들쭉날쭉하던 것),
   표 안의 숫자 칸은 오른쪽 정렬 — 오른쪽 정렬된 제목(th.num)·합계와 세로로 딱 맞게 */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), select {
  height: 40px; box-sizing: border-box; line-height: normal; }
.setup-form button, .filters button, .filters .btn, .setup-form .btn { height: 40px; box-sizing: border-box; }
td input:not([type=checkbox]):not([type=radio]), td select { height: 36px; }   /* 표 안은 조금 낮게 (줄이 많아서) */
table input[type=number], input.num { text-align: right; }
td:has(> input[type=number]), td:has(> input.num), td.num > input, td.num > select { text-align: right; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { min-width: 240px; }
label.check { display: inline-flex; gap: 4px; align-items: center; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; max-width: 780px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.form-grid label input, .form-grid label select { font-weight: normal; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid h2 { margin: 0; }
.actions { display: flex; gap: 12px; align-items: center; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 12px; background: var(--ok-bg); border: 1px solid var(--ok-line); }
.flash.error { background: #fdecec; border-color: #f2b8b8; color: #8a1f1f; }
.errors { border-color: #f2b8b8; }
.errors ul { margin: 0; padding-left: 20px; color: #8a1f1f; }

.login { max-width: 380px; margin: 90px auto; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; }

/* 대시보드 차트 */
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 0; }
.dash-grid > .card { margin-bottom: 0; min-width: 0; }
.dash-grid .span2 { grid-column: span 2; }
.dash-grid + .dash-bottom { margin-top: 16px; }
.dash-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
.dash-bottom > .card { min-width: 0; }
.viz { min-height: 60px; }
.viz-empty { display: block; color: var(--muted); padding: 24px 0; text-align: center; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--grid); stroke-width: 1; }
.viz-base { stroke: var(--axis); stroke-width: 1; }
.viz-cross { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.viz-key.line { height: 3px; width: 14px; border-radius: 2px; }

.viz-hbar { display: flex; flex-direction: column; gap: 6px; }
.viz-hbar-row { display: grid; grid-template-columns: minmax(70px, 38%) 1fr auto; gap: 10px; align-items: center;
  padding: 3px 4px; border-radius: 6px; outline: none; }
.viz-hbar-row:hover, .viz-hbar-row:focus { background: var(--primary-soft); }
.viz-hbar-label { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-hbar-track { height: 14px; }
.viz-hbar-bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.viz-hbar-value { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; min-width: 72px; }

.viz-stack { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; margin: 6px 0 14px; }
.viz-stack-seg { min-width: 4px; }
.viz-stack-seg.good { background: var(--status-good); }
.viz-stack-seg.warning { background: var(--status-warning); }
.viz-stack-seg.critical { background: var(--status-critical); }
.viz-status-legend { display: flex; flex-direction: column; gap: 6px; }
.viz-status { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--text); }
.viz-status:hover { background: var(--primary-soft); text-decoration: none; }
.viz-status b { margin-left: auto; font-size: 16px; }
.viz-status-icon { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.viz-status.good .viz-status-icon { background: var(--status-good); }
.viz-status.warning .viz-status-icon { background: var(--status-warning); color: #3d2a00; }
.viz-status.critical .viz-status-icon { background: var(--status-critical); }

.share-cell { min-width: 120px; white-space: nowrap; }
.share-bar { display: inline-block; width: 70px; height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.share-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.viz-share { color: var(--muted); font-size: 11px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.viz-donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.viz-donut-svg { width: 168px; height: 168px; flex: none; margin: 0 auto; }
.viz-donut-seg { transition: opacity .15s; cursor: default; }
.viz-donut-seg.dim { opacity: .3; }
.viz-donut-cap { fill: var(--muted); font-size: 12px; }
.viz-donut-total { fill: var(--text); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.viz-donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 4px; }
.viz-donut-item, .viz-split-item { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 6px; border-radius: 6px; }
.viz-donut-item.on, .viz-donut-item:focus { background: var(--primary-soft); outline: none; }
.viz-donut-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-donut-item b, .viz-split-item b { font-variant-numeric: tabular-nums; font-weight: 600; }
.viz-donut-item .viz-share { min-width: 40px; text-align: right; }
.viz-split-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.viz-tip { position: fixed; display: none; z-index: 50; pointer-events: none; min-width: 140px; max-width: 280px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 24px rgba(36, 16, 79, .16); }
.viz-tip-title { display: block; color: var(--muted); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .span2 { grid-column: auto; }
  .dash-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 8px 16px; }
  main { padding: 16px; }
}

.price-alert { background: var(--warn-bg); border-color: var(--warn-line); max-width: 780px; }
.price-alert h2 { color: #8a5a00; }

.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.bulk-bar .btn.danger { border-color: #f2b8b8; }
.bulk-bar .btn.danger:hover { background: #fdecec; }
th.pick, td.pick { width: 34px; text-align: center; }
th.pick input, td.pick input { width: 16px; height: 16px; cursor: pointer; }

/* 상품 사진·포장 크기 */
.product-top { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.product-info .tiles { margin-bottom: 12px; }
.photo-card { padding: 12px; text-align: center; }
.photo-card img { width: 100%; height: 216px; object-fit: contain; border-radius: 8px; background: #faf8fd; display: block; }
.photo-empty { height: 216px; border: 2px dashed var(--line); border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--muted); }
.photo-form { display: flex; justify-content: center; gap: 12px; align-items: center; margin-top: 10px; }
.photo-form label.btn { cursor: pointer; }
th.thumb-col, td.thumb-col { width: 48px; padding: 4px 6px; }
td.thumb-col img, .no-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block;
  background: #f1eef7; }
.size-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; display: grid;
  grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: end; }
.size-box legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.size-sum { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.size-sum b { padding: 8px 11px; background: var(--primary-soft); border-radius: 8px; color: var(--primary-dark); }
@media (max-width: 900px) {
  .product-top { grid-template-columns: 1fr; }
  .size-box { grid-template-columns: repeat(2, 1fr); }
}
.size-box { min-width: 0; min-inline-size: 0; }
.size-box input { min-width: 0; width: 100%; }
.size-sum b { white-space: nowrap; }

/* 공급처 직배송 · 위탁 매출 */
.badge.dropship { background: #fff1e0; color: #a65c00; }
.form-grid label.dropship-check { flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px;
  border: 1px dashed #d6d0e4; border-radius: 8px; flex-wrap: wrap; }
.form-grid label.dropship-check small { font-weight: normal; }
td input.price-input { width: 110px; text-align: right; }
.price-add input[name=new_code] { width: 300px; }
.price-add input[name=new_price] { width: 140px; }
.consign-name { font-weight: 600; }
tr.total td { font-weight: 700; border-top: 2px solid #d6d0e4; }
.price-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* 토글 출고 줄 수정 */
.btn.small { padding: 4px 10px; font-size: 13px; }
tr.edit-row td { background: var(--primary-soft); }
.edit-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.edit-form > label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.edit-form label.check { padding-bottom: 8px; font-size: 13px; }
.edit-form p { flex-basis: 100%; margin: 0; }
button.danger-outline { color: var(--danger); border-color: var(--danger); background: #fff; }
tr.flash-row td { background: #fff7e0; }

/* 위탁 단가·배송비 설정 */
.enter-save { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
input.tier-name { width: 130px; text-align: right; font-weight: 600; }
tr.new-row td { background: var(--primary-soft); }
.templates { display: flex; flex-wrap: wrap; gap: 16px; }
.template-box { border: 1px solid var(--primary-line); border-radius: 10px; padding: 12px 14px; min-width: 300px; }
.template-box.new { border-style: dashed; }
.template-box .tname { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.setup-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.setup-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.setup-form .grow { flex: 1 1 220px; min-width: 200px; }
.setup-form .grow > input, .setup-form .grow > select, .setup-form .grow > textarea { width: 100%; box-sizing: border-box; }
.deduct-preview { padding-bottom: 9px; font-size: 13px; }
.deduct-preview b { color: var(--primary-dark); }
/* 상품코드 찾기 목록 (codepick.js) */
.code-pick { position: absolute; z-index: 50; max-width: min(560px, calc(100vw - 16px)); max-height: 320px;
  overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(31, 25, 51, .15); font-size: 13px; }
.code-pick-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); line-height: 1.35; }
.code-pick-item:last-child { border-bottom: 0; }
.code-pick-item span { color: var(--muted); }
.code-pick-item:hover, .code-pick-item.on { background: var(--bg); }
.code-pick-item.on b { color: var(--primary-dark); }
.code-pick-more { padding: 7px 10px; color: var(--muted); }
.code-hint { margin: 2px 0 6px; padding: 4px 8px; border-radius: 6px; background: #fff4d6; font-size: 13px; }
.sum-line { margin: 12px 0 4px; }

/* 입고 거래명세서 */
.receipt-head { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 6px; }
.receipt-head label, .memo { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.receipt-head .grow { flex: 1; min-width: 240px; }
.memo { margin: 12px 0; max-width: 520px; }
.receipt-lines td, .receipt-lines th { padding: 5px 8px; }
.receipt-lines td.no, .statement-lines td.no, th.no { width: 36px; color: var(--muted); text-align: center; }
.receipt-lines input[name=code] { width: 100%; min-width: 200px; }
.receipt-lines .pname { min-width: 220px; font-size: 13px; }
input.qty-input { width: 90px; text-align: right; }
.statement-title { text-align: center; letter-spacing: 4px; font-size: 22px; margin: 4px 0 16px; }
.statement-title small { letter-spacing: 0; font-size: 13px; color: var(--muted); }
.statement-head { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; }
.statement-head .kv { flex: 1; min-width: 280px; }
table.kv th { width: 120px; text-align: left; background: var(--primary-soft); }
table.area-fees { margin-top: 8px; }
table.area-fees th { text-align: left; font-size: 13px; }
textarea.remote-areas { width: 100%; max-width: 520px; font: inherit; padding: 8px 11px; border: 1px solid #d6d0e4;
  border-radius: 8px; }
.badge.area { background: #e6efff; color: #2456b3; }

table.catalog img.thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 6px; background: #fff; }

/* 위탁 발주서 */
tr.warn-row td { background: var(--warn-bg); }
.order-lines td.addr { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-lines input[type=number] { text-align: right; }
@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body.has-side { padding-left: 0 !important; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}

/* 휴대폰 화면: 메뉴 접기, 넓은 표는 옆으로 밀어서 보기 */
.menu-toggle { display: none; }
.menu-toggle, .menu-toggle:hover, .menu-toggle:focus, .menu-toggle:active {
  background: rgba(255, 255, 255, .12); color: #fff; border: 0; padding: 6px 12px; }
@media (max-width: 900px) {
  .topbar { gap: 8px; }
  .menu-toggle { display: inline-block; margin-left: auto; }
  .topbar nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0; }
  .topbar nav a { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
  .side-top { flex: 1; }
  .nav-group { display: flex; flex-direction: column; }
  .nav-title { display: block; font-size: 11px; color: #9d8fcf; padding: 10px 12px 2px; }
  .topbar .me { display: none; flex-basis: 100%; padding: 8px 12px; }
  body.menu-open .topbar nav, body.menu-open .topbar .me { display: flex; }
  .card { overflow-x: auto; }
  .head { flex-wrap: wrap; gap: 8px; }
  .filters { flex-wrap: wrap; }
  input, select, button, .btn { font-size: 16px; }  /* 아이폰이 글자 칸을 누를 때 화면을 확대하지 않게 */
  .receipt-lines input[name=code] { min-width: 150px; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
}

/* 입출고 내역: 날짜 → 내역서 → 품목 펼치기 */
details.day { padding: 0; margin-bottom: 10px; }
details.day > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 14px 18px;
  cursor: pointer; list-style: none; }
details.day > summary::-webkit-details-marker, details.doc > summary::-webkit-details-marker { display: none; }
details.day > summary::before, details.doc > summary::before { content: "▸"; color: var(--muted); }
details[open] > summary::before { content: "▾"; }
details.day[open] > summary { border-bottom: 1px solid var(--line); }
.day-date { min-width: 6.5em; }
.day-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; }
details.doc { border-bottom: 1px solid var(--line); }
details.doc:last-child { border-bottom: 0; }
details.doc > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 18px 10px 30px;
  cursor: pointer; list-style: none; }
details.doc > summary .btn { margin-left: auto; }
details.doc[open] > summary { background: var(--bg); }
details.doc .table-wrap { padding: 0 12px 12px; }
.warn-text { color: #b45309; }
tr.ad-row td { background: #fff7f7; }
form.settle-paid { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* 휴대폰 카메라 바코드 찍기 (scan.js) */
.scan-btn { margin-left: 4px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  font-size: 16px; line-height: 1; cursor: pointer; vertical-align: middle; }
.scan-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15, 10, 30, .92); display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.scan-overlay[hidden] { display: none; }
.scan-box { position: relative; width: min(92vw, 420px); aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  border: 3px solid var(--primary); background: #000; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff4d4d; box-shadow: 0 0 8px #ff4d4d; }
.scan-msg { color: #fff; text-align: center; margin: 0; }
/* 결산 대시보드 */
.pnl-table td.sub { padding-left: 22px; color: var(--muted); }
.pnl-table tr.net td { background: var(--primary-soft); font-size: 15px; }
form.inline-form { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
details.pnl-detail { margin-top: 12px; }
details.pnl-detail summary { cursor: pointer; color: var(--primary-dark); }

/* 기록 더보기 (static/more.js) */
[data-more] [hidden], .more-btn[hidden] { display: none !important; }
.more-btn { display: block; width: 100%; margin: 10px 0 16px; padding: 10px; }
.more-note { color: var(--primary); font-size: 12px; }
.more-note:empty { display: none; }

/* 일정표 + 댓글 (찬대표 2026-10-30) */
.todo-card h2 .small { margin-left: 8px; font-weight: 400; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todo-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px; border-radius: 8px; }
.todo-list li.late { background: #fdf2f2; }
.badge.new { background: var(--primary); color: #fff; }
.badge.auto { background: var(--grid); color: var(--muted); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; }
table.calendar { table-layout: fixed; }
table.calendar th { text-align: center; }
table.calendar td { vertical-align: top; height: 96px; padding: 4px; border: 1px solid var(--line); }
table.calendar td.out { background: var(--bg); color: var(--muted); }
table.calendar td.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.cal-item { display: block; font-size: 12px; padding: 2px 6px; margin-bottom: 2px; border-radius: 4px; background: var(--primary-soft);
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item:hover { text-decoration: none; filter: brightness(.96); }
.cal-item.done { opacity: .5; text-decoration: line-through; }
.cal-item.late { background: #fdf2f2; color: var(--status-critical); }
.cal-item.auto { background: var(--grid); color: var(--muted); }
.cal-item .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
/* 한국식 달력 색: 일요일·공휴일 빨강, 토요일 파랑 (날짜 글자에만, 일정 줄은 그대로) */
:root { --holiday: #d23b3b; --saturday: #2563eb; }
table.calendar th.sun, table.calendar td.holiday .cal-day, .cal-list-day.holiday > b, .hol-key { color: var(--holiday); }
table.calendar th.sat, table.calendar td.sat .cal-day, .cal-list-day.sat > b, .sat-key { color: var(--saturday); }
table.calendar td.holiday:not(.out) { background: #fff8f8; }
table.calendar td.out .cal-day { opacity: .55; }
.cal-day { font-weight: 600; }
.hol-name { font-size: 11px; font-weight: 500; color: var(--holiday); }
.cal-list { display: none; }
.cal-list-day { padding: 8px 0; border-bottom: 1px solid var(--line); }
.cal-list-day.today b { color: var(--primary); }
.cal-list-day .cal-item { white-space: normal; margin-top: 4px; font-size: 14px; padding: 6px 8px; }
@media (max-width: 720px) {
  table.calendar { display: none; }
  .cal-list { display: block; }
}
.comment { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-bottom: 8px; max-width: 640px; }
.comment.mine { background: var(--primary-soft); margin-left: auto; }
.comment-head { margin-bottom: 2px; }
.comment p { margin: 0; }
.pre { white-space: pre-wrap; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.comment-form textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; box-sizing: border-box; }
.comment-form button { align-self: flex-end; }

/* 일정: 중요 일정만 달력에, 날짜를 누르면 오른쪽 '그날 보기' (찬대표 2026-10-30) */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.cal-wrap > .card { margin-bottom: 0; }
.day-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
table.calendar td[data-day] { cursor: pointer; }
table.calendar td[data-day]:hover { background: var(--primary-soft); }
table.calendar td.picked { box-shadow: inset 0 0 0 2px var(--primary); background: var(--primary-soft); }
.cal-more { display: block; font-size: 11px; color: var(--muted); padding: 1px 6px; }
.cal-day .dot { margin-left: 2px; }
.day-view h2 { margin-bottom: 10px; }
.day-view h2.holiday { color: var(--holiday); }
.day-view h2.sat { color: var(--saturday); }
.day-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.day-item.important .day-item-head b { color: var(--text); }
.day-item.done { opacity: .6; }
.day-item.auto { font-size: 13px; }
.day-item-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.day-item p { margin: 4px 0; }
.mini-comment { font-size: 12px; background: var(--bg); border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.mini-form { display: flex; gap: 4px; margin-top: 6px; }
.mini-form input[name=body] { flex: 1; min-width: 0; }
.day-add { margin-top: 12px; }
.day-add summary { cursor: pointer; color: var(--primary); font-size: 13px; }
.setup-form.compact { flex-direction: column; align-items: stretch; margin-top: 8px; }
.important-check { white-space: nowrap; }
@media (max-width: 1100px) { .cal-wrap { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 720px) {
  .cal-wrap { display: block; }
  .day-panel { display: none; }
}
.setup-form label.check, .setup-form label.important-check { flex-direction: row; align-items: center; gap: 6px; height: 40px; }

/* 입력 줄 표 (입고·출고·조정·중개 거래, 찬대표 2026-10-30): 칸 폭을 정해 두고 입력칸이 칸을 꽉 채움 → 제목·입력·합계가 세로로 딱 맞음 */
table.line-grid { table-layout: fixed; min-width: 720px; }
table.line-grid td > input:not([type=checkbox]), table.line-grid td > select { width: 100%; min-width: 0; box-sizing: border-box; }
table.line-grid .c-no { width: 44px; }
table.line-grid .c-code { width: 30%; }
table.line-grid .c-qty { width: 110px; }
table.line-grid .c-price { width: 140px; }
table.line-grid .c-amount { width: 130px; }
table.line-grid .c-x { width: 44px; }
table.line-grid .c-x2 { width: 64px; }
table.line-grid td.pname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.receipt-lines.line-grid input[name=code] { min-width: 0; }
/* 위쪽 입력칸을 같은 폭 칸으로 나란히 (중개 거래) */
.form-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 16px; align-items: end; margin-bottom: 12px; }
.form-cols label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; min-width: 0; }
.form-cols label > input, .form-cols label > select { width: 100%; box-sizing: border-box; }
.form-cols .wide { grid-column: 1 / -1; }
.form-cols .btn-cell button { height: 40px; align-self: flex-start; }

/* 입고 운송비 (찬대표 2026-11-02) */
.direct-fee { margin: 12px 0; padding: 10px 12px; border: 1px dashed var(--primary-line); border-radius: 8px; background: var(--primary-soft); }
.direct-fee .form-cols { margin: 8px 0 0; }
tr.fee-row td { background: #faf8fd; }

/* 플랫폼 행사 (찬대표 2026-11-02) */
.badge.plat { background: #e9f2fd; color: #1d5fae; }
.badge.expect { background: #fff4d6; color: #8a5a00; }
tr.expect-row td { color: var(--muted); }
tr.expect-row td b { color: var(--text); }
.day-item.event { font-size: 13px; }
.cal-item.event { background: #f3f8fe; }
.setup-form.compact .grow { flex: none; }
.form-cols label.check { flex-direction: row; align-items: center; gap: 6px; height: 40px; align-self: end; }

/* 위탁 개별 단가표 (찬대표 2026-11-04): 칸 폭 고정, 입력칸은 칸을 꽉 채우고 숫자는 오른쪽 */
table.price-table { table-layout: fixed; min-width: 860px; }
table.price-table .c-code { width: 190px; }
table.price-table .c-amt { width: 100px; }
table.price-table .c-in { width: 130px; }
table.price-table .c-unit { width: 110px; }
table.price-table .c-del { width: 72px; }
table.price-table td > input { width: 100%; min-width: 0; box-sizing: border-box; }
table.price-table td > input[type=number] { text-align: right; }
table.price-table td > button { width: 100%; }
table.price-table tr.price-add-row td { border-top: 2px solid var(--line); }

/* 파일 끌어다 놓기 상자 (찬대표 2026-11-05, static/dropzone.js) — 입력칸 크기에 맞춘 작은 상자 (2026-11-05 줄임) */
.dropzone { position: relative; display: inline-flex; flex-direction: column; justify-content: center; gap: 2px;
  width: 100%; max-width: 420px; min-height: 44px; padding: 6px 12px; box-sizing: border-box; vertical-align: middle;
  border: 2px dashed var(--primary-line); border-radius: 8px; background: var(--card); color: var(--muted);
  text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.filters > .dropzone, .setup-form > .dropzone { flex: 0 1 380px; width: auto; }
label > .dropzone { flex: none; height: auto; min-height: 40px; }
.dropzone > input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-text { font-size: 13px; line-height: 1.35; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropzone .dz-text b { color: var(--text); }
.dropzone .dz-name { font-size: 12px; line-height: 1.35; color: var(--text); font-weight: 600; pointer-events: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone .dz-name:empty { display: none; }
.dropzone .dz-name.neg { color: var(--danger); white-space: normal; }
.dropzone:hover, .dropzone.over, .drop-target.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--primary); }
.drop-target { outline: 2px dashed transparent; outline-offset: -6px; transition: outline-color .15s, background .15s; }
.drop-target.over { outline-color: var(--primary); }
.drop-hint { margin: 6px 0 0; }
label > .dropzone { margin-top: 4px; display: flex; }
form:not(.filters):not(.setup-form):has(> .dropzone) { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 상품·재고 목록 (찬대표 2026-11-11): 판매량은 빨간색, 재고금액 합계 */
.sold-red { color: var(--danger); }
.stock-total { margin: 8px 0; }
