:root {
  --bg: #f3f5f8; --panel: #fff; --line: #e3e7ee; --text: #1c2430; --muted: #6b7686;
  --side: #17202e; --side-text: #b9c3d3; --primary: #1f6feb; --primary-dark: #1a5fd0;
  --red: #c93434; --red-bg: #fdecec; --amber: #9a6200; --amber-bg: #fff3d6;
  --green: #1a7f46; --green-bg: #e3f6ea; --blue: #1d5fbf; --blue-bg: #e6f0fd; --gray-bg: #eceff3;
  --return: #8a5a00; --return-bg: #fdf0c8; --repair: #0d6b74; --repair-bg: #d5f1f1;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 600; font-size: 16px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.text-red { color: var(--red); } .right { text-align: right; } .big { font-size: 20px; }
.print-only { display: none; }

.shell { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-size: 16px; font-weight: 600; padding: 20px 18px 14px; }
.brand small { display: block; font-size: 12px; font-weight: 400; color: #7f8ba0; margin-top: 2px; }
.sidebar nav { flex: 1; padding: 0 10px; }
.nav-group { font-size: 11px; color: #6c7890; padding: 14px 10px 4px; letter-spacing: 1px; }
.nav-link { display: flex; justify-content: space-between; align-items: center; color: var(--side-text); padding: 8px 10px; border-radius: 6px; }
.nav-link:hover { background: #222e40; text-decoration: none; color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-count { background: #e5484d; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.sidebar-user { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid #263246; font-size: 13px; }
.sidebar-user strong { color: #fff; } .sidebar-user span { font-size: 12px; }
.main { flex: 1; min-width: 0; padding: 22px 28px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 760px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.hint { background: #f6f8fb; border-left: 3px solid #c5cfdd; padding: 8px 12px; border-radius: 4px; color: #4a5565; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; margin: 0; }
.count { background: var(--gray-bg); border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 500; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash-notice { background: var(--green-bg); color: var(--green); }
.flash-alert { background: var(--red-bg); color: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #cfd6e0; background: #fff; color: var(--text); padding: 7px 14px; border-radius: 6px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f6f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--red); border-color: #e7b5b5; } .btn-danger:hover { background: var(--red-bg); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.sidebar .btn-ghost { color: var(--side-text); border-color: #344056; } .sidebar .btn-ghost:hover { background: #222e40; }
.btn-sm { padding: 4px 10px; font-size: 13px; } .btn-lg { padding: 12px 22px; font-size: 16px; } .btn-block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; color: inherit; border: 1px solid #cfd6e0; border-radius: 6px; padding: 7px 10px; background: #fff; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8d2fb; border-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #4a5565; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.span-2 { grid-column: span 2; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .grow { flex: 1; min-width: 160px; }
.filters { margin-bottom: 14px; }
.form-foot { margin-top: 14px; justify-content: flex-end; }
.decision { display: flex; flex-direction: column; gap: 8px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-narrow { max-width: 420px; } .check-col { width: 32px; }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-gray { background: var(--gray-bg); color: #4a5565; } .badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-red { background: var(--red-bg); color: var(--red); } .badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-kind-return { background: var(--return-bg); color: var(--return); } .badge-kind-repair { background: var(--repair-bg); color: var(--repair); }

.alert-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.alert-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; color: var(--text); display: flex; flex-direction: column; }
.alert-card:hover { border-color: var(--primary); text-decoration: none; }
.alert-card b { font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.alert-card small { color: var(--muted); }
.alert-card.is-hot { border-color: #eeb4b4; background: #fffafa; } .alert-card.is-hot b { color: var(--red); }

.pipeline { display: flex; gap: 22px; flex-wrap: wrap; align-items: stretch; }
.stage { position: relative; flex: 1; min-width: 110px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); display: flex; flex-direction: column; }
.stage:hover { border-color: var(--primary); text-decoration: none; }
.stage b { font-size: 22px; font-variant-numeric: tabular-nums; } .stage span { font-size: 12px; color: #4a5565; }
.stage.is-empty b { color: #a9b2c0; }
.pipeline > .stage:not(:first-child)::before { content: "→"; position: absolute; left: -18px; top: 50%; transform: translateY(-50%); color: #a9b2c0; }
.stage-branch { background: #fff8f8; border-style: dashed; }
.pipeline-side { display: flex; flex-direction: column; gap: 6px; min-width: 130px; }
.stage.is-small { flex-direction: row; align-items: baseline; gap: 8px; padding: 5px 12px; } .stage.is-small b { font-size: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

.scan-form { display: flex; gap: 10px; }
.scan-input { flex: 1; font-size: 20px !important; padding: 12px 16px !important; font-family: ui-monospace, Menlo, Consolas, monospace !important; }
.scan-result { margin-top: 16px; border-radius: 8px; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 5px; }
.scan-result-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.scan-ok { background: #f3fbf6; border-color: #9fd9b6; } .scan-ok .scan-result-title { color: var(--green); }
.scan-warn { background: #fffaf0; border-color: #ebc671; } .scan-warn .scan-result-title { color: var(--amber); }
.scan-bad { background: #fff7f7; border-color: #e9a3a3; } .scan-bad .scan-result-title { color: var(--red); }
.scan-neutral { background: #f8fafc; border-color: #b9c8dd; }
.scan-ticket-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 8px; }
.scan-result .scan-form, .scan-result .inline-form, .scan-result .form-grid { margin-top: 12px; }
.exception-box { margin-top: 14px; border-top: 1px dashed #cbd3df; padding-top: 10px; }
.exception-box summary { cursor: pointer; color: var(--red); }
.confirm-box { background: #f6f8fb; padding: 12px 14px; border-radius: 8px; margin: 12px 0; }

.dl { display: grid; grid-template-columns: 110px 1fr; gap: 7px 12px; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; word-break: break-all; }
.dl-compact { grid-template-columns: 90px 1fr; gap: 4px 12px; }
.photo { max-width: 100%; max-height: 260px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 10px; display: block; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline b { margin-right: 8px; } .timeline p { margin: 2px 0 0; color: #4a5565; font-size: 13px; }
.desk-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.desk-item-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.desk-item p { margin-bottom: 6px; }
.error-list { color: var(--red); padding-left: 18px; font-size: 13px; }

body.plain { display: grid; place-items: center; min-height: 100vh; background: var(--side); }
.login-card { background: #fff; border-radius: 12px; padding: 32px; width: min(360px, 92vw); }
.login-card h1 { margin-bottom: 4px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; } .sidebar { width: auto; height: auto; position: static; }
  .main { padding: 16px; } .two-col, .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
}
@media print {
  .sidebar, .no-print, .flash { display: none !important; } .print-only { display: block; }
  body { background: #fff; } .main { padding: 0; } .card { border: 0; padding: 0; }
  .sign-line { margin-top: 40px; }
}

.import-rules ul { margin: 6px 0; padding-left: 20px; } .import-rules p { margin: 0; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stat-row div { display: flex; flex-direction: column; } .stat-row b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat-row span { font-size: 12px; color: var(--muted); } .text-green { color: var(--green); }
input[type=file] { font: inherit; }

.field-title { font-size: 13px; color: #4a5565; margin-bottom: 8px; }
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.chip { flex-direction: row; align-items: flex-start; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; color: var(--text); }
.chip:has(input:checked) { border-color: var(--primary); background: #f3f7ff; }
.chip span { display: flex; flex-direction: column; } .chip small { color: var(--muted); font-size: 12px; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.perm-group-head { margin-bottom: 8px; color: var(--text); font-size: 14px; }
.perm-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; padding-left: 22px; }
form.inline { display: inline; } .nowrap { white-space: nowrap; }

.date-filter input[type=date] { padding: 4px 8px; }
.list-head { margin: 14px 0 10px; } .list-head h3 { margin: 0; }
