/* ===== 바자회 판매·재고 — 부드러운 파스텔 모바일 UI ===== */
:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #fbf8f4;
  --ink: #4a4540;
  --ink-soft: #8d857c;
  --line: #ece5dc;
  --primary: #8aa893;      /* 뮤트 세이지 */
  --primary-deep: #6f9079;
  --primary-soft: #e7efe9;
  --accent: #e7b4a3;       /* 뮤트 코랄(포인트) */
  --warn: #d99a5b;
  --warn-soft: #f6ead9;
  --danger: #cd8a82;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(120, 110, 98, 0.10);
  --shadow-soft: 0 2px 8px rgba(120, 110, 98, 0.07);
  --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(247, 243, 238, 0.92);
  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: 1.15rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.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: 600;
  padding: 13px 16px; border-radius: 13px; cursor: pointer;
  font-family: inherit; transition: transform .05s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-deep); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.ghost.danger { border-color: #e7cdc9; }
.btn.sm { padding: 9px 13px; font-size: 0.9rem; border-radius: 11px; }

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

/* ---------- 판매(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; }
.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: 13px 0; display: flex; justify-content: center; align-items: center;
  font-size: 0.92rem; color: var(--ink-soft); font-family: inherit; font-weight: 600;
  position: relative;
}
.tab-btn.active { color: var(--primary-deep); font-weight: 800; }
.tab-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; 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: #e7cdc9; background: #f8eeec; }
.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: #fbeee9; border-color: #f0d8cf; }
.stat-card.profit .stat-value { color: #c08367; 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; }
.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;
}
