:root {
  --blue: #1a5fd0; --blue-l: #e8f0fd; --line: #d9dde3; --head: #f3f5f8; --text: #222; --muted: #7a818c;
  --pink: #f7d9dc; --teal: #cdeef0; --green: #c4e8d3; --purple: #dccbe0; --yellow: #fbf1c7; --rblue: #d6e6fa; --gray: #e6e6e6; --red: #f4b9b9;
  --orange: #f07a12;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: 13px; color: var(--text); background: #fff; }
a { color: inherit; text-decoration: none; }
[x-cloak] { display: none !important; }

/* ---------- 상단 ---------- */
.topbar { display: flex; align-items: center; gap: 24px; height: 46px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 20px; letter-spacing: -1px; }
.logo small { font-size: 11px; font-weight: 600; margin-left: 2px; color: var(--muted); }
.topmenu { display: flex; gap: 4px; flex: 1; }
.topmenu a { padding: 5px 12px; border-radius: 4px; color: #444; }
.topmenu a.on { background: var(--blue-l); color: var(--blue); font-weight: 700; }
.userbox { color: var(--muted); display: flex; gap: 12px; align-items: center; }
.userbox a { color: var(--blue); }

.layout { display: flex; height: calc(100% - 46px); }
.sidebar { width: 190px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; background: #fbfbfc; }
.sidebar .grp { font-weight: 700; padding: 8px 8px 4px; color: #333; }
.sidebar a { display: block; padding: 5px 8px 5px 18px; color: #666; border-radius: 4px; }
.sidebar a:hover { background: #eef1f5; }
.sidebar a.on { color: var(--blue); font-weight: 700; background: var(--blue-l); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { flex: 1; overflow: auto; padding: 12px 16px 70px; }

/* ---------- 공통 ---------- */
.title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.title-row h1 { font-size: 16px; margin: 0 12px 0 0; }
.btn { border: 1px solid #c8cdd4; background: #fff; border-radius: 4px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: #333; white-space: nowrap; font-family: inherit; }
.btn:hover { background: #f4f6f9; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #154fae; }
.btn.danger { color: #c0392b; border-color: #e3b4ae; }
.btn:disabled { opacity: .5; cursor: default; }
input.inp, select.inp, textarea.inp { border: 1px solid #c8cdd4; border-radius: 4px; padding: 5px 8px; font-size: 12.5px; font-family: inherit; background: #fff; }
input.inp:focus, select.inp:focus, textarea.inp:focus { outline: 2px solid #b9cff5; border-color: var(--blue); }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tab { border: 1px solid #cfd8e6; background: #f4f7fc; color: #4a6aa0; border-radius: 14px; padding: 3px 11px; font-size: 12px; cursor: pointer; }
.tab b { margin-left: 3px; font-weight: 600; }
.tab.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab.warn { border-color: #f0b27a; background: #fff4ea; color: #c0560f; }
.tab.warn.on { background: var(--orange); color: #fff; }

.pager { display: flex; gap: 4px; align-items: center; margin: 4px 0 8px; font-size: 12px; }
.pager button { border: none; background: none; cursor: pointer; padding: 2px 6px; border-radius: 10px; color: #666; }
.pager button.on { background: var(--blue); color: #fff; }

/* ---------- 이카운트형 그리드 ---------- */
.grid-wrap { border: 1px solid var(--line); overflow: auto; max-height: calc(100vh - 250px); }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
.grid th { background: var(--head); position: sticky; top: 0; z-index: 2; font-weight: 600; color: #444; border: 1px solid var(--line); padding: 7px 5px; white-space: nowrap; }
.grid td { border: 1px solid var(--line); padding: 6px 6px; vertical-align: middle; }
.grid tbody tr:hover td { filter: brightness(0.97); }
.grid td.no { color: #aaa; font-size: 11px; text-align: center; width: 30px; }
.grid td.doc { font-weight: 700; font-size: 13px; white-space: nowrap; cursor: pointer; }
.grid td.doc:hover { text-decoration: underline; }
.grid td.shop { font-weight: 700; text-align: center; white-space: nowrap; }
.grid td.prod { font-weight: 600; min-width: 230px; max-width: 320px; line-height: 1.35; text-transform: uppercase; }
.grid td.num { text-align: right; white-space: nowrap; }
.grid td.sm { font-size: 11px; white-space: nowrap; }
.grid td.qty-multi { background: var(--orange) !important; color: #fff; font-weight: 800; font-size: 15px; text-align: center; }
.grid td.qty { text-align: center; font-size: 14px; }
.grid tr.sel td { box-shadow: inset 0 0 0 9999px rgba(26, 95, 208, .10); }
.row-pink td { background: var(--pink); }
.row-green td { background: var(--green); }
.row-purple td { background: var(--purple); }
.row-yellow td { background: var(--yellow); }
.row-blue td { background: var(--rblue); }
.row-gray td { background: var(--gray); }
.row-red td { background: var(--red); }
.row-teal td { background: var(--teal); }
.txt-orange { color: var(--orange); }
.txt-blue { color: var(--blue); }
.txt-teal { color: #0b7d86; font-weight: 700; }
.txt-gray { color: #888; }
.txt-strike { color: #888; text-decoration: line-through; }
.alert-dot { display: inline-block; background: #e53935; color: #fff; border-radius: 9px; font-size: 10px; padding: 1px 6px; margin-left: 4px; }
.badge { display: inline-block; border-radius: 3px; padding: 1px 5px; font-size: 10.5px; background: #eef1f5; color: #555; }
.badge.ok { background: #dff3e6; color: #1e7b45; }
.badge.err { background: #fde3e1; color: #b3261e; }
.f-재고, .f-입고완료 { background: #d5f2e0; color: #17733f; }
.f-발주진행 { background: #dbe8fb; color: #1a5fd0; }
.f-발주필요 { background: #fde3e1; color: #b3261e; }
.f-SKU미등록 { background: #fff0d6; color: #a15c00; }
.fbadges { display: flex; gap: 3px; flex-wrap: wrap; }
.fbadges .badge { white-space: nowrap; }
.sku { font-family: Consolas, "Courier New", monospace; font-size: 11.5px; }

/* ---------- 하단 고정 툴바 ---------- */
.bottombar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 8px 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bottombar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------- 폼 ---------- */
.form-box { border: 1px solid var(--line); border-radius: 6px; padding: 14px 18px; background: #fff; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 100px 1fr 100px 1fr; gap: 8px 12px; align-items: center; max-width: 900px; }
.form-grid label { color: #555; font-size: 12.5px; }
.section-title { font-weight: 700; margin: 18px 0 8px; font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 20px; font-weight: 800; margin-top: 4px; }
.bar { height: 8px; background: #8fb1ea; border-radius: 4px; }

/* ---------- 모달 ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 50, .35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 40px; }
.modal { background: #fff; border-radius: 6px; width: min(1300px, 95vw); max-height: calc(100vh - 80px); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.sm { width: min(820px, 95vw); }
.modal-head { background: var(--blue); color: #fff; padding: 9px 14px; display: flex; justify-content: space-between; align-items: center; border-radius: 6px 6px 0 0; font-weight: 700; }
.modal-head button { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.modal-body { padding: 12px 14px; overflow: auto; flex: 1; }
.modal-foot { padding: 8px 14px; border-top: 1px solid var(--line); display: flex; gap: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr 110px 1fr; gap: 6px 10px; margin-bottom: 12px; }
.kv .k { color: var(--muted); }

#toast { position: fixed; right: 20px; bottom: 70px; z-index: 100; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: #263238; color: #fff; padding: 10px 14px; border-radius: 6px; max-width: 460px; white-space: pre-line; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#toast div.err { background: #b3261e; }

/* ---------- 로그인 ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100%; background: #f2f5f9; }
.login-box { background: #fff; padding: 34px 36px; border-radius: 10px; width: 340px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.login-box h1 { margin: 0 0 20px; font-size: 20px; }
.login-box input { width: 100%; margin-bottom: 10px; padding: 9px 10px; }
.login-box .btn { width: 100%; padding: 9px; font-size: 14px; }
.error { color: #c0392b; margin-bottom: 10px; }

@media (max-width: 800px) {
  .sidebar { display: none; }
  .topmenu { display: none; }
  .form-grid, .kv { grid-template-columns: 90px 1fr; }
  .page { padding: 10px 10px 80px; }
}

/* 가격 재확인 알림 팝업 */
.remind-bg { z-index: 200; align-items: center; padding-top: 0; }
.remind-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.remind-sku { font-size: 16px; }
.remind-memo { margin: 4px 0; white-space: pre-line; }
.remind-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.remind-act a.btn { text-decoration: none; }

/* 프로모션 이력 묶음 펼치기 */
.icon-btn { padding: 1px 5px; margin-right: 4px; line-height: 1; vertical-align: middle; }
.log-child td { background: #f7f9fc; }
.err-text { color: #c0392b; }

.inp.price-diff { background: #fff4c2; }

/* 출하 중지 경고 팝업 */
.stop-bg { z-index: 300; background: rgba(120, 0, 0, .45); }
.stop-head { background: #b3261e; }
.stop-msg { background: #fdecea; border: 1px solid #f1b0aa; color: #8c1d18; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-weight: 700; }
.stop-card { border-color: #e3b4ae; }
.stop-items { margin: 6px 0 0; font-weight: 700; }

/* 검색 상품 합계 / 출하대기 요약 */
.prodtotal { background: #fff8e1; border: 1px solid #f0d58a; border-radius: 6px; padding: 7px 12px; margin: 6px 0; }
.prodtotal .big { font-size: 18px; color: #b26a00; }
.pick-sum { background: #eef6ff; border: 1px solid #b9d4f2; border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.pick-sum .big { font-size: 18px; color: #0b57a4; }
