:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

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

/* 页面头部 */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 20px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.header .subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

.station-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  margin-top: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.station-badge .icon {
  font-size: 1.3rem;
}

/* 容器 */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* 分类标签 */
.categories {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 16px 0;
  -webkit-overflow-scrolling: touch;
}

.categories::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex-shrink: 0;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-tab:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.category-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* 外设列表 */
.peripherals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.peripheral-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border: 2px solid transparent;
}

.peripheral-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.peripheral-card.selected {
  border-color: var(--primary);
  background: linear-gradient(to bottom, rgba(37, 99, 235, 0.05), transparent);
}

.peripheral-card .check-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

.peripheral-card.selected .check-icon {
  display: flex;
}

.peripheral-image {
  width: 100%;
  height: 100px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.peripheral-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peripheral-brand {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.peripheral-status {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
}

.peripheral-status.available {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.peripheral-status.unavailable {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* 底部提交栏 */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  padding: 16px;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.selected-count {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.selected-count span {
  color: var(--primary);
  font-weight: 600;
}

.submit-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.submit-btn:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.submit-btn:disabled {
  background: var(--secondary);
  cursor: not-allowed;
  transform: none;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: all 0.3s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-message {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

/* ============ 员工端样式 ============ */
.staff-header {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.order-list {
  padding: 16px 0;
}

.order-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

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

.order-station {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-time {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.order-items {
  margin-bottom: 12px;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.order-item-icon {
  font-size: 1.5rem;
}

.order-item-name {
  font-weight: 500;
}

.order-item-brand {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.order-actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

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

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

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

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* 声音控制 */
.sound-control {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  z-index: 100;
}

.sound-control .icon {
  font-size: 1.5rem;
}

.sound-control.muted {
  opacity: 0.6;
}

/* Tab 切换 */
.tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* 状态标签 */
.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.status-badge.in_use {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.status-badge.returned {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

/* ============ 管理后台样式 ============ */
.admin-header {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

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

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: all 0.2s ease;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

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

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.action-btns {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn.edit {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.action-btn.delete {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

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

.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
}

/* 加载动画 */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Toast 提示 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 0.95rem;
  z-index: 2000;
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* 响应式 - 移动端H5适配 */
@media (max-width: 768px) {
  .header {
    padding: 16px;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .header .subtitle {
    font-size: 0.85rem;
  }

  .station-badge {
    padding: 6px 12px;
    font-size: 1rem;
    margin-top: 8px;
  }

  .container {
    padding: 12px;
  }

  .categories {
    padding: 12px 0;
    gap: 8px;
  }

  .category-tab {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .peripherals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .peripheral-card {
    padding: 12px;
  }

  .peripheral-image {
    height: 80px;
    font-size: 2.5rem;
    margin-bottom: 8px;
  }

  .peripheral-name {
    font-size: 0.9rem;
  }

  .peripheral-brand {
    font-size: 0.8rem;
  }

  .peripheral-status {
    font-size: 0.75rem;
    padding: 3px 8px;
  }

  .submit-bar {
    padding: 12px 16px;
  }

  .submit-btn {
    padding: 10px 24px;
    font-size: 0.95rem;
  }

  .selected-count {
    font-size: 0.9rem;
  }

  .modal {
    padding: 20px;
    max-width: 90%;
  }

  .modal-icon {
    font-size: 3rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

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

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .section {
    padding: 16px;
  }

  .table {
    font-size: 0.9rem;
  }

  .table th,
  .table td {
    padding: 10px 8px;
  }

  .action-btns {
    flex-direction: column;
    gap: 6px;
  }

  .action-btn {
    padding: 8px 12px;
    text-align: center;
  }
}

@media (max-width: 400px) {
  .peripherals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .peripheral-card {
    padding: 10px;
  }

  .peripheral-image {
    height: 60px;
    font-size: 2rem;
  }

  .peripheral-name {
    font-size: 0.85rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .header h1 {
    font-size: 1.1rem;
  }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
  .peripheral-card {
    -webkit-tap-highlight-color: transparent;
  }

  .peripheral-card:active {
    transform: scale(0.98);
  }

  .btn:active,
  .submit-btn:active,
  .modal-btn:active,
  .category-tab:active {
    transform: scale(0.95);
  }
}

/* 安全区域适配 (iPhone X 等) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .submit-bar {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .has-submit-bar {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* 内边距补偿（底部固定栏） */
.has-submit-bar {
  padding-bottom: 80px;
}