/* ============================================================
   Mileage Audit — Unified MTC Style
   White-based, red accent (#C62828), Apple-inspired minimal
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #C62828;
  --primary-dark: #b71c1c;
  --primary-light: #ef5350;
  --primary-bg: #fef2f2;
  --success: #2E7D32;
  --success-bg: #f0fdf4;
  --danger: #C62828;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --gray-50: #fafafa;
  --gray-100: #f5f5f7;
  --gray-200: #e5e5e5;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1d1d1f;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #fafafa;
  color: #1d1d1f;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER — MTC nav-bar style (white, logo + title)
   ============================================================ */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  height: 32px;
  width: auto;
}

.app-header h1 {
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
  letter-spacing: -0.2px;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background .2s;
}
.back-link:hover { background: var(--primary-bg); }

.header-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 11px;
  border-radius: 12px;
  letter-spacing: 0.3px;
}
.status-live { background: var(--success-bg); color: #15803d; }
.status-soon { background: #fefce8; color: #a16207; }

/* ============================================================
   CONTAINER
   ============================================================ */
.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ============================================================
   PAGE INTRO — MTC centered red title style
   ============================================================ */
.page-intro {
  text-align: center;
  margin-bottom: 28px;
}

.page-intro-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.page-intro-desc {
  font-size: 14px;
  color: #86868b;
}

/* ============================================================
   SECTION CARD — MTC card style (white, red left border)
   ============================================================ */
.section-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border: 1px solid #f0f0f0;
  border-left: 3px solid var(--primary);
  margin-bottom: 18px;
}

.section-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 16px;
  letter-spacing: -0.1px;
}

/* Upload Section */
.upload-section { margin-bottom: 24px; }

.audit-mode-hint {
  background: linear-gradient(135deg, #fef2f2, #f0fdf4);
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #4b5563;
}

.hint-icon {
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.upload-card {
  background: #fafafa;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid #e5e5e5;
  transition: box-shadow .2s;
}
.upload-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }

.upload-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.upload-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}

.upload-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  color: white;
}
.badge-1 { background: var(--primary); }
.badge-2 { background: #8B1A1A; }
.badge-3 { background: #9a9a9a; }

.badge-optional {
  font-size: 10px;
  background: rgba(255,255,255,.35);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 500;
}

.upload-desc {
  font-size: 12px;
  color: #86868b;
  margin-bottom: 14px;
}

.upload-area {
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: white;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.upload-area.has-file {
  border-color: var(--success);
  background: var(--success-bg);
  border-style: solid;
}

.upload-icon {
  font-size: 32px;
  color: #9a9a9a;
  margin-bottom: 8px;
}
/* 三个文件图标各用一色，与各自徽标同色（红白灰黑体系） */
#uploadArea1 .upload-icon { color: var(--primary); }
#uploadArea2 .upload-icon { color: #8B1A1A; }
#uploadArea3 .upload-icon { color: #9a9a9a; }
.upload-area.has-file .upload-icon { color: #C62828; }

.upload-text {
  font-size: 13px;
  color: #4b5563;
  font-weight: 500;
}

.upload-hint {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.file-input { display: none; }

.file-status {
  margin-top: 10px;
  font-size: 12px;
  color: #86868b;
  min-height: 18px;
}
.file-status.success { color: var(--success); }
.file-status.error { color: var(--danger); }

/* Action Bar */
.action-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s ease;
  letter-spacing: 0.2px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(198,40,40,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(198,40,40,.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: #4b5563;
  border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #f5f5f7; }

.btn-export {
  background: var(--success);
  color: white;
}
.btn-export:hover { background: #15803d; }

/* Progress */
.progress-section { margin-bottom: 24px; }

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.progress-header h3 { font-size: 15px; font-weight: 600; color: #1d1d1f; }

.progress-percent {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
  transition: width .4s ease;
}

.progress-text { font-size: 13px; color: #86868b; }

/* Results */
.results-section { animation: fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border: 1px solid #f0f0f0;
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #1d1d1f;
  line-height: 1.2;
}
.stat-pass .stat-value { color: var(--success); }
.stat-fail .stat-value { color: var(--danger); }
.stat-meal .stat-value { color: var(--primary); }
.stat-meal-warn .stat-value { color: var(--warning); }

.stat-label { font-size: 12px; color: #86868b; margin-top: 4px; }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group label { font-size: 13px; font-weight: 500; color: #4b5563; }

select, .search-input {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #374151;
  background: white;
  outline: none;
  transition: border-color .2s;
}
select:focus, .search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198,40,40,.08);
}
.search-input { width: 150px; }

/* Table */
.table-wrapper {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid #f0f0f0;
  overflow-x: auto;
}

.results-table { width: 100%; border-collapse: collapse; font-size: 12px; }

.results-table thead {
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 1;
}

.results-table th {
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: #6b7280;
  border-bottom: 2px solid #e5e5e5;
  white-space: nowrap;
  user-select: none;
}
.results-table th.sortable { cursor: pointer; }
.results-table th.sortable:hover { color: var(--primary); }

.results-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f5f5f5;
  color: #374151;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results-table td.col-wide {
  max-width: 300px;
  white-space: normal;
  word-break: break-all;
  font-size: 11px;
  line-height: 1.4;
}
.results-table tbody tr:hover { background: #fafafa; }

.sort-arrow::after { content: ' \2195'; font-size: 9px; color: #c4c4c8; }

/* Footer */
.app-footer {
  text-align: center;
  color: #aeaeb2;
  font-size: 12px;
  padding: 28px 0 36px;
  letter-spacing: 0.3px;
  border-top: 1px solid #f0f0f0;
  margin-top: auto;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .upload-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .upload-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .app-header h1 { font-size: 14px; }
  .header-logo { height: 28px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .app-container { padding: 16px 12px 32px; }
}

/* Shared platform header layout. */
.app-header { padding: 0; }
.app-header .header-inner { max-width: 1024px; min-height: 62px; padding: 0 20px; }
@media (max-width: 680px) { .app-header .header-inner { min-height: 56px; padding: 0 16px; } }


/* Shared platform typography. */
body, button, input, select, textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

/* Shared return control: an explicit, comfortably sized button. */
.back-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 12px; border: 1px solid #f0caca;
  background: #fef6f6; border-radius: 7px; line-height: 1; white-space: nowrap;
}
