* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "맑은 고딕", sans-serif; background: #f3f5f8; color: #1a1d24; }
body { padding-bottom: env(safe-area-inset-bottom); }

/* 로그인 오버레이 */
.overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #0b5fff 0%, #4a8bff 100%); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100; }
.overlay.hidden { display: none; }
.login-card { background: #fff; border-radius: 20px; padding: 40px 28px; width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.25); text-align: center; }
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-sub { color: #6b7280; margin: 4px 0 24px; font-size: 14px; }
.btn-google { width: 100%; background: #0b5fff; color: #fff; border: none; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-google:hover { background: #0a52e0; }
.btn-google:disabled { opacity: .6; cursor: wait; }
.btn-primary { width: 100%; background: #0b5fff; color: #fff; border: none; padding: 12px; border-radius: 10px; font-weight: 600; margin-top: 8px; cursor: pointer; }
.warn { color: #d97706; font-size: 13px; margin: 16px 0 8px; }
.hint { color: #6b7280; font-size: 11px; margin: 8px 0 0; line-height: 1.5; }
.login-card label { display: block; text-align: left; font-size: 12px; color: #6b7280; margin: 12px 0 4px; }
.login-card input[type=text] { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; }
.error { color: #dc2626; font-size: 13px; margin-top: 12px; white-space: pre-wrap; }

/* 상단바 */
.topbar { position: sticky; top: 0; background: #0b5fff; color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.1); padding-top: calc(14px + env(safe-area-inset-top)); }
.topbar h1 { margin: 0; font-size: 18px; }
.icon-btn { background: rgba(255,255,255,.15); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; }

/* 메인 */
.main { padding: 16px; padding-bottom: 80px; max-width: 600px; margin: 0 auto; }

/* 카드 */
.card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-label { display: block; font-size: 13px; font-weight: 600; color: #6b7280; margin-bottom: 10px; }

/* 바코드 입력 */
.barcode-row { display: flex; gap: 8px; }
#barcode-input, #g-barcode-input { flex: 1; padding: 14px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 16px; font-family: ui-monospace, monospace; min-width: 0; }
#barcode-input:focus, #g-barcode-input:focus { border-color: #0b5fff; outline: none; }
.btn-icon { background: #f3f4f6; border: none; width: 52px; border-radius: 10px; font-size: 22px; cursor: pointer; }
.btn-icon:active { background: #e5e7eb; }
#scanner-area { margin-top: 12px; }
#qr-reader { width: 100%; }
#qr-reader video { border-radius: 10px; }
.btn-secondary { width: 100%; background: #6b7280; color: #fff; border: none; padding: 10px; border-radius: 10px; margin-top: 8px; cursor: pointer; }
.product-info { margin-top: 12px; padding: 12px; background: #f0f7ff; border-left: 3px solid #0b5fff; border-radius: 6px; }
.pi-row { display: flex; gap: 10px; padding: 4px 0; font-size: 14px; }
.pi-label { color: #6b7280; min-width: 44px; font-size: 12px; }
.pi-row span:last-child { flex: 1; word-break: keep-all; }

/* 수량 */
.qty-row { display: flex; gap: 6px; align-items: center; }
.qty-btn { flex: 0 0 auto; background: #f3f4f6; border: none; padding: 12px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; min-width: 48px; }
.qty-btn:active { background: #d1d5db; }
#qty-input, #g-qty-input { flex: 1; text-align: center; font-size: 22px; font-weight: 600; padding: 10px; border: 2px solid #e5e7eb; border-radius: 8px; min-width: 0; }
#qty-input:focus, #g-qty-input:focus { border-color: #0b5fff; outline: none; }

/* 입출고 토글 */
.toggle-row { display: flex; gap: 8px; }
.toggle-btn { flex: 1; background: #f3f4f6; border: 2px solid transparent; padding: 14px 4px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; color: #6b7280; white-space: nowrap; }
.toggle-btn.active[data-type="입고"] { background: #ecfdf5; border-color: #10b981; color: #047857; }
.toggle-btn.active[data-type="출고"] { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.toggle-btn.active[data-type="재고조사"] { background: #f5f3ff; border-color: #8b5cf6; color: #6d28d9; }

/* 현재고 표시 */
.pi-stock { margin-top: 10px; padding: 9px 11px; background: #eef2ff; border-radius: 8px; font-size: 15px; color: #1e3a8a; }
.pi-stock b { font-size: 19px; }
.pi-stock.zero { background: #fef2f2; color: #b91c1c; }
.pi-stock.none, .pi-stock.loading { background: #f3f4f6; color: #9ca3af; font-size: 13px; }
.pi-stock-sub { font-size: 11px; color: #6b7280; font-weight: 400; }

/* 사유 */
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason-btn { background: #f3f4f6; border: 2px solid transparent; padding: 12px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.reason-btn.active { background: #eff6ff; border-color: #0b5fff; color: #0b5fff; font-weight: 600; }
.reason-custom { width: 100%; margin-top: 10px; padding: 12px; border: 2px solid #0b5fff; border-radius: 8px; font-size: 15px; }
.reason-custom:focus { outline: none; box-shadow: 0 0 0 3px rgba(11,95,255,.15); }

/* 작업자 */
.worker-row { display: flex; gap: 8px; }
#worker-select, #worker-input { flex: 1; padding: 12px; border: 2px solid #e5e7eb; border-radius: 8px; font-size: 14px; min-width: 0; }
#worker-select:focus, #worker-input:focus { border-color: #0b5fff; outline: none; }

/* 저장 버튼 */
.btn-save { width: 100%; background: #0b5fff; color: #fff; border: none; padding: 18px; border-radius: 14px; font-size: 17px; font-weight: 700; cursor: pointer; margin: 8px 0; box-shadow: 0 4px 12px rgba(11,95,255,.3); }
.btn-save:active { background: #0a52e0; transform: translateY(1px); }
.btn-save:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; }
.save-msg { text-align: center; font-size: 13px; margin: 4px 0 16px; min-height: 18px; }
.save-msg.ok { color: #047857; }
.save-msg.err { color: #dc2626; }

/* 최근 기록 */
.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-item { padding: 10px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.recent-item:last-child { border-bottom: none; }
.recent-meta { color: #6b7280; font-size: 11px; }
.recent-empty { color: #9ca3af; font-size: 13px; text-align: center; padding: 16px; }

/* 토스트 */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 12px 20px; border-radius: 24px; font-size: 14px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90%; }

@media (min-width: 600px) { .main { padding: 24px; } }

/* 로그인 폼 입력 */
.login-card input[type=text], .login-card input[type=password] {
  width: 100%; padding: 13px 14px; border: 1px solid #d1d5db; border-radius: 10px;
  font-size: 15px; margin: 6px 0; box-sizing: border-box;
}
.login-card input:focus { outline: none; border-color: #0b5fff; box-shadow: 0 0 0 3px rgba(11,95,255,.12); }
#user-login .btn-primary, #admin-login .btn-google { margin-top: 10px; }
.link-btn { background: none; border: none; color: #6b7280; font-size: 13px; margin-top: 16px; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: #0b5fff; }

/* 상단바 우측 */
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-badge { color: #fff; font-size: 13px; opacity: .95; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-start; justify-content: center; padding: 20px; z-index: 150; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 440px; margin-top: 40px; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid #eef0f3; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .icon-btn { background: #f3f4f6; color: #374151; }
.modal-body { padding: 18px; }
.add-user input { width: 100%; padding: 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; margin: 6px 0; box-sizing: border-box; }
.add-user input:focus { outline: none; border-color: #0b5fff; }
.add-user .btn-primary { margin-top: 8px; }
.user-list-wrap { margin-top: 20px; }
.user-list { list-style: none; padding: 0; margin: 8px 0 0; }
.user-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f3f4f6; }
.ui-name { font-weight: 600; font-size: 15px; flex: 1; }
.ui-date { color: #9ca3af; font-size: 11px; }
.ui-del { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.ui-del:active { background: #fee2e2; }

/* 페이지 전환 */
.page[hidden] { display: none; }
.main { padding-bottom: 84px; }

/* 하단 탭바 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #fff; border-top: 1px solid #e5e7eb; padding-bottom: env(safe-area-inset-bottom); z-index: 40; box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.tab { flex: 1; background: none; border: none; padding: 10px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: #9ca3af; cursor: pointer; }
.tab .tab-ico { font-size: 22px; }
.tab.active { color: #0b5fff; font-weight: 600; }

/* 사이즈 강조 */
.pi-size { font-weight: 700; color: #0b5fff; }

/* 팔레트 적재 안내 */
.pallet-guide { background: #0b5fff; color: #fff; border-radius: 14px; padding: 18px; margin-bottom: 12px; text-align: center; box-shadow: 0 4px 14px rgba(11,95,255,.3); }
.pallet-guide .pg-label { font-size: 13px; opacity: .9; }
.pallet-guide .pg-size { font-size: 30px; font-weight: 800; margin: 4px 0; }
.pallet-guide .pg-item { font-size: 13px; opacity: .95; }

/* 출고완료 버튼 */
.btn-shipout { width: 100%; background: #059669; color: #fff; border: none; padding: 18px; border-radius: 14px; font-size: 17px; font-weight: 700; cursor: pointer; margin: 8px 0; box-shadow: 0 4px 12px rgba(5,150,105,.3); }
.btn-shipout:active { background: #047857; transform: translateY(1px); }
.btn-shipout:disabled { background: #9ca3af; box-shadow: none; }

/* 팔레트 현황 */
.pallet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pallet-total { font-size: 13px; color: #6b7280; font-weight: 600; }
.pallet { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.pallet.empty { opacity: .5; }
.pallet-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #f0f7ff; cursor: pointer; }
.pallet-name { font-weight: 700; font-size: 14px; color: #0b5fff; }
.pallet-qty { font-size: 13px; color: #374151; font-weight: 600; }
.pallet-items { padding: 0 12px; }
.pallet-items.collapsed { display: none; }
.p-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #f3f4f6; font-size: 13px; }
.p-item .pi-q { font-weight: 700; color: #0b5fff; min-width: 36px; text-align: right; }
.p-item .pi-t { flex: 1; word-break: keep-all; }
.p-item .pi-x { background: #fef2f2; color: #dc2626; border: none; border-radius: 6px; width: 26px; height: 26px; font-size: 14px; cursor: pointer; }
.pallet-empty-msg { color: #9ca3af; font-size: 12px; text-align: center; padding: 14px; }

/* ===== 그로스출고: 붉은색 테마 ===== */
.growth-mode .topbar { background: #dc2626; box-shadow: 0 2px 8px rgba(220,38,38,.25); }
.growth-mode .tab.active { color: #dc2626; }
#page-growth #g-barcode-input:focus, #page-growth #g-qty-input:focus { border-color: #dc2626; }
#g-product-info { background: #fef2f2; border-left-color: #dc2626; }
.pi-size { color: #dc2626; }
#page-growth .btn-save { background: #dc2626; box-shadow: 0 4px 12px rgba(220,38,38,.3); }
#page-growth .btn-save:active { background: #b91c1c; }
.pallet-guide { background: #dc2626; box-shadow: 0 4px 14px rgba(220,38,38,.3); }
.pallet-bar { background: #fef2f2; }
.pallet-name { color: #dc2626; }
.p-item .pi-q { color: #dc2626; }
.btn-shipout { background: #b91c1c; box-shadow: 0 4px 12px rgba(185,28,28,.35); }
.btn-shipout:active { background: #991b1b; }

/* ===== 제품실측 ===== */
.m-controls { display: flex; gap: 8px; }
#m-search { flex: 1; padding: 12px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 15px; min-width: 0; }
#m-search:focus { outline: none; border-color: #0b5fff; }
#m-refresh { background: #f3f4f6; }
.m-toggle { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: #374151; cursor: pointer; }
.m-toggle input { width: 18px; height: 18px; }
.m-summary { margin-top: 10px; font-size: 13px; color: #6b7280; }
.m-summary b { color: #dc2626; }

#m-list { display: flex; flex-direction: column; gap: 10px; }
.m-card { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 4px solid #10b981; }
.m-card.mismatch { border-left-color: #dc2626; }
.m-title { font-size: 14px; font-weight: 700; word-break: keep-all; line-height: 1.4; }
.m-sub { font-size: 11px; color: #9ca3af; margin: 3px 0 10px; }
.m-sub .mono { font-family: ui-monospace, monospace; }
.m-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.m-table th { font-size: 11px; color: #9ca3af; font-weight: 600; text-align: right; padding: 3px 4px; }
.m-table th:first-child { text-align: left; }
.m-table td { padding: 4px; text-align: right; border-top: 1px solid #f3f4f6; }
.m-table td:first-child { text-align: left; color: #6b7280; font-size: 11px; }
.m-cls { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 600; font-size: 12px; }
.m-cls.cou { background: #eff6ff; color: #0b5fff; }
.m-cls.sht { background: #f0fdf4; color: #059669; }
.m-card.mismatch .m-cls.cou { background: #fef2f2; color: #dc2626; }
.m-diff { font-weight: 700; }
.m-diff.hi { color: #dc2626; }
.m-empty { text-align: center; color: #9ca3af; padding: 30px; font-size: 14px; }
.m-card { cursor: pointer; }
.m-card:active { background: #f9fafb; }

/* 실측 입력 모달 */
.mm-product { background: #f0f7ff; border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.mm-product .mmp-name { font-weight: 700; font-size: 14px; word-break: keep-all; line-height: 1.4; }
.mm-product .mmp-sub { font-size: 11px; color: #6b7280; margin-top: 4px; }
.mm-product .mmp-sub .mono { font-family: ui-monospace, monospace; }
.mm-field { margin-bottom: 16px; }
.mm-field > label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.mm-row { display: flex; gap: 8px; }
.mm-row input { flex: 1; padding: 13px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 17px; text-align: center; min-width: 0; }
.mm-row input:focus { outline: none; border-color: #0b5fff; }
.mm-cam { width: 56px; background: #f3f4f6; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 22px; cursor: pointer; }
.mm-cam.has { background: #ecfdf5; border-color: #10b981; }
.mm-cam:active { background: #e5e7eb; }
.mm-thumb { display: block; width: 100%; max-height: 220px; object-fit: contain; margin-top: 8px; border-radius: 10px; border: 1px solid #e5e7eb; background: #fafafa; }
.mm-thumb[hidden] { display: none; }
