:root {
  --xanh: #0b5cad; --xanh-nhat: #e8f1fb; --chu: #1c2733; --mo: #6b7785; --vien: #dde3ea; --nen: #f4f6f9; --trang: #fff;
  --do: #d93025; --cam: #f29900; --la: #1e8e3e; --bot: #eef3ff; --nv: #dcf3e3; --dt: #eceff3;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--chu); background: var(--nen); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--vien); border-radius: 8px; background: var(--trang); }
textarea { resize: vertical; }
label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--mo); }
label input, label select, label textarea { margin-top: 4px; color: var(--chu); }
.nut { border: 1px solid var(--vien); background: var(--trang); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.nut.chinh { background: var(--xanh); border-color: var(--xanh); color: #fff; font-weight: 600; }
.nut.do { color: var(--do); border-color: #f3c2bd; }
.nut.nho { padding: 4px 10px; font-size: 13px; }
.nut:disabled { opacity: .5; cursor: default; }
.nut-icon { border: 0; background: none; font-size: 20px; padding: 6px 8px; cursor: pointer; color: inherit; }
.loi { color: var(--do); min-height: 1.4em; }
.nhac { background: #fff7e0; border: 1px solid #f5dd9b; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.nap { position: fixed; inset: 0; display: grid; place-items: center; color: var(--mo); }

/* vào */
.man-vao { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #0b5cad, #123d63); }
.the-vao { width: 100%; max-width: 380px; background: var(--trang); border-radius: 16px; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.the-vao h1 { margin: 6px 0 0; font-size: 24px; }
.the-vao .phu { color: var(--mo); margin: 4px 0 8px; }
.the-vao .logo { width: 56px; height: 56px; }
.the-vao .nut { width: 100%; margin-top: 16px; padding: 11px; }

/* khung app */
#app { height: 100%; display: flex; flex-direction: column; }
.dau { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--xanh); color: #fff; flex: none; }
.dau b { font-size: 17px; }
.gian { flex: 1; }
.cong { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,.15); }
.cong.on { color: #9ff0b5; } .cong.off { color: #ffb3ab; }
.menu { position: absolute; top: 48px; left: 8px; z-index: 30; background: var(--trang); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.2); min-width: 230px; padding: 6px; }
.menu a { display: block; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu a:hover { background: var(--xanh-nhat); }
.menu small { color: var(--mo); }
.trang { flex: 1; min-height: 0; }
.trang.hop { overflow: auto; padding: 16px; max-width: 900px; width: 100%; margin: 0 auto; }

/* hộp thư */
.hop-thu { display: flex; }
.cot-ds { width: 360px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--vien); background: var(--trang); min-height: 0; }
.loc { display: flex; gap: 6px; padding: 8px; }
.loc select { width: 130px; flex: none; }
.chip { display: flex; gap: 6px; padding: 0 8px 8px; overflow-x: auto; flex: none; }
.chip button { border: 1px solid var(--vien); background: var(--trang); border-radius: 16px; padding: 4px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip button.bat { background: var(--xanh); color: #fff; border-color: var(--xanh); }
.chip i { font-style: normal; font-weight: 700; color: var(--do); }
.chip button.bat i { color: #fff; }
.ds-ht { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.ds-ht li { display: flex; gap: 10px; padding: 10px; border-bottom: 1px solid #eef1f4; cursor: pointer; align-items: center; }
.ds-ht li:hover { background: #f7f9fc; }
.ds-ht li.chon { background: var(--xanh-nhat); }
.av { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #cfd8e3; flex: none; }
.ds-ht .giua { flex: 1; min-width: 0; }
.ds-ht .dong1 { display: flex; gap: 6px; align-items: baseline; }
.ds-ht .dong1 b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ds-ht .gio { font-size: 12px; color: var(--mo); flex: none; }
.ds-ht .tin { color: var(--mo); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-ht li.chua .tin { color: var(--chu); font-weight: 600; }
.the { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 8px; background: #eef1f4; color: var(--mo); margin-right: 4px; }
.the.can { background: #fde3e1; color: var(--do); font-weight: 600; }
.the.oa { background: #e2f0ff; color: var(--xanh); }
.so-chua { background: var(--do); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 700; flex: none; }

.cot-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #e9eef4; }
.cot-chat .trong { margin: auto; color: var(--mo); }
#chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-dau { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--trang); border-bottom: 1px solid var(--vien); }
.c-ten { display: flex; flex-direction: column; min-width: 0; }
.c-ten small { color: var(--mo); }
.chat-nut { display: flex; gap: 6px; padding: 6px 12px; flex-wrap: wrap; background: var(--trang); border-bottom: 1px solid var(--vien); align-items: center; }
.chat-nut .lydo { color: var(--do); font-size: 13px; }
.tin-ds { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.bong { max-width: 75%; padding: 7px 11px; border-radius: 12px; background: var(--trang); white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bong.ra { align-self: flex-end; background: var(--nv); }
.bong.ra.bot { background: var(--bot); }
.bong.ra.dien_thoai { background: var(--dt); }
.bong .meta { display: block; font-size: 11px; color: var(--mo); margin-top: 2px; }
.bong .meta.loi { color: var(--do); }
.bong a { color: var(--xanh); }
.bong img { max-width: 220px; max-height: 260px; border-radius: 8px; display: block; }
.ngay { align-self: center; font-size: 12px; color: var(--mo); background: rgba(255,255,255,.7); padding: 1px 10px; border-radius: 10px; margin: 6px 0; }
.soan { display: flex; gap: 8px; padding: 8px; background: var(--trang); border-top: 1px solid var(--vien); align-items: flex-end; }
.soan textarea { max-height: 140px; }
.chi-dt { display: none; }

/* trang hộp */
.khoi { background: var(--trang); border: 1px solid var(--vien); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.khoi h2 { margin: 0 0 8px; font-size: 18px; }
.khoi h3 { margin: 12px 0 6px; font-size: 15px; }
.hang { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hang > .gian { flex: 1; }
.nick { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid #eef1f4; flex-wrap: wrap; }
.nick:first-of-type { border-top: 0; }
.tt { font-size: 12px; padding: 1px 8px; border-radius: 10px; }
.tt.dang_chay { background: #dcf3e3; color: var(--la); }
.tt.chua_noi, .tt.mat_ket_noi { background: #fde3e1; color: var(--do); }
.tt.cho_qr { background: #fff2d6; color: #9a6a00; }
.phu-hop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.hop-trong { background: var(--trang); border-radius: 14px; padding: 18px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; }
.qr { text-align: center; }
.qr img { width: 260px; height: 260px; image-rendering: pixelated; border: 1px solid var(--vien); border-radius: 8px; }
.bao-nho { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2733; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 90vw; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.mo { color: var(--mo); font-size: 13px; }

@media (max-width: 760px) {
  .cot-ds { width: 100%; border-right: 0; }
  .cot-chat { display: none; }
  .hop-thu.dang-chat .cot-ds { display: none; }
  .hop-thu.dang-chat .cot-chat { display: flex; }
  .chi-dt { display: inline-block; }
  .bong { max-width: 88%; }
  .trang.hop { padding: 12px; }
}
