/* ========== 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: #333;
  background-color: #f5f6fa;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 20px;
}

/* ========== 顶部导航 ========== */
.app-header {
  background: linear-gradient(135deg, #1a73e8 0%, #4a90d9 100%);
  color: #fff;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* ========== 标签页 ========== */
.tab-bar {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 99;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
  position: relative;
}

.tab-item.active {
  color: #1a73e8;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: #1a73e8;
  border-radius: 2px;
}

.tab-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

.tab-text {
  font-size: 12px;
}

/* ========== 页面 ========== */
.page {
  display: none;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.page.active {
  display: block;
}

/* ========== 卡片 ========== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tip-card {
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f4ff 100%);
  border-left: 4px solid #1a73e8;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.tip-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a73e8;
  margin-bottom: 4px;
}

.tip-content {
  font-size: 13px;
  color: #5a6c8e;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a73e8;
  margin-bottom: 16px;
  padding-left: 10px;
  border-left: 4px solid #1a73e8;
}

/* ========== 表单 ========== */
.form-item {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.required {
  color: #e74c3c;
  margin-right: 2px;
}

.form-tip {
  font-size: 12px;
  color: #e74c3c;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 44px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  background: #fafafa;
  color: #333;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s, background 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #1a73e8;
  background: #fff;
}

.form-input:disabled {
  background: #f0f0f0;
  color: #666;
  cursor: not-allowed;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ========== 扫码按钮 ========== */
.scan-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  background: #f0f7ff;
  border: 2px dashed #1a73e8;
  border-radius: 8px;
  margin-bottom: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.scan-all-btn:active {
  background: #e0efff;
}

.scan-all-icon {
  font-size: 20px;
  margin-right: 8px;
}

.scan-all-text {
  font-size: 15px;
  color: #1a73e8;
  font-weight: 500;
}

/* ========== 级联选择 ========== */
.cascade-section {
  background: #f8f9fc;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid #e8ecf4;
}

.cascade-title {
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  color: #1a73e8;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8ecf4;
}

.cascade-icon {
  margin-right: 6px;
}

/* ========== 按钮 ========== */
.submit-btn {
  width: 100%;
  height: 48px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.submit-btn:active {
  background: #1557b0;
}

.submit-btn:disabled {
  background: #a0c4f5;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  height: 44px;
  background: #fff;
  color: #1a73e8;
  border: 1px solid #1a73e8;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s;
}

.secondary-btn:active {
  background: #f0f7ff;
}

/* ========== 统计卡片 ========== */
.stats-card {
  background: linear-gradient(135deg, #1a73e8 0%, #4a90d9 100%);
  color: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.stats-item {
  text-align: center;
  flex: 1;
}

.stats-number {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 2px;
}

.stats-label {
  font-size: 12px;
  opacity: 0.9;
}

.stats-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, 0.3);
}

/* ========== 操作栏 ========== */
.action-card {
  padding: 14px 20px;
}

.action-row {
  display: flex;
  gap: 12px;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border-radius: 8px;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.action-btn:active {
  opacity: 0.8;
}

.export-btn {
  background: #e8f0fe;
  color: #1a73e8;
}

.refresh-btn {
  background: #e6f4ea;
  color: #137333;
}

.action-icon {
  margin-right: 4px;
}

/* ========== 筛选 ========== */
.filter-card {
  padding: 14px 20px;
}

.filter-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 10px;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  display: inline-block;
  padding: 5px 14px;
  background: #f0f0f0;
  border-radius: 20px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-tag.active {
  background: #1a73e8;
  color: #fff;
}

/* ========== 记录卡片 ========== */
.record-card {
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}

.record-model {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}

.record-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 500;
}

.status-install { background: #e3f2fd; color: #1565c0; }
.status-remove { background: #fff3e0; color: #e65100; }
.status-burn { background: #fce4ec; color: #c62828; }
.status-burn-out { background: #f3e5f5; color: #6a1b9a; }
.status-polish { background: #e8f5e9; color: #2e7d32; }
.status-polish-early { background: #e0f7fa; color: #00695c; }
.status-polish-weld { background: #fff8e1; color: #f57f17; }
.status-default { background: #f0f0f0; color: #666; }

.record-body {
  padding: 12px 16px;
}

.record-row {
  display: flex;
  padding: 4px 0;
  font-size: 13px;
}

.record-label {
  color: #999;
  width: 80px;
  flex-shrink: 0;
}

.record-value {
  color: #333;
  flex: 1;
  word-break: break-all;
}

.record-location .record-value {
  color: #1a73e8;
  font-weight: 500;
}

.record-time {
  color: #666;
  font-size: 12px;
}

.record-footer {
  padding: 10px 16px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
}

.record-delete {
  display: flex;
  align-items: center;
  color: #e74c3c;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.record-delete:active {
  background: #fde8e8;
}

.delete-icon {
  margin-right: 4px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
  color: #666;
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 13px;
  color: #999;
}

/* ========== 加载状态 ========== */
.loading-state {
  text-align: center;
  padding: 40px 20px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: #1a73e8;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

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

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.scan-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 4px;
}

.scan-modal .modal-body {
  padding: 16px;
}

.scan-tip {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-top: 12px;
}

/* 确认弹窗 */
.confirm-modal {
  padding: 24px 20px 20px;
  text-align: center;
}

.confirm-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
}

.confirm-message {
  font-size: 14px;
  color: #666;
  margin-bottom: 24px;
  line-height: 1.6;
}

.confirm-buttons {
  display: flex;
  gap: 12px;
}

.confirm-btn {
  flex: 1;
  height: 42px;
  border-radius: 8px;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.confirm-btn:active {
  opacity: 0.8;
}

.cancel-btn {
  background: #f0f0f0;
  color: #666;
}

.ok-btn {
  background: #1a73e8;
  color: #fff;
}

.ok-btn.danger {
  background: #e74c3c;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

.toast.success {
  background: rgba(46, 125, 50, 0.9);
}

.toast.error {
  background: rgba(198, 40, 40, 0.9);
}

/* ========== 响应式 ========== */
@media (min-width: 600px) {
  .page {
    padding: 20px;
  }
  .card {
    padding: 24px;
  }
}
