* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Microsoft YaHei', sans-serif; background: #f0f2f5; color: #333; }
a { color: #4A90D9; text-decoration: none; }

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

/* 侧边栏 */
.sidebar {
  width: 220px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h1 { font-size: 20px; font-weight: 700; }
.sidebar-header p { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 4px; }
.nav-list { list-style: none; padding: 12px 0; flex: 1; }
.nav-item {
  padding: 14px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: rgba(255,255,255,0.7); transition: all 0.2s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(74,144,217,0.2); color: #4A90D9; border-right: 3px solid #4A90D9; }
.nav-icon { font-size: 18px; }
.badge {
  position: absolute; right: 16px; background: #E74C3C; color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

/* 主内容 */
.main-content {
  margin-left: 220px; flex: 1; padding: 30px; min-height: 100vh;
}
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page h2 { font-size: 24px; margin-bottom: 16px; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
}
.stat-card.warning { border-left: 4px solid #F57C00; }
.stat-num { font-size: 36px; font-weight: 700; color: #4A90D9; display: block; }
.stat-card.warning .stat-num { color: #F57C00; }
.stat-label { font-size: 14px; color: #999; margin-top: 4px; }

/* 工具栏 */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px; padding: 10px 16px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; outline: none;
}
.search-input:focus { border-color: #4A90D9; }
.filter-select {
  padding: 10px 16px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px;
  background: #fff; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: #4A90D9; }

/* 表格 */
.data-table {
  width: 100%; background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-collapse: collapse;
}
.data-table th {
  background: #f8f9fa; padding: 12px 16px; text-align: left; font-size: 13px;
  font-weight: 600; color: #666; border-bottom: 2px solid #eee;
}
.data-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover td { background: #f8f9ff; }
.table-info { margin-top: 8px; font-size: 13px; color: #999; text-align: right; }

/* 状态标签 */
.status-tag {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
}
.status-available { background: #E8F5E9; color: #2E7D32; }
.status-borrowed { background: #E3F2FD; color: #1565C0; }
.status-transferring { background: #FFF3E0; color: #E65100; }
.status-fault { background: #FFEBEE; color: #C62828; }
.status-pending { background: #FFF8E1; color: #F57C00; }
.status-approved { background: #E8F5E9; color: #2E7D32; }
.status-rejected { background: #FFEBEE; color: #C62828; }

/* 复选框列 + 序号列 */
.th-checkbox, .td-checkbox { width: 40px; text-align: center; vertical-align: middle; }
.th-checkbox input, .td-checkbox input { width: 16px; height: 16px; cursor: pointer; display: block; margin: 0 auto; }
.th-index, .td-index { width: 55px; min-width: 55px; text-align: center; vertical-align: middle; color: #999; font-size: 12px; }

/* 批量操作栏 */
.batch-bar {
  display: none; align-items: center; gap: 12px; padding: 12px 16px;
  background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-top: 12px; font-size: 13px;
}
.batch-bar.show { display: flex; }
.batch-bar .batch-count { color: #666; font-weight: 600; }
.batch-bar .btn { margin: 0; }

/* 列宽拖拽手柄 */
.th-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.resize-handle {
  position: absolute; right: -8px; top: 0; bottom: 0; width: 16px;
  cursor: col-resize; z-index: 10;
}
.resize-handle::after {
  content: ''; position: absolute; right: 6px; top: 20%; bottom: 20%;
  width: 2px; background: #ddd; border-radius: 1px;
}
.data-table th:hover .resize-handle::after { background: #4A90D9; }
.data-table.resizing { user-select: none; }
.data-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }

/* 分页 */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 16px; font-size: 13px;
}
.pagination .page-info {
  color: #999; margin-right: 12px; font-size: 13px;
}
.pagination button {
  min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid #ddd;
  border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px;
  color: #333; transition: all 0.15s; display: inline-flex;
  align-items: center; justify-content: center;
}
.pagination button:hover:not(:disabled):not(.active) { border-color: #4A90D9; color: #4A90D9; }
.pagination button.active { background: #4A90D9; color: #fff; border-color: #4A90D9; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.nav-btn { min-width: 56px; }

/* 行内状态下拉选 */
.status-select {
  padding: 4px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px;
  background: #fff; outline: none; cursor: pointer;
}
.status-select:focus { border-color: #4A90D9; }
.status-select.status-fault { border-color: #C62828; color: #C62828; }

/* 列宽比例 - 设备表 */
#device-table th:nth-child(3), #device-table td:nth-child(3) { width: 100px; }  /* 编号 */
#device-table th:nth-child(4), #device-table td:nth-child(4) { min-width: 140px; } /* 名称 */
#device-table th:nth-child(5), #device-table td:nth-child(5) { min-width: 140px; } /* 型号 */
#device-table th:nth-child(6), #device-table td:nth-child(6) { width: 100px; }  /* 分类 */
#device-table th:nth-child(7), #device-table td:nth-child(7) { width: 90px; }   /* 状态 */
#device-table th:nth-child(8), #device-table td:nth-child(8) { width: 100px; }  /* 持有人 */
#device-table th:nth-child(9), #device-table td:nth-child(9) { width: 140px; }  /* 操作 */

/* 按钮 */
.btn {
  display: inline-block; padding: 8px 18px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 13px; cursor: pointer; background: #fff; transition: all 0.2s;
}
.btn:hover { border-color: #4A90D9; color: #4A90D9; }
.btn-primary { background: #4A90D9; color: #fff; border-color: #4A90D9; }
.btn-primary:hover { background: #357ABD; color: #fff; }
.btn-success { background: #43A047; color: #fff; border-color: #43A047; }
.btn-success:hover { background: #2E7D32; color: #fff; }
.btn-danger { background: #E74C3C; color: #fff; border-color: #E74C3C; }
.btn-danger:hover { background: #C62828; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn + .btn { margin-left: 8px; }

/* Tab按钮 */
.tab-bar { display: flex; gap: 8px; }
.tab-btn {
  padding: 8px 20px; border: 1px solid #ddd; border-radius: 8px; background: #fff; cursor: pointer;
  font-size: 13px; transition: all 0.2s;
}
.tab-btn.active { background: #4A90D9; color: #fff; border-color: #4A90D9; }
.tab-btn:hover:not(.active) { border-color: #4A90D9; color: #4A90D9; }

/* 弹窗 */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 500px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-lg { width: 700px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #eee; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; color: #999; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 8px; }

/* 表单 */
.form-input {
  width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; margin-bottom: 12px; outline: none; box-sizing: border-box;
}
.form-input:focus { border-color: #4A90D9; }
.form-textarea { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; margin-bottom: 12px; outline: none; resize: vertical; font-family: inherit; box-sizing: border-box; }
.form-textarea:focus { border-color: #4A90D9; }

/* 导出 */
.export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 16px; }
.export-card {
  background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.export-card h3 { font-size: 16px; margin-bottom: 8px; }
.export-card p { font-size: 13px; color: #999; margin-bottom: 16px; line-height: 1.5; }

/* 工单详情 */
.order-detail-section { margin-bottom: 16px; }
.order-detail-section h4 { font-size: 14px; color: #666; margin-bottom: 8px; }
.order-detail-section p { font-size: 14px; line-height: 1.6; }
.device-item-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }

.text-muted { color: #999; font-size: 14px; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h1, .sidebar-header p, .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 14px; }
  .main-content { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .export-grid { grid-template-columns: 1fr; }
}
