:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.bar { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; }
.brand { font-weight: 700; font-size: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 6px; }
.nav a {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}
.nav a:hover { background: #f8fafc; color: var(--ink); text-decoration: none; }

main.wrap { padding-top: 22px; padding-bottom: 40px; flex: 1; }
.foot { text-align: center; color: #94a3b8; font-size: 12px; padding: 18px; }

/* ---------- 通用 ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; letter-spacing: .3px; }
.nowrap { white-space: nowrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { margin: 0; font-size: 20px; }
.card h3 { margin: 0 0 14px; font-size: 16px; }

.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.page-head h1, .hero h1 { margin: 0; }
.page-head h1 { font-size: 22px; }
.export-btn { margin-left: auto; align-self: center; }

.req { color: var(--danger); font-weight: 400; }

.device-preview {
  margin: -6px 0 16px;
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px dashed #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
}

.hero { max-width: 720px; margin: 8px auto 22px; }
.hero h1 { font-size: 24px; margin-bottom: 6px; }
.hero p { margin: 0; color: var(--muted); }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field > span i { color: var(--danger); font-style: normal; }
.field > span em { color: var(--muted); font-style: normal; font-weight: 400; }

input[type=text], input[type=tel], input[type=search], input[type=file],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 60px; }
input[type=file] { padding: 8px; background: #f8fafc; }
select { cursor: pointer; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border-color: #cbd5e1; color: var(--muted); }
.btn.ghost:hover { background: #f8fafc; color: var(--ink); }
.btn.block { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.btn.xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

.tip { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 0; }
.form-card { max-width: 720px; margin-left: auto; margin-right: auto; }

/* ---------- 提示条 ---------- */
.flashes { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  border: 1px solid;
}
.flash.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash.big { font-size: 15px; padding: 16px; }

/* ---------- 统计 ---------- */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1 1 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
}
.stat:hover { text-decoration: none; border-color: #cbd5e1; }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, .12); }
.stat b { font-size: 22px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12px; }
.c-pending { color: var(--warn); }
.c-doing { color: var(--primary); }
.c-done { color: var(--ok); }
.c-canceled { color: #94a3b8; }

/* ---------- 筛选 ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 130px; }
.filters input[type=search] { flex: 1; min-width: 200px; }

.operator-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.operator-bar label { color: var(--muted); }
.operator-bar input { width: 180px; padding: 6px 10px; }
.operator-bar .hint { color: #94a3b8; font-size: 12px; }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.big { font-size: 13px; padding: 4px 14px; }
.badge.pending { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge.doing { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge.done { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge.canceled { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.tbl { width: 100%; border-collapse: collapse; min-width: 940px; font-size: 14px; }
.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafcff; }
.tbl .desc { min-width: 200px; max-width: 280px; }
.tbl .loc { white-space: nowrap; }
.tbl .cat { white-space: nowrap; }
.tbl .device { min-width: 150px; }
.tbl .person { white-space: nowrap; }
.tbl.wide { min-width: 1120px; }
.result-box { margin-top: 14px; border-left: 3px solid var(--ok); }
.tbl .code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; white-space: nowrap; }
.col-ops { min-width: 150px; }
td.ops { white-space: nowrap; }
td.ops form { display: inline-block; margin: 0 4px 4px 0; }
td.ops .btn.xs { display: inline-block; }

.empty {
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 50px 20px;
}

/* ---------- 详情页 ---------- */
.detail-head { margin-bottom: 12px; }
.back { font-size: 14px; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 24px;
  margin: 0 0 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.info div { min-width: 0; }
.info dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.info dd { margin: 0; word-break: break-word; }

.desc-box { background: #f8fafc; border-radius: 10px; padding: 14px 16px; }
.desc-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.desc-box p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.shot {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin-top: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* ---------- 时间线 ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 20px 24px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: -4px;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute;
  left: 0;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.tl-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-top b { font-size: 14px; }
.tl-note {
  margin-top: 8px;
  background: #f8fafc;
  border-left: 3px solid var(--line);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.op-form { max-width: 620px; }

/* ---------- 我的工单 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex;
  flex-direction: column;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
  background: #f8fafc;
}
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip small { font-family: inherit; color: var(--muted); font-size: 11px; }

.empty-page { text-align: center; padding: 56px 20px; }
.empty-page h1 { font-size: 44px; margin: 0 0 8px; color: var(--primary); }

/* ---------- 平板 / 手机：表格变卡片 ---------- */
@media (max-width: 760px) {
  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  .tbl { display: block; min-width: 0; }
  .tbl thead { display: none; }
  .tbl tbody { display: block; }
  .tbl tr {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 12px;
  }
  .tbl td {
    display: block;
    position: relative;
    border: 0;
    padding: 4px 0 4px 68px;
    word-break: break-word;
  }
  .tbl td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 4px;
    width: 60px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
  }
  .tbl td.desc { min-width: 0; max-width: none; }
  .tbl.wide { min-width: 0; }
  .tbl td.code-cell .code { font-size: 14px; }
  .tbl td.ops { padding: 10px 0 0; }
  .tbl td.ops::before { display: none; }
  .tbl td.ops form { margin: 0 8px 6px 0; }
  .tbl td.ops .btn.xs { padding: 7px 14px; font-size: 13px; }
}

/* ---------- 二维码卡片 ---------- */
.qr-card { max-width: 720px; margin-left: auto; margin-right: auto; }
.qr-flex { display: flex; gap: 22px; align-items: center; }
.qr-img {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: #fff;
}
.qr-text p { margin: 0 0 10px; }
.qr-text p:last-child { margin-bottom: 0; }
.qr-url {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  word-break: break-all;
}

/* ---------- 小屏 ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .hero h1 { font-size: 20px; }
  .stats { gap: 8px; }
  .stat { flex: 1 1 calc(50% - 8px); padding: 10px 12px; }
  .stat b { font-size: 18px; }
  .bar { height: 52px; }
  .brand span { display: none; }
  .filters {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .filters select { grid-column: 1; grid-row: 1; width: 100%; }
  .filters input[type=search] { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .filters .btn { grid-column: 2; grid-row: 1; }
  .filters a.btn { grid-column: 1 / -1; grid-row: 3; }
  .qr-flex { flex-direction: column; align-items: flex-start; }
  .qr-url { font-size: 14px; }
}
