/* ═══════════════════════════════════════════════
   M.center v2 - 공통 스타일시트
   역할별 색상 구분, 사이드바 레이아웃, 컴포넌트
═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
  /* 브랜드 컬러 */
  --primary: #1A3C6E;
  --primary-light: #2A5298;
  --accent: #E67E22;

  /* 역할별 컬러 */
  --admin-color: #1A3C6E;
  --seller-color: #16A085;
  --customer-color: #7D3C98;
  --branch-color: #6D4C41;

  /* 상태 컬러 */
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #C0392B;
  --info: #2980B9;

  /* 수수료 전용 */
  --tax-red: #C0392B;
  --net-blue: #1565C0;
  --gross-dk: #2C2C2C;

  /* 레이아웃 */
  --sidebar-width: 240px;
  --topbar-height: 56px;

  /* 배경/텍스트 */
  --bg-main: #F4F6F9;
  --bg-card: #FFFFFF;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden; /* 모바일 가로 스크롤 전역 차단 */
}

/* ── 레이아웃 ───────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── 사이드바 ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--admin-color);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar.seller { background: var(--seller-color); }
.sidebar.customer { background: var(--customer-color); }
.sidebar.branch { background: var(--branch-color); }

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-logo .logo-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
}
.sidebar-logo .logo-sub {
  font-size: 11px; opacity: 0.65; margin-top: 2px;
}

.sidebar-user {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.sidebar-user .user-info .name { font-size: 13px; font-weight: 600; }
.sidebar-user .user-info .role-badge {
  font-size: 10px; opacity: 0.75;
  background: rgba(255,255,255,0.15);
  padding: 1px 6px; border-radius: 8px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; opacity: 0.5;
  padding: 10px 18px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all 0.18s;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-left-color: #fff;
  font-weight: 600;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.6); text-decoration: none;
  font-size: 13px;
}
.sidebar-footer a:hover { color: #fff; }

/* ── 모바일 topbar 로그아웃 버튼 ─────────────────── */
.topbar-logout {
  display: none; /* PC에서는 숨김 */
}
@media (max-width: 768px) {
  .topbar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    color: #6B7280;
    font-size: 18px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s;
  }
  .topbar-logout:hover,
  .topbar-logout:active {
    background: #FEE2E2;
    color: #DC2626;
  }
}

/* ── 메인 콘텐츠 ──────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }
.breadcrumb { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── 카드 ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── 스탯 카드 ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue   { background: var(--info); }
.stat-card .stat-icon.green  { background: var(--success); }
.stat-card .stat-icon.orange { background: var(--accent); }
.stat-card .stat-icon.red    { background: var(--danger); }
.stat-card .stat-icon.teal   { background: var(--seller-color); }
.stat-card .stat-icon.purple { background: var(--customer-color); }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-card .stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-card .stat-sub   { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ── 테이블 ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #F8F9FA;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }

/* ── 배지 ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-success  { background: #DCFCE7; color: #166534; }
.badge-warning  { background: #FEF9C3; color: #854D0E; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }
.badge-secondary{ background: #F1F5F9; color: #475569; }
.badge-sale     { background: #E0F2FE; color: #0369A1; }
.badge-override { background: #F3E8FF; color: #6B21A8; }

/* ── 버튼 ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none; cursor: pointer;
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  transition: all 0.18s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #229954; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-secondary { background: #F1F5F9; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #E2E8F0; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 6px; }

/* ── 폼 ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.18s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
select.form-control { appearance: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── 검색바 ────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  flex: 1; max-width: 320px;
}
.search-bar input {
  border: none; outline: none; flex: 1;
  font-size: 13px; font-family: inherit;
}
.search-bar i { color: var(--text-secondary); }

/* ── 모달 ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 520px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  transform: translateY(20px); transition: transform 0.2s;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal-overlay.show .modal { transform: translateY(0); }


.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-secondary); padding: 2px;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── 알림 토스트 ────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--text-primary);
  color: #fff; min-width: 260px;
  font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: slideInRight 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── 수수료 정산 전용 ────────────────────────────── */
.comm-header-banner {
  background: linear-gradient(135deg, #1A3C6E 0%, #2A5298 100%);
  color: #fff; padding: 16px 22px;
  border-radius: 10px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.comm-header-banner .formula {
  font-size: 13px; opacity: 0.85; margin-top: 4px;
}
.comm-header-banner .tax-badge {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 600;
}

.comm-row-gross   { color: var(--gross-dk); font-weight: 600; }
.comm-row-tax     { color: var(--tax-red);  font-size: 12px; }
.comm-row-net     { color: var(--net-blue); font-weight: 700; }

.deduction-badge {
  display: inline-block;
  background: #FFF3E0; color: #E65100;
  padding: 1px 6px; border-radius: 4px;
  font-size: 11px; margin-left: 4px;
}

/* ── 프린트 ────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay,
  .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff !important; }
}

/* ══════════════════════════════════════════════════
   모바일 햄버거 메뉴 & 오버레이
══════════════════════════════════════════════════ */

/* 햄버거 버튼 - PC에서는 숨김 */
.hamburger-btn {
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: none; background: none;
  cursor: pointer; padding: 4px;
  border-radius: 8px;
  transition: background .15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(0,0,0,0.06); }
.hamburger-btn .hb-bar {
  display: block; width: 20px; height: 2px;
  background: #374151; border-radius: 2px;
  transition: transform .3s, opacity .3s;
}
.hamburger-btn .hb-bar + .hb-bar { margin-top: 5px; }

/* 사이드바 열린 상태 - X 모양 */
.hamburger-btn.open .hb-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open .hb-bar:nth-child(2) { opacity: 0; }
.hamburger-btn.open .hb-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 어두운 오버레이 */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* 사이드바 전환 애니메이션 */
.sidebar {
  transition: transform .28s cubic-bezier(0.4,0,0.2,1);
  z-index: 200;
}

/* ── 반응형 ────────────────────────────────────── */
@media (max-width: 768px) {
  /* 사이드바: 기본 숨김, .open시 나타남 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }

  /* 메인 컨텐츠: 전체 너비 */
  .main-content { margin-left: 0; }

  /* 햄버거 버튼 표시 */
  .hamburger-btn { display: flex; flex-direction: column; }

  /* topbar에서 제목 잘림 방지 */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-title { font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 8px; flex-shrink: 0; }

  /* 그리드 반응형 */
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row  { grid-template-columns: 1fr; }

  /* 페이지 패딩 축소 */
  .page-content { padding: 14px; }
  .page-header  { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* main-content overflow 방지 */
  .main-content { overflow-x: hidden; min-width: 0; }
}

@media (max-width: 480px) {
  .page-content { padding: 10px; }
}

/* ── 유틸리티 ───────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16  { margin-top: 16px; }
.mt-20  { margin-top: 20px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--text-secondary); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-blue   { color: var(--net-blue); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.w-full { width: 100%; }
.loading { opacity: 0.5; pointer-events: none; }

/* 빈 상태 */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-secondary);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* 로딩 스피너 */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════
   고객 전용 모바일 하단 탭바
   PC(>768px): display:none  /  모바일(≤768px): flex
════════════════════════════════════════════════ */
.cust-bottom-nav {
  display: none; /* PC 기본 숨김 */
}

@media (max-width: 768px) {
  /* 탭바 컨테이너 */
  .cust-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: #fff;
    border-top: 1px solid #E5E7EB;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    z-index: 300;
    align-items: stretch;
  }

  /* 탭 아이템 */
  .cust-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: #9CA3AF;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
  }

  .cust-tab-item i {
    font-size: 20px;
    transition: transform .15s;
  }

  /* 활성 탭 */
  .cust-tab-item.active {
    color: #1A3C6E;
  }
  .cust-tab-item.active i {
    transform: translateY(-2px);
  }

  /* 활성 탭 상단 인디케이터 */
  .cust-tab-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    background: #1A3C6E;
    border-radius: 0 0 3px 3px;
  }

  /* 탭바 높이만큼 페이지 하단 여백 */
  .main-content.has-bottom-nav {
    padding-bottom: 62px;
  }
}
