:root {
  --bg0: #eef6fb;
  --bg1: #f5faff;
  --primary: #1e88e5;
  --cyan: #00acc1;
  --silver: #b0bec5;
  --line: rgba(30, 60, 100, .12);
  --glass: rgba(255, 255, 255, .78);
  --glass-strong: rgba(255, 255, 255, .92);
  --text: #1a2b4a;
  --muted: #5a7399;
  --danger: #e53935;
  --ok: #2e7d32;
  --shadow: 0 10px 40px rgba(30, 60, 100, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hirino Sans GB", sans-serif;
  color: var(--text); line-height: 1.5;
  background: #f4f7fb;
  min-height: 100vh;
  overflow-x: hidden;
}

.wrap { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }

/* 视觉标识：高铁实拍图 banner */
.hero { display: block; position: relative; margin: 4px 0 16px; border-radius: 14px; overflow: hidden; }
.train-hero {
  width: 100%; height: 200px;
  background: url('/hazmat_train.png') center 42% / cover no-repeat, linear-gradient(135deg, #cfe4f5, #aacbe6);
  background-color: #bcd6ea;
}
.hero-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(15,40,70,0) 40%, rgba(15,40,70,.55) 100%);
}
.hero-title { color: #fff; font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.hero-sub { color: rgba(255,255,255,.88); font-size: 12px; margin-top: 4px; letter-spacing: .5px; }
.emblem.sm { width: 72px; margin-bottom: 10px; }
.emblem.xs { width: 40px; height: 22px; }

/* 产线只读标签（用户无需选择） */
.line-chip {
  flex: 1; min-width: 0; font-size: 16px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; padding: 13px 2px;
}
.line-chip::before { content: "🚄"; margin-right: 8px; font-size: 18px; }

/* 扫码填写二维码 */
.qr-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.qr-info { flex: 1; min-width: 220px; }
.qr-tip { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.6; }
.qr-url { font-size: 12.5px; color: var(--primary); word-break: break-all; background: rgba(30,136,229,.07);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr-box img { width: 200px; height: 200px; border-radius: 12px; background: #fff; border: 1px solid var(--line); padding: 6px; box-shadow: var(--shadow); }
.qr-cap { font-size: 12px; color: var(--muted); letter-spacing: 2px; }

/* 卡片 */
.card { margin-top: 14px; padding: 18px; border-radius: 12px; }
.glass { background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(20,40,80,.06); }

/* 字段 */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,136,229,.12); }
.ico { flex: 0 0 22px; width: 22px; height: 22px; color: var(--primary); display: inline-flex; }
.ico svg { width: 100%; height: 100%; fill: currentColor; }
.field input, .field select {
  flex: 1; min-width: 0; width: 100%; border: none; background: transparent; outline: none;
  color: var(--text); font-size: 16px; padding: 13px 2px;
}
.field input::placeholder { color: var(--muted); }
.field select { color: var(--text); }
.field select option { color: #111; }
.field select:disabled { opacity: .55; cursor: not-allowed; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary);
  color: #fff; border: none; border-radius: 10px; padding: 13px 16px;
  font-size: 16px; font-weight: 700; cursor: pointer; width: 100%;
  transition: background .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active { background: #1565c0; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3f8fd; }
.btn.sm { padding: 9px 14px; font-size: 14px; width: auto; }
.btn.danger { color: var(--danger); border-color: rgba(229,57,53,.25); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* 结果卡片 */
.result-card { border: 1px solid rgba(30,136,229,.35); background: #f7fbff; }
.code-big {
  font-size: 42px; font-weight: 900; letter-spacing: 3px; text-align: center; margin: 6px 0 2px;
  color: var(--primary); text-shadow: 0 0 18px rgba(30,136,229,.25); word-break: break-all;
}
.code-sub { font-size: 12px; color: var(--muted); text-align: center; letter-spacing: 2px; }
.result-actions { display: flex; gap: 10px; }
.result-actions .btn { flex: 1; }

/* 后台 */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 14px; }
.line-switch { display: flex; align-items: center; gap: 10px; }
.line-sel {
  background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 15px; color: var(--text); outline: none;
}
.line-sel:focus { border-color: var(--primary); }
.admin-link { color: var(--primary); font-size: 13px; text-decoration: none; border: 1px solid var(--line); padding: 7px 14px; border-radius: 10px; background: rgba(255,255,255,.72); }
.corner-admin { position: fixed; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan)); box-shadow: 0 6px 20px rgba(30,136,229,.25); }
.card-h { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; padding-left: 10px; border-left: 3px solid var(--primary); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* 主数据 */
.master-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.master-col { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(255,255,255,.55); }
.master-title { font-weight: 700; margin-bottom: 8px; color: var(--primary); }
.master-add { display: flex; gap: 6px; margin-bottom: 8px; }
.master-add input { flex: 1; min-width: 0; padding: 9px 10px; font-size: 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.master-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.master-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.master-list li:last-child { border-bottom: none; }
.linkbtn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 14px; padding: 6px; }
.badge { font-size: 11px; color: var(--muted); background: rgba(30,136,229,.1); padding: 2px 6px; border-radius: 6px; }

/* 导入 */
.upload-wrap {
  border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center;
  background: rgba(255,255,255,.5); transition: border-color .2s, background .2s; position: relative;
}
.upload-wrap.drag { border-color: var(--primary); background: rgba(30,136,229,.06); }
.upload-wrap input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload-hint { font-size: 15px; color: var(--text); font-weight: 600; }
.upload-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 三类分开导入 */
.imp-block { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); margin-bottom: 12px; }
.imp-block:last-child { margin-bottom: 0; }
.imp-title { font-weight: 700; color: var(--primary); margin-bottom: 6px; font-size: 14px; }
.imp-block .upload-wrap { padding: 16px; }

/* 危险区 */
.danger-zone { border-color: rgba(229,57,53,.2); background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,235,238,.5)); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td { color: var(--text); }
.rc { font-weight: 700; color: var(--primary); }
/* 后台记录表：加宽容器 + 固定布局 + 自动换行，桌面 9 列完整显示，不出现横向滚动条 */
.wrap.admin { max-width: 1180px; }
#tbl { table-layout: fixed; }
#tbl th, #tbl td { white-space: normal; word-break: break-word; }
#tbl td:last-child { white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.pager span { font-size: 13px; color: var(--muted); }

/* 窄屏：记录表格转为卡片式，彻底避免横向滚动，每条记录完整呈现 */
@media (max-width: 760px) {
  .table-wrap { overflow-x: visible; }
  #tbl, #tbl thead, #tbl tbody, #tbl tr, #tbl td { display: block; width: 100%; }
  #tbl thead { display: none; }
  #tbl tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 4px 2px; background: #fff; }
  #tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px dashed var(--line); }
  #tbl td:last-child { border-bottom: none; }
  #tbl td::before { content: attr(data-label); font-weight: 700; color: var(--muted); flex: 0 0 auto; margin-right: 8px; text-align: left; }
  #tbl td:last-child { justify-content: flex-start; gap: 16px; }
}

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(20,40,80,.35); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 400px; animation: pop .2s ease; box-shadow: 0 8px 30px rgba(20,40,80,.18); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .card-h { margin-bottom: 14px; }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 登录 */
#loginCard { max-width: 380px; margin: 18vh auto 0; text-align: center; }
#loginForm { display: flex; flex-direction: column; gap: 12px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(26,43,74,.95); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; border: 1px solid var(--line); opacity: 0; transition: opacity .25s; z-index: 99; max-width: 90%; }
.toast.show { opacity: .98; }
.toast.err { border-color: var(--danger); color: #ffcdd2; }

@media (max-width: 480px) {
  .row2 { grid-template-columns: 1fr; }
  .master-grid { grid-template-columns: 1fr; }
  .code-big { font-size: 34px; }
  .line-switch { gap: 6px; }
}
