/* 가게 매니저 웹앱 — 모바일 우선 (아이폰 기준) */
/* v23 디자인 패스: 팔레트는 로고(icon-512.png) 샘플링에서 뽑았다.
   - 웜 크림 배경: 로고 배경 크림 #ffeabd를 페이지용으로 부드럽게 → #faf3e1
   - 포인트 그린: 로고 캐릭터 딥그린 군(#004020~#107030)·브랜드 그린 #1f7a3d
   - 웜 차콜 텍스트: #292520 (차가운 회색 대신 따뜻한 톤)
   신호등 🔴🟡🟢 색·틴트(.signal-card/.coach-card/.feedback/.sa-bar)는 의미 색이라 손대지 않는다. */
:root {
  --bg: #faf3e1;
  --ink: #292520;
  --ink-2: #45403a;
  --ink-sub: #6d675a;
  --muted: #948d78;
  --line: #f0ead8;
  --line-warm: #e7dfca;
  --tint-warm: #f2eedd;
  --brand: #1f7a3d;
  --brand-dark: #175c2e;
  --brand-tint: #e7f6ec;
  --card-shadow: 0 1px 2px rgba(112, 88, 32, 0.05), 0 6px 18px rgba(112, 88, 32, 0.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- 로그인 ---------- */
#loginView {
  min-height: 100dvh;
  background:
    radial-gradient(120% 55% at 50% 0%, #e9f5e6 0%, rgba(233, 245, 230, 0) 60%),
    linear-gradient(180deg, #fdf8ec 0%, var(--bg) 55%);
}
.login-box {
  max-width: 420px;
  margin: 0 auto;
  padding: 72px 20px 48px;
  text-align: center;
}
.logo { font-size: 56px; }
.logo-img {
  width: 120px;
  height: 120px;
  border-radius: 28px;
  border: 3px solid #fff;
  box-shadow: 0 10px 24px rgba(112, 88, 32, 0.18);
}
.login-box h1 {
  margin: 14px 0 2px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--brand-dark);
}
.login-box .sub { font-size: 19px; font-weight: 700; color: #3f4a3a; margin: 2px 0 6px; }
.login-tag { color: var(--muted); font-size: 14px; margin: 0 0 30px; }
.login-box form {
  text-align: left;
  background: #fff;
  border-radius: 16px;
  padding: 20px 18px 18px;
  box-shadow: var(--card-shadow);
}
.keep-login { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.keep-login input { display: inline-block; width: auto; margin: 0; padding: 0; }

/* ---------- 공통 ---------- */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 12px 0;
}
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 16px; /* 16px 미만이면 iOS가 자동 확대함 */
  border: 1px solid #ddd3ba;
  border-radius: 12px;
  background: #fff;
  font-weight: 400;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 122, 61, 0.16);
}
textarea { resize: vertical; line-height: 1.5; }
.btn {
  border: 1px solid #ddd3ba;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(31, 122, 61, 0.25);
}
.btn.big { width: 100%; padding: 14px; min-height: 52px; font-size: 16px; margin-top: 16px; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-sub); box-shadow: none; }
.error { color: #b3261e; font-size: 14px; }
.ok { color: var(--brand); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.notice {
  max-width: 560px;
  margin: 16px auto;
  padding: 12px 16px;
  background: #fff7e0;
  border-radius: 10px;
}
em.over { color: #b3261e; font-style: normal; font-weight: 700; }

/* ---------- 앱 골격 ---------- */
#appView { max-width: 560px; margin: 0 auto; }
.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
}
.topbar-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(112, 88, 32, 0.15);
}
.topbar #logoutBtn { margin-left: auto; }
.store-name { font-size: 20px; font-weight: 800; }
.store-sub { font-size: 13px; color: var(--ink-sub); }
main { padding: 8px 14px 100px; }
.card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  margin: 12px 0;
  box-shadow: var(--card-shadow);
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid .card { margin: 0; }
.stat-label { font-size: 13px; color: var(--ink-sub); }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: -0.3px; }
.stat-note { font-size: 12px; color: var(--muted); }

/* ---------- 신호 카드 ---------- */
.signal-card { text-align: center; padding: 22px 16px; }
.signal-card.red { background: #fdecea; }
.signal-card.yellow { background: #fff7e0; }
.signal-card.green { background: #e7f6ec; }
.signal-emoji { font-size: 52px; line-height: 1.1; }
.signal-headline { font-size: 21px; font-weight: 800; margin-top: 6px; }
.signal-sub { font-size: 13px; color: var(--ink-sub); margin-top: 4px; }
.coach-card.red { background: #fdecea; }
.coach-card.yellow { background: #fff7e0; }
.coach-card.green { background: #e7f6ec; }
.coach-evidence { font-size: 15px; font-weight: 700; line-height: 1.5; }
.coach-line { font-size: 15px; line-height: 1.5; margin-top: 6px; }

/* ---------- 브리핑 ---------- */
.briefing-date { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.briefing-body { white-space: pre-line; font-size: 14.5px; }

/* ---------- 피드백 ---------- */
.feedback.red { background: #fdecea; }
.feedback.yellow { background: #fff7e0; }
.feedback.green { background: #e7f6ec; }
.feedback-headline { font-size: 17px; font-weight: 800; }
.feedback-lines p { margin: 8px 0 0; font-size: 14.5px; }

/* ---------- 현금 매상 질문 ---------- */
.cash-ask {
  background: #fff7e0;
  border: 1px solid #f0dfa8;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.cash-ask p { margin: 0; font-size: 14.5px; font-weight: 700; }

/* ---------- 매출 인박스 전부 등록 (v21) ---------- */
#salesBulkBar:empty { display: none; }
#salesBulkBar .hint { margin-top: 6px; }

/* ---------- 매출 한눈에 (v21) ---------- */
.sa-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sa-stat { background: #f7f2e2; border-radius: 12px; padding: 10px 12px; }
.sa-stat .sa-label { font-size: 12.5px; color: var(--muted); }
.sa-stat .sa-value { font-size: 17px; font-weight: 800; margin-top: 2px; }
.sa-stat .sa-value-sm { font-size: 14px; }
.sa-head { font-size: 14.5px; font-weight: 700; margin: 18px 0 4px; }
.sa-chart { position: relative; display: flex; gap: 2px; height: 120px; margin-top: 16px; }
.sa-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.sa-bar { width: 100%; border-radius: 3px 3px 0 0; }
.sa-bar.green { background: #34a853; }
.sa-bar.yellow { background: #f2b705; }
.sa-bar.red { background: #e05252; }
.sa-bar.monthly { background: #7aa5c9; width: 72%; }
.sa-bar.empty { background: #efe9d6; height: 3px; border-radius: 2px; }
.sa-be { position: absolute; left: 0; right: 0; border-top: 2px dashed #8a8f8a; pointer-events: none; }
.sa-be span { position: absolute; right: 0; top: -15px; font-size: 10.5px; color: #666; }
.sa-days { display: flex; gap: 2px; margin-top: 4px; }
.sa-days span { flex: 1; text-align: center; font-size: 8.5px; color: #9a9e9a; min-width: 0; }
.sa-bar-val { font-size: 10px; color: #555; margin-bottom: 3px; white-space: nowrap; }
.sa-bar-val.sa-none { color: #b5b9b5; }
.sa-mlabel { font-size: 11px; color: var(--muted); margin-top: 4px; }
.sale-split { font-size: 13px; color: var(--muted); margin-top: 2px; }
.si-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.si-fields label { font-size: 12.5px; color: var(--muted); flex: 1 1 30%; min-width: 96px; }
.si-fields input { width: 100%; margin-top: 2px; }

/* ---------- 목록 ---------- */
.list-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .desc { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.list-row .cat { font-weight: 700; }
.row-actions { margin-top: 6px; display: flex; gap: 6px; }
.menu-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.menu-row:last-child { border-bottom: none; }
.menu-ratio { font-size: 13.5px; text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  background: var(--tint-warm);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.chip.total { background: #1f7a3d; color: #fff; font-weight: 700; }

/* ---------- 설정 ---------- */
.menu-edit { padding: 10px 0; border-bottom: 1px solid var(--line); }
.menu-fields {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 6px;
}
.menu-fields label { margin: 0; flex: 1; min-width: 100px; }
.menu-fields input { margin-top: 4px; padding: 8px; }
.menu-add {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.menu-add input { margin-top: 0; }
.menu-add input:first-child { grid-column: 1 / -1; }
.menu-add-cost { grid-column: 1 / -1; }
.menu-add-cost .menu-fields { margin-top: 6px; }
.menu-add > button[type="submit"] { grid-column: 1 / -1; }
.nm-ing-reg {
  border: 1px dashed #d8cfb4;
  border-radius: 12px;
  padding: 10px;
  margin: 8px 0;
}
.nm-ing-reg select { margin-top: 4px; padding: 8px; width: 100%; }

/* ---------- 쿠폰 (쿠폰핑 연동) ---------- */
a.btn { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; }
.proposal-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
}
.proposal-label {
  flex: 0 0 36px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-sub);
  padding-top: 7px;
}
.proposal-text { flex: 1; min-width: 0; padding-top: 6px; word-break: break-word; }
.proposal-line .btn { flex: 0 0 auto; }
.coupon-badge { font-weight: 800; color: #1f7a3d; }
.qr-box { text-align: center; padding: 8px 0; }
.qr-box canvas { width: 240px; height: 240px; }
.qr-desc { font-size: 15px; line-height: 1.55; margin: 10px 0 4px; }
.qr-desc-en { font-size: 13px; color: var(--ink-sub); line-height: 1.5; margin: 0 0 8px; }
.qr-url { word-break: break-all; text-align: center; }
#qrMain .row-actions { justify-content: center; }

/* ---------- 영수증 인박스 ---------- */
.upload-label { text-align: center; cursor: pointer; }
.upload-label input { display: none; } /* 전역 input{display:block}이 hidden 속성을 덮으므로 명시 */
.inbox-row { display: flex; gap: 10px; }
.inbox-thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--tint-warm);
  cursor: pointer;
}
.inbox-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: default;
}
.inbox-main { flex: 1; min-width: 0; }
.chip.st-pending { background: #fff7e0; }
.chip.st-done { background: #e7f6ec; color: #1f7a3d; font-weight: 700; }
.chip.st-failed { background: #fdecea; color: #b3261e; }

/* ---------- 포스터 (인쇄 전용) ---------- */
#posterPrint { display: none; }
#cpPosterPrint { display: none; }
#cpQrCard .row-actions { justify-content: center; }
@media print {
  #loginView, #appView { display: none !important; }
  #posterPrint { display: block !important; }
  /* 손님용 QR 포스터 인쇄 시에는 단골 포스터 대신 이쪽만 나온다. */
  body.print-cp #posterPrint { display: none !important; }
  body.print-cp #cpPosterPrint { display: block !important; }
  .poster-inner { text-align: center; padding: 48px 24px; font-family: inherit; }
  .poster-store { font-size: 22px; font-weight: 700; color: var(--ink-2); }
  .poster-inner h1 { font-size: 44px; margin: 12px 0 4px; }
  .poster-sub { font-size: 20px; color: var(--ink-sub); margin: 0 0 16px; }
  .poster-desc {
    font-size: 19px;
    line-height: 1.55;
    max-width: 640px;
    margin: 0 auto 8px;
  }
  .poster-desc-en {
    font-size: 15px;
    color: var(--ink-sub);
    line-height: 1.5;
    max-width: 640px;
    margin: 0 auto 24px;
  }
  .poster-inner canvas { width: 420px; height: 420px; }
  .poster-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
    margin: 28px 0 0;
    font-size: 20px;
    line-height: 1.9;
  }
  .poster-steps li::before {
    counter-increment: step;
    content: counter(step) ". ";
    font-weight: 800;
    color: #1f7a3d;
  }
  .poster-foot { margin-top: 32px; font-size: 14px; color: var(--muted); }
}

/* ---------- v12: 사장님 컨디션 ---------- */
.owner-signal { font-size: 26px; line-height: 1; }
.mood-row { display: flex; gap: 8px; margin: 10px 0 4px; }
.mood-btn {
  flex: 1;
  border: 1px solid #ddd3ba;
  background: #fff;
  border-radius: 12px;
  padding: 10px 4px;
  min-height: 44px;
  font-size: 15px;
  cursor: pointer;
}
.mood-btn.active {
  background: #1f7a3d;
  border-color: #1f7a3d;
  color: #fff;
  font-weight: 700;
}

/* ---------- v12: 구매 판정 ---------- */
.verdict-box { border-radius: 12px; padding: 12px 14px; margin-top: 14px; font-size: 14.5px; }
.verdict-box p { margin: 6px 0 0; }
.verdict-box.go { background: #e7f6ec; }
.verdict-box.caution { background: #fff7e0; }
.verdict-box.no { background: #fdecea; }
.verdict-box.none { background: var(--tint-warm); }
.verdict-headline { font-size: 17px; font-weight: 800; }
.price-check { margin-top: 10px; border-top: 1px dashed rgba(0,0,0,.18); padding-top: 8px; }
.price-check-title { font-weight: 700; font-size: 13.5px; }
.price-check p { margin: 4px 0 0; }
.sub-h { font-size: 14px; margin: 16px 0 4px; color: var(--ink-2); }

/* ---------- v17 원가 계산기 ---------- */
.cost-line-cost { font-size: 13px; color: var(--ink-2); white-space: nowrap; padding-bottom: 10px; min-width: 52px; text-align: right; }
#costSummary { margin: 12px 0; }
#costLines .menu-fields { border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* ---------- v12: 가게 몸값 ---------- */
.value-range { font-size: 26px; font-weight: 800; color: var(--brand); margin: 4px 0; letter-spacing: -0.3px; }
#valueBody p { font-size: 14.5px; margin: 8px 0 0; }

/* ---------- v12: 시세 (주식 시세판) ---------- */
.market-search { margin: 10px 0 2px; }
.ticker {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.ticker:empty { display: none; }
.ticker-item { font-size: 13.5px; font-weight: 600; }
.chg { font-weight: 700; font-size: 13.5px; }
.chg.up { color: #d32f2f; }   /* 상승 = 빨강 (한국 증시 관례) */
.chg.down { color: #1565c0; } /* 하락 = 파랑 */
.chg.flat { color: var(--muted); }
.mprice { font-size: 17px; font-weight: 800; }

/* ---------- 하단 탭 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #fffdf6;
  border-top: 1px solid var(--line-warm);
  box-shadow: 0 -2px 12px rgba(112, 88, 32, 0.05);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 8px 2px 10px;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab span {
  font-size: 11px;
  white-space: nowrap;
  letter-spacing: -0.2px;
  padding: 2px 8px;
  border-radius: 999px;
}
.tab.active { color: var(--brand); }
.tab.active span { background: var(--brand-tint); font-weight: 700; }

@media (min-width: 720px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 560px; border-radius: 16px 16px 0 0; }
}

/* ---------- v22: 장터 게시판 ---------- */
button.chip { border: none; cursor: pointer; font-family: inherit; }
.chip.board-chip.active { background: #1f7a3d; color: #fff; font-weight: 700; }
.board-row { cursor: pointer; }
.board-cat { font-size: 12px; font-weight: 700; color: #1f7a3d; }
.board-title { font-size: 15.5px; font-weight: 700; margin-top: 2px; }
.board-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.board-detail-title { font-size: 19px; font-weight: 800; margin: 8px 0 4px; line-height: 1.4; }
.board-body { white-space: pre-line; font-size: 15px; line-height: 1.6; margin-top: 10px; }
.comment-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment-row:last-child { border-bottom: none; }
.comment-body { font-size: 14.5px; white-space: pre-line; margin-top: 2px; }

/* v14: 오늘의 돈 카드 */
.money-card { border: 1px solid var(--line-warm); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: #fffdf4; }
.money-card-title { font-weight: 700; font-size: 15px; }
.money-card-body { margin: 6px 0 0; font-size: 14.5px; line-height: 1.5; }
.money-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.money-card-actions .btn { margin-top: 0; }
