:root{font-family:Pretendard,"Noto Sans KR",Arial,sans-serif;color:#172033;background:#f4f6f9}*{box-sizing:border-box}body{margin:0}.page{max-width:1500px;margin:auto;padding:24px}header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}header h1{margin:0;font-size:28px}header p{margin:6px 0 0;color:#64748b}header a{color:#172033;text-decoration:none;border:1px solid #ccd4df;padding:9px 16px;border-radius:9px;background:#fff}.toolbar,.scan,.summary,.table-wrap{background:#fff;border:1px solid #dfe5ec;border-radius:14px}.toolbar{display:flex;align-items:end;gap:14px;padding:16px;margin-bottom:12px}.toolbar label,.scan label{display:grid;gap:6px;font-weight:700}.toolbar label:first-child{flex:1}.toolbar input,.scan input,#search{height:42px;border:1px solid #cbd5e1;border-radius:8px;padding:0 12px;font:inherit}.actions{display:flex;gap:7px}button{border:1px solid #cbd5e1;border-radius:8px;background:#fff;padding:10px 14px;font-weight:700;cursor:pointer}.primary{background:#176b52;color:#fff;border-color:#176b52}.ghost{color:#475569}.scan{display:flex;align-items:end;gap:10px;padding:16px;margin-bottom:12px}.scan form{display:flex;align-items:end;gap:8px}.scan input{width:330px}.scan #status{color:#176b52;font-weight:700;margin-left:6px}.scan #status.error{color:#c2413b}.summary{display:flex;justify-content:flex-end;gap:32px;padding:12px 18px;margin-bottom:12px}.summary div{display:flex;gap:9px;align-items:baseline}.summary span{color:#64748b}.summary strong{font-size:20px}.table-wrap{overflow:auto}.table-wrap table{width:100%;border-collapse:collapse;min-width:1080px}.table-wrap th{background:#f8fafc;color:#475569;font-size:13px;padding:11px 7px;border-bottom:1px solid #dfe5ec}.table-wrap td{padding:6px;border-bottom:1px solid #edf0f4}.table-wrap input,.table-wrap select{width:100%;height:35px;border:1px solid transparent;border-radius:6px;background:transparent;padding:0 6px;font:inherit}.table-wrap input:hover,.table-wrap input:focus,.table-wrap select:hover{border-color:#bac5d3;background:#fff}.table-wrap input[type=number]{text-align:right}.num{text-align:right;white-space:nowrap}.code{width:145px}.name{width:26%}.spec{width:13%}.maker{width:13%}.price{width:95px}.mode{width:105px}.qty{width:90px}.amount{width:110px}.remove{width:48px}.empty{text-align:center;padding:48px;color:#94a3b8}.print-head{display:none}dialog{border:0;border-radius:14px;padding:0;box-shadow:0 20px 60px #0004;width:min(650px,92vw)}dialog::backdrop{background:#0f172a88}.dialog{padding:18px}.dialog-head{display:flex;align-items:center;justify-content:space-between}.dialog-head h2{margin:0 0 14px}.dialog-head button{font-size:22px;border:0}.dialog #search{width:100%;margin-bottom:10px}.result,.history-item{display:flex;width:100%;text-align:left;justify-content:space-between;gap:10px;padding:12px;border:0;border-bottom:1px solid #e5e7eb;border-radius:0}.result small,.history-item small{display:block;color:#64748b;margin-top:3px}.history-actions{display:flex;gap:5px}.danger{color:#b42318}#blankBtn{margin-top:12px;width:100%}
@media(max-width:800px){.page{padding:12px}.toolbar{align-items:stretch;flex-direction:column}.actions{flex-wrap:wrap}.scan{align-items:stretch;flex-wrap:wrap}.scan form{flex:1}.scan label{flex:1}.scan input{width:100%}.summary{justify-content:space-between;gap:8px}.summary div{display:grid;gap:2px}}

/* 외부재고 페이지와 동일한 포털 프레임 및 색상 체계 */
:root{
  --bg:#b8b8b8;
  --panel:#fff;
  --panel-soft:#f8fbfd;
  --ink:#5f5650;
  --muted:#7b736d;
  --line:rgba(89,73,55,.22);
  --accent:#f18f01;
  --green:#2f7d45;
  --red:#b45252;
  --shadow:0 16px 28px rgba(82,60,46,.12);
  color:var(--ink);
  background:var(--bg);
  font-family:"IBM Plex Sans KR","Malgun Gothic","Segoe UI",sans-serif;
}
body{
  min-height:100vh;
  background:linear-gradient(180deg,#f4f7fb 0%,#e9eef5 100%);
}
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.62;
  background:linear-gradient(140deg,rgba(255,255,255,.34) 0 18%,transparent 18% 100%),linear-gradient(-16deg,rgba(255,255,255,.2) 0 16%,transparent 16% 100%);
}
.page{
  position:relative;
  width:min(1460px,calc(100vw - 40px));
  max-width:none;
  margin:0 auto;
  padding:42px 36px 36px;
}
header,.toolbar,.scan,.summary,.table-wrap{
  position:relative;
  border:1px solid var(--line);
  border-radius:0;
  background:var(--panel);
  box-shadow:var(--shadow);
}
header{padding:20px 22px;margin-bottom:18px;overflow:hidden}
header::before,.toolbar::before,.scan::before,.summary::before,.table-wrap::before{
  content:"";
  position:absolute;
  z-index:1;
  top:12px;
  left:16px;
  right:16px;
  height:1px;
  background:rgba(241,143,1,.34);
}
header h1{color:var(--accent);letter-spacing:-.02em}
header p{color:var(--muted)}
header a,button{
  min-height:38px;
  padding:8px 14px;
  border:1px solid rgba(241,143,1,.78);
  border-radius:0;
  background:var(--accent);
  color:#fffefc;
  font-weight:700;
}
header a:hover,button:hover{background:#d97900;border-color:rgba(217,121,0,.9);color:#fffefc}
button.ghost{background:#fff;color:var(--ink);border-color:var(--line)}
button.ghost:hover{background:var(--accent);color:#fffefc;border-color:rgba(217,121,0,.9)}
.primary{background:var(--accent);border-color:rgba(241,143,1,.78)}
.toolbar,.scan,.summary{padding:18px;margin-bottom:18px;overflow:hidden}
.toolbar input,.scan input,#search{
  min-height:44px;
  border-color:var(--line);
  border-radius:0;
  color:var(--ink);
}
.toolbar input:focus,.scan input:focus,#search:focus{
  outline:2px solid rgba(241,143,1,.22);
  border-color:rgba(241,143,1,.55);
}
.scan #status{color:var(--green)}
.scan #status.error,.danger{color:var(--red)}
.summary span{color:var(--muted)}
.table-wrap{overflow:auto;padding-top:26px}
.table-wrap th{background:var(--panel-soft);color:var(--ink);font-weight:900;border-bottom-color:var(--line)}
.table-wrap td{border-bottom-color:#edf1f6}
.table-wrap input,.table-wrap select{border-radius:0;color:var(--ink)}
.empty,.result small,.history-item small{color:var(--muted)}
dialog{border-radius:0;color:var(--ink)}
.dialog-head h2{color:var(--accent)}
.dialog-head button{background:transparent;color:var(--ink)}
.result,.history-item{background:#fff;color:var(--ink);border-color:#e5e7eb}
.result:hover,.history-item:hover{background:var(--panel-soft);color:var(--ink)}

@media(max-width:980px){.page{width:auto;padding:20px 18px 18px}}
@media(max-width:720px){.page{width:min(100vw - 24px,100%);padding:20px 0 18px}.toolbar,.scan,.summary{margin-bottom:14px}}
@media print{@page{size:A4 portrait;margin:8mm}body{background:#fff;font-size:9pt}.page{max-width:none;padding:0}.no-print,header{display:none!important}.print-head{display:flex;justify-content:space-between;align-items:end;margin-bottom:7px}.print-head h2{margin:0;font-size:15pt}.summary{border:0;padding:0 0 6px;margin:0;gap:18px}.summary strong{font-size:10pt}.table-wrap{border:0;overflow:visible}.table-wrap table{min-width:0;table-layout:fixed}.table-wrap th,.table-wrap td{padding:2px 4px;height:19px;border:1px solid #777}.table-wrap input{height:auto;padding:0;border:0}.mode,.remove{display:none}.name{width:31%}.spec{width:8%}.maker{width:17%}.expiry{width:13%}.price{width:10%}.qty{width:10%}.amount{width:11%}.empty{display:none}}
@media print{
  body::before,.summary::before,.table-wrap::before{display:none!important}
  .summary,.table-wrap{padding-top:0!important;background:#fff!important;box-shadow:none!important}
  .table-wrap th{background:#fff!important;color:#000!important;font-weight:700}
  .table-wrap td{background:#fff!important;color:#000!important}
  .table-wrap input,.table-wrap select{background:#fff!important;color:#000!important;box-shadow:none!important}
}
.table-wrap table{min-width:1000px}
.name{width:34%}
.spec{width:9%}
.maker{width:17%}
.remove{width:64px}
.table-wrap [data-remove]{padding:8px 10px;white-space:nowrap}
.batch{width:145px}
.expiry{width:125px}
@media print{
  .table-wrap table{min-width:0}
  .name{width:31%}.spec{width:8%}.maker{width:17%}
  .expiry{width:13%}.price{width:10%}.qty{width:10%}.amount{width:11%}
}

/* 낱알 입력과 완통/낱알 수량 편집 */
.scan{
  --scan-control-height:46px;
  align-items:flex-end;
  flex-wrap:wrap;
}
.scan #scanForm{
  display:flex;
  align-items:flex-end;
  flex-wrap:wrap;
  gap:10px;
}
.scan .barcode-field input{
  width:330px;
  height:var(--scan-control-height);
  min-height:var(--scan-control-height);
}
.scan .piece-mode-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  height:var(--scan-control-height);
  min-height:var(--scan-control-height);
  padding:3px 11px;
  border:2px solid #f18f01;
  background:#fff8e8;
  color:#6f4300;
  cursor:pointer;
  user-select:none;
}
.scan .piece-mode-toggle:hover,
.scan .piece-mode-toggle:has(input:checked){
  background:#f18f01;
  color:#fff;
  box-shadow:0 0 0 4px rgba(241,143,1,.16);
}
.scan .piece-mode-toggle input{
  flex:0 0 auto;
  width:22px;
  height:22px;
  min-height:0;
  margin:0;
  padding:0;
  accent-color:#176b52;
  cursor:pointer;
}
.piece-mode-toggle span{
  display:grid;
  gap:0;
  line-height:1.1;
}
.piece-mode-toggle b{font-size:15px}
.piece-mode-toggle small{font-size:11px;font-weight:700;white-space:nowrap}
.scan #scanForm > button,
.scan #manualBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:var(--scan-control-height);
  min-height:var(--scan-control-height);
  margin:0;
  white-space:nowrap;
}
.scan #pieceEntryForm{
  display:flex;
  align-items:flex-end;
  gap:9px;
  flex:1 1 560px;
  padding:11px 13px;
  border:2px solid #2f7d45;
  background:#edf8f0;
  box-shadow:0 0 0 4px rgba(47,125,69,.1);
}
.scan #pieceEntryForm[hidden]{display:none!important}
.scan #pieceEntryForm label{
  display:grid;
  flex:1;
  gap:5px;
  color:#205c33;
}
.scan #pieceEntryForm input{
  width:100%;
  border:2px solid #2f7d45;
  background:#fff;
  font-size:18px;
  font-weight:800;
}
.scan #status{
  flex:1 1 260px;
  display:flex;
  align-items:center;
  align-self:flex-end;
  min-height:var(--scan-control-height);
  margin-left:0;
}
.qty{width:105px}
.table-wrap .quantity-button{
  display:grid;
  place-items:center;
  gap:2px;
  width:100%;
  min-width:88px;
  min-height:43px;
  padding:5px 8px;
  border:1px solid rgba(47,125,69,.45);
  background:#f1f8f3;
  color:#285d38;
  text-align:center;
  line-height:1.25;
}
.table-wrap .quantity-button:hover,
.table-wrap .quantity-button:focus-visible{
  border-color:#2f7d45;
  background:#dff1e4;
  color:#174627;
  outline:2px solid rgba(47,125,69,.2);
}
.quantity-button span{
  display:flex;
  justify-content:center;
  align-items:baseline;
  width:100%;
  gap:4px;
}
.quantity-button .pack-quantity,
.quantity-button .piece-quantity{font-size:15px;font-weight:900}
.quantity-button .piece-quantity{color:#285d38}
@keyframes recently-added-outline{
  0%{outline-color:#f18f01}
  55%{outline-color:rgba(241,143,1,.72)}
  100%{outline-color:rgba(241,143,1,0)}
}
.table-wrap tr.recently-added{
  position:relative;
  z-index:2;
  outline:3px solid transparent;
  outline-offset:-3px;
  animation:recently-added-outline 1.8s ease-out both;
}
@media(prefers-reduced-motion:reduce){
  .table-wrap tr.recently-added{animation:none;outline-color:#f18f01}
}
.quantity-dialog-form{padding:22px}
.quantity-dialog-form .dialog-head h2{margin-bottom:4px}
#quantityProductName{margin:0 0 16px;color:var(--muted);font-weight:700}
.manual-quantity-dialog-form{padding:22px}
.manual-quantity-dialog-form .dialog-head h2{margin-bottom:4px}
#manualQuantityProductName{margin:0 0 16px;color:var(--muted);font-weight:700}
.manual-quantity-field{display:grid;gap:7px;font-weight:800}
.manual-quantity-field input{
  width:100%;
  height:50px;
  padding:0 12px;
  border:2px solid var(--accent);
  border-radius:0;
  font:inherit;
  font-size:22px;
  font-weight:900;
  text-align:center;
}
.manual-quantity-field input:focus{outline:3px solid rgba(241,143,1,.18)}
#manualQuantityMessage{min-height:20px;margin:8px 0 0;color:var(--muted);font-size:13px;font-weight:700}
.quantity-edit-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}
.quantity-edit-grid label{
  display:grid;
  gap:7px;
  font-weight:800;
}
.quantity-edit-grid input{
  width:100%;
  height:46px;
  padding:0 11px;
  border:1px solid var(--line);
  border-radius:0;
  font:inherit;
  font-size:18px;
  text-align:right;
}
.quantity-edit-grid input:focus{
  outline:2px solid rgba(241,143,1,.22);
  border-color:#f18f01;
}
.dialog-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:18px;
}
@media(max-width:800px){
  .scan #scanForm{width:100%}
  .scan .barcode-field{flex:1 1 230px}
  .scan .barcode-field input{width:100%}
  .scan .piece-mode-toggle{flex:0 0 auto}
  .scan #pieceEntryForm{flex-basis:100%}
  .quantity-edit-grid{grid-template-columns:1fr}
}
@media(max-width:520px){
  .scan .piece-mode-toggle{width:100%;justify-content:center}
  .scan #pieceEntryForm{align-items:stretch;flex-wrap:wrap}
  .scan #pieceEntryForm label{flex-basis:100%}
  .summary{display:grid;grid-template-columns:repeat(2,1fr)}
}
@media print{
  .qty{width:10%}
  .table-wrap .quantity-button{
    min-width:0;
    min-height:0;
    padding:0;
    border:0;
    background:#fff;
    color:#000;
    font-size:8pt;
  }
}
