:root {
  --primary: #d63a2f;
  --primary-dark: #b52e24;
  --primary-soft: #fdf0ee;
  --primary-line: #f3c9c4;
  --text: #222;
  --text-sub: #666;
  --text-muted: #999;
  --line: #e8e8e8;
  --bg: #fff;
  --bg-soft: #f7f7f8;
  --notice: #fdf6d8;
  --notice-line: #f3e3a1;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans KR', sans-serif; color: var(--text); background: var(--bg); font-size: 14px; min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Header */
header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.header-inner { max-width: 1600px; margin: 0 auto; padding: 0 24px; height: 72px; display: flex; align-items: center; gap: 28px; }
.logo { font-weight: 900; font-size: 24px; color: var(--primary); letter-spacing: -0.5px; font-style: italic; white-space: nowrap; }
nav { display: flex; gap: 6px; flex: 1; }
nav a { padding: 7px 12px; border-radius: 999px; font-weight: 500; color: #555; white-space: nowrap; }
nav a:hover { color: var(--primary); }
nav a.active { background: var(--primary); color: #fff; }
.auth { display: flex; gap: 8px; align-items: center; }
.btn-pill { display: inline-block; padding: 6px 16px; border-radius: 999px; font-weight: 500; border: none; cursor: pointer; white-space: nowrap; }
.btn-pill.solid { background: var(--primary); color: #fff; }
.btn-pill.soft { background: var(--primary-soft); color: var(--primary); }
.user-chip { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.user-chip .pts { color: var(--primary); font-weight: 700; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; margin-left: auto; }

/* Order layout */
.layout { max-width: 1600px; margin: 0 auto; display: grid; grid-template-columns: 260px 1fr 1fr; min-height: calc(100vh - 72px); }
.col { padding: 28px 24px; min-width: 0; }
.col + .col { border-left: 1px solid var(--line); }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.tabs a, .tabs button { flex: 1; background: none; border: none; padding: 12px 0; font-size: 16px; color: var(--text-sub); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-align: center; }
.tabs a.active, .tabs button.active { color: var(--primary); font-weight: 700; border-color: var(--primary); }
.cat-list { display: flex; flex-direction: column; gap: 14px; }
.cat-group { display: flex; flex-direction: column; gap: 7px; }
.cat { display: flex; align-items: center; gap: 16px; padding: 16px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-size: 17px; font-weight: 700; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.cat-parent { width: 100%; }
.cat-child { margin-left: 18px; padding: 10px 14px; font-size: 14px; }
.cat-arrow { margin-left: auto; color: var(--text-muted); }
.cat:hover { border-color: var(--primary-line); }
.cat.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 2px 8px rgba(214,58,47,.12); }
.cat-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 900; flex-shrink: 0; }
.cat-icon[src] { object-fit: cover; }
.image-preview { display: block; width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.image-preview[hidden], .product-preview[hidden] { display: none; }
.product-preview { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; margin-top: 10px; background: var(--bg-soft); }
.catalog-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 8px; }

.banner { background: var(--primary-soft); border-radius: 10px; padding: 14px 18px; text-align: center; color: #333; margin-bottom: 20px; }
.status-notice-content { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 24px; background: var(--bg); }
.card-title { text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.chip { display: inline-block; padding: 5px 14px; border: 1px solid var(--primary); color: var(--primary); border-radius: 999px; font-size: 14px; background: var(--bg); }
.field { margin-bottom: 20px; }
.field label { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.category-group-heading { height: 30px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 0; }
.category-group-heading label { margin: 0; }
.category-group-heading .btn { flex: 0 0 auto; }
.num { width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; display: grid; place-items: center; }
.field select, .field input, .field textarea { width: 100%; height: 42px; border: 1px solid #ddd; border-radius: 8px; padding: 0 12px; background: var(--bg); outline: none; }
.field textarea { height: 120px; padding: 10px 12px; resize: vertical; }
.field select:focus, .field input:focus, .field textarea:focus { border-color: var(--primary); }
.field input[type=checkbox] { width: auto; height: auto; }
.field input[type=color] { padding: 2px; width: 60px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.total { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-weight: 700; }
.total strong { font-size: 20px; font-weight: 900; }
.benefit { display: flex; gap: 10px; align-items: flex-start; background: var(--primary-soft); border-radius: 8px; padding: 14px; margin-bottom: 20px; }
.badge { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.benefit b { display: block; margin-bottom: 4px; }
.benefit p { font-size: 12px; color: var(--text-sub); }
.benefit em, .benefit a { color: var(--primary); font-style: normal; font-weight: 700; }
.btn-order { width: 100%; height: 48px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn-order:hover { background: var(--primary-dark); }
.btn-order:disabled { opacity: .6; cursor: default; }
.footnote { text-align: center; font-size: 12px; color: var(--text-sub); margin-top: 14px; }
.form-msg { color: var(--primary); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.notice { background: var(--notice); border: 1px solid var(--notice-line); border-radius: 10px; padding: 14px; text-align: center; color: #8a6d00; margin-bottom: 20px; }
.side-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px; }
.side-card .card-title { padding-bottom: 14px; margin-bottom: 18px; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; }
.step-tag { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; margin-top: 2px; }
.steps b { display: block; margin-bottom: 3px; }
.steps p { font-size: 12px; color: var(--text-sub); }
.btn-outline { display: block; width: 100%; padding: 10px; border: 1px solid var(--primary); border-radius: 8px; background: var(--bg); color: var(--primary); text-align: center; cursor: pointer; }
.faq { display: flex; flex-direction: column; gap: 8px; }
.faq details { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; }
.faq summary { list-style: none; padding: 12px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '›'; font-size: 18px; color: var(--text-muted); transition: transform .15s; }
.faq details[open] summary::after { transform: rotate(90deg); }
.faq details p { padding: 0 14px 12px; font-size: 13px; color: var(--text-sub); white-space: pre-wrap; }
.faq .meta { font-size: 12px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* Generic pages */
.page { max-width: 1000px; margin: 0 auto; padding: 32px 16px 96px; }
.page h1 { font-size: 24px; margin-bottom: 20px; }
.page h2 { font-size: 18px; margin: 28px 0 12px; }
.auth-box { max-width: 420px; margin: 56px auto; }
.auth-box .alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-sub); }
.auth-box .alt a { color: var(--primary); font-weight: 700; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
th { background: var(--bg-soft); font-weight: 700; }
td.wrap { white-space: normal; min-width: 160px; word-break: break-all; }
td.num-cell, th.num-cell { text-align: right; }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status.pending { background: #fff4d6; color: #a67c00; }
.status.processing { background: #e0edff; color: #1d5fd1; }
.status.completed { background: #dcf5e7; color: #14804a; }
.status.canceled { background: #eee; color: #888; }
.plus { color: #14804a; font-weight: 700; }
.minus { color: var(--primary); font-weight: 700; }
.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--primary-line); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--primary); }
.empty { text-align: center; padding: 48px 0; color: var(--text-muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { height: 36px; border: 1px solid #ddd; border-radius: 8px; padding: 0 10px; background: var(--bg); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cat-heading { display: flex; align-items: center; gap: 10px; }
.cat-subheading { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 18px 0 10px; }
.prose p { line-height: 1.8; color: var(--text-sub); margin-bottom: 12px; }
.prose.pre { white-space: pre-wrap; line-height: 1.8; color: var(--text-sub); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--bg); }
.stat span { font-size: 13px; color: var(--text-sub); }
.stat strong { font-size: 22px; font-weight: 900; }
.stat small { font-size: 12px; color: var(--text-muted); }
a.stat:hover, button.stat:hover { border-color: var(--primary-line); }
button.stat { text-align: left; cursor: pointer; }
.stat.alert strong { color: var(--primary); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); color: var(--text-sub); font-size: 12px; }
.footer-inner { max-width: 1600px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.footer-links { display: flex; gap: 16px; font-size: 13px; color: #444; }
.footer-links b { font-weight: 700; }
.footer-inner span { color: #ccc; margin: 0 4px; }

/* Floating chat */
.fab { position: fixed; right: 32px; bottom: 32px; width: 64px; height: 64px; border-radius: 18px; background: var(--primary); color: #fff; border: none; font-size: 26px; cursor: pointer; box-shadow: 0 6px 18px rgba(214,58,47,.35); display: grid; place-items: center; z-index: 20; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: #222; color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .col-right { grid-column: 1 / -1; border-left: none !important; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  nav { display: none; position: absolute; top: 72px; left: 0; right: 0; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 16px; }
  nav.open { display: flex; }
  .menu-toggle { display: block; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .user-chip b { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col { padding: 20px 16px; }
  .col + .col { border-left: none; border-top: 1px solid var(--line); }
  .cat-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .cat-group { flex-shrink: 0; max-width: 85vw; }
  .cat { flex-shrink: 0; padding: 10px 14px; font-size: 14px; }
  .tabs { margin-bottom: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .fab { right: 16px; bottom: 16px; width: 52px; height: 52px; font-size: 22px; }
}

.price-saving { margin-top: 16px; padding: 12px 14px; background: var(--primary-soft); border-radius: 8px; }
.price-saving[hidden] { display: none; }
.price-saving-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.price-saving del { color: var(--text-muted); }
.price-saving b { color: var(--primary); }
.price-saving p { margin-top: 5px; color: var(--text-sub); font-size: 12px; }

.status.partial {background:#fff4d6;color:#a67c00;}

.discount-options {display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;}
button:focus-visible,a:focus-visible {outline:2px solid var(--primary);outline-offset:3px;}
@media(max-width:600px){.toolbar {flex-wrap:wrap;} .toolbar input,.toolbar select{min-width:0;max-width:100%;} .page{padding-left:12px;padding-right:12px;}}

.reauth-dialog {border:1px solid var(--line);border-radius:12px;padding:24px;max-width:440px;width:calc(100% - 32px);margin:auto;}
.reauth-dialog::backdrop{background:rgba(0,0,0,.4);}
.reauth-dialog p{margin:12px 0 20px;color:var(--text-sub);}

.site-popup{border:0;border-radius:16px;padding:0;margin:auto;background:#fff;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 20px 70px #0004;overflow:auto;}
.site-popup::backdrop{background:rgba(0,0,0,.55);}
.site-popup-image{display:block;width:auto;height:auto;max-width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 120px);margin:auto;object-fit:contain;}
.site-popup-controls{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border-top:1px solid #eee;}
.site-popup-controls label{display:flex;align-items:center;gap:6px;font-size:13px;cursor:pointer;}
.site-popup-controls input{width:auto;min-height:0;}
.popup-admin-preview{display:block;max-width:260px;max-height:260px;width:auto;height:auto;border-radius:8px;margin:12px 0;object-fit:contain;}

.popup-admin-preview[hidden]{display:none;}
