:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-alt: #f1f4f5;
  --border: #e3e8ea;
  --text: #1f2d33;
  --text-2: #56666d;
  --muted: #8d9aa0;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: rgba(20, 184, 166, 0.12);
  --header: #03363d;
  --warn-bg: #fef3c7;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1f; --surface: #16242b; --surface-alt: #1c2d35; --border: #2a3d46;
    --text: #e8f0f2; --text-2: #aab9bf; --muted: #7d8f96; --brand: #2dd4bf; --brand-2: #2dd4bf;
    --brand-soft: rgba(45, 212, 191, 0.14); --header: #021f24; --warn-bg: #3b2f12; --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── 헤더 / 메뉴 ── */
.cs-header { background: var(--header); color: #fff; position: sticky; top: 0; z-index: 10; }
.cs-header-inner { max-width: 960px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cs-logo { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cs-logo b { font-weight: 800; }
.cs-logo-mark { background: var(--brand-2); color: #03363d; font-weight: 900; font-size: 12px; padding: 3px 6px; border-radius: 6px; }
.cs-user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cs-user[hidden] { display: none; }
.cs-grade { background: rgba(255, 255, 255, 0.16); padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.cs-link-btn { background: none; border: none; color: rgba(255, 255, 255, 0.75); cursor: pointer; font-size: 12px; padding: 4px; }
.cs-link-btn:hover { color: #fff; }
.cs-nav { max-width: 960px; margin: 0 auto; padding: 0 8px; display: flex; overflow-x: auto; scrollbar-width: none; }
.cs-nav[hidden] { display: none; }
.cs-nav a { flex: none; padding: 10px 14px 12px; color: rgba(255, 255, 255, 0.7); font-weight: 600; border-bottom: 3px solid transparent; }
.cs-nav a.active { color: #fff; border-bottom-color: var(--brand-2); }

.cs-banner { background: var(--warn-bg); color: var(--warn); font-size: 13px; font-weight: 600; text-align: center; padding: 8px 16px; }
.cs-banner[hidden] { display: none; }
.cs-main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.cs-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 28px; border-top: 1px solid var(--border); }
.cs-footer span { font-size: 11px; }

/* ── 공통 ── */
.cs-title { font-size: 20px; font-weight: 800; margin: 4px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cs-sub { color: var(--text-2); margin: -8px 0 16px; font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title a { font-size: 12px; font-weight: 600; color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 10px; border: none; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-alt); color: var(--text-2); white-space: nowrap; }
.pill.new, .pill.open, .pill.hold { background: var(--warn-bg); color: var(--warn); }
.pill.pending, .pill.solved { background: var(--brand-soft); color: var(--brand); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface);
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover .list-main strong { color: var(--brand); }
.list-main { flex: 1; min-width: 0; }
.list-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ── 로그인 ── */
.login-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.login-card { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; box-shadow: var(--shadow); font: inherit; color: var(--text); }
.login-card:hover { border-color: var(--brand-2); }
.login-card strong { font-size: 16px; }

/* ── 홈 ── */
.hero { background: linear-gradient(135deg, var(--header), #0f766e); color: #fff; border-radius: 16px; padding: 22px 22px; margin-bottom: 16px; }
.hero h2 { margin: 0 0 4px; font-size: 21px; }
.hero p { margin: 0; opacity: .85; font-size: 13.5px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px; text-align: center; box-shadow: var(--shadow); }
.quick:hover { border-color: var(--brand-2); }
.quick-icon { font-size: 26px; }
.quick b { display: block; margin-top: 4px; }
.quick span { font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .quick-grid { grid-template-columns: 1fr; } }

/* ── 1:1 문의 상세 ── */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); }
.msg.agent { background: var(--brand-soft); border-color: transparent; }
.msg-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-head b { color: var(--text-2); }
.msg.agent .msg-head b { color: var(--brand); }
.msg-body { white-space: pre-line; }
.msg-att a { display: inline-block; margin-top: 6px; margin-right: 8px; font-size: 12px; color: var(--brand); }
.waiting { font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; }

/* ── 채팅 ── */
.chat-card { display: flex; flex-direction: column; height: min(640px, calc(100vh - 230px)); min-height: 420px; padding: 0; overflow: hidden; }
.chat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-top b { font-size: 15px; }
.chat-status { font-size: 12px; color: var(--muted); }
.chat-status.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; margin-right: 5px; vertical-align: 1px; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-alt); }
.bubble-row { display: flex; flex-direction: column; max-width: 78%; }
.bubble-row.me { align-self: flex-end; align-items: flex-end; }
.bubble-row.agent { align-self: flex-start; }
.bubble-who { font-size: 11.5px; color: var(--muted); margin: 0 4px 3px; }
.bubble { padding: 9px 13px; border-radius: 16px; white-space: pre-line; word-break: break-word; }
.me .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.agent .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-time { font-size: 10.5px; color: var(--muted); margin: 3px 4px 0; }
.chat-sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 4px 12px; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chat-quick button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chat-quick button:hover { border-color: var(--brand-2); color: var(--brand); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; font: inherit; color: var(--text); background: var(--surface); }
.chat-input input:focus { outline: none; border-color: var(--brand-2); }
.chat-input .btn { border-radius: 999px; }

/* ── 주문 ── */
.order { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; background: var(--surface); box-shadow: var(--shadow); }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.order-main { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; cursor: pointer; }
.order-main strong { font-size: 15px; }
.order-detail { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.order-detail[hidden] { display: none; }

/* ── 회원정보 ── */
.me-top { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface-alt); border-radius: 10px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } .stat-grid { grid-template-columns: 1fr 1fr 1fr; } }

.cs-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1f2d33; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100% - 32px); }
.cs-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 좁은 화면(휴대폰) - 가로로 넘치지 않게 */
html, body { overflow-x: hidden; }
@media (max-width: 480px) {
  .cs-header-inner { padding: 12px 14px; }
  .cs-logo { font-size: 15px; }
  #cs-user-name { display: none; }
  .cs-main { padding: 16px 12px 32px; }
  .hero { padding: 18px 16px; }
  .hero h2 { font-size: 18px; }
  .kv { grid-template-columns: 84px 1fr; }
  .bubble-row { max-width: 88%; }
}

/* 회원정보 하위 메뉴 + 배송지 관리 */
.sub-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.sub-tabs a { flex: none; padding: 9px 14px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.addr-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.addr-row:last-child { border-bottom: none; }
.addr-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 520px) { .addr-row { flex-direction: column; align-items: stretch; } .addr-actions { justify-content: flex-start; } }

/* 시연 데이터 편집 */
.demo-note { background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; margin-bottom: 10px; }
.demo-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.demo-grid input, .demo-grid select, .demo-table input, .demo-table select {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 13px; color: var(--text); background: var(--surface); width: 100%;
}
.demo-table-wrap { overflow-x: auto; }
.demo-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.demo-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 4px 6px; }
.demo-table td { padding: 3px 4px; }
.demo-x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; }
.demo-x:hover { color: var(--danger); }
.demo-save { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.demo-table select { min-width: 104px; }
.demo-table { min-width: 760px; }
