/* ===== 바자회 판매·재고 — 모바일 UI ===== */
:root {
  --bg: #eef1f0;
  --surface: #ffffff;
  --surface-2: #f1f5f3;
  --ink: #16211d;
  --ink-soft: #5e6b65;
  --line: #dde5e1;
  --primary: #0fa468;      /* 확실한 에메랄드 */
  --primary-deep: #0a7d4e;
  --primary-soft: #d8f1e5;
  --accent: #ff6a4d;       /* 선명한 코랄(판매/뱃지 포인트) */
  --accent-deep: #e4502f;
  --warn: #e08a2b;
  --warn-soft: #fbeed6;
  --danger: #e24b43;
  --danger-soft: #fbe3e1;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(20, 60, 45, 0.12);
  --shadow-soft: 0 2px 8px rgba(20, 60, 45, 0.08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(96px + var(--safe-b));
}

/* ---------- 헤더 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(238, 241, 240, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 720px; margin: 0 auto;
  padding: 11px 16px;
  padding-top: calc(11px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 { font-size: clamp(0.96rem, 4.2vw, 1.15rem); font-weight: 700; margin: 0;
  letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0; padding-right: 10px; }
.icon-btn {
  border: none; background: transparent; font-size: 1.25rem;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--line); }
.text-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: 0.85rem; font-weight: 600; padding: 7px 13px; border-radius: 10px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.text-btn:active { background: var(--line); }

main { max-width: 720px; margin: 0 auto; padding: 12px 12px 0; }

/* ---------- 공통 ---------- */
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.center { text-align: center; padding: 40px 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 0.95rem; margin: 0 0 10px; color: var(--ink-soft); font-weight: 600; }

.btn {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 1rem; font-weight: 700;
  padding: 13px 16px; border-radius: 13px; cursor: pointer;
  font-family: inherit; transition: transform .08s, background .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 3px 10px rgba(15, 164, 104, 0.28); }
.btn.primary:active { background: var(--primary-deep); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.ghost.danger { border-color: #ecc7c4; }
.btn.sm { padding: 9px 13px; font-size: 0.9rem; border-radius: 11px; }
.btn.block { width: 100%; }

/* CSV 가져오기 안내 */
.guide-steps { margin: 4px 0 14px; padding-left: 22px; line-height: 1.7; }
.guide-steps li { margin-bottom: 10px; }
.guide-steps b { color: var(--primary-deep); }
.guide-tip { background: var(--primary-soft); border-radius: 11px; padding: 11px 13px;
  font-size: 0.85rem; color: var(--ink); margin: 0 0 16px; line-height: 1.5; }

/* 안내 박스(기기별 저장 등) */
.info-note { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: 11px; padding: 12px 14px; margin: 4px 0 16px; font-size: 0.82rem; line-height: 1.6; color: var(--ink-soft); }
.info-note b { color: var(--ink); }
.info-note > b:first-child { display: block; margin-bottom: 4px; font-size: 0.88rem; }
.info-note u { text-decoration-color: var(--accent); text-underline-offset: 2px; }
.info-note.warn { border-left-color: var(--warn); background: var(--warn-soft); }

/* 마우스(데스크톱)에서 호버 피드백 — 클릭 가능함을 분명히 */
@media (hover: hover) {
  .btn:hover { border-color: var(--primary); color: var(--primary-deep);
    box-shadow: var(--shadow-soft); transform: translateY(-1px); }
  .btn.primary:hover { background: var(--primary-deep); border-color: var(--primary-deep);
    color: #fff; box-shadow: 0 6px 16px rgba(15, 164, 104, 0.36); }
  .btn.ghost:hover { background: var(--primary-soft); }
  .btn.danger:hover, .btn.ghost.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
  .text-btn:hover { border-color: var(--primary); color: var(--primary-deep); background: var(--primary-soft); }
  .linklike:hover { color: var(--accent-deep); }
  .prod-card:hover:not(:disabled) { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
  .stock-row:hover { border-color: var(--primary); }
  .tab-btn:hover { color: var(--primary-deep); }
  .method-btn:hover { border-color: var(--primary); color: var(--primary-deep); }
  .icon-btn:hover { background: var(--line); }
  .qty-stepper button:hover { border-color: var(--primary); color: var(--primary-deep); }
}

.list-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.head-btns { display: flex; gap: 8px; }

/* 온보딩(빈 상태) */
.onboard { text-align: center; padding: 30px 16px; max-width: 380px; margin: 0 auto; }
.onboard-logo {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 22px;
  background: var(--primary-soft); display: grid; place-items: center; font-size: 2.2rem;
}
.onboard h2 { font-size: 1.45rem; font-weight: 800; color: var(--ink); margin-bottom: 10px; letter-spacing: -0.02em; }
.onboard > .muted { line-height: 1.6; margin-bottom: 22px; }
.onboard-btns { display: flex; flex-direction: column; gap: 10px; }
.onboard-bulk {
  margin-top: 26px; padding-top: 22px; border-top: 1px dashed var(--line);
}
.onboard-bulk .muted { line-height: 1.6; margin-bottom: 12px; font-size: 0.85rem; }
.onboard-bulk b { color: var(--primary-deep); }
.stock-hint { margin: 0 2px 12px; font-size: 0.85rem; color: var(--ink-soft); }
.linklike { border: none; background: none; color: var(--primary-deep); font-weight: 700;
  font-family: inherit; font-size: 0.85rem; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- 판매(POS) 그리드 — 한 화면에 들어오게 압축 ---------- */
.sell-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
@media (min-width: 520px) { .sell-grid { grid-template-columns: repeat(3, 1fr); } }
.prod-card {
  position: relative; border: 1px solid var(--line);
  background: var(--surface); border-radius: 13px;
  padding: 10px 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-soft); font-family: inherit;
  transition: transform .06s, box-shadow .12s; text-align: left;
}
.prod-card:active { transform: scale(0.97); box-shadow: none; }
.prod-card.sold { opacity: 0.45; }
.prod-name { font-weight: 700; font-size: 0.95rem; color: var(--ink); line-height: 1.25; }
/* 항목명 앞 이모지 — 글자 크기에 맞춰 동일 사이즈 */
.ico { display: inline-block; width: 1.25em; margin-right: 4px; text-align: center;
  font-size: 1em; font-style: normal; }
.opt-tag { display: inline-block; font-size: 0.68rem; font-weight: 700; color: #fff;
  background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 3px; vertical-align: middle; }
.prod-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.prod-price { font-size: 0.95rem; color: var(--primary-deep); font-weight: 800; white-space: nowrap; }
.prod-price small { color: var(--ink-soft); font-weight: 500; }
.prod-stock { font-size: 0.74rem; color: var(--ink-soft); white-space: nowrap; }
.prod-stock.low { color: var(--warn); font-weight: 700; }
.prod-stock.out { color: var(--danger); font-weight: 700; }
.prod-badge {
  position: absolute; top: -7px; right: -7px;
  background: var(--accent); color: #fff; font-weight: 800;
  min-width: 24px; height: 24px; border-radius: 12px;
  display: grid; place-items: center; font-size: 0.8rem;
  box-shadow: var(--shadow); padding: 0 6px;
}
.sell-empty { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.sell-empty .btn { margin-top: 14px; }

/* ---------- 장바구니 바 ---------- */
.cart-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(66px + var(--safe-b)); z-index: 18;
  padding: 0 14px;
  max-width: 720px; margin: 0 auto;
}
.cart-summary {
  width: 100%; border: none; cursor: pointer;
  background: var(--primary-deep); color: #fff;
  border-radius: 14px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 6px 20px rgba(111, 144, 121, 0.4);
  font-family: inherit; font-size: 1rem;
}
.cart-count {
  background: rgba(255,255,255,0.25); min-width: 28px; height: 28px;
  border-radius: 14px; display: grid; place-items: center; font-weight: 800;
}
.cart-total { font-weight: 800; font-size: 1.1rem; }
.cart-cta { margin-left: auto; font-weight: 600; opacity: 0.95; }

/* ---------- 하단 탭바 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 19;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; padding-bottom: var(--safe-b);
  max-width: 720px; margin: 0 auto;
}
.tab-btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.74rem; color: var(--ink-soft); font-family: inherit; font-weight: 600;
  position: relative; transition: color .12s;
}
.tab-btn .ti { font-size: 1.4rem; line-height: 1; filter: grayscale(0.6); opacity: 0.55; transition: all .12s; }
.tab-btn.active { color: var(--primary-deep); font-weight: 800; }
.tab-btn.active .ti { filter: none; opacity: 1; transform: translateY(-1px); }
.tab-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 3px; border-radius: 2px; background: var(--primary-deep);
}

/* ---------- 재고 리스트 ---------- */
.stock-list { display: flex; flex-direction: column; gap: 10px; }
.stock-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-soft);
}
.stock-row.low { border-color: #ecd4b3; background: var(--warn-soft); }
.stock-row.out { border-color: #eec6c3; background: var(--danger-soft); }
.sr-emoji { font-size: 1.6rem; }
.sr-main { flex: 1; min-width: 0; }
.sr-name { font-weight: 700; }
.sr-opts { font-size: 0.82rem; color: var(--primary-deep); font-weight: 600; margin-top: 1px; }
.sr-meta { font-size: 0.82rem; color: var(--ink-soft); margin-top: 2px; }
.tag { font-size: 0.72rem; font-weight: 800; padding: 1px 7px; border-radius: 8px; margin-left: 4px; }
.tag.low { background: var(--warn); color: #fff; }
.tag.out { background: var(--danger); color: #fff; }

/* ---------- 판매내역 ---------- */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.hist-row {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 11px 13px;
}
.hr-main { flex: 1; min-width: 0; }
.hr-items { font-weight: 600; font-size: 0.95rem; }
.hr-meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; }
.hr-buyer { color: var(--primary-deep); font-weight: 700; }
.hr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.hr-right strong { font-size: 1.02rem; color: var(--primary-deep); }

/* ---------- 대시보드 ---------- */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-soft);
}
.stat-card.big { grid-column: 1 / -1; background: var(--primary-soft); border-color: #d5e3d9; }
.stat-card.profit { grid-column: 1 / -1; background: #e6f0fb; border-color: #cfe0f7; }
.stat-card.profit .stat-value { color: #2767c4; font-size: 1.75rem; }
.stat-label { font-size: 0.82rem; color: var(--ink-soft); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.stat-card.big .stat-value { font-size: 2rem; color: var(--primary-deep); }

.stat-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
}
.method-bars, .ranking-list { display: flex; flex-direction: column; gap: 12px; }
.mbar-top { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.mbar-track, .rk-track { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; }
.mbar-fill { height: 100%; background: var(--primary); border-radius: 5px; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rk-no {
  width: 22px; height: 22px; border-radius: 11px; background: var(--surface-2);
  border: 1px solid var(--line); display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 800; color: var(--ink-soft);
}
.rank-row:nth-child(1) .rk-no { background: var(--accent); color: #fff; border-color: var(--accent); }
.rk-emoji { font-size: 1.3rem; }
.rk-main { flex: 1; min-width: 0; }
.rk-name { font-size: 0.9rem; font-weight: 700; }
.rk-name small { color: var(--ink-soft); font-weight: 500; margin-left: 4px; }
.rk-track { margin-top: 4px; }
.rk-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.rk-amt { font-size: 0.92rem; color: var(--primary-deep); white-space: nowrap; }

.stat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---------- 모달 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(74, 69, 64, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); width: 100%; max-width: 720px;
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + var(--safe-b));
  max-height: 88vh; overflow-y: auto;
  animation: slideup .22s cubic-bezier(.2,.9,.3,1);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
}
@keyframes slideup { from { transform: translateY(100%); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { color: var(--ink); font-size: 1.1rem; margin: 0; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.modal-foot .btn { flex: 1; }

/* 폼 */
.f { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 14px; }
.f input {
  font-size: 1.05rem; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface-2); color: var(--ink);
  font-family: inherit; width: 100%;
}
.f input:focus { outline: none; border-color: var(--primary); background: #fff; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 판매 옵션 편집 */
.opt-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 6px; background: var(--surface-2); }
.opt-head { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 10px; }
.opt-row { display: grid; grid-template-columns: 1fr 0.9fr 0.6fr 34px; gap: 7px; margin-bottom: 8px; align-items: center; }
.opt-row input { font-size: 0.95rem; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit; width: 100%; }
.opt-row input:focus { outline: none; border-color: var(--primary); }
.opt-del { width: 34px; height: 40px; border: none; background: transparent; color: var(--danger); font-size: 1rem; cursor: pointer; border-radius: 8px; }
.opt-del:active { background: var(--line); }
.opt-hint { font-size: 0.75rem; color: var(--ink-soft); margin: 8px 0 0; line-height: 1.4; }
#pf-add-opt { margin-top: 2px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }

/* 장바구니 모달 */
.cart-lines { display: flex; flex-direction: column; gap: 10px; }
.cart-line { display: flex; align-items: center; gap: 10px; }
.cl-emoji { font-size: 1.5rem; }
.cl-name { flex: 1; font-weight: 600; font-size: 0.92rem; }
.cl-name small { color: var(--ink-soft); font-weight: 500; }
.cl-amt { font-weight: 700; color: var(--primary-deep); white-space: nowrap; }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper button {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 1.2rem; cursor: pointer; color: var(--ink);
}
.qty-stepper button:disabled { opacity: 0.35; }
.qty-stepper b { min-width: 22px; text-align: center; font-size: 1.05rem; }
.cart-total-row { display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 600; }
.cart-total-row strong { font-size: 1.3rem; color: var(--primary-deep); }
.buyer-f { margin-top: 16px; margin-bottom: 0; }
.method-pick { margin-top: 16px; }
.method-pick > span { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
.method-btns { display: flex; gap: 8px; margin-top: 8px; }
.method-btn {
  flex: 1; padding: 11px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); font-family: inherit; font-size: 0.95rem; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.method-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 토스트 ---------- */
.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(140px + var(--safe-b));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 13px;
  font-size: 0.92rem; box-shadow: var(--shadow); pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 440px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast button {
  background: var(--accent); border: none; color: #fff; font-weight: 700;
  padding: 6px 12px; border-radius: 9px; cursor: pointer; font-family: inherit; white-space: nowrap;
}

/* 홈화면 추가 안내 */
.ig-intro { font-size: 0.88rem; line-height: 1.6; color: var(--ink-soft); margin: 2px 0 16px; }
.ig-os { background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px;
  padding: 13px 15px; margin-bottom: 12px; }
.ig-os > b { display: block; font-size: 0.95rem; margin-bottom: 8px; color: var(--ink); }
.ig-os ol { margin: 0; padding-left: 20px; line-height: 1.7; font-size: 0.88rem; }
.ig-os ol b { color: var(--primary-deep); }
.ig-os .muted { font-size: 0.78rem; margin: 8px 0 0; }
