[hidden] { display: none !important; }
:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1f2328; --mute: #6b7280; --line: #e5e3de;
  --brand: #2f6f5e; --brand-soft: #e3efe9;
  --red: #c0392b; --red-soft: #fbe9e7; --amber: #b7791f; --amber-soft: #fdf3dc; --green: #2f855a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Pretendard", "Malgun Gothic", system-ui, sans-serif; }
header { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 20px; }
.brand { font-weight: 800; font-size: 17px; color: var(--brand); }
button.brand { border: 0; background: none; padding: 0; cursor: pointer; font-family: inherit; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font: inherit; cursor: pointer; color: var(--mute); }
nav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.freshness { margin-left: auto; font-size: 12px; color: var(--mute); }
.freshness .old { color: var(--red); font-weight: 700; }
main { padding: 16px 20px 80px; max-width: 1400px; margin: 0 auto; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.search { flex: 1 1 260px; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
button { font: inherit; cursor: pointer; }
.primary { background: var(--brand); color: #fff; border: 0; padding: 9px 16px; border-radius: 8px; font-weight: 700; }
.ghost { background: #fff; border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; }
.sm { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.chk { display: inline-flex; gap: 4px; align-items: center; color: var(--mute); }
.legend { color: var(--mute); font-size: 13px; margin-bottom: 8px; }
.hint { color: var(--mute); font-size: 12px; }
.link { color: var(--brand); text-decoration: underline; cursor: pointer; }

.warn { background: var(--amber-soft); border: 1px solid #f1d9a6; color: #7a5212; padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; }
.warn a { color: inherit; font-weight: 700; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--mute); font-weight: 600; background: #fbfaf8; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big { font-size: 20px; font-weight: 800; }
.avail-bad { color: var(--red); }
.avail-low { color: var(--amber); }
.avail-ok { color: var(--green); }
tr.row-bad { background: var(--red-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #f0eeea; color: #444; white-space: nowrap; }
.chip.ch-스마트스토어 { background: #e4f4e6; color: #1e6b2c; }
.chip.ch-자사몰 { background: #e6eefb; color: #1d4b91; }
.chip.ch-전화 { background: #fdeee0; color: #8a4b12; }
.st { font-size: 12px; padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.st-open { background: var(--amber-soft); color: #7a5212; }
.st-shipped { background: #e4f4e6; color: #1e6b2c; }
.st-cancelled { background: #eee; color: #777; }
.st-pending { background: #eef; color: #447; }
.opt { color: var(--mute); font-size: 12px; max-width: 420px; }
.um { color: var(--red); font-weight: 700; }
.actions { white-space: nowrap; display: flex; gap: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 640px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--mute); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row select { flex: 1; min-width: 0; }
.item-row input { width: 90px; }

.drop { border: 2px dashed #c9c5bc; border-radius: 12px; padding: 36px 20px; text-align: center; margin: 12px 0; color: var(--mute); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.res { padding: 8px 12px; border-radius: 8px; margin: 6px 0; background: var(--brand-soft); }
.res.bad { background: var(--red-soft); color: var(--red); }

.listing { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.listing-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.listing-head .title { font-weight: 700; }
.listing-head .meta { color: var(--mute); font-size: 12px; }
.keychips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.keychip { font-size: 12px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--mute); cursor: pointer; }
.keychip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.combo-row td { vertical-align: middle; }
.combo-row .c { font-weight: 600; }

.bulkbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 20; background: #1f2328; color: #fff;
  padding: 10px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(480px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog form { padding: 18px 20px; margin: 0; }
dialog h3 { margin: 0 0 12px; }
dialog .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
dialog .mv { max-height: 50vh; overflow: auto; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 30; background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 10px; }
#ord-table { min-width: 980px; }
#stock-table { min-width: 720px; }
#ord-table td:nth-child(3) { white-space: nowrap; }
@media (max-width: 700px) {
  header { padding: 8px 12px; }
  nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  nav button { white-space: nowrap; }
  .freshness { margin-left: 0; }
  main { padding: 12px 12px 80px; }
  #stock-table th:nth-child(5), #stock-table td:nth-child(5) { display: none; }
}
.formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.formula > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; display: flex; flex-direction: column; }
.formula > div span { font-weight: 800; }
.formula > div small { color: var(--mute); font-size: 12px; }
.formula > div.hl { border-color: var(--brand); background: var(--brand-soft); }
.formula > div.hl span { color: var(--brand); }
.formula > b { font-size: 20px; color: var(--mute); }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--brand); }
form label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
#cafe24-code { flex: 1; width: auto; min-width: 0; }

.auth { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: min(380px, 100%); }
.auth-card .brand { font-size: 22px; margin-bottom: 4px; }
.auth-card .primary { width: 100%; margin-top: 4px; }
.userbox { display: flex; gap: 6px; align-items: center; }
.memo { margin-top: 4px; font-size: 12px; background: #fff8e1; border-radius: 6px; padding: 2px 6px; color: #6b5200; display: inline-block; }
.by { color: var(--mute); font-size: 11px; }
body.staff .admin-only { display: none !important; }

.manual-layout { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.manual-layout > .narrow { flex: 1 1 360px; max-width: 480px; }
.manual-layout > .board { flex: 2 1 420px; min-width: 0; }
.manual-layout .board .table-wrap { max-height: 70vh; overflow-y: auto; }

/* 전화주문 예약 현황판: 좁은 화면에서는 표 대신 카드로 */
@media (max-width: 700px) {
  .manual-layout .board .table-wrap { overflow-x: visible; max-height: none; }
  #phone-board-table thead { display: none; }
  #phone-board-table, #phone-board-table tbody, #phone-board-table tr, #phone-board-table td { display: block; width: 100%; min-width: 0; }
  #phone-board-table { min-width: 0; }
  #phone-board-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  #phone-board-table tr:last-child { margin-bottom: 0; }
  #phone-board-table td { border: 0; padding: 3px 0; text-align: left; white-space: normal; }
  #phone-board-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 68px; color: var(--mute); font-size: 12px; }
  #phone-board-table td.actions { display: flex; gap: 6px; padding-top: 8px; }
}

/* ===== 스마트폰 (갤럭시 S26 · 아이폰 14 Plus 등) ===== */
.c-st, .c-st-col { }
@media (max-width: 700px) {
  body { font-size: 15px; }
  header { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  main { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  /* 아이폰은 입력칸 글자가 16px 미만이면 눌렀을 때 화면이 확대되어 레이아웃이 깨짐 */
  input, select, textarea, .search { font-size: 16px; }
  button { min-height: 40px; }
  .sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  nav { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { padding: 10px 12px; }
  .toolbar > * { max-width: 100%; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .card { padding: 14px; }
  .formula > div { flex: 1 1 100%; }
  .formula > b { display: none; }
  .bulkbar { width: calc(100% - 24px); flex-wrap: wrap; justify-content: center; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); text-align: center; }
  dialog { width: 94vw; max-height: 90dvh; }
  dialog form { padding: 16px; }
  dialog .mv { max-height: 55dvh; }
  .item-row input { width: 80px; }
  .item-row { flex-wrap: wrap; }

  /* 표 → 카드 */
  .table-wrap { overflow-x: visible; background: none; border: 0; }
  #stock-table, #ord-table, #act-table { min-width: 0; }
  #stock-table thead, #ord-table thead, #act-table thead { display: none; }
  #stock-table, #stock-table tbody, #stock-table tr, #stock-table td,
  #ord-table, #ord-table tbody, #ord-table tr, #ord-table td,
  #act-table, #act-table tbody, #act-table tr, #act-table td { display: block; width: 100%; min-width: 0; }
  #stock-table tr, #ord-table tr, #act-table tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 12px; margin-bottom: 10px; }
  #stock-table tr.row-bad { background: var(--red-soft); border-color: #f1b5ad; }
  #stock-table td, #ord-table td, #act-table td { border: 0; padding: 3px 0; white-space: normal; text-align: left; }
  #stock-table td[data-label]::before, #ord-table td[data-label]::before, #act-table td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 76px; color: var(--mute); font-size: 12px; font-weight: 400; }
  #ord-table td:nth-child(3) { white-space: normal; }
  #stock-table th:nth-child(5), #stock-table td:nth-child(5) { display: block; }
  #stock-table td.c-chips:empty, #stock-table td.c-chips .chips:empty { display: none; }
  #stock-table td.n, #ord-table td.n { text-align: left; }

  /* 재고현황 카드: 이름 크게, 가용재고 강조 */
  #stock-table td.c-name { font-size: 16px; padding-bottom: 6px; }
  #stock-table td.big { font-size: 26px; line-height: 1.2; padding: 2px 0 6px; }
  #stock-table td.big::before { font-size: 12px; margin-right: 8px; vertical-align: middle; }
  #stock-table td.actions, #ord-table td.actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; white-space: normal; }
  #stock-table td.actions .sm, #ord-table td.actions .sm { flex: 1 1 22%; }
  /* 주문 카드: 채널 + 상태를 한 줄로 */
  #ord-table td.c-st-col { display: none; }
  #ord-table td.c-ch { padding-bottom: 4px; }
  .opt { max-width: none; }
  #act-table td.hint { padding-bottom: 0; }
}
@media (min-width: 701px) { .c-st { display: none; } }

/* ===== 캘린더 ===== */
.cal-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
.cal-head b { font-size: 18px; min-width: 110px; text-align: center; }
.cal-note { margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--mute); padding: 4px 0; }
.cal-wd.sun, .cal-cell.sun .cal-d { color: var(--red); }
.cal-wd.sat, .cal-cell.sat .cal-d { color: #1d4b91; }
.cal-cell { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 96px; padding: 4px 6px; overflow: hidden; }
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.has { cursor: pointer; border-color: #bcd5ca; }
.cal-cell.has:hover { background: var(--brand-soft); }
.cal-cell.today { outline: 2px solid var(--brand); }
.cal-cell.late { background: var(--red-soft); border-color: #f1b5ad; }
.cal-d { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
.cal-tot { background: var(--brand); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; }
.cal-line { display: flex; justify-content: space-between; gap: 4px; font-size: 11.5px; line-height: 1.35; }
.cal-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { font-size: 11px; color: var(--mute); }
.cal-short { font-size: 11px; color: var(--red); font-weight: 700; margin-top: 2px; }
.cal-agenda { display: none; }
.cal-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; cursor: pointer; }
.cal-card.today { border-color: var(--brand); border-width: 2px; }
.cal-card.late { background: var(--red-soft); border-color: #f1b5ad; }
.cal-card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cal-card-h .cal-tot { margin-left: auto; font-size: 13px; padding: 1px 10px; }
.cal-dd { font-size: 12px; color: var(--mute); }
.cal-card .cal-line { font-size: 14px; }
.cal-card .cal-short { font-size: 12px; }
#cal-alerts details.warn summary { cursor: pointer; font-weight: 700; }
.cal-list { margin-top: 8px; }
.cal-li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
@media (max-width: 700px) {
  .cal-grid { display: none; }
  .cal-agenda { display: block; }
}

/* ===== 새 옵션 조합 알림 ===== */
.global-alert { background: var(--red); color: #fff; padding: 10px 20px; }
.global-alert ul { margin: 4px 0 6px; padding-left: 18px; }
.global-alert .opt { color: #ffd9d4; }
.global-alert .alert-btn { display: inline-block; background: #fff; color: var(--red); font-weight: 700; padding: 6px 14px; border-radius: 8px; text-decoration: none; }
.badge { background: var(--red); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; font-weight: 700; }
@media (max-width: 700px) { .global-alert { padding: 10px 12px; font-size: 14px; } }
