/* ============================================================
   XƯỞNG CRM — xuong.css (15/10/2026). Cùng tông màu với Klasse CRM (design tokens giống style.css gốc).
   ============================================================ */
:root {
  --primary: #2563eb; --primary-h: #1d4ed8; --primary-soft: #eff6ff;
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #06b6d4;
  --bg: #f1f5f9; --surface: #fff; --border: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --side: #1e293b; --side-w: 236px; --head-h: 56px; --r: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 20% 0%, #dbeafe 0%, transparent 60%), radial-gradient(700px 500px at 100% 100%, #cffafe 0%, transparent 60%), var(--bg); }
.login-box { width: min(380px, 100%); background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(15, 23, 42, .12); }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-logo .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 22px; }
.login-sub { color: var(--muted); margin-bottom: 20px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ---------- Khung ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side-w); background: var(--side); color: #cbd5e1; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 20; }
.side-brand { height: var(--head-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; color: #fff; font-weight: 800; font-size: 17px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.side-brand .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; font-size: 18px; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; cursor: pointer; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: var(--primary); color: #fff; }
.nav .ic { width: 20px; text-align: center; font-size: 16px; }
.nav a.sub { padding: 8px 12px 8px 30px; font-size: 13.5px; }
.nav .chev { margin-left: auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; background: rgba(255, 255, 255, .08); color: #e2e8f0; transition: transform .15s, background .15s; flex: none; }
.nav a.on .chev { background: rgba(255, 255, 255, .22); color: #fff; }
.nav .chev:hover { background: rgba(255, 255, 255, .12); }
.nav .chev.open { transform: rotate(90deg); }
.nav .cnt + .chev { margin-left: 6px; }
.nav .cnt { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 10px; }
.sf-me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sf-av { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.sf-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sf-who b { color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-who span { color: #94a3b8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sf-btn { height: 32px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .06); color: #cbd5e1; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.sf-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sf-btn.out:hover { background: rgba(239, 68, 68, .2); color: #fca5a5; }
.main { margin-left: var(--side-w); flex: 1; min-width: 0; }
.top { height: var(--head-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 0; z-index: 10; }
.top h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { padding: 20px 22px 90px; }
.bottom-nav { display: none; }

/* ---------- Thành phần ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.input, .select, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none; }
textarea.input { height: auto; min-height: 70px; padding: 9px 12px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: #334155; }
.field .req { color: var(--danger); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.card-b { padding: 14px 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; flex: 0 1 220px; }
.toolbar .grow { flex: 1 1 240px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px; cursor: pointer; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi.warn .v { color: var(--warning); } .kpi.bad .v { color: var(--danger); } .kpi.good .v { color: var(--success); } .kpi.blue .v { color: var(--primary); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid2 > *, .kpis > * { min-width: 0; }
.kpis.kpis4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 8px; }
.use-ctl { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.use-ctl .select, .use-ctl .input { height: 28px; font-size: 12px; padding: 0 6px; border-radius: 6px; width: 100%; min-width: 0; }
.hist-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.hist-filter .select, .hist-filter .input { width: auto; height: 32px; font-size: 13px; padding: 0 8px; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f8fafc; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f8fafc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.tbl .m-sel { width: 36px; padding-right: 0; }
.tbl .m-sel input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); }
.tbl tr.sel td { background: #eff6ff; }
.sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px; border-radius: 10px; background: #eff6ff; border: 1px solid #bfdbfe; font-size: 13.5px; }
.sel-bar .btn:last-child { margin-left: auto; }
.muted { color: var(--muted); } .small { font-size: 12px; } .b { font-weight: 700; } .nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.gray { background: #f1f5f9; color: #475569; } .badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.green { background: #d1fae5; color: #047857; } .badge.red { background: #fee2e2; color: #b91c1c; }
.badge.amber { background: #fef3c7; color: #b45309; }
.bar { height: 8px; border-radius: 6px; background: #e2e8f0; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.bar.done > i { background: var(--success); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px; }

/* ---------- Sản phẩm (từ Klasse CRM) ---------- */
.kp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 8px; cursor: pointer; box-shadow: var(--shadow); min-width: 0; }
.kp-card:hover { border-color: var(--primary); }
.kp-img { aspect-ratio: 1; border-radius: 8px; background: #f8fafc; display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; font-size: 28px; color: #cbd5e1; }
.kp-img img { width: 100%; height: 100%; object-fit: contain; }
.kp-name { font-weight: 600; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kp-row { display: flex; align-items: flex-start; gap: 6px; }
.kp-row .kp-name { flex: 1; min-width: 0; }
.kp-stock { flex: none; padding: 2px 7px; border-radius: 6px; background: #f1f5f9; font-size: 12px; color: #475569; white-space: nowrap; }
.kp-stock b { font-size: 13px; color: var(--text); }
.kp-stock.has { background: #ecfdf5; } .kp-stock.has b { color: #047857; }
.kp-stock.neg { background: #fef2f2; } .kp-stock.neg b { color: var(--danger); }
.kp-big { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.kp-big img { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #fff; display: block; }

/* ---------- Ô chọn sản phẩm Klasse (form lệnh) ---------- */
.pp { position: relative; }
.pp-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18); max-height: 360px; overflow: auto; padding: 4px; }
.pp-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.pp-row:hover, .pp-row.on { background: var(--primary-soft); }
.pp-row img, .pp-sel img, .pp-noimg { width: 46px; height: 46px; border-radius: 6px; object-fit: contain; background: #f8fafc; border: 1px solid var(--border); flex: none; display: grid; place-items: center; font-size: 18px; }
.pp-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-stock { font-size: 12px; color: #047857; background: #d1fae5; border-radius: 6px; padding: 3px 8px; white-space: nowrap; flex: none; }
.pp-stock.zero { color: #b91c1c; background: #fee2e2; }
.pp-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.pp-more { padding: 8px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.pp-sel { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px; border: 1px solid #bfdbfe; background: var(--primary-soft); border-radius: 10px; }
.pp-sel img, .pp-sel .pp-noimg { width: 56px; height: 56px; }

/* ---------- Danh sách chọn nổi trên hộp thoại (chọn SP / khách — Gửi thành phẩm) ---------- */
.pick-bg { position: fixed; inset: 0; z-index: 150; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pick-box { width: min(560px, 100%); max-height: 86vh; background: #fff; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
.pick-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 14px 0; }
.pick-list { flex: 1; overflow: auto; padding: 0 8px 8px; min-height: 160px; }
.ship-line .ship-pick { flex: 1 1 200px; min-width: 0; justify-content: flex-start; height: auto; min-height: 40px; padding: 4px 8px; gap: 8px; text-align: left; font-weight: 500; }
.ship-line .ship-pick img, .ship-line .ship-pick .pp-noimg { width: 32px; height: 32px; }
/* Phiếu order từ công ty (Klasse → xưởng, 16/10/2026) */
.req-box { margin-bottom: 16px; }
.req-box .card-h .select { width: auto; max-width: 60%; height: 32px; padding: 4px 8px; font-size: 13px; }
.req-box.has-new { border-color: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.req-th img, .req-th .pp-noimg { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; background: #f8fafc; border: 1px solid var(--border); display: grid; place-items: center; font-size: 15px; }
.ship-line .ship-pick .sp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-line .input[data-ship-qty] { width: 80px; }
.ship-line { flex-wrap: wrap; }
.ship-line .ship-err { flex: 1 1 100%; color: var(--danger); font-size: 12.5px; font-weight: 600; margin: -2px 0 0; }
.ship-line .ship-err:empty { display: none; }
.ship-line.err .input[data-ship-qty] { border-color: var(--danger); box-shadow: 0 0 0 3px #fee2e2; color: var(--danger); font-weight: 700; }

/* ---------- Hộp thoại ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100; display: flex; justify-content: flex-end; }
.modal { width: min(640px, 100%); height: 100%; background: var(--surface); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-h b { flex: 1; font-size: 16px; }
.modal-x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-b { flex: 1; overflow: auto; padding: 16px 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.lines { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.line { display: flex; gap: 8px; align-items: center; }
.line .select { flex: 1; min-width: 0; }
.line .input { width: 110px; flex: none; }
.line.bom-line .input[data-bom-qty] { width: 100px; }
.line.bom-line .bom-note { width: auto; flex: 1 1 150px; min-width: 0; }
.line .x { border: 0; background: none; color: var(--danger); font-size: 20px; cursor: pointer; width: 28px; flex: none; }
.line .hint { font-size: 12px; color: var(--muted); width: 90px; flex: none; text-align: right; }
.sec-t { font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.stage { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.stage-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stage-top b { flex: 1; }
.stage-act { display: flex; gap: 6px; margin-top: 8px; }
.stage-act .input { width: 140px; height: 32px; }
.stage-log { font-size: 12px; color: var(--muted); margin-top: 6px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.info-grid .k { font-size: 12px; color: var(--muted); }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--danger); } .toast.success { background: #047857; }
.demo-tag { white-space: nowrap; flex: none; background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }

/* ---------- Điện thoại ---------- */
@media (max-width: 1024px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 768px) {
  .side { display: none; }
  .main { margin-left: 0; }
  .top { padding: 0 14px; }
  .page { padding: 14px 12px 90px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 8px 2px 7px; font-size: 11px; color: var(--muted); text-decoration: none; font-weight: 600; position: relative; }
  .bottom-nav a .ic { font-size: 20px; line-height: 24px; height: 24px; }
  .bottom-nav a .lb { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 14px; }
  .bottom-nav a.on { color: var(--primary); }
  .bottom-nav .cnt { position: absolute; top: 3px; left: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }
  .toolbar .input, .toolbar .select { flex: 1 1 140px; }
  .kp-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tbl .m-hide { display: none !important; }
  /* Bảng → thẻ trên điện thoại (labelTables gắn data-label = tiêu đề cột): ô đầu là tiêu đề thẻ, các ô sau "nhãn ……… giá trị" */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 0; border: 0; text-align: right; min-width: 0 !important; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .tbl td:first-child { display: block; text-align: left; font-size: 15px; padding-bottom: 6px; }
  .tbl td:first-child::before { display: none; }
  /* ô tích (chỉ tài khoản admin) nằm góc phải thẻ, ô kế tiếp làm tiêu đề thẻ */
  .tbl tr { position: relative; }
  .tbl td.m-sel { position: absolute; right: 14px; top: 10px; padding: 0; width: auto; }
  .tbl td.m-sel + td { display: block; text-align: left; font-size: 15px; padding-bottom: 6px; padding-right: 32px; }
  .tbl td.m-sel + td::before { display: none; }
  .tbl td[data-label=""]::before { display: none; }
  .tbl td[data-label=""] { justify-content: flex-end; }
  .tbl td > .bar { flex: 1; max-width: 160px; }
  .tbl td.num { white-space: normal; }
  .kpis { gap: 8px; } .kpi { padding: 12px; } .kpi .v { font-size: 22px; }
  .kpis.kpis4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-filter .select { flex: 1 1 100%; }
  .hist-filter .input { flex: 1 1 0; min-width: 0; }
  .card-h { flex-wrap: wrap; }
  /* Bảng trong hộp thoại: các ô phụ chia 2 cột cho gọn (bảng vật tư của lệnh, lịch sử kho của vật tư / sản phẩm…) */
  .modal .tbl tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; }
  .modal .tbl td:first-child, .modal .tbl td[data-label=""] { grid-column: 1 / -1; }
  .modal .tbl td { font-size: 13px; }
  .modal .tbl td.m-hide { display: none !important; }
  .modal .tbl td.nowrap, .modal .tbl td.num { white-space: normal; }
  .modal .tbl td { flex-wrap: wrap; row-gap: 2px; }
  .modal .tbl td .tdv { min-width: 0; margin-left: auto; text-align: right; }
  /* Thanh công cụ: ô tìm cả hàng, ô chọn / nút chia đều */
  .toolbar { gap: 6px; }
  .toolbar > * { flex: 1 1 140px; min-width: 0; }
  .toolbar > .btn { flex: 1 1 80px; }
  .toolbar > .grow, .toolbar > label { flex-basis: 100%; }
  .toolbar > span:empty, .toolbar > span[style*="flex:1"] { display: none; }
  .toolbar .btn { padding: 0 8px; }
  /* Chân hộp thoại: nút xếp lưới đều, bỏ khoảng đệm */
  .modal-f { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .modal-f > span { display: none; }
  .modal-f:has(> .btn:nth-of-type(4):last-of-type) { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* 4 nút → 2 × 2 thay vì 3 + 1 */
  .modal-f .btn { width: 100%; padding: 0 6px; }
  .modal-b { padding: 14px 14px; }
  /* Ghi nhận tiến độ: ô nhập cả hàng, 2 nút chia đều */
  .stage-act { flex-wrap: wrap; }
  .stage-act .input { flex: 1 1 100%; width: auto; }
  .stage-act .btn { flex: 1 1 0; }
  .kpi .l { font-size: 12px; line-height: 1.3; }
  .info-grid { gap: 8px 12px; }
  .line { flex-wrap: wrap; } .line .select { flex: 1 1 100%; }
  .line.bom-line { padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
}


/* ================= GIAO DIỆN THEO MÙA (chép từ Klasse CRM style.css, 16/10/2026) =================
   Đổi tên khung cho khớp Xưởng: .topbar → .top, .sidebar → .side, .sb-logo → .side-brand, .sb-logo-mark → .side-brand .mark,
   .sb-nav → .nav, .sb-footer → .side-foot, .topbar-right → .top-right. Bỏ quy tắc đổi position của thanh bên (ở Xưởng là fixed). */
.top-right { display: flex; align-items: center; gap: 4px; flex: none; }
.top-right .theme-toggle-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.top-right .theme-toggle-btn:hover { background: #f1f5f9; }
body[class*="theme-"] .top { overflow: visible; }
/* ===== ÁO HALLOWEEN (body.theme-halloween, 12/10/2026) — chỉ đổi màu nhấn + trang trí ở rìa ===== */
body.theme-halloween {
  --primary: #ea580c; --primary-h: #c2410c; --primary-soft: #fff7ed; --accent: #9333ea;
  --sb-bg: #22152f; --sb-text: #e9d5ff; --sb-muted: #7c6a92;
  --sb-active-bg: rgba(234, 88, 12, .22); --sb-active-text: #fdba74; --sb-hover: rgba(253, 186, 116, .08);
}
body.theme-halloween .top { position: sticky; box-shadow: inset 0 -2px 0 #f97316; }   /* KHÔNG overflow:hidden — sẽ cắt ô thông báo xổ xuống */
body.theme-halloween .side-brand .mark { background: linear-gradient(135deg, #f97316, #9333ea); }
body.theme-halloween .side { background: linear-gradient(180deg, #2a1838 0%, #22152f 55%, #1b1026 100%); }
.theme-toggle-btn { font-size: 17px; line-height: 1; }
.theme-toggle-btn.theme-off { filter: grayscale(1); opacity: .55; }
.theme-deco { pointer-events: none; }
.hw-bats { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.hw-bat { position: absolute; left: -40px; width: 26px; color: #4c1d95; opacity: .5; animation: hw-fly 26s linear infinite; }
.hw-bat svg { display: block; width: 100%; height: auto; }
.hw-wing { transform-origin: 0 0; animation: hw-flap .32s ease-in-out infinite alternate; }
.hw-wing-r { animation-delay: .16s; }
/* Đường lượn lấy từ --y1..--y3 do JS chọn ngẫu nhiên mỗi vòng (_hwBatRandom) */
@keyframes hw-fly { 0% { transform: translate(0, 0); } 25% { transform: translate(28vw, var(--y1, 9px)); } 50% { transform: translate(56vw, var(--y2, -2px)); } 75% { transform: translate(84vw, var(--y3, 8px)); } 100% { transform: translate(calc(100vw + 80px), 0); } }
@keyframes hw-flap { from { transform: scaleY(1); } to { transform: scaleY(.45); } }
body.theme-halloween .top h1, body.theme-halloween .top-right { position: relative; z-index: 1; }
.hw-pumpkin { display: inline-flex; width: 22px; margin-left: auto; filter: drop-shadow(0 0 6px rgba(249, 115, 22, .55)); }
.hw-pumpkin svg, .hw-pumpkin-foot svg { width: 100%; height: auto; display: block; }
.hw-web { position: absolute; top: 0; right: 0; width: 70px; color: rgba(233, 213, 255, .16); z-index: 0; }
.hw-pumpkin-foot { position: absolute; right: 14px; bottom: 72px; width: 34px; opacity: .85; z-index: 0; filter: drop-shadow(0 0 10px rgba(249, 115, 22, .5)); }
body.theme-halloween .side-brand, body.theme-halloween .nav, body.theme-halloween .side-foot { position: relative; z-index: 1; }
@media (max-width: 768px) { .hw-bat:nth-child(n+4), .hw-pumpkin-foot { display: none; } }
@media (prefers-reduced-motion: reduce) { .hw-bats { display: none; } }
@media print { .theme-deco, .theme-toggle-btn { display: none !important; } }

/* ===== GIÁNG SINH (body.theme-christmas, 13/10/2026) — đỏ / xanh lá, dây đèn, tuyết, cây thông ===== */
body.theme-christmas {
  --primary: #c62828; --primary-h: #a51d1d; --primary-soft: #fef2f2; --accent: #15803d;
  --sb-bg: #0f2a1d; --sb-text: #dcfce7; --sb-muted: #6b8f7b;
  --sb-active-bg: rgba(220, 38, 38, .25); --sb-active-text: #fecaca; --sb-hover: rgba(255, 255, 255, .07);
}
body.theme-christmas .side { background: linear-gradient(180deg, #14382a 0%, #0f2a1d 60%, #0b2016 100%); }
body.theme-christmas .side-brand .mark { background: linear-gradient(135deg, #dc2626, #15803d); }
body.theme-christmas .top { position: sticky; box-shadow: inset 0 -2px 0 #15803d; }
body.theme-christmas .top h1, body.theme-christmas .top-right { position: relative; z-index: 1; }
body.theme-christmas .side-brand, body.theme-christmas .nav, body.theme-christmas .side-foot { position: relative; z-index: 1; }
/* Dây đèn nháy dọc mép dưới thanh trên */
.xm-lights { position: absolute; left: 0; right: 0; bottom: -5px; height: 12px; display: flex; justify-content: space-between; padding: 0 10px; overflow: hidden; z-index: 0; }
.xm-lights::before { content: ""; position: absolute; left: 0; right: 0; top: 1px; height: 6px; border-bottom: 1.5px solid #14532d; border-radius: 0 0 50% 50%; }
.xm-lights i { position: relative; top: 4px; width: 6px; height: 8px; border-radius: 50% 50% 45% 45%; background: var(--c); box-shadow: 0 0 6px var(--c); animation: xm-blink 1.75s ease-in-out infinite; }
@keyframes xm-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; box-shadow: none; } }
/* Tuyết rơi trong thanh menu */
.xm-snow { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.xm-snow i { position: absolute; top: -10px; width: var(--s); height: var(--s); border-radius: 50%; background: rgba(255, 255, 255, .75); animation: xm-fall linear infinite; }
@keyframes xm-fall { from { transform: translate(0, -10px); } 50% { transform: translate(12px, 50vh); } to { transform: translate(-6px, 102vh); } }
.xm-star { display: inline-flex; width: 20px; margin-left: auto; filter: drop-shadow(0 0 6px rgba(250, 204, 21, .8)); animation: xm-twinkle 2.4s ease-in-out infinite; }
.xm-star svg, .xm-tree svg { width: 100%; height: auto; display: block; }
@keyframes xm-twinkle { 50% { transform: scale(.85) rotate(12deg); opacity: .8; } }
.xm-tree { position: absolute; right: 12px; bottom: 70px; width: 40px; z-index: 0; filter: drop-shadow(0 0 10px rgba(250, 204, 21, .35)); }
@media (max-width: 768px) { .xm-tree { display: none; } .xm-lights i:nth-child(2n) { display: none; } }
@media (prefers-reduced-motion: reduce) { .xm-snow { display: none; } .xm-lights i, .xm-star { animation: none; } }

/* Giao diện theo mùa: KHÔNG đổi position của sidebar trên điện thoại — ở đó sidebar là position:fixed trượt ra / vào;
   đặt relative làm sidebar chen vào bố cục, đẩy cả trang sang phải (lỗi 13/10/2026). Trên máy tính cần relative để
   trang trí (tuyết, mạng nhện, cây thông) bám vào sidebar. */

/* ===== TẾT CỔ TRUYỀN (body.theme-tet, 14/10/2026) — đỏ son / vàng kim, đèn lồng, hoa mai, cờ đỏ sao vàng ===== */
body.theme-tet {
  --primary: #c8102e; --primary-h: #a00d25; --primary-soft: #fff1f2; --accent: #e0a800;
  --sb-bg: #5c0a14; --sb-text: #ffe8b0; --sb-muted: #b98a6a;
  --sb-active-bg: rgba(255, 205, 0, .18); --sb-active-text: #ffd84d; --sb-hover: rgba(255, 205, 0, .08);
}
body.theme-tet .side { background: linear-gradient(180deg, #7a0f1c 0%, #5c0a14 60%, #45070f 100%); }
body.theme-tet .side-brand .mark { background: linear-gradient(135deg, #da251d, #e0a800); }
body.theme-tet .top { position: sticky; box-shadow: inset 0 -2px 0 #e0a800; }
body.theme-tet .top h1, body.theme-tet .top-right { position: relative; z-index: 1; }
body.theme-tet .side-brand, body.theme-tet .nav, body.theme-tet .side-foot { position: relative; z-index: 1; }
.theme-toggle-btn .vn-flag { width: 22px; height: auto; display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
/* Đèn lồng treo, đung đưa — đặt giữa thanh trên (không che nút ở 2 bên) */
.tet-lanterns { position: absolute; top: 0; left: 32%; right: 32%; height: 100%; display: flex; justify-content: space-around; overflow: visible; z-index: 0; }
.tet-lantern { width: 26px; transform-origin: 50% 0; animation: tet-swing 3.2s ease-in-out infinite alternate; margin-top: -3px; filter: drop-shadow(0 2px 4px rgba(200, 16, 46, .35)); }
.tet-l2 { width: 30px; animation-delay: -1.1s; }
.tet-l3 { animation-delay: -2.2s; }
.tet-lantern svg { width: 100%; height: auto; display: block; }
@keyframes tet-swing { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
/* Lá cờ phấp phới cạnh logo */
.tet-flag { display: inline-flex; margin-left: auto; width: 24px; animation: tet-wave 2.6s ease-in-out infinite; transform-origin: 0 50%; }
.tet-flag svg { width: 100%; height: auto; display: block; border-radius: 2px; }
@keyframes tet-wave { 0%, 100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-4deg) scaleX(.94); } }
/* Hoa mai rơi trong thanh menu */
.tet-petals { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.tet-petals i { position: absolute; top: -20px; width: var(--s); opacity: .85; animation: tet-fall linear infinite; }
.tet-petals i svg { width: 100%; height: auto; display: block; }
@keyframes tet-fall { from { transform: translate(0, -20px) rotate(0); } 50% { transform: translate(16px, 50vh) rotate(180deg); } to { transform: translate(-8px, 102vh) rotate(360deg); } }
.tet-greet { position: absolute; right: 12px; bottom: 74px; z-index: 0; text-align: right; font-weight: 800; font-size: 13px; line-height: 1.25;
  color: #ffd84d; text-shadow: 0 1px 0 #7a0f1c, 0 0 10px rgba(255, 205, 0, .45); letter-spacing: .3px; }
/* Điện thoại: thanh trên hẹp, đèn lồng đè lên nút 🎃 / 🎄 / cờ → ẩn; giữ hoa mai + cờ trong menu */
@media (max-width: 768px) { .tet-lanterns { display: none; } .tet-greet { display: none; } }
@media (prefers-reduced-motion: reduce) { .tet-petals { display: none; } .tet-lantern, .tet-flag { animation: none; } }

/* Nút Tết = đèn lồng (14/10/2026) */
.tet-btn-lantern { display: block; width: 15px; animation: tet-swing 3s ease-in-out infinite alternate; transform-origin: 50% 0; }
.tet-btn-lantern svg { width: 100%; height: auto; display: block; }
.theme-toggle-btn.theme-off .tet-btn-lantern { animation: none; }
/* Halloween: nhện thả tơ trong thanh menu (14/10/2026) */
.hw-spiders { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.hw-spiders i { position: absolute; top: 0; width: var(--sz); transform: translateY(-40px); animation: hw-dangle ease-in-out infinite; }
.hw-spiders i::before { content: ""; position: absolute; left: 50%; bottom: 70%; width: 1px; height: 100vh; background: rgba(233, 213, 255, .32); }
.hw-spiders i svg { position: relative; display: block; width: 100%; height: auto; filter: drop-shadow(0 0 3px rgba(249, 115, 22, .35));
  animation: hw-sway 2.6s ease-in-out infinite alternate; transform-origin: 50% -40%; }
.hw-spiders i svg path { stroke: #c4b5fd; }
.hw-spiders i svg ellipse, .hw-spiders i svg circle:first-of-type { fill: #3b2352; }
@keyframes hw-dangle {
  0% { transform: translateY(-40px); }
  35% { transform: translateY(var(--d)); }
  45% { transform: translateY(calc(var(--d) - 18px)); }
  55% { transform: translateY(var(--d)); }
  100% { transform: translateY(-40px); }
}
@keyframes hw-sway { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@media (prefers-reduced-motion: reduce) { .hw-spiders { display: none; } }

/* Đoàn chạy ngang thanh trên (15/10/2026): Giáng sinh = ông già Noel + tuần lộc, Tết = múa lân + trẻ con chạy theo.
   Nằm dưới nút / tiêu đề (z-index 0), chạy 1 lượt rồi nghỉ, lặp lại. */
.season-run { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.season-runner { position: absolute; left: -140px; bottom: 2px; width: 118px; animation: season-ride 34s linear infinite; animation-delay: 3s; }
.season-runner svg { display: block; width: 100%; height: auto; animation: season-bob .34s ease-in-out infinite alternate; }
.tet-lion { width: 112px; animation-duration: 40s; }
@keyframes season-ride { 0% { left: -140px; } 55% { left: 100%; } 100% { left: 100%; } }
@keyframes season-bob { from { transform: translateY(0); } to { transform: translateY(-2.5px); } }
.season-runner .run-a, .season-runner .run-b { transform-box: fill-box; transform-origin: 50% 0; animation: run-leg .34s ease-in-out infinite alternate; }
.season-runner .run-b { animation-direction: alternate-reverse; }
@keyframes run-leg { from { transform: rotate(-24deg); } to { transform: rotate(24deg); } }
.tet-lion .lan-head { transform-box: fill-box; transform-origin: 20% 90%; animation: lan-nod .5s ease-in-out infinite alternate; }
@keyframes lan-nod { from { transform: rotate(-7deg); } to { transform: rotate(6deg) translateY(-1px); } }
@media (max-width: 768px) { .season-runner { width: 86px; } .tet-lion { width: 82px; } }
@media (prefers-reduced-motion: reduce) { .season-run { display: none; } }
