:root {
  --primary: #1f6feb;
  --primary-dark: #1857b6;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e2e6ee;
  --text: #1f2329;
  --text-muted: #6b7280;
  --danger: #d92c2c;
  --success: #1a7f37;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f6feb 0%, #3b82f6 45%, #7fb0ff 100%); }
.login-card { background: var(--card); border-radius: 16px; padding: 40px 36px; width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border .15s; }
.field input:focus { border-color: var(--primary); }
.login-card .btn { width: 100%; margin-top: 6px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: center; }
.hint { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* ---------- 主布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #16213b; color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .logo { padding: 22px 20px; font-size: 17px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); line-height: 1.4; }
.sidebar .logo small { display: block; font-size: 11px; font-weight: 400; color: rgba(255,255,255,.55); margin-top: 4px; }
.nav { flex: 1; padding: 12px 0; }
.nav-item { padding: 12px 20px; cursor: pointer; font-size: 14px; color: rgba(255,255,255,.8); border-left: 3px solid transparent; transition: background .15s; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: rgba(255,255,255,.1); border-left-color: #4f9bff; color: #fff; font-weight: 600; }
.sidebar .me { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: rgba(255,255,255,.7); }
.sidebar .me b { display: block; color: #fff; margin-bottom: 6px; font-size: 14px; }
.link-btn { background: none; border: none; color: #9fc3ff; cursor: pointer; font-size: 12px; margin-right: 10px; text-decoration: underline; }
.link-btn.danger { color: #ff9d9d; }

.main { flex: 1; padding: 24px 30px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 20px; }

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=text], .toolbar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar .search { flex: 1; min-width: 220px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-size: 14px; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e8ecf3; color: var(--text); }
.btn.secondary:hover { background: #dce1ea; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 文件表格 ---------- */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 12px 14px; background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.gauge { background: #e0ecff; color: #1f6feb; }
.badge.plate { background: #fbe6ff; color: #a020f0; }
.file-cell { display: flex; align-items: center; gap: 8px; }
.file-icon { width: 34px; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.file-icon.img { background: linear-gradient(135deg,#34a853,#52c41a); }
.file-icon.pdf { background: linear-gradient(135deg,#e02020,#ff5c5c); }
.file-icon.doc { background: linear-gradient(135deg,#1f6feb,#42a5f5); }
.file-icon.other { background: linear-gradient(135deg,#6b7280,#9ca3af); }
.file-name { font-weight: 600; }
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.row-actions { display: flex; gap: 6px; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.pagination .btn { padding: 5px 12px; }

/* ---------- 空状态 ---------- */
.empty { padding: 50px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 14px; width: 520px; max-width: 94vw; max-height: 90vh; overflow: auto; padding: 24px 26px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; min-height: 70px; font-family: inherit; resize: vertical; }
.modal .field textarea:focus { border-color: var(--primary); }
.modal .row { display: flex; gap: 12px; }
.modal .row .field { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal .dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 26px; text-align: center; color: var(--text-muted); font-size: 13px; cursor: pointer; transition: border .15s, background .15s; margin-bottom: 14px; }
.modal .dropzone:hover, .modal .dropzone.drag { border-color: var(--primary); background: #f0f6ff; }
.modal .dropzone .sel { color: var(--primary); text-decoration: underline; }
.file-to-upload { display: flex; align-items: center; justify-content: space-between; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.file-to-upload .sz { color: var(--text-muted); font-size: 12px; }

/* ---------- 预览 ---------- */
.preview-modal { display: flex; flex-direction: column; }
.preview-modal h3 { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.preview-modal .modal-actions { flex-shrink: 0; margin-top: 14px; }
.preview-body { flex: 1; min-height: 60vh; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.preview-img { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; background: #f0f0f0; }
.preview-pdf-wrap { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.preview-pdf { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.preview-actions { float: right; }
/* 全屏大图查看 */
.preview-modal.fullscreen { position: fixed; inset: 0; width: 100vw !important; height: 100vh; max-width: none; max-height: none; overflow: hidden; border-radius: 0; z-index: 60; }
.preview-modal.fullscreen .preview-body { flex: 1; min-height: 0; height: auto; overflow: hidden; }
.preview-modal.fullscreen .preview-img { max-height: none; height: 100%; width: 100%; object-fit: contain; }
.preview-modal.fullscreen .preview-pdf-wrap { flex: 1; min-height: 0; }
.preview-modal.fullscreen .preview-pdf { height: 100%; }
.preview-info { font-size: 13px; line-height: 1.8; color: var(--text); }
.preview-info .kv { display: flex; }
.preview-info .k { color: var(--text-muted); width: 90px; flex-shrink: 0; }

/* ---------- 交付记录 ---------- */
.delivery-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.delivery-item:last-child { border-bottom: none; }
.delivery-item .d-file { font-weight: 600; }
.delivery-item .d-meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.delivery-item .d-taker { text-align: right; }
.delivery-item .d-time { color: var(--text-muted); font-size: 12px; }

/* ---------- 用户管理 ---------- */
.user-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row .u-name { font-weight: 600; }
.user-row .u-meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; }

/* ---------- 款号相关 ---------- */
.style-no { font-weight: 700; color: var(--primary); }
.count-chip { display: inline-block; min-width: 26px; text-align: center; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #edf0f5; color: var(--text-muted); }
.count-chip.has { background: #e0ecff; color: #1f6feb; }
.count-chip.plate.has { background: #fbe6ff; color: #a020f0; }

.style-info { display: flex; flex-wrap: wrap; gap: 8px 28px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 22px; }
.style-info .kv { font-size: 14px; }
.style-info .k { color: var(--text-muted); margin-right: 8px; }

.block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.block-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.block-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.file-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }
.desc-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 权限 ---------- */
.perm-badges { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0 8px; }
.perm { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.perm.ok { background: rgba(26,127,55,.12); color: var(--success); }
.perm.none { background: rgba(107,114,128,.12); color: var(--text-muted); }
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; cursor: pointer; inset: 0; background: #cbd2de; border-radius: 22px; transition: background .2s; }
.switch span:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span:before { transform: translateX(20px); }

/* ---------- 通用 ---------- */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 12px 22px; border-radius: 8px; color: #fff; font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: fade .25s; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
.toast.info { background: #6b7280; }
@keyframes fade { from { opacity: 0; transform: translate(-50%,-8px);} to { opacity: 1; transform: translate(-50%,0);} }
.hidden { display: none !important; }
.right { text-align: right; }
/* 移动端导航：汉堡菜单 + 抽屉 */
.menu-btn { display: none; position: fixed; top: 14px; left: 14px; z-index: 80; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 20px; cursor: pointer; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.mob-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 66; }
@media (max-width: 760px) {
  .menu-btn { display: flex; }
  .shell { flex-direction: column; }
  .sidebar { position: fixed; top: 0; left: 0; width: 240px; height: 100vh; flex-direction: column; z-index: 70; transform: translateX(-100%); transition: transform .22s ease; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
  .nav { display: block; padding: 12px 0; }
  .nav-item { border-left: 3px solid transparent; border-bottom: none; white-space: normal; }
  .nav-item.active { border-bottom-color: transparent; border-left-color: #4f9bff; }
  .main { padding: 58px 12px 14px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---------- 新增：款式图片 / 布片 / 工序 / 二维码 / 扫码 ---------- */
.img-type-title { display: flex; align-items: center; gap: 8px; padding: 12px 16px 4px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 10px 16px 16px; }
.img-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.img-thumb { width: 100%; height: 130px; background-size: cover; background-position: center; cursor: pointer; }
.img-name { font-size: 12px; padding: 6px 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-meta { padding: 2px 8px 6px; }
.proc-group { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.proc-group:last-child { border-bottom: none; }
.proc-group-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.proc-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.proc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.proc-who { font-weight: 600; }
.proc-fields { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text); }
.scan-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; max-width: 640px; }
.scan-hit { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.scan-style { font-size: 15px; }
.scan-actions { display: flex; gap: 10px; margin-top: 12px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; z-index: 100; }
.lightbox img { max-width: 96vw; max-height: 94vh; object-fit: contain; }
.lb-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; }
.qr-modal { width: 420px; text-align: center; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.qr-box img { width: 220px; height: 220px; }
.qr-text { font-size: 17px; font-weight: 700; color: var(--primary); }
.qr-info { margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px dashed var(--border); border-radius: 8px; text-align: left; font-size: 13px; line-height: 1.7; color: #333; }
