/* Layout: a shop front (stamp-red price tags on white product tiles) with role tabs; admin and hospital views are summary-first boards. */
:root {
  --bg: #F3F5F7; --card: #FFFFFF; --ink: #17202C; --muted: #5C6977; --line: #DCE2E8;
  --stamp: #D9482B; --stamp-ink: #FFFFFF; --stamp-soft: #FBE9E4;
  --hosp: #1D7466; --hosp-soft: #E1F2EE;
  --bad: #B8322A; --bad-bg: #FBE6E3; --ok: #1E7A45; --ok-bg: #E2F3E8; --wait: #8A5A00; --wait-bg: #FFF2D6; --chip: #EDF0F3;
  --t1: #FCE3DC; --t2: #DDEFEA; --t3: #E6E7F7; --t4: #FFF0CC;
  --btn: #17202C; --btn-fg: #FFFFFF;
  --display: "Do Hyeon", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --body: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11161D; --card: #1A212B; --ink: #E6EAEF; --muted: #9AA5B1; --line: #2C3642;
  --stamp: #F0684B; --stamp-ink: #1A0B07; --stamp-soft: #3A1E17;
  --hosp: #5CC9B5; --hosp-soft: #15312C;
  --bad: #FF8A7A; --bad-bg: #3A1D1A; --ok: #67CF91; --ok-bg: #16301F; --wait: #F3C35B; --wait-bg: #382B10; --chip: #232C37;
  --t1: #3A231D; --t2: #173029; --t3: #22243A; --t4: #3A3014;
  --btn: #E6EAEF; --btn-fg: #11161D; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #11161D; --card: #1A212B; --ink: #E6EAEF; --muted: #9AA5B1; --line: #2C3642;
  --stamp: #F0684B; --stamp-ink: #1A0B07; --stamp-soft: #3A1E17;
  --hosp: #5CC9B5; --hosp-soft: #15312C;
  --bad: #FF8A7A; --bad-bg: #3A1D1A; --ok: #67CF91; --ok-bg: #16301F; --wait: #F3C35B; --wait-bg: #382B10; --chip: #232C37;
  --t1: #3A231D; --t2: #173029; --t3: #22243A; --t4: #3A3014;
  --btn: #E6EAEF; --btn-fg: #11161D; color-scheme: dark }
* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg) }
.wrap { max-width: 1080px; margin: 0 auto; padding-block: 0 72px }
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; gap: 10px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-block: 10px }
.brand { display: flex; align-items: baseline; gap: 8px; cursor: pointer; background: none; border: 0; color: inherit; padding: 0 }
.brand b { font-family: var(--display); font-weight: 400; font-size: 28px; letter-spacing: .5px; color: var(--stamp) }
.brand span { font-family: var(--display); font-size: 17px; color: var(--ink) }
nav.tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.tab { font: inherit; font-size: 14px; font-weight: 500; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 13px; cursor: pointer }
.tab[aria-current="page"] { background: var(--btn); color: var(--btn-fg); border-color: var(--btn) }
.bell { position: relative }
.bell .dot { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--stamp); color: var(--stamp-ink); font-size: 11px; display: grid; place-items: center; padding: 0 4px; font-family: var(--mono) }
main { display: grid; gap: 18px; padding-top: 18px }
h1, h2, h3 { margin: 0; text-wrap: balance }
h2 { font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .3px }
h3 { font-size: 15px; font-weight: 700 }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; min-width: 0 }
.muted, .note { color: var(--muted) } .note { font-size: 13px }
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: stretch }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr } }
.hero .pitch { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 10px; align-content: center }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 6vw, 44px); line-height: 1.12 }
.hero h1 em { font-style: normal; color: var(--stamp) }
.tag { display: inline-grid; place-items: center; background: var(--stamp); color: var(--stamp-ink); font-family: var(--display); font-size: 20px; border-radius: 6px; padding: 2px 10px; transform: rotate(-2deg); justify-self: start }
.how { display: grid; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px }
.how ol { margin: 0; padding-left: 20px; display: grid; gap: 8px }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px }
.prod { all: unset; box-sizing: border-box; cursor: pointer; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; grid-template-rows: auto 1fr }
.prod:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px }
.prod .pic, .pic { aspect-ratio: 4 / 3; width: 100%; max-width: 100%; display: grid; place-items: center; font-family: var(--display); font-size: 30px; color: var(--ink); overflow: hidden }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block }
.prod .body { padding: 12px 14px; display: grid; gap: 4px; align-content: start }
.price { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 20px; color: var(--stamp) }
.price small { font-family: var(--body); font-size: 13px; color: var(--muted) }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 9px; background: var(--chip); color: var(--muted); white-space: nowrap }
.pill.bad { background: var(--bad-bg); color: var(--bad) } .pill.ok { background: var(--ok-bg); color: var(--ok) }
.pill.wait { background: var(--wait-bg); color: var(--wait) } .pill.hosp { background: var(--hosp-soft); color: var(--hosp) } .pill.stamp { background: var(--stamp-soft); color: var(--stamp) }
.pills { display: flex; gap: 5px; flex-wrap: wrap }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.between { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
@media (max-width: 520px) { .grid2, .grid3 { grid-template-columns: 1fr } }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0 }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0 }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums }
input[type="checkbox"] { width: auto }
textarea { min-height: 80px; resize: vertical }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 1px }
.chips { display: flex; gap: 6px; flex-wrap: wrap }
.chip { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 8px 12px; cursor: pointer }
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-fg); border-color: var(--btn); font-weight: 700 }
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 11px 16px; background: var(--btn); color: var(--btn-fg); cursor: pointer }
.btn.stamp { background: var(--stamp); color: var(--stamp-ink) } .btn.hosp { background: var(--hosp); color: var(--card) }
.btn.sub { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 500; padding: 7px 12px }
.btn.danger { background: var(--card); color: var(--bad); border: 1px solid var(--bad); font-weight: 500; padding: 7px 12px }
.btn:disabled { opacity: .5; cursor: not-allowed }
.msg { font-size: 14px; border-radius: 8px; padding: 10px 12px; background: var(--chip) }
.msg.bad { background: var(--bad-bg); color: var(--bad) } .msg.ok { background: var(--ok-bg); color: var(--ok) } .msg.wait { background: var(--wait-bg); color: var(--wait) }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px }
@media (max-width: 620px) { .stats { grid-template-columns: repeat(2, 1fr) } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px }
.stat .k { font-size: 12px; color: var(--muted) } .stat .v { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums }
.stat.alert { border-color: var(--stamp) } .stat.alert .v { color: var(--stamp) }
.list { display: grid; gap: 8px }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-width: 0 }
.item.flag { border-left: 4px solid var(--stamp) }
.item > button.head { all: unset; box-sizing: border-box; display: grid; gap: 6px; width: 100%; padding: 12px 14px; cursor: pointer }
.item > button.head:focus-visible { outline: 2px solid var(--stamp); border-radius: 10px }
.item .t { font-weight: 700 } .num { font-family: var(--mono); font-variant-numeric: tabular-nums }
.detail { padding: 12px 14px 14px; display: grid; gap: 12px; border-top: 1px dashed var(--line) }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 14px }
dl.kv dt { color: var(--muted) } dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere }
.adtext { background: var(--hosp-soft); color: var(--ink); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px }
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card) }
table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 560px }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap }
td.r, th.r { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap }
tr:last-child td { border-bottom: 0 }
.plus { color: var(--ok) } .minus { color: var(--stamp) }
.big { font-family: var(--mono); font-size: clamp(28px, 6vw, 38px); font-variant-numeric: tabular-nums }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 20, .55); display: grid; place-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
.sheet { background: var(--card); color: var(--ink); border-radius: 14px; width: 100%; max-width: 560px; max-height: 100%; overflow: auto; display: grid; gap: 14px; padding: 18px }
.notes { display: grid; gap: 6px }
.notes .n { display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: 14px }
.notes .n.new { background: var(--stamp-soft) }
.notes .n time { font-size: 12px; color: var(--muted); font-family: var(--mono) }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--btn); color: var(--btn-fg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px) }
ol.help { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px }
@media (prefers-reduced-motion: no-preference) { .tab, .chip, .btn, .prod { transition: background-color .15s, color .15s, border-color .15s } .prod:hover { border-color: var(--stamp) } }

/* 서버 버전 추가 */
.auth { max-width: 460px; margin: 0 auto; width: 100% }
.linkbtn { background: none; border: 0; color: var(--stamp); font: inherit; cursor: pointer; padding: 0; text-decoration: underline }
img { max-width: 100% }
[hidden] { display: none !important }

/* 가격표: 휴대폰에서는 품목별 카드로 */
@media (max-width: 640px) {
  table.ptable { min-width: 0 !important }
  .ptable thead { display: none }
  .ptable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; border-bottom: 1px solid var(--line) }
  .ptable tr:last-child { border-bottom: 0 }
  .ptable td { border: 0; padding: 0; text-align: left !important }
  .ptable td:first-child { grid-column: 1 / -1 }
  .ptable td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-family: var(--body); margin-bottom: 2px }
  .ptable td input { max-width: none !important; text-align: left !important }
}

/* 적립금 내역: 휴대폰에서는 한 건씩 카드로 (차감 금액·잔액이 화면 밖으로 밀리지 않게) */
@media (max-width: 640px) {
  table.ltable { min-width: 0 !important }
  .ltable thead { display: none }
  .ltable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line) }
  .ltable tr:last-child { border-bottom: 0 }
  .ltable td { border: 0; padding: 0; text-align: left !important }
  .ltable td.full { grid-column: 1 / -1 }
  .ltable td.when { font-size: 12px; color: var(--muted) }
  .ltable td.what { font-weight: 700 }
  .ltable td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-family: var(--body); font-weight: 400 }
  .ltable td.amt { font-size: 17px }
}
/* 동의 체크 · 약관 */
.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.5; cursor: pointer }
.agree input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--stamp) }
.legal { display: grid; gap: 6px; font-size: 14px; line-height: 1.7 }
.legal h3 { margin: 14px 0 2px; font-size: 16px }
.legal h4 { margin: 10px 0 0; font-size: 14px }
.legal p { margin: 0; overflow-wrap: anywhere }
.legal p.li { padding-left: 1em }
.sheet .legal { max-height: 60vh; overflow: auto; padding-right: 4px }
/* 상품 상세페이지 */
.crumb { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap }
.pd { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start }
.pd-pic .pic { border-radius: 12px; border: 1px solid var(--line); font-size: 48px }
.pd-info { display: grid; gap: 14px; position: sticky; top: 12px }
.pd-info h1 { font-family: var(--display); font-weight: 400; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; margin: 0 }
.pd-tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--line); overflow-x: auto }
.pd-sec { display: grid; gap: 12px; scroll-margin-top: 60px }
.pd-sec h2 { margin: 6px 0 0 }
.pd-desc { margin: 0; white-space: pre-wrap; line-height: 1.8; font-size: 15px }
.pd-imgs { display: grid; max-width: 860px; width: 100%; margin: 0 auto }
.pd-imgs img { width: 100%; height: auto; display: block }
.pd-list { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; line-height: 1.6 }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden }
.stepper button { all: unset; cursor: pointer; width: 38px; text-align: center; font-size: 18px; background: var(--bg) }
.stepper input { width: 64px; max-width: none; border: 0; border-radius: 0; text-align: center; -moz-appearance: textfield }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none }
.btn.big { padding: 14px; font-size: 17px }
.buybar { display: none }
.dimgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px }
.dimg { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--card) }
.dimg img { width: 100%; height: 120px; object-fit: cover; object-position: top; border-radius: 4px }
@media (max-width: 760px) {
  .pd { grid-template-columns: 1fr }
  .pd-info { position: static }
  .buybar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 10px; align-items: center; justify-content: space-between;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08) }
  .buybar > div { display: grid; min-width: 0 } .buybar .note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
  .wrap:has(.buybar) { padding-bottom: 96px }
}
