* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; background: #eef1f5; color: #1f2933; }
button { font-family: inherit; cursor: pointer; }
a { cursor: pointer; }

/* LOGIN */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 360px; box-shadow: 0 14px 44px rgba(20,30,50,.12); }
.login-card .logo { text-align: center; font-size: 38px; }
/* Logo SISC GROUP ở màn hình đăng nhập */
.login-card .logo-img { display: block; width: 150px; max-width: 60%; height: auto; margin: 0 auto 12px; }
.login-card h1 { text-align: center; margin: 4px 0 2px; letter-spacing: 1px; }
.login-card .sub { text-align: center; color: #7a8593; margin: 0 0 18px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: #7a8593; margin: 12px 0 4px; }
.login-card input { width: 100%; padding: 11px 12px; font-size: 15px; border: 1px solid #cfd8e2; border-radius: 8px; }
.login-card input:focus { outline: none; border-color: #2f6fe0; box-shadow: 0 0 0 3px #2f6fe022; }
.login-card button { width: 100%; margin-top: 18px; padding: 12px; font-size: 15px; font-weight: 600; color: #fff; background: #2f6fe0; border: 0; border-radius: 9px; }
.login-card button:hover { background: #285fc4; }
.err { color: #dc2626; font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* APP */
#app { display: flex; min-height: 100vh; }
.side { width: 210px; background: #14243b; color: #cdd7e5; flex-shrink: 0; }
/* Brand sidebar: logo SISC (nền tối -> đặt trên nền trắng bo góc để giữ màu thương hiệu) + tên app */
.side .brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; padding: 14px 16px; border-bottom: 1px solid #223655; }
.side .brand img { width: 38px; height: 38px; flex: none; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; box-sizing: border-box; }
.side .brand span { letter-spacing: .5px; }
.side nav a { display: block; padding: 12px 20px; color: #b9c6d8; text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
.side nav a:hover { background: #1b3050; color: #fff; }
.side nav a.active { background: #1b3050; color: #fff; border-left-color: #3b82f6; }
main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid #dbe1e8; display: flex; align-items: center; padding: 0 22px; gap: 14px; }
.topbar #viewTitle { font-size: 17px; font-weight: 700; }
.topbar .sp { flex: 1; }
.topbar .who { font-size: 14px; }
.topbar .role { margin-left: 6px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #e3f0ff; color: #2f6fe0; }
.topbar .role.staff { background: #fff2e0; color: #b45309; }
.topbar #logout { padding: 8px 14px; border: 1px solid #cfd8e2; background: #fff; border-radius: 8px; font-size: 13px; }
#content { padding: 22px; }

/* Cards */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid #dbe1e8; border-radius: 12px; padding: 18px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: #7a8593; font-size: 13px; margin-top: 4px; }
.stat.warn { background: #fff7d6; border-color: #f5d98a; }
.stat.err { background: #fde8e8; border-color: #f5b5b5; }

/* Panel + table */
.panel { background: #fff; border: 1px solid #dbe1e8; border-radius: 12px; overflow: hidden; }
.panel .ph { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eef1f5; }
.panel .ph h3 { margin: 0; font-size: 15px; }
.panel .ph .sp { flex: 1; }
.panel .ph button { padding: 8px 14px; background: #2f6fe0; color: #fff; border: 0; border-radius: 8px; font-size: 13px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #eef1f5; white-space: nowrap; }
th { background: #f7f9fb; color: #7a8593; font-size: 12px; font-weight: 600; }
tr:hover td { background: #fafbfc; }
tr.row-warning td { background: #fff7d6; }
tr.row-warning:hover td { background: #fdefc0; }
tr.row-error td { background: #fde8e8; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; }
.st-normal { background: #e6f7ee; color: #17a05a; }
.st-warning { background: #fff2c2; color: #b45309; }
.st-error { background: #fde0e0; color: #dc2626; }
.st-offline { background: #edf1f5; color: #7a8593; }
.sev-low { background: #e6f7ee; color: #17a05a; }
.sev-medium { background: #fff2c2; color: #b45309; }
.sev-high { background: #fde0e0; color: #dc2626; }
.ic-open { background: #dbeafe; color: #2563eb; }
.ic-in_progress { background: #fef3c7; color: #b45309; }
.ic-resolved { background: #e6f7ee; color: #17a05a; }
.ic-closed { background: #edf1f5; color: #7a8593; }

td select, td button.mini { font-size: 12px; padding: 4px 8px; border: 1px solid #cfd8e2; border-radius: 6px; background: #fff; }
.pcchips { display: flex; flex-wrap: wrap; gap: 5px; }
.pcchip { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid #cfd8e2; cursor: pointer; }
.pcchip.on { background: #17a05a; color: #fff; border-color: #17a05a; }
.empty { padding: 30px; text-align: center; color: #9aa4b2; }

/* Modal */
/* z-index phải CAO HƠN Handsontable (tiêu đề cột/hàng cố định dùng z-index ~101-107),
   nếu không popup sẽ bị tiêu đề cột của lưới đè lên. */
.modal-mask { position: fixed; inset: 0; background: rgba(20,28,40,.42); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 460px; max-width: 92vw; box-shadow: 0 20px 60px rgba(10,20,40,.3); overflow: hidden; }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid #e6eaf0; font-weight: 700; }
.modal .mb { padding: 20px 22px; max-height: 62vh; overflow: auto; }

/* ---------------------------------------------------------------------------
   HỆ FORM THỐNG NHẤT (dùng cho mọi popup)
   • Mọi ô nhập cùng CHIỀU CAO 38px, cùng bo góc, cùng viền, cùng cỡ chữ.
   • Bố cục lưới 2 cột: field ngắn (mã, ngày, số…) đi cặp; field dài chiếm cả hàng.
   • Nhãn nằm TRÊN ô, cùng khoảng cách -> các hàng thẳng nhau, không so le.
   --------------------------------------------------------------------------- */
/* ===========================================================================
   TIỆN ÍCH DÙNG CHUNG — thay cho style="" viết thẳng trong JS.
   Mọi CSS của dự án nằm ở FILE NÀY; các file .js chỉ gắn class.
   =========================================================================== */
.dim { color: #9aa4b2; }                 /* chữ phụ, mờ */
.sub { font-size: 12px; color: #7a8593; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row-8 { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; box-sizing: border-box; }
.pad-x { padding-left: 18px; padding-right: 18px; }
.pad { padding: 16px 18px; }
.mt-0 { margin-top: 0; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; }
.mb-6 { margin-bottom: 6px; } .mb-8 { margin-bottom: 8px; } .mb-10 { margin-bottom: 10px; }
.m-0 { margin: 0; }
.hr-soft { border: 0; border-top: 1px solid #eef1f5; margin: 14px 0; }
:root[data-theme=dark] .hr-soft { border-color: #24303f; }
:root[data-theme=dark] .dim { color: #7d8b9c; }

/* Popup có lưới form -> tự nới rộng để 2 cột thở được (popup thường vẫn 460px) */
.modal:has(.mb > .form-grid) { width: 660px; }
.modal.wide:has(.mb > .form-grid) { width: 1180px; }
@media (max-width: 700px) { .modal:has(.mb > .form-grid) { width: 92vw; } .modal .mb .form-grid { grid-template-columns: 1fr; } }
.modal .mb .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.modal .mb .fld { display: flex; flex-direction: column; min-width: 0; }         /* 1 ô = nửa hàng */
.modal .mb .fld.full { grid-column: 1 / -1; }                                    /* chiếm cả hàng */
.modal .mb .fld > label { margin: 0 0 5px; }
.modal .mb .fld .hint { font-size: 11px; color: #9aa4b2; margin-top: 4px; }
/* Ô nhập kèm nút bên phải (VD: Mã số thuế + Lấy dữ liệu) — nút cùng chiều cao với ô */
.modal .mb .in-btn { display: flex; gap: 8px; }
.modal .mb .in-btn input { flex: 1; min-width: 0; }
.modal .mb .in-btn button { height: 38px; padding: 0 14px; white-space: nowrap; border: 1px solid #cfd8e2; border-radius: 8px; background: #fff; font-size: 13px; }
.modal .mb .checkline { align-items: center; gap: 10px; margin: 0; padding: 9px 12px; border: 1px solid #e3e8ee; border-radius: 8px; }
.modal .mb .checkline input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.modal .mb .checkline label { margin: 0; font-size: 13.5px; color: #1f2933; font-weight: 500; }
:root[data-theme=dark] .modal .mb .checkline { border-color: #2c3a4c; }
:root[data-theme=dark] .modal .mb .checkline label { color: #e3e8ef; }
:root[data-theme=dark] .modal .mb .in-btn button { background: #1b2634; border-color: #2c3a4c; color: #d7dee7; }
.modal .mb .form-sec { grid-column: 1 / -1; margin-top: 6px; padding-top: 12px; border-top: 1px solid #eef1f5; font-size: 12px; font-weight: 700; color: #57626f; text-transform: uppercase; letter-spacing: .4px; }
.modal .mb .form-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.modal .mb label { display: block; font-size: 12px; color: #7a8593; margin: 12px 0 5px; font-weight: 600; }
.modal .mb input:not([type=checkbox]):not([type=radio]):not([type=file]),
.modal .mb select,
.modal .mb textarea {
  width: 100%; box-sizing: border-box; height: 38px; padding: 0 12px;
  border: 1px solid #cfd8e2; border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: #1f2933; transition: border-color .12s, box-shadow .12s;
}
.modal .mb textarea { height: auto; min-height: 76px; padding: 9px 12px; line-height: 1.5; resize: vertical; }
.modal .mb select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7a8593 50%), linear-gradient(135deg, #7a8593 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.modal .mb select[size] { height: auto; padding: 6px; background-image: none; }
.modal .mb input:focus, .modal .mb select:focus, .modal .mb textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,224,.14); }
.modal .mb input:disabled, .modal .mb select:disabled { background: #f4f6f9; color: #7a8593; }
.modal .mb input[type=checkbox], .modal .mb input[type=radio] { width: auto; height: auto; }
:root[data-theme=dark] .modal .mb input:disabled, :root[data-theme=dark] .modal .mb select:disabled { background: #1b2634; }
:root[data-theme=dark] .modal .mb .form-sec { border-color: #24303f; color: #9aa7b8; }
.modal.wide { width: 1180px; }
.modal.wide .mb { max-height: 76vh; }
.modal .mf { padding: 14px 20px; border-top: 1px solid #e6eaf0; display: flex; justify-content: flex-end; gap: 10px; }

/* Popup biểu đồ biến — điều khiển 1 hàng ngang gọn, cùng chiều cao, giãn cách đều */
.vc-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 12px; }
.vc-controls label, .vc-group { font-size: 11px; color: #7a8593; display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; flex: none; }
.vchart .right .rowval { width: 74px; padding: 3px 5px; border: 1px solid #cfd8e2; border-radius: 6px; font-size: 12px; }
.vchart .right .rowdel { border: 0; background: transparent; color: #dc2626; cursor: pointer; font-size: 12px; margin-left: 3px; }
.vc-group { border-left: 1px solid #e6eaf0; padding-left: 14px; }
.vc-controls select, .vc-controls input, .vc-controls button { height: 34px; box-sizing: border-box; vertical-align: middle; flex: none; }
.vc-controls select, .vc-controls input { padding: 4px 8px; border: 1px solid #cfd8e2; border-radius: 6px; font-size: 13px; color: #1f2933; background: #fff; }
.vc-controls select { width: 118px; max-width: 118px; }
.vc-controls input[type=number] { width: 66px; text-align: center; }
.vc-controls input[type=number]::-webkit-inner-spin-button, .vc-controls input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.vc-controls input[type=datetime-local] { width: 142px; padding: 0 4px; font-size: 11px; }
.vc-controls button { padding: 0 9px; font-size: 12px; }
.vchart { display: flex; gap: 16px; }
.vchart .left { flex: 1.5; min-width: 0; }
.vchart .left canvas { width: 100%; height: 340px; display: block; border: 1px solid #eef1f5; border-radius: 8px; background: #fff; }
.vchart .right { flex: 1; min-width: 0; max-height: 366px; overflow: auto; border: 1px solid #eef1f5; border-radius: 8px; }
.vchart .right table { width: 100%; min-width: 0; }
.vchart .right thead th { position: sticky; top: 0; background: #f7f9fb; z-index: 1; }
.vchart .right tbody tr { cursor: pointer; }
.vchart .right tbody tr:hover td { background: #fafbfc; }
.vchart .right tbody tr.sel td { background: #fdebc7; }
@media (max-width: 760px) { .modal.wide { width: 96vw; } .vchart { flex-direction: column; } .vchart .right { max-height: 240px; } }
.modal .mf button { padding: 9px 18px; border-radius: 8px; border: 1px solid #cfd8e2; background: #fff; }
.modal .mf button.ok { background: #2f6fe0; color: #fff; border-color: #2f6fe0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 10px 20px; border-radius: 8px; opacity: 0; transition: opacity .2s; z-index: 1100; pointer-events: none; }
.toast.show { opacity: .96; }
.mgr-only.hide { display: none; }

/* Clickable rows + links */
tr.clickable { cursor: pointer; }
.link { color: #2f6fe0; text-decoration: none; }
.link:hover { text-decoration: underline; }
.backbtn { background: #fff; border: 1px solid #cfd8e2; border-radius: 8px; padding: 7px 13px; font-size: 13px; margin-bottom: 14px; }
.rowbtns { display: flex; gap: 6px; }
.btn-ghost { padding: 4px 10px; border: 1px solid #cfd8e2; border-radius: 6px; background: #fff; font-size: 12px; }
.btn-danger { border-color: #f0b4b4; color: #dc2626; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* Detail header info grid */
.detail-head { background: #fff; border: 1px solid #dbe1e8; border-radius: 12px; padding: 18px 20px; }
.detail-head h2 { margin: 0 0 3px; font-size: 20px; }
.detail-head .muted { color: #7a8593; font-size: 13px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 22px; margin-top: 14px; }
.info-grid .k { color: #7a8593; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.info-grid .v { font-size: 14px; margin-top: 2px; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #eef1f5; }
.section-head h3 { margin: 0; font-size: 15px; }
.section-head .sp { flex: 1; }
.section-head button { padding: 7px 13px; background: #2f6fe0; color: #fff; border: 0; border-radius: 8px; font-size: 13px; }

/* Online dot */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: #c3ccd6; }
.dot.on { background: #17a05a; box-shadow: 0 0 0 3px #17a05a22; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #edf1f5; color: #57626f; }
.pill.on { background: #e6f7ee; color: #17a05a; }
.op-running { background: #e6f7ee; color: #17a05a; }
.op-stopped { background: #fde0e0; color: #dc2626; }
.op-maintenance { background: #fef3c7; color: #b45309; }

/* Field / variable blocks */
.field-block { border: 1px solid #e6eaf0; border-radius: 10px; margin: 12px 18px; overflow: hidden; }
.field-block .fh { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #f7f9fb; border-bottom: 1px solid #eef1f5; }
.field-block .fh b { font-size: 14px; }
.field-block .fh .sp { flex: 1; }
.val-ok { color: #17a05a; font-weight: 600; }
.val-bad { color: #dc2626; font-weight: 700; }
.val-na { color: #9aa4b2; }

/* Ticket priority/channel/status badges */
.pr-urgent { background: #fde0e0; color: #dc2626; }
.pr-high { background: #ffe4cc; color: #c2410c; }
.pr-medium { background: #fff2c2; color: #b45309; }
.pr-low { background: #e6f7ee; color: #17a05a; }
.tk-new { background: #dbeafe; color: #2563eb; }
.tk-assigned { background: #e0e7ff; color: #4f46e5; }
.tk-in_progress { background: #fef3c7; color: #b45309; }
.tk-waiting { background: #f3e8ff; color: #9333ea; }
.tk-resolved { background: #e6f7ee; color: #17a05a; }
.tk-closed { background: #edf1f5; color: #7a8593; }

/* Mã lỗi / sự cố */
.errwrap { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.errchip { font-size: 12px; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.errchip.sev-low { background: #e6f7ee; color: #17a05a; }
.errchip.sev-medium { background: #fff2c2; color: #b45309; }
.errchip.sev-high { background: #fde0e0; color: #dc2626; }
.errchip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 12px; opacity: .7; padding: 0; }
.errchip button:hover { opacity: 1; }

/* Chat khách hàng <-> CSKH */
.chat-thread { padding: 16px 18px; max-height: 480px; overflow-y: auto; background: #f4f6f9; }
.msg { display: flex; margin-bottom: 12px; }
.msg.me { justify-content: flex-end; }
.msg .bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; box-shadow: 0 1px 2px rgba(20,30,50,.06); }
.msg.them .bubble { background: #fff; border: 1px solid #e6eaf0; border-bottom-left-radius: 4px; }
.msg.me .bubble { background: #2f6fe0; color: #fff; border-bottom-right-radius: 4px; }
.msg .mtext { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg .mmeta { font-size: 11px; margin-top: 5px; opacity: .7; }
.msg .matts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg .matt { width: 150px; max-height: 150px; border-radius: 8px; object-fit: cover; display: block; cursor: pointer; background: #eef1f5; }
video.matt { object-fit: contain; }
.sysline { text-align: center; margin: 10px 0; }
.sysline span { display: inline-block; background: #e9edf3; color: #6b7688; font-size: 12px; padding: 3px 12px; border-radius: 999px; }

/* Composer */
.composer { border-top: 1px solid #eef1f5; padding: 12px 16px; background: #fff; }
.side-toggle { display: inline-flex; border: 1px solid #cfd8e2; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.side-toggle button { border: 0; background: #fff; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.side-toggle button.on { background: #2f6fe0; color: #fff; }
.composer textarea { width: 100%; border: 1px solid #cfd8e2; border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 14px; resize: vertical; }
.attprev { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attchip { font-size: 12px; background: #eef3fb; border-radius: 999px; padding: 3px 10px; display: inline-flex; align-items: center; gap: 6px; }
.attchip button { border: 0; background: transparent; cursor: pointer; color: #7a8593; }
.composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.send-btn { padding: 9px 20px; background: #2f6fe0; color: #fff; border: 0; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.send-btn:disabled { opacity: .6; }

/* Care-history timeline */
.timeline { padding: 8px 18px 18px; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed #eef1f5; }
.tl-icon { width: 34px; height: 34px; border-radius: 50%; background: #eef3fb; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-meta { color: #7a8593; font-size: 12px; margin-top: 3px; }
.tl-body .tl-content { white-space: pre-wrap; word-break: break-word; }

/* Toolbar (search + filters + view toggle) */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid #eef1f5; }
.toolbar input, .toolbar select { padding: 8px 11px; border: 1px solid #cfd8e2; border-radius: 8px; font-size: 13px; font-family: inherit; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .sp { flex: 1; }
.viewtoggle { display: flex; border: 1px solid #cfd8e2; border-radius: 8px; overflow: hidden; }
.viewtoggle button { border: 0; background: #fff; padding: 8px 12px; font-size: 13px; }
.viewtoggle button.on { background: #2f6fe0; color: #fff; }

/* Device grid (dạng ô) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding: 18px; }
.dcard { border: 1px solid #e0e6ee; border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; transition: box-shadow .15s, transform .05s; }
.dcard:hover { box-shadow: 0 8px 22px rgba(20,30,50,.1); transform: translateY(-1px); }
.dcard .thumb { height: 140px; background: #f2f5f9 center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 44px; color: #c3ccd6; }
.dcard .body { padding: 12px 14px; }
.dcard .body h4 { margin: 0 0 3px; font-size: 15px; }
.dcard .body .meta { color: #7a8593; font-size: 12px; margin-bottom: 8px; }
.dcard .body .foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Image gallery */
.gallery { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 18px; }
.gallery .gi { position: relative; width: 130px; height: 100px; border-radius: 10px; border: 1px solid #e0e6ee; background: #f2f5f9 center/cover no-repeat; }
.gallery .gi .del { position: absolute; top: 4px; right: 4px; background: rgba(20,25,35,.65); color: #fff; border: 0; border-radius: 6px; width: 22px; height: 22px; font-size: 13px; cursor: pointer; }
.gallery .gi.default::after { content: 'Mặc định'; position: absolute; left: 4px; bottom: 4px; background: rgba(20,25,35,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 5px; }
.thumb-img { width: 130px; height: 100px; border-radius: 10px; border: 1px solid #e0e6ee; background: #f2f5f9 center/cover no-repeat; }

/* Device ↔ PC connection row */
.conn { display: flex; align-items: center; gap: 0; padding: 8px 18px 4px; flex-wrap: wrap; }
.conn .node { flex: 1; min-width: 200px; border: 1px solid #e0e6ee; border-radius: 12px; padding: 14px 16px; background: #fbfcfe; }
.conn .node .t { font-size: 11px; color: #7a8593; text-transform: uppercase; letter-spacing: .3px; }
.conn .node .m { font-size: 16px; font-weight: 700; margin-top: 2px; }
.conn .node .s { font-size: 12px; color: #57626f; margin-top: 4px; }
.conn .wire { flex: 0 0 70px; text-align: center; color: #9aa4b2; font-size: 13px; position: relative; }
.conn .wire::before { content: ''; position: absolute; top: 50%; left: 6px; right: 6px; height: 2px; background: repeating-linear-gradient(90deg,#c3ccd6 0 6px,transparent 6px 11px); }
.conn .wire span { position: relative; background: #fff; padding: 0 4px; }
.conn .wire.on { color: #17a05a; }
.conn .wire.on::before { background: #17a05a; }
.conn .pcstack { flex: 2; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.pcnode { display: flex; align-items: center; gap: 12px; border: 1px solid #e0e6ee; border-radius: 12px; padding: 12px 14px; background: #fbfcfe; flex-wrap: wrap; }
.pcnode .m { font-size: 15px; font-weight: 700; }
.pcnode .s { font-size: 12px; color: #7a8593; margin-top: 3px; }
.pc-connect { padding: 8px 16px; background: #17a05a; color: #fff; border: 0; border-radius: 8px; font-size: 13px; font-weight: 600; }
.pc-connect:hover { background: #148a4d; }

/* Settings tabs */
.tabs { display: flex; gap: 8px; padding: 12px 18px 0; }
.tabs button { padding: 8px 16px; border: 1px solid #cfd8e2; border-bottom: 0; background: #f7f9fb; border-radius: 8px 8px 0 0; font-size: 13px; }
.tabs button.on { background: #fff; font-weight: 600; color: #2f6fe0; }
.map-link { color: #2f6fe0; text-decoration: none; font-size: 13px; }
.mapbox { margin-top: 10px; border-radius: 10px; overflow: hidden; border: 1px solid #e0e6ee; }
.mapbox iframe { width: 100%; height: 180px; border: 0; display: block; }

/* Chi tiết thiết bị 2 cột: trái rộng, phải hẹp gọn */
.dev2col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.dev2col > .col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 980px) { .dev2col { grid-template-columns: 1fr; } }

/* Địa chỉ nằm ngang (label + nội dung cùng dòng, tự tràn dòng) */
.addr-line { font-size: 13px; line-height: 1.55; word-break: break-word; }
.addr-line .klabel { color: #7a8593; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .3px; margin-right: 5px; }

/* Lịch sử đăng nhập (log truy cập) */
.loglist { padding: 6px 16px 14px; }
.logitem { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #eef1f5; align-items: flex-start; }
.logitem:last-child { border-bottom: 0; }
.logitem b { font-size: 13px; }
.logitem .s { font-size: 12px; color: #7a8593; margin-top: 2px; word-break: break-word; }

/* Mini chart */
.chart-wrap { padding: 14px 18px; }
.chart-wrap canvas { width: 100%; max-width: 720px; height: 220px; border: 1px solid #eef1f5; border-radius: 8px; background: #fff; }
.checkline { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.checkline input { width: auto; }

/* Đánh giá hài lòng: bộ sao */
.stars { display: inline-flex; gap: 2px; font-size: 20px; line-height: 1; user-select: none; }
.stars .star { color: #d4dbe3; cursor: pointer; transition: color .1s; }
.stars .star.on { color: #f5a623; }
.stars.ro { font-size: 15px; }
.stars.ro .star { cursor: default; }
.rating-box { padding: 8px 18px 16px; }
.rate-row { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.rate-row .rate-label { width: 200px; font-size: 13px; color: #3a4652; }
.rating-box textarea { width: 100%; box-sizing: border-box; }
.rate-summary { font-size: 13px; color: #3a4652; background: #fff8ec; border: 1px solid #f5deb0; padding: 6px 12px; border-radius: 8px; }
.nowrap { white-space: nowrap; }

/* Ô hiển thị mật khẩu (reset / tạo mới) */
.pwbox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; letter-spacing: 2px; text-align: center; background: #f4f7fb; border: 1px dashed #b8c4d2; border-radius: 8px; padding: 14px; margin-top: 10px; user-select: all; color: #16324f; }

/* Hộp chip (tỉnh/thành của khu vực) */
.chipbox { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chipbox .pcchip button { border: 0; background: transparent; color: inherit; cursor: pointer; margin-left: 4px; font-size: 12px; }

/* Dấu quyền trong bảng nhóm nhân sự */
.yes { color: #17a05a; font-weight: 700; }
.no { color: #c3ccd6; }

/* Danh sách phân quyền trong popup nhóm nhân sự (checkbox trái · mô tả phải) */
.modal .mb .perm-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 0; }
.modal .mb .perm-row { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 11px 13px; border: 1px solid #e3e8ee; border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s; }
.modal .mb .perm-row:hover { border-color: #b9c6d6; background: #fafbfc; }
.modal .mb .perm-row input[type=checkbox] { width: 18px; height: 18px; margin: 1px 0 0; flex: none; cursor: pointer; accent-color: #2f6fe0; }
.modal .mb .perm-row:has(input:checked) { border-color: #2f6fe0; background: #f2f7ff; }
.modal .mb .perm-row .perm-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal .mb .perm-row .perm-txt b { font-size: 13.5px; color: #1f2933; }
.modal .mb .perm-row .perm-txt span { font-size: 12px; color: #7a8593; line-height: 1.4; }

/* Thư viện lỗi (Handsontable) */
/* Vô hiệu hoá CSS bảng CHUNG của app bên trong Handsontable (min-width 640px làm lệch overlay) */
.handsontable table { min-width: 0; width: auto; border-collapse: separate; font-size: 13px; }
.handsontable th, .handsontable td { white-space: normal; min-width: 0; }
.errlib-panel { overflow: visible; }
.err-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #eef1f5; }
.err-toolbar select { height: 34px; padding: 4px 10px; border: 1px solid #cfd8e2; border-radius: 8px; font-size: 13px; background: #fff; }
.err-toolbar .err-groups { margin-left: auto; font-size: 12px; color: #57626f; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* KHÔNG dùng padding cho container Handsontable — padding làm lệch overlay tiêu đề so với thân.
   Dùng margin để tạo khoảng cách. */
.hot-wrap { margin: 14px 18px 4px; }
.hot-wrap.handsontable { font-size: 13px; }
.err-actions { display: flex; align-items: center; gap: 10px; padding: 6px 18px 16px; flex-wrap: wrap; }
.err-search { padding: 12px 18px 0; }
.err-search input { width: 340px; max-width: 100%; height: 34px; padding: 6px 12px; border: 1px solid #cfd8e2; border-radius: 8px; font-size: 13px; background: #fff; }
.err-actions .rown { width: 62px; height: 34px; text-align: center; padding: 4px; border: 1px solid #cfd8e2; border-radius: 8px; font-size: 13px; }
.err-imgs { display: flex; flex-wrap: wrap; gap: 10px; }
.err-img { position: relative; width: 110px; height: 110px; border: 1px solid #e3e8ee; border-radius: 8px; overflow: hidden; }
.err-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.err-img button { position: absolute; top: 3px; right: 3px; border: 0; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.img-cell { cursor: pointer; color: #2f6fe0; font-weight: 600; }
/* Ô đã sửa (vàng) / dòng thêm mới (xanh) — báo trạng thái chưa lưu */
.handsontable td.cell-edit { background: #fff3cd; color: #7a5b00; }
.handsontable td.cell-new { background: #d9f2e3; color: #15633a; }

/* ================= Ticket chi tiết 2 cột ================= */
.tk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-ok { padding: 8px 14px; background: #17a05a; color: #fff; border: 0; border-radius: 8px; font-size: 13px; cursor: pointer; }
.ticket-2col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; margin-top: 18px; }
.tk-left, .tk-right { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 1000px) { .ticket-2col { grid-template-columns: 1fr; } }

.post-first .post-meta { padding: 0 18px; font-size: 12px; color: #7a8593; }
.post-first .post-body { padding: 10px 18px 16px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

/* Sidebar thông tin (key/value) */
.side-info { padding: 4px 18px 14px; }
.si-row { padding: 8px 0; border-bottom: 1px dashed #eef1f5; }
.si-row:last-child { border-bottom: 0; }
.si-row .k { font-size: 11px; color: #7a8593; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 3px; }
.si-row .v { font-size: 13.5px; color: #1f2933; word-break: break-word; }
.mini { font-size: 11px; }
.staff-line { display: flex; align-items: center; gap: 7px; padding: 3px 2px; font-size: 13px; }
.staff-line small { margin-left: auto; }
.staff-line.clickable { cursor: pointer; border-radius: 6px; }
.staff-line.clickable:hover { background: #eef3fb; }
.cc-list { display: flex; flex-direction: column; gap: 2px; }
.side-info select.mini { height: 30px; padding: 3px 8px; border: 1px solid #cfd8e2; border-radius: 6px; font-size: 13px; }

/* Nút Ẩn/Hiện ở góc mỗi cửa sổ (panel) */
.collapse-btn { margin-left: auto; min-width: 26px; height: 26px; border: 1px solid #d5dee8; background: #fff; border-radius: 6px; cursor: pointer; font-size: 11px; color: #57626f; line-height: 1; }
.collapse-btn:hover { background: #eef3fb; border-color: #b9c6d6; }
.panel.collapsed > :not(.section-head):not(.ph) { display: none; }

/* Khối mời/kết quả đánh giá hài lòng (phía khách hàng) trong khung chat */
.rate-req { margin: 4px 16px 10px; padding: 12px 14px; border: 1px solid #cfe0f5; background: #f2f7ff; border-radius: 12px; }
.rate-req.done { border-color: #f5deb0; background: #fff8ec; }
.rate-req .rr-head { font-size: 13.5px; color: #1f2933; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rate-req .rr-cmt { font-size: 13px; color: #57626f; font-style: italic; margin: 4px 0 8px; }
.rate-req .stars.ro { font-size: 16px; }

/* Trình soạn thảo rich text + kéo-thả */
.composer-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-bottom: 10px; margin-bottom: 2px; border-bottom: 1px dashed #eef1f5; }
.composer.drag { outline: 2px dashed #2f6fe0; outline-offset: -6px; background: #f2f7ff; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; padding: 6px; border: 1px solid #cfd8e2; border-bottom: 0; border-radius: 8px 8px 0 0; background: #f7f9fb; }
.rte-toolbar button { min-width: 30px; height: 28px; border: 1px solid transparent; background: transparent; border-radius: 6px; cursor: pointer; font-size: 13px; color: #3a4652; padding: 0 6px; }
.rte-toolbar button:hover { background: #e6ecf3; border-color: #d5dee8; }
.rte-sep { width: 1px; height: 18px; background: #d5dee8; margin: 0 3px; }
.rte-toolbar select { height: 28px; border: 1px solid #d5dee8; border-radius: 6px; background: #fff; font-size: 12px; padding: 0 4px; color: #3a4652; }
.rte-color { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 5px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 13px; color: #3a4652; }
.rte-color:hover { background: #e6ecf3; border-color: #d5dee8; }
.rte-color input[type=color] { width: 20px; height: 20px; border: 0; padding: 0; background: none; cursor: pointer; }
.rte { min-height: 92px; max-height: 260px; overflow-y: auto; border: 1px solid #cfd8e2; border-radius: 0 0 8px 8px; padding: 9px 12px; font-size: 14px; line-height: 1.55; outline: none; background: #fff; }
.rte:empty:before { content: attr(data-ph); color: #9aa4b2; }
.rte ul, .rte ol { margin: 4px 0; padding-left: 22px; }
.rte blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid #cfd8e2; color: #57626f; }

/* Nội dung tin nhắn (HTML đã làm sạch) */
.msg .mtext { white-space: normal; }
.msg .mtext p { margin: 0 0 6px; }
.msg .mtext p:last-child { margin-bottom: 0; }
.msg .mtext ul, .msg .mtext ol { margin: 4px 0; padding-left: 22px; }
.msg .mtext blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid rgba(120,140,170,.4); }
.msg .mtext a { color: inherit; text-decoration: underline; }
/* Định dạng rich text (dùng chung cho editor .rte và bong bóng .mtext) */
.msg .mtext h1, .rte h1 { font-size: 1.4em; margin: 4px 0; line-height: 1.3; }
.msg .mtext h2, .rte h2 { font-size: 1.25em; margin: 4px 0; line-height: 1.3; }
.msg .mtext h3, .rte h3 { font-size: 1.1em; margin: 4px 0; line-height: 1.3; }
.msg .mtext pre, .rte pre { background: rgba(0,0,0,.06); padding: 8px 10px; border-radius: 6px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; }
.msg .mtext hr, .rte hr { border: 0; border-top: 1px solid rgba(120,140,170,.4); margin: 6px 0; }
.rte ul, .rte ol { margin: 4px 0; padding-left: 22px; }
/* Đính kèm dạng file (không phải ảnh/video) */
.fileatt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 10px; background: #f4f6f9; border: 1px solid #e0e6ee; border-radius: 8px; text-decoration: none; color: #2f6fe0; max-width: 100%; }
.msg.me .fileatt { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: #fff; }

/* ===========================================================================
   Thanh trên: chuông thông báo + hồ sơ cá nhân (avatar)
   =========================================================================== */
:root { --accent: #2f6fe0; }
.tb-wrap { position: relative; }
.icon-btn { position: relative; width: 38px; height: 38px; border: 1px solid #dbe1e8; background: #fff; border-radius: 10px; font-size: 17px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f4f6f9; }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px #fff; }
.bell-badge.hide { display: none; }
/* Nút tự động cập nhật: quay 1 vòng mỗi lần nạp lại xong; mờ đi khi tắt */
#refreshDot { color: #17a05a; font-size: 18px; }
#refreshDot.off { color: #9aa4b2; opacity: .6; }
#refreshDot.beat { animation: spin1 .6s ease; }
@keyframes spin1 { to { transform: rotate(360deg); } }
.avatar-btn { border: 0; background: transparent; padding: 0; display: flex; align-items: center; border-radius: 999px; }
.avatar-btn:hover .ava { box-shadow: 0 0 0 3px rgba(47,111,224,.18); }

.ava { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #e6ecf3 center/cover no-repeat; color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.ava.letter { background: var(--accent); }
.ava.big { width: 44px; height: 44px; font-size: 15px; }
.ava.xl { width: 84px; height: 84px; font-size: 26px; }

/* Menu xổ xuống (chung) */
/* z-index 900: trên Handsontable (~101-107), dưới modal (1000) */
.dropdown { display: none; position: absolute; top: 46px; right: 0; z-index: 900; background: #fff; border: 1px solid #dbe1e8; border-radius: 12px; box-shadow: 0 16px 44px rgba(20,30,50,.16); overflow: hidden; }
.dropdown.show { display: block; }
.profile-dd { width: 250px; padding-bottom: 6px; }
.profile-dd .pf-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #eef1f5; }
.profile-dd .pf-id { min-width: 0; }
.profile-dd .pf-id b { display: block; font-size: 14px; }
.profile-dd a { display: block; padding: 10px 16px; font-size: 14px; color: #1f2933; text-decoration: none; }
.profile-dd a:hover { background: #f4f6f9; }
.profile-dd a.danger { color: #dc2626; border-top: 1px solid #eef1f5; margin-top: 6px; }

/* Danh sách thông báo */
.notif-dd { width: 380px; max-width: 92vw; }
.dd-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #eef1f5; }
.dd-head .sp { flex: 1; }
.dd-unread { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #fde0e0; color: #dc2626; font-weight: 600; }
.linkbtn { border: 0; background: transparent; color: var(--accent); font-size: 12px; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-list.page { max-height: none; }
.dd-foot { border-top: 1px solid #eef1f5; text-align: center; padding: 10px; }
.dd-foot a { color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none; }
.dd-foot a:hover { text-decoration: underline; }

.notif { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-bottom: 1px solid #f2f5f9; cursor: pointer; }
.notif:hover { background: #f7f9fb; }
.notif.unread { background: #f3f8ff; }
.notif.unread:hover { background: #e9f2ff; }
.notif .ni-icon { width: 30px; height: 30px; border-radius: 50%; background: #eef3fb; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.notif .ni-body { flex: 1; min-width: 0; }
.notif .ni-title { font-size: 13px; font-weight: 600; }
.notif.unread .ni-title { font-weight: 700; }
.notif .ni-text { font-size: 12px; color: #57626f; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif .ni-meta { font-size: 11px; color: #9aa4b2; margin-top: 3px; }
.notif .ni-dot { width: 10px; height: 10px; border-radius: 50%; border: 0; background: var(--accent); flex-shrink: 0; margin-top: 6px; padding: 0; }
.notif:not(.unread) .ni-dot { background: transparent; border: 1px solid #cfd8e2; }

/* Hồ sơ: Thông tin · Giao diện · Bảo mật */
.pf-editor { display: flex; gap: 18px; align-items: flex-start; }
.pf-ava-edit { text-align: center; flex-shrink: 0; }
.pf-ava-btns { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-btn { display: inline-block; text-align: center; cursor: pointer; }
.pf-fields { flex: 1; min-width: 0; }
.pf-fields label:first-child { margin-top: 0; }
.accents { display: flex; gap: 10px; }
.accent-dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.accent-dot.on { border-color: #1f2933; box-shadow: 0 0 0 2px #fff inset; }
.pf-sessions { margin-top: 16px; padding-top: 14px; border-top: 1px solid #eef1f5; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pf-sessions > div { flex: 1; }

/* Dashboard — bố cục 2 cột + biểu đồ */
/* Cột phải bằng 4/5 bề rộng cũ (1fr -> 0.8fr) — cột trái nở ra chiếm phần dôi */
.dash2col { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.8fr); gap: 18px; align-items: start; }
.dcol { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.dash-stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 0; }
.dash-stats .stat { padding: 14px; }
.dash-stats .stat .n { font-size: 24px; }
@media (max-width: 1100px) { .dash2col { grid-template-columns: 1fr; } }

.chartbox { padding: 14px 18px 18px; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { transition: opacity .12s; }
.chart .bar:hover { opacity: .82; }
.legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12px; color: #57626f; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }
/* Cột ngang xếp hạng theo model */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 130px; align-items: center; gap: 10px; }
.hb-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { display: flex; gap: 2px; height: 18px; }
.hb-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-val { font-size: 12px; color: #7a8593; text-align: right; white-space: nowrap; }
.chart-tip { position: fixed; z-index: 1200; background: #1f2933; color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 6px; pointer-events: none; opacity: 0; transition: opacity .1s; }
.chart-tip.show { opacity: .96; }
:root[data-theme=dark] .legend, :root[data-theme=dark] .hb-val { color: #9aa7b8; }

/* Dashboard — Đề xuất tổng hợp từ các trang */
.sug-list { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 18px; }
.sug-group { display: flex; flex-direction: column; gap: 8px; }
.sug-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #57626f; display: flex; align-items: center; gap: 7px; }
.sug-head .dot-high, .sug-head .dot-medium, .sug-head .dot-low { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.sug-head .dot-high { background: #dc2626; } .sug-head .dot-medium { background: #d97706; } .sug-head .dot-low { background: #9aa4b2; }
.sug { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #e0e6ee; border-left-width: 4px; border-radius: 10px; background: #fff; cursor: pointer; }
.sug:hover { background: #f3f8ff; border-color: var(--accent); border-left-color: var(--accent); }
.sug-high { border-left-color: #dc2626; } .sug-medium { border-left-color: #d97706; } .sug-low { border-left-color: #cfd8e2; }
.sug-icon { font-size: 20px; flex-shrink: 0; }
.sug-body { flex: 1; min-width: 0; }
.sug-title { font-weight: 600; font-size: 14px; }
.sug-detail { color: #7a8593; font-size: 12px; margin-top: 2px; }
.sug-go { font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
:root[data-theme=dark] .sug { background: #16202c; border-color: #2c3a4c; }
:root[data-theme=dark] .sug:hover { background: #1c2941; }
:root[data-theme=dark] .sug-head { color: #9aa7b8; }

/* Đánh giá hài lòng — 2 bảng (nhân viên · phiên CSKH) */
.rate-2tbl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0; }
.rate-2tbl > div + div { border-left: 1px solid #eef1f5; }
@media (max-width: 1100px) { .rate-2tbl { grid-template-columns: 1fr; } .rate-2tbl > div + div { border-left: 0; border-top: 1px solid #eef1f5; } }
:root[data-theme=dark] .rate-2tbl > div + div { border-color: #24303f; }
/* Trang khảo sát công khai (khách hàng mở link /?survey=token) */
#survey { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.survey-card { background: #fff; border: 1px solid #dbe1e8; border-radius: 14px; padding: 28px 32px; width: 560px; max-width: 100%; box-shadow: 0 14px 44px rgba(20,30,50,.12); }
.survey-head { text-align: center; margin-bottom: 18px; }
.survey-head .logo { font-size: 38px; }
.survey-head .logo-img { display: block; width: 140px; max-width: 55%; height: auto; margin: 0 auto 10px; }
.survey-head h1 { margin: 4px 0 6px; font-size: 22px; }
.survey-head .sub { color: #7a8593; font-size: 14px; margin: 0; }
.survey-card textarea { width: 100%; box-sizing: border-box; border: 1px solid #cfd8e2; border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 14px; }
:root[data-theme=dark] .survey-card { background: #16202c; border-color: #2c3a4c; }
.perm-row.hide { display: none; }

/* Popup tạo event khảo sát — trái: thiết lập & bộ lọc · phải: danh sách khách hàng */
.modal .mb .ev2col { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 20px; }
.modal .mb .ev-left { display: flex; flex-direction: column; gap: 12px; }
.modal .mb .ev-left .fld { gap: 0; }
.modal .mb .ev-left .form-sec { margin: 0; padding: 0 0 8px; border-top: 0; border-bottom: 1px solid #eef1f5; }
.modal .mb .ev-right { display: flex; flex-direction: column; min-width: 0; }
.modal .mb .ev-list { max-height: 52vh; overflow-y: auto; }
:root[data-theme=dark] .modal .mb .ev-left .form-sec { border-color: #24303f; }
@media (max-width: 900px) { .modal .mb .ev2col { grid-template-columns: 1fr; } }

/* Popup soạn thông báo — trái: nội dung · phải: mục tiêu + xem trước số đơn vị nhận */
.modal .mb .bc2col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 20px; }
.modal .mb .bc-left, .modal .mb .bc-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.modal .mb .bc-left .form-sec, .modal .mb .bc-right .form-sec { margin: 0; padding: 0 0 8px; border-top: 0; border-bottom: 1px solid #eef1f5; }
.modal .mb .bc-left .rte { min-height: 220px; max-height: 44vh; }
/* Thanh công cụ soạn thảo trong popup: vừa khung soạn thảo, TỰ XUỐNG DÒNG khi chật.
   Mọi phần tử cùng chiều cao 28px và căn giữa -> ô màu không còn lệch. */
.modal .mb .rte-toolbar { flex-wrap: wrap; overflow: visible; align-items: center; row-gap: 4px; padding: 6px 8px; }
.modal .mb .rte-toolbar > * { flex: none; height: 28px; box-sizing: border-box; }
.modal .mb .rte-toolbar button { display: inline-flex; align-items: center; justify-content: center; }
.modal .mb .rte-toolbar select { width: auto; min-width: 96px; padding: 0 6px; background-image: none; font-size: 12px; }
.modal .mb .rte-toolbar .rte-color { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; }
.modal .mb .rte-toolbar .rte-color input[type=color] { width: 20px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer; }
.modal .mb .rte-toolbar .rte-sep { height: 18px; align-self: center; }
.modal .mb .bc-right select[multiple] { height: auto; padding: 6px; background-image: none; }
.bc-preview { margin-top: auto; padding: 12px 14px; border: 1px solid #cfe0ff; background: #f3f8ff; border-radius: 10px; font-size: 13px; color: #1f2933; }
.bc-preview.warn-hint { border-color: #f5d98a; background: #fff7d6; color: #8a6100; }
:root[data-theme=dark] .bc-preview { background: #17283d; border-color: #2c4a6e; color: #e3e8ef; }
:root[data-theme=dark] .modal .mb .bc-left .form-sec, :root[data-theme=dark] .modal .mb .bc-right .form-sec { border-color: #24303f; }
@media (max-width: 900px) { .modal .mb .bc2col { grid-template-columns: 1fr; } }

/* Bảng tiêu chí / câu trả lời trong popup cài đặt */
.crit-tbl { min-width: 0; }
.crit-tbl th, .crit-tbl td { padding: 6px 8px; white-space: normal; }
.crit-tbl input:not([type=checkbox]), .crit-tbl select { width: 100%; padding: 5px 8px; border: 1px solid #cfd8e2; border-radius: 6px; font-size: 13px; }
.crit-tbl .pct-in input { width: 62px; }
.crit-tbl .btn-ghost { padding: 3px 8px; }
.bulk-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; flex-wrap: wrap; }
.bulk-row select { flex: 1; min-width: 160px; padding: 6px 9px; border: 1px solid #cfd8e2; border-radius: 8px; }
:root[data-theme=dark] .crit-tbl input, :root[data-theme=dark] .crit-tbl select, :root[data-theme=dark] .bulk-row select { background: #0f1620; border-color: #2c3a4c; color: #e3e8ef; }

/* Ô nhập trọng số % và ô nhập điểm */
.pct-in { display: inline-flex; align-items: center; gap: 4px; }
.pct-in input { width: 72px; padding: 5px 8px; border: 1px solid #cfd8e2; border-radius: 6px; text-align: right; }
.pct-in span { color: #7a8593; font-size: 12px; }
.score-in { width: 90px; padding: 6px 9px; border: 1px solid #cfd8e2; border-radius: 8px; }
.ok-hint { color: #17a05a; } .warn-hint { color: #b45309; }
:root[data-theme=dark] .pct-in input, :root[data-theme=dark] .score-in { background: #0f1620; border-color: #2c3a4c; color: #e3e8ef; }

/* Đánh giá hài lòng — tab Cài đặt phiếu */
.rc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; padding: 18px; border-top: 1px solid #eef1f5; }
.rc-grid h4 { margin: 0 0 8px; font-size: 14px; }
.th-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.th-row input { width: 70px; padding: 5px 8px; border: 1px solid #cfd8e2; border-radius: 6px; }
:root[data-theme=dark] .rc-grid { border-top-color: #24303f; }

/* Ticket: mã lỗi gán với Thư viện lỗi — tên lỗi · nguyên nhân · danh sách cách khắc phục */
.errwrap { flex-direction: column; }
.errcard { width: 100%; border: 1px solid #e0e6ee; border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.errcard.clickable:hover { border-color: var(--accent); background: #f3f8ff; }
.errcard .ec-head { display: flex; align-items: center; gap: 8px; }
.errcard .ec-name { flex: 1; font-weight: 600; font-size: 13px; min-width: 0; }
.errcard .ec-del { border: 0; background: transparent; color: #dc2626; font-size: 13px; cursor: pointer; }
.errcard .ec-line { font-size: 13px; margin-top: 8px; }
.errcard .ec-line .k { display: block; color: #7a8593; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.sol-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.sol-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid #e0e6ee; border-radius: 8px; background: #fff; cursor: pointer; }
.sol-item:hover { border-color: var(--accent); background: #f3f8ff; }
.sol-n { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sol-txt { flex: 1; min-width: 0; font-size: 13px; }
.sol-txt b { display: block; }
.sol-txt span { display: block; color: #7a8593; font-size: 12px; margin-top: 2px; }
.sol-img { font-size: 11px; color: #7a8593; white-space: nowrap; }
.sol-detail h4 { margin: 16px 0 6px; font-size: 14px; }
.sol-box { border: 1px solid #e6eaf0; border-radius: 8px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; background: #fbfcfe; }
:root[data-theme=dark] .errcard, :root[data-theme=dark] .sol-box { background: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .sol-item { background: #16202c; border-color: #2c3a4c; }
:root[data-theme=dark] .sol-item:hover { background: #1c2941; }

/* Ticket chi tiết: nút Phân loại trước tên ticket + droplist trạng thái ở hàng nút */
.tk-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 3px; }
.cat-btn { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cat-btn:hover { background: var(--accent); color: #fff; }
.cat-btn.none { border-color: #cfd8e2; color: #9aa4b2; border-style: dashed; }
.cat-btn.none:hover { background: #f4f6f9; color: #57626f; }
/* Trạng thái · Sửa ticket · Xoá ticket: cùng bề rộng, cùng chiều cao, cách đều nhau */
/* Nhắc: sự cố cũ chưa chuyển thành ticket */
.inc-alert { margin: 0 18px 12px; padding: 10px 14px; border: 1px solid #f5d98a; background: #fff7d6; color: #8a6100; border-radius: 10px; font-size: 13px; cursor: pointer; }
.inc-alert:hover { background: #fdefc0; }
:root[data-theme=dark] .inc-alert { background: #33290f; border-color: #6b571d; color: #f0d68a; }

/* Popup chi tiết SỰ CỐ — chia khối: tóm tắt · thông tin/mã lỗi (2 cột) · khắc phục · ticket */
.inc-detail { display: flex; flex-direction: column; gap: 14px; }
.inc-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid #eef1f5; }
.inc-top .sp { flex: 1; }
.inc-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.inc-box { border: 1px solid #e6eaf0; border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.inc-box h4 { margin: 0 0 10px; font-size: 13px; }
.inc-kv { display: flex; gap: 10px; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed #eef1f5; }
.inc-kv:last-of-type { border-bottom: 0; }
.inc-kv > span { width: 110px; flex-shrink: 0; color: #7a8593; font-size: 12px; }
.inc-kv > b { flex: 1; min-width: 0; font-weight: 600; }
.inc-note { margin-top: 8px; padding: 8px 10px; background: #fff; border: 1px solid #e6eaf0; border-radius: 8px; font-size: 13px; white-space: pre-wrap; }
.inc-box .empty { padding: 14px; }
:root[data-theme=dark] .inc-box { background: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .inc-note { background: #16202c; border-color: #2c3a4c; }
:root[data-theme=dark] .inc-top, :root[data-theme=dark] .inc-kv { border-color: #24303f; }

/* Sự cố gắn vào ticket — chip ngay dưới tên ticket + nút gán dạng biểu tượng */
.tk-incs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.inc-chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.inc-chip:hover { filter: brightness(.94); }
.inc-add { width: 26px; height: 26px; padding: 0; border: 1px dashed #cfd8e2; background: transparent; color: #7a8593; border-radius: 999px; font-size: 12px; line-height: 1; }
.inc-add:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }
:root[data-theme=dark] .inc-add { border-color: #2c3a4c; color: #9aa7b8; }

.tk-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tk-actions > * { width: 150px; height: 38px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; }
.status-sel { border: 1px solid #cfd8e2; cursor: pointer; text-align: center; text-align-last: center; }
:root[data-theme=dark] .cat-btn.none { border-color: #2c3a4c; }
:root[data-theme=dark] .cat-btn.none:hover { background: #1b2634; color: #d7dee7; }

/* Hàng nút ở đầu panel: Thiết lập · Lưu bảng | Xoá — tách nhau rõ ràng.
   .panel .ph button tô nền xanh cho MỌI nút trong header -> phải trả lại kiểu riêng cho từng nút. */
.ph-btns { display: flex; align-items: center; gap: 10px; }
.ph-btns button { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.panel .ph .btn-ghost { background: #fff; color: #1f2933; border: 1px solid #cfd8e2; }
.panel .ph .btn-ghost:hover { background: #f4f6f9; }
.panel .ph .btn-danger { background: #fff; color: #dc2626; border-color: #f0b4b4; }
.panel .ph .btn-danger:hover { background: #fdf2f2; }
.ph-sep { width: 1px; height: 22px; background: #dbe1e8; margin: 0 2px; }
:root[data-theme=dark] .panel .ph .btn-ghost { background: #1b2634; color: #d7dee7; border-color: #2c3a4c; }
:root[data-theme=dark] .panel .ph .btn-ghost:hover { background: #24303f; }
:root[data-theme=dark] .panel .ph .btn-danger { background: #1b2634; color: #f87171; border-color: #5b2b2b; }
:root[data-theme=dark] .ph-sep { background: #2c3a4c; }

/* Thư viện lỗi — hàng TAB + ô tìm kiếm nằm chung một dòng */
.tabs.tabs-row { align-items: center; padding-right: 18px; }
.tabs.tabs-row .sp { flex: 1; }
.tabs.tabs-row input[type=search] { width: 300px; max-width: 45vw; padding: 7px 11px; border: 1px solid #cfd8e2; border-radius: 8px; font-size: 13px; font-family: inherit; }
:root[data-theme=dark] .tabs.tabs-row input[type=search] { background: #0f1620; border-color: #2c3a4c; color: #e3e8ef; }
/* Dòng bảng bấm được: nền sáng nhẹ khi rê chuột */
tr.clickable:hover td { background: #eef4fd; }
:root[data-theme=dark] tr.clickable:hover td { background: #1c2941; }

/* Màu nhấn áp cho các nút chính */
.panel .ph button, .section-head button, .modal .mf button.ok, .send-btn, .login-card button,
.side-toggle button.on, .viewtoggle button.on { background: var(--accent); border-color: var(--accent); }
/* Tab đang chọn: nền sáng liền với panel + chữ màu nhấn (KHÔNG tô nền màu nhấn — chữ sẽ chìm) */
.tabs button.on { color: var(--accent); }
.side nav a.active { border-left-color: var(--accent); }

/* ===========================================================================
   Chế độ tối
   =========================================================================== */
:root[data-theme=dark] body { background: #0f1620; color: #e3e8ef; }
:root[data-theme=dark] .topbar { background: #16202c; border-bottom-color: #24303f; }
:root[data-theme=dark] .panel, :root[data-theme=dark] .detail-head, :root[data-theme=dark] .stat,
:root[data-theme=dark] .dcard, :root[data-theme=dark] .modal, :root[data-theme=dark] .dropdown,
:root[data-theme=dark] .login-card, :root[data-theme=dark] .composer { background: #16202c; border-color: #24303f; color: #e3e8ef; }
:root[data-theme=dark] .panel .ph, :root[data-theme=dark] .section-head, :root[data-theme=dark] .toolbar,
:root[data-theme=dark] .modal .mh, :root[data-theme=dark] .modal .mf, :root[data-theme=dark] .dd-head,
:root[data-theme=dark] .dd-foot, :root[data-theme=dark] .profile-dd .pf-head { border-color: #24303f; }
:root[data-theme=dark] th { background: #1b2634; color: #9aa7b8; }
:root[data-theme=dark] th, :root[data-theme=dark] td { border-bottom-color: #24303f; }
:root[data-theme=dark] tr:hover td { background: #1b2634; }
:root[data-theme=dark] input:not([type=checkbox]):not([type=radio]), :root[data-theme=dark] select,
:root[data-theme=dark] textarea, :root[data-theme=dark] .rte { background: #0f1620; border-color: #2c3a4c; color: #e3e8ef; }
:root[data-theme=dark] .btn-ghost, :root[data-theme=dark] .backbtn, :root[data-theme=dark] .icon-btn,
:root[data-theme=dark] .modal .mf button, :root[data-theme=dark] .viewtoggle button, :root[data-theme=dark] .side-toggle button,
:root[data-theme=dark] .tabs button { background: #1b2634; border-color: #2c3a4c; color: #d7dee7; }
:root[data-theme=dark] .tabs button.on { background: #16202c; color: var(--accent); }
:root[data-theme=dark] .btn-ghost:hover, :root[data-theme=dark] .icon-btn:hover { background: #24303f; }
:root[data-theme=dark] .btn-danger { color: #f87171; border-color: #5b2b2b; }
:root[data-theme=dark] .field-block { border-color: #24303f; }
:root[data-theme=dark] .field-block .fh { background: #1b2634; border-bottom-color: #24303f; }
:root[data-theme=dark] .chat-thread { background: #111a24; }
:root[data-theme=dark] .msg.them .bubble { background: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .sysline span { background: #1b2634; color: #9aa7b8; }
:root[data-theme=dark] .notif:hover { background: #1b2634; }
:root[data-theme=dark] .notif.unread { background: #17283d; }
:root[data-theme=dark] .notif.unread:hover { background: #1c3149; }
:root[data-theme=dark] .notif, :root[data-theme=dark] .profile-dd a { border-color: #24303f; color: #e3e8ef; }
:root[data-theme=dark] .profile-dd a:hover { background: #1b2634; }
:root[data-theme=dark] .notif .ni-icon, :root[data-theme=dark] .tl-icon { background: #22303f; }
:root[data-theme=dark] .notif .ni-text { color: #a6b2c0; }
:root[data-theme=dark] .empty, :root[data-theme=dark] .muted { color: #7d8b9c; }
:root[data-theme=dark] .bell-badge { box-shadow: 0 0 0 2px #16202c; }
:root[data-theme=dark] .accent-dot.on { border-color: #e3e8ef; }
:root[data-theme=dark] .vchart .left canvas, :root[data-theme=dark] .vchart .right { background: #0f1620; border-color: #24303f; }
:root[data-theme=dark] .vchart .right thead th { background: #1b2634; }
:root[data-theme=dark] .thumb-img, :root[data-theme=dark] .dcard .thumb, :root[data-theme=dark] .gallery .gi { background-color: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .conn .node { background: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .pill, :root[data-theme=dark] .attchip, :root[data-theme=dark] .fileatt { background: #22303f; color: #cbd5e1; border-color: #2c3a4c; }
:root[data-theme=dark] .rte-toolbar { background: #1b2634; border-color: #2c3a4c; }
:root[data-theme=dark] .rte-toolbar button, :root[data-theme=dark] .rte-color { color: #cbd5e1; }
:root[data-theme=dark] .rte-toolbar button:hover, :root[data-theme=dark] .rte-color:hover { background: #24303f; border-color: #2c3a4c; }
