/* 2027 리브랜딩 가이드(REBRANDING.pdf) 기준
   네이비 #030143 (로고타입·심볼), 크림 #FFF0D1, 차콜 #1A1A1A, 버건디 #630B17, 린넨 #E9E2D2, 보조 올리브 */
:root {
  --navy: #030143;
  --cream: #fff0d1;
  --charcoal: #1a1a1a;
  --burgundy: #630b17;
  --linen: #e9e2d2;
  --olive: #5b6b2f;
  --bg: #fffaf0;
  --surface: #ffffff;
  --line: #ece4d3;
  --line-strong: #cfc4ae;
  --text: var(--charcoal);
  --muted: #6b6b6b;
  --accent: var(--navy);
  --accent-soft: var(--cream);
  --ok: var(--olive);
  --warn: #9a5800;
  --danger: #a3192b;
  --zero: #c4c4c4;
  --q-red: #c62828;
  --q-blue: #1565c0;
  --radius: 10px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand img.logo { height: 22px; width: auto; display: block; }
.brand img.symbol { height: 26px; width: auto; display: block; }
.login { border-top: 4px solid var(--navy); }
.login .brand { flex-direction: column; align-items: center; width: 100%; gap: 14px; margin-bottom: 6px; }
.login .brand img.symbol { height: 56px; }
.login .brand img.logo { height: 30px; }
.login h1 { font-size: 15px; font-weight: 500; color: var(--muted); text-align: center; margin: 4px 0 24px; letter-spacing: .02em; }
.tagline { font-size: 10.5px; letter-spacing: .28em; color: var(--muted); text-align: center; margin-top: 18px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 12px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1080px; margin: 0 auto; padding: 12px 16px 10px; }
.top-row { display: flex; align-items: center; gap: 10px; }
.top-row .who { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.chip.sample { background: #fff3e0; color: var(--warn); }
.search { display: flex; gap: 8px; margin-top: 10px; }
.search input { flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.search input:focus, .field input:focus, .cell-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.metaline { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12.5px; color: var(--muted); align-items: center; }
.metaline b { color: var(--text); font-weight: 600; }
.metaline label { display: inline-flex; gap: 5px; align-items: center; margin-left: auto; cursor: pointer; }

/* 재고 목록 */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }
.list-head, .row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 90px 110px; gap: 12px; align-items: center; padding: 11px 12px; }
.list-head { font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); position: sticky; z-index: 4; background: var(--bg); }
.row { border-bottom: 1px solid var(--line); background: var(--surface); }
.c-code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); }
.c-name { overflow-wrap: anywhere; }
.c-qty { font-weight: 700; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
/* 수량 구간 색상 (색약 고려: 빨강·파랑 대비 + 굵기 차이) */
.q-low { color: var(--q-red); font-weight: 800; }
.q-mid { color: var(--q-blue); font-weight: 700; }
.q-ok { color: var(--charcoal); font-weight: 600; }
.legend { display: inline-flex; gap: 10px; align-items: center; }
.legend .q-low, .legend .q-mid, .legend .q-ok { font-size: 12.5px; }
.legend .soldout { padding: 1px 7px; font-size: 11.5px; }
.soldout { display: inline-block; padding: 3px 10px; border-radius: 99px; background: #fbe9eb; color: var(--burgundy); font-size: 12.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.row.is-out .c-name, .row.is-out .c-size, .row.is-out .c-code { color: var(--muted); }
.list-head .c-qty { font-size: 12.5px; font-weight: 400; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.sentinel { height: 1px; }

@media (max-width: 640px) {
  .list-head { display: none; }
  .row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "name name qty" "code size qty"; gap: 3px 10px; padding: 11px 12px; }
  .c-name { grid-area: name; font-weight: 600; }
  .c-code { grid-area: code; font-size: 12px; }
  .c-size { grid-area: size; font-size: 12px; color: var(--muted); }
  .c-qty { grid-area: qty; font-size: 19px; }
  .metaline label { margin-left: 0; }
  .top .brand img.symbol { display: none; }
  .top .brand img.logo { height: 19px; }
  .top-row .who .uname { display: none; }
}

/* 채널 재고 '전체' 보기: 품목 정보 | 채널별 가용수량 | 총 가용수량 사이 세로 구분선 */
.all-grid { display: grid; grid-template-columns: 150px minmax(160px, 1fr) 72px repeat(4, 84px) 104px; align-items: stretch; }
.all-grid > span { display: flex; align-items: center; padding: 10px 10px; min-width: 0; }
.all-grid > span.num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.all-grid > .ch { border-left: 1px solid #e2d9c6; }             /* 채널 사이 얇은 선 */
.all-grid > .vl { border-left: 2px solid var(--line-strong); }   /* 영역 경계 굵은 선 */
.all-head { position: sticky; z-index: 4; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.all-row { background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.all-row .c-name { overflow-wrap: anywhere; }
.all-row .total { font-weight: 800; font-size: 15px; background: #faf8f2; }
.all-head .vl:last-child { color: var(--navy); font-weight: 700; }
.all-row .zero-n { color: var(--zero); }
.all-row.is-out .c-name, .all-row.is-out .c-size, .all-row.is-out .c-code { color: var(--muted); }
@media (max-width: 900px) {
  .all-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .all-wrap .all-grid { min-width: 860px; }
  .all-head { position: static; }
}

/* 관리자 */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; color: var(--muted); }
.tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel h3 { font-size: 14px; margin: 18px 0 8px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th, .grid-table td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid-table th { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.grid-table td.wrap-cell { white-space: normal; min-width: 150px; }
.grid-table th.num, .grid-table td.num { text-align: right; }
.grid-table tfoot td { font-weight: 700; border-bottom: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cell-input { width: 72px; padding: 6px 8px; text-align: right; border: 1px solid var(--line); border-radius: 6px; font-variant-numeric: tabular-nums; }
.cell-input.bad { border-color: var(--danger); background: #fdecea; }
.sum-bad { color: var(--danger); font-weight: 700; }
.sum-ok { color: var(--ok); font-weight: 700; }
.lot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.lot-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.lot-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.lot-card .no { font-weight: 700; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.lot-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.status.pending { background: #fff3e0; color: var(--warn); }
.status.confirmed { background: #eef1e4; color: var(--ok); }
.status.partial { background: #e8eefb; color: var(--q-blue); }

/* 입고 배정 표: 품목 선택 체크박스, 선택 행 강조, 확정 행 흐리게 */
.lot-table th.chk, .lot-table td.chk { width: 44px; text-align: center; padding-left: 4px; padding-right: 4px; }
.lot-table input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--navy); }
.lot-table tr.is-sel td { background: var(--cream); }
.lot-table tr.is-done td { color: var(--muted); }
.lot-table tr.is-done .status { font-size: 11px; padding: 1px 6px; }
/* 하단 버튼 줄: 왼쪽 '선택 항목' 묶음, 오른쪽 '전체' 묶음. 화면 아래에 고정 */
.sel-bar {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  margin: 0 -16px -16px; padding: 14px 16px; /* 패널 안쪽 여백까지 채워 하단 간격을 위아래 동일하게 */
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
}
.sel-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sel-count { font-weight: 700; color: var(--navy); min-width: 56px; margin-right: 4px; }
.sel-bar .btn { height: 38px; padding: 0 14px; white-space: nowrap; }
.sel-bar .msg { flex-basis: 100%; font-size: 13px; }
.sel-bar .msg:empty { display: none; }
@media (max-width: 640px) {
  .sel-bar { gap: 8px; }
  .sel-group { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .sel-group .sel-count { grid-column: 1 / -1; }
  .sel-bar .btn { padding: 0 8px; }
}
.lot-detail .result:empty { display: none; }
/* 신상품·리오더 구분 표시 */
.type-tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.type-tag.new { background: var(--cream); color: var(--burgundy); }
.type-tag.re { background: #e8eefb; color: var(--q-blue); }
.type-tag.re.nosales { background: #f1f1f1; color: var(--muted); }
.lot-table tr.is-active td, .lot-table tr.is-active + tr.note-row td { background: #f2f4fa; }
.lot-table tr.is-active td.chk { box-shadow: inset 3px 0 0 var(--navy); }
.lot-table tr { cursor: default; }
/* 입력 방식 전환: 수량 ↔ 비율(%) */
.lot-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 10px; }
.lot-tools .min-filter { margin-top: 0; }
.mode-switch { display: inline-flex; align-items: center; gap: 0; font-size: 13px; }
.mode-switch .muted { margin-right: 8px; }
.mode-switch button { height: 32px; padding: 0 14px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 13px; }
.mode-switch button:first-of-type { border-radius: 8px 0 0 8px; }
.mode-switch button:last-of-type { border-radius: 0 8px 8px 0; border-left: 0; }
.mode-switch button.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.lot-table .p-wrap { display: none; position: relative; }
.lot-table .p-suffix { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.lot-table .cell-input.p { padding-right: 22px; }
.lot-table.mode-pct .cell-input.q { display: none; }
.lot-table.mode-pct .p-wrap { display: inline-block; }
.lot-table.mode-pct .cell-input.p { background: #f6f8fd; border-color: #cdd6ea; }
.rowsum-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
/* 카페24 연결: 승인 후 주소 붙여 넣기 */
.c24-steps { margin: 14px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.8; }
.c24-paste { align-items: stretch; }
.c24-paste .btn, .c24-paste .cell-input { height: 40px; }
.c24-paste a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.c24p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.c24p-stats > div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; background: #fbfaf7; }
.c24p-stats b { font-size: 18px; }
.c24p-stats .muted { font-size: 12px; }
/* 머리글 클릭 정렬 */
.lot-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.lot-table th.sortable:hover { color: var(--navy); }
.lot-table th.sortable::after { content: '↕'; margin-left: 4px; font-size: 11px; color: #cbc2b2; }
.lot-table th.sortable.asc::after { content: '▲'; color: var(--navy); }
.lot-table th.sortable.desc::after { content: '▼'; color: var(--navy); }
.lot-table th.sortable.asc, .lot-table th.sortable.desc { color: var(--navy); font-weight: 700; }
/* 품목 줄 아래 배정 근거 코멘트 */
.lot-table tr[data-i] td { border-bottom: 0; padding-bottom: 4px; }
.lot-table tr.note-row td { padding-top: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
/* 배정 근거 라벨 (품목 정보 아래) */
.note-label { display: inline-block; font-size: 12px; color: var(--muted); padding: 1px 8px; border-radius: 6px; background: #f4f6fb; }
.note-label b { color: var(--q-blue); font-weight: 700; }
.note-label.new { background: var(--cream); color: var(--burgundy); font-weight: 600; }
.note-label.none { background: #f1f1f1; }
.note-arrow { color: #b9b0a0; font-size: 13px; }
/* 채널 입력칸 바로 아래 비중: 숫자 + 미니 막대 */
.note-cell { padding-top: 0 !important; }
.note-pct { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; width: 72px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.note-pct .bar { flex: 1; height: 5px; border-radius: 3px; background: #ece7dd; overflow: hidden; }
.note-pct .bar i { display: block; height: 100%; background: #9aa6c4; border-radius: 3px; }
.note-pct.hi { color: var(--navy); font-weight: 700; }
.note-pct.hi .bar i { background: var(--navy); }
.note-pct.fixed { color: #a39a8b; }
.note-pct.fixed .bar i { background: #cfc4ae; }
.lot-table tr.note-row.is-done td { opacity: .65; }
.lot-table tr.is-sel + tr.note-row td { background: var(--cream); }
.lot-table tr.hidden, .lot-table tr.note-row.hidden { display: none; }
.min-filter { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.min-filter input { width: 16px; height: 16px; accent-color: var(--navy); }
/* 추천 근거 (입고 배정 영역 하단) */
.basis:empty { display: none; }
.basis { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 8px; background: #fbfaf7; font-size: 13.5px; line-height: 1.6; }
.basis-title { font-size: 12px; font-weight: 700; color: var(--navy); letter-spacing: .04em; margin-bottom: 2px; }
.lot-detail .result .notice { margin: 0 0 14px; }
.lot-table tfoot td { padding-top: 12px; padding-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-row select, .form-row input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 110px; }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.pick-list button { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 9px 10px; font-size: 13.5px; }
.pick-list button:hover { background: var(--accent-soft); }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-top: 12px; }
.notice.ok { background: #e7f4ec; color: var(--ok); }
.notice.err { background: #fdecea; color: var(--danger); }
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.ratio-grid input { width: 100%; }
@media (max-width: 640px) {
  .pick-list button { grid-template-columns: 1fr auto; }
  .pick-list button .pc { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
}
