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

:root {
  --primary-color: #3498db;
  --primary-dark: #2980b9;
  --secondary-color: #2ecc71;
  --danger-color: #e74c3c;
  --warning-color: #f39c12;
  --text-color: #2c3e50;
  --text-light: #7f8c8d;
  --bg-color: #ecf0f1;
  --white: #ffffff;
  --border-color: #bdc3c7;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --sidebar-width: 250px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--white);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  padding: 0 20px 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.logo h1 {
  font-size: 24px;
  font-weight: 600;
}

.nav-menu {
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s;
}

.nav-item:hover,
.nav-item.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

.nav-item .icon {
  margin-right: 12px;
  font-size: 18px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 30px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}

.page-header h2 {
  font-size: 28px;
  color: var(--text-color);
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--white);
  border-radius: 10px;
  padding: 25px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-icon {
  font-size: 40px;
  margin-right: 15px;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 5px;
}

/* 仪表板区块 */
.dashboard-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.section {
  background: var(--white);
  border-radius: 10px;
  padding: 25px;
  box-shadow: var(--shadow);
}

.section h3 {
  margin-bottom: 20px;
  color: var(--text-color);
  font-size: 18px;
}

/* 分类统计 */
.category-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.category-stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-color);
}

.category-stat-bar {
  flex: 1;
  height: 20px;
  background: var(--bg-color);
  border-radius: 10px;
  margin: 0 15px;
  overflow: hidden;
}

.category-stat-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s;
}

/* 库存预警 */
.low-stock-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.low-stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #fff5f5;
  border-left: 4px solid var(--danger-color);
  border-radius: 5px;
}

.low-stock-item .name {
  font-weight: 500;
}

.low-stock-item .quantity {
  color: var(--danger-color);
  font-weight: 600;
}

/* 筛选器 */
.filters {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.search-input,
.filter-select {
  padding: 10px 15px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 14px;
  background: var(--white);
}

.search-input {
  flex: 1;
  max-width: 400px;
}

.search-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* 表格 */
.table-container {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--primary-color);
  color: var(--white);
}

.data-table th,
.data-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid var(--bg-color);
}

.data-table th {
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: var(--bg-color);
}

.data-table .actions {
  display: flex;
  gap: 8px;
}

/* 按钮 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--text-light);
  color: var(--white);
}

.btn-secondary:hover {
  background: var(--text-color);
}

.btn-danger {
  background: var(--danger-color);
  color: var(--white);
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-success {
  background: var(--secondary-color);
  color: var(--white);
}

.btn-success:hover {
  background: #27ae60;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--white);
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 20px;
  color: var(--text-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-light);
}

.modal-close:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 20px;
}

.modal-form {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

/* 表单 */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-color);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* 扫码页面 */
.scan-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 30px;
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.scan-box {
  width: 100%;
  max-width: 500px;
}

.scan-type-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.scan-type-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border-color);
  background: var(--white);
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s;
}

.scan-type-btn.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: var(--white);
}

.scan-input-area {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.scan-input-area label {
  font-weight: 500;
}

.scan-input {
  padding: 15px;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  font-size: 16px;
}

.scan-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.scan-result {
  margin-top: 20px;
  padding: 20px;
  border-radius: 5px;
  background: var(--bg-color);
  display: none;
}

.scan-result.show {
  display: block;
}

.scan-result.success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.scan-result.error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.qr-video,
.qr-canvas {
  display: none;
  max-width: 100%;
  border-radius: 10px;
}

.qr-video.active,
.qr-canvas.active {
  display: block;
}

/* 资产详情 */
.asset-detail-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.asset-detail-item {
  padding: 15px;
  background: var(--bg-color);
  border-radius: 5px;
}

.asset-detail-item label {
  font-size: 12px;
  color: var(--text-light);
  display: block;
  margin-bottom: 5px;
}

.asset-detail-item .value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
}

.qr-code-container {
  text-align: center;
  padding: 20px;
  background: var(--white);
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  margin-top: 20px;
}

.qr-code-container img {
  max-width: 200px;
}

/* 标签 */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-in {
  background: #d4edda;
  color: #155724;
}

.badge-out {
  background: #f8d7da;
  color: #721c24;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .main-content {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-sections {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .search-input {
    max-width: 100%;
  }

  .table-container {
    overflow-x: auto;
  }

  .data-table {
    min-width: 600px;
  }
}

/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s linear infinite;
}

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

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 15px;
}
