/* MINSE 재고관리 시스템 스타일 */
:root {
  --primary: #2962ff;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --danger: #e53935;
  --success: #4caf50;
  --orange: #ff9800;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #333;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #2962ff, #651fff);
  color: white;
  padding: 16px 24px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.app-sub { font-size: 12px; opacity: 0.85; }

.tab-bar { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.tab-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.06);
  color: white;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tab-btn:hover { background: rgba(255,255,255,0.15); }
.tab-btn.active { background: white; color: #1a237e; box-shadow: 0 3px 10px rgba(0,0,0,0.25); }

/* Container & Cards */
.container { max-width: 1400px; margin: 10px auto 20px; padding: 0 12px; }

.card {
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  padding: 18px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title { font-size: 15px; font-weight: 600; }

/* Buttons */
.btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 10px rgba(37,99,235,0.4);
  white-space: nowrap;
  transition: transform 0.2s;
}

.btn:hover { transform: translateY(-1px); }
.btn.red { background: var(--danger); }
.btn.green { background: var(--success); }
.btn.orange { background: var(--orange); }
.btn.yellow { background: #f9a825; color: #333; }
.btn.gray { background: #757575; }
.btn.purple { background: #7b1fa2; }
.btn.outline { background: white; color: var(--primary); border: 1px solid var(--primary); box-shadow: none; }
.btn.sm { padding: 4px 10px; font-size: 11px; }

.icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-right: 2px;
}

.icon-btn.edit { background: #e3f2fd; color: #1e40af; }
.icon-btn.delete { background: #fee2e2; color: #b91c1c; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { background: #f9fafb; }
th, td { padding: 7px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; white-space: nowrap; }
th { font-weight: 600; color: #4b5563; }
tbody tr:hover { background: #eff6ff; }

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* Modals & Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.overlay.show { display: flex; }

.modal {
  width: 750px;
  max-width: 95vw;
  max-height: 90vh;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(15,23,42,0.4);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { overflow: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Popups */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 210;
}

.popup-box {
  background: white;
  width: 650px;
  max-width: 95vw;
  max-height: 85vh;
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(15,23,42,0.45);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.popup-box h3 { margin: 0 0 8px; font-size: 15px; }

.popup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.popup-footer-left, .popup-footer-right { display: flex; gap: 8px; }

/* Form Elements */
.input-row { margin-bottom: 10px; }
.input-row label { display: block; font-size: 12px; color: #4b5563; margin-bottom: 3px; }

.input-row input,
.input-row textarea,
.input-row select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  outline: none;
  background: #f9fafb;
}

.input-row input:focus,
.input-row textarea:focus,
.input-row select:focus {
  border-color: var(--primary);
  background: white;
}

.input-row input[readonly] { background: #e8e8e8; color: #666; }
.input-row input.locked { background: #fff3cd; color: #856404; border-color: #ffc107; }
textarea { resize: vertical; min-height: 50px; }

.pill-input-row { display: flex; gap: 6px; align-items: center; }
.pill-input-row input { flex: 1; }

.address-row { display: flex; gap: 6px; align-items: flex-start; }
.address-detail { margin-top: 6px; }

/* Tags */
.tag-area { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag {
  padding: 5px 11px;
  border-radius: 999px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 11px;
  color: #374151;
  transition: all 0.2s;
}

.tag:hover { background: #d1d5db; }
.tag.active { background: var(--primary); color: white; }
.tag.green { background: #e8f5e9; color: #2e7d32; }
.tag.green.active { background: #4caf50; color: white; }

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.status-badge.cancel { background: #ffebee; color: #c62828; }
.status-badge.exchange { background: #fff3e0; color: #e65100; }
.status-badge.refund { background: #f3e5f5; color: #7b1fa2; }
.status-badge.complete { background: #e8f5e9; color: #2e7d32; }
.status-badge.paid { background: #e3f2fd; color: #1565c0; }

.status-btn { opacity: 0.5; transform: scale(0.95); }
.status-btn.active { opacity: 1; transform: scale(1); box-shadow: 0 0 0 3px rgba(0,0,0,0.2); }

.bulk-status-btn { opacity: 0.6; transform: scale(0.95); }
.bulk-status-btn.active { opacity: 1; transform: scale(1); box-shadow: 0 0 0 3px rgba(0,0,0,0.25); }

/* Transaction Badges */
.badge-in { display: inline-block; background: #1565c0; color: white; padding: 2px 8px; border-radius: 4px; font-size: 10px; }
.badge-out { display: inline-block; background: #c62828; color: white; padding: 2px 8px; border-radius: 4px; font-size: 10px; }
.trans-badge { display: inline-block; background: #9c27b0; color: white; padding: 2px 6px; border-radius: 4px; font-size: 10px; }
.auction-badge { display: inline-block; background: #ff9800; color: white; padding: 2px 6px; border-radius: 4px; font-size: 10px; margin-left: 5px; }

/* Stock Status */
.stock-danger { color: #fff !important; background: #e53935 !important; font-weight: 700; }
.stock-warning { color: #e65100 !important; background: #fff3e0 !important; font-weight: 600; }
.stock-normal { color: #2962ff; font-weight: 600; }

/* Search Box */
.search-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-box input {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid #d1d5db;
  width: 200px;
  font-size: 12px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 15px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-group label { font-size: 12px; color: #666; white-space: nowrap; }
.filter-group input[type="date"],
.filter-group select {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 12px;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 12px 15px;
  color: white;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.stat-card.blue { background: linear-gradient(135deg, #2962ff 0%, #0d47a1 100%); }
.stat-card.green { background: linear-gradient(135deg, #4caf50 0%, #1b5e20 100%); }
.stat-card.orange { background: linear-gradient(135deg, #ff9800 0%, #e65100 100%); }
.stat-card.red { background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%); }
.stat-card.purple { background: linear-gradient(135deg, #7b1fa2 0%, #4a148c 100%); }

.stat-card .stat-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 28px;
  opacity: 0.3;
}

.stat-card .stat-label { font-size: 11px; opacity: 0.9; margin-bottom: 3px; }
.stat-card .stat-value { font-size: 20px; font-weight: 700; }
.stat-card .stat-sub { font-size: 10px; opacity: 0.8; margin-top: 3px; }

/* Charts */
.chart-container {
  background: white;
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  margin-bottom: 12px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-title:hover { color: var(--primary); }
.chart-title .hint { font-size: 10px; color: #888; font-weight: normal; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 5px 0;
  border-bottom: 2px solid #e5e7eb;
}

.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }

.bar {
  width: 100%;
  max-width: 50px;
  background: linear-gradient(180deg, #2962ff 0%, #651fff 100%);
  border-radius: 8px 8px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.bar-label { font-size: 10px; color: #666; text-align: center; }
.bar-value { font-size: 11px; font-weight: 600; color: #333; }

/* Ranking */
.ranking-list { list-style: none; padding: 0; margin: 0; max-height: 180px; overflow-y: auto; }

.ranking-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s;
}

.ranking-item:hover { background: #f5f5f5; }
.ranking-item:last-child { border-bottom: none; }

.ranking-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  margin-right: 10px;
}

.ranking-num.gold { background: #ffd700; color: #333; }
.ranking-num.silver { background: #c0c0c0; color: #333; }
.ranking-num.bronze { background: #cd7f32; color: white; }
.ranking-num.normal { background: #e5e7eb; color: #666; }

.ranking-info { flex: 1; }
.ranking-name { font-weight: 600; font-size: 12px; color: #333; }
.ranking-sub { font-size: 10px; color: #888; }
.ranking-value { font-weight: 700; font-size: 12px; color: #2962ff; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

/* Sub Tabs */
.sub-tab-bar { display: flex; gap: 4px; margin-bottom: 10px; }

.sub-tab {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.sub-tab:hover { background: #e5e7eb; }
.sub-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.sub-tab.orange.active { background: var(--orange); border-color: var(--orange); }

/* Stats Table */
.stats-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stats-table th { background: #f0f7ff; padding: 10px 8px; text-align: center; border-bottom: 2px solid #c8e0ff; }
.stats-table td { padding: 8px; text-align: center; border-bottom: 1px solid #e5e7eb; }
.stats-table .text-left { text-align: left; }
.stats-table .text-right { text-align: right; }
.stats-table .col-in { background: #e3f2fd; color: #1565c0; }
.stats-table .col-out { background: #ffebee; color: #c62828; }
.stats-table .col-buy { background: #fff3e0; color: #e65100; }
.stats-table .col-sell { background: #e8f5e9; color: #2e7d32; }
.stats-table tfoot tr { background: #f5f5f5; font-weight: 700; }

/* Cross Table */
.cross-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.cross-table th, .cross-table td { padding: 8px 6px; border: 1px solid #e0e0e0; text-align: center; }
.cross-table th { background: #f5f5f5; font-weight: 600; }
.cross-table .row-header { background: #e3f2fd; font-weight: 600; text-align: left; }
.cross-table .col-total { background: #fff3e0; font-weight: 600; }
.cross-table .grand-total { background: #e8f5e9; font-weight: 700; }
.cross-table .cell-count { font-weight: 600; color: #1565c0; }
.cross-table .cell-amount { font-size: 10px; color: #666; }

/* Customer Table */
.customer-table { width: 100%; margin-top: 10px; font-size: 11px; }
.customer-table th { background: #f0f7ff; text-align: center; padding: 6px 4px; }
.customer-table td { text-align: center; padding: 6px 4px; }
.customer-table input {
  width: 70px;
  text-align: right;
  padding: 4px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 11px;
}
.customer-table input.locked { background: #fff3cd; width: 70px; }
.total-row { background: #e8f5e9 !important; font-weight: 600; }
.total-row td { border-top: 2px solid #4caf50; }

/* Order Input */
.order-input {
  width: 70px !important;
  text-align: center !important;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px;
  font-size: 12px;
}

.order-badge {
  display: inline-block;
  background: #ff9800;
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* Info Box */
.info-box {
  background: #f0f7ff;
  border: 1px solid #c8e0ff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 12px;
}

.info-box .row { display: flex; gap: 15px; margin-bottom: 5px; align-items: center; }
.info-box .row:last-child { margin-bottom: 0; }
.info-box .label { color: #666; min-width: 60px; }
.info-box .value { color: #333; font-weight: 500; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  margin-left: 10px;
  border: 2px solid #ddd;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Product Group Styles */
.product-group {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  background: white;
}

.product-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  cursor: pointer;
  transition: background 0.2s;
}

.product-group-header:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.product-group-header.expanded {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-bottom: 1px solid #90caf9;
}

.product-group-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-group-toggle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: transform 0.3s;
}

.product-group-header.expanded .product-group-toggle {
  transform: rotate(90deg);
}

.product-group-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.product-group-meta {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: #666;
}

.product-group-count {
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.product-group-body {
  display: none;
  padding: 0;
}

.product-group-body.show {
  display: block;
}

.product-group-body table {
  margin: 0;
  border-radius: 0;
}

.product-group-body thead {
  background: #f5f5f5;
}

.version-row {
  transition: background 0.2s;
}

.version-row:hover {
  background: #f8f9fa;
}

.version-row.inactive {
  background: #f5f5f5;
  opacity: 0.6;
}

.version-row.inactive td {
  color: #999;
}

.version-badge {
  display: inline-block;
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 10px;
  color: #666;
  margin-left: 6px;
}

/* View Mode Toggle */
.view-mode-toggle {
  display: flex;
  gap: 4px;
  background: #f0f0f0;
  padding: 3px;
  border-radius: 8px;
}

.view-mode-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  font-size: 11px;
  color: #666;
  transition: all 0.2s;
}

.view-mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 0 10px; }
  .card { padding: 12px; }
  .modal { width: 95vw; }
  .popup-box { width: 95vw; }
  .stat-card .stat-value { font-size: 22px; }
  .tab-btn { min-width: 50px; font-size: 10px; padding: 6px 0; }
  .search-box { flex-direction: column; align-items: stretch; }
  .search-box input { width: 100%; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
  table { font-size: 11px; }
  th, td { padding: 5px 4px; }
  .product-group-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .product-group-meta { flex-wrap: wrap; }
}
