/* ================= SmartQMS Stylesheet ================= */
:root {
  --red: #E8262D;
  --red-dark: #C31A20;
  --red-bg: #FDEDEE;
  --primary: #2E6DB4;
  --primary-dark: #2560A3;
  --dark: #2B3A55;
  --dark-2: #33466A;
  --dark-3: #3E5480;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --text: #23272F;
  --muted: #7A828E;
  --line: #E4E7EC;
  --green: #16A34A; --green-bg: #E9F7EF;
  --blue: #2563EB;  --blue-bg: #EAF1FE;
  --orange: #D97706; --orange-bg: #FDF3E3;
  --gray-bg: #EEF0F3;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .16);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: 13.5px; color: var(--text); background: var(--bg); display: flex; overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(47, 109, 180, .22); }

/* ---------- Sidebar ---------- */
#sidebar-root { width: 232px; flex-shrink: 0; }
.sidebar { width: 232px; height: 100vh; background: var(--dark); color: #C9D4E6; display: flex; flex-direction: column; position: fixed; left: 0; top: 0; overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 4px; } .sidebar::-webkit-scrollbar-thumb { background: var(--dark-3); border-radius: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-mark svg { display: block; }
.brand-name { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 10px; color: #8FA2C4; margin-top: 1px; letter-spacing: .4px; }
.nav-group { padding: 6px 0 2px; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: #7C8BAA; padding: 8px 20px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8.5px 20px; color: #C9D4E6; cursor: pointer; border-left: 3px solid transparent; font-size: 13.5px; }
.nav-item:hover { background: var(--dark-2); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(47,109,180,.22), rgba(47,109,180,.04)); border-left-color: var(--primary); color: #fff; font-weight: 600; }
.nav-item .ni { width: 17px; height: 17px; opacity: .85; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--dark-3); font-size: 11px; color: #7C8BAA; line-height: 1.7; }

/* ---------- Main / Topbar ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
#topbar-root { flex-shrink: 0; }
.topbar { height: 54px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 22px; gap: 14px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 15.5px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumb { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.tb-seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.tb-seg button { border: 0; background: #fff; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--muted); font-family: var(--font); }
.tb-seg button.on { background: var(--primary); color: #fff; font-weight: 600; }
.tb-select { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12.5px; color: var(--text); background: #fff; font-family: var(--font); cursor: pointer; }
.tb-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--text); font-family: var(--font); }
.tb-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- App container ---------- */
#app { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* ---------- Cards / KPI ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-title { font-size: 13.5px; font-weight: 700; padding: 13px 18px 0; display: flex; justify-content: space-between; align-items: center; }
.card-title .sub { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; cursor: pointer; transition: transform .12s, box-shadow .12s; position: relative; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 700; margin-top: 5px; letter-spacing: -.3px; }
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-delta { font-size: 11.5px; margin-top: 5px; color: var(--muted); }
.kpi-delta .up { color: var(--green); font-weight: 600; }
.kpi-delta .down { color: var(--red); font-weight: 600; }
.kpi::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--line); }
.kpi.k-red::before { background: var(--red); } .kpi.k-green::before { background: var(--green); }
.kpi.k-blue::before { background: var(--blue); } .kpi.k-orange::before { background: var(--orange); }

/* ---------- Grid rows ---------- */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.row-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.row-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #EEF0F3; vertical-align: middle; }
.tbl tbody tr:hover { background: #F8F9FB; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.tbl-empty { text-align: center; color: var(--muted); padding: 30px 0 !important; }
.rowlink { color: var(--blue); cursor: pointer; font-weight: 500; }
.rowlink:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; border-radius: 20px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-gray { background: var(--gray-bg); color: #5A6270; }
.b-dark { background: var(--dark); color: #fff; }
.dot { display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:6px; vertical-align:1px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 5px; border-radius: 7px; padding: 6.5px 14px; font-size: 12.8px; cursor: pointer; font-family: var(--font); border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #C9CEDB; background: #F8F9FB; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: 3.5px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--red); border-color: #F3C1C4; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-link { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; font-size: 12.3px; font-family: var(--font); }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--red); }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar select, .filter-bar input[type=text], .filter-bar input[type=month], .filter-bar input[type=date] { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-size: 12.5px; font-family: var(--font); background: #fff; color: var(--text); }
.filter-bar input[type=text] { width: 190px; }
.filter-bar .spacer { flex: 1; }
.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font-size: 12.5px; box-shadow: var(--shadow); }
.chip b { font-size: 16px; margin-right: 4px; }
.chip.c-red b { color: var(--red); } .chip.c-blue b { color: var(--blue); } .chip.c-orange b { color: var(--orange); } .chip.c-green b { color: var(--green); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 16px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 19, 28, .45); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 46px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 620px; max-width: 100%; box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
.modal.wide { width: 860px; } .modal.xl { width: 1020px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-x { border: 0; background: none; font-size: 19px; color: var(--muted); cursor: pointer; line-height: 1; padding: 2px 4px; }
.modal-x:hover { color: var(--primary); }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.f-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.f-field label .req { color: var(--red); margin-left: 2px; }
.f-field input, .f-field select, .f-field textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 7.5px 10px; font-size: 13px; font-family: var(--font); color: var(--text); background: #fff; }
.f-field textarea { min-height: 64px; resize: vertical; }
.f-field input:focus, .f-field select:focus, .f-field textarea:focus, .filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 109, 180, .12); }
.f-field .err { border-color: var(--red) !important; }
.f-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.f-sec { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 4px; letter-spacing: .3px; }

/* defect rows */
.defect-row { display: grid; grid-template-columns: 1fr 130px 90px 32px; gap: 8px; margin-bottom: 8px; }
.defect-row input, .defect-row select { border: 1px solid var(--line); border-radius: 7px; padding: 6.5px 9px; font-size: 12.5px; font-family: var(--font); }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.check-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12.8px; padding: 6px 0; border-bottom: 1px dashed #EEF0F3; }
.check-item input { margin-top: 2px; }
.check-item .std { color: var(--muted); font-size: 11.5px; }

/* ---------- AQL panel ---------- */
.aql-panel { background: #FAFBFC; border: 1px dashed #D5DAE3; border-radius: 8px; padding: 12px 14px; margin: 4px 0 6px; }
.aql-panel .v { font-weight: 700; }
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.verdict.pass { background: var(--green-bg); color: var(--green); }
.verdict.fail { background: var(--red-bg); color: var(--red); }

/* ---------- Timeline (detail / complaint) ---------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2.5px solid var(--blue); }
.tl-item.done::before { background: var(--green); border-color: var(--green); }
.tl-item.warn::before { border-color: var(--orange); }
.tl-date { font-size: 11.5px; color: var(--muted); }
.tl-text { font-size: 12.8px; margin-top: 2px; }

/* ---------- Gate timeline (dev project) ---------- */
.gates { display: flex; margin: 16px 0 6px; }
.gate { flex: 1; position: relative; text-align: center; cursor: pointer; padding: 0 4px; }
.gate-node { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: #fff; border: 2.5px solid #D5DAE3; color: var(--muted); position: relative; z-index: 2; }
.gate::before { content: ''; position: absolute; top: 17px; left: -50%; width: 100%; height: 2.5px; background: #D5DAE3; z-index: 1; }
.gate:first-child::before { display: none; }
.gate.done .gate-node { background: var(--green); border-color: var(--green); color: #fff; }
.gate.done::before { background: var(--green); }
.gate.current .gate-node { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px rgba(47,109,180,.14); }
.gate.blocked .gate-node { border-color: var(--red); background: var(--red); color: #fff; }
.gate.locked .gate-node { opacity: .55; }
.gate-name { font-size: 12px; margin-top: 7px; font-weight: 600; }
.gate-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.gate:hover .gate-name { color: var(--primary); }

/* ---------- 8D stepper ---------- */
.d8-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 0; min-height: 420px; }
.d8-steps { border-right: 1px solid var(--line); padding: 14px 0; background: #FAFBFC; border-radius: 10px 0 0 10px; }
.d8-step { display: flex; gap: 10px; padding: 9px 16px; cursor: pointer; align-items: center; }
.d8-step .n { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #D5DAE3; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0; }
.d8-step.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.d8-step.cur .n { border-color: var(--primary); color: var(--primary); }
.d8-step.cur .t { color: var(--primary); font-weight: 700; }
.d8-step.lock { opacity: .5; cursor: default; }
.d8-step .t { font-size: 12.5px; }
.d8-body { padding: 18px 22px; }

/* ---------- Trace chain ---------- */
.trace-chain { display: flex; flex-direction: column; align-items: stretch; }
.trace-node { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 9px; background: #fff; padding: 12px 16px; box-shadow: var(--shadow); }
.trace-node.t-supplier { border-left-color: var(--orange); }
.trace-node.t-material { border-left-color: var(--blue); }
.trace-node.t-production { border-left-color: var(--green); }
.trace-node.t-shipment { border-left-color: #7C3AED; }
.trace-node.t-complaint { border-left-color: var(--red); }
.trace-arrow { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.6; padding: 1px 0; }
.trace-node h4 { font-size: 13px; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.trace-kv { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12.3px; color: var(--muted); }
.trace-kv b { color: var(--text); font-weight: 600; }

/* ---------- PDCA wall ---------- */
.pdca-wall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pdca-col { background: #FAFBFC; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 180px; }
.pdca-col h4 { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin: 2px 4px 8px; }
.pdca-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.pdca-card:hover { border-color: var(--primary); }
.pdca-card .t { font-weight: 600; font-size: 12.8px; }
.pdca-card .m { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Charts ---------- */
.chart-box { width: 100%; height: 240px; display: block; }
.chart-legend { display: flex; gap: 16px; padding: 4px 18px 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.chart-legend .k { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 66px; right: 22px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-lg); animation: slidein .18s ease-out; max-width: 380px; }
.toast.ok { border-left: 4px solid var(--green); }
.toast.err { border-left: 4px solid var(--red); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.kv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 20px; }
.kv-list .k { font-size: 11.5px; color: var(--muted); }
.kv-list .v { font-size: 13px; font-weight: 600; margin-top: 2px; word-break: break-all; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.mini-note { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.alert-box { background: var(--orange-bg); border: 1px solid #F3D9AE; color: #92610A; border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 12px; line-height: 1.6; }
.alert-box.red { background: var(--red-bg); border-color: #F3C1C4; color: var(--red-dark); }
.todo-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 18px; border-bottom: 1px solid #EEF0F3; font-size: 12.8px; }
.todo-item:last-child { border-bottom: 0; }
.todo-item .desc { flex: 1; }
.link-plain { color: var(--text); }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb12 { margin-bottom: 12px; } .mb6 { margin-bottom: 6px; }
.flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.text-muted { color: var(--muted); } .text-red { color: var(--red); } .text-green { color: var(--green); }
.tag { display: inline-block; background: var(--gray-bg); color: #5A6270; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 600; margin-right: 4px; }
.progressbar { height: 6px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; min-width: 70px; }
.progressbar > i { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.footer-note { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 26px; }

/* ---------- 报告预览（A4 版式，可打印） ---------- */
.report-overlay { position: fixed; inset: 0; background: rgba(15, 19, 28, .52); z-index: 300; overflow-y: auto; }
.rep-toolbar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 10px 24px; background: #23272F; box-shadow: var(--shadow); }
.rep-tb-title { color: #fff; font-size: 13px; font-weight: 600; }
.rep-paper { background: #fff; width: 820px; max-width: 94%; margin: 26px auto 60px; padding: 44px 52px; box-shadow: var(--shadow-lg); border-radius: 4px; }
.rep-head { border-bottom: 2.5px solid var(--primary); padding-bottom: 14px; margin-bottom: 18px; }
.rep-brand { display: flex; gap: 10px; align-items: center; }
.rep-sys { font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.rep-tag { font-size: 11px; color: var(--muted); }
.rep-title { text-align: center; font-size: 21px; font-weight: 800; letter-spacing: 2px; margin: 18px 0 7px; }
.rep-docno { text-align: center; font-size: 12px; color: var(--muted); }
table.rep-meta { width: 100%; border-collapse: collapse; font-size: 12.8px; margin-bottom: 4px; }
.rep-meta th { width: 108px; text-align: left; font-weight: 600; color: var(--muted); background: #FAFBFC; border: 1px solid var(--line); padding: 7px 10px; white-space: nowrap; }
.rep-meta td { border: 1px solid var(--line); padding: 7px 10px; font-weight: 600; word-break: break-all; }
.rep-sec { margin-top: 16px; }
.rep-sec-title { font-size: 13px; font-weight: 700; border-left: 3px solid var(--primary); padding-left: 8px; margin-bottom: 8px; }
.rep-sec .tbl th { background: #FAFBFC; }
.rep-text { font-size: 13px; line-height: 1.8; }
.rep-verdict { display: flex; align-items: center; font-size: 14px; font-weight: 600; padding: 4px 0; }
.rep-list { font-size: 13px; line-height: 2; padding-left: 2px; }
.rep-signs { display: flex; gap: 26px; margin-top: 34px; }
.rep-sign { flex: 1; }
.rep-sign-role { font-size: 12px; color: var(--muted); }
.rep-sign-line { border-bottom: 1px solid var(--text); height: 36px; }
.rep-foot { margin-top: 30px; text-align: center; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
@media print {
  body > *:not(#report-ov) { display: none !important; }
  .report-overlay { position: static !important; background: none !important; overflow: visible !important; }
  .rep-toolbar { display: none !important; }
  .rep-paper { box-shadow: none !important; margin: 0 !important; width: 100% !important; max-width: none !important; padding: 8mm 10mm !important; border-radius: 0 !important; }
  .rep-signs { page-break-inside: avoid; }
  .rep-sec { page-break-inside: avoid; }
}

/* ---------- Approval chain timeline（多级审批时间线） ---------- */
.chain { display: flex; flex-direction: column; }
.chain-node { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.chain-node:last-child { padding-bottom: 0; }
.chain-node:not(:last-child)::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.chain-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.cd-green { background: var(--green-bg); color: var(--green); }
.cd-red { background: var(--red-bg); color: var(--red); }
.cd-gray { background: var(--gray-bg); color: var(--muted); }
.chain-body { min-width: 0; }
.chain-tt { font-size: 13px; font-weight: 700; line-height: 28px; }
.chain-sub { font-size: 12px; color: var(--muted); line-height: 1.6; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } .row-2, .row-2-1, .row-1-2, .row-3 { grid-template-columns: 1fr; } .pdca-wall { grid-template-columns: repeat(2, 1fr); } .d8-wrap { grid-template-columns: 1fr; } .d8-steps { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---------- Mobile inspection (phone-frame preview on desktop, full-bleed on phones) ---------- */
.mstage { display: flex; justify-content: center; padding: 6px 0 20px; }
.mphone { width: 100%; max-width: 430px; background: #F2F4F7; border-radius: 26px; border: 10px solid #23272F; box-shadow: 0 18px 44px rgba(16,24,40,.22); overflow: hidden; display: flex; flex-direction: column; min-height: 640px; max-height: 78vh; }
.mphone .m-status { background: var(--dark); color: #9FB0CC; font-size: 10.5px; display: flex; justify-content: space-between; padding: 4px 14px; font-family: var(--font-mono); }
.mphone .m-head { background: var(--primary); color: #fff; padding: 12px 16px 13px; }
.mphone .m-head .t { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.mphone .m-head .s { font-size: 10.5px; opacity: .85; margin-top: 2px; line-height: 1.4; }
.mbody { flex: 1; overflow-y: auto; padding: 12px 12px 18px; }
.mcard { background: #fff; border-radius: 14px; box-shadow: 0 1px 3px rgba(16,24,40,.09); padding: 12px 14px; margin-bottom: 10px; }
.mcard .mt { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.mtask { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.mtask:last-child { border-bottom: 0; padding-bottom: 2px; }
.mtask .badge-lv { width: 38px; height: 38px; border-radius: 10px; background: #EEF2F7; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.mtask .ti { flex: 1; min-width: 0; }
.mtask .ti b { font-size: 13px; display: block; }
.mtask .ti span { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
.mbtn { border: 0; border-radius: 10px; padding: 10px 16px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: var(--font); background: var(--primary); color: #fff; }
.mbtn.ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.mbtn.wide { width: 100%; padding: 13px; font-size: 14.5px; }
.mbtn:active { transform: scale(.98); }
.mbtn:disabled { opacity: .45; cursor: not-allowed; }
.mscan { display: flex; gap: 8px; }
.mscan input { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-family: var(--font-mono); }
.mscan input:focus { outline: none; border-color: var(--primary); }
.mchk { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.mchk:last-child { border-bottom: 0; }
.mtoggle { position: relative; width: 46px; height: 26px; border-radius: 14px; background: #C6CEDB; cursor: pointer; transition: background .15s; flex-shrink: 0; border: 0; }
.mtoggle.on { background: var(--green); }
.mtoggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.mtoggle.on::after { left: 23px; }
.mquick { display: flex; flex-wrap: wrap; gap: 7px; }
.mchip { border: 1.5px solid var(--line); background: #fff; border-radius: 18px; padding: 6.5px 13px; font-size: 12.5px; cursor: pointer; font-family: var(--font); color: var(--text); }
.mchip:active { background: var(--primary-bg, #E9F1FA); border-color: var(--primary); color: var(--primary); }
.mdef { border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; margin-bottom: 8px; }
.mdef .row1 { display: flex; align-items: center; gap: 6px; }
.mdef .lvl { border: 0; border-radius: 7px; padding: 4.5px 9px; font-size: 11px; font-weight: 700; cursor: pointer; font-family: var(--font); background: #EEF0F3; color: var(--muted); }
.mdef .lvl.on-cr { background: var(--red); color: #fff; }
.mdef .lvl.on-ma { background: var(--orange); color: #fff; }
.mdef .lvl.on-mi { background: var(--blue); color: #fff; }
.mdef .dx { flex: 1; border: 0; border-bottom: 1px dashed var(--line); font-size: 13px; padding: 4px 2px; font-family: var(--font); background: transparent; }
.mdef .dx:focus { outline: none; border-bottom-color: var(--primary); }
.mdef .del { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 2px; }
.mdef .row2 { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.mdef .qty { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.mdef .qty button { border: 0; background: #F4F6F9; width: 34px; height: 32px; font-size: 16px; cursor: pointer; color: var(--text); }
.mdef .qty input { width: 52px; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 32px; font-size: 13.5px; font-weight: 700; }
.mdef .ph { margin-left: auto; }
.mdef .thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mdef .thumbs .th { position: relative; width: 54px; height: 54px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.mdef .thumbs .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mdef .thumbs .th .rm { position: absolute; top: 1px; right: 1px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 50%; width: 17px; height: 17px; font-size: 10px; line-height: 1; cursor: pointer; }
.mdef .add-ph { border: 1.5px dashed #C4CCD9; border-radius: 8px; width: 54px; height: 54px; background: none; color: var(--muted); font-size: 19px; cursor: pointer; line-height: 1; }
.maql { display: flex; align-items: center; gap: 12px; }
.maql .ring { width: 84px; height: 84px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.maql .ring.pass { background: var(--green); }
.maql .ring.fail { background: var(--red); }
.maql .ring b { font-size: 22px; letter-spacing: .02em; }
.maql .ring span { font-size: 10px; opacity: .9; }
.maql .facts { flex: 1; font-size: 12px; color: var(--muted); line-height: 1.8; }
.maql .facts b { color: var(--text); font-family: var(--font-mono); }
.msign { display: flex; align-items: center; gap: 10px; padding: 12px 2px 2px; border-top: 1px dashed var(--line); margin-top: 4px; }
.msign .who { flex: 1; font-size: 12px; color: var(--muted); }
.msign .who b { display: block; font-size: 13.5px; color: var(--text); }
.moff { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.moff .hint { color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.5; }
.mqueue { display: flex; align-items: center; gap: 8px; background: #FFF7E8; border: 1px solid #F0DDB4; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 12.5px; }
.mqueue .cnt { background: var(--orange); color: #fff; border-radius: 12px; padding: 1px 9px; font-weight: 700; font-size: 12px; }
.mok { text-align: center; padding: 34px 10px 24px; }
.mok .big { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.mok .big.fail { background: var(--red); }
.mok h4 { font-size: 16px; margin-bottom: 6px; }
.mok p { font-size: 12.5px; color: var(--muted); }
.mempty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }
@media (max-width: 700px) {
  .mstage { padding: 0; }
  .mphone { max-width: none; border: 0; border-radius: 0; box-shadow: none; min-height: 100vh; max-height: none; }
  .mphone .m-status { display: none; }
}
body.m-route #sidebar-root, body.m-route #topbar-root { display: none; }
body.m-route .main { height: auto; }
.m-tag { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .06em; background: var(--primary); color: #fff; border-radius: 4px; padding: 1px 5px; vertical-align: 2px; margin-left: 4px; }
.mcam { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; border: 2.5px dashed var(--primary); background: var(--primary-bg, #E9F1FA); color: var(--primary); border-radius: 14px; padding: 18px 12px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: var(--font); }
.mcam:active { transform: scale(.985); background: #DEEBF7; }
.mcam .ci { font-size: 26px; line-height: 1; }
.tb-user { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; }
.tb-user b { font-weight: 700; }

/* ---------- UTC theme (black/white minimal + red accents) ---------- */
[data-theme="utc"] {
  --primary: #111418;
  --primary-dark: #23282F;
  --red: #C8102E;
  --red-dark: #A50D26;
  --blue: #4A5568;
  --blue-bg: #EBECEE;
  --bg: #F7F7F5;
  --dark: #111418;
  --dark-2: #1D2229;
  --dark-3: #2A303A;
}
[data-theme="utc"] .nav-item.active { background: linear-gradient(90deg, rgba(200,16,46,.20), rgba(200,16,46,.04)); border-left-color: #D0021B; }
[data-theme="utc"] .brand-mark { background: #fff; }
[data-theme="utc"] .brand-mark svg { stroke: #111418; }
[data-theme="utc"] .brand-name .red { color: #FF5A66; }
[data-theme="utc"] .btn-primary, [data-theme="utc"] .tb-seg button.on { background: #111418; border-color: #111418; }
[data-theme="utc"] .btn-primary:hover { background: #23282F; border-color: #23282F; }
[data-theme="utc"] .tab.active { color: #111418; border-bottom-color: #D0021B; }
[data-theme="utc"] .kpi::before { width: 4px; }

/* ===== workbench (external users: qc / sqe / sas) ===== */
.wb-stats { display: flex; gap: 10px; margin-bottom: 12px; }
.wb-stat { flex: 1; background: var(--card, #fff); border: 1px solid var(--line, #E3E7EE); border-radius: 10px; padding: 12px 14px; text-align: center; }
.wb-stat b { display: block; font-size: 26px; line-height: 1.2; }
.wb-stat span { font-size: 12px; color: var(--muted, #7A8499); }
.wb-stat.c-orange b { color: #E67E22; }
.wb-stat.c-green b { color: #27AE60; }
[data-theme="utc"] .wb-stat { background: #16191F; border-color: #262B33; }
