:root {
  --red: #ed1c24;
  --danger: #b91c1c;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --panel: #ffffff;
  --bg: #f5f7fb;
  --ok: #166534;
  --warn: #b45309;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, .button-link { border: 1px solid var(--red); background: var(--red); color: #fff; border-radius: 6px; min-height: 34px; padding: 7px 12px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, .button-link.ghost { border-color: var(--line); background: #fff; color: var(--ink); }
button.danger { border-color: #fecaca; background: #fff; color: var(--danger); }
input, select, textarea { border: 1px solid #cfd4dc; border-radius: 6px; padding: 7px 8px; color: var(--ink); background: #fff; min-width: 0; }
textarea { resize: vertical; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.check-label { display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--ink); }
.check-label input { width: auto; min-width: 0; }
.file-label input { max-width: 220px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--red); }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: var(--bg); }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px rgba(16, 24, 40, .14); padding: 22px; display: grid; gap: 14px; }
.login-card strong { color: var(--ink); font-size: 20px; }
.login-card input, .login-card button { width: 100%; }
.login-message { margin: 0; min-height: 18px; color: var(--danger); font-size: 13px; font-weight: 700; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.main-nav { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: grid; align-content: start; gap: 22px; }
.nav-brand { align-items: flex-start; }
.nav-brand strong { color: var(--ink); font-size: 15px; }
.nav-user { display: block; margin-top: 4px; color: var(--muted); font-weight: 700; line-height: 1.35; }
.vertical-tabs { display: grid; gap: 8px; }
.main-tab { width: 100%; justify-content: flex-start; text-align: left; background: #fff; border-color: var(--line); color: var(--ink); }
.main-tab.active { background: var(--red); border-color: var(--red); color: #fff; }
.main-content { min-width: 0; padding: 22px; display: grid; }
.main-view { display: none; min-width: 0; align-content: start; gap: 16px; }
.main-view.active { display: grid; }
.list-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--red); font-weight: 700; text-transform: uppercase; font-size: 12px; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-label { display: flex; grid-template-columns: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.toolbar-label input { width: 132px; padding: 6px 7px; }
.doc-filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.doc-filter-bar > input { min-width: 240px; flex: 1 1 260px; }
.doc-filter-bar select { min-width: 150px; }
.quick-date-filter.active, .reset-doc-date-filter.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.dashboard-date-scope { margin: -2px 0 10px; font-weight: 700; }
.select-col { width: 42px; min-width: 42px; max-width: 42px; text-align: center; vertical-align: middle; }
.select-col input { width: auto; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.list-panel { align-content: start; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stats-grid div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 6px; }
.stats-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stats-grid strong { font-size: 22px; }
.stats-grid small { color: var(--muted); font-weight: 700; }
.modal-summary-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.modal-summary-grid div { min-width: 0; padding: 4px 6px; gap: 1px; border-radius: 6px; }
.modal-summary-grid span { font-size: 10px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-summary-grid strong { font-size: 14px; line-height: 1; }
.modal-summary-grid small { display: none; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.dashboard-card { min-height: 220px; align-content: start; }
.dashboard-wide { grid-column: 1 / -1; }
.pqc-environment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pqc-environment-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px; display: grid; gap: 8px; min-width: 0; }
.pqc-chart { min-height: 252px; overflow: hidden; }
.pqc-chart-svg { width: 100%; height: 220px; display: block; }
.pqc-grid-line { stroke: #eef2f7; stroke-width: 1; }
.pqc-limit-line { stroke: #ef4444; stroke-width: 1.5; stroke-dasharray: 5 4; }
.pqc-limit-label, .pqc-axis-label, .pqc-x-label { fill: #64748b; font-size: 11px; font-weight: 700; }
.pqc-x-label { text-anchor: middle; }
.pqc-chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.pqc-chart-dot { stroke: #fff; stroke-width: 2; }
.pqc-chart-dot.ok { fill: #16a34a; }
.pqc-chart-dot.bad { fill: #dc2626; }
.pqc-chart-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.pqc-chart-footer strong { color: var(--ink); font-size: 16px; }
.stage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stage-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 10px; background: #fff; }
.stage-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.stage-card strong { font-size: 24px; }
.quality-progress-grid { display: grid; gap: 12px; }
.quality-progress-panel { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; display: grid; gap: 10px; }
.quality-progress-title { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.quality-progress-title h3 { margin: 0; font-size: 15px; }
.quality-progress-title span { color: var(--muted); font-size: 12px; font-weight: 800; }
.quality-progress-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
.quality-metric { display: grid; grid-template-columns: 126px minmax(0, 1fr); gap: 12px; align-items: center; }
.quality-metric.compact { grid-template-columns: 104px minmax(0, 1fr); }
.quality-metric-label { color: #334155; font-size: 12px; font-weight: 900; text-transform: uppercase; margin-bottom: 6px; }
.donut { --pct: 0; --tone: var(--danger); width: 116px; aspect-ratio: 1; border-radius: 999px; background: conic-gradient(var(--tone) calc(var(--pct) * 1%), #eef2f7 0); display: grid; place-items: center; }
.donut::before { content: attr(data-label); width: 74%; aspect-ratio: 1; border-radius: inherit; background: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 900; color: var(--ink); }
.quality-metric.compact .donut { width: 102px; }
.quality-bars { display: grid; gap: 9px; min-width: 0; }
.dashboard-bars { display: grid; gap: 10px; align-content: start; }
.dashboard-bar-row { display: grid; gap: 5px; }
.dashboard-bar-label { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dashboard-bar-label strong { color: var(--ink); font-size: 12px; text-align: right; }
.dashboard-bar-track { height: 9px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.dashboard-bar-track i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: #64748b; }
.dashboard-bar-track i.ok { background: var(--ok); }
.dashboard-bar-track i.warn { background: var(--warn); }
.dashboard-bar-track i.bad { background: var(--danger); }
.action-list { display: grid; gap: 8px; }
.action-item { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 8px 0; font-weight: 700; cursor: pointer; }
.action-item span { color: var(--muted); }
.form-panel { background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
.compact-form { padding: 8px 10px; gap: 6px; overflow: auto; }
.compact-form .form-grid { grid-template-columns: repeat(4, minmax(112px, 1fr)); gap: 6px 8px; align-items: end; }
.compact-form label { gap: 3px; font-size: 11px; }
.compact-form input, .compact-form select, .compact-form textarea { padding: 4px 7px; min-height: 26px; }
.compact-form textarea { height: 28px; min-height: 28px; }
.compact-form .wide { grid-column: 1 / -1; }
.compact-form .span-2 { grid-column: span 2; }
.compact-form .span-3 { grid-column: span 3; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
.defect-editor-cell { padding: 0; border: 0; }
.modal-card.defect-mode .modal-common-row { grid-template-columns: 1fr; }
.modal-card.defect-mode .common-tools { display: none; }
.modal-card.defect-mode .modal-list-panel .section-title { display: none; }
.modal-card.defect-mode .modal-body { grid-template-rows: auto minmax(0, 1fr); }
.modal-card.defect-mode .modal-body { gap: 10px; }
.modal-card.defect-mode .modal-list-panel { background: transparent; border: 0; padding: 0; }
.modal-card.defect-mode .modal-header h2 { font-size: 32px; line-height: 1; }
.modal-card.defect-mode .modal-header .eyebrow { font-size: 13px; font-weight: 800; }
.modal-card.defect-mode .compact-form { padding: 5px 10px; max-height: 116px; overflow: hidden; }
.modal-card.defect-mode .compact-form .form-grid { grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 4px 10px; }
.modal-card.defect-mode .compact-form label { font-size: 12px; font-weight: 600; color: #475569; }
.modal-card.defect-mode .compact-form input, .modal-card.defect-mode .compact-form select, .modal-card.defect-mode .compact-form textarea { min-height: 30px; padding: 5px 8px; font-size: 14px; font-weight: 500; }
.modal-card.defect-mode .compact-form textarea { height: 30px; min-height: 30px; }
.defect-section-card { display: grid; gap: 8px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.defect-section-card > .section-title { display: flex !important; }
.defect-section-card > .section-title h2 { font-size: 20px; font-weight: 800; }
.defect-section-card > .section-title .muted { font-size: 14px; font-weight: 600; }
.defect-related-table, .defect-analysis-table { width: 100%; min-width: 920px; }
.defect-related-table th, .defect-analysis-table th { color: #a00000; background: #fff3f3; font-weight: 700; text-align: center; font-size: 15px; padding: 10px 9px; }
.defect-related-table th, .defect-related-table td { font-size: 15px; font-weight: 500; }
.defect-analysis-table col.content-col { width: auto; }
.defect-analysis-table col.owner-col { width: 130px; }
.defect-analysis-table col.date-col { width: 130px; }
.defect-analysis-table col.status-col { width: 130px; }
.defect-analysis-table td { vertical-align: top; }
.defect-action-label { width: 150px; font-weight: 600; font-size: 15px; color: var(--ink); background: #fff; }
.defect-meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.defect-meta-grid label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.defect-meta-grid input, .defect-meta-grid select { min-height: 34px; }
.defect-analysis-table textarea { width: 100%; min-height: 108px; border: 0; resize: vertical; background: transparent; line-height: 1.45; font-size: 15px; font-weight: 500; }
.defect-analysis-table textarea.compact { min-height: 56px; }
.defect-analysis-table input, .defect-analysis-table select { width: 100%; border: 0; background: transparent; min-height: 34px; font-size: 15px; font-weight: 500; }
.defect-analysis-table tbody tr:hover td, .defect-related-table tbody tr:hover td { background: #fff; }
.defect-analysis-table textarea:focus, .defect-analysis-table input:focus, .defect-analysis-table select:focus { outline: 1px solid #cbd5e1; background: #fff; }
.defect-workspace { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 10px; min-width: min(1180px, calc(100vw - 80px)); }
.defect-workspace label { display: grid; gap: 4px; font-size: 12px; font-weight: 800; color: var(--muted); }
.defect-workspace input, .defect-workspace select, .defect-workspace textarea { width: 100%; }
.defect-workspace textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.defect-workspace .wide { grid-column: 1 / -1; }
.list-table-wrap { max-height: calc(100vh - 245px); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px; }
th, td { border: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #fff7f7; color: #991b1b; white-space: nowrap; }
tbody tr:hover td { background: #fffafa; }
.modal-line-wrap tbody tr:hover td,
.modal-line-wrap tbody tr:focus-within td {
  background: #bbf7d0;
}
.modal-line-wrap tbody tr:hover .sticky-col,
.modal-line-wrap tbody tr:focus-within .sticky-col {
  background: #bbf7d0;
}
.modal-line-wrap tbody tr:focus-within td {
  box-shadow: inset 0 1px 0 #22c55e, inset 0 -1px 0 #22c55e;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; color: var(--ink); }
.muted-cell { text-align: center; color: var(--muted); padding: 28px; }
.status-ok { color: var(--ok); font-weight: 700; }
.status-warn { color: var(--warn); font-weight: 700; }
.status-bad { color: var(--danger); font-weight: 700; }
.pill { display: inline-flex; min-height: 24px; align-items: center; border-radius: 999px; padding: 3px 8px; background: #f2f4f7; color: var(--ink); font-weight: 800; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fffbeb; color: var(--warn); }
.pill.bad { background: #fee2e2; color: var(--danger); }
.clickable-row { cursor: pointer; }
.modal-line-wrap { min-height: 0; height: 100%; max-height: none; border: 1px solid var(--line); border-radius: 8px; }
.modal-line-wrap input, .modal-line-wrap select { min-width: 120px; width: 100%; border: 0; border-radius: 4px; padding: 6px; background: #fff; }
.modal-line-wrap .sticky-index { left: 0; width: 44px; min-width: 44px; max-width: 44px; text-align: right; }
.modal-line-wrap .sticky-line-1 { left: 44px; min-width: 170px; width: 170px; max-width: 170px; }
.modal-line-wrap .sticky-line-2 { left: 214px; min-width: 160px; width: 160px; max-width: 160px; }
.modal-line-wrap .sticky-line-3 { left: 374px; min-width: 280px; width: 280px; max-width: 280px; }
.modal-line-wrap .sticky-col { position: sticky; z-index: 3; background: #fff; box-shadow: 1px 0 0 var(--line); }
.modal-line-wrap th.sticky-col { z-index: 5; background: #fff7f7; }
.line-photo-actions { display: flex; gap: 6px; min-width: 150px; }
.line-toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: start; }
.line-filters { display: grid; grid-template-columns: minmax(160px, 1.3fr) repeat(3, minmax(110px, 1fr)) auto; gap: 7px; align-items: end; }
.line-filters label { min-width: 0; }
.line-filters input, .line-filters select { width: 100%; min-height: 30px; padding: 5px 7px; }
.line-filters button { min-height: 30px; padding: 5px 10px; }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.segment { min-height: 28px; padding: 4px 9px; border-color: transparent; background: transparent; color: var(--ink); font-size: 12px; }
.segment.active { background: var(--red); border-color: var(--red); color: #fff; }
.line-view-switch { justify-self: start; max-width: 100%; }
.oqc-pcba-tabs { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.oqc-pcba-tabs .pcbaSelect { width: 18px; height: 18px; accent-color: var(--red); }
.oqc-pcba-tabs .pcba-nav { width: 34px; min-height: 32px; padding: 0; background: #fff; color: #0f172a; border: 1px solid #d9e2ef; box-shadow: none; }
.oqc-pcba-tabs .pcba-nav:disabled { opacity: .4; cursor: not-allowed; }
.oqc-pcba-tabs .pcba-page { min-width: 118px; text-align: center; font-weight: 700; color: #0f172a; }
.pqc-line-tab { min-width: 76px; min-height: 32px; padding: 6px 10px; border: 1px solid #d9e2ef; background: #fff; color: #0f172a; box-shadow: none; border-radius: 6px; font-weight: 800; text-align: center; }
.pqc-line-tab.active { background: var(--red); border-color: var(--red); color: #fff; }
.pqc-line-tab.ok:not(.active) { border-color: #86efac; background: #ecfdf3; color: #047857; }
.pqc-line-tab.bad:not(.active) { border-color: #fecaca; background: #fff1f2; color: #b91c1c; }
.oqc-pcba-info { display: grid; grid-template-columns: minmax(160px, 230px) minmax(140px, 180px) auto; gap: 8px; align-items: end; padding: 0; background: transparent; }
.oqc-pcba-info label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.oqc-pcba-info input { min-height: 32px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.oqc-pcba-photo-actions { display: flex; gap: 6px; align-items: end; padding-bottom: 0; }
.line-col-hidden { display: none; }
.line-filter-info { margin: -4px 0 0; }
.mini { min-height: 28px; padding: 4px 8px; font-size: 12px; }
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .58); padding: 18px; z-index: 20; overflow: auto; }
.modal.hidden { display: none; }
.modal-card { width: min(1380px, 98vw); height: min(880px, 96vh); min-width: 720px; min-height: 560px; max-width: 98vw; max-height: 96vh; margin: 0 auto; background: var(--bg); border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; grid-template-rows: auto 1fr; overflow: hidden; resize: both; }
.camera-card { width: min(860px, 96vw); height: min(760px, 96vh); min-width: 520px; min-height: 420px; max-width: 96vw; max-height: 96vh; margin: 0 auto; background: var(--bg); border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; grid-template-rows: auto 1fr; overflow: hidden; resize: both; }
.email-card { width: min(1180px, 96vw); height: min(820px, 94vh); min-width: 720px; min-height: 520px; max-width: 96vw; max-height: 94vh; margin: 0 auto; background: var(--bg); border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; grid-template-rows: auto 1fr; overflow: hidden; resize: both; }
.gallery-card { width: min(1180px, 96vw); height: min(860px, 94vh); min-width: 720px; min-height: 520px; max-width: 96vw; max-height: 94vh; margin: 0 auto; background: var(--bg); border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; grid-template-rows: auto 1fr; overflow: hidden; resize: both; }
.modal-header { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.modal-body { min-height: 0; display: grid; grid-template-rows: minmax(120px, 1.35fr) minmax(0, 3.65fr); gap: 8px; padding: 8px; overflow: hidden; }
.modal-common-row { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); gap: 10px; align-items: stretch; }
.common-tools { padding: 8px; gap: 6px; align-content: start; overflow: auto; }
.modal-list-panel { min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
.camera-body { padding: 12px; overflow: auto; }
.camera-body video { width: 100%; max-height: 620px; background: #111827; border-radius: 8px; }
.camera-select-label { display: flex; grid-template-columns: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.camera-select-label select { width: min(280px, 38vw); min-height: 34px; }
.camera-serial-label { display: flex; grid-template-columns: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.camera-serial-label input { width: min(220px, 30vw); min-height: 34px; }
.email-body { min-height: 0; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; padding: 12px; overflow: hidden; }
.email-fields { align-content: start; }
.email-fields input { width: 100%; }
.email-preview { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.photo-gallery-body { overflow: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-content: start; }
.photo-gallery-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.photo-gallery-item img { width: 100%; max-height: 520px; object-fit: contain; background: #111827; border-radius: 6px; }
.photo-gallery-item figcaption { color: var(--muted); font-size: 12px; font-weight: 700; word-break: break-word; }
.photo-gallery-actions { display: flex; justify-content: flex-end; }
.guide-panel { gap: 14px; }
.guide-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.guide-tab-button { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.guide-tab-button.active { background: var(--red); border-color: var(--red); color: #fff; }
.guide-tab-panel { display: none; }
.guide-tab-panel.active { display: block; }
.pfd-panel { gap: 12px; }
.pfd-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pfd-meta-grid div { border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; padding: 8px 10px; display: grid; gap: 3px; }
.pfd-meta-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }
.pfd-meta-grid strong { color: var(--ink); font-size: 15px; }
.pfd-legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pfd-legend-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: 12px; font-weight: 800; }
.pfd-flow-strip { display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 12px; }
.pfd-flow-card { position: relative; flex: 0 0 132px; min-height: 96px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 8px; display: grid; justify-items: center; align-content: start; gap: 6px; text-align: center; }
.pfd-flow-card::after { content: ""; position: absolute; top: 36px; right: -11px; width: 11px; height: 2px; background: #cbd5e1; }
.pfd-flow-card:last-child::after { display: none; }
.pfd-flow-card strong { font-size: 12px; color: var(--ink); line-height: 1.2; }
.pfd-flow-card > span:not(.pfd-flow-icon) { color: var(--muted); font-size: 11px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pfd-flow-icon { width: 42px; height: 32px; display: inline-grid; place-items: center; position: relative; color: #0f172a; font-size: 11px; font-weight: 900; line-height: 1; }
.pfd-flow-icon span { position: relative; z-index: 1; }
.pfd-flow-icon.process { border: 2px solid #2563eb; background: #eff6ff; border-radius: 6px; }
.pfd-flow-icon.inspect { border: 2px solid #16a34a; background: #ecfdf3; transform: rotate(45deg); width: 34px; height: 34px; border-radius: 5px; }
.pfd-flow-icon.inspect span { transform: rotate(-45deg); }
.pfd-flow-icon.move { width: 46px; height: 24px; background: #fff7ed; border: 2px solid #f97316; clip-path: polygon(0 18%, 70% 18%, 70% 0, 100% 50%, 70% 100%, 70% 82%, 0 82%); }
.pfd-flow-icon.store { width: 40px; height: 34px; border: 2px solid #64748b; background: #f8fafc; border-radius: 50% / 18%; }
.pfd-flow-icon.label { border: 2px solid #7c3aed; background: #f5f3ff; border-radius: 4px; }
.pfd-flow-icon.pack { border: 2px solid #b45309; background: #fffbeb; border-radius: 2px; }
.pfd-flow-icon.rework { border: 2px dashed #dc2626; background: #fef2f2; border-radius: 999px; }
.pfd-icon-cell { text-align: center; vertical-align: middle; }
.pfd-edit-col { display: none; }
.pfd-editing .pfd-edit-col { display: table-cell; }
.pfd-edit-input { width: 100%; min-width: 0; border: 1px solid #cbd5e1; border-radius: 5px; padding: 5px 6px; background: #fff; font-size: 12px; line-height: 1.35; }
textarea.pfd-edit-input { min-height: 74px; resize: vertical; }
input.pfd-edit-input { min-height: 30px; }
.pfd-hidden-row td { background: #f8fafc; color: #94a3b8; }
.pfd-hide-check { display: inline-flex; align-items: center; gap: 6px; min-width: 72px; color: var(--ink); }
.pfd-hide-check input { width: auto; min-width: 0; }
.pfd-table-wrap { max-height: calc(100vh - 260px); border: 1px solid var(--line); border-radius: 8px; }
.pfd-table { min-width: 1620px; width: 100%; }
.pfd-table th { text-align: center; vertical-align: middle; }
.pfd-table td { white-space: pre-line; line-height: 1.45; font-size: 12px; }
.pfd-table th:nth-child(1), .pfd-table td:nth-child(1) { width: 48px; }
.pfd-table th:nth-child(2), .pfd-table td:nth-child(2) { width: 70px; }
.pfd-table th:nth-child(3), .pfd-table td:nth-child(3) { width: 135px; }
.pfd-table th:nth-child(4), .pfd-table td:nth-child(4) { width: 140px; }
.pfd-table th:nth-child(5), .pfd-table td:nth-child(5) { width: 360px; }
.pfd-table th:nth-child(6), .pfd-table td:nth-child(6), .pfd-table th:nth-child(8), .pfd-table td:nth-child(8) { width: 70px; text-align: center; }
.pfd-table th:nth-child(7), .pfd-table td:nth-child(7), .pfd-table th:nth-child(9), .pfd-table td:nth-child(9) { width: 330px; }
.pfd-table th:nth-child(10), .pfd-table td:nth-child(10) { width: 84px; text-align: center; }
.quality-policy-document {
  max-width: 760px;
  margin: 0 auto;
  padding: 42px 54px 34px;
  background: #fff;
  border: 1px solid #d0d5dd;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
  color: #111827;
  font-family: "Times New Roman", Times, serif;
  font-size: 15px;
  line-height: 1.55;
}
.quality-policy-header { text-align: center; margin-bottom: 26px; }
.quality-policy-header h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; text-transform: uppercase; color: #111827; letter-spacing: 0; }
.quality-policy-header p { margin: 0; font-size: 16px; font-weight: 700; }
.quality-policy-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 12px;
}
.quality-policy-list li { padding-left: 4px; }
.quality-policy-list strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}
.quality-policy-list p { margin: 0; text-align: justify; }
.quality-policy-signature {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.quality-policy-signature p {
  width: min(360px, 58%);
  margin: 0 0 6px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}
.quality-policy-signature img { width: min(360px, 58%); max-height: 240px; height: auto; object-fit: contain; }
.guide-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; align-items: start; }
.guide-flow { position: sticky; top: 16px; align-content: start; }
.flow-steps { display: grid; gap: 10px; }
.flow-step { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 10px 10px 48px; display: grid; gap: 3px; }
.flow-step strong { position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 12px; }
.flow-step span { font-weight: 800; }
.flow-step small { color: var(--muted); font-weight: 700; line-height: 1.35; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.guide-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; display: grid; gap: 8px; }
.guide-card.guide-primary { grid-column: 1 / -1; background: #fffafa; border-color: #fecaca; }
.guide-card p { margin: 0; color: #344054; line-height: 1.45; }
.guide-card ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; color: #344054; line-height: 1.42; }
.guide-card li { padding-left: 2px; }
.quality-objective-grid {
  display: block;
  max-width: 900px;
  margin: 0 auto;
  padding: 42px 56px;
  background: #fff;
  border: 1px solid #d0d5dd;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
  color: #111827;
}
.quality-objective-grid .guide-card {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: block;
}
.quality-objective-grid .guide-card + .guide-card { margin-top: 18px; }
.quality-objective-grid .guide-card.guide-primary {
  background: transparent;
  border: 0;
  text-align: center;
  margin-bottom: 26px;
}
.quality-objective-grid .guide-card.guide-primary h2 {
  margin: 0 0 16px;
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: 0;
}
.quality-objective-grid .guide-card.guide-primary p {
  text-align: justify;
  font-size: 15px;
  color: #111827;
}
.quality-objective-grid .guide-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #111827;
}
.quality-objective-grid .guide-card ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: block;
  color: #111827;
  line-height: 1.7;
}
.quality-objective-grid .guide-card li {
  padding-left: 0;
  margin: 0 0 6px;
  text-align: justify;
}
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr); gap: 14px; align-items: start; }
.user-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.user-form-grid .span-2 { grid-column: 1 / -1; }
.settings-actions { justify-content: flex-end; margin-top: 12px; }
.archive-passed-docs.is-loading { background: #fff7ed; border-color: #f97316; color: #9a3412; cursor: wait; }
.archive-passed-docs:disabled { opacity: .72; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #111827; color: #fff; padding: 12px 14px; border-radius: 8px; max-width: 460px; box-shadow: 0 16px 38px rgba(0,0,0,.18); z-index: 40; }
.hidden { display: none; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .main-nav { border-right: 0; border-bottom: 1px solid var(--line); }
  .vertical-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-topbar { align-items: flex-start; flex-direction: column; }
  .dashboard-grid, .stage-grid, .pqc-environment-grid, .guide-layout, .pfd-meta-grid, .settings-grid, .user-form-grid, .quality-progress-body, .quality-metric, .quality-metric.compact, .defect-workspace { grid-template-columns: 1fr; }
  .user-form-grid .span-2 { grid-column: auto; }
  .guide-flow { position: static; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-body { grid-template-rows: auto minmax(0, 1fr); overflow: auto; }
  .modal-common-row, .compact-form .form-grid, .line-toolbar, .line-filters, .email-body { grid-template-columns: 1fr; }
  .email-card, .gallery-card { min-width: 0; width: 100%; }
  .compact-form .span-2, .compact-form .span-3 { grid-column: 1 / -1; }
  .line-view-switch { justify-self: stretch; max-width: none; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .main-nav, .main-view:not(#view-guide), #view-guide .list-topbar .actions, .toast { display: none !important; }
  .app-shell, .main-content, #view-guide, .guide-grid { display: block; }
  .main-content { padding: 0; }
  .panel, .guide-card { border-color: #999; break-inside: avoid; page-break-inside: avoid; }
}
