/* 디자인 교회 창고 및 재고 관리 — 모바일 우선 스타일 */
:root {
  --primary: #1e3a8a;
  --primary-d: #152a63;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --nav-h: 60px;
  --header-h: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }

/* 헤더 */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--primary); color: #fff; display: flex; align-items: center;
  padding: 0 12px; z-index: 50; gap: 8px;
  padding-top: env(safe-area-inset-top);
}
#header-title { font-size: 17px; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-user { font-size: 12px; opacity: .9; }
.icon-btn { background: none; border: none; color: #fff; font-size: 28px; line-height: 1; padding: 0 6px; cursor: pointer; }

/* 메인 */
#view {
  padding: 14px;
  padding-top: calc(var(--header-h) + 14px + env(safe-area-inset-top));
  padding-bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; min-height: 100vh;
}
/* 인증 화면은 헤더/네비 없이 풀스크린 */
body.auth-mode #view { padding-top: 24px; }

/* 하단 네비 */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; z-index: 50; padding-bottom: env(safe-area-inset-bottom);
}
#bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px;
}
#bottom-nav a .ico { font-size: 20px; }
#bottom-nav a.active { color: var(--primary); font-weight: 600; }

/* 카드 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card.tappable:active { background: #fafafa; }

/* 통계 그리드 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.alert .num { color: var(--danger); }

/* 리스트 아이템 */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .li-right { text-align: right; white-space: nowrap; }

/* 뱃지 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.qty { background: #eef2ff; color: var(--primary-d); }
.badge.low { background: #fef2f2; color: var(--danger); }
.badge.ok { background: #f0fdf4; color: var(--success); }
.badge.tag { background: #f3f4f6; color: #374151; margin-right: 4px; }
.badge.in { background: #f0fdf4; color: var(--success); }
.badge.out { background: #fef2f2; color: var(--danger); }
.badge.pending { background: #fffbeb; color: var(--warn); }
.badge.approved { background: #f0fdf4; color: var(--success); }
.badge.rejected { background: #f3f4f6; color: var(--muted); }

/* 폼 */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; background: #fff; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input.input-invalid { border-color: var(--danger); background: #fff7f7; }
input.input-invalid:focus { border-color: var(--danger); }
.field-hint { margin-top: 4px; }
/* 폼 안내문 */
.form-intro {
  background: #eef2ff; border: 1px solid #dbe4ff; color: #334155;
  font-size: 12.5px; line-height: 1.55; padding: 10px 12px; border-radius: 10px; margin-bottom: 6px;
}
.field-desc { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 3px 0 2px; }
.btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 16px; text-align: center; text-decoration: none;
  white-space: nowrap;
}
.btn:active { background: var(--primary-d); }
.btn.secondary { background: #f3f4f6; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; display: inline-block; padding: 8px 14px; font-size: 14px; margin: 0; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { margin-top: 0; }

/* 검색바 */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { margin: 0; }

/* 인증 화면 */
.auth-wrap { max-width: 380px; margin: 8vh auto 0; padding: 0 8px; }
.auth-logo { text-align: center; font-size: 40px; margin-bottom: 8px; }
.auth-wrap h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.auth-wrap .sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* 기타 */
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { height: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.err-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 20px 0 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.scan-box { aspect-ratio: 1; background: #000; border-radius: var(--radius); overflow: hidden; position: relative; margin-bottom: 12px; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 토스트 */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
  z-index: 100; max-width: 90%; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* 모달 */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; display: flex; align-items: flex-end; }
.modal { background: #fff; width: 100%; max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 20px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 12px; }

@media (min-width: 480px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }

/* QR 라벨 시트 */
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qr-label {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 8px; text-align: center;
  background: #fff; break-inside: avoid; page-break-inside: avoid;
}
.qr-label .qr-img { display: flex; justify-content: center; align-items: center; aspect-ratio: 1; }
.qr-label .qr-img svg { width: 100%; height: auto; max-width: 150px; }
.qr-label .qr-code { font-weight: 700; font-size: 14px; margin-top: 6px; letter-spacing: .04em; }
.qr-label .qr-type { font-size: 11px; color: var(--muted); }
.qr-label .qr-title { font-size: 13px; font-weight: 600; margin-top: 2px; }
.qr-label .qr-sub { font-size: 11px; color: var(--muted); }
.qr-thumb svg { width: 56px; height: 56px; display: block; }

/* 도움말 페이지 */
.help-sec { background: var(--card); border-radius: 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden; }
.help-sec > summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none; font-size: 15px; }
.help-sec > summary::-webkit-details-marker { display: none; }
.help-sec > summary::after { content: '▾'; float: right; color: var(--muted); }
.help-sec[open] > summary::after { content: '▴'; }
.help-body { padding: 0 16px 14px; font-size: 14px; color: #374151; line-height: 1.6; }
.help-body ul { margin: 4px 0; padding-left: 18px; }
.help-body li { margin: 5px 0; }
.help-body p { margin: 8px 0; }
.help-body code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table th, .help-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.help-table th { background: #f8fafc; }
.help-table th:nth-child(n+2), .help-table td:nth-child(n+2) { text-align: center; width: 64px; }

/* 인쇄 */
@media print {
  #app-header, #bottom-nav, #toast, .no-print { display: none !important; }
  body { background: #fff; }
  #view { padding: 0 !important; max-width: none; }
  .qr-sheet { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .qr-label { border: 1px solid #999; }
}
