:root {
  --primary: #1890ff;
  --primary-dark: #096dd9;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --info: #13c2c2;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #666;
  --border: #e8e8e8;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Login Page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 40px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { font-size: 24px; margin-bottom: 8px; }
.login-header p { color: var(--text-secondary); }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(24,144,255,0.2);
}

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

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff2f0;
  border-radius: 4px;
  border: 1px solid #ffccc7;
}

/* Forgot Password */
.form-extra {
  text-align: right;
  margin-top: 4px;
  margin-bottom: 16px;
}

.forgot-pwd-link {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}

.forgot-pwd-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.modal-sm { width: 440px; }

.modal-body { padding: 8px 0 16px; }

.modal-footer { padding-top: 8px; }

.forgot-pwd-icon {
  text-align: center;
  font-size: 48px;
  margin-bottom: 16px;
}

.forgot-pwd-desc {
  text-align: center;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 20px;
}

.forgot-pwd-alternative {
  background: #f6f8fa;
  border-radius: 8px;
  padding: 16px;
}

.forgot-pwd-alternative .alt-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.alt-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.alt-steps code {
  background: #e8e8e8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #389e0d; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #cf1322; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn i, .btn svg { margin-right: 4px; }
.btn-sm i, .btn-sm svg { font-size: 12px; }

/* Top Bar */
.topbar {
  background: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right span { color: var(--text-secondary); font-size: 14px; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
  font-size: 22px;
  margin-bottom: 6px;
  opacity: 0.85;
}

.stat-number { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.stat-total .stat-icon { color: #1890ff; }
.stat-today .stat-icon { color: #13c2c2; }
.stat-received .stat-icon { color: #1890ff; }
.stat-received .stat-number { color: #1890ff; }
.stat-diagnosing .stat-icon { color: #faad14; }
.stat-diagnosing .stat-number { color: #faad14; }
.stat-repairing .stat-icon { color: #fa8c16; }
.stat-repairing .stat-number { color: #fa8c16; }
.stat-completed .stat-icon { color: #52c41a; }
.stat-completed .stat-number { color: #52c41a; }
.stat-picked .stat-icon { color: #8c8c8c; }
.stat-picked .stat-number { color: #8c8c8c; }

/* Filter Bar */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-left { display: flex; gap: 12px; flex-wrap: wrap; }

.filter-bar select,
.filter-bar input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.filter-bar input[type="text"] { width: 240px; }

/* Table */
.table-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow-x: auto;
}

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

.orders-table th {
  background: #fafafa;
  padding: 12px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.orders-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orders-table td:nth-child(1),
.orders-table td:nth-child(2),
.orders-table td:nth-child(3),
.orders-table td:nth-child(6),
.orders-table td:nth-child(7) {
  white-space: nowrap;
}

.orders-table td:nth-child(4) {
  white-space: nowrap;
  font-size: 13px;
}

.orders-table td:nth-child(5) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orders-table td:nth-child(5) small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-table td:last-child {
  white-space: nowrap;
  overflow: visible;
}

.orders-table tr:hover { background: #f5f7fa; }

.empty-msg {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px !important;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-1 { background: #e6f7ff; color: #1890ff; }
.status-2 { background: #fff7e6; color: #fa8c16; }
.status-3 { background: #fff1e6; color: #d46b08; }
.status-4 { background: #f6ffed; color: #52c41a; }
.status-5 { background: #f5f5f5; color: #8c8c8c; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-info { font-size: 13px; color: var(--text-secondary); }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination button {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  min-width: 32px;
  transition: all .15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination span { font-size: 13px; color: var(--text-secondary); }
.pagination .page-ellipsis { padding: 5px 4px; font-size: 13px; color: var(--text-secondary); }

.page-size-select {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.page-size-select select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

/* Tooltip */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-box {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,40,0.92);
  color: #fff;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 9999;
  min-width: 220px;
  pointer-events: none;
  line-height: 1.9;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(30,30,40,0.92);
}
.tooltip-wrap:hover .tooltip-box { display: block; }
.tooltip-row { display: flex; gap: 6px; }
.tooltip-label { color: #aaa; flex-shrink: 0; }

/* Image Grid */
.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.image-thumb {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fafafa;
  cursor: pointer;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.image-thumb:hover img { opacity: 0.8; }

.image-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.image-thumb:hover .image-delete-btn { opacity: 1; }

.image-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  color: #999;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  text-align: center;
}

.image-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.modal-lg { width: 700px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* Detail */
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}

.detail-item { font-size: 14px; padding: 4px 0; }
.detail-item .label { color: var(--text-secondary); margin-right: 8px; }

/* Timeline */
.timeline { padding-left: 20px; border-left: 2px solid var(--border); }
.timeline-item {
  position: relative;
  padding: 0 0 16px 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-status { font-weight: 600; font-size: 14px; }
.timeline-note { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.timeline-time { font-size: 12px; color: #bbb; margin-top: 2px; }

/* Status advance */
.advance-section {
  margin-top: 20px;
  padding: 16px;
  background: #f6f8fa;
  border-radius: 8px;
}
.advance-section h3 { border: none; padding: 0; margin-bottom: 12px; }
.advance-section .form-group { margin-bottom: 12px; }

.action-buttons { display: flex; gap: 8px; white-space: nowrap; }

.action-buttons .btn { flex-shrink: 0; }

/* Responsive */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-left { flex-direction: column; }
  .filter-bar input[type="text"] { width: 100%; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
}
