
/* ========== CSS 变量 ========== */
:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  /* 手机顶栏高度（含灵动岛/刘海安全区在媒体查询里用 env() 叠加） */
  --topbar-h: 52px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== 布局 ========== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-light);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  margin-bottom: 2px;
}

/* 导航小红点 + 数字提醒（新派单未读） */
.nav-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--sidebar-bg, #1f2937);
  pointer-events: none;
}

.nav-item:hover { background: rgba(255,255,255,0.06); }

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
}

.main {
  flex: 1;
  margin-left: 220px;
  padding: 28px 32px;
  max-width: calc(100vw - 220px);
}

/* ========== 业务板块切换条 ========== */
.brand-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand-switch-label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.brand-switch-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.brand-switch-btn:hover { background: #eef2ff; }
.brand-switch-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37,99,235,.3);
}

/* ========== 页面标题 ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ========== 卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-body { padding: 20px; }

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  transition: transform 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }

/* ========== 状态标签 ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending { background: #fee2e2; color: #dc2626; }       /* 待处理 红 */
.badge-dispatched { background: #dbeafe; color: #2563eb; }    /* 派单中 蓝 */
.badge-label_created { background: #cffafe; color: #0891b2; } /* 已出运单 青 */
.badge-received { background: #e0e7ff; color: #4338ca; }      /* 已入库 靛 */
.badge-inspecting { background: #ffedd5; color: #ea580c; }    /* 检测中 橙 */
.badge-repairing { background: #fef9c3; color: #a16207; }     /* 维修中 黄 */
.badge-ready { background: #fce7f3; color: #be185d; }         /* 待发货 粉 */
.badge-confirming { background: #fce7f3; color: #db2777; }    /* 待确认 粉红 */
.badge-shipped { background: #ccfbf1; color: #0f766e; }       /* 已发货 蓝绿 */
.badge-completed { background: #dcfce7; color: #16a34a; }    /* 已完成 绿 */
.badge-inspected { background: #e0e7ff; color: #4338ca; }

/* ========== 优先级（正常 / 紧急） ========== */
.badge.prio-normal { background: #ecfdf5; color: #047857; }      /* 正常：淡绿 */
.badge.prio-urgent { background: #fee2e2; color: #b91c1c;       /* 紧急：红底红字 + 闪烁呼吸 */
                       animation: prioPulse 1.8s ease-in-out infinite; }
@keyframes prioPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.0); }
  50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18); }
}

/* 紧急工单整行高亮 */
tr.row-urgent {
  background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 50%, #ffffff 100%);
}
tr.row-urgent:hover {
  background: linear-gradient(90deg, #fee2e2 0%, #fecaca 50%, #fff5f5 100%);
}
tr.row-urgent td:first-child {
  border-left: 3px solid #dc2626;
}

/* 重复的工作记录：整行标红提示（系统不自动删除，由用户核对后自行删除） */
tr.row-dup {
  background: linear-gradient(90deg, #fff1f2 0%, #fff7f7 55%, #ffffff 100%);
}
tr.row-dup:hover {
  background: linear-gradient(90deg, #ffe4e6 0%, #fecdd3 55%, #fff7f7 100%);
}
tr.row-dup td:first-child {
  border-left: 3px solid #e11d48;
}
.dup-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}
.dup-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid #fecdd3;
  border-left: 4px solid #e11d48;
  border-radius: var(--radius-sm);
  background: #fff1f2;
  color: #9f1239;
  font-size: 13px;
  line-height: 1.5;
}

/* 同一工单号被重复记录（工作历史）：整行淡红底 + 工单号变红（2026-10-01）
   与「内容完全重复」的 row-dup 区分：这里只认工单号，底色更浅、不做整行重标红 */
tr.row-dupcase {
  background: linear-gradient(90deg, #fff5f5 0%, #fffbff 55%, #ffffff 100%);
}
tr.row-dupcase:hover {
  background: linear-gradient(90deg, #ffe4e6 0%, #fecdd3 55%, #fff7f7 100%);
}
tr.row-dupcase td:first-child {
  border-left: 3px solid #f87171;
}
.cell-link-dup {
  color: #dc2626 !important;
  font-weight: 700;
}
.cell-link-dup:hover {
  color: #b91c1c !important;
}
.dup-case-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}

/* 维修指示列简写 */
.td-instructions .cell-truncate {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.td-instructions .cell-truncate .more {
  color: #9ca3af;
  font-weight: 600;
}

/* 备注列：末列，允许折行 + 顶对齐。
   2026-11-11 修：原来只有 max-width:220px、没有下限，12~13 列工单表在 width:100% 的
   auto 布局下会把这一列压到 53px，长备注变成「一字一行」竖排、整行被撑到 500px 高。
   补 width/min-width 作硬下限，多出来的表格宽度由 .table-wrap 的横向滚动消化：
   页面可视宽度与其它列都不变，只是备注从竖条变成正常横排的文本块。 */
.td-notes {
  width: 300px;
  min-width: 260px;
  max-width: 360px;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #374151;
  font-size: 12px;
  line-height: 1.45;
}

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
/* 备件下拉：相对定位参照系（下拉 absolute 挂其内部，跟随输入框一起滚动） */
.part-input-wrap { position: relative; }
/* 下拉弹出时临时解除表格横向滚动裁剪，避免下拉被 .table-wrap 切掉（JS 内联控制，这里兜底） */
.table-wrap.dropdown-open,
.table-wrap:has(.part-search-dropdown) { overflow: visible; }
.part-search-dropdown { box-sizing: border-box; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody tr:hover { background: #f8fafc; }
tbody tr { transition: background 0.1s; }
/* 从详情返回列表时，当前处理工单行用深色背景高亮 */
#records-body tr.active-row,
#records-body tr.active-row td {
  background: #bfdbfe !important;
}
#records-body tr.active-row:hover,
#records-body tr.active-row:hover td {
  background: #93c5fd !important;
}

.clickable-row { cursor: pointer; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-group { display: flex; gap: 8px; }

/* ========== 表单 ========== */
.form-section {
  margin-bottom: 28px;
}

.form-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title .num {
  background: var(--primary);
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

label .required { color: var(--danger); }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; min-height: 70px; }

input[type="date"] { cursor: pointer; }
input[readonly] { background: #f8fafc; color: var(--text-secondary); }

/* ========== 备件表格 ========== */
.parts-table { margin-top: 8px; }

.parts-table th { font-size: 12px; }

.parts-table input {
  padding: 6px 10px;
  font-size: 13px;
}

.part-row-total {
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  padding: 8px 14px;
}

.btn-remove-part {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
}

/* ========== 费用汇总 ========== */
.cost-summary {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.cost-row.total {
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* ========== 筛选栏 ========== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input, .filter-bar select {
  width: auto;
  min-width: 140px;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

/* 派单管理：「🔥 仅看紧急」筛选按钮激活态（红底白字，与紧急徽标一致） */
.filter-bar .btn.on-urgent-filter {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.filter-bar .btn.on-urgent-filter:hover { background: #b91c1c; }

/* 维修工程师「只看紧急」勾选框 */
.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
}
.filter-checkbox input { width: auto !important; min-width: 0 !important; margin: 0; }
.filter-checkbox:has(input:checked) { color: #dc2626; font-weight: 600; }


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

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ========== 模态框 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal h3 { font-size: 18px; margin-bottom: 12px; }
.modal p { color: var(--text-secondary); margin-bottom: 20px; }

/* ========== 结算报表 ========== */
.settlement-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.settlement-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px;
  text-align: center;
}

.settlement-card .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.settlement-card .value { font-size: 22px; font-weight: 700; }
.settlement-card .value.primary { color: var(--primary); }

/* ========== 打印样式 ========== */
.print-only { display: none; }

@media print {
  .sidebar, .page-header, .filter-bar, .no-print { display: none !important; }
  .main { margin-left: 0; padding: 0; }
  .print-only { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }

  .print-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #333;
  }
  .print-header h2 { font-size: 20px; margin-bottom: 6px; }
  .print-header p { font-size: 13px; color: #666; }

  .print-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 13px;
  }

  /* ===== 维修报告打印：只显示报告本身 ===== */
  body > *:not(#report-modal) { display: none !important; }
  #report-modal { display: block !important; position: static; background: #fff; padding: 0; }
  #report-modal .no-print { display: none !important; }
  .report-doc { box-shadow: none !important; border: none !important; margin: 0; max-width: 100%; }
}

/* ========== 维修报告弹窗 ========== */
#report-modal {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  overflow-y: auto;
  padding: 24px;
}
.report-toolbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: flex-end; gap: 8px;
  max-width: 800px; margin: 0 auto 16px;
  background: #fff; padding: 12px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.report-doc {
  background: #fff; max-width: 800px; margin: 0 auto;
  padding: 36px 40px; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  color: #1a1a1a; font-size: 13px; line-height: 1.6;
}
.report-doc .print-header { text-align: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid #333; }
.report-doc .print-header h2 { font-size: 22px; margin-bottom: 6px; }
.report-doc .print-header p { font-size: 12px; color: #666; }
.report-info { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.report-info th { text-align: left; background: #f5f6f8; width: 14%; padding: 8px 10px; border: 1px solid #e2e5ea; font-weight: 600; }
.report-info td { padding: 8px 10px; border: 1px solid #e2e5ea; }
.report-subtitle { font-size: 15px; margin: 22px 0 10px; padding-left: 8px; border-left: 4px solid var(--primary, #2563eb); }
.report-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.report-table th { background: #f5f6f8; padding: 8px 10px; border: 1px solid #e2e5ea; text-align: left; font-weight: 600; }
.report-table td { padding: 8px 10px; border: 1px solid #e2e5ea; vertical-align: top; }
.report-table tfoot td { background: #fafbfc; font-weight: 700; }
.report-test { border: 1px solid #e2e5ea; border-radius: 6px; padding: 12px 14px; min-height: 48px; background: #fcfcfd; }
.report-sign { display: flex; flex-wrap: wrap; gap: 24px 48px; margin-top: 36px; font-size: 13px; }
.report-sign span { display: inline-block; }

/* ========== 提示信息 ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ========== 图表 ========== */
.chart-bar-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 180px;
  padding: 12px 0;
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 50px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
  position: relative;
}

.chart-bar-label { font-size: 12px; color: var(--text-secondary); }
.chart-bar-value { font-size: 11px; color: var(--text); font-weight: 600; }

/* ========== 最近 3 个月「三格」区块（仪表盘：费用 / 工时共用） ========== */
.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.month-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.month-tile.is-current {
  border-color: var(--primary);
  background: var(--primary-light);
}
.month-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.month-tile-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.month-tile-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  word-break: break-all;
}
.month-tile-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0 6px;
}
.month-tile-bar > div { height: 100%; background: var(--primary); border-radius: 3px; }
.month-tile-sub { font-size: 12px; color: var(--text-secondary); }
.month-tile-detail { font-size: 12px; color: var(--text-light); margin-top: 6px; line-height: 1.6; }

/* ========== 响应式 — 手机端 ========== */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--sidebar-bg); color: #fff; z-index: 200;
  align-items: center; padding: 0 12px; gap: 10px;
}
.mobile-topbar .hamburger {
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.12); color: #fff; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.mobile-topbar .m-title { font-size: 14px; font-weight: 700; flex: 1; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  /* 顶栏始终盖在侧边栏之上，保证汉堡键可点关闭；顶部加安全区避开灵动岛/刘海 */
  .mobile-topbar {
    display: flex;
    z-index: 300;
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0;
  }
  .mobile-topbar .hamburger { width: 34px; height: 34px; font-size: 18px; }
  .mobile-topbar .m-title {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 15px;
  }

  /* 🔴 2026-10-28 手机「点了没反应」的两条硬防护：
     ① iOS Safari 对字号 <16px 的输入框，**聚焦时会自动把整页放大**，而且不会自己缩回来。
        放大之后用户手指点的位置和元素实际位置就错开了 —— 体感就是「点这儿没反应，
        要多点几次才行」，但点别的 App 又完全正常（不是手机问题）。
        → 移动端输入框/下拉/文本域统一切 16px（含备件表、筛选栏）。
     ② 可点元素加 touch-action: manipulation：去掉浏览器「等一秒看是不是双击缩放」的判定，
        手指一抬立刻派发 click，也避免轻微滑动被当成滚动而取消点击。 */
  input, select, textarea { font-size: 16px !important; }
  .btn, .nav-item, .brand-switch-btn, .filter-checkbox, .cell-link,
  .hamburger, .pw-toggle, .modal button, td button { touch-action: manipulation; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    width: 82%;
    max-width: 320px;
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    margin-left: 0 !important;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px) 12px 20px !important;
    max-width: 100vw !important;
  }

  /* 业务板块切换条：避开固定顶栏，吸顶在顶栏下方 */
  .brand-switch {
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    z-index: 60;
    margin: 0 -12px 16px;
    border-radius: 0;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand-switch-label { width: 100%; font-size: 13px; }
  .brand-switch-btn { padding: 7px 14px; font-size: 13px; }

  /* 表单网格单列 */
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; gap: 12px; }

  /* 统计卡片两列 */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 12px; }

  /* 最近 3 个月费用：保持三列并排便于对比，整体收紧 */
  .month-grid { gap: 8px; }
  .month-tile { padding: 10px 8px; }
  .month-tile-title { font-size: 12px; }
  .month-tile-value { font-size: 15px; }
  .month-tile-sub { font-size: 11px; }
  .month-tile-detail { font-size: 11px; margin-top: 4px; }
  .month-tile-bar { height: 5px; margin: 6px 0 5px; }

  /* 页面标题竖向排列，按钮占满宽度 */
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }
  .page-header .btn, .page-header > .flex { width: 100%; }
  .page-header .flex.gap-8 { flex-direction: column; }
  .page-header .flex.gap-8 .btn { width: 100%; }

  /* 筛选栏竖向排列，控件占满宽度 */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .search-input { width: 100% !important; min-width: 0 !important; flex: 1 1 auto; font-size: 16px; }
  .filter-bar .text-secondary { display: none; }

  .login-card { padding: 26px 18px; }
  .login-card h1 { font-size: 17px; }
  .login-card .subtitle { font-size: 12px; }
  .login-tab { font-size: 13px; padding: 11px; }

  .card-body { padding: 14px; }

  /* 整体正文略缩，手机上更紧凑（iPhone 16 宽 390pt，原 14px 偏松） */
  body { font-size: 13px; line-height: 1.5; }
  table { font-size: 12px; }
  th { font-size: 11px; padding: 10px 12px; }
  td { font-size: 12px; padding: 10px 12px; }
  label { font-size: 12px; }
  .form-section-title { font-size: 14px; margin-bottom: 10px; }
  .form-section-title .num { width: 20px; height: 20px; font-size: 11px; }
  .badge { font-size: 11px; padding: 2px 8px; }
  .alert { font-size: 12px; }
  .empty-state { padding: 40px 16px; }
  .empty-state .icon { font-size: 38px; }
  .empty-state p { font-size: 13px; }
  .cost-row { font-size: 13px; }
  .cost-row.total { font-size: 16px; }
  .settlement-card { padding: 14px; }
  .settlement-card .label { font-size: 12px; }
  .settlement-card .value { font-size: 18px; }
  .sidebar-header h1 { font-size: 15px; }
  .sidebar-header p { font-size: 11px; }
  .nav-icon { font-size: 16px; }

  /* 输入框字号 ≥16px，避免 iOS 聚焦时整页缩放 */
  input, select, textarea { font-size: 16px; }
  .parts-table input { font-size: 15px; }

  /* 增大点按区域，方便手指操作 */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 38px; padding: 6px 12px; font-size: 13px; }
  .nav-item { padding: 13px 14px; font-size: 14px; }
  .nav-badge { font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; }

  /* 弹窗在手机上可滚动、不被截断 */
  .modal-overlay { padding: 12px; align-items: flex-start; overflow-y: auto; }
  .modal {
    width: 100%;
    max-width: 100% !important;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 18px 14px;
    margin: auto 0;
  }
  .modal h3 { font-size: 16px; }
  .modal p { font-size: 12px; }
  .modal .flex.gap-8 { flex-direction: column; }
  .modal .flex.gap-8 .btn { width: 100%; }

  .voice-btn { padding: 12px 20px; font-size: 14px; }
  .tech-card { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tech-stats { gap: 10px; font-size: 11px; }
  .dash-grid, .csr-dash-grid { grid-template-columns: 1fr !important; }

  /* ===== 手机端：表格转卡片式，不再横向滚动 ===== */
  /* 仅卡片化后的表格取消横向滚动；可编辑的备件表仍保留横向滚动 */
  .table-wrap:has(table.mobile-cards) { overflow: visible; }
  table.mobile-cards,
  table.mobile-cards tbody,
  table.mobile-cards tr,
  table.mobile-cards td { display: block; width: 100%; }
  table.mobile-cards thead { display: none; }
  table.mobile-cards tr {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 4px 14px;
    box-shadow: var(--shadow);
  }
  table.mobile-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    font-size: 12px;
  }
  table.mobile-cards tr td:last-child { border-bottom: none; }
  table.mobile-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-secondary);
    text-align: left;
    flex: 0 0 auto;
    margin-right: 12px;
    font-size: 11px;
  }
  table.mobile-cards td .cell-link { font-weight: 600; font-size: 13px; }
  table.mobile-cards td .badge { font-size: 11px; }
  /* 卡片模式下 td 变成块级 flex，桌面的备注列宽度下限会撑破手机卡片 → 这里释放 */
  table.mobile-cards .td-notes { width: 100%; min-width: 0; max-width: none; }
}

/* ========== 更细的手机优化（iPhone 16 系列 390~430pt） ========== */
@media (max-width: 480px) {
  .main { padding-left: 10px; padding-right: 10px; }
  .brand-switch { padding: 8px 10px; gap: 6px; }
  .brand-switch-btn { padding: 6px 12px; font-size: 12px; }
  .page-title { font-size: 17px; }
  .stat-value { font-size: 19px; }
  .stat-card { padding: 10px; }
  .card-body { padding: 12px; }
  .modal { padding: 16px 12px; }
  .btn { padding: 10px 14px; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .search-input { font-size: 16px; }
  table.mobile-cards td { font-size: 12px; padding: 9px 2px; }
  table.mobile-cards td::before { font-size: 11px; }
  .form-section-title { font-size: 13px; }
  /* 最近 3 个月费用：iPhone 16 全系再收紧一档 */
  .month-grid { gap: 6px; }
  .month-tile { padding: 9px 7px; }
  .month-tile-value { font-size: 14px; }
  .month-tile-detail { font-size: 10px; line-height: 1.5; }
  .month-tile-title { font-size: 11px; }
  /* 重复记录提示：小屏收紧，不挤压表格 */
  .dup-banner { padding: 8px 10px; font-size: 12px; margin-bottom: 12px; }
  .dup-badge { font-size: 10px; padding: 1px 5px; margin-right: 4px; }
}

/* ========== 登录界面 ========== */
.login-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
  display: flex; align-items: center; justify-content: center; z-index: 300;
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 36px 32px;
  max-width: 400px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; color: var(--text); }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 13px; }
.login-tabs {
  display: flex; gap: 0; margin-bottom: 24px; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--border);
}
.login-tab {
  flex: 1; padding: 12px; border: none; background: var(--bg);
  font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.15s;
  color: var(--text-secondary); font-family: inherit;
}
.login-tab.active { background: var(--primary); color: #fff; }
.login-field { text-align: left; margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.login-field input {
  width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; transition: border 0.15s;
}
.login-field input:focus { outline: none; border-color: var(--primary); }
.login-error {
  color: var(--danger); font-size: 13px; margin-bottom: 12px; display: none;
}
.login-error.show { display: block; }

/* ===== 密码框「显示/隐藏」小眼睛（2026-10-05）=====
   用在登录页与「修改我的密码」弹窗：把密码框包进 .pw-wrap，右侧放一个 .pw-toggle 按钮。
   只切换 input 的 type，不参与任何密码校验，因此对业务逻辑零影响。 */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input { padding-right: 46px; }        /* 给右侧按钮留位，避免文字被盖 */
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px;
  color: var(--text-secondary); cursor: pointer; transition: color .15s, background .15s;
}
.pw-toggle:hover { color: var(--text); background: rgba(15, 23, 42, 0.06); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pw-toggle svg { width: 19px; height: 19px; display: block; pointer-events: none; }
.pw-toggle .pw-eye-off { display: none; }                 /* 默认隐藏「划线眼睛」 */
.pw-toggle.revealed .pw-eye-on { display: none; }         /* 已显示密码时换成「划线眼睛」 */
.pw-toggle.revealed .pw-eye-off { display: block; }

/* ========== 扫码弹窗 ========== */
.scan-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 400;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.scan-modal.show { display: flex; }
.scan-modal-content {
  background: #fff; border-radius: 16px; padding: 20px;
  max-width: 480px; width: 100%; text-align: center;
}
.scan-modal-content h3 { font-size: 16px; margin-bottom: 8px; }
.scan-modal-content p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
#scan-reader { width: 100%; border-radius: 12px; overflow: hidden; }
.scan-result {
  margin-top: 12px; padding: 12px; background: #ecfdf5; border-radius: 8px;
  border: 1px solid #6ee7b7; font-size: 16px; font-weight: 700; display: none;
}
.scan-result.show { display: block; }
.scan-loading { font-size: 14px; color: var(--text-secondary); padding: 20px; }

/* ========== 维修项目卡片 ========== */
.repair-item {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 12px; position: relative;
}
.repair-item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.repair-item-title {
  font-weight: 700; font-size: 14px; color: var(--primary);
}
.repair-item .form-grid { margin-top: 0; }
.repair-item textarea { font-size: 13px; }

/* ========== 工具样式 ========== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.mono { font-family: "SF Mono", "Fira Code", monospace; }
/* 账号管理：角色筛选标签页 */
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tabs .tab { padding: 6px 14px; border: 1px solid var(--border, #e5e7eb); background: #fff; color: #374151; border-radius: 999px; cursor: pointer; font-size: 13px; transition: all .15s; }
.filter-tabs .tab:hover { border-color: var(--primary, #2563eb); color: var(--primary, #2563eb); }
.filter-tabs .tab.active { background: var(--primary, #2563eb); border-color: var(--primary, #2563eb); color: #fff; font-weight: 600; }
/* 列表里可点击查看详情的单元格（工单号 / SN码） */
.cell-link { cursor: pointer; color: #2563eb; text-decoration: underline; text-underline-offset: 2px; }
.cell-link:hover { color: #1d4ed8; }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.nav-group { }

/* ========== 语音录入 ========== */
.voice-section {
  background: #f0f9ff; border: 2px dashed #93c5fd; border-radius: 12px;
  padding: 20px; margin-bottom: 20px; text-align: center;
}
.voice-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 28px; border: none; border-radius: 30px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.voice-btn:hover { background: var(--primary-dark); }
.voice-btn.recording { background: var(--danger); animation: pulse 1.5s infinite; }
.ri-voice-btn.recording { background: var(--danger) !important; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }
.voice-status { margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
.voice-transcript {
  margin-top: 12px; padding: 12px; background: #fff; border-radius: 8px;
  border: 1px solid var(--border); font-size: 14px; text-align: left;
  min-height: 40px; max-height: 120px; overflow-y: auto; display: none;
}
.voice-transcript.show { display: block; }
.voice-parsed {
  margin-top: 8px; padding: 12px; background: #ecfdf5; border-radius: 8px;
  border: 1px solid #6ee7b7; font-size: 13px; text-align: left; display: none;
}
.voice-parsed.show { display: block; }
.voice-parsed .item { margin-bottom: 4px; }

/* ========== 维修工程师卡片 ========== */
.tech-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 16px; transition: box-shadow 0.15s;
}
.tech-card:hover { box-shadow: var(--shadow-lg); }
.tech-info { display: flex; align-items: center; gap: 12px; }
.tech-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.tech-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.tech-stats span { font-weight: 600; color: var(--text); }

/* ========== 运单附件 ========== */
.att-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; color: var(--text);
}
.att-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.att-link:hover { text-decoration: underline; }
.att-remove {
  margin-left: 8px; color: #b91c1c; cursor: pointer; font-size: 12px;
  border-left: 1px solid var(--border); padding-left: 8px;
}
.att-remove:hover { text-decoration: underline; }
#dispatch-waybill-group input[type=file],
#case-waybill { display: block; margin-top: 6px; }

/* ========== 品牌方仪表盘：各状态工单数饼图 ========== */
.pie-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.pie-svg { width: 200px; height: 200px; flex: 0 0 auto; }
.pie-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 8px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pie-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.pie-legend-label { flex: 1; color: var(--text); }
.pie-legend-count { font-weight: 600; min-width: 28px; text-align: right; color: var(--text); }
.pie-legend-pct { color: var(--text-light); min-width: 38px; text-align: right; }
.pie-center-num { font-size: 32px; font-weight: 700; fill: var(--text); }
.pie-center-cap { font-size: 12px; fill: var(--text-light); }

@media (max-width: 768px) {
  .pie-wrap { gap: 16px; }
  .pie-svg { width: 150px; height: 150px; }
  .pie-legend { min-width: 120px; gap: 6px; }
  .pie-legend-item { font-size: 12px; }
  .pie-center-num { font-size: 26px; }
}

/* ========== 本机数据收敛（换账号后自动收拾本机数据）提示条 ========== */
.scope-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  color: #1e40af;
  font-size: 13px;
  line-height: 1.65;
}
.scope-notice-close {
  flex: 0 0 auto;
  border: 1px solid #93c5fd;
  background: #fff;
  color: #1d4ed8;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.scope-notice-close:hover { background: #dbeafe; }
@media (max-width: 768px) {
  .scope-notice { flex-direction: column; gap: 8px; font-size: 12px; }
}

/* ========== 派单管理：操作列按钮横排一行、文字不折行（2026-09-30 用户要求） ========== */
.td-actions { white-space: nowrap; }
.td-actions .flex { flex-wrap: nowrap; }
.td-actions .btn { white-space: nowrap; }

/* 技师「我的工单」：所有信息单行显示（不折行），列多放不下时靠 .table-wrap 左右滑动查看 */
.table-nowrap th,
.table-nowrap td { white-space: nowrap; }
/* 例外——维修指示列：单行 nowrap 截断时文字会与相邻列的徽章互相遮挡（徽章被挤溢出盖字），
   改为允许折行：最多 3 行 + 省略号，全文仍可悬浮/长按 title 查看 */
.table-nowrap .td-instructions { white-space: normal; }
/* 备注列在单行 nowrap 表格里同样允许折行，避免长备注把相邻列挤变形 */
.table-nowrap .td-notes { white-space: normal; }
.table-nowrap .td-instructions .cell-truncate {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  max-width: 100%;
  overflow: hidden;
  white-space: normal;
}
/* 单元格内行内小提示（如 SN 后面的「↩ 转自」「👷 归属」）：跟随同一行，不换行 */
.cell-sub { font-size: 11px; margin-left: 6px; white-space: nowrap; }

/* ========== 技师「记录工作」：这台机器（该 SN）的工单候选区（2026-09-30） ==========
   系统定位工单只认「工单号」；输入 SN 后把该 SN 的所有工单列在这里由技师点选。
   不点选＝保存时新建一张。同一台机器可以有多张工单（不同时间、不同问题）。 */
.case-cand {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.case-cand.is-bound {
  border-style: solid;
  border-color: #86efac;
  background: #f0fdf4;
}
.case-cand-hd {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.5;
}
.case-cand-sub {
  font-size: 12px;
  color: #64748b;
  line-height: 1.55;
  margin-top: 3px;
  word-break: break-word;
}
.case-cand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}
.case-cand-main { flex: 1; min-width: 0; font-size: 13px; }
.case-cand-row .btn { flex-shrink: 0; }
@media (max-width: 768px) {
  .case-cand-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .case-cand-row .btn { width: 100%; }
}

/* ===== 表单校验错误提示（2026-10-02）=====
   背景：原来只有 alert()，浏览器一旦「阻止此页面创建更多对话框」（或被内嵌浏览器屏蔽），
   用户点「派单」就会毫无反应、也不知道差哪个字段。这里补一个页面内的红条 + 字段红框，
   保证任何校验失败都看得见。 */
.form-error-bar {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.form-error-bar .form-error-title { font-weight: 700; }
.field-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

/* ===== 工单问题标记 / 品牌方 ↔ 工程师沟通（2026-11-10） =====
   整行标红必须压过 tbody tr:hover、#records-body tr.active-row td 等后写规则 → 用 !important。
   第三轮：入口从「工单号」格移到「操作」列，做成与编辑/查看同款小按钮；
   工单号列不再被长描述撑宽，描述改放按钮 title（悬停）与沟通弹窗。 */
tr.row-issue, tr.row-issue td { background: #fee2e2 !important; }
tr.row-issue:hover, tr.row-issue:hover td { background: #fecaca !important; }
tr.row-issue td:first-child { border-left: 4px solid #dc2626 !important; }

/* 操作列里的问题按钮：短文字 + nowrap，不把表格撑宽 */
.issue-btn {
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}
.issue-btn-active {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #dc2626;
  font-weight: 700;
}
.issue-btn-active:hover { background: #dc2626; color: #fff; }

.issue-status {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  border-left: 4px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
}
.issue-status.is-active { background: #fee2e2; color: #991b1b; border-left-color: #dc2626; }
.issue-status.is-resolved { background: #dcfce7; color: #166534; border-left-color: #16a34a; }

/* 沟通窗里的「工单状态」下拉（2026-11-13）：三角色可改，改状态即取消红标 */
.issue-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.issue-status-row label { font-size: 12px; font-weight: 700; color: #475569; white-space: nowrap; }
.issue-status-row select.form-control {
  width: auto;
  min-width: 150px;
  max-width: 220px;
  padding: 5px 8px;
  font-size: 13px;
}
.issue-status-row-note { font-size: 11px; color: #64748b; }

.issue-thread {
  flex: 1 1 auto;
  min-height: 130px;
  max-height: 46vh;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
}
.issue-thread.detail { max-height: 220px; min-height: 0; }
.issue-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 18px 0; }
.issue-msg { display: flex; flex-direction: column; margin-bottom: 12px; align-items: flex-start; }
.issue-msg.from-tech { align-items: flex-end; }
.issue-msg-meta { font-size: 11px; color: #94a3b8; margin: 0 4px 4px; }
.issue-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  background: #fff;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}
.issue-msg.from-tech .issue-bubble { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }

@media (max-width: 768px) {
  .issue-btn { padding: 3px 7px; font-size: 11px; }
  .issue-thread { max-height: 38vh; }
  .issue-status-row { gap: 6px; padding: 7px 8px; }
  .issue-status-row select.form-control { min-width: 125px; }
  .issue-status-row-note { flex-basis: 100%; }
}
