/* ===== 디자인 토큰 ===== */
:root {
  --bg: #f8fafc;
  --card: #fff;
  --ink: #0f172a;
  --ink-dim: #64748b;
  --ink-light: #94a3b8;
  --accent: #2563eb;
  --accent-dark: #1e40af;
  --accent-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #ea580c;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --divider: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "맑은 고딕", -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
}

body { display: flex; flex-direction: column; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--divider);
  background: var(--card);
}
.brand { display: flex; align-items: baseline; gap: 16px; }
.brand h1 { font-size: 20px; margin: 0; }
.status { color: var(--ink-dim); font-size: 13px; }

.actions { display: flex; gap: 8px; }
button {
  font: inherit; cursor: pointer; padding: 8px 14px;
  border: 1px solid var(--divider); background: var(--card);
  border-radius: 6px; color: var(--ink);
}
button:hover { background: var(--accent-soft); }
button.ghost { background: var(--card); color: var(--ink-dim); }
button.ghost:hover { background: #f1f5f9; color: var(--ink); }
button.ghost.small { padding: 4px 10px; font-size: 12px; }
button.primary {
  background: var(--accent); color: white; border: none;
  font-weight: bold; padding: 12px 24px; font-size: 15px;
}
button.primary:hover { background: var(--accent-dark); }
button.copy-btn {
  background: var(--accent-soft); color: var(--accent-dark);
  border: none; padding: 6px 12px; font-weight: bold; font-size: 12px;
}

.filters {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--divider);
  background: var(--card);
}
.filters select, .filters input[type=text], .filters input:not([type]) {
  padding: 6px 10px; border: 1px solid var(--divider); border-radius: 6px;
  font: inherit; min-width: 140px;
}
.filters input { min-width: 200px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink-dim); }
.counter { margin-left: auto; color: var(--ink-dim); font-weight: 500; }

.layout {
  display: grid; grid-template-columns: 340px 1fr;
  gap: 12px; padding: 12px 24px;
  flex: 1; overflow: hidden;
}

.card {
  background: var(--card); border-radius: 8px; box-shadow: var(--shadow);
  padding: 14px; overflow: hidden;
}
.card-h {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 8px;
}
.card h3 { margin: 0 0 6px 0; font-size: 15px; }
.hint { color: var(--ink-dim); font-size: 12px; }

/* 목록 - 카드 형태 */
.list-pane { display: flex; flex-direction: column; }
.list-cards { flex: 1; overflow: auto; padding: 4px; display: flex; flex-direction: column; gap: 6px; }
.inq-card {
  background: white; border: 1px solid var(--divider); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; transition: all .12s;
}
.inq-card:hover { border-color: var(--accent); background: #fafbfc; }
.inq-card.selected { border-color: var(--accent); border-width: 2px; background: var(--accent-soft); padding: 9px 11px; }
.inq-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.inq-grade { font-size: 14px; }
.inq-mall {
  font-size: 11px; font-weight: bold; padding: 2px 8px; border-radius: 4px;
  background: #f1f5f9; color: var(--ink-dim);
}
.inq-mall.mall-스마트스토어 { background: #dcfce7; color: #03c75a; }
.inq-mall.mall-쿠팡 { background: #fee2e2; color: #f70066; }
.inq-mall.mall-지마켓 { background: #dbeafe; color: #00bfff; }
.inq-mall.mall-옥션 { background: #fee2e2; color: #e60012; }
.inq-mall.mall-11번가 { background: #fee2e2; color: #ff1a1a; }
.inq-cat { font-size: 11px; color: var(--ink-dim); padding: 2px 6px; background: #f1f5f9; border-radius: 4px; }
.inq-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; margin-left: auto; }
.inq-mid { display: flex; gap: 8px; margin: 4px 0; align-items: baseline; }
.inq-buyer { font-weight: bold; color: var(--ink); font-size: 13px; }
.inq-order { color: var(--ink-dim); font-size: 12px; font-family: ui-monospace,monospace; }
.inq-preview {
  font-size: 12px; color: var(--ink-dim); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* 전송 상태 */
.inq-card.send-verified { background: var(--success-soft); border-color: var(--success); }
.inq-card.send-sending { background: #fef3c7; border-color: #92400e; }
.inq-card.send-failed { background: #fee2e2; border-color: var(--danger); }

/* 상세 */
.detail-pane { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.detail-pane .row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.detail-pane .row:first-child { min-height: 280px; max-height: 380px; }
.detail-pane .row:last-child { flex: 1; min-height: 0; }
.detail-q, .detail-a { display: flex; flex-direction: column; }
.meta { color: var(--ink-dim); font-size: 13px; margin: 4px 0 8px 0; }

.order-card {
  background: var(--accent-soft); padding: 10px 14px;
  border-radius: 8px; display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.order-label { color: var(--accent-dark); font-weight: bold; font-size: 12px; }
#order-no {
  border: 1px solid var(--divider); padding: 6px 10px;
  font-weight: bold; font-size: 14px; min-width: 200px;
  background: white; border-radius: 4px;
}
.badge {
  font-weight: bold; font-size: 12px; padding: 4px 10px; border-radius: 4px;
}
.badge.color-green { background: var(--success-soft); color: var(--success); }
.badge.color-blue { background: var(--accent-soft); color: var(--accent-dark); }
.badge.color-red { background: #fee2e2; color: var(--danger); }
.badge.color-orange { background: var(--warning-soft); color: var(--warning); }
.badge.color-gray { background: #f1f5f9; color: var(--ink-dim); }

.text-area {
  background: #f8fafc; padding: 12px; border-radius: 6px;
  font: inherit; flex: 1; overflow: auto; white-space: pre-wrap;
  border: none; resize: none;
}
.text-area.readonly { cursor: default; }

.detail-a { background: var(--accent-soft); }
.cat-label { color: var(--danger); font-weight: bold; font-size: 13px; }
.grade-hint { color: var(--ink-dim); font-size: 12px; font-weight: bold; margin-bottom: 6px; }
.answer-box {
  background: white; border: none; padding: 14px;
  font: inherit; font-size: 15px; line-height: 1.6;
  flex: 1; min-height: 220px; resize: vertical; border-radius: 6px;
}

.send-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
}
.send-left .send-title { color: var(--success); font-weight: bold; }
.send-hint { color: var(--ink-dim); font-size: 12px; margin-top: 2px; }
.send-right { display: flex; gap: 8px; }

.bottom-l, .bottom-r { max-height: 320px; overflow: auto; display: flex; flex-direction: column; }
.track-result { color: var(--success); font-weight: bold; margin-top: 8px; font-size: 13px; }

/* 주문/배송 그리드 */
.order-grid { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.o-empty { color: var(--ink-light); padding: 20px; text-align: center; font-size: 13px; }
.o-card {
  background: #fafbfc; border: 1px solid var(--divider); border-radius: 8px;
  padding: 10px 12px;
}
.o-card.o-cancelled { background: #fee2e2; border-color: #fca5a5; }
.o-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.o-tag { background: var(--accent-soft); color: var(--accent-dark); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.o-tag-cancel { background: var(--danger); color: white; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.o-title { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-memo {
  background: #fff7ed; border-left: 3px solid var(--warning);
  color: #9a3412; padding: 6px 10px; border-radius: 4px; font-size: 13px;
  font-weight: 600; margin-bottom: 6px;
}
.o-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 12px; }
.o-row { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.o-k { color: var(--ink-dim); min-width: 56px; flex-shrink: 0; font-size: 11px; }
.o-v { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* 빠른 답변 - 큰 버튼 */
.tpl-section { margin-top: 10px; }
.tpl-label { color: var(--ink-dim); font-size: 12px; font-weight: bold; margin-bottom: 6px; }
.tpl-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-btn {
  border: none; padding: 14px 16px; font-weight: bold; font-size: 14px;
  border-radius: 8px; cursor: pointer; flex: 1; min-width: 110px;
  transition: all .12s;
}
.tpl-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-content { background: white; border-radius: 8px; max-width: 800px; width: 90%; max-height: 80vh; overflow: auto; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--divider); }
.modal-h h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; padding: 4px 12px; }
.modal-close:hover { background: var(--bg); }
#modal-body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { padding: 14px; border-radius: 8px; }
.stat-card .stat-label { color: var(--ink-dim); font-size: 12px; }
.stat-card .stat-value { font-size: 24px; font-weight: bold; margin-top: 4px; }

.cat-table { width: 100%; border-collapse: collapse; }
.cat-table th, .cat-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--divider); font-size: 13px; }
.cat-table th { color: var(--ink-dim); font-weight: 600; }

/* ===== 인증 페이지 ===== */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}
.auth-card {
  background: white; padding: 40px 36px; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08); width: 380px; max-width: 90%;
}
.auth-card h1 { margin: 0; font-size: 24px; color: var(--ink); }
.auth-sub { color: var(--ink-dim); margin: 4px 0 24px 0; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { font-size: 12px; color: var(--ink-dim); font-weight: 600; }
.auth-form input {
  padding: 10px 12px; border: 1px solid var(--divider); border-radius: 6px;
  font: inherit; font-size: 14px;
}
.auth-form input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.auth-form button.primary { margin-top: 12px; padding: 12px; font-size: 15px; }
.auth-foot { margin-top: 20px; text-align: center; color: var(--ink-dim); font-size: 13px; }
.auth-foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.err {
  background: #fee2e2; color: var(--danger); padding: 10px 12px;
  border-radius: 6px; margin-bottom: 12px; font-size: 13px;
}

/* ===== 사용자 칩 / 로그아웃 ===== */
.user-chip {
  background: var(--accent-soft); color: var(--accent-dark);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.btn-link { text-decoration: none; }
a.btn-link { display: inline-block; }

/* ===== 빈 데이터 안내 ===== */
.empty-data {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 40px; color: var(--ink-dim);
  text-align: center;
}
.empty-data.hidden { display: none; }
.empty-icon { font-size: 48px; }
.empty-data button { margin-top: 12px; }

/* ===== 설정 모달 ===== */
.upload-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0 24px 0; }
.up-card {
  background: var(--bg); border: 1px solid var(--divider); border-radius: 8px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.up-label { font-size: 13px; color: var(--ink); font-weight: 500; }
.up-st { font-size: 11px; padding: 2px 8px; background: #f1f5f9; color: var(--ink-dim); border-radius: 4px; margin-left: 6px; }
.up-st.ok { background: var(--success-soft); color: var(--success); }
.up-desc { font-size: 11px; color: var(--ink-light); display: block; }
.up-card button { padding: 6px 12px; font-size: 12px; }
#settings-body h3 { margin: 16px 0 6px 0; font-size: 15px; }
.settings-status {
  background: var(--bg); padding: 12px; border-radius: 6px;
  font-size: 13px; line-height: 1.8;
}
.settings-foot { margin-top: 20px; text-align: right; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .detail-pane .row { grid-template-columns: 1fr; }
  .upload-row { grid-template-columns: 1fr; }
}
