* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --sidebar-bg: #0f172a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid #1e293b; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; font-weight: bold;
}
.logo-title { font-size: 16px; font-weight: 600; }
.logo-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }

.nav { padding: 12px 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; cursor: pointer; color: #cbd5e1;
  transition: all .2s; font-size: 14px;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { font-size: 16px; }
.sidebar-footer { padding: 16px 20px; font-size: 11px; color: #64748b; border-top: 1px solid #1e293b; }

/* 侧边栏用户区 */
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid #1e293b;
}
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 600;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.sidebar-btn {
  background: transparent; border-color: #334155; color: #cbd5e1;
  padding: 0 8px; height: 26px;
}
.sidebar-btn:hover { border-color: var(--primary); color: #fff; }
.sidebar-logout { background: transparent; border-color: #334155; color: #fca5a5; padding: 0 8px; height: 26px; }
.sidebar-logout:hover { border-color: var(--danger); color: #fecaca; }

/* 主区域 */
.main { flex: 1; padding: 24px; overflow-x: hidden; }
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 输入控件 */
.input {
  height: 36px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; background: #fff;
  transition: border .2s;
}
.input:focus { border-color: var(--primary); }
.search-input { width: 220px; }
.search-input.small { width: 140px; }
.select { min-width: 120px; cursor: pointer; }

/* 按钮 */
.btn {
  height: 36px; padding: 0 16px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px;
  transition: all .2s; color: var(--text);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* 表格 */
.table-wrap { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 13px; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--muted); padding: 40px; }

/* 标签 */
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.tag-0 { background: #fef3c7; color: #92400e; }
.tag-1 { background: #dbeafe; color: #1d4ed8; }
.tag-2 { background: #dcfce7; color: #166534; }
.tag-on { background: #dcfce7; color: #166534; }
.tag-off { background: #e2e8f0; color: #475569; }
.tag-normal { background: #dcfce7; color: #166534; }
.tag-abnormal { background: #fee2e2; color: #b91c1c; }

/* 分页 */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 18px; align-items: center; }
.pagination button { min-width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-info { color: var(--muted); margin: 0 8px; }

/* 弹窗 */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; align-items: center; justify-content: center; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-lg { width: 820px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { cursor: pointer; font-size: 24px; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.form-row { display: flex; align-items: center; margin-bottom: 14px; }
.form-row label { width: 90px; flex-shrink: 0; color: #475569; }
.form-row .input { flex: 1; }
.input.input-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.08); }

/* 巡检项选项编辑器 */
.item-options-box { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #f8fafc; }
.option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.option-text { flex: 1; }
.option-abnormal { white-space: nowrap; color: #475569; font-size: 13px; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: #475569; font-size: 14px; }
.switch-label input { cursor: pointer; }
.req-mark { color: var(--danger); font-weight: 700; }
.answer-area { margin-bottom: 10px; }
.answer-area .input { width: 100%; }
.detail-answer { color: #334155; font-size: 13px; margin-bottom: 6px; }

/* 巡检执行 */
.inspect-info { background: #f8fafc; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; color: #475569; font-size: 13px; line-height: 1.8; }
.inspect-items { margin-top: 8px; }
.inspect-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.inspect-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.inspect-item-name { font-weight: 600; }
.inspect-item .radio-group { display: flex; gap: 16px; }
.inspect-item .radio-group label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.photo-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-thumb { position: relative; }
.photo-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.photo-del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; border: none; cursor: pointer; font-size: 12px; line-height: 1; }
.photo-upload { width: 72px; height: 72px; border: 1px dashed var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-size: 22px; position: relative; overflow: hidden; }
.photo-upload:hover { border-color: var(--primary); color: var(--primary); }
.photo-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-progress { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* 详情 */
.detail-record { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.detail-record-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.detail-record .remark { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-record img { max-width: 120px; max-height: 120px; border-radius: 6px; border: 1px solid var(--border); margin: 4px; cursor: pointer; }

/* toast */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 8px;
  z-index: 999; display: none; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.show { display: block; animation: fadeIn .25s; }
.toast.error { background: var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 日志页 ===== */
.log-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.log-tab {
  padding: 9px 22px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 14px; color: var(--text);
  transition: all .2s;
}
.log-tab:hover { border-color: var(--primary); color: var(--primary); }
.log-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 系统配置 ===== */
.config-card { background: var(--card); border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.05); max-width: 640px; }
.config-card-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.config-card-desc { color: var(--muted); font-size: 13px; margin-bottom: 20px; line-height: 1.6; }
.config-form .form-row { margin-bottom: 16px; }
.config-form .form-row label { width: 140px; }
.config-actions { display: flex; gap: 10px; margin-top: 8px; }
.config-status { margin-top: 16px; }

/* ===== 数据看板 ===== */
.quarter-badge { background: #eef2ff; color: var(--primary); padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; }

.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); border-left: 4px solid var(--border);
}
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.blue { border-left-color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 34px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.orange .stat-value { color: var(--warning); }
.stat-card.blue .stat-value { color: var(--primary); }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 10px; }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid:last-child { grid-template-columns: 1fr 1fr; }
.dash-panel { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.dash-panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* 每日柱状图 */
.bar-chart { display: flex; align-items: flex-end; height: 200px; gap: 4px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-value { font-size: 10px; color: var(--muted); margin-bottom: 3px; height: 14px; }
.bar { width: 100%; max-width: 20px; height: 150px; background: #f1f5f9; border-radius: 3px 3px 0 0; position: relative; }
.bar-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, var(--primary), #7c3aed);
  border-radius: 3px 3px 0 0; transition: height .3s;
}
.bar-date { font-size: 10px; color: var(--muted); margin-top: 4px; height: 14px; white-space: nowrap; }

/* 状态分布 */
.dist-list { margin-bottom: 16px; }
.dist-row { display: flex; align-items: center; margin-bottom: 12px; }
.dist-label { width: 52px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.dist-bar { flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; margin: 0 10px; }
.dist-fill { height: 100%; border-radius: 5px; transition: width .3s; }
.dist-num { width: 28px; text-align: right; font-weight: 600; font-size: 13px; }
.ring-wrap { display: flex; justify-content: center; }

/* 各季度完成情况 */
.quarter-list { display: flex; flex-direction: column; gap: 14px; }
.quarter-row { display: flex; align-items: center; gap: 10px; }
.quarter-name { width: 70px; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.quarter-bar { flex: 1; height: 16px; background: #f1f5f9; border-radius: 8px; overflow: hidden; }
.quarter-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #7c3aed); border-radius: 8px; transition: width .3s; }
.quarter-num { width: 100px; text-align: right; color: var(--muted); font-size: 12px; flex-shrink: 0; }

/* 巡检质量 */
.quality-stats { display: flex; gap: 20px; justify-content: space-around; padding: 10px 0; }
.quality-item { text-align: center; }
.quality-num { font-size: 32px; font-weight: 700; color: var(--text); }
.quality-num.ok { color: var(--success); }
.quality-num.bad { color: var(--danger); }
.quality-label { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* 响应式 */
@media (max-width: 900px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid:last-child { grid-template-columns: 1fr; }
}

/* ===== 车辆导入 ===== */
.import-tips { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; font-size: 13px; color: #475569; line-height: 1.8; }
.import-tips .btn { margin-top: 8px; }
.import-drop { border: 2px dashed var(--border); border-radius: 10px; padding: 28px; text-align: center; cursor: pointer; position: relative; transition: border-color .2s; }
.import-drop:hover { border-color: var(--primary); }
.import-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-drop-text { color: var(--muted); font-size: 14px; }
.import-result { margin-top: 16px; }
.import-summary { padding: 10px 14px; border-radius: 8px; background: #dcfce7; color: #166534; font-weight: 600; font-size: 14px; }
.import-summary.has-error { background: #fef3c7; color: #92400e; }
.import-errors { margin-top: 10px; max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.import-error-row { padding: 8px 14px; border-bottom: 1px solid var(--border); color: var(--danger); font-size: 13px; }
.import-error-row:last-child { border-bottom: none; }

/* ============================================================
   移动端适配 (≤ 768px)
   ============================================================ */
.mobile-topbar { display: none; }
.sidebar-mask { display: none; }

@media (max-width: 768px) {
  body { font-size: 15px; }

  /* 顶部栏 */
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 50;
    background: var(--sidebar-bg); color: #fff;
    padding: 12px 16px; margin: -16px -16px 16px;
  }
  .hamburger {
    background: transparent; border: none; color: #fff;
    font-size: 24px; cursor: pointer; line-height: 1; padding: 2px;
  }
  .mobile-title { font-size: 16px; font-weight: 600; }

  /* 侧边栏抽屉 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
    width: 240px; transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: none; position: fixed; inset: 0; z-index: 150;
    background: rgba(0,0,0,.4);
  }
  .sidebar-mask.show { display: block; }

  /* 主区域 */
  .main { padding: 16px; }
  .page-header h2 { font-size: 18px; }
  .input, .select { font-size: 16px; } /* 防止 iOS 聚焦自动缩放 */
  .page-actions { width: 100%; }
  .search-input { flex: 1; width: auto; min-width: 0; }
  .page-actions .btn { flex: 1; }

  /* 弹窗全屏 */
  .modal-mask { align-items: flex-end; }
  .modal, .modal-lg {
    width: 100%; max-width: 100%; max-height: 96vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* 表单标签竖排 */
  .form-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .form-row label { width: auto; }
  .config-form .form-row label { width: auto; }

  /* 看板 */
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 26px; }
  .dash-grid { grid-template-columns: 1fr; gap: 10px; }
  .dash-grid:last-child { grid-template-columns: 1fr; }
  .bar-chart { height: 160px; }
  .bar { height: 110px; }

  /* 分页按钮更易点按 */
  .pagination button { min-width: 36px; height: 36px; }

  /* 按钮更大更易点按 */
  .btn { height: 40px; padding: 0 14px; }

  /* ===== 表格卡片化 ===== */
  .table-wrap { background: transparent; box-shadow: none; border-radius: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--card); border-radius: 12px;
    margin-bottom: 12px; padding: 8px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  .table tbody tr:hover { background: var(--card); }
  .table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid #f1f5f9; text-align: right;
    gap: 12px; flex-wrap: wrap;
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--muted); font-size: 13px;
    text-align: left; flex-shrink: 0; margin-right: auto;
  }
  .table td[data-label=""]::before, .table td.empty::before { display: none; }
  .table td.empty { display: block; text-align: center; }
  .table td[data-label="操作"] { justify-content: flex-end; }
  .table td[data-label="操作"]::before { margin-right: auto; }

  /* 巡检执行：选项/照片控件触屏优化 */
  .inspect-item { padding: 14px; }
  .inspect-item .radio-group { flex-wrap: wrap; gap: 10px; }
  .inspect-item .radio-group label { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
  .photo-thumb img { width: 88px; height: 88px; }
  .photo-upload { width: 88px; height: 88px; }

  /* 日志 tab */
  .log-tab { flex: 1; text-align: center; }
  .log-tabs { display: flex; }

  /* 配置 */
  .config-card { padding: 16px; }
}

