/* 라바짜블루 재고·발주 — 모바일 우선. 최대 폭 560px, 터치 타깃 44px 이상. */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202c;
  --ink-2: #5b6878;
  --ink-3: #8b97a6;
  --line: #e3e8ef;
  --brand: #1b4fa0;
  --brand-ink: #ffffff;
  --brand-soft: #e8effa;
  --warn: #b3541e;
  --warn-soft: #fff2e6;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --ok: #1d6f42;
  --ok-soft: #e7f5ec;
  --radius: 14px;
  --tab-h: 62px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 8px 20px rgba(16, 32, 56, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px);
  word-break: keep-all;
}

a { color: var(--brand); text-decoration: none; }

button, input, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 14px; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand);
  color: var(--brand-ink);
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 17px; }
.brand small { font-weight: 500; opacity: .78; margin-left: 6px; font-size: 12px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px;
  border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 14px; font-weight: 700;
}
.chip:active { background: rgba(255, 255, 255, .28); }
.iconbtn {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: #fff; border-radius: 12px; font-size: 13px; opacity: .9;
}

/* ---------- 본문 ---------- */
main { padding: 14px 0 20px; }
.page-head { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 12px; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--ink-2); font-size: 13px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 10px 12px; }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }

.banner {
  border-radius: 12px; padding: 10px 12px; font-size: 13px;
  background: var(--brand-soft); color: #123a75;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner b { font-weight: 800; }

.progress { height: 8px; border-radius: 999px; background: #e6ebf2; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* ---------- 입력 ---------- */
.field { display: block; }
.field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-weight: 700; font-size: 15px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f3c9c5; background: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: 13px; border-radius: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 목록 행 ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 10px;
  padding: 12px 14px; border-top: 1px solid var(--line);
}
.item-row:first-child { border-top: 0; }
.item-row .nm { font-weight: 700; }
.item-row .meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.item-row .meta b { color: var(--ink); font-weight: 700; }
.item-row.missing { background: #fffdf3; }
.item-row.done { background: #fafcff; }

.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 20px; font-weight: 700; line-height: 1;
}
.stepper input {
  width: 84px; height: 44px; text-align: center; font-size: 18px; font-weight: 800;
  border: 1px solid var(--line); border-radius: 12px; padding: 0 6px;
}
.stepper input.empty { border-color: #e9c168; background: #fffdf3; }

.group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 4px 6px;
}
.group-head .t { font-weight: 800; }
.group-head .t small { font-weight: 600; color: var(--ink-3); margin-left: 6px; }
.channel-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 800; vertical-align: 2px;
}
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; background: #eef1f5; color: var(--ink-2);
}
.badge.low { background: var(--warn-soft); color: var(--warn); }
.badge.urgent { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.hq { background: #efe9fb; color: #5b3ea8; }

.check {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid #c6d0dd; background: #fff;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; margin-top: 2px;
}
.check.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 하단 고정 CTA ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  z-index: 15; background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.actionbar .in {
  max-width: 560px; margin: 0 auto; padding: 10px 14px;
  display: flex; gap: 8px; align-items: center;
}
.actionbar .sum { flex: 1; font-size: 13px; color: var(--ink-2); }
.actionbar .sum b { display: block; font-size: 17px; color: var(--ink); }
body.has-actionbar { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 86px); }

/* ---------- 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 18;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-3); font-size: 12px; font-weight: 700;
}
.tabbar a .dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.tabbar a.on { color: var(--brand); }
.tabbar a.on .dot { background: var(--brand); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi .s { font-size: 11px; color: var(--ink-3); }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr 64px; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 10px; border-radius: 999px; background: #edf1f6; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th { font-size: 11px; color: var(--ink-3); font-weight: 700; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 시트·모달 ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 20, 35, .42);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-back.center { align-items: center; }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  animation: up .16s ease-out;
}
.sheet-back.center .sheet { border-radius: 18px; margin: 16px; max-width: 420px; width: auto; }
/* 시트는 열릴 때 표시하고 display:none 으로 두지 않는다 — display:none 이면 애니메이션이 보이지 않는다 */
@keyframes up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 2px 0 4px; font-size: 16px; }
.sheet .sheet-val {
  font-size: 34px; font-weight: 800; text-align: center; letter-spacing: -.02em;
  padding: 6px 0 2px;
}
.sheet .sheet-hint { text-align: center; font-size: 12px; color: var(--ink-3); }
.sheet .quick { display: flex; gap: 6px; justify-content: center; margin: 10px 0 12px; flex-wrap: wrap; }
.sheet .quick button { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: #f8fafc; font-weight: 700; font-size: 13px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.keypad button {
  height: 52px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 20px; font-weight: 700;
}
.keypad .ok { background: var(--brand); border-color: var(--brand); color: #fff; }
.sheet .sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.sheet .sheet-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%) translateY(10px);
  background: #16202c; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 60; opacity: 0; pointer-events: none; transition: all .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }

.empty { text-align: center; padding: 26px 14px; color: var(--ink-2); }
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

.footer-note { color: var(--ink-3); font-size: 12px; line-height: 1.5; padding: 4px 2px 10px; }

.demo-badge {
  background: #fff4d6; color: #7a5200; font-size: 12px; font-weight: 700;
  padding: 6px 14px; text-align: center;
}

@media (prefers-color-scheme: dark) {
  /* 매장 폰에서 다크 모드가 켜져 있어도 흰 카드 그대로 읽히게 한다(색 반전은 하지 않는다) */
}
