/* Bố cục: thanh trên (kỳ lương, vai trò) · cột phân hệ bên trái · vùng làm việc. Tông xanh lá doanh nghiệp. */
:root {
  --bg: #f3f5f4; --surface: #ffffff; --sunk: #e9edeb; --line: #d5dcd8; --fg: #17201c; --muted: #5d6b64;
  --accent: #1d6b55; --accent-soft: #dcefe7; --accent-fg: #ffffff;
  --warn: #9a5600; --warn-soft: #fdf0dc; --bad: #b3261e; --bad-soft: #fbe4e2; --ok: #1d6b55;
  --hol: #7b3fa0; --hol-soft: #f1e6f8; --info: #245a8f; --info-soft: #e3eef9;
  --f-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "Roboto Mono", ui-monospace, Consolas, monospace;
  --shadow: 0 10px 30px rgba(10, 30, 20, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111614; --surface: #18201d; --sunk: #202a26; --line: #2f3b36; --fg: #e4ebe7; --muted: #93a39b;
  --accent: #4cbf98; --accent-soft: #1d3a30; --accent-fg: #0b1310;
  --warn: #f0a94a; --warn-soft: #3a2a12; --bad: #f2867d; --bad-soft: #3d1c19; --ok: #4cbf98;
  --hol: #c99ae6; --hol-soft: #2e2238; --info: #8ab8ea; --info-soft: #1b2b3d; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #111614; --surface: #18201d; --sunk: #202a26; --line: #2f3b36; --fg: #e4ebe7; --muted: #93a39b;
  --accent: #4cbf98; --accent-soft: #1d3a30; --accent-fg: #0b1310;
  --warn: #f0a94a; --warn-soft: #3a2a12; --bad: #f2867d; --bad-soft: #3d1c19; --ok: #4cbf98;
  --hol: #c99ae6; --hol-soft: #2e2238; --info: #8ab8ea; --info-soft: #1b2b3d; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark }
* { box-sizing: border-box }
html, body { margin: 0 }
[hidden] { display: none !important }
body { background: var(--bg); color: var(--fg); font-family: var(--f-ui); font-size: 14px; line-height: 1.45 }
button, input, select, textarea { font: inherit; color: inherit }
.num, td.r, .r { font-variant-numeric: tabular-nums }
.mono { font-family: var(--f-num) }
h1, h2, h3, h4 { margin: 0; text-wrap: balance }
h2 { font-size: 20px; font-weight: 700 }
h3 { font-size: 15px; font-weight: 600 }
h4 { font-size: 13px; font-weight: 600 }
p { margin: 0 }
.muted { color: var(--muted) }
.small { font-size: 12px }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600 }
.bad { color: var(--bad) } .okc { color: var(--ok) } .warnc { color: var(--warn) }
.b { font-weight: 700 }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center }
.brand { display: flex; flex-direction: column; margin-right: auto; min-width: 0 }
.brand b { font-size: 15px }
.brand span { font-size: 12px; color: var(--muted) }
.tb-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap }
.tb-group label { font-size: 12px; color: var(--muted) }
select, input[type=text], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0 }
input[type=number], input.r { text-align: right; font-family: var(--f-num) }
textarea { width: 100%; min-height: 60px; resize: vertical }
input:disabled, select:disabled, textarea:disabled { background: var(--sunk); color: var(--muted) }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center }
.btn:hover { border-color: var(--muted) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg) }
.btn.danger { color: var(--bad); border-color: var(--bad) }
.btn.ghost { border-color: transparent; background: transparent }
.btn.sm { padding: 3px 9px; font-size: 12px }
.btn:disabled { opacity: .45; cursor: not-allowed }
.lnk { all: unset; cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px }
.lnk:hover { text-decoration: underline }
.lnk:focus-visible { outline: 2px solid var(--accent) }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--muted); white-space: nowrap }
.chip.ok { background: var(--accent-soft); color: var(--ok) } .chip.warn { background: var(--warn-soft); color: var(--warn) }
.chip.bad { background: var(--bad-soft); color: var(--bad) } .chip.hol { background: var(--hol-soft); color: var(--hol) }
.chip.info { background: var(--info-soft); color: var(--info) }
/* Người tổ khác tăng cường trong ngày */
.chip.tc { background: var(--info-soft); color: var(--info); padding: 0 7px; font-size: 11px }
tr.tc-h td { background: var(--info-soft); color: var(--info) }
/* Ăn ca sáng tích nhanh */
.sang-q { display: flex; gap: 4px; justify-content: center; margin-top: 4px; font-weight: 400 }
th .sang-day { padding: 0 5px; margin-top: 2px; min-height: 0; line-height: 16px }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--line); flex: none }
.dot.ok { background: var(--ok) } .dot.warn { background: var(--warn) } .dot.bad { background: var(--bad) }
.menu { position: relative }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 240px; padding: 6px; display: flex; flex-direction: column; z-index: 30 }
.menu-pop button, .menu-pop a { all: unset; cursor: pointer; padding: 8px 10px; border-radius: 6px; font-size: 13px }
.menu-pop button:hover, .menu-pop a:hover { background: var(--sunk) }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0 }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 56px) }
.rail { border-right: 1px solid var(--line); background: var(--surface); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px }
.rail button { all: unset; cursor: pointer; display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px }
.rail .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--sunk); color: var(--muted) }
.rail .t { font-size: 13px; font-weight: 500; line-height: 1.25 }
.rail button[aria-current=true] { background: var(--accent-soft) }
.rail button[aria-current=true] .n { background: var(--accent); color: var(--accent-fg) }
.rail button:focus-visible { outline: 2px solid var(--accent) }
.rail .sep { height: 1px; background: var(--line); margin: 8px 6px }
main { padding-block: 18px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); min-width: 0 }
.pane { display: flex; flex-direction: column; gap: 14px; max-width: 1360px }
.pane-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; justify-content: space-between }
.pane-head p { color: var(--muted); max-width: 72ch; margin-top: 4px }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.banner.lock { background: var(--sunk); color: var(--fg) }
.banner.bad { background: var(--bad-soft); color: var(--bad) }
.banner.warn { background: var(--warn-soft); color: var(--warn) }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; overflow-x: auto }
.card.flush { padding: 0 }
.card-h { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px }
.flush > .card-h { padding: 12px 14px 0 }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start }
.tabs { display: flex; gap: 4px; flex-wrap: wrap }
.tabs button { all: unset; cursor: pointer; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 13px; color: var(--muted) }
.tabs button[aria-selected=true] { background: var(--fg); color: var(--bg) }
.tabs button:focus-visible { outline: 2px solid var(--accent) }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.toolbar .grow { flex: 1 }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0 }
.field > label, .field > .lbl { font-size: 12px; color: var(--muted); font-weight: 500 }
.field .hint { font-size: 11px; color: var(--muted) }
.field.wide { grid-column: 1 / -1 }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px }
.kpi .v { font-family: var(--f-num); font-size: 19px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums }
.kpi .s { font-size: 12px; color: var(--muted) }
.note { font-size: 12.5px; padding: 9px 12px; border-radius: 8px; background: var(--sunk); color: var(--muted) }
.note.ok { background: var(--accent-soft); color: var(--ok) } .note.warn { background: var(--warn-soft); color: var(--warn) } .note.bad { background: var(--bad-soft); color: var(--bad) }
.empty { text-align: center; padding: 28px 16px; color: var(--muted) }
.empty b { display: block; color: var(--fg); margin-bottom: 4px }

/* ---------- bảng ---------- */
.scroll { overflow: auto; max-width: 100% }
.scroll.tall { max-height: 70vh }
table { border-collapse: separate; border-spacing: 0; width: 100% }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle }
th { font-size: 11px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--sunk); white-space: nowrap }
.sticky thead th { position: sticky; top: 0; z-index: 2 }
.sticky thead tr:nth-child(2) th { top: 29px }
.sticky .sc { position: sticky; left: 0; background: var(--surface); z-index: 1 }
.sticky thead .sc { background: var(--sunk); z-index: 3 }
.card table td { white-space: nowrap }
.fg-grid td { padding: 3px 6px }
.fg-grid input { -moz-appearance: textfield; appearance: textfield }
.fg-grid input::-webkit-inner-spin-button, .fg-grid input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0 }
.card table td.wrap { white-space: normal }
.sticky tr.grp .sc, .sticky tfoot .sc { background: var(--sunk) }
tbody tr.click:hover td.sc { background: var(--accent-soft) }
td.r, th.r { text-align: right }
th.c, td.c { text-align: center }
td.nw, th.nw { white-space: nowrap }
tr.grp td { background: var(--sunk); font-weight: 700 }
tr.tot td { font-weight: 700; border-top: 2px solid var(--fg); background: var(--surface) }
tfoot td { background: var(--sunk); font-weight: 700 }
tbody tr.click { cursor: pointer }
tbody tr.click:hover td { background: var(--accent-soft) }
tbody tr.sel td { background: var(--accent-soft) }
tr.pend td { background: var(--warn-soft) }
tr.badrow td { background: var(--bad-soft) }
td input[type=number], td input[type=text], td select { padding: 3px 6px }
.money { font-family: var(--f-num); font-variant-numeric: tabular-nums }
.zero { color: var(--muted) }

/* ---------- modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 16, 12, .45); z-index: 50; display: grid; place-items: center; padding: 16px }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column }
.modal.wide { width: min(1100px, 100%) }
.modal.narrow { width: min(460px, 100%) }
.modal-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px }
.modal-b { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px }
.modal-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); box-shadow: var(--shadow); z-index: 45; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px) }
.drawer .modal-b { flex: 1 }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none }
.toast { background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow); max-width: 90vw }
.toast.bad { background: var(--bad); color: #fff }

/* ---------- phiếu chuyến ---------- */
.zone { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 8px; background: var(--sunk) }
.zone-h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px }
.zn { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 700; flex: none }
.areas { display: flex; flex-wrap: wrap; gap: 6px }
.area { position: relative; cursor: pointer }
.area input { position: absolute; opacity: 0; inset: 0; cursor: pointer }
.area span { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 13px }
.area input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-fg) }
.area input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px }
.area input:disabled + span { opacity: .5 }
.kgs { display: grid; grid-template-columns: 1.2fr repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center }
.kgs .h { font-size: 11px; color: var(--muted); font-weight: 600; text-align: right }
.kgs .h:first-child { text-align: left }
.kgs input { width: 100% }
.kgs.kgs-one { grid-template-columns: repeat(3, minmax(0, 1fr)) } .kgs.kgs-one .h, .kgs.kgs-one .h:first-child { text-align: left }
.kg-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 8px; border-top: 1px solid var(--line) }
.kg-total b { font-size: 18px; font-family: var(--f-num) }
.area-tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--sunk); margin: 1px 3px 1px 0; white-space: nowrap }
.area-tag.il { background: var(--hol-soft); color: var(--hol); font-weight: 600 }
.gh-p { background: var(--sunk) }
th.gh-x { background: var(--accent-soft); color: var(--ok) }

/* ---------- ca, chấm công ---------- */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px }
.day { all: unset; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--surface); display: flex; flex-direction: column; gap: 1px }
.day .d { font-size: 11px; color: var(--muted); font-weight: 600 }
.day .v { font-family: var(--f-num); font-size: 13px; font-weight: 600 }
.day[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft) }
.day.hol { border-color: var(--hol) } .day.hol .d { color: var(--hol) }
.day.empty .v { color: var(--muted); font-weight: 400 }
.day:focus-visible { outline: 2px solid var(--accent) }
.cc td { padding: 1px; text-align: center; font-family: var(--f-num); font-size: 11px; min-width: 28px }
.cc td.sc { text-align: left; font-family: var(--f-ui); font-size: 13px; white-space: nowrap; padding: 4px 8px }
.cc th { padding: 4px 2px; text-align: center; font-size: 10px }
.cc th.hol { color: var(--hol) }
.cc select { border: 0; background: transparent; padding: 2px 0; font-family: var(--f-num); font-size: 11px; width: 34px; text-align: center; appearance: none; -webkit-appearance: none; cursor: pointer; border-radius: 4px }
.cc select.g-sp { background: var(--accent-soft); color: var(--ok); font-weight: 700 }
.cc select.g-tg { background: var(--info-soft); color: var(--info) }
.cc select.g-nghi, .cc select.g-bhxh { background: var(--warn-soft); color: var(--warn) }
.cc select.g-khong { color: var(--muted) }
.cc select.g-ngung, .m-row-wrap select.g-ngung { background: var(--bad-soft); color: var(--bad) }
/* Mã công không làm SP ở tổ (+, Ô, TS, P…) */
select.code-sel, .cc select.code-sel { font-family: inherit; width: auto; min-width: 70px; max-width: 150px; font-size: 12px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; appearance: auto; -webkit-appearance: auto; text-align: left }
.m-row-wrap select.code-sel { grid-column: 1 / -1; max-width: none; margin: 0 8px 6px }
.m-row-wrap select.g-tg { background: var(--info-soft); color: var(--info) }
.m-row-wrap select.g-nghi, .m-row-wrap select.g-bhxh { background: var(--warn-soft); color: var(--warn) }
table.grid-m .wsm.cd { color: var(--warn); font-weight: 700 }
th.cd-c { text-align: center }
.cc select.g-x { background: var(--bad-soft); color: var(--bad) }
.cc select.g-auto, .m-row select.g-auto { background: var(--accent-soft); color: var(--ok); font-style: italic }
.cc td.flag { box-shadow: inset 0 0 0 2px var(--bad) }

/* ---------- giải thích ---------- */
.steps { display: flex; flex-direction: column; gap: 10px }
.step { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px }
.step h4 { margin-bottom: 4px }
.formula { font-family: var(--f-num); font-size: 12px; background: var(--sunk); border-radius: 6px; padding: 6px 8px; overflow-x: auto; white-space: nowrap }
.drawer .formula { white-space: normal; overflow-wrap: anywhere }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px }
.flow span { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface) }
.flow em { font-style: normal; color: var(--muted) }
.wf { display: flex; flex-wrap: wrap; gap: 4px; align-items: center }
.wf span { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--muted) }
.wf span.done { background: var(--accent-soft); color: var(--ok) }
.wf span.cur { background: var(--accent); color: var(--accent-fg) }
.wf i { color: var(--muted); font-style: normal }
.issues { display: flex; flex-direction: column; gap: 4px }
.issue { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 6px; font-size: 13px }
.issue.error { background: var(--bad-soft) } .issue.warn { background: var(--warn-soft) }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr }
  .rail { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; position: sticky; top: 0 }
  .rail button { grid-template-columns: 22px auto; white-space: nowrap }
  .rail button .dot, .rail .sep { display: none }
  .brand span { display: none }
}
@media (max-width: 560px) {
  .kgs { grid-template-columns: 1fr 1fr 1fr }
  .kgs .h:first-child, .kgs .lbl-area { grid-column: 1 / -1 }
  .kgs.kgs-one .h:first-child { grid-column: auto }
  .tb-group label { display: none }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important } }

/* ---------- giấy đề nghị nhập kho (xem trên màn hình) ---------- */
.f2wrap table.f2 { border-collapse: collapse; min-width: 720px }
.f2wrap .f2 th, .f2wrap .f2 td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap }
.f2wrap .f2 th { text-align: center; background: var(--sunk) }
.f2wrap .f2 td.r { text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums }
.f2wrap .f2 tr.sec td { font-weight: 700; background: var(--sunk) }
.f2wrap .f2 tr.tot td { border-top: 2px solid var(--fg) }
.f2wrap .f2 td.sub { padding-left: 16px; color: var(--muted) }

/* ---------- giao nhận mủ: thanh bước ---------- */
.gn-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 8px }
.gn-steps button { min-width: 0 }
.gn-steps button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface) }
.gn-steps button:hover { border-color: var(--muted) }
.gn-steps button:focus-visible { outline: 2px solid var(--accent) }
.gn-steps button[aria-selected=true] { border-color: var(--accent); background: var(--accent-soft) }
.gn-steps b { display: block; font-size: 13px }
.gn-steps small { display: block; font-size: 11px; color: var(--muted) }
.gn-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--sunk); color: var(--accent); font-size: 16px; flex: none }
.gn-steps button[aria-selected=true] .gn-ico { background: var(--accent); color: var(--accent-fg) }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)) }
tr.grp-top td { border-top: 2px solid var(--line) }
@media (max-width: 560px) { .fields.three { grid-template-columns: 1fr } }

/* ---------- tổ đánh đông ---------- */
.dd-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px }
.dd-person { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface) }
.dd-person.on { border-color: var(--accent); background: var(--accent-soft) }
.dd-person label { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; cursor: pointer }
.dd-person input[type=number] { width: 64px }
.dd-tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--sunk); color: var(--muted) }
.dd-tag.cty, .dd-tag.DC2, .dd-tag.thang { background: var(--accent-soft); color: var(--ok) } .dd-tag.ial, .dd-tag.ton { background: var(--hol-soft); color: var(--hol) } .dd-tag.tm, .dd-tag.DC15 { background: var(--info-soft); color: var(--info) }
table.cc td.ddc { text-align: center; font-family: var(--f-num); font-size: 12px }
/* Ô của người không thuộc nhóm của cột (Cán ủ chia cột theo nhóm) */
table.cc td.ddc.na { background: var(--sunk) }

/* ================= Điện thoại (≤ 700px) =================
   Thanh phân hệ nằm dưới đáy (ngón cái với tới), thanh trên gọn 2 dòng, modal toàn màn hình,
   ô nhập 16px để iPhone không tự phóng to, vùng chạm ≥ 40px, dải ngày vuốt ngang. */
.rail .ts, .brand .bs, .m-only { display: none }
:root { --navh: 60px }
body.no-nav { --navh: 0px }
@media (max-width: 700px) {
  .m-only { display: revert } .d-only { display: none !important }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px 8px; padding-block: 8px }
  .brand { grid-column: 1 / 3; margin: 0 } .brand .bl { display: none } .brand .bs { display: block; font-size: 15px }
  .menu { grid-column: 3; grid-row: 1 } .menu .mt { display: none } .menu-pop { position: fixed; left: 8px; right: 8px; top: 56px; min-width: 0 }
  .tb-group { min-width: 0; flex-wrap: nowrap } .tb-group select { min-width: 0; flex: 1 }
  .topbar > .tb-group:nth-of-type(2) { grid-column: 1 } .topbar > .tb-group:nth-of-type(3) { grid-column: 2 / 4 }
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; flex-direction: row; overflow-x: auto; border: 0; border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); gap: 2px; box-shadow: 0 -4px 14px rgba(0, 0, 0, .08); scrollbar-width: none }
  .rail button { flex: 1 0 70px; grid-template-columns: 1fr; justify-items: center; gap: 3px; padding: 6px 2px; text-align: center; min-height: 48px; box-sizing: border-box }
  .rail .t, .rail button .dot { display: none } .rail .ts { display: block; font-size: 11px; white-space: nowrap; font-weight: 600 }
  main { padding-top: 12px; padding-bottom: calc(var(--navh) + 28px + env(safe-area-inset-bottom, 0px)) }
  .pane { gap: 12px }
  h2 { font-size: 18px }
  .pane-head p { font-size: 13px }
  .pane-head > .toolbar { width: 100% }
  .pane-head .tabs { flex-wrap: nowrap; overflow-x: auto; width: 100% }
  select, input[type=text], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], textarea { font-size: 16px; min-height: 42px }
  .btn { min-height: 40px; padding: 8px 14px } .btn.sm { min-height: 36px; padding: 6px 11px; font-size: 13px }
  .toolbar > input[type=search] { flex: 1 1 100% }
  .toolbar > select { flex: 1 1 40% }
  .grid2 { grid-template-columns: 1fr !important }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px } .kpi { padding: 8px 10px } .kpi .v { font-size: 16px }
  .overlay { padding: 0; place-items: stretch }
  .modal, .modal.wide { width: 100%; max-height: none; height: 100dvh; border-radius: 0 }
  .modal.narrow { align-self: end; width: 100%; max-height: 90dvh; border-radius: 14px 14px 0 0 }
  .modal-f { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) } .modal-f .btn { flex: 1 1 0; justify-content: center }
  .drawer { width: 100vw }
  .days { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; scrollbar-width: none }
  .day { flex: 0 0 62px; scroll-snap-align: center; padding: 8px }
  .gn-steps { grid-template-columns: 1fr 1fr } .gn-steps small { display: none } .gn-steps button { padding: 8px }
  .gn-actions { position: sticky; bottom: calc(var(--navh) + env(safe-area-inset-bottom, 0px)); background: var(--surface); margin: 12px -14px -14px; padding: 10px 14px; border-top: 1px solid var(--line); z-index: 2 }
  .gn-actions .btn { flex: 1 1 0; justify-content: center }
  .dd-people { grid-template-columns: 1fr }
  .fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px }
  .modal-b { flex: 1 }
  .rail.single { display: none }
  .dd-person { min-height: 52px }
  .dd-person input[type=checkbox] { width: 22px; height: 22px }
}

/* ---------- thẻ & danh sách cho điện thoại ---------- */
.m-list { display: flex; flex-direction: column; gap: 8px }
.m-card { all: unset; box-sizing: border-box; display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; width: 100% }
.m-card:focus-visible { outline: 2px solid var(--accent) }
.m-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0 }
.m-top > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis }
.m-kg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; font-family: var(--f-num); font-size: 13px }
.m-kg span { display: block; font-family: var(--f-ui); font-size: 11px; color: var(--muted) }
.m-cols { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none }
.m-cols button { all: unset; flex: none; cursor: pointer; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; background: var(--surface); white-space: nowrap }
.m-cols button[aria-pressed=true] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent) }
.m-cols button.virtual { border-style: dashed }
.m-people { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden }
.m-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; min-height: 54px; border-bottom: 1px solid var(--line); cursor: pointer }
.m-row:last-child { border-bottom: 0 }
.m-row.on { background: var(--accent-soft) }
.m-row input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent) }
.m-row select { min-width: 88px }
.m-row .flag { color: var(--bad); font-size: 12px }
.m-recon { display: grid; grid-template-columns: minmax(0, 1fr) auto 110px; gap: 6px 10px; align-items: center }
.m-recon .h { font-size: 11px; color: var(--muted) }

/* ---------- bảng sản lượng khai thác & chế biến ---------- */
table.kcs tr.kcs-l0 td { font-weight: 700; color: var(--ok); background: var(--sunk) }
table.kcs tr.kcs-l1 td { font-weight: 700; color: var(--bad) }
table.kcs tr.kcs-l2 td { font-weight: 600 }
table.kcs th { white-space: normal; min-width: 90px; vertical-align: bottom }
table.kcs input[type=number] { padding: 3px 6px }

/* ăn ca sáng trong màn chấm công bộ phận */
th.sang-c, td.sang-c { background: var(--warn-soft) }
.m-row-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; border-bottom: 1px solid var(--line) }
.m-row-wrap:last-child { border-bottom: 0 }
.m-row-wrap .m-row { border-bottom: 0 }
.sang-tog { display: flex; align-items: center; gap: 6px; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--warn); background: var(--warn-soft); cursor: pointer; white-space: nowrap }
.sang-tog input { width: 20px; height: 20px; margin: 0 }

/* chấm công bộ phận: nhập nhanh */
.wcell { display: inline-flex; align-items: center; gap: 4px }
.w-in { width: 46px; padding: 2px 4px; font-size: 12px; text-align: center; border: 1px solid transparent; background: transparent; border-radius: 4px }
.w-in:hover, .w-in:focus { border-color: var(--line, #ccc); background: var(--bg, #fff) }
.sl-in { width: 90px; margin-top: 4px; padding: 2px 6px; font-size: 12px; text-align: right }
.sl-in.bad { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) }
.btn.xs { padding: 1px 6px; font-size: 11px; margin-top: 4px; min-height: 0 }
table.grid-m td.ddc, table.grid-m th { min-width: 30px; padding-left: 2px; padding-right: 2px }
table.grid-m th.sun { color: #a15c00 }
table.grid-m .wsm { font-size: 10px; line-height: 1 }

/* điện thoại: gọn chữ */
@media (max-width: 700px) {
  .m-hide, .pane-head .eyebrow { display: none }
  .pane-head h2 { font-size: 18px; margin: 0 }
  .days-card { padding: 8px }
  .day-head { margin: 8px 0 }
  .day-head h3 { display: flex; align-items: center; gap: 6px; font-size: 16px }
  .day-head h3 .m-only { display: inline-flex; gap: 4px; order: 2; margin-left: auto }
  .day-head h3 .btn { min-width: 40px }
  .m-tools { display: flex; gap: 6px; align-items: center; margin: 8px 0 }
  .m-sl { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-left: auto }
  .m-sl input { width: 90px; text-align: right }
  .day-head > div:first-child { flex: 1 } .day-head h3 { width: 100% }
  .m-cols { flex-wrap: wrap }
  .m-row { min-height: 48px; padding: 8px 12px }
  .sang-tog { padding: 0 10px; font-size: 12px }
}

/* Phân vùng cột theo dây chuyền (Chế biến): hàng nhóm có màu, nền nhạt theo nhóm, không viền */
.grp-row th { position: static; padding: 5px 6px; font-size: 12px; font-weight: 700; text-align: center; letter-spacing: .02em }
.g-DC2 { --gc: var(--ok); --gbg: var(--accent-soft) }
.g-DC15 { --gc: var(--info); --gbg: var(--info-soft) }
.g-KHAC { --gc: var(--hol); --gbg: var(--hol-soft) }
.grp-row th.grp { color: var(--gc); background: var(--gbg) }
table.grouped .gcol { background: color-mix(in srgb, var(--gbg) 35%, transparent) }
table.grouped th.gcol { background: var(--gbg) }
.g-PALLET { --gc: var(--ok); --gbg: var(--accent-soft) }
.g-XUCLAT { --gc: var(--info); --gbg: var(--info-soft) }
.g-XUAT { --gc: var(--hol); --gbg: var(--hol-soft) }
/* Tổ sản xuất Thành Công: màu từng tổ */
.g-DD { --gc: var(--ok); --gbg: var(--accent-soft) }
.g-GCN { --gc: var(--warn); --gbg: var(--warn-soft) }
.g-TP { --gc: var(--info); --gbg: var(--info-soft) }
.g-S10 { --gc: var(--hol); --gbg: var(--hol-soft) }
/* Bảng tô vùng (cfg.zones): nền vùng đậm, không đường kẻ ô; ô không thuộc tổ của người đó tô nhạt theo màu vùng thay cho nền xám */
table.zones th, table.zones td { border-bottom: 0 }
table.zones td.gcol { background: color-mix(in srgb, var(--gbg) 80%, transparent) }
table.zones td.ddc.na { background: color-mix(in srgb, var(--gbg) 55%, transparent) }
/* Form phiếu: 5 ô kg (nhãn trên, ô dưới) */
.kgs.kgs-one { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px }
.kgs .kgf { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 600 }
@media (max-width: 700px) { .kgs.kgs-one { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
/* Bảng giao nhận ngày */
table.gd .drc-in { width: 64px; margin-top: 0 }
table.gd tr.drc-def td { background: var(--sunk) }
.time24 { display: flex; align-items: center; gap: 6px } .time24 select { width: auto; min-width: 72px }
table.gn-lines input { width: 84px } table.gn-lines select { min-width: 90px }
/* DRC lái xe nhập dưới ô kg của từng loại mủ (Thành Công) */
table.gn-lines input.drc-lx { display: block; margin-top: 4px; font-size: 12px; background: var(--sunk) }
tr.grp-h td { background: var(--sunk); font-weight: 700; font-size: 12px }
.m-grp { margin: 10px 0 4px; font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em }
.grp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start } .grp-cards select { max-width: 100% }

/* ô chọn kèm nút bên phải (vd số xe + Thêm xe) */
.row-in { display: flex; gap: 6px; align-items: center; }
.row-in > select, .row-in > input { flex: 1; min-width: 0; }
