* { box-sizing: border-box; }

.nav-link.active {
  background-color: #3730a3;
  color: white;
}

.category-btn span {
  display: inline-block;
  padding: 6px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.category-btn input:checked + span {
  border-color: #6366f1;
  background-color: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}
.category-btn span:hover {
  border-color: #a5b4fc;
}

.size-preset-btn.selected {
  border-color: #6366f1;
  background-color: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}

.color-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 13px;
}
.color-tag button {
  color: #9ca3af;
  line-height: 1;
  cursor: pointer;
}
.color-tag button:hover { color: #ef4444; }

.size-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 13px;
  color: #5b21b6;
  font-weight: 500;
}
.size-tag button { color: #a78bfa; cursor: pointer; }
.size-tag button:hover { color: #7c3aed; }

/* ── 뷰 모드 토글 버튼 ── */
.view-mode-btn {
  border-color: #e5e7eb;
  color: #9ca3af;
  background: white;
}
.view-mode-btn:hover {
  border-color: #a5b4fc;
  color: #6366f1;
  background: #eef2ff;
}
.view-mode-btn.active {
  border-color: #6366f1;
  color: #6366f1;
  background: #eef2ff;
}

/* ── 그리드 뷰 ── */
#productGrid.mode-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px;
}
@media (min-width: 768px)  { #productGrid.mode-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { #productGrid.mode-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { #productGrid.mode-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.product-card:hover {
  border-color: #a5b4fc;
  box-shadow: 0 4px 16px rgba(99,102,241,0.12);
  transform: translateY(-2px);
}

.product-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f9fafb;
}
.product-img-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 40px;
}

/* ── 목록 뷰 ── */
#productGrid.mode-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 16px 10px 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.product-list-row:hover {
  border-color: #a5b4fc;
  box-shadow: 0 2px 10px rgba(99,102,241,0.1);
  background: #fafbff;
}
.product-list-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f3f4f6;
}
.product-list-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.product-list-info { flex: 1; min-width: 0; }
.product-list-name {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-list-sub {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}
.product-list-prices {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 120px;
  flex-shrink: 0;
}
.product-list-price-row { font-size: 12px; }
.product-list-stocks {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.product-list-stock-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
}

/* ── 표 뷰 ── */
#productGrid.mode-table {
  display: block;
}
.product-table {
  width: 100%;
  background: white;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-size: 13px;
}
.product-table thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.product-table thead th:hover { background: #f1f5f9; color: #4f46e5; }
.product-table thead th.sort-asc::after  { content: ' ↑'; }
.product-table thead th.sort-desc::after { content: ' ↓'; }
.product-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid #f1f5f9;
}
.product-table tbody tr:last-child { border-bottom: none; }
.product-table tbody tr:hover { background: #fafbff; }
.product-table td {
  padding: 9px 14px;
  color: #374151;
  vertical-align: middle;
}
.product-table td.td-name {
  font-weight: 600;
  color: #1f2937;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-table th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}
.inv-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}
.inv-table tr:last-child td { border-bottom: none; }
.inv-table tr:hover td { background: #fafafa; }

.qty-cell {
  font-weight: 700;
  color: #1e293b;
  font-size: 16px;
}
.def-cell { color: #ef4444; font-size: 13px; }
.smp-cell { color: #f59e0b; font-size: 13px; }

.color-tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.color-tab:hover { background: #f1f5f9; }
.color-tab.active {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4f46e5;
}

.wh-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}
.wh1 { background: #dbeafe; color: #1d4ed8; }
.wh2 { background: #fce7f3; color: #be185d; }

#toast.show { display: flex; animation: slideIn 0.2s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

.log-row td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f1f5f9; }
.badge-add { background:#dcfce7; color:#166534; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600; }
.badge-sub { background:#fee2e2; color:#991b1b; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600; }
.badge-set { background:#e0e7ff; color:#3730a3; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600; }

.color-item { border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; background: #fafafa; }

input[type=number]::-webkit-inner-spin-button { opacity: 1; }

.adjust-type-btn, .adjust-field-btn { cursor: pointer; transition: all 0.15s; }

/* ── Calendar ── */
.cal-grid {
  min-height: 480px;
}
.cal-day {
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  min-height: 100px;
  padding: 6px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: #fafbff; }
.cal-day.today .day-num {
  background: #6366f1;
  color: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .day-num { color: #cbd5e1; }
.cal-day.selected { background: #eef2ff; }
.cal-day.sunday .day-num { color: #ef4444; }
.cal-day.saturday .day-num { color: #3b82f6; }
.day-num {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}
.cal-event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.5;
}
.cal-event:hover { opacity: 0.85; }
.cal-more {
  font-size: 10px;
  color: #94a3b8;
  padding: 1px 4px;
}

/* Platform radio buttons */
.platform-btn span, .status-btn span {
  display: inline-block;
  padding: 5px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}
.platform-btn input:checked + span, .status-btn input:checked + span {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}
.platform-btn span:hover, .status-btn span:hover { border-color: #a5b4fc; }

.color-pick-btn.ring-indigo-500 { ring-color: #6366f1; }
.color-pick-btn { transition: transform 0.1s; }
.color-pick-btn:hover { transform: scale(1.15); }
.color-pick-btn.selected { ring-color: #1e293b; box-shadow: 0 0 0 2px #1e293b; }

/* Broadcast cards in day panel */
.bcast-card {
  border-radius: 8px;
  padding: 8px 10px;
  border-left: 4px solid;
  background: #fafafa;
  cursor: pointer;
  transition: background 0.1s;
}
.bcast-card:hover { background: #f1f5f9; }

/* Camera search button */
.camera-search-label { user-select: none; }
.camera-search-label:active { transform: scale(0.96); }

/* Image search result item */
#imageSearchResults > div { transition: all 0.12s; }

/* Similarity progress bar animation */
@keyframes barFill { from { width: 0 } }
#imageSearchResults .sim-bar { animation: barFill 0.5s ease-out; }

/* Export dropdown */
#exportDropdown a { transition: background 0.1s; }

/* Sales entry */
.sales-entry { transition: box-shadow 0.1s; }
.sales-entry:hover { box-shadow: 0 2px 8px rgba(16,185,129,0.08); }

/* Status badges */
.sbadge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600; }
.s-예정 { background:#dbeafe; color:#1e40af; }
.s-진행중 { background:#dcfce7; color:#166534; }
.s-완료 { background:#f1f5f9; color:#475569; }
.s-취소 { background:#fee2e2; color:#991b1b; }

/* ═══════════════════════════════════════════
   MOBILE BOTTOM NAV & MORE PANEL
   ═══════════════════════════════════════════ */

#mobileBottomNav { display: none; }
#mobileMorePanel { display: none; }

@media (max-width: 767px) {
  /* Hide desktop sidebar */
  #appPage > aside { display: none; }

  /* Account for bottom nav */
  #appPage > main { padding-bottom: 64px; }

  /* Toast above bottom nav */
  #toast {
    bottom: 76px;
    right: 12px;
    left: 12px;
    justify-content: center;
    text-align: center;
  }

  /* ── Bottom Navigation ── */
  #mobileBottomNav {
    display: flex;
    align-items: center;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mob-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 10px;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    gap: 3px;
    transition: color 0.15s;
  }
  .mob-nav-btn i { font-size: 18px; line-height: 1; }
  .mob-nav-btn.active { color: #6366f1; }
  .mob-nav-btn:active { opacity: 0.7; }

  .mob-nav-scan {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
  }
  .mob-nav-scan-inner {
    width: 50px;
    height: 50px;
    background: #6366f1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 14px rgba(99,102,241,0.45);
    transform: translateY(-10px);
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .mob-nav-scan:active .mob-nav-scan-inner {
    transform: translateY(-8px) scale(0.95);
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
  }

  /* ── More Panel ── */
  #mobileMorePanel {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
  }
  #mobileMorePanel.open {
    pointer-events: auto;
    visibility: visible;
  }
  .mob-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s;
  }
  #mobileMorePanel.open .mob-more-backdrop { background: rgba(0,0,0,0.4); }
  .mob-more-sheet {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(72px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  #mobileMorePanel.open .mob-more-sheet { transform: translateY(0); }

  .mob-more-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 4px;
  }
  .mob-more-export-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .mob-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    border-radius: 12px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 11px;
    color: #374151;
    font-weight: 500;
    border: none;
    text-decoration: none;
    transition: background 0.1s;
    text-align: center;
  }
  .mob-more-item i { font-size: 22px; }
  .mob-more-item:active { background: #e5e7eb; }

  /* ── Calendar: stack vertically on mobile ── */
  #view-calendar > div.flex.flex-col { flex-direction: column; }

  /* ── Dashboard grid: 2-col on mobile ── */
  #view-dashboard .grid.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

  /* ── 상품 목록뷰: 모바일 최적화 ── */
  .product-list-row { gap: 10px; padding: 10px 12px 10px 10px; }
  .product-list-thumb,
  .product-list-thumb-placeholder { width: 48px; height: 48px; flex-shrink: 0; }
  /* 재고 뱃지: 모바일에서 숫자만 작게 */
  .product-list-stocks { gap: 4px; }
  .product-list-stock-badge {
    min-width: 36px;
    padding: 3px 5px;
    font-size: 10px;
  }
  /* 불량·샘플 뱃지 숨기기 (재고만 표시) */
  .product-list-stock-badge:not(:first-child) { display: none; }

  /* ── 상품 표(table)뷰: 가로 스크롤 허용 ── */
  #productGrid.mode-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .product-table { min-width: 480px; font-size: 12px; }
  .product-table thead th { padding: 8px 10px; font-size: 10px; }
  .product-table td { padding: 7px 10px; }
  .product-table td.td-name { max-width: 120px; }

  /* ── 재고 상세 테이블: 가로 스크롤 ── */
  .inv-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inv-table { min-width: 360px; }

  /* ── 전체 뷰에서 가로 넘침 방지 ── */
  .view { overflow-x: hidden; }
  #view-products, #view-revenue, #view-sellers, #view-orders { overflow-x: hidden; }

  /* ── 모달: 하단 네비바 위로 올리기 ── */
  [id$="Modal"] {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
