/* ==================== 共享样式 - 统一配色方案 ==================== */
/* 主色调: #4f46e5 (indigo) */
/* 辅助色: #059669 (green), #d97706 (amber), #dc2626 (red) */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
  color: #111827;
}
.container { max-width: 1600px; margin: 0 auto; padding: 20px; }

/* ==================== Animations ==================== */
@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== Header ==================== */
.header {
  background: white;
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 20px;
  display: flex;
  animation: slide-down 0.5s ease;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  gap: 12px;
  min-width: 0; /* 允许子元素收缩 */
}
.header h1 { color: #4f46e5; font-size: 20px; font-weight: 700; white-space: nowrap; }
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0; /* 防止品牌区域收缩 */
}
.version-tag {
  background: #4f46e5;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.header-right { 
  display: flex; 
  align-items: center; 
  justify-content: flex-end; /* 右对齐 */
  gap: 10px; 
  flex: 1;
  min-width: 0; /* 允许子元素收缩 */
  overflow: hidden; /* 隐藏溢出 */
}
.user-info, .user-badge { 
  font-size: 14px; 
  color: #6b7280; 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==================== Navigation ==================== */
.nav { 
  display: flex; 
  gap: 6px; 
  flex-wrap: nowrap; /* 禁止换行 */
  overflow-x: auto; /* 水平滚动 */
  scrollbar-width: none; /* Firefox 隐藏滚动条 */
  -ms-overflow-style: none; /* IE/Edge 隐藏滚动条 */
  min-width: 0;
}
.nav::-webkit-scrollbar { 
  display: none; /* Chrome/Safari 隐藏滚动条 */
}
.nav-btn {
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  padding: 6px 10px; /* 减小内边距 */
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px; /* 减小字体 */
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap; /* 禁止文字换行 */
  flex-shrink: 0; /* 禁止按钮收缩 */
}
.nav-btn:hover { background: #e5e7eb; color: #374151; }
.nav-btn.active { background: #4f46e5; color: white; }

/* ==================== Navigation Dropdown ==================== */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dropdown-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 1000;
  margin-top: 4px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  color: #374151;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  background: #f3f4f6;
  color: #111827;
}

.nav-dropdown-item.active {
  background: #4f46e5;
  color: white;
}

/* ==================== Buttons ==================== */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: #4f46e5; color: white; }
.btn-primary:hover { background: #4338ca; }
.btn-success { background: #059669; color: white; }
.btn-success:hover { background: #047857; }
.btn-warning { background: #d97706; color: white; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: #f3f4f6; color: #374151; }
.btn-ghost:hover { background: #e5e7eb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ==================== Badges ==================== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-A { background: #dc2626; color: white; }
.badge-B { background: #d97706; color: white; }
.badge-C { background: #059669; color: white; }
.badge-D { background: #6b7280; color: white; }
.badge-Z { background: #7c3aed; color: white; }
.badge-T0 { background: #7c3aed; color: white; }
.badge-T1 { background: #2563eb; color: white; }
.badge-T2 { background: #0d9488; color: white; }
.badge-paused { background: #9ca3af; color: white; }
.badge-trend-up { background: #fee2e2; color: #dc2626; }
.badge-trend-down { background: #dcfce7; color: #059669; }
.badge-trend-stable { background: #f3f4f6; color: #6b7280; }
.badge-admin { background: #4f46e5; color: white; }
.badge-user { background: #6b7280; color: white; }
.badge-perm-true { background: #dcfce7; color: #065f46; }
.badge-perm-false { background: #fee2e2; color: #991b1b; }

/* ==================== Panels / Cards ==================== */
.panel {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 20px;
}
.panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.panel-header h2 { font-size: 16px; font-weight: 600; color: #111827; }
.panel-body { padding: 20px 24px; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card h3 { font-size: 12px; color: #6b7280; font-weight: 500; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #111827; }
.stat-card .sub { font-size: 12px; color: #9ca3af; margin-top: 4px; }

/* Stats bar - compact inline style */
.stats-bar {
  background: white;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}
.stat-label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
}
.stat-sub {
  font-size: 10px;
  color: #9ca3af;
  white-space: nowrap;
}
.stat-divider {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
  align-self: center;
}

/* Action bar */
.action-bar {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.action-bar .spacer { flex: 1; }
.search-input {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  width: 200px;
}
.search-input:focus { outline: none; border-color: #4f46e5; }

/* ==================== Table ==================== */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid #f9fafb;
  vertical-align: middle;
  color: #374151;
}
tr:hover td { background: #f9fafb; }
.table-scroll { overflow-x: auto; }

/* ==================== Forms ==================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ==================== Modal ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  /* 滚动条优化：不撑开布局，圆角不受影响 */
  overflow: hidden;
}
/* 滚动条只在内容区出现，不影响 header/footer */
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  /* 美化滚动条 */
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}
/* Chrome/Safari 自定义滚动条 */
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #9ca3af; line-height: 1; }
.modal-close:hover { color: #374151; }

.modal-footer { padding: 16px 24px; border-top: 1px solid #f3f4f6; display: flex; justify-content: flex-end; gap: 10px; }

/* ==================== Alerts ==================== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.alert.error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; display: block; }
.alert.success { background: #f0fdf4; border: 1px solid #a7f3d0; color: #065f46; display: block; }
.alert.info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; display: block; }
.alert.warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; display: block; }

/* ==================== Health Check ==================== */
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.health-item { padding: 14px 16px; border-radius: 8px; border: 1px solid #e5e7eb; display: flex; align-items: center; gap: 12px; }
.health-item.ok { border-color: #a7f3d0; background: #f0fdf4; }
.health-item.error { border-color: #fca5a5; background: #fef2f2; }
.health-icon { font-size: 20px; }
.health-text { flex: 1; }
.health-text .title { font-size: 14px; font-weight: 500; color: #111827; }
.health-text .msg { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ==================== Tabs ==================== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #f3f4f6; margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 14px; font-weight: 500; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab:hover { color: #374151; }
.tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ==================== Misc ==================== */
.loading { text-align: center; padding: 40px; color: #9ca3af; }
.perm-denied { text-align: center; padding: 60px 20px; }
.perm-denied h2 { color: #dc2626; margin-bottom: 12px; }
.perm-denied p { color: #6b7280; }
.empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; }
.empty-state h3 { margin-bottom: 8px; font-size: 18px; color: #6b7280; }
.text-muted { color: #9ca3af; font-size: 13px; }
.text-sm { font-size: 12px; }
.text-danger { color: #dc2626; }
.text-success { color: #059669; }
.text-warning { color: #d97706; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* SKU table */
.sku-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.sku-table th { background: #f9fafb; padding: 8px 12px; text-align: left; font-size: 12px; color: #6b7280; font-weight: 600; border-bottom: 1px solid #e5e7eb; }
.sku-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.sku-table tr.changed td { background: #fffbeb; }
.sku-table tr.changed td:first-child { border-left: 3px solid #f59e0b; }
.price-old { color: #9ca3af; text-decoration: line-through; font-size: 12px; }
.price-new { color: #059669; font-weight: 600; font-size: 14px; }
.price-up { color: #dc2626; font-weight: 600; }
.price-down { color: #059669; font-weight: 600; }
.changed-badge { display: inline-block; background: #fef3c7; color: #92400e; font-size: 11px; padding: 1px 6px; border-radius: 3px; font-weight: 600; margin-left: 4px; }

/* Permission table specific */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.perm-cell { text-align: center; padding: 6px; background: #f9fafb; border-radius: 6px; font-size: 12px; }
.perm-cell.granted { background: #dcfce7; color: #065f46; }
.perm-cell.denied { background: #fee2e2; color: #991b1b; }

/* ==================== Dashboard specific ==================== */
.product-name { font-weight: 500; color: #111827; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.product-name:hover { color: #4f46e5; text-decoration: underline; }
.product-name-wrap { display: flex; align-items: center; gap: 6px; }
.product-id { font-family: monospace; font-size: 12px; color: #6b7280; margin-top: 2px; }
.price-info { font-size: 13px; color: #374151; }
.price-info strong { color: #059669; }
.trend-up { color: #dc2626; font-weight: 600; }
.trend-down { color: #059669; font-weight: 600; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Fire icon for price changes */
.price-fire {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; background: #f59e0b; color: white;
  border-radius: 3px; font-size: 11px; font-weight: 900; cursor: pointer;
  line-height: 1; flex-shrink: 0; vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}

/* Queue drag list */
.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  margin-bottom: 4px; background: #f9fafb; border: 1px solid #e5e7eb;
  border-radius: 8px; cursor: grab; transition: background .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.queue-item:hover { background: #f3f4f6; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.queue-item.dragging { opacity: .4; background: #dbeafe; border-color: #3b82f6; }
.queue-item.drag-over { border-color: #3b82f6; background: #eff6ff; }
.queue-item .drag-handle { color: #9ca3af; cursor: grab; font-size: 16px; line-height: 1; flex-shrink: 0; padding: 0 2px; }
.queue-item .q-name { flex: 1; font-size: 13px; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .q-badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; flex-shrink: 0; }
.q-badge-a { background: #fee2e2; color: #991b1b; }
.q-badge-b { background: #fef3c7; color: #92400e; }
.q-badge-c { background: #f3f4f6; color: #6b7280; }
.queue-item .q-pos { font-size: 11px; color: #d1d5db; min-width: 18px; text-align: center; flex-shrink: 0; }
.queue-item .q-actions { display: flex; gap: 4px; flex-shrink: 0; }
.queue-item .q-btn { border: none; background: none; cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 4px; line-height: 1; transition: background .1s; }
.queue-item .q-btn:hover { background: #e5e7eb; }
.q-btn-top { color: #d97706; }
.q-btn-top:hover { background: #fef3c7; color: #b45309; }
.q-btn-rm { color: #9ca3af; }
.q-btn-rm:hover { background: #fee2e2; color: #dc2626; }
.q-btn-pause { color: #6b7280; }
.q-btn-pause:hover { background: #fef3c7; color: #d97706; }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .header { flex-direction: column; align-items: flex-start; }
  .table-scroll { font-size: 12px; }
  .modal { width: 98vw; }
}

/* ==================== Scheduler Panel ==================== */
.scheduler-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.scheduler-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #f3f4f6;
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-dot.status-online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.status-offline {
  background: #9ca3af;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.scheduler-info .info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scheduler-info .info-label {
  font-size: 12px;
  color: #9ca3af;
}

.scheduler-info .info-value {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}
