:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --shadow: 0 6px 20px rgba(15, 23, 42, .07);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: rgba(255, 255, 255, .18);
  border-radius: 12px;
}

.brand h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; font-size: 12px; opacity: .8; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- 顶栏内的当前员工标识 ---------- */

.topbar-employee {
  display: flex;
  align-items: center;
  cursor: default;
}
.te-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 700;
  border: 2px solid;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .45);
}

/* ---------- 操作按钮组 ---------- */

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.btn-purple { background: #7c3aed; color: #fff; }
.btn-purple:hover { background: #6d28d9; transform: translateY(-1px); }
.btn-outline-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-outline-danger:hover { background: var(--red-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-mini-gray { background: #6b7280; color: #fff; margin-left: 4px; }
.btn-mini-gray:hover { background: #4b5563; }

/* ---------- 通用面板 ---------- */

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title h2 { margin: 0; font-size: 18px; }

.section-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 18px;
}
.notice-icon { background: var(--amber-soft); }
.repair-icon { background: var(--primary-soft); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.hint { font-size: 12px; color: var(--muted); }

/* ---------- 按钮 ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }

.btn-outline { background: #fff; color: var(--primary); border-color: #bfdbfe; }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }

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

.btn-mini { padding: 3px 10px; font-size: 12px; background: var(--amber); color: #fff; }
.btn-mini:hover { background: #b45309; }

.btn-link { background: none; color: var(--primary); padding: 6px 8px; }
.btn-link:hover { text-decoration: underline; }

.btn-toggle-hidden { font-size: 12px; padding: 6px 4px; color: var(--muted); white-space: nowrap; }
.btn-toggle-hidden:hover { color: var(--primary); }

.topbar .btn-outline.btn-sm { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .4); }
.topbar .btn-outline.btn-sm:hover { background: rgba(255, 255, 255, .22); }

/* ---------- 重要通知 ---------- */

.notice-compose { margin-bottom: 18px; }

.notice-compose textarea,
.field textarea,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.notice-compose textarea { min-height: 68px; resize: vertical; }
.notice-compose textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.check-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.check-label input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.message-list { display: flex; flex-direction: column; gap: 10px; }

.message-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  background: #fff;
}
.message-item.pending { border-left-color: var(--amber); background: #fffdf7; }

.message-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.message-author { font-weight: 700; color: var(--primary-dark); font-size: 14px; }
.message-time { font-size: 12px; color: var(--muted); }
.message-content { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.badge-pending { background: var(--amber-soft); color: #92400e; }
.badge-handled { background: var(--green-soft); color: #15803d; }
.badge-hidden { background: #f3f4f6; color: #6b7280; }

.message-item.hidden-msg {
  opacity: .72;
  border-left-color: #9ca3af;
  background: #f9fafb;
  border-style: dashed;
}
.message-item.hidden-msg .message-content { text-decoration: line-through; color: #6b7280; }

.notice-footer { text-align: center; margin-top: 12px; }

.empty-hint {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 26px 12px;
  background: #f9fafb;
  border-radius: 10px;
  margin-top: 6px;
}
.empty-hint.show { display: block; }

/* ---------- 维修记录 ---------- */

.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar:empty { display: none; }
.filter-label { font-size: 13px; color: var(--muted); }

.filter-chip {
  border: 1px solid #bfdbfe;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.filter-chip:hover { background: #dbeafe; }
.filter-chip span { margin-left: 5px; font-weight: 700; }

.table-wrap { overflow-x: auto; }

.record-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.record-table th {
  text-align: left;
  padding: 11px 12px;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.record-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.record-table tbody tr:hover { background: #f8fbff; }
.record-table tbody tr:nth-child(even) { background: #fcfdff; }
.record-table tbody tr:nth-child(even):hover { background: #f8fbff; }

.filter-link {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  transition: filter .15s ease, transform .15s ease;
}
.filter-link:hover { filter: brightness(.94); transform: translateY(-1px); }

/* 机器编号：中性灰蓝 */
.opt-machine { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* 选项配色表（同一颜色可用于内容/过程/员工，靠具体值区分） */
.opt-blue   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.opt-cyan   { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.opt-purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.opt-indigo { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.opt-gray   { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }
.opt-green  { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.opt-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.opt-red    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.opt-rose   { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.opt-gold   { background: #fffbeb; color: #b45309; border-color: #fde68a; }

.note-cell { color: #4b5563; max-width: 280px; word-break: break-word; }
.time-cell { color: var(--muted); font-size: 13px; white-space: nowrap; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.page-info { font-size: 14px; color: var(--muted); min-width: 110px; text-align: center; }

/* ---------- 弹窗 ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  animation: pop .2s ease;
}

@keyframes pop {
  from { transform: scale(.96) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head .hint { margin: 4px 0 0; }

.modal-close {
  border: none;
  background: #f1f5f9;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { background: #e2e8f0; }

/* 员工选择网格 */
.employee-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.employee-card {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 16px 8px;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}
.employee-card:hover { border-color: #93c5fd; background: var(--primary-soft); transform: translateY(-2px); }
.employee-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.employee-no {
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.employee-name { font-size: 15px; font-weight: 600; }

.modal-foot-hint { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field textarea { resize: vertical; min-height: 72px; }

.tip-box {
  background: var(--amber-soft);
  color: #92400e;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.6;
}
.tip-box b { color: #b45309; }
.danger-tip { background: var(--red-soft); color: #991b1b; border: 1px solid #fecaca; }
.danger-tip b { color: #b91c1c; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.inline-msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.inline-msg.error { color: var(--red); }
.inline-msg.success { color: var(--green); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
  .app { padding: 14px 12px 40px; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 16px; }
  .panel { padding: 16px; }
  .employee-grid { grid-template-columns: repeat(2, 1fr); }
  .compose-actions { flex-direction: column; align-items: stretch; }
  .compose-actions .btn { width: 100%; }
}
