/* OP_Roasting - checklist khu rang. Mau theo trang chu iLD (navy, vang, nau rang).
   To phieu (.sheet) ve giong ban giay: o ke, chu Times, dau phieu 3 cot, dong ky cuoi phieu. Khong dung style inline. */
:root {
  --ink: #20262b; --muted: #55616b; --line: #dde2e7; --paper: #eef1f4; --card: #fff; --card-2: #f6f8fa;
  --navy: #31465c; --navy-d: #243546; --gold: #d1a13a; --roast: #704424; --roast-l: #f6eee6;
  --sheet: #fff; --sheet-ink: #111; --grid: #4b5157; --grid-2: #b9c0c7; --head-bg: #f3f4f5;
  --focus: #1e73d2;
  --ok: #146c3f; --ok-bg: #e5f3ea; --bad: #b42318; --bad-bg: #fdecea; --warn: #9a5b00; --warn-bg: #fff3dd;
  --info: #1d5fa8; --info-bg: #e5effa; --neu: #55616b; --neu-bg: #eceff2;
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --serif: "Times New Roman", Times, Cambria, "Noto Serif", serif;
  --r: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6ebf1; --muted: #a2adb9; --line: #2e3946; --paper: #11161c; --card: #18202a; --card-2: #1d2631;
    --navy: #8fb0d3; --roast-l: #2b2119; --sheet: #161d26; --sheet-ink: #e8edf2; --grid: #6b7886; --grid-2: #34404d; --head-bg: #1e2732;
    --ok: #5fcf8f; --ok-bg: #12301f; --bad: #ff8a80; --bad-bg: #3b1714; --warn: #f0b85a; --warn-bg: #36280d;
    --info: #8cbcf2; --info-bg: #142a42; --neu: #a2adb9; --neu-bg: #232c37; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e6ebf1; --muted: #a2adb9; --line: #2e3946; --paper: #11161c; --card: #18202a; --card-2: #1d2631;
  --navy: #8fb0d3; --roast-l: #2b2119; --sheet: #161d26; --sheet-ink: #e8edf2; --grid: #6b7886; --grid-2: #34404d; --head-bg: #1e2732;
  --ok: #5fcf8f; --ok-bg: #12301f; --bad: #ff8a80; --bad-bg: #3b1714; --warn: #f0b85a; --warn-bg: #36280d;
  --info: #8cbcf2; --info-bg: #142a42; --neu: #a2adb9; --neu-bg: #232c37; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.en { display: block; color: var(--muted); font-size: 12.5px; font-style: italic; font-weight: 400; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Thanh tieu de ---------- */
.apphead { background: var(--navy-d); color: #fff; border-bottom: 3px solid var(--gold); }
.apphead .wrap { display: flex; align-items: center; gap: 12px; min-height: 54px; flex-wrap: wrap; padding-block: 6px; }
.apphead h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.apphead h1 a { color: inherit; text-decoration: none; }
.apphead h1 small { display: block; font-size: 12px; font-weight: 400; opacity: .8; }
.apphead .sp { flex: 1; }
.who { font-size: 13px; text-align: right; line-height: 1.3; }
.who b { display: block; font-size: 14px; }
.lvl { display: inline-block; margin-top: 2px; padding: 1px 8px; border-radius: 99px; background: rgba(255, 255, 255, .14); font-size: 12px; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 46px; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--navy-d); border-bottom-color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab.on { color: #fff; } }
:root[data-theme="dark"] .tab.on { color: #fff; }
.cnt { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--neu-bg); color: var(--neu); font-size: 12.5px; display: inline-grid; place-items: center; }
.cnt.hot { background: var(--warn); color: #fff; }

/* ---------- Nut, badge ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy-d); border-color: var(--navy-d); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-bad { background: var(--card); border-color: var(--bad); color: var(--bad); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: #3d5a78; border-color: #3d5a78; } :root:not([data-theme="light"]) .btn-ok { color: #0b1f14; } }
:root[data-theme="dark"] .btn-primary { background: #3d5a78; border-color: #3d5a78; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; font-family: var(--sans); font-style: normal; }
.b-ok { color: var(--ok); background: var(--ok-bg); } .b-bad { color: var(--bad); background: var(--bad-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); } .b-info { color: var(--info); background: var(--info-bg); }
.b-neu { color: var(--neu); background: var(--neu-bg); } .b-she { color: #fff; background: var(--roast); }
.b-out { border: 1px solid var(--line); color: var(--muted); background: transparent; font-weight: 500; }

/* ---------- Bo cuc ---------- */
main { padding: 14px 0 120px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { font-size: 15px; margin: 0; padding: 12px 14px 0; }
.pad { padding: 14px; } .mt { margin-top: 16px; }
.section-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
.section-h h2 { font-size: 18px; margin: 0; }
.section-h p { margin: 2px 0 0; }

.picker { padding: 14px 16px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: center; margin-bottom: 16px; }
.picker-l { font-weight: 700; font-size: 16px; }
.picker-l small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.form-select { width: 100%; min-height: 48px; padding: 0 12px; font-size: 16px; font-weight: 600; border: 2px solid var(--navy); border-radius: 8px; background: var(--card); }
.picker > p, .selmeta { grid-column: 2; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; }
@media (max-width: 600px) { .picker { grid-template-columns: 1fr; } .picker > p, .selmeta { grid-column: 1; } }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 12px; border-bottom: 1px solid var(--line); }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); font-weight: 600; }
.filters input, .filters select { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); min-width: 140px; font-weight: 400; color: var(--ink); }
.filters .grow { flex: 1; min-width: 200px; }
.filters .grow input { width: 100%; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { background: var(--card-2); text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--card-2); }
.docno { font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px; font-size: 14px; }
@media (max-width: 760px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.list td { border: 0; padding: 2px 0; }
  table.list td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 13px; }
}

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); font-weight: 600; text-decoration: none; margin-bottom: 10px; }
.statusrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 12px; font-size: 14px; }
.progress { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pbar { width: 140px; height: 8px; background: var(--neu-bg); border-radius: 99px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--ok); }
.alert { padding: 12px 14px; border-radius: var(--r); border: 1px solid; margin: 0 0 12px; }
.alert-bad { background: var(--bad-bg); border-color: var(--bad); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: var(--info); }
.alert h3 { margin: 0 0 4px; font-size: 15px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; max-height: 220px; overflow: auto; }
.alert a { color: inherit; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; font-weight: 600; }
.field > span i { color: var(--bad); font-style: normal; }
.field input, .field select, .field textarea { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); width: 100%; }
input:disabled, select:disabled, textarea:disabled { color: var(--sheet-ink); -webkit-text-fill-color: var(--sheet-ink); opacity: 1; }

/* =================== TO PHIEU (giong ban giay) =================== */
.sheet-scroll { overflow-x: auto; }
.sheet { background: var(--sheet); color: var(--sheet-ink); border: 1.5px solid var(--grid); font-family: var(--serif); box-shadow: 0 2px 10px rgba(16, 24, 40, .08); min-width: 0; }
.sheet .en { font-family: var(--serif); color: inherit; opacity: .75; font-size: 13px; }

.sh-head { display: grid; grid-template-columns: 190px minmax(0, 1fr) 270px; border-bottom: 1.5px solid var(--grid); }
.sh-logo { border-right: 1px solid var(--grid); display: grid; grid-template-rows: 1fr auto auto; text-align: center; font-size: 13px; }
.sh-logo .ild { display: flex; justify-content: center; align-items: center; padding: 10px 8px; background: #fff; }   /* logo luon tren nen trang (ca che do toi) */
.sh-logo .ild img { width: 101px; height: auto; display: block; }
.sh-logo .co, .sh-logo .dept { border-top: 1px solid var(--grid); padding: 3px 4px; }
.sh-title { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 10px 14px; }
.sh-title h2 { margin: 0; font-size: 25px; font-weight: 700; line-height: 1.2; text-wrap: balance; letter-spacing: .3px; }
.sh-title p { margin: 4px 0 0; font-size: 14px; opacity: .75; font-style: italic; }
.sh-info { border-left: 1px solid var(--grid); display: flex; flex-direction: column; }
.hrow { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--grid); min-height: 30px; font-size: 14px; }
.hrow:last-child { border-bottom: 0; }
.hrow label, .hrow .lbl { padding: 0 6px; white-space: nowrap; }
.hrow label i { color: #d0202a; font-style: normal; margin-left: 2px; }
.hrow .val { padding: 0 6px; }
.hrow input, .hrow select { width: 100%; height: 100%; min-height: 30px; border: 0; border-left: 1px dotted var(--grid-2); background: transparent; padding: 0 6px; font-family: var(--sans); font-size: 14.5px; color: var(--sheet-ink); }
.hrow input:focus, .hrow select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--card); }

.tbl-paper { overflow-x: auto; }
table.paper { width: 100%; border-collapse: collapse; font-size: 15px; }
table.paper th, table.paper td { border: 1px solid var(--grid); padding: 6px 8px; vertical-align: middle; }
table.paper thead th { font-weight: 700; text-align: center; background: var(--head-bg); line-height: 1.25; font-size: 14.5px; }
table.paper thead th .en { font-size: 13px; }
table.paper tr:first-child th { border-top: 0; }
table.paper th:first-child, table.paper td:first-child { border-left: 0; }
table.paper th:last-child, table.paper td:last-child { border-right: 0; }
table.paper tr.grp th { text-align: center; font-size: 16px; letter-spacing: 1px; background: var(--head-bg); }
.c-no { width: 44px; text-align: center; }
.c-area { width: 150px; text-align: center; font-weight: 700; font-size: 14px; }
.c-desc .vi { display: block; }
.c-desc .she { display: inline-flex; align-items: center; gap: 3px; margin-top: 3px; padding: 0 6px; border-radius: 4px; background: var(--roast); color: #fff; font: 600 11px/1.6 var(--sans); }
.c-desc .she svg { width: 12px; height: 12px; }
.c-desc .hint { display: block; margin-top: 3px; font-size: 13px; color: var(--warn); font-family: var(--sans); }
.c-freq, .c-mat, .c-qty, .c-std, .c-unit { text-align: center; white-space: nowrap; }
.c-qty { font-weight: 700; font-size: 17px; }
.c-ref { width: 150px; text-align: center; padding: 3px; }
.c-ref img { width: 140px; height: 96px; object-fit: cover; display: block; margin: auto; cursor: zoom-in; }
.paper-F009 .c-ref img { height: 104px; }
.c-photo { width: 220px; text-align: center; }
.c-status { width: 270px; font-family: var(--sans); }
.c-note { width: 230px; font-family: var(--sans); }
.paper-F009 .c-status { width: 200px; }
.paper-F006 .c-desc { width: 27%; min-width: 220px; } .paper-F006 .c-ref { width: 150px; } .paper-F006 .c-ref img { width: 140px; height: 96px; } .paper-F006 .c-std { width: 76px; white-space: normal; } .paper-F006 .c-unit { width: 52px; }
.paper-F006 .c-status { width: 200px; } .paper-F006 .c-note { width: 26%; min-width: 220px; } .paper-F006 .c-note input, .paper-F006 .c-note textarea { width: 100%; }
.paper-F004 .c-mat { width: 90px; } .paper-F004 .c-qty { width: 80px; } .paper-F003 .c-freq { width: 130px; white-space: normal; }

/* Nut ket qua trong o */
.tgs { display: flex; gap: 4px; }
.tg { flex: 1 1 auto; white-space: nowrap; min-height: 38px; min-width: 50px; padding: 0 6px; border: 1px solid var(--grid-2); border-radius: 6px; background: var(--card); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.tg:hover:not(:disabled) { border-color: var(--grid); }
.tg:disabled { cursor: default; opacity: .55; }
.tg.on { opacity: 1; }
.tg-ok.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tg-ng.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.tg-na.on { background: var(--neu); border-color: var(--neu); color: #fff; }
.numwrap .tg-na { flex: none; min-height: 38px; }
.numwrap { display: flex; align-items: center; gap: 6px; }
.num-in { width: 92px; min-height: 38px; padding: 0 8px; border: 1px solid var(--grid-2); border-radius: 6px; font-size: 17px; text-align: right; font-variant-numeric: tabular-nums; background: var(--card); }
.unit { color: var(--muted); font-size: 13.5px; }
.note-in { width: 100%; min-height: 38px; padding: 4px 8px; border: 1px solid var(--grid-2); border-radius: 6px; background: var(--card); font-size: 14px; }
.c-status .note-in { margin-top: 6px; }
.note-in.req { border-color: var(--bad); background: var(--bad-bg); }
.note-in.req::placeholder { color: var(--bad); }
.note-ro { display: block; font-size: 14px; white-space: pre-wrap; }
.c-status .note-ro { margin-top: 6px; }
tr.is-ng .note-ro { color: var(--bad); font-weight: 600; }
.notewrap { display: flex; gap: 6px; align-items: center; }
.camb { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--grid-2); border-radius: 6px; cursor: pointer; color: var(--muted); background: var(--card); }
.camb:hover { color: var(--ink); border-color: var(--grid); }
.camb input, .addph input { display: none; }
.photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; justify-content: center; }
.c-note .photos { justify-content: flex-start; }
.ph { position: relative; }
.ph img { width: 72px; height: 54px; object-fit: cover; border: 1px solid var(--grid-2); cursor: zoom-in; display: block; border-radius: 4px; }
.c-photo .ph img { width: 96px; height: 72px; }
.ph button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; }
.ph button svg { width: 13px; height: 13px; }
.c-photo .addph { margin-top: 6px; }

/* Trang thai dong */
tr.is-ng td.c-status, tr.is-ng td.c-note { background: var(--bad-bg); }
tr.is-ng td.c-no { box-shadow: inset 4px 0 0 var(--bad); }
tr.is-ok td.c-no { box-shadow: inset 4px 0 0 var(--ok); }
tr.is-na td.c-no { box-shadow: inset 4px 0 0 var(--neu); }
tr.is-auto td:not(.c-area) { color: var(--muted); }
tr.flash td:not(.c-area) { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: var(--warn-bg); } }

/* Dong ky cuoi phieu */
.sh-sign { display: grid; grid-template-columns: 1fr 1fr; border-top: 1.5px solid var(--grid); font-size: 15px; }
.sh-sign > div { padding: 10px 12px; min-height: 56px; }
.sh-sign > div + div { border-left: 1px solid var(--grid); }
.sh-sign .lbl { font-weight: 700; text-decoration: underline; }
.sh-sign small { font-family: var(--sans); font-size: 13px; }
.stamp { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border: 2px solid var(--ok); color: var(--ok); border-radius: 4px; font: 700 12.5px/1.5 var(--sans); transform: rotate(-3deg); vertical-align: middle; }
.stamp svg { width: 14px; height: 14px; }
.cmt { margin-top: 6px; font-size: 14px; font-style: italic; }
.sheet-foot { display: flex; flex-direction: column; gap: 2px; margin: 8px 2px 0; font-size: 13px; color: var(--muted); }

/* Bien ban rang */
table.rec { font-size: 14px; }
table.rec thead th { font-size: 13px; padding: 4px; min-width: 64px; }
table.rec td { padding: 0; font-family: var(--sans); }
table.rec td.c-no { padding: 0 4px; }
table.rec td input, table.rec td select { width: 100%; min-width: 64px; min-height: 36px; border: 0; padding: 0 6px; background: transparent; font-variant-numeric: tabular-nums; color: var(--sheet-ink); }
table.rec td input.wide { min-width: 120px; }
table.rec td input:focus, table.rec td select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--card); }
table.paper td.calc { background: var(--head-bg); text-align: right; padding: 0 8px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--sans); }
table.paper td.calc.ng { color: var(--bad); background: var(--bad-bg); }
table.rec td.del { width: 40px; text-align: center; }
table.sum { border-top: 1.5px solid var(--grid); }
table.sum thead th { font-size: 13px; }
table.sum td input { width: 100%; min-height: 36px; border: 0; padding: 0 6px; background: transparent; text-align: right; font-family: var(--sans); color: var(--sheet-ink); }
.addrow { margin: 0; padding: 6px 8px; border-top: 1px solid var(--grid); }
.std-line { margin: 0; padding: 6px 10px; border-top: 1.5px solid var(--grid); font-weight: 700; text-align: center; background: var(--head-bg); }
.formula { margin: 0; padding: 6px 10px; border-top: 1px solid var(--grid); font-style: italic; font-size: 14px; }

/* Dien thoai: bang ke o -> moi dong thanh 1 khoi, van giu thu tu cot cua phieu */
@media (max-width: 720px) {
  .sh-head { grid-template-columns: 1fr; }
  .sh-logo { display: none; }
  .sh-title h2 { font-size: 19px; }
  .sh-info { border-left: 0; border-top: 1px solid var(--grid); }
  .tbl-paper:not(:has(table.rec)):not(:has(table.sum)) { overflow: visible; }
  table.paper:not(.rec):not(.sum) thead { display: none; }
  table.paper:not(.rec):not(.sum), table.paper:not(.rec):not(.sum) tbody { display: block; }
  table.paper:not(.rec):not(.sum) tr { display: grid; grid-template-columns: 40px minmax(0, 1fr); border-bottom: 1px solid var(--grid); padding: 8px 10px 10px 0; gap: 4px 8px; }
  table.paper:not(.rec):not(.sum) tr.first::before { content: attr(data-area); grid-column: 1 / -1; margin: -8px -10px 4px 0; padding: 5px 10px; background: var(--head-bg); font-weight: 700; font-size: 13.5px; border-bottom: 1px solid var(--grid-2); }
  table.paper:not(.rec):not(.sum) tr.grp { display: block; padding: 0; }
  table.paper:not(.rec):not(.sum) tr.grp th { display: block; border: 0; }
  table.paper:not(.rec):not(.sum) td { display: block; border: 0; padding: 0; width: auto; text-align: left; }
  table.paper:not(.rec):not(.sum) td.c-area { display: none; }
  table.paper:not(.rec):not(.sum) td.c-no { grid-row: span 6; text-align: center; font-weight: 700; padding-top: 2px; }
  table.paper:not(.rec):not(.sum) td.c-ref img { width: 120px; height: 84px; margin: 0; }
  td.c-freq::before { content: "Tần suất: "; } td.c-mat::before { content: "Vật liệu: "; } td.c-qty::before { content: "Số lượng: "; }
  td.c-std::before { content: "Tiêu chuẩn: "; } td.c-unit::before { content: "Đơn vị: "; }
  td.c-freq, td.c-mat, td.c-qty, td.c-std, td.c-unit { font-size: 14px; font-weight: 400 !important; }
  td.c-freq::before, td.c-mat::before, td.c-qty::before, td.c-std::before, td.c-unit::before { opacity: .7; }
  .paper-F004 td.c-mat, .paper-F004 td.c-qty, .paper-F006 td.c-std, .paper-F006 td.c-unit { display: inline-block !important; margin-right: 14px; }
  .c-photo .photos { justify-content: flex-start; }
  tr.is-ng td.c-status, tr.is-ng td.c-note { background: transparent; }
  tr.is-ng { background: var(--bad-bg); }
  .tg { min-height: 44px; }
  .num-in, .note-in, .camb { min-height: 44px; }
  .camb { width: 44px; height: 44px; }
  .sh-sign { grid-template-columns: 1fr; }
  .sh-sign > div + div { border-left: 0; border-top: 1px solid var(--grid); }
}

/* ---------- Nhat ky, thanh thao tac ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 14px 12px; }
.timeline li { position: relative; padding: 8px 0 8px 22px; border-left: 2px solid var(--line); margin-left: 6px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--navy); }
.timeline li.t-approve::before { border-color: var(--ok); background: var(--ok); }
.timeline li.t-return::before, .timeline li.t-reopen::before { border-color: var(--bad); background: var(--bad); }
.timeline time { color: var(--muted); font-size: 13px; margin-left: 6px; }
.timeline .c { display: block; color: var(--muted); }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(0, 0, 0, .06); z-index: 20; padding-bottom: env(safe-area-inset-bottom, 0px); }
.actionbar .wrap { display: flex; align-items: center; gap: 10px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.actionbar .sp { flex: 1; }
.savest { font-size: 13px; color: var(--muted); }
.savest.err { color: var(--bad); font-weight: 600; }
@media (max-width: 600px) { .actionbar .btn { flex: 1; } }

/* ---------- Hop thoai, toast, xem anh ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 20, 26, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.dlg { background: var(--card); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.dlg header { padding: 16px 18px 6px; }
.dlg header h2 { font-size: 18px; margin: 0; }
.dlg .body { padding: 6px 18px 4px; display: grid; gap: 12px; }
.dlg footer { padding: 14px 18px 18px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dlg .ferr { color: var(--bad); font-weight: 600; font-size: 14px; min-height: 1em; margin: 0; }
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .86); z-index: 60; display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }
.toast { position: fixed; top: 14px; right: 14px; z-index: 70; padding: 10px 16px; border-radius: 10px; background: var(--navy-d); color: #fff; box-shadow: var(--shadow); max-width: min(420px, calc(100% - 28px)); font-weight: 600; }
.toast.bad { background: var(--bad); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.demo-bar { background: var(--gold); color: #20262b; font-size: 14px; }
.demo-bar .wrap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 44px; }
.demo-bar select { min-height: 34px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .25); padding: 0 8px; background: #fff; color: #20262b; }
.demo-bar .btn { background: #fff; color: #20262b; border-color: rgba(0, 0, 0, .25); }

/* ---------- Ban in: chi in to phieu ---------- */
@media print {
  @page { size: A4; margin: 8mm; }
  body { background: #fff; font-size: 11px; }
  .apphead, .tabs, .actionbar, .back, .no-print, .demo-bar, .statusrow, .alert, .camb, .addph, .ph button, .addrow, .picker, .card.pad { display: none !important; }
  main { padding: 0; } .wrap { width: 100%; }
  .sheet { box-shadow: none; --sheet: #fff; --sheet-ink: #000; --grid: #000; --head-bg: #fff; }
  table.paper { font-size: 11px; } table.paper th, table.paper td { padding: 3px 5px; }
  .tg:not(.on) { display: none; } .tg { min-height: 22px; border: 0; background: none !important; color: #000 !important; font-weight: 700; }
  .c-ref img { width: 90px; height: 62px; }
  tr { break-inside: avoid; }
}

/* ban 1.2 */
.exportbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.selcol, td:has(> .rowsel) { width: 40px; text-align: center; }
.rowsel, .selcol input { width: 20px; height: 20px; cursor: pointer; }
.chg { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; }
.chg del { color: var(--bad); }
.chg ins { color: var(--ok); text-decoration: none; font-weight: 600; }
.addrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline .chg li { border: 0; margin: 0; padding: 1px 0; list-style: disc; }
.timeline .chg li::before { display: none; }
.timeline li.t-edit_approved::before { border-color: var(--warn); background: var(--warn); }
.timeline li.t-copy::before { border-color: var(--info); }

/* ban 1.3: chon vung, Ctrl+D */
td.c-no.pick { cursor: pointer; user-select: none; }
td.c-no.pick:hover { background: var(--info-bg); }
table.paper tr.sel td { background: var(--info-bg) !important; }
table.paper tr.sel td.c-no { box-shadow: inset 4px 0 0 var(--info); font-weight: 700; }
table.rec td input.rsel { background: var(--info-bg); outline: 2px solid var(--info); outline-offset: -2px; }
.selbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 30; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--info); box-shadow: 0 6px 20px rgba(0,0,0,.18); font-size: 14px; max-width: calc(100% - 24px); }
.selbar > span { font-weight: 600; color: var(--info); padding: 0 4px; }
@media print { .selbar { display: none !important; } }

/* ban 1.4: quan tri */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 14px; }
.subnav a { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; background: var(--card); }
.subnav a.on { background: var(--navy-d); border-color: var(--navy-d); color: #fff; }
.tpl-sec { margin-bottom: 14px; }
.tpl-sec h3 { margin: 0 0 10px; font-size: 16px; }
.tpl-sec h4 { margin: 14px 0 6px; font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tpl-grid .field.wide { grid-column: span 2; }
@media (max-width: 600px) { .tpl-grid .field.wide { grid-column: auto; } }
table.mini { border-collapse: collapse; width: 100%; font-size: 14px; }
table.mini th { text-align: left; background: var(--card-2); padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mini td.ctr, table.mini th.ctr { text-align: center; }
table.mini input[type=text], table.mini input[type=number], table.mini select, table.mini textarea { width: 100%; min-height: 34px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-size: 14px; }
table.mini input[type=checkbox] { width: 18px; height: 18px; }
table.mini textarea { min-width: 220px; resize: vertical; }
.tpl-tbl td:nth-child(2) input { min-width: 110px; }
.tpl-tbl td input[type=number] { width: 80px; }
.tpl-tbl .refc { white-space: nowrap; }
.tpl-tbl .refc img { width: 64px; height: 44px; object-fit: cover; border-radius: 4px; vertical-align: middle; cursor: zoom-in; margin-right: 4px; }
.tpl-tbl .acts { white-space: nowrap; }
.tpl-tbl .acts .btn { padding: 0 6px; min-height: 30px; }
.btn.danger { color: var(--bad); }
.tbl-scroll { overflow-x: auto; }
.card-h.nopad { padding: 0 0 8px; }
table.mini.tpl-tbl { width: max-content; min-width: 100%; }
.tpl-tbl select { min-width: 140px; }
.tpl-tbl td:nth-child(2) input, .tpl-tbl td input[maxlength="60"] { min-width: 150px; }
.tpl-tbl input[maxlength="12"] { width: 72px; }
.tpl-tbl input[maxlength="120"] { min-width: 130px; }
.tpl-tbl input[maxlength="200"] { min-width: 170px; }
.tpl-tbl textarea { min-width: 240px; }
.tpl-tbl td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; font-weight: 700; }

/* 09/11/2026 - Quan tri -> Nguoi dung: ma tran quyen (bang that, cuon ngang tren dien thoai) */
.tbl-wrap { overflow-x: auto; }
table.perm-matrix { width: 100%; border-collapse: collapse; min-width: 560px; }
table.perm-matrix th, table.perm-matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.perm-matrix thead th { background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 600; }
table.perm-matrix tbody th { font-weight: 500; }
table.perm-matrix .c { text-align: center; }
table.perm-matrix input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.view-only { margin-top: 10px; }
.view-only h3 { display: flex; align-items: center; gap: 6px; }

/* v1.7: STD nhap tay, chon vung nhieu o, huy phieu */
.std-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; }
.std-line .sep { margin: 0 6px; font-weight: 400; }
.std-line input.std-in { width: 4.2em; padding: 3px 4px; text-align: center; font: inherit; font-weight: 700; border: 1px solid var(--grid); border-radius: 4px; background: var(--sheet); color: var(--sheet-ink); }
.std-line input.std-in:disabled { border-color: transparent; background: transparent; color: inherit; opacity: 1; }
.startno { margin: 0; padding: 4px 10px; text-align: left; }
table.rec td.rsel { background: var(--info-bg) !important; box-shadow: inset 0 0 0 1px var(--info); }
table.rec td.rsel input, table.rec td.rsel select { background: transparent; }
table.rec td.c-no { cursor: pointer; user-select: none; }
body.selecting, body.selecting * { user-select: none !important; cursor: cell; }
.btn-danger-o { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-danger-o:hover:not(:disabled) { background: var(--bad); color: #fff; }
.btn-danger-o:disabled { opacity: .5; }
@media print { .startno { display: none; } }
.selbar { width: max-content; max-width: 96vw; justify-content: center; }
.selbar .btn { white-space: nowrap; }

/* ===== Bieu mau dang bang co cong thuc (F.010 / F.012 / F.015) ===== */
table.rec.grid td input.tick { width: 18px; min-width: 18px; min-height: 18px; margin: 0 auto; display: block; accent-color: var(--accent, #7a4b1f); }
table.rec.grid td input.ng { background: var(--bad-bg, #fde8e8); color: var(--bad, #b42318); font-weight: 700; }
table.rec.grid td.calc { text-align: center; font-weight: 600; background: var(--head-bg); font-variant-numeric: tabular-nums; }
.grid-sec + .grid-sec { margin-top: 12px; }
.grid-foot { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 8px 10px; border-top: 1.5px solid var(--grid); align-items: flex-start; }
.grid-foot .tots { display: flex; flex-direction: column; gap: 4px; min-width: 260px; }
.grid-foot .tot, .grid-foot .gf { display: flex; gap: 8px; align-items: center; }
.grid-foot .tl { font-weight: 600; }
.grid-foot .tot-v { min-width: 70px; padding: 2px 8px; background: var(--head-bg); border: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; }
.grid-foot .gfields { display: flex; flex-wrap: wrap; gap: 6px 16px; flex: 1; min-width: 260px; align-items: center; }
.grid-foot .gft { flex-basis: 100%; }
.grid-foot .gf input { width: 110px; min-height: 32px; border: 1px solid var(--grid); padding: 0 6px; background: var(--card); color: var(--sheet-ink); }
.grid-foot .gf-wide { flex-basis: 100%; }
.grid-foot .gf-wide input, .grid-foot .gf-wide textarea { width: 100%; max-width: 560px; }
.foot-note { padding: 6px 10px; font-size: 13px; border-top: 1px solid var(--grid); }
.foot-note p { margin: 2px 0; }

/* ===== Bang Stocking (F.007 ban 3) ===== */
.stock { border-top: 1.5px solid var(--grid); }
.stock-wrap { display: grid; grid-template-columns: 1.25fr 1fr; gap: 0; }
@media (max-width: 900px) { .stock-wrap { grid-template-columns: 1fr; } }
table.stock-t { width: 100%; }
table.stock-t th { font-size: 13px; padding: 4px; }
table.stock-t td { padding: 0; text-align: center; }
table.stock-t td input { width: 100%; min-width: 70px; min-height: 34px; border: 0; padding: 0 6px; background: transparent; text-align: right; font-variant-numeric: tabular-nums; color: var(--sheet-ink); }
table.stock-t td.yel { background: #fff7c2; }
table.stock-t td.calc.ng { color: var(--bad); background: var(--bad-bg); }
.stock-warn { padding: 0 10px 8px; }
.grid-title { margin: 0; padding: 6px 10px; font-size: 14px; border-top: 1.5px solid var(--grid); background: var(--head-bg); }
/* Net dam phan cach Green coffee | Roasted coffee */
.stock-wrap > .tbl-paper + .tbl-paper { border-left: 3px solid var(--sheet-ink, #111); }
.stock-wrap > .tbl-paper:first-child { border-right: 0; }
@media (max-width: 900px) { .stock-wrap > .tbl-paper + .tbl-paper { border-left: 0; border-top: 3px solid var(--sheet-ink, #111); } }

/* Chon nhom checklist theo tan suat (tab Lap checklist) */
.picker-r { display: grid; gap: 10px; min-width: 0; }
.picker-r .selmeta, .picker-r > p { grid-column: 1; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; }
.grp-row { display: flex; flex-wrap: wrap; gap: 8px; }
.grp-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 44px; padding: 6px 14px; border: 1.5px solid var(--line, #cfd6dd); border-radius: 10px; background: var(--card, #fff); color: inherit; font: inherit; cursor: pointer; text-align: left; }
.grp-chip b { font-size: 14.5px; }
.grp-chip small { font-size: 12px; color: var(--muted); }
.grp-chip:hover:not(:disabled) { border-color: var(--brand, #1f3a52); }
.grp-chip.on { background: var(--brand, #1f3a52); border-color: var(--brand, #1f3a52); color: #fff; }
.grp-chip.on small { color: rgba(255, 255, 255, .8); }
.grp-chip:disabled { opacity: .6; cursor: not-allowed; }

/* Quet chon nhieu o trong bang Stocking */
table.stock-t td.ssel { background: #cfe3ff !important; outline: 1px solid #3b7ddd; outline-offset: -1px; }
table.stock-t td.ssel input { background: transparent; }
body.ssel-drag { user-select: none; cursor: cell; }
body.ssel-drag table.stock-t input { pointer-events: none; }

/* O ten san pham tu gian chieu cao khi ten dai (wrap text) */
.hrow textarea.autogrow { width: 100%; min-height: 30px; border: 0; border-left: 1px dotted var(--grid-2); background: transparent; padding: 5px 6px; font-family: var(--sans); font-size: 14.5px; line-height: 1.3; color: var(--sheet-ink); resize: none; overflow: hidden; display: block; }
.hrow textarea.autogrow:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--card); }
.hrow textarea.autogrow:disabled { opacity: 1; -webkit-text-fill-color: var(--sheet-ink); }

/* v1.9.8: o ghi chu / ten san pham trong bang va dong checklist tu gian chieu cao (wrap text) */
table.rec td textarea.autogrow { width: 100%; min-width: 64px; min-height: 36px; border: 0; padding: 7px 6px 6px; background: transparent; color: var(--sheet-ink); font: inherit; font-size: 14px; line-height: 1.35; resize: none; overflow: hidden; display: block; }
table.rec td textarea.autogrow.wide { min-width: 140px; }
table.rec td textarea.autogrow:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--card); }
table.rec td textarea.autogrow:disabled { -webkit-text-fill-color: var(--sheet-ink); opacity: 1; }
textarea.note-in { resize: none; overflow: hidden; display: block; font-family: var(--sans); line-height: 1.35; padding-top: 7px; }
.grid-foot .gf textarea.autogrow { width: 100%; min-height: 34px; resize: none; overflow: hidden; border: 1px solid var(--grid-2); border-radius: 6px; padding: 6px 8px; font: inherit; line-height: 1.35; background: var(--card); }

/* ===== QA Form (04/11/2026): mau do lap (dong con), o chon, anh cua mau, nhom CHEM / MICRO ===== */
table.rec.repgrid tbody tr.rep:not(.rep-1) td { border-top-style: dashed; }
table.rec.repgrid tbody tr.rep-1 td { border-top-width: 2px; }
table.rec.grid td select.ng, table.rec.grid td.calc.ng { background: var(--bad-bg, #fde8e8); color: var(--bad, #b42318); font-weight: 700; }
table.rec.grid td.replbl { background: var(--head-bg); font-size: 12px; padding: 0 6px; white-space: nowrap; color: var(--muted, #555); }
table.rec.grid td select { min-width: 72px; }
table.rec.grid td input.cfu { min-width: 72px; text-align: center; }
table.rec.grid td.c-photo { min-width: 110px; padding: 4px; vertical-align: middle; }
.gphotos { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.gphotos .ph { position: relative; }
.gphotos .ph img { width: 56px; height: 42px; object-fit: cover; border-radius: 4px; cursor: zoom-in; display: block; }
.gphotos .ph button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--bad, #b42318); color: #fff; padding: 0; display: grid; place-items: center; }
.gphotos .ph button .i { width: 12px; height: 12px; }
.gphotos .addph input[type=file] { display: none; }
.gfields select { min-height: 34px; }
/* 10/11/2026 - giam sat theo khu */
.sup-line { margin: 0 0 8px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sup-line.warn { color: #b45309; }
table.perm-matrix td.warn-cell { color: #b45309; font-weight: 600; }
.filters label.chk-inline, .chk-inline { flex-direction: row; display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; min-height: 40px; }
.filters .chk-inline input { min-height: 0; min-width: 0; width: 18px; height: 18px; padding: 0; flex: none; }
/* 10/11/2026 - tab Huong dan */
.card.guide { padding: 14px 18px; margin-top: 14px; }
.card.guide h2 { font-size: 16px; margin: 0 0 8px; }
.guide-ol, .guide-ul { margin: 0; padding-left: 22px; line-height: 1.6; }
.guide-ol li, .guide-ul li { margin: 4px 0; }
.guide-tip { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
/* 11/11/2026 - Quan tri -> Nguoi dung tinh gon */
.um-intro { margin: 0 0 12px; }
.card.um { padding: 14px 16px; }
.card.um h2 { font-size: 16px; margin: 0 0 4px; }
.card.um > p.small { margin: 0 0 10px; }
.um-sup { display: grid; gap: 8px; }
.um-sup-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.um-sup-row.empty { border-color: #f59e0b; background: rgba(245, 158, 11, .07); }
.um-khu b { display: block; }
.um-khu small { color: var(--muted); font-size: 12px; }
.um-people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.um-person { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--info-bg); border: 1px solid var(--info); font-size: 14px; }
.um-x { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; width: 24px; height: 24px; border-radius: 50%; color: inherit; }
.um-x:hover { background: rgba(0, 0, 0, .08); }
.um-none { color: #b45309; font-size: 14px; }
.um-add { min-height: 32px; padding: 0 8px; border: 1px dashed var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-size: 13px; }
.um-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.um-q { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 240px; font: inherit; }
.um-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.um-chip { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.um-chip.on { background: var(--info); border-color: var(--info); color: var(--card); }
.um-tbl select { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13.5px; padding: 0 6px; background: var(--card); color: var(--ink); }
.um-tbl tr.um-blk td { background: rgba(220, 38, 38, .07); }
.um-adv summary { cursor: pointer; font-weight: 600; }
.um-adv[open] summary { margin-bottom: 10px; }
@media (max-width: 640px) { .um-sup-row { grid-template-columns: 1fr; gap: 6px; } .um-q { min-width: 0; flex: 1; } }
.um-lap { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-link { border: 0; background: none; padding: 0; color: var(--info); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }
.um-suptxt { font-weight: 600; color: var(--info); }
/* 11/11/2026 - tim bieu mau thong minh + Hay dung */
.finder { display: grid; gap: 8px; margin-bottom: 10px; }
.finder-wrap { position: relative; display: flex; align-items: center; }
.finder-wrap > .i { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.finder-in { width: 100%; min-height: 44px; padding: 0 12px 0 38px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; font-size: 15px; background: var(--card); color: var(--ink); }
.finder-in:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.finder-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; max-height: 360px; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.finder-h { padding: 6px 10px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.finder-it { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.finder-it.on, .finder-it:hover { background: var(--info-bg); }
.finder-code { font-weight: 700; color: var(--info); }
.finder-txt { display: grid; min-width: 0; }
.finder-txt b, .finder-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-txt small { color: var(--muted); font-size: 12.5px; }
.finder-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.finder-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.freq-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.freq-l { font-size: 13px; color: var(--muted); font-weight: 600; }
.freq-chip { display: inline-flex; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink); text-decoration: none; background: var(--card); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.freq-chip b { color: var(--info); }
.freq-chip:hover, .freq-chip.on { border-color: var(--info); background: var(--info-bg); }
@media (max-width: 640px) { .finder-it { grid-template-columns: 48px 1fr; } .finder-tags { grid-column: 2; justify-content: flex-start; } }
.picker { align-items: start; }
.picker-l { max-width: 170px; padding-top: 10px; }
@media (max-width: 760px) { .picker { grid-template-columns: 1fr; } .picker-l { max-width: none; padding-top: 0; } }
/* 11/11/2026 - chu ky nguoi dung */
.um-sig { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sig-thumb { height: 30px; max-width: 110px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 1px 3px; }
.sigdlg .dlg { width: min(640px, 100%); }
.sigdlg .body { display: grid; gap: 10px; }
.sig-f { display: grid; gap: 4px; }
.sig-f input { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.sig-prev, .sig-rca { min-height: 64px; display: flex; align-items: center; padding: 6px 10px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; }
.sig-rca:empty { display: none; }
.sig-prev img, .sig-rca img { max-height: 70px; max-width: 100%; object-fit: contain; }
.sig-pad { width: 100%; max-width: 560px; aspect-ratio: 560 / 180; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; display: block; margin-top: 6px; }
.sig-on { display: block; height: 46px; max-width: 200px; object-fit: contain; margin-bottom: 2px; }
.btn-mysig { margin-left: 8px; background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.btn-mysig:hover { background: rgba(255, 255, 255, .12); }
.warn { color: #b45309; }
.sigdlg .chk-inline { white-space: normal; align-items: flex-start; min-height: 0; }
.sigdlg .chk-inline input { margin-top: 3px; flex: none; }
.sigdlg .toolbar { flex-wrap: wrap; }
.sigdlg .dlg { overflow-x: hidden; }
/* 12/11/2026 - tab Truy xuat */
.trace-form { padding: 14px 16px; display: grid; gap: 10px; margin-bottom: 14px; }
.seg-row { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; width: fit-content; max-width: 100%; }
.seg { border: 0; background: var(--card); color: var(--ink); padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--info); color: var(--card); font-weight: 600; }
.filters.trace-f { padding: 0; border: 0; }
.trace-f .trace-main { font-size: 15px; }
.trace-empty { padding: 8px 2px; }
.trace-sum { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.trace-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.trace-chips a { text-decoration: none; cursor: pointer; }
.card.trace-g { padding: 10px 12px; margin-bottom: 12px; }
.card.trace-g h3 { margin: 2px 2px 8px; font-size: 15px; }
.trace-hits { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.trace-hits li { margin: 1px 0; }
.trace-hits mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }
/* 12/11/2026 - dau phieu khong co o Date / Shift (dung ban giay): logo + ten bieu mau */
.sh-head.nohead { grid-template-columns: 190px minmax(0, 1fr); }
@media (max-width: 720px) { .sh-head.nohead { grid-template-columns: 1fr; } }
/* 13/11/2026 - tab SAP */
.sap-sum { padding: 8px 12px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.sap-sum b { color: var(--ink); }
table.sap-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 980px; }
table.sap-tbl th { position: sticky; top: 0; background: var(--card-2); text-align: left; font-size: 12px; letter-spacing: .03em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.sap-tbl th .sap-hd { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; padding: 2px 4px; border-radius: 4px; }
table.sap-tbl th .sap-hd:hover, table.sap-tbl th .sap-hd:focus-visible { background: var(--line); } table.sap-tbl th .sap-hd:focus-visible { outline: 2px solid var(--accent, #2f6fb3); }
table.sap-tbl th .sap-hd.on { color: var(--accent, #1f5fa8); font-weight: 700; } table.sap-tbl th .sap-fn { font-size: 10px; }
.sap-menu { position: fixed; z-index: 60; width: 260px; max-height: 350px; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--card, #fff); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13px; }
.sap-menu hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; } .sap-menu input[type=search] { width: 100%; box-sizing: border-box; }
.sap-mi { all: unset; cursor: pointer; padding: 5px 8px; border-radius: 5px; } .sap-mi:hover, .sap-mi:focus-visible { background: var(--line); } .sap-mi.on { font-weight: 700; color: var(--accent, #1f5fa8); }
.sap-vals { overflow: auto; min-height: 60px; max-height: 180px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.sap-v { display: flex; gap: 6px; align-items: center; padding: 2px 2px; cursor: pointer; } .sap-v .sap-vt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .sap-act { display: flex; justify-content: flex-end; gap: 6px; }
table.sap-tbl td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.sap-tbl td.nm { white-space: normal; min-width: 240px; }
table.sap-tbl .r { text-align: right; }
table.sap-tbl tbody tr:hover td { background: var(--card-2); }

/* History changes (18/11/2026) */
.hist-kind { margin: 4px 0 12px; }
.hist-kind .seg { border-radius: 0; }
.filters.hist-f { align-items: flex-end; }
.hist-t td { vertical-align: top; }
.hist-t td.nowrap { white-space: nowrap; }
.hist-t .en { display: block; }
.hist-t .chg { margin: 2px 0 0; }
.hist-t td > a { white-space: nowrap; }

/* 18/11/2026 (audit) */
.edited, td.edited input, td.edited textarea, td.edited select, label.edited input { background: #dbeafe !important; }
td.edited { box-shadow: inset 0 0 0 2px #2563eb; }
.edited-chip, .tpl-new-chip { background: #dbeafe; color: #1e40af; padding: 0 6px; border-radius: 4px; font-weight: 600; }
th.tpl-new, .tl.tpl-new, td.tpl-new { background: #dbeafe !important; color: #1e40af !important; }
.tpl-diff td.tpl-new { font-weight: 600; }
.edit-req .chg { margin: 6px 0; }
.edit-req-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
input.bad-date, .dbox input.bad { border-color: var(--bad) !important; background: var(--bad-bg) !important; }
.dbox { display: inline-flex; align-items: stretch; position: relative; max-width: 100%; }
.dbox > input[type="text"] { width: 9.5em; min-width: 0; padding-right: 30px; }
.dbox-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; padding: 4px; cursor: pointer; color: var(--muted, #667); display: inline-flex; }
.dbox-btn:disabled { display: none; }
.dbox-pk { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.miss-tab { color: var(--bad) !important; }
.freq-t select { min-width: 150px; } .freq-t .num-s { width: 70px; }
.um-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.um-chips input { max-width: 240px; }
.card.mb, section.mb { margin-bottom: 14px; }
@media print { td.edited { box-shadow: none; } .edited, td.edited input { background: #dbeafe !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* 19/11/2026: loc / sap xep tai tieu de cot - Template chuan, Tan suat bieu mau (dung lai menu .sap-menu) */
table.cf-tbl th { white-space: nowrap; }
table.cf-tbl th .sap-hd { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; font: inherit; color: inherit; padding: 2px 6px; margin: -2px -6px; border-radius: 5px; }
table.cf-tbl th .sap-hd:hover, table.cf-tbl th .sap-hd:focus-visible { background: var(--line); }
table.cf-tbl th .sap-hd:focus-visible { outline: 2px solid var(--accent, #2f6fb3); }
table.cf-tbl th .sap-hd.on { color: var(--accent, #1f5fa8); font-weight: 700; }
table.cf-tbl th .sap-fn { font-size: 10px; opacity: .8; }
.cf-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 0 0 8px; }

/* 28/11/2026: Product Release */
.rel-types { margin: 4px 0 10px; } .rel-types .seg { text-decoration: none; }
.rel-sum { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
table.rel-tbl td.nm { white-space: normal; min-width: 180px; } table.rel-tbl .r { text-align: right; } table.rel-tbl tr.rel-row { cursor: pointer; }
.rel-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; margin-bottom: 12px; }
.rel-h { display: flex; flex-direction: column; gap: 2px; } .rel-h .tl { font-size: 12px; color: var(--muted); } .rel-h input { width: 100%; box-sizing: border-box; }
table.rel-rep td.nm { white-space: normal; min-width: 200px; font-size: 13px; } table.rel-rep tr.rel-ng td { background: var(--bad-bg); } table.rel-rep tr.rel-miss td { background: var(--warn-bg); }
table.rel-rep .rel-in { width: 110px; } .rel-two { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.rel-sap { margin-top: 12px; } .rel-sap summary { cursor: pointer; } .rel-ta { width: 100%; box-sizing: border-box; font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin: 8px 0; }
.rel-sap tr.rel-chg td { background: #dbeafe; }
.rel-types .seg.on .muted { color: inherit; opacity: .85; }

/* 29/11/2026: Chon mau tu SAP (F033) */
.dlg.dlg-wide { width: min(760px, calc(100vw - 32px)); max-width: none; }
.sp-row { display: flex; flex-wrap: wrap; gap: 12px; } .sp-row .field { flex: 1 1 160px; }
.sp-batches { max-height: 210px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.sp-b { all: unset; cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 13px; line-height: 1.35; }
.sp-b:hover, .sp-b:focus-visible { background: var(--card-2); } .sp-b:focus-visible { outline: 2px solid var(--accent, #2f6fb3); }
.sp-b.on { background: #dbeafe; }
.sp-cb { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 4px 0 8px; }
.sp-prev table.mini { width: 100%; } .sp-prev tr.sp-next td { color: var(--muted); font-style: italic; }
table.rec td select.wide { min-width: 110px; }
.opt-t input { width: 100%; min-width: 160px; box-sizing: border-box; }
table.cf-tbl td.ctr, table.cf-tbl th.ctr { text-align: center; }
.trace-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
