/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 유틸리티 — 모든 요소에 적용 */
.hidden { display: none !important; }

:root {
  --primary: #7c3aed;
  --primary-light: #ede9fe;
  --primary-dark: #5b21b6;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg: #f5f4fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --sidebar-w: 220px;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
}

html, body { height: 100%; }
body {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(160deg, #1e1b4b 0%, #312e81 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon { font-size: 28px; }
.brand-name  { font-size: 17px; font-weight: 700; color: #fff; }
.brand-sub   { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; }

.sidebar-nav { padding: 16px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-version { font-size: 11px; color: rgba(255,255,255,.3); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;          /* flex 아이템 넘침 방지 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.topbar-date  { font-size: 13px; color: var(--text-muted); }

/* ── Pages ────────────────────────────────────────────────────────────────── */
.page { padding: 28px 28px 48px; width: 100%; min-width: 0; overflow-x: hidden; }
.page.hidden { display: none !important; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
  overflow: hidden;
}
.card-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Stat Cards ───────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: 100px;
}
.stat-card.skeleton { animation: pulse 1.4s infinite; background: #e5e7eb; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-icon  { font-size: 28px; float: right; opacity: .8; }
.stat-card.purple { border-top: 3px solid var(--primary); }
.stat-card.green  { border-top: 3px solid var(--success); }
.stat-card.amber  { border-top: 3px solid var(--warning); }
.stat-card.blue   { border-top: 3px solid var(--info); }

/* ── Dashboard Row ────────────────────────────────────────────────────────── */
.dashboard-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.flex-1 { flex: 1; min-width: 300px; }

/* ── Bar Chart ────────────────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 88px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); transition: width .5s ease; }
.bar-count { width: 28px; font-size: 12px; font-weight: 600; color: var(--text); }

/* ── Status List ──────────────────────────────────────────────────────────── */
.status-list { display: flex; flex-direction: column; gap: 10px; }
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.status-dot-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-count { font-size: 13px; font-weight: 600; }

/* ── Filter Bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-group { display: flex; gap: 6px; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.input, .select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.input { min-width: 240px; }
.select { cursor: pointer; }
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.table-wrap { overflow-x: auto; width: 100%; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #faf9ff; }

.order-no { font-family: monospace; font-size: 12px; color: var(--primary); font-weight: 600; }
.product-name { font-weight: 500; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-cell { font-weight: 600; text-align: right; }

/* ── Badge / Status ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-결제완료   { background: #dbeafe; color: #1d4ed8; }
.badge-상품준비중  { background: #fef9c3; color: #92400e; }
.badge-배송중     { background: #ede9fe; color: #5b21b6; }
.badge-배송완료   { background: #d1fae5; color: #065f46; }
.badge-취소      { background: #fee2e2; color: #991b1b; }
.badge-반품      { background: #fce7f3; color: #9d174d; }

.platform-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding-top: 20px;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.page-btn:hover  { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none !important; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.95) translateY(10px); opacity: 0; } }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}
.modal-title    { font-size: 17px; font-weight: 700; }
.modal-order-no { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-family: monospace; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}
.edit-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail-item {}
.detail-key   { font-size: 11px; color: var(--text-light); margin-bottom: 3px; }
.detail-value { font-size: 13px; font-weight: 500; color: var(--text); }

.status-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status-select-row .select { flex: 1; min-width: 160px; }

.memo-row { display: flex; flex-direction: column; gap: 8px; }
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: toastIn .2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

/* ── 닉네임 그룹 카드 (주문서 탭) ────────────────────────────────────────── */
.order-list-meta {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* ── 주문 테이블 (플랫, 구글시트 스타일) ─────────────────────────────────── */
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* 컬럼 헤더 */
.order-table thead th {
  padding: 8px 12px;
  background: #f5f5f7;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.order-table .ot-h-price { text-align: right; }
.order-table .ot-h-act   { width: 80px; }
.order-table .ot-h-nick  { width: 120px; }
.order-table .ot-h-pay   { width: 130px; }

/* ── 주문 행 ── */
.ot-row td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.ot-row:hover td { background: rgba(0,0,0,.025); }
.ot-row.ot-editing td { background: #faf5ff; }

/* 그룹 경계: 새 닉네임 첫 행에 굵은 구분선 */
.ot-row.ot-group-start td { border-top: 2px solid #e2e8f0; }

/* 상태별 배경 (매우 연하게) */
.ot-row.ogr-none    td { background: #fff8f8; }
.ot-row.ogr-partial td { background: #fffaf5; }
.ot-row.ogr-over    td { background: #fefdf0; }
.ot-row.ogr-done    td { background: #f8fffe; }
.ot-row.ogr-none.ot-group-start td,
.ot-row.ogr-partial.ot-group-start td,
.ot-row.ogr-over.ot-group-start td,
.ot-row.ogr-done.ot-group-start td { border-top: 2px solid #e2e8f0; }
.ot-row.ot-editing td { background: #faf5ff !important; }

/* 셀 스타일 */
.ot-nick-cell,
.ot-name-cell,
.ot-phone-cell,
.ot-addr-cell  { vertical-align: middle !important; }
.order-table .ot-h-name  { width: 80px; }
.order-table .ot-h-phone { width: 110px; }
.order-table .ot-h-addr  { width: 160px; }
.ot-nick      { font-weight: 700; color: var(--primary); font-size: 13px; }
.ot-name      { font-size: 13px; color: var(--text-muted); }
.ot-phone     { font-size: 12px; color: var(--text-muted); }
.ot-addr      { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 160px; }
.ot-nick-cont { font-size: 12px; color: #c8c8c8; }
.ot-item      { font-weight: 500; color: var(--text); }
.ot-price     { text-align: right; font-weight: 700; color: var(--primary); white-space: nowrap; }
.ot-size,
.ot-color     { color: var(--text-muted); font-size: 12px; }
.ot-act       { text-align: right; white-space: nowrap; }

/* 입금 상태 셀 */
.ot-pay { vertical-align: middle; text-align: center; }
.ot-pay-amt {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}
.ot-no-dep { color: var(--text-light); font-size: 12px; }

.diff-plus  { color: #d97706; }
.diff-minus { color: var(--danger); }

/* 극소형 버튼 (수정/삭제) */
.btn-xs {
  padding: 3px 8px !important;
  font-size: 11px !important;
  border-radius: 5px !important;
}
.btn-del { color: var(--danger) !important; }

/* 상태 배지 */
.match-badge.status-done    { background: #d1fae5; color: #065f46; }
.match-badge.status-over    { background: #fef3c7; color: #92400e; }
.match-badge.status-partial { background: #ffedd5; color: #9a3412; }
.match-badge.status-none    { background: #fee2e2; color: #991b1b; }

/* ── 입금현황 배지 ────────────────────────────────────────────────────────── */
.match-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 200px;
}
.match-badge.matched {
  background: #d1fae5;
  color: #065f46;
}
.match-badge.unmatched {
  background: #fee2e2;
  color: #991b1b;
}
.match-badge-icon { font-size: 11px; flex-shrink: 0; }
.match-badge-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.match-badge-amt { flex-shrink: 0; }
.match-badge-amt.amt-diff {
  color: #d97706;
  background: #fef3c7;
  padding: 0 4px;
  border-radius: 4px;
}

/* ── 미연결 입금 직접 연결 테이블 ─────────────────────────────────────────── */
/* ── 매칭 현황 테이블 ──────────────────────────────────────────────────────── */
.mg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mg-table thead th {
  padding: 7px 12px;
  background: #f8f7ff;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mg-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}
.mg-table tbody tr:last-child { border-bottom: none; }
.mg-table td {
  padding: 7px 12px;
  vertical-align: middle;
}
.mg-table .mg-nick    { font-weight: 600; }
.mg-table .mg-name    { color: var(--text-muted); font-size: 12px; }
.mg-table .mg-num-r   { text-align: right; white-space: nowrap; }
.mg-table .mg-cnt     { color: var(--text-light); font-size: 11px; margin-left: 3px; }
.mg-table .mg-dep-ok  { color: var(--success); }
.mg-table .mg-dep-none { color: var(--text-light); }

/* ── 미연결 입금 직접 연결 테이블 ─────────────────────────────────────────── */
.dep-assign-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dep-assign-table thead th {
  padding: 7px 12px;
  background: #f8f7ff;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dep-assign-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background .08s;
}
.dep-assign-table tbody tr:last-child { border-bottom: none; }
.dep-assign-table tbody tr:hover { background: #fafafa; }
.dep-assign-table td { padding: 7px 12px; vertical-align: middle; }

.da-time  { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.da-amt   { white-space: nowrap; }
.da-payer { color: var(--text-muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.da-nick  { color: var(--info); font-size: 12px; white-space: nowrap; }
.da-assign {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 200px;
}
.da-input {
  flex: 1;
  min-width: 120px;
  max-width: 180px;
  height: 30px !important;
  padding: 0 8px !important;
  font-size: 12px !important;
}

/* ── 매칭 탭 액션 버튼 줄 ─────────────────────────────────────────────────── */
.match-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── 매칭 카드 (전체 현황 / 미연결 입금) ─────────────────────────────────── */
.match-card {}
.match-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* 각 그룹 행 */
.mg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}
.mg-row:last-child { border-bottom: none; }
.mg-row:hover { background: #fafafa; }

.mg-identity { display: flex; align-items: baseline; gap: 6px; min-width: 110px; }
.mg-nick  { font-size: 14px; font-weight: 700; color: var(--primary); }
.mg-name  { font-size: 12px; color: var(--text-muted); }

.mg-nums {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  font-size: 13px;
}
.mg-order   { color: var(--text-muted); }
.mg-dep     { color: var(--success); font-weight: 600; }
.mg-dep em  { font-style: normal; }
.mg-no-dep  { color: var(--text-light); font-size: 12px; }

/* ── Inner Tabs (주문서 / 입금매칭) ──────────────────────────────────────── */
.inner-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.inner-tab {
  padding: 10px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.inner-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.inner-tab:hover:not(.active) { color: var(--text); }

/* ── 매칭 요약 바 ─────────────────────────────────────────────────────────── */
.match-summary-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.match-stat { text-align: center; padding: 0 16px; }
.match-stat-val   { font-size: 22px; font-weight: 700; line-height: 1; }
.match-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.match-stat-divider { width: 1px; background: var(--border); align-self: stretch; margin: 0 4px; }

/* ── 수동매칭 힌트 바 ─────────────────────────────────────────────────────── */
.match-hint {
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #78350f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.match-hint.hidden { display: none !important; }

/* ── 미매칭 컬럼 레이아웃 ────────────────────────────────────────────────── */
.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}
.match-col {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.match-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.match-col-count {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.match-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

/* ── 매칭 아이템 카드 ────────────────────────────────────────────────────── */
.match-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.match-item:last-child { border-bottom: none; }
.match-item:hover { background: #faf9ff; }
.match-item.selected { background: var(--primary-light) !important; outline: 2px solid var(--primary); outline-offset: -2px; }
.match-item-main { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.match-nick { font-weight: 700; font-size: 13px; color: var(--primary); }
.match-name { font-size: 12px; color: var(--text-muted); }
.match-item-sub { display: flex; align-items: center; justify-content: space-between; }
.match-item-product { font-size: 12px; color: var(--text-muted); }
.match-item-price { font-size: 13px; font-weight: 700; color: var(--text); }

/* ── CSV Modal ────────────────────────────────────────────────────────────── */
.csv-modal { max-width: 680px; }

.csv-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
}
.csv-tab {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: background .15s, color .15s;
}
.csv-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.csv-tab:hover:not(.active) { color: var(--text); }

.csv-paste-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.csv-paste-area {
  width: 100%;
  font-size: 13px;
  font-family: 'Noto Sans KR', monospace;
  min-height: 160px;
  resize: vertical;
}

.csv-guide {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.csv-guide-title { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.csv-cols { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.csv-col {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.required-col { background: var(--primary-light); color: var(--primary-dark); border-color: transparent; }
.csv-guide-note { font-size: 12px; color: var(--text-light); line-height: 1.6; }

.csv-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.csv-drop-zone:hover, .csv-drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.csv-drop-icon { font-size: 36px; margin-bottom: 10px; }
.csv-drop-text { font-size: 14px; font-weight: 600; color: var(--text); }
.csv-drop-sub  { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.csv-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 16px 0 10px;
}
.csv-count-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.csv-mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.mapping-row { display: flex; flex-direction: column; gap: 4px; }
.mapping-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.mapping-select { width: 100%; }

.row-error td { background: #fff5f5 !important; }
.cell-warn { color: var(--danger) !important; }

.csv-errors {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
}
.csv-error-title { font-size: 12px; font-weight: 700; color: var(--danger); margin-bottom: 6px; }
.csv-error-item  { font-size: 12px; color: #7f1d1d; margin-top: 3px; }

/* ── Nav Divider ──────────────────────────────────────────────────────────── */
.nav-divider {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 14px 12px 4px;
}

/* ── Live Cards ───────────────────────────────────────────────────────────── */
.lives-grid { display: flex; flex-direction: column; gap: 24px; }
.live-date-group {}
.live-date-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 2px;
}
.live-cards-row { display: flex; flex-wrap: wrap; gap: 12px; }
.live-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 220px;
  max-width: 300px;
  cursor: pointer;
  transition: box-shadow .15s, transform .12s;
  border-left: 4px solid var(--primary);
  position: relative;
}
.live-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.live-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.live-card-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; }
.live-card-del {
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0 2px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.live-card-del:hover { color: var(--danger); background: #fee2e2; }
.live-card-note { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.live-card-footer { display: flex; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.live-card-count, .live-card-total { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ── Live Meta ────────────────────────────────────────────────────────────── */
.live-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.live-stats-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
}

/* ── 고객 목록 페이지 ─────────────────────────────────────────────────────── */
.cust-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cust-total-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

.cust-form-card { margin-bottom: 16px; }
.cust-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
  margin-bottom: 16px;
}

/* 고객 테이블 */
.cust-table .cust-id   { color: var(--text-light); font-size: 12px; font-variant-numeric: tabular-nums; }
.cust-table .cust-nick { font-weight: 700; color: var(--primary); }
.cust-table .cust-phone{ font-variant-numeric: tabular-nums; }
.cust-table .cust-addr { color: var(--text-muted); font-size: 13px; max-width: 260px; }
.cust-table .cust-memo { color: var(--text-light); font-size: 12px; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .cust-form-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Order Form ───────────────────────────────────────────────────────────── */
.order-form-card {}
.order-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
  margin-bottom: 16px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.required { color: var(--danger); }
.form-field .input { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Live Order Table ─────────────────────────────────────────────────────── */
.cell-item  { font-weight: 600; }
.cell-price { font-weight: 700; color: var(--primary); text-align: right; }
.cell-empty { color: var(--text-light); font-size: 12px; }
.row-editing td { background: #faf5ff !important; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .order-form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page { padding: 16px; }
  .input { min-width: 0; width: 100%; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-direction: column; }
  .order-form-grid { grid-template-columns: 1fr 1fr; }
}

/* ── 택배리스트 ──────────────────────────────────────────────────────────────── */
.delivery-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.dv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dv-table thead th {
  padding: 8px 12px;
  background: #f5f5f7;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.dv-table .dv-order-amt,
.dv-table .dv-dep-amt,
.dv-table .dv-count { text-align: right; }
.dv-row td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.dv-row:last-child td { border-bottom: none; }
.dv-row:hover td { background: #fafafa; }
.dv-nick       { font-weight: 700; color: var(--primary); white-space: nowrap; }
.dv-name       { color: var(--text-muted); white-space: nowrap; }
.dv-phone      { font-size: 12px; color: var(--text); white-space: nowrap; }
.dv-addr       { font-size: 12px; color: var(--text-muted); max-width: 200px; }
.dv-order-amt  { font-weight: 600; white-space: nowrap; }
.dv-dep-amt    { color: var(--success); white-space: nowrap; }
.dv-unpaid     { color: var(--danger) !important; }
.dv-count      { color: var(--text-muted); }
.dv-items      { font-size: 12px; color: var(--text); max-width: 300px; }
.dv-status     { white-space: nowrap; }
.dv-empty        { color: var(--text-light); }

/* ── 품목별 뷰 ──────────────────────────────────────────────────────────────── */
.items-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.iv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.iv-table thead th {
  padding: 8px 14px;
  background: #f5f5f7;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.iv-table .iv-h-qty,
.iv-table .iv-h-done,
.iv-table .iv-h-unpaid { text-align: center; width: 64px; }
.iv-table .iv-h-item { width: 200px; }

.iv-var-row td {
  padding: 9px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.iv-var-row:hover td { background: #fafafa; }

/* 품목 셀 */
.iv-item-cell {
  vertical-align: middle !important;
  border-right: 2px solid var(--border) !important;
  background: #fafbff !important;
}
.iv-item-name {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 4px;
}
.iv-item-total {
  display: inline-block;
  font-size: 11px;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 7px;
  border-radius: 10px;
  margin-right: 4px;
}
.iv-item-done {
  display: inline-block;
  font-size: 11px;
  background: #d1fae5;
  color: #065f46;
  padding: 2px 7px;
  border-radius: 10px;
}

/* 사이즈/색상 */
.iv-size  { font-weight: 600; color: var(--text); }
.iv-color { color: var(--text-muted); }

/* 수량 - 크게 */
.iv-qty     { text-align: center; }
.iv-qty-num {
  display: inline-block;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  min-width: 36px;
  text-align: center;
}

/* 완료/미입금 카운트 */
.iv-done-cnt,
.iv-unpaid-cnt { text-align: center; }
.iv-done {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  min-width: 28px;
  text-align: center;
}
.iv-unpaid {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  min-width: 28px;
  text-align: center;
}

/* 품목 경계선 */
.iv-var-row:first-child td { border-top: 2px solid #e2e8f0; }
.dv-section-title {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}
.dv-section-cnt   { font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.dv-title-paid    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.dv-title-unpaid  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
