
/* ===== Mobile Components ===== */

/* ===== 通用菜单徽章样式（替换index.html中重复的inline style） ===== */
.menu-badge {
  margin-left: 8px;
  flex-shrink: 0;
  background: #ff4d4f;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
  font-weight: 500;
  white-space: nowrap;
}
.menu-badge.sm {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 10px;
}
/* Round5 Fix S3: 空徽标（如未读数为 0 时）不再渲染成红色小短条，避免"消息聊天"右侧出现多余红块 */
.menu-badge:empty {
  display: none !important;
}

/* ===== Round4 Fix T5: 材料来源筛选按钮样式 ===== */
.material-src-btn {
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #595959;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.material-src-btn:hover {
  border-color: #1890ff;
  color: #1890ff;
}
.material-src-btn.active {
  background: #1890ff;
  border-color: #1890ff;
  color: #fff;
}

/* ===== Round5 Fix S23: 材料库/问题库分页条样式 ===== */
.doc-pro-pager-btn {
  min-width: 34px;
  padding: 5px 10px;
  font-size: 13px;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s;
  line-height: 1.5;
}
.doc-pro-pager-btn:hover:not(:disabled) {
  border-color: #1890ff;
  color: #1890ff;
}
.doc-pro-pager-btn.active {
  background: #1890ff;
  border-color: #1890ff;
  color: #fff;
  font-weight: 600;
}
.doc-pro-pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== Round5 Fix S24: 通用 Switch 开关（启用/禁用控件） ===== */
.switch-control {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
  flex-shrink: 0;
}
.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-control .switch-slider {
  position: absolute;
  inset: 0;
  background: #d9d9d9;
  border-radius: 999px;
  transition: background 0.25s ease;
  cursor: pointer;
}
.switch-control .switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease;
}
.switch-control input:checked + .switch-slider {
  background: #34c759;
}
.switch-control input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch-control input:disabled + .switch-slider {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===== Round4 Fix T1: 子目录与父目录同字大小 ===== */
.menu-group-items .menu-item {
  font-size: 14px;
}
.menu-group-items .menu-item .menu-badge {
  margin-left: auto;
}

/* ===== Round4 Fix T2: 侧边栏与内容区衔接平顺 ===== */
.app-sidebar {
  border-right: none !important;
}

/* ===== Round4 Fix T4: 公文预览正文样式 ===== */
.gw-body p {
  text-indent: 2em;
  margin: 0.5em 0;
  line-height: 1.8;
}
.gw-body .gw-h1 {
  font-weight: bold;
  font-size: 16px;
  margin: 1em 0 0.5em;
}
.gw-body .gw-h2 {
  font-weight: bold;
  font-size: 15px;
  margin: 0.8em 0 0.4em;
}
.gw-body .gw-h3 {
  font-weight: 500;
  margin: 0.6em 0 0.3em;
}

.mobile-tabbar { display: none; }
.mobile-more-panel { display: none; }
.mobile-fab { display: none; }

/* ===== Responsive: Tablet (768px) ===== */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 80%;
    max-width: 280px;
    z-index: 101;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .header { padding: 0 16px; height: 56px; }
  .header-left { font-size: 16px; }
  .header-links { display: none !important; }
  .content {
    padding: 16px !important;
    padding-bottom: calc(16px + 56px + env(safe-area-inset-bottom, 0)) !important;
  }
  .page-section { padding: 0; margin: 0; }
  .card { padding: 16px; margin-bottom: 16px; border-radius: var(--radius); }
  .card-header { margin-bottom: 12px; padding-bottom: 10px; }
  .card-title { font-size: 15px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
  .stats-grid-6 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 16px; }
  .stat-card-sm { padding: 10px 6px; }
  .stat-card-sm .stat-value { font-size: 20px; }
  .stat-card .stat-value { font-size: 28px; }
  .stat-card .stat-label { font-size: 12px; }
  .dashboard-top { flex-direction: column; }
  .dashboard-top .filter-bar { min-width: unset; width: 100%; }
  .utility-row { width: 100%; }
  .mini-card { flex: 1; min-width: 0; padding: 6px 8px; }
  .filter-bar { gap: 10px; margin-bottom: 16px; }
  .filter-bar .form-group { width: 100%; min-width: 100%; }
  .filter-bar .btn { width: 100%; height: 40px; font-size: 14px; }
  .table th, .table td { padding: 10px 8px; font-size: 13px; white-space: nowrap; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-content { width: 95%; max-width: 100%; max-height: 90vh; }
  .modal-header { padding: 16px; }
  .modal-title { font-size: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .form-row { flex-direction: column; gap: 0; }
  .btn { padding: 10px 18px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-item { padding: 10px 16px; font-size: 13px; white-space: nowrap; }
  .pagination { flex-direction: column; gap: 10px; align-items: flex-start; }
  .settings-grid { grid-template-columns: 1fr; gap: 12px; }
  .settings-card .card-header { padding: 12px 16px; }
  .settings-card .card-body { padding: 12px 16px; }
  .settings-groups { gap: 12px; }
  .form-group-inline { flex-wrap: wrap; }
  .form-group-inline label { min-width: 100%; }

  .auth-container { width: calc(100% - 32px) !important; max-width: none !important; margin: 16px auto !important; border-radius: var(--radius-lg) !important; }
  .auth-header { padding: 20px 24px !important; }
  .auth-header h1 { font-size: 18px !important; }
  .auth-header p { font-size: 13px !important; }
  .auth-form { padding: 24px !important; }
  .auth-form .form-group label { font-size: 13px !important; }
  .auth-form .form-group input { padding: 10px 14px !important; font-size: 15px !important; }
  .auth-form .btn-primary { padding: 12px 24px !important; font-size: 15px !important; }
  .auth-footer { padding: 16px 24px !important; }
  .password-hint { font-size: 10px !important; }
  .password-hint .hint-item { padding: 2px 6px !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid-6 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid-4 { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 24px; }
  .stat-card-sm .stat-value { font-size: 18px; }
  .filter-bar { flex-wrap: wrap; }
  .filter-bar .form-group { flex: 1; min-width: 120px; }
  .utility-row { flex-direction: column; }
  .mini-card { max-width: 100%; }
  .content { padding: 12px !important; padding-bottom: calc(12px + 56px + env(safe-area-inset-bottom, 0)) !important; }
  .page-section { padding: 0; margin: 0; }
  .card { padding: 12px; margin-bottom: 12px; }
  .header-left { font-size: 15px; }
  .user-info span { display: none; }
  .btn { padding: 8px 14px; font-size: 12px; }
  .btn-sm { padding: 4px 8px; font-size: 11px; }
  .modal-footer .btn-primary, .modal-footer .btn-default { max-width: none; }
  .form-group { margin-bottom: 16px; }
  .form-group input, .form-group select, .form-group textarea { padding: 10px 12px; font-size: 13px; }
  .action-btns { flex-wrap: wrap; gap: 4px; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-container { width: calc(100% - 24px) !important; margin: 12px auto !important; }
  .auth-header h1 { font-size: 16px !important; }
  .auth-form { padding: 20px 16px !important; }
}

/* ===== Mobile Full Adaptation (<=768px) ===== */
@media (max-width: 768px) {
  .mobile-hide { display: none !important; }
  .sidebar { display: none !important; }
  .main { margin-left: 0 !important; }
  .header { height: 50px; padding: 0 12px; position: sticky; top: 0; z-index: 50; }
  .header-left { font-size: 16px; }
  .menu-toggle { display: none !important; }
  .content { padding: 12px !important; padding-bottom: calc(12px + 56px + env(safe-area-inset-bottom, 0)) !important; }
  .page-section { padding: 0; margin: 0; }
  .page-title { font-size: 17px; margin-bottom: 12px; }

  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #FFFFFF;
    border-top: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
  }

  .tabbar-item .tabbar-icon { font-size: 20px; margin-bottom: 2px; line-height: 1; }
  .tabbar-item.active { color: var(--brand); }
  .tabbar-item:active { background: var(--slate-100); }

  .mobile-more-panel {
    display: none;
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.12);
    z-index: var(--z-modal);
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    max-height: 60vh;
    overflow-y: auto;
  }

  .mobile-more-panel.show {
    display: block;
    animation: slideUp 0.25s ease;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .mobile-more-panel .more-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
  }

  .mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .mobile-more-grid .more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition-fast);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-more-grid .more-item:active { background: var(--brand-lighter); }
  .mobile-more-grid .more-item .more-icon { font-size: 24px; }
  .mobile-more-grid .more-item .more-text { font-size: 11px; color: var(--text-secondary); }
  .mobile-more-grid a.more-item { color: inherit; text-decoration: none; }
  .mobile-more-grid a.more-item .more-text { color: var(--text-secondary); }

  .mobile-more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 998;
  }

  .mobile-more-backdrop.show { display: block; }

  .mobile-fab { display: none !important; }
  .mobile-fab:active { transform: scale(0.9); }

  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .stat-card { padding: 14px 10px !important; }
  .stat-card .stat-value { font-size: 22px !important; }
  .stat-card .stat-label { font-size: 12px !important; }

  .table-container { overflow-x: visible !important; }
  .card .table, .pub-order-table { display: block; }
  .card .table thead, .pub-order-table thead { display: none; }
  .card .table tbody, .pub-order-table tbody { display: block; }

  .card .table tbody tr, .pub-order-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #FFFFFF;
    box-shadow: var(--shadow-xs);
  }

  .card .table tbody tr:hover, .pub-order-table tbody tr:hover { background: #FFFFFF; }

  .card .table tbody td, .pub-order-table tbody td {
    display: flex;
    align-items: center;
    width: 50%;
    padding: 4px 0;
    border: none;
    font-size: 13px;
    white-space: normal;
    text-align: left;
  }

  .card .table tbody td:before, .pub-order-table tbody td:before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
  }

  .card .table tbody td:last-child, .pub-order-table tbody td:last-child {
    width: 100%;
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
  }

  .card .table tbody td[colspan], .pub-order-table tbody td[colspan] {
    width: 100%;
    justify-content: center;
    padding: 20px;
    color: var(--text-muted);
  }

  .card .table tbody td[colspan]:before, .pub-order-table tbody td[colspan]:before { content: ''; }

  .card .table.repair-items-table { display: table !important; width: 100%; }
  .card .table.repair-items-table thead { display: table-header-group !important; }
  .card .table.repair-items-table tbody { display: table-row-group !important; }
  .card .table.repair-items-table tbody tr { display: table-row !important; border-radius: 0; border: none; box-shadow: none; margin-bottom: 0; padding: 0; flex-wrap: nowrap; }
  .card .table.repair-items-table tbody td, .card .table.repair-items-table thead th { display: table-cell !important; width: auto !important; flex: none; padding: 8px 4px; border: 1px solid var(--border-light); font-size: 12px; white-space: nowrap; text-align: center; }
  .card .table.repair-items-table tbody td:before { content: '' !important; margin: 0; }
  .card .table.repair-items-table tbody td:last-child { justify-content: center; margin-top: 0; padding-top: 8px; border-top: 1px solid var(--border-light); }

  .empty-state { text-align: center; padding: 20px; color: var(--text-muted); }

  .modal { align-items: stretch !important; padding: 0 !important; }
  .modal.show { display: flex; }
  .modal-content { width: 100% !important; max-width: 100% !important; max-height: 100vh !important; height: 100vh !important; border-radius: 0 !important; margin: 0 !important; }
  .modal-header { padding: 12px 16px !important; border-bottom: 1px solid var(--border-light); position: sticky; top: 0; background: #FFFFFF; z-index: 10; }
  .modal-title { font-size: 16px !important; }
  .modal-body { padding: 16px !important; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-footer { padding: 10px 16px !important; border-top: 1px solid var(--border-light); position: sticky; bottom: 0; background: #FFFFFF; z-index: 10; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)); }
  .modal-footer .btn { flex: 1; max-width: none !important; min-height: 44px; }

  .form-row { flex-direction: column !important; gap: 0 !important; }
  .form-group input, .form-group select, .form-group textarea { min-height: 44px; font-size: 15px !important; }
  .form-group label { font-size: 13px; }

  .filter-bar { flex-direction: column !important; gap: 8px !important; align-items: stretch !important; }
  .filter-bar .form-group { min-width: 0 !important; width: 100%; }
  .filter-bar .form-group input, .filter-bar .form-group select { min-height: 40px; }
  .filter-bar .btn, .search-btn { min-height: 40px; width: 100%; }

  .btn { min-height: 44px; font-size: 14px !important; padding: 10px 16px; }
  .btn-sm { min-height: 36px; font-size: 13px !important; padding: 6px 12px; }

  .card { padding: 14px !important; margin-bottom: 12px !important; border-radius: var(--radius); }
  .card-header { flex-wrap: wrap; gap: 8px; padding-bottom: 10px !important; }
  .card-title { font-size: 14px !important; }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
  .tab-item { white-space: nowrap; padding: 8px 12px !important; font-size: 13px !important; min-height: 44px; display: flex; align-items: center; }

  .detail-grid { grid-template-columns: 1fr !important; }
  .detail-row { flex-direction: column !important; gap: 0 !important; }
  .photo-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .upload-area { padding: 16px !important; }
  .upload-area .upload-icon { font-size: 32px !important; }
  .settings-grid { grid-template-columns: 1fr !important; }
  .pagination { flex-wrap: wrap; justify-content: center; gap: 4px; }
  .pagination button { min-width: 36px; min-height: 36px; font-size: 12px; }
  .header-right { gap: 8px; }
  .user-info span:not(.user-avatar) { display: none; }
  #bindWorkshopBtn, #userName, #userWorkshopInfo { display: none !important; }
  .user-avatar { width: 32px !important; height: 32px !important; font-size: 14px !important; }
  .notification-dropdown { position: fixed; top: 50px; right: 0; left: 0; width: 100% !important; max-height: 60vh; border-radius: 0 0 var(--radius-md) var(--radius-md); }
  #repairStepTabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #repairStepTabs .tab-item { min-width: 80px; justify-content: center; }
  #repairItemsBody tr td { font-size: 12px; padding: 6px 4px; }
  .modal-content[style*="900px"], .modal-content[style*="800px"], .modal-content[style*="600px"], .modal-content[style*="500px"], .modal-content[style*="450px"], .modal-content[style*="400px"] { width: 100% !important; max-width: 100% !important; }
  .action-btns { flex-wrap: wrap; gap: 4px; }
  .order-actions { flex-wrap: wrap; gap: 4px; }
  .repair-cost-summary { padding: 10px !important; }
  .repair-cost-row.total .cost-value { font-size: 15px !important; }
  #sidebarBackdrop { display: none !important; }

  .menu-item[data-desktop-only] { display: none !important; }
  .menu-group[data-desktop-only] { display: none !important; }
  [data-desktop-only] { display: none !important; }
  .sidebar-logo, .sidebar-footer { display: none !important; }
  .notification-bell { display: none !important; }
  .user-info { display: none !important; }
  .mobile-logout-btn { display: flex !important; }
  #bindWorkshopBtn { display: none !important; }
  .btn[onclick="switchPage('password')"] { display: none !important; }
  .header { justify-content: space-between !important; }
  .header-left { flex: 1; }
  #pageTitle { font-size: 16px; font-weight: 600; }

  .mobile-tabbar { display: flex !important; }
  .mobile-more-panel.show { display: block !important; }
  .mobile-more-backdrop.show { display: block !important; }

  #page-repairs .btn-back, #page-repairs [onclick*="showPage('dashboard')"], #page-repairs [onclick*="switchPage('dashboard')"] { display: none !important; }
  #page-repairs .filter-bar { flex-direction: column; gap: 10px; }
  #page-repairs .filter-bar .form-group { width: 100%; }
  #page-repairs .filter-bar .btn { width: 100%; height: 44px; font-size: 15px; }
  #page-repairs input[type="text"], #page-repairs input[type="number"], #page-repairs input[type="date"], #page-repairs select, #page-repairs textarea { min-height: 44px; font-size: 15px; padding: 10px 12px; }
  #page-repairs .btn { min-height: 44px; font-size: 15px; }
  #page-repairs .form-group label { font-size: 14px; margin-bottom: 6px; }
  #page-repairs .form-group { margin-bottom: 14px; }
  #page-repairs .upload-box, #page-repairs .upload-area { min-height: 80px; font-size: 14px; }
  #page-repairs .photo-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  #page-repairs .tabs { overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; white-space: nowrap; width: 100%; border-bottom: none; margin-bottom: 0; padding-bottom: 8px; border-bottom: 2px solid var(--border-light); }
  #page-repairs .tabs::-webkit-scrollbar { display: none; }
  #page-repairs .tab-item { flex-shrink: 0; padding: 10px 16px; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -2px; }
  #page-repairs .tab-item.active { border-bottom-color: var(--brand); color: var(--brand); font-weight: 500; }
  #page-repairs .filter-bar input, #page-repairs .filter-bar select { width: 100%; min-height: 44px; }
  #page-repairs .card { border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
  #page-repairs #newRepairBtn { min-height: 40px; padding: 0 16px; font-size: 14px; }
  #page-repairs .repair-filter-bar { display: none !important; }

  .form-group input, .form-group select, .form-group textarea { width: 100%; max-width: 100%; box-sizing: border-box; }
  .filter-group select, .filter-group input, .filter-bar select, .filter-bar input { width: 100%; max-width: 100%; box-sizing: border-box; }
  .form-row { flex-direction: column; gap: 10px; }
  .form-row .form-group { width: 100%; }
  .btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }
  .upload-box { padding: 12px; width: 100%; box-sizing: border-box; }
  .upload-preview img { max-width: 100%; height: auto; }
  .modal { width: 95%; max-width: 95vw; max-height: 90vh; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; overflow-y: auto; }
  .modal-content { width: 100%; box-sizing: border-box; padding: 16px; }
  .table-wrapper, .card table { max-width: 100%; overflow-x: auto; display: block; }
  .detail-grid, .detail-item { max-width: 100%; box-sizing: border-box; }
  .card .actions, .card [style*="display:flex"][style*="gap"] { flex-wrap: wrap; gap: 8px; }
  .btn, .tab-item, .menu-item, .more-item { -webkit-tap-highlight-color: transparent; }
  .btn { min-height: 40px; font-size: 14px; }
  .btn-sm { min-height: 32px; }
  .form-group input, .form-group select, .form-group textarea { min-height: 42px; font-size: 15px; }
  .card { margin-bottom: 12px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  #page-password .card { max-width: 100% !important; }
  #page-invite-codes .card-header { flex-direction: column; align-items: stretch; }
  #page-invite-codes #inviteCodeActionArea { width: 100%; }
  #page-invite-codes #inviteCodeActionArea .btn { flex: 1; }
  #page-public-orders .card-header { flex-direction: column; align-items: stretch; }
  .table-wrapper { -webkit-overflow-scrolling: touch; }
  .pagination button, .pagination .page-btn { min-width: 36px; min-height: 36px; font-size: 13px; }
  .modal { overflow-y: auto; }
  .modal-content { max-height: 85vh; }

  html, body { overflow-x: hidden; width: 100%; max-width: 100vw; }
  #app { overflow-x: hidden; width: 100%; max-width: 100vw; }
  .main { width: 100%; max-width: 100vw; overflow-x: hidden; }
  .content { padding: 12px !important; padding-bottom: calc(12px + 56px + env(safe-area-inset-bottom, 0)) !important; }
  .page-section { padding: 0; margin: 0; }
  .card { width: 100%; max-width: 100%; box-sizing: border-box; overflow-x: hidden; }
  .header { width: 100%; box-sizing: border-box; padding: 8px 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .stats-grid-6 { grid-template-columns: repeat(2, 1fr) !important; }
  .stats-grid-4 { grid-template-columns: 1fr !important; }
  .mobile-more-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card .stat-value { font-size: 18px !important; }
  .stat-card-sm .stat-value { font-size: 16px !important; }
  .card .table tbody td, .pub-order-table tbody td { width: 100% !important; }
  .card .table tbody td:before, .pub-order-table tbody td:before { width: 70px; }
  .header-left { font-size: 14px; }
}

/* Desktop: repair filter toggle */
@media (min-width: 769px) {
  #repairFilterToggle { display: none; }
  #repairDateFilter { display: flex !important; }
}

/* ===== Chat System ===== */
#page-chat.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.chat-layout {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-sidebar {
  width: 300px;
  min-width: 260px;
  background: var(--slate-50);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-sidebar-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: #FFFFFF;
}

.chat-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}

.chat-sidebar-icon { font-size: 18px; }

.chat-new-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #FFFFFF;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition-fast);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.chat-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chat-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
}

.chat-search-icon {
  color: var(--text-muted);
  font-size: 13px;
}

.chat-search input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--slate-50);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: var(--transition-fast);
  color: var(--text-primary);
}

.chat-search input:focus {
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
  background: #FFFFFF;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.chat-list-tip {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition-fast);
}

.conversation-item:hover {
  background: var(--brand-lighter);
}

.conversation-item.active {
  background: var(--brand-light);
  border-left-color: var(--brand);
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #06B6D4);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conversation-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conversation-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conversation-msg {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conversation-unread {
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
  font-weight: 600;
}

/* ===== Vehicle Calendar View ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
}
.calendar-header {
  display: contents;
}
.calendar-weekday {
  background: #1890ff;
  color: #fff;
  text-align: center;
  padding: 8px 0;
  font-weight: 600;
  font-size: 13px;
}
.calendar-day {
  background: #fff;
  min-height: 80px;
  padding: 4px 6px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  overflow: hidden;
}
.calendar-day:hover { background: #e6f7ff; }
.calendar-day.other-month { background: #fafafa; color: #ccc; }
.calendar-day.today { background: #e6f7ff; border: 2px solid #1890ff; }
.calendar-day.selected { background: #bae7ff; border: 2px solid #096dd9; }
.calendar-day-number {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}
.calendar-day.today .calendar-day-number { color: #1890ff; }
.calendar-event {
  font-size: 10px;
  padding: 1px 3px;
  margin-bottom: 1px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  color: #fff;
}
.calendar-event.overdue { background: #ff4d4f; }
.calendar-event.soon7 { background: #faad14; }
.calendar-event.soon30 { background: #1890ff; }
.calendar-event.normal { background: #52c41a; }
.calendar-more {
  font-size: 10px;
  color: #999;
  padding: 0 3px;
}
.calendar-day-detail {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
}
.calendar-day-detail h4 {
  margin: 0 0 8px 0;
  font-size: 15px;
  color: #333;
}
.calendar-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #f0f0f0;
  font-size: 13px;
}
.calendar-detail-item:last-child { border-bottom: none; }
.calendar-detail-type {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}
.calendar-detail-type.overdue { background: #ff4d4f; }
.calendar-detail-type.soon7 { background: #faad14; }
.calendar-detail-type.soon30 { background: #1890ff; }
.calendar-detail-type.normal { background: #52c41a; }

@media (max-width: 768px) {
  .calendar-day { min-height: 60px; padding: 2px 3px; }
  .calendar-event { font-size: 9px; padding: 0 2px; }
  .calendar-day-number { font-size: 11px; }
}

/* ===== Image Lazy Loading ===== */
img.lazy-load {
  background: linear-gradient(135deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
  background-size: 200% 100%;
  animation: lazy-shimmer 1.5s infinite;
  min-height: 60px;
}
@keyframes lazy-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
img.lazy-load.loaded {
  animation: none;
  background: transparent;
}
/* 全局图片懒加载降级 */
img[loading="lazy"] {
  background-color: #f5f5f5;
}

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--slate-50);
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

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

.chat-empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.chat-new-btn-large {
  border: none;
  border-radius: var(--radius);
  padding: 10px 22px;
  background: var(--brand-gradient);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: var(--transition-fast);
}

.chat-new-btn-large:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-head {
  padding: 12px 18px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-back-btn {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--slate-700);
  font-size: 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.chat-back-btn:hover {
  background: var(--slate-100);
}

.chat-head-main {
  flex: 1;
  min-width: 0;
}

.chat-head-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-readonly-badge {
  background: var(--warning-light);
  color: #92400E;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.chat-clear-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-muted);
  font-size: 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.chat-clear-btn:hover {
  color: var(--danger);
  border-color: #FECACA;
  background: var(--danger-light);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  display: flex;
  max-width: 72%;
}

.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.received {
  align-self: flex-start;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: linear-gradient(135deg, var(--slate-300), var(--slate-400));
  color: #FFFFFF;
}

.message.sent .message-avatar {
  background: var(--brand-gradient);
  margin-left: 8px;
}

.message.received .message-avatar {
  margin-right: 8px;
}

.message-body {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message.sent .message-meta {
  flex-direction: row-reverse;
}

.message-sender {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.message.sent .message-sender {
  color: var(--brand);
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
}

.message-sending {
  font-size: 11px;
  color: var(--text-muted);
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.message.sent .message-bubble {
  background: var(--brand-gradient);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
  background: #FFFFFF;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-temp .message-bubble {
  opacity: 0.75;
}

.message-error .message-bubble {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
  border-color: #FECACA !important;
}

.message-error .message-sending {
  color: var(--danger);
}

.chat-composer {
  padding: 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.chat-attach-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-attach-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--brand);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.chat-attach-btn:hover {
  background: var(--brand-lighter);
  border-color: #93C5FD;
  transform: rotate(45deg);
}

.chat-attach-menu {
  position: absolute;
  bottom: 48px;
  left: 0;
  width: 250px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 8px;
  z-index: 300;
  display: none;
}

.chat-attach-menu.show {
  display: block;
  animation: chatMenuIn 0.18s ease;
}

@keyframes chatMenuIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-attach-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.chat-attach-item:hover {
  background: var(--slate-50);
}

.chat-attach-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--brand-lighter);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-attach-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.chat-attach-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-composer textarea {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.5;
  outline: none;
  max-height: 110px;
  transition: var(--transition-fast);
  color: var(--text-primary);
  background: #FFFFFF;
}

.chat-composer textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}

.chat-send-btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  background: var(--brand-gradient);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.chat-send-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Order card in chat */
.order-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 240px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.order-card:hover {
  border-color: #93C5FD;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.order-card-no {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.order-card-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--brand-lighter);
  color: var(--brand);
  font-weight: 500;
}

.order-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.order-card-amount {
  color: var(--danger);
  font-weight: 600;
  margin-top: 6px;
  font-size: 13px;
}

.order-card-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--brand);
  font-weight: 500;
}

/* Picker item */
.picker-item {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFFFFF;
}

.picker-item:hover {
  border-color: #93C5FD;
  background: var(--brand-lighter);
}

.picker-item-info {
  flex: 1;
  min-width: 0;
}

.picker-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.picker-item-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.picker-item-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Chat new partner */
.chat-new-partner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.chat-new-partner:hover {
  background: var(--brand-lighter);
}

.chat-new-partner-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #06B6D4);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

/* ============================================
   车辆全生命周期档案 - 桌面端样式 V3
   设计风格：简约鲜亮、冷色调蓝灰、大留白、卡片分层
   ============================================ */

/* ===== 车辆全生命周期档案：统一网站风格（全局设计令牌 + 卡片分层） ===== */
#vehicleDetailModal.modal {
  background: var(--overlay, rgba(15, 23, 42, 0.45));
}
#vehicleDetailModal .modal-content {
  width: 800px !important;
  max-width: 92vw !important;
  border-radius: var(--radius-lg, 18px);
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: var(--shadow-lg, 0 20px 40px -10px rgba(15, 23, 42, 0.20));
}
#vehicleDetailModal .modal-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  background: var(--bg-primary, #fafbfc);
  border-radius: var(--radius-lg, 18px) var(--radius-lg, 18px) 0 0;
}
#vehicleDetailModal .modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  letter-spacing: 0.2px;
}
#vehicleDetailModal .modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card-bg, #fff);
  color: var(--text-secondary, #64748b);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
#vehicleDetailModal .modal-close:hover {
  background: var(--danger-bg, #fef2f2);
  color: var(--danger-color, #dc2626);
  border-color: var(--danger-border, #fecaca);
}
#vehicleDetailModal .modal-body {
  padding: 18px 22px 22px !important;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-primary, #fafbfc);
  border-radius: 0 0 var(--radius-lg, 18px) var(--radius-lg, 18px);
}

/* ----- 顶部车牌 Hero 卡片（蓝白渐变 + 设计令牌） ----- */
.vehicle-detail-hero {
  position: relative;
  border-radius: var(--radius-md, 14px);
  padding: 22px 24px;
  margin-bottom: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary-50, #eff6ff) 0%, var(--primary-100, #dbeafe) 55%, var(--indigo-50, #eef2ff) 100%);
  border: 1px solid var(--primary-200, #bfdbfe);
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(59, 130, 246, 0.08));
}
.vehicle-detail-hero-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 88% 10%, var(--primary-rgb, 59, 130, 246) 10%, transparent 45%),
    radial-gradient(circle at 8% 95%, var(--indigo-rgb, 99, 102, 241) 8%, transparent 50%);
  background-image:
    radial-gradient(circle at 88% 10%, rgba(59, 130, 246, 0.10) 0, transparent 45%),
    radial-gradient(circle at 8% 95%, rgba(99, 102, 241, 0.08) 0, transparent 50%);
  pointer-events: none;
}
.vehicle-detail-hero-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.vehicle-detail-hero-left {
  flex: 1;
  min-width: 0;
}
.vehicle-detail-plate {
  display: inline-block;
  padding: 8px 22px;
  background: var(--card-bg, #fff);
  color: var(--primary-700, #1d4ed8);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  border-radius: var(--radius-sm, 12px);
  border: 1.5px solid var(--primary-200, #bfdbfe);
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(29, 78, 216, 0.10));
  margin-bottom: 10px;
}
.vehicle-detail-brand {
  color: var(--text-secondary, #475569);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
/* 导出档案按钮：蓝色描边 + 白底（令牌统一） */
.vehicle-export-btn {
  flex-shrink: 0;
  background: var(--card-bg, #fff) !important;
  color: var(--primary-color, #2563eb) !important;
  border: 1.5px solid var(--primary-200, #bfdbfe) !important;
  border-radius: var(--radius-sm, 10px);
  padding: 7px 16px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(37, 99, 235, 0.12));
  transition: all 0.15s ease;
}
.vehicle-export-btn:hover {
  background: var(--primary-50, #eff6ff) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md, 0 4px 14px rgba(37, 99, 235, 0.18));
}
.vehicle-export-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm, 0 1px 4px rgba(37, 99, 235, 0.14));
}

/* ----- 4 列统计卡片组（纯白、微阴影，和首页 stat-card 一致） ----- */
.vehicle-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md, 14px);
  margin-bottom: 16px;
}
.vehicle-stat-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #eef1f5);
  border-radius: var(--radius-md, 14px);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(15, 23, 42, 0.04));
  transition: all 0.2s ease;
}
.vehicle-stat-card:hover {
  box-shadow: var(--shadow-md, 0 6px 16px rgba(15, 23, 42, 0.08));
  transform: translateY(-2px);
}
.vehicle-stat-card--featured {
  border-color: var(--danger-border, #fecaca);
  background: linear-gradient(180deg, var(--card-bg, #fff) 0%, var(--danger-50, #fef2f2) 100%);
}
.vehicle-stat-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-sm, 12px);
  border: 1px solid var(--border, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--bg-secondary, #f8fafc);
}
/* 统计图标语义色（取代 HTML inline style） */
.vehicle-stat-icon--success { background: var(--success-50, #f6ffed); border-color: var(--success-border, #b7eb8f); color: var(--success-color, #52c41a); }
.vehicle-stat-icon--primary { background: var(--primary-50, #e6f7ff); border-color: var(--primary-200, #91d5ff); color: var(--primary-color, #1890ff); }
.vehicle-stat-icon--info    { background: var(--info-50, #f0f5ff);    border-color: var(--info-border, #adc6ff);    color: var(--info-color, #2f54eb); }
.vehicle-stat-icon--danger  { background: var(--danger-50, #fff1f0);  border-color: var(--danger-border, #ffa39e);  color: var(--danger-color, #ff4d4f); }
.vehicle-stat-body {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.vehicle-stat-label {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  margin-bottom: 4px;
  font-weight: 500;
}
.vehicle-stat-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  display: inline-flex;
  align-items: baseline;
}
.vehicle-stat-value--success { color: var(--success-color, #389e0d); }
.vehicle-stat-value--primary { color: var(--primary-700, #0958d9); }
.vehicle-stat-value--danger  { color: var(--danger-color, #cf1322); }
.vehicle-stat-value--xl {
  font-size: 22px;
}

/* ----- 车辆基础信息卡片 ----- */
.vehicle-detail-info-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #eef1f5);
  border-radius: var(--radius-md, 14px);
  padding: 18px 20px;
  margin-bottom: 4px;
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(15, 23, 42, 0.04));
}
.vehicle-info-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  display: flex;
  align-items: center;
  gap: 6px;
}
.vehicle-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 20px;
}
.vehicle-info-item--wide {
  grid-column: span 2;
}
.vehicle-info-label {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  margin-bottom: 5px;
  font-weight: 500;
}
.vehicle-info-value {
  font-size: 14px;
  color: var(--text-primary, #0f172a);
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
}
.vehicle-info-value--mono {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #334155);
  font-size: 13px;
  background: var(--bg-secondary, #f8fafc);
  padding: 5px 10px;
  border-radius: var(--radius-sm, 6px);
  display: inline-block;
  border: 1px solid var(--border, #e2e8f0);
}

/* 状态徽章（令牌统一） */
.vehicle-status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.vehicle-status-badge--active {
  background: var(--success-50, rgba(16, 185, 129, 0.12));
  color: var(--success-color, #059669);
  border-color: var(--success-border, rgba(110, 231, 183, 0.45));
}
.vehicle-status-badge--idle {
  background: var(--bg-secondary, rgba(148, 163, 184, 0.14));
  color: var(--text-secondary, #475569);
  border-color: var(--border, rgba(203, 213, 225, 0.5));
}
.vehicle-status-badge--repairing {
  background: var(--warning-50, rgba(245, 158, 11, 0.14));
  color: var(--warning-color, #b45309);
  border-color: var(--warning-border, rgba(253, 230, 138, 0.55));
}
.vehicle-status-badge--scrapped,
.vehicle-status-badge--sold,
.vehicle-status-badge--inactive {
  background: var(--danger-50, rgba(239, 68, 68, 0.12));
  color: var(--danger-color, #dc2626);
  border-color: var(--danger-border, rgba(252, 165, 165, 0.5));
}

/* 车辆标签（胶囊风格，令牌统一） */
.vehicle-tag-empty {
  color: var(--text-muted, #94a3b8);
  font-size: 13px;
  font-style: normal;
}
.vehicle-tag-pill {
  display: inline-block;
  padding: 3px 10px;
  margin: 2px 6px 2px 0;
  background: var(--primary-50, rgba(59, 130, 246, 0.10));
  color: var(--primary-color, #2563eb);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 0.5px solid var(--primary-200, rgba(147, 197, 253, 0.45));
}

/* 车辆档案 tabs 栏（分段控制风格，令牌统一） */
.vehicle-detail-tabs-bar {
  margin-top: 22px !important;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--bg-secondary, rgba(148, 163, 184, 0.10));
  border-radius: var(--radius-md, 12px);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.16));
  display: flex;
  gap: 2px;
  border-bottom: none !important;
}
.vehicle-detail-tabs-bar .tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 14px !important;
  font-size: 13px !important;
  font-weight: 600;
  border-radius: var(--radius-sm, 9px);
  color: var(--text-muted, #64748b);
  border: none;
  transition: all 0.15s ease;
}
.vehicle-detail-tabs-bar .tab-item.active {
  background: var(--card-bg, #fff);
  color: var(--text-primary, #0f172a);
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(15, 23, 42, 0.06));
}

/* 维修时间线（卡片流风格） */
#repairTimeline .timeline-item {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb) !important;
  border-radius: var(--radius-md, 14px);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.04));
  transition: all 0.2s ease;
}
#repairTimeline .timeline-item:hover {
  background: var(--card-bg, #fff);
  box-shadow: var(--shadow-md, 0 6px 16px rgba(15, 23, 42, 0.08));
}
.timeline-amount {
  color: var(--danger-color, #dc2626);
  font-weight: 700;
}

/* 费用趋势汇总卡（卡片风格，非毛玻璃） */
.cost-lifetime-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 16px);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.04));
  margin-bottom: 16px;
}
.cost-lifetime-main { flex: 1; min-width: 0; }
.cost-lifetime-label {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
  margin-bottom: 6px;
}
.cost-lifetime-total {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary, #1e293b) 0%, var(--danger-color, #dc2626) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.cost-lifetime-meta {
  display: flex;
  align-items: center;
  gap: 24px;
}
.cost-meta-item { text-align: center; }
.cost-meta-label { color: var(--text-muted, #94a3b8); font-size: 12px; margin-bottom: 4px; }
.cost-meta-value { color: var(--text-primary, #0f172a); font-weight: 800; font-size: 18px; }
.cost-meta-divider { width: 1px; align-self: stretch; background: var(--border, rgba(148, 163, 184, 0.2)); }

/* ECharts 容器统一卡片底 */
#vehicleDetailModal .chart-container {
  background: var(--card-bg, #fff);
  border-radius: var(--radius-md, 14px);
  padding: 12px;
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(15, 23, 42, 0.04));
}

@media (max-width: 640px) {
  .cost-lifetime-summary { flex-direction: column; align-items: flex-start; gap: 14px; }
  .cost-lifetime-meta { width: 100%; justify-content: space-around; }
}

/* ===== 问题8：手机端（含临时切换到PC视口宽度<=768 的手机场景）车辆档案排版优化 ===== */
@media (max-width: 768px) {
  #vehicleDetailModal .modal-content {
    width: 92vw !important;
    max-width: 92vw !important;
    margin: 2vh auto !important;
  }
  #vehicleDetailModal .modal-header {
    padding: 14px 16px 10px !important;
  }
  #vehicleDetailModal .modal-body {
    padding: 4px 16px 20px !important;
  }
  .vehicle-detail-hero {
    padding: 18px 16px !important;
    border-radius: 18px !important;
    margin-bottom: 14px !important;
  }
  .vehicle-detail-hero-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .vehicle-detail-hero-left { width: 100%; }
  .vehicle-detail-plate {
    font-size: 22px;
    padding: 8px 18px;
    letter-spacing: 2px;
    border-radius: 12px;
  }
  .vehicle-export-btn {
    align-self: stretch;
    text-align: center;
    width: 100%;
  }
  .vehicle-detail-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .vehicle-stat-card {
    padding: 12px 14px !important;
    border-radius: 16px !important;
    gap: 10px !important;
  }
  .vehicle-stat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    font-size: 18px;
  }
  .vehicle-stat-label { font-size: 11px; }
  .vehicle-stat-value { font-size: 15px; }
  .vehicle-stat-value--xl { font-size: 17px; }
  .vehicle-detail-info-card {
    padding: 14px 16px !important;
    border-radius: 18px !important;
    margin-bottom: 10px !important;
  }
  .vehicle-info-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0 !important;
  }
  .vehicle-info-grid .vehicle-info-item {
    padding: 10px 10px 10px 0 !important;
  }
  .vehicle-info-item--wide { grid-column: span 2 !important; padding-right: 0 !important; }
  .vehicle-info-label { font-size: 11px; }
  .vehicle-info-value { font-size: 13px; line-height: 1.5; }
  .vehicle-detail-tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
    white-space: nowrap;
  }
  .vehicle-detail-tabs-bar .tab-item {
    flex: none;
    min-width: 72px;
    font-size: 12px;
    padding: 7px 10px;
  }
  #costChartContainer .chart-container {
    height: 240px !important;
    padding: 8px !important;
    border-radius: 14px !important;
  }
}
/* 手机临时打开PC视图时，强制应用移动端排版，使车辆档案在手机屏幕依然符合常理 */
body.mobile-temp-view #vehicleDetailModal .modal-content {
  width: 92vw !important;
  max-width: 92vw !important;
  margin: 2vh auto !important;
}
body.mobile-temp-view .vehicle-detail-stats {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 10px !important;
}
body.mobile-temp-view .vehicle-info-grid {
  grid-template-columns: repeat(2, 1fr) !important;
}
body.mobile-temp-view .vehicle-detail-hero-content {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
body.mobile-temp-view .vehicle-export-btn {
  width: 100%;
}

/* 费用趋势图容器高度适配 */
#costChartContainer .chart-container {
  width: 100%;
  height: 360px;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid #f0f0f0;
}

.chat-new-partner-info {
  flex: 1;
  min-width: 0;
}

.chat-new-partner-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.chat-new-partner-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-new-partner-action {
  color: var(--brand);
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 500;
}

/* Chat image */
.chat-msg-image {
  max-width: 220px;
  max-height: 260px;
  border-radius: var(--radius);
  display: block;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
}

.chat-images-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.chat-image-wrap {
  position: relative;
  display: inline-block;
}

/* Chat mobile */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: row;
    border: none;
    border-radius: 0;
  }
  .chat-sidebar { width: 100%; min-width: 0; border-right: none; }
  .chat-sidebar.hidden { display: none; }
  .chat-main { display: none; flex: 1; }
  .chat-main.show { display: flex; }
  .chat-back-btn { display: flex !important; }
  .chat-messages { padding: 14px; }
  .message { max-width: 85%; }
  .chat-composer { padding: 10px 12px; }
  .chat-composer textarea { font-size: 16px; }
}