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

:root {
  --primary: #1677ff;
  --primary-light: #e6f4ff;
  --primary-dark: #0958d9;
  --accent: #6f42f5;
  --industrial-amber: #ffa800;
  --sidebar-width: 220px;
  --sidebar-collapsed: 60px;
  --topbar-height: 56px;
  --bg: #eef1f8;
  --card-bg: #fff;
  --border: #e8ecf3;
  --text: #1a1a1a;
  --text-secondary: #666;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --sidebar-bg: #0b1e3f;
  --sidebar-text: rgba(255,255,255,0.78);
  --sidebar-active: #1677ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  font-size: 14px;
  background: linear-gradient(160deg, #eef2fb 0%, #e7ecf6 40%, #eef1f8 100%);
  background-attachment: fixed;
  color: var(--text);
}

/* 各模块识别色 - 提升页面间的辨识度 */
.topbar[data-module="dashboard"], .page-content[data-module="dashboard"] { --m-color: #1677ff; --m-light: #e6f4ff; }
.topbar[data-module="workorders"], .page-content[data-module="workorders"] { --m-color: #fa541c; --m-light: #fff2e8; }
.topbar[data-module="map"], .page-content[data-module="map"] { --m-color: #13c2c2; --m-light: #e6fffb; }
.topbar[data-module="customers"], .page-content[data-module="customers"] { --m-color: #722ed1; --m-light: #f9f0ff; }
.topbar[data-module="parts"], .page-content[data-module="parts"] { --m-color: #d48806; --m-light: #fffbe6; }
.topbar[data-module="payments"], .page-content[data-module="payments"] { --m-color: #389e0d; --m-light: #f6ffed; }
.topbar[data-module="express"], .page-content[data-module="express"] { --m-color: #2f54eb; --m-light: #f0f5ff; }
.topbar[data-module="reports"], .page-content[data-module="reports"] { --m-color: #eb2f96; --m-light: #fff0f6; }
.topbar[data-module="users"], .page-content[data-module="users"] { --m-color: #595959; --m-light: #f0f0f0; }
.topbar[data-module] .page-title { color: var(--m-color); border-left: 4px solid var(--m-color); padding-left: 10px; transition: color .2s, border-color .2s; }

/* 登录 */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #001529 0%, #003a70 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: #001529; }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* 主布局 */
.main-layout { display: flex; min-height: 100vh; }

/* 侧边栏 - 工业风格背景：蓝图网格 + 斜纹纹理 */
.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.022) 0px, rgba(255,255,255,0.022) 2px, transparent 2px, transparent 16px),
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px) 0 0/100% 24px,
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0/24px 100%,
    linear-gradient(195deg, #0a1d3a 0%, #13294f 55%, #0a1c38 100%);
  display: flex; flex-direction: column; transition: width 0.2s; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; overflow: hidden; box-shadow: 2px 0 12px rgba(0,0,0,0.25);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 14px; color: #fff; font-size: 18px; font-weight: 700; min-height: 58px; letter-spacing: 0.5px;
  border-bottom: 3px solid; border-image: repeating-linear-gradient(135deg, var(--industrial-amber) 0 10px, #16407a 10px 20px) 1;
}
.logo-text { white-space: nowrap; }
.collapse-btn { cursor: pointer; color: rgba(255,255,255,0.6); flex-shrink: 0; }
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; overflow-x: hidden; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--sidebar-text); cursor: pointer; transition: all 0.15s; white-space: nowrap; position: relative; border-radius: 6px; margin: 3px 8px; font-size: 15.5px; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,0.09); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, #1677ff 0%, #00c6fb 120%); color: #fff; box-shadow: inset 3px 0 0 var(--industrial-amber), 0 4px 14px rgba(0,151,255,0.4); font-weight: 700; }
.nav-item .el-icon { font-size: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 500; }
.user-role { color: rgba(255,255,255,0.5); font-size: 11px; }

/* 主内容 */
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.2s; }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }
.topbar { height: var(--topbar-height); background: rgba(255,255,255,0.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: 0.5px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 20px; flex: 1; }

/* 卡片 */
.card { background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(31,45,82,0.06); border: 1px solid rgba(232,236,243,0.8); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; padding-left: 10px; border-left: 4px solid var(--m-color, var(--primary)); color: var(--text); }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden; border: 1px solid var(--border); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--primary); opacity: 0.85; }
.stat-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.08); transform: translateY(-2px); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 10px; background: var(--primary-light); color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-value { font-size: 30px; font-weight: 800; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning .stat-icon { background: #fff7e6; color: var(--warning); }
.stat-card.danger .stat-icon { background: #fff1f0; color: var(--danger); }
.stat-card.success .stat-icon { background: #f6ffed; color: var(--success); }

/* 工作台分区标题 */
.dash-section-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
.dash-section-title .el-icon { font-size: 18px; color: var(--m-color, var(--primary)); }
.kanban-card .card-header { flex-wrap: wrap; gap: 12px; }

/* 看板统计 - 排行展示 */
.kanban-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kanban-summary-item { background: linear-gradient(135deg, var(--primary-light) 0%, #f5f8ff 100%); border-radius: 10px; padding: 14px 16px; }
.kanban-summary-item .v { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.kanban-summary-item .l { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; }
.rank-item { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; transition: background .15s; }
.rank-item:hover { background: #f7f9fc; }
.rank-badge { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; background: #c0c4cc; flex-shrink: 0; }
.rank-badge.r1 { background: linear-gradient(135deg,#ffd666,#ffa940); }
.rank-badge.r2 { background: linear-gradient(135deg,#e2e8f0,#a3b1c6); }
.rank-badge.r3 { background: linear-gradient(135deg,#f3c6a0,#d98e5b); }
.rank-name { width: 84px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.rank-bars { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rank-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.rank-bar-label { width: 76px; color: var(--text-secondary); flex-shrink: 0; }
.rank-bar-track { flex: 1; height: 6px; background: #eef1f7; border-radius: 3px; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.rank-bar-fill.repair { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.rank-bar-fill.fee { background: linear-gradient(90deg, var(--success), #95de64); }
.rank-bar-fill.scale { background: linear-gradient(90deg, var(--warning), #ffd666); }
.rank-bar-value { width: 64px; text-align: right; font-weight: 700; flex-shrink: 0; }

/* 工单状态标签 */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-pending { background: #fff7e6; color: #d46b08; }
.tag-assigned { background: #e6f4ff; color: #0958d9; }
.tag-in_progress { background: #f0f5ff; color: #1d39c4; }
.tag-completed { background: #f6ffed; color: #389e0d; }
.tag-cancelled { background: #f5f5f5; color: #8c8c8c; }
.tag-urgent { background: #fff1f0; color: #cf1322; }
.tag-high { background: #fff7e6; color: #d46b08; }
.tag-normal { background: #f0f5ff; color: #1d39c4; }
.tag-install { background: #e6fffb; color: #08979c; }
.tag-repair { background: #fff0f6; color: #c41d7f; }
.tag-upgrade { background: #f9f0ff; color: #531dab; }
.tag-remote { background: #f0f5ff; color: #1d39c4; }

/* 工单池 */
.order-pool { display: grid; gap: 12px; }
.order-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px; cursor: pointer; transition: all 0.15s; position: relative; }
.order-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(22,119,255,0.1); }
.order-card.urgent { border-left: 4px solid var(--danger); }
.order-card.high { border-left: 4px solid var(--warning); }
.order-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.order-no { font-size: 12px; color: var(--text-secondary); font-family: monospace; }
.order-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.order-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 地图 */
.map-container { height: calc(100vh - var(--topbar-height) - 80px); border-radius: 8px; overflow: hidden; }
#map, #customer-map { width: 100%; height: 100%; }

/* 搜索栏 */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search-bar .el-input { width: 240px; }

/* 表格美化 */
.el-table { border-radius: 8px; --el-table-border-color: #f0f0f0; font-size: 14px; }
.el-table th.el-table__cell { background: var(--m-light, #fafbfc) !important; color: #444; font-weight: 700; font-size: 13.5px; height: 46px; }
.el-table td.el-table__cell { padding: 10px 0; font-size: 14px; }
.el-table .cell { line-height: 1.5; }
.el-table--striped .el-table__body tr.el-table__row--striped td { background: #fafbfc; }
.el-table__row:hover > td.el-table__cell { background: #f0f7ff !important; }
.el-pagination { padding: 4px 4px; }
.tag { font-weight: 600; letter-spacing: 0.3px; }

/* 照片上传 */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.photo-item { aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }

/* 详情页面 */
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.detail-section { margin-bottom: 16px; }
.detail-section h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; margin-bottom: 10px; font-size: 14px; }
.detail-label { width: 100px; color: var(--text-secondary); flex-shrink: 0; }
.detail-value { flex: 1; font-weight: 500; }

/* 时间线日志 */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot { position: absolute; left: -20px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary); }
.timeline-content { background: var(--bg); border-radius: 6px; padding: 10px 12px; }
.timeline-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.timeline-action { font-size: 12px; color: var(--text-secondary); }
.timeline-time { font-size: 11px; color: #999; }
.timeline-text { font-size: 13px; }

/* 移动端适配 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .detail-layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar .el-input { width: 100%; }
  .page-content { padding: 12px; }
}

/* 快速新建按钮 */
.fab { position: fixed; right: 24px; bottom: 24px; z-index: 99; }

/* 报表 */
.report-table .highlight { font-weight: 700; color: var(--primary); }
.perf-bar { height: 6px; background: var(--primary-light); border-radius: 3px; }
.perf-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }

/* 加载 */
.loading-mask { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text-secondary); flex-direction: column; gap: 12px; }
