:root {
  --brand: #ffc300;
  --brand-ink: #7a5a00;
  --brand-tint: #fff8e0;
  --ink: #1f1f1f;
  --sub: #6b6b6b;
  --hint: #a3a3a3;
  --line: #e9e9e9;
  --ground: #f6f6f4;
  --panel: #ffffff;
  --ok: #2f9e44;
  --ok-tint: #ebf7ee;
  --err: #d9363e;
  --err-tint: #fdecec;
  --info: #2b6cb0;
  --info-tint: #eaf2fb;
  --wechat: #07c160;
  --wechat-tint: #e6f8ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body { font: 14px/1.5 "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 56px; }
.logo { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: inline-block; }
.logo small { font-weight: 500; color: var(--sub); font-size: 13px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--sub); white-space: nowrap; font-weight: 500; position: relative; }
.tabs a:hover { background: var(--ground); color: var(--ink); }
.tabs a.on { color: var(--ink); background: var(--brand-tint); font-weight: 600; }
.tabs .dot { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.top-actions { display: flex; gap: 8px; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
h1 { font-size: 20px; margin: 0 0 4px; }
.lead { color: var(--sub); margin: 0 0 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #cfcfcf; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #2a2000; font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--sub); }
.icon-btn:hover { background: var(--ground); color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--sub); font-size: 13px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.panel-h h2 { font-size: 15px; margin: 0; }
.panel-b { padding: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--sub); font-weight: 600; background: #fbfbfa; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--sub); }
.hint { color: var(--hint); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--sub); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ground); color: var(--sub); white-space: nowrap; }
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.err { background: var(--err-tint); color: var(--err); }
.badge.info { background: var(--info-tint); color: var(--info); }
.badge.brand { background: var(--brand-tint); color: var(--brand-ink); }
.badge.wechat { background: var(--wechat-tint); color: #058a45; }

.seg { display: inline-flex; background: var(--ground); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--sub); font-weight: 500; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }

.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--ground); display: block; }
.name-zh { font-weight: 600; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; border: 0; background: #d4d4d4; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(16px); }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; font-weight: 600; }
.inp, select.inp, textarea.inp { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.inp:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea.inp { resize: vertical; min-height: 64px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.sec-t { font-size: 13px; font-weight: 700; margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.sec-t:first-child { margin-top: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--brand-tint); cursor: pointer; }
.check input { margin-top: 3px; }

/* 서랍 */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--panel); z-index: 41; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.drawer-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-h h2 { margin: 0; font-size: 16px; flex: 1; }
.drawer-b { padding: 20px; overflow: auto; flex: 1; }
.drawer-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.photo-edit { display: flex; gap: 14px; align-items: center; }
.photo-edit img { width: 132px; height: 96px; object-fit: cover; border-radius: 10px; background: var(--ground); }
.prod { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.prod.hidden-p { opacity: .55; }

/* 상담함 */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 180px); min-height: 520px; }
.inbox-list { border-right: 1px solid var(--line); overflow: auto; }
.thread { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: block; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.thread:hover { background: #fbfbfa; }
.thread.on { background: var(--brand-tint); }
.thread .t1 { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.thread .t2 { color: var(--sub); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.thread .t3 { font-size: 12px; color: var(--hint); margin-top: 2px; }
.unread { margin-left: auto; min-width: 20px; height: 20px; border-radius: 10px; background: var(--err); color: #fff; font-size: 11px; text-align: center; line-height: 20px; padding: 0 6px; }
.conv { display: flex; flex-direction: column; min-width: 0; }
.conv-h { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.conv-b { flex: 1; overflow: auto; padding: 18px; background: #fafaf8; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.guest { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-top-left-radius: 4px; }
.msg.staff { background: var(--ink); color: #fff; align-self: flex-end; border-top-right-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--hint); margin-top: 3px; }
.msg.staff + .msg-meta { align-self: flex-end; }
.msg.system { align-self: center; background: var(--info-tint); color: var(--info); font-size: 12px; border-radius: 999px; padding: 4px 12px; max-width: 90%; text-align: center; }
.conv-f { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 8px; align-items: flex-end; }
.conv-f textarea { flex: 1; min-height: 44px; max-height: 140px; }
.quota { font-size: 12px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--wechat-tint); color: #056b37; }
.quota.off { background: var(--err-tint); color: var(--err); }

.login { max-width: 360px; margin: 14vh auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login h1 { display: flex; gap: 8px; align-items: center; }
.login h1 i { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: inline-block; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--err); }

.new-flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { background: #fff1b8; } 100% { background: transparent; } }

@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
  .conv-b { min-height: 360px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
[hidden] { display: none !important; }
