:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e7ee;
  --primary: #1f6feb; --primary-text: #fff; --danger: #d93025; --warn: #e8a100; --ok: #188038;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px; padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
#topbar {
  position: sticky; top: 0; z-index: 5; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
}
#topbar h1 { font-size: 18px; margin: 0; }
#who { display: block; font-size: 13px; opacity: .9; }
.top-actions { display: flex; gap: 6px; }
.top-actions button { background: rgba(255,255,255,.18); color: #fff; padding: 8px 12px; font-weight: 600; }
.top-actions button[hidden] { display: none; }
#fontsize small { font-size: 12px; }
main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }

#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  flex: 1; text-align: center; padding: 10px 0 12px; color: var(--muted); text-decoration: none; font-size: 13px;
}
#tabs a { position: relative; }
#tabs a > span { display: block; font-size: 20px; }
#tabs a b { position: absolute; top: 2px; left: 55%; }
#tabs a b .badge { padding: 1px 6px; font-size: 11px; background: var(--danger); color: #fff; }
#tabs a.on { color: var(--primary); font-weight: 600; }

.card { background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }
.name { font-weight: 600; font-size: 16px; }
.total { font-weight: 700; color: var(--primary); text-align: right; word-break: keep-all; }
.lots { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.lot { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; gap: 8px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: var(--muted); white-space: nowrap; }
.badge.red { background: #fde8e7; color: var(--danger); }
.badge.yellow { background: #fff4d6; color: #9a6b00; }
.badge.green { background: #e6f4ea; color: var(--ok); }
.badge.blue { background: #e7f0fe; color: var(--primary); }
h2 { font-size: 17px; margin: 8px 0 12px; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
button {
  border: 0; border-radius: 10px; padding: 11px 14px; background: #e9edf3; color: var(--text); cursor: pointer; white-space: nowrap;
}
button.primary { background: var(--primary); color: var(--primary-text); font-weight: 600; }
button.danger { background: #fde8e7; color: var(--danger); }
button.small { padding: 6px 10px; font-size: 13px; }
button.block { width: 100%; margin-top: 12px; }
button:disabled { opacity: .5; }
.scan-btn { font-size: 20px; padding: 9px 13px; }
.qty { display: flex; gap: 6px; }
.qty input { width: 90px; flex: none; }
.qty select { width: auto; flex: 1; }
.filters { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { padding: 7px 12px; font-size: 14px; }
.filters button.on { background: var(--primary); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
table.items { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.items td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.items td.num { text-align: right; word-break: keep-all; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
.sheet {
  background: var(--card); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 8px; }
#reader { width: 100%; border-radius: 10px; overflow: hidden; background: #000; min-height: 200px; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
.login { max-width: 360px; margin: 40px auto; }
.conv { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.conv[hidden] { display: none; }
.conv input { width: 90px; }
label.check { display: flex; gap: 6px; align-items: center; }
label.check input { width: auto; }

/* 글자 크기: 화면 전체를 비율로 키움 (보통/크게/아주 크게) */
/* 화면 위에 고정된 하단 탭은 확대하면 화면 밖으로 밀려나서, 내용·상단·팝업만 확대하고 탭은 글자만 키움 */
html[data-size="1"] #topbar, html[data-size="1"] #view, html[data-size="1"] .sheet { zoom: 1.15; }
html[data-size="2"] #topbar, html[data-size="2"] #view, html[data-size="2"] .sheet { zoom: 1.3; }
html[data-size="1"] #tabs a { font-size: 15px; }
html[data-size="1"] #tabs a > span { font-size: 23px; }
html[data-size="2"] #tabs a { font-size: 16px; font-weight: 600; }
html[data-size="2"] #tabs a > span { font-size: 26px; }
html[data-size="1"] #toast { font-size: 16px; }
html[data-size="2"] #toast { font-size: 18px; }
.install-steps { font-size: 17px; line-height: 1.7; padding-left: 22px; margin: 8px 0 0; }
.block-link { display: block; text-align: center; padding: 12px; margin-top: 12px; border-radius: 10px; background: #e7f0fe; color: var(--primary); font-weight: 600; text-decoration: none; }
.lot > span:last-child { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; text-align: right; word-break: keep-all; }
.edit-banner { background: #fff4d6; border: 2px solid var(--warn); }
.pending { border: 2px solid #cfe0fd; }
.pending .lot { padding: 8px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.just-added { animation: just-added 2s ease-out; }
@keyframes just-added { 0%, 40% { box-shadow: 0 0 0 3px var(--primary); background: #e7f0fe; } 100% { box-shadow: 0 1px 2px rgba(0,0,0,.05); background: var(--card); } }
.date-pick { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin-bottom: 10px; }
.date-pick[hidden] { display: none; }
.log-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.short { font-size: 12px; font-weight: 700; color: #fff; background: var(--danger); border-radius: 6px; padding: 1px 6px; margin-top: 2px; display: inline-block; }

/* 긴 내용이 카드 밖으로 밀어내지 않게 */
.row > .grow, .lot > span { min-width: 0; }
/* 재고 카드: 품명이 너무 좁아지지 않게 재고 수량 칸은 절반까지만 */
.row.between > .grow { flex: 1 1 50%; }
.total { max-width: 50%; }
.badge { max-width: 100%; }
/* 발주 카드 머리: 날짜 쪽이 줄바꿈되고 상태 배지(요청/일부 출고 등)는 항상 다 보이게 */
.row.between > div:first-child { min-width: 0; }
.row.between > .badge { flex-shrink: 0; }
/* 유통기한 배지 등은 좁으면 두 줄로 */
.lot > .badge { white-space: normal; text-align: left; word-break: keep-all; overflow-wrap: normal; }
/* 긴 바코드·숫자는 필요하면 줄바꿈 */
.card, .sheet { overflow-wrap: anywhere; }
table.items td:first-child { overflow-wrap: anywhere; }
