
:root{
  --bg:#f5f7fb;--surface:#fff;--text:#172033;--muted:#6b7280;--line:#e5e9f0;
  --primary:#0f5fd7;--primary-dark:#084cab;--soft:#eef5ff;--ok:#168552;--ng:#c93c34;
  --warning:#9b6500;--shadow:0 8px 28px rgba(23,32,51,.08);--radius:18px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif}
button,input,select{font:inherit}
button{cursor:pointer}
.app-shell{max-width:620px;min-height:100vh;margin:0 auto;background:#f8fafc}
.header{position:sticky;top:0;z-index:20;background:rgba(248,250,252,.96);backdrop-filter:blur(10px);border-bottom:1px solid var(--line);padding:13px 16px}
.header-row{display:flex;align-items:center;gap:10px}
.back{width:42px;height:42px;border:1px solid var(--line);background:white;border-radius:12px;font-size:22px;line-height:1;flex:none}
.brand-logo{height:34px;width:auto;flex:none}
.header-title{font-size:20px;font-weight:800;line-height:1.25}
.header-sub{font-size:12px;color:var(--muted);margin-top:2px}
main{padding:16px 16px 36px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;margin-bottom:14px}
.hero{padding:20px;background:linear-gradient(140deg,#0f5fd7,#2c7df0);color:white;border:0}
.hero h1{font-size:25px;margin:0 0 8px;line-height:1.25}
.hero p{margin:0;color:rgba(255,255,255,.87);font-size:14px;line-height:1.55}
.kpi{display:flex;gap:10px;margin-top:16px;flex-wrap:wrap}
.kpi span{padding:7px 10px;background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.18);border-radius:999px;font-size:12px}
.section-title{font-size:15px;font-weight:800;margin:0 0 11px}
.action-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.action{min-height:92px;border:1px solid #dce3ee;background:white;border-radius:16px;padding:15px;text-align:left;color:var(--text)}
.action.primary{grid-column:1/-1;background:var(--soft);border-color:#bad4fb}
.action strong{display:block;font-size:16px;margin-bottom:5px}
.action span{display:block;color:var(--muted);font-size:12px;line-height:1.45}
.search-row{display:flex;gap:8px}
.input{width:100%;height:48px;border:1px solid #d9dee8;border-radius:13px;background:white;padding:0 13px;color:var(--text);outline:0}
.input:focus,.select:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(15,95,215,.12)}
.btn{height:48px;border:0;border-radius:13px;padding:0 16px;font-weight:750}
.btn-primary{background:var(--primary);color:white}
.btn-primary:hover{background:var(--primary-dark)}
.btn-soft{background:#eef1f5;color:#344054}
.btn-danger{background:#fff0ef;color:var(--ng);border:1px solid #ffd3cf}
.btn-block{width:100%}
.hint{font-size:12px;color:var(--muted);line-height:1.5;margin-top:10px}
.mold-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}
.mold-code{font-size:28px;font-weight:850;letter-spacing:.3px}
.product{font-size:14px;color:var(--muted);margin-top:2px}
.status{display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:7px 10px;font-weight:750;font-size:13px}
.status.ok{background:#eaf8f0;color:var(--ok)}
.status.ng{background:#fff0ef;color:var(--ng)}
.status.neutral{background:#f0f3f7;color:#556070}
.dot{width:8px;height:8px;border-radius:50%;background:currentColor}
.info-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:14px}
.info{padding:12px;border:1px solid var(--line);border-radius:14px;background:#fbfcfe}
.lbl{font-size:12px;color:var(--muted);margin-bottom:5px}
.val{font-size:14px;font-weight:700;overflow-wrap:anywhere}
.ops{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.op{min-height:56px;border:1px solid #dce3ee;background:white;border-radius:14px;padding:12px;text-align:left;font-weight:750;color:#243148}
.op.active{border-color:var(--primary);background:var(--soft);color:var(--primary)}
.form{display:none;margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}
.form.show{display:block}
.row{margin-bottom:12px}
label{display:block;font-size:13px;color:#465269;font-weight:700;margin-bottom:7px}
.select{width:100%;height:48px;border:1px solid #d9dee8;border-radius:12px;padding:0 12px;background:white;color:var(--text);outline:0}
.timeline{display:flex;flex-direction:column}
.timeline-item{display:grid;grid-template-columns:100px 1fr;gap:11px;padding:11px 0;border-bottom:1px solid var(--line)}
.timeline-item:last-child{border-bottom:0}
.time{font-size:12px;color:var(--muted);line-height:1.35}
.event{font-size:14px;font-weight:750}
.detail{font-size:13px;color:var(--muted);margin-top:4px;line-height:1.4}
.by{font-size:12px;color:#8a93a2;margin-top:3px;overflow-wrap:anywhere}
.scanner-box{position:relative;border-radius:18px;overflow:hidden;background:#111;min-height:340px;display:flex;align-items:center;justify-content:center}
.scanner-box video{width:100%;height:100%;min-height:340px;object-fit:cover;display:none}
.scan-placeholder{color:white;text-align:center;padding:28px}
.scan-frame{position:absolute;inset:50% auto auto 50%;width:230px;height:230px;transform:translate(-50%,-50%);border:3px solid rgba(255,255,255,.95);border-radius:22px;box-shadow:0 0 0 999px rgba(0,0,0,.25);pointer-events:none;display:none}
.scan-status{margin-top:10px;font-size:13px;color:var(--muted);line-height:1.5}
.error{color:var(--ng)}
.success{color:var(--ok)}
.toolbar{display:flex;gap:8px;flex-wrap:wrap}
.print-list{max-height:330px;overflow:auto;border:1px solid var(--line);border-radius:14px}
.print-row{display:grid;grid-template-columns:34px 1fr auto;gap:8px;align-items:center;padding:10px 12px;border-bottom:1px solid var(--line)}
.print-row:last-child{border-bottom:0}
.print-row input{width:18px;height:18px}
.print-code{font-weight:800}
.print-product{font-size:12px;color:var(--muted);margin-top:2px}
.badge{font-size:11px;border-radius:999px;background:#f0f3f7;padding:5px 8px;color:#556070}
.print-preview-title{display:flex;align-items:center;justify-content:space-between;gap:10px}
.label-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.qr-label{border:1px dashed #9aa4b2;border-radius:12px;padding:10px;background:white;display:grid;grid-template-columns:84px 1fr;gap:10px;align-items:center;min-height:105px}
.qr-label img{width:84px;height:84px;image-rendering:pixelated}
.qr-code{font-size:18px;font-weight:850}
.qr-product{font-size:11px;color:var(--muted);margin-top:3px}
.qr-note{font-size:9px;color:#7d8795;margin-top:7px}
.empty{padding:22px;text-align:center;color:var(--muted);font-size:13px}
.toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%) translateY(30px);width:min(92vw,540px);background:#172033;color:white;border-radius:14px;padding:13px 15px;box-shadow:0 14px 34px rgba(0,0,0,.2);opacity:0;pointer-events:none;transition:.22s;z-index:50}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.footer-note{text-align:center;font-size:11px;color:#8a93a2;margin-top:18px;line-height:1.55}
.footer-note .brand-line{color:#5b6575;font-weight:600}
.footer-note a{color:#0f5fd7;text-decoration:none}
.footer-note a:hover{text-decoration:underline}
@media(max-width:420px){
  .action-grid,.ops{grid-template-columns:1fr}
  .action.primary{grid-column:auto}
  .info-grid{grid-template-columns:1fr 1fr}
  .label-grid{grid-template-columns:1fr}
}
@media print{
  body{background:white}
  .app-shell,.toast{display:none!important}
  #print-sheet{display:grid!important;grid-template-columns:repeat(3,1fr);gap:4mm;padding:0}
  #print-sheet .qr-label{border:1px solid #777;border-radius:0;min-height:34mm;padding:3mm;grid-template-columns:27mm 1fr;break-inside:avoid;page-break-inside:avoid}
  #print-sheet .qr-label img{width:27mm;height:27mm}
  #print-sheet .qr-code{font-size:13pt}
  #print-sheet .qr-product{font-size:8pt}
  #print-sheet .qr-note{font-size:6pt}
  @page{size:A4;margin:8mm}
}
#print-sheet{display:none}

/* ===== roles, login, multi-select, admin ===== */
.rolebar{max-width:620px;margin:0 auto;display:flex;align-items:center;gap:8px;padding:8px 16px;background:#fff;border-bottom:1px solid var(--line);flex-wrap:wrap}
.role-chip{font-size:11px;font-weight:800;border-radius:999px;padding:4px 10px}
.role-public{background:#eef1f5;color:#475467}
.role-tech{background:#e7f0ff;color:#0f5fd7}
.role-admin{background:#fdecc8;color:#7a4c00}
.rb-who{font-size:12px;color:var(--muted);flex:1;min-width:80px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rb-btn{height:32px;border:1px solid var(--line);background:#fff;border-radius:9px;padding:0 12px;font-size:12px;font-weight:750;color:#344054}
.tag-auto{display:inline-block;font-size:10px;font-weight:700;background:#eef5ff;color:#0f5fd7;border-radius:6px;padding:2px 6px;margin-left:6px}
.muted-p{font-size:13px;color:var(--muted);line-height:1.5;margin:0 0 10px}
.op-multi{display:inline-block;font-size:10px;font-weight:800;background:#e7f0ff;color:#0f5fd7;border-radius:6px;padding:2px 6px;margin-left:4px;vertical-align:middle}
.check-list{display:flex;flex-direction:column;gap:8px;border:1px solid #d9dee8;border-radius:12px;padding:12px}
.check-item{display:flex;align-items:center;gap:10px;font-weight:600;color:#243148;margin:0}
.check-item input{width:20px;height:20px;flex:none}
.picked-row{display:flex;flex-wrap:wrap;gap:6px;min-height:8px}
.pill{font-size:12px;font-weight:750;background:var(--soft);color:var(--primary);border:1px solid #bad4fb;border-radius:999px;padding:4px 10px}
.actor-box{border:1px solid #d9dee8;border-radius:12px;padding:12px;background:#fbfcfe;font-weight:750}
.adm-table{border:1px solid var(--line);border-radius:12px;overflow:hidden}
.adm-row{display:grid;grid-template-columns:78px 1fr 70px 40px 56px;gap:6px;align-items:center;padding:9px 10px;border-bottom:1px solid var(--line);font-size:12px}
.adm-row-u{grid-template-columns:1fr 1fr 60px 54px 52px}
.adm-row:last-child{border-bottom:0}
.adm-head{background:#f5f7fb;font-weight:800;color:#556070}
.btn-xs{height:30px;padding:0 10px;font-size:12px;border-radius:8px}
.chip-wrap{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px;max-height:200px;overflow:auto;border:1px solid var(--line);border-radius:10px;padding:8px}
.chip-wrap:empty{display:none}
.chip{display:inline-flex;align-items:center;gap:4px;background:#f0f3f7;border:1px solid var(--line);border-radius:999px;padding:4px 4px 4px 10px;font-size:12px;font-weight:650}
.chip-txt{cursor:pointer}
.chip-x{width:20px;height:20px;border:0;background:#e2e7ef;border-radius:50%;font-size:13px;line-height:1;color:#556070}
.chip-x:hover{background:#ffd3cf;color:var(--ng)}
@media(max-width:420px){
  .adm-row{grid-template-columns:64px 1fr 56px 34px 48px;font-size:11px}
}
@media print{ .rolebar{display:none!important} }

/* ===== GĐ2: tra cứu thông tin khuôn ===== */
.spec-card{padding:0;overflow:hidden}
.spec-title{background:#16a34a;color:#fff;font-weight:800;font-size:16px;padding:12px 16px}
.spec-grid{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--line)}
.spec{background:#f7fbf5;padding:11px 14px;min-width:0}
.spec-lbl{font-size:12px;color:var(--muted);margin-bottom:3px}
.spec-val{font-size:17px;font-weight:800;color:var(--text);overflow-wrap:anywhere;line-height:1.3}
.spec-missing .spec-val{color:#8a93a2;font-weight:700}
.spec-nosource .spec-val{font-size:13px;font-style:italic}
@media(max-width:340px){.spec-grid{grid-template-columns:1fr}}
.info-wide{grid-column:1/-1}

/* ===== GĐ3: Dashboard 65" — co chu theo chieu rong man hinh (1920px ~16px, 3840px ~32px) ===== */
body.dash-mode{background:#eef2f7}
.dash{font-size:16px;font-size:clamp(13px,.83vw,44px);min-height:100vh;display:flex;flex-direction:column;gap:.7em;padding:.7em 1em;color:#111827}
.dash-top{display:flex;align-items:center;gap:.8em;background:#15803d;color:#fff;border-radius:.6em;padding:.45em .8em}
.dash-logo{height:2.1em;background:#fff;border-radius:.35em;padding:.15em .35em}
.dash-title{font-size:1.55em;font-weight:900;flex:1;white-space:nowrap}
.dash-meta{display:flex;flex-direction:column;align-items:flex-end;font-size:.95em;font-weight:600;gap:.15em}
.dash-error{background:#fee2e2;color:#991b1b;border-radius:.3em;padding:.1em .5em;font-weight:800}
.dash-btn{font-size:1em;height:2.3em;padding:0 .9em;border:0;border-radius:.45em;background:rgba(255,255,255,.18);color:#fff;font-weight:800}
.dash-back{font-size:1.4em;width:1.8em;padding:0;height:1.65em}
.dash-loading{grid-column:1/-1;padding:3em;text-align:center;font-size:1.4em;color:#6b7280}
.dash-body{flex:1;display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:.8em;min-height:0}
.dash-left,.dash-right{display:flex;flex-direction:column;gap:.8em;min-height:0}
.kpis{display:grid;grid-template-columns:1.35fr repeat(3,1fr) 1.25fr;gap:.6em}
.kpi-box{background:#fff;border-radius:.6em;padding:.6em .8em;border-top:.35em solid #64748b;box-shadow:0 1px 3px rgba(0,0,0,.08)}
.kpi-l{font-size:1em;font-weight:800;color:#374151;line-height:1.25}
.kpi-v{font-size:3.4em;font-weight:900;line-height:1.05;margin-top:.1em}
.kpi-s{font-size:.9em;color:#4b5563;font-weight:600;margin-top:.15em}
.kpi-total{border-top-color:#1d4ed8}.kpi-total .kpi-v{color:#1d4ed8}
.kpi-ok{border-top-color:#16a34a}.kpi-ok .kpi-v{color:#15803d}
.kpi-ng{border-top-color:#dc2626}.kpi-ng .kpi-v{color:#dc2626}
.kpi-nu{border-top-color:#9ca3af}.kpi-nu .kpi-v{color:#4b5563}
.kpi-machine{border-top-color:#0f766e}.kpi-machine .kpi-v{color:#0f766e}
.dp{background:#fff;border-radius:.6em;padding:.6em .8em;box-shadow:0 1px 3px rgba(0,0,0,.08);min-height:0;display:flex;flex-direction:column}
.dp h2{font-size:1.2em;font-weight:900;margin:0 0 .4em}
.dp-head{display:flex;align-items:baseline;justify-content:space-between;gap:.6em;flex-wrap:wrap}
.dp-count{font-weight:800;color:#991b1b}
.legend{display:flex;align-items:center;gap:.4em;flex-wrap:wrap;font-size:.9em;font-weight:700}
.lg{padding:.1em .5em;border-radius:.3em}
.lg-empty{border:1px dashed #9ca3af;color:#6b7280}
.lg-note{color:#6b7280;font-weight:600}
.dp-machines{flex:1}
.machines{flex:1;display:grid;grid-template-columns:repeat(10,minmax(0,1fr));grid-auto-rows:minmax(0,1fr);gap:.4em;min-height:0}
.mt{border:.12em solid #cbd5e1;border-radius:.45em;padding:.25em .3em;display:flex;flex-direction:column;gap:.2em;overflow:hidden;background:#f8fafc;min-width:0}
.mt-name{font-weight:900;font-size:1.05em;line-height:1.1}
.mt-mold{border-radius:.3em;padding:.12em .3em;display:flex;flex-direction:column;line-height:1.15;min-width:0}
.mt-mold b{font-size:.98em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mt-mold span{font-size:.85em;white-space:normal;overflow-wrap:anywhere}
.mt-empty{background:#fff;border-style:dashed}
.mt-free{color:#9ca3af;font-weight:700;font-size:.9em}
.mt-inactive{opacity:.75}
.st-ng{background:#dc2626;color:#fff}
.st-ok{background:#16a34a;color:#fff}
.st-notUpdated{background:#e2e8f0;color:#1f2937}
.st-other{background:#fff;color:#1f2937;border:1px dashed #475569}
.dp-ng{flex:1.4}
.dl-wrap{overflow:auto;min-height:0}
.dl{width:100%;border-collapse:collapse;font-size:1em}
.dl th{text-align:left;font-size:.9em;color:#4b5563;border-bottom:.12em solid #e5e7eb;padding:.25em .35em}
.dl td{padding:.3em .35em;border-bottom:1px solid #f1f5f9;overflow-wrap:anywhere}
.tag-machine{font-size:.75em;background:#fee2e2;color:#991b1b;border-radius:.3em;padding:.05em .35em;font-weight:800;white-space:nowrap}
.dl-empty{color:#15803d;font-weight:800;padding:.6em 0}
.dl-note{font-size:.85em;color:#6b7280;margin-bottom:.2em}
.dl-cols{display:grid;grid-template-columns:1fr 1.2fr .8fr;font-size:.9em;color:#4b5563;font-weight:700;border-bottom:.12em solid #e5e7eb;padding:.2em .35em}
.dl-pending{margin-top:.4em;background:#f1f5f9;border:1px dashed #94a3b8;border-radius:.4em;padding:.45em .6em;color:#475569;font-weight:600;font-size:.92em}
.lt-controls{display:flex;gap:.35em;flex-wrap:wrap;align-items:center}
.lt-btn{font-size:1em;height:2.1em;padding:0 .9em;border:1px solid #cbd5e1;background:#fff;border-radius:.4em;font-weight:800;color:#1f2937}
.lt-btn.active{background:#15803d;border-color:#15803d;color:#fff}
.lt-date{font-size:1em;height:2.1em;border:1px solid #cbd5e1;border-radius:.4em;padding:0 .4em}
.lt-range{margin-top:.4em}
/* Vua khit 1 man hinh (TV 1920x1080 / 3840x2160); man thap hon thi cuon tu nhien de khong cat noi dung */
@media(min-width:1101px) and (min-height:860px){
  body.dash-mode #app{height:100vh;display:flex;flex-direction:column;overflow:hidden}
  body.dash-mode .dash{flex:1;min-height:0}
}
@media(min-width:1101px) and (max-height:859px){
  .machines{grid-auto-rows:auto}
}
@media(max-width:1100px){
  .dash{font-size:14px}
  .dash-body{grid-template-columns:1fr}
  .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
  .kpi-total{grid-column:1/-1}
  .machines{grid-template-columns:repeat(auto-fill,minmax(96px,1fr));grid-auto-rows:auto}
  .dash-title{font-size:1.2em;white-space:normal}
  .dash-top{flex-wrap:wrap}
}

/* ===== nhan moi truong UAT ===== */
.env-banner{position:sticky;top:0;z-index:60;height:32px;line-height:32px;background:#b42318;color:#fff;text-align:center;font-weight:800;font-size:13px;padding:0 12px;letter-spacing:.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media(max-width:560px){.env-extra{display:none}}
.env-banner ~ .app-shell .header{top:32px}
@media print{ .env-banner{display:none!important} }

/* ===== loading indicator ===== */
body.loading .app-shell{opacity:.6;pointer-events:none}

/* ===== modal ===== */
.modal-overlay{position:fixed;inset:0;background:rgba(15,23,42,.5);display:flex;align-items:flex-end;justify-content:center;z-index:70;padding:0}
.modal-card{background:#fff;border-radius:18px 18px 0 0;width:100%;max-width:640px;max-height:88vh;overflow:auto;padding:18px}
@media(min-width:640px){.modal-overlay{align-items:center;padding:20px}.modal-card{border-radius:18px}}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;gap:10px}
.modal-close{width:34px;height:34px;flex:none;border:0;background:#f0f3f7;border-radius:50%;font-size:18px;line-height:1}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media(max-width:480px){.form-grid{grid-template-columns:1fr}}
.field-error{border-color:var(--ng)!important}
.details-toggle{background:none;border:0;color:var(--primary);font-weight:700;font-size:13px;padding:6px 0;text-align:left}

/* ===== import ===== */
.import-drop{border:2px dashed #bcd0ee;border-radius:14px;padding:24px;text-align:center;color:var(--muted);background:#fbfcfe}
.import-summary{display:flex;gap:10px;flex-wrap:wrap;margin:12px 0}
.import-stat{flex:1;min-width:90px;border-radius:12px;padding:10px;text-align:center;font-weight:800}
.import-stat.new{background:#eaf8f0;color:var(--ok)}
.import-stat.update{background:#eef5ff;color:var(--primary)}
.import-stat.error{background:#fff0ef;color:var(--ng)}
.import-stat span{display:block;font-size:11px;font-weight:600;color:var(--muted);margin-top:2px}
.import-row-list{max-height:260px;overflow:auto;border:1px solid var(--line);border-radius:12px;font-size:12px}
.import-row-item{display:grid;grid-template-columns:40px 60px 1fr 1fr;gap:6px;padding:7px 10px;border-bottom:1px solid var(--line)}
.import-row-item:last-child{border-bottom:0}
.import-row-item.err{background:#fff8f7}
