/* HSVN Inbox 0.6: giao diện mới (thanh menu dọc, thẻ, ảnh đại diện). Không thư viện ngoài. */
:root {
  /* màu lấy từ logo HSVN: xanh navy #233477, chữ HS ánh bạc */
  --rail: #121c45; --rail-2: #1f2d63; --rail-text: #aab4d4;
  --bg: #f4f6fb; --panel: #fff; --line: #e3e7f0; --line-2: #eef1f7;
  --text: #141c33; --muted: #5f6b85; --faint: #97a0b5;
  --primary: #233477; --primary-600: #1a2760; --primary-50: #eef1f9; --primary-100: #d8def0;
  --silver: #c9cfdc;
  --warn: #c2410c; --warn-50: #fff4ec; --ok: #0f7a55; --ok-50: #e9f8f1; --bad: #c81e1e; --bad-50: #fdeeee;
  --violet: #5b46c9; --violet-50: #f1effc;
  --out: #233477; --in: #fff;
  --r: 12px; --r-sm: 9px;
  --sh: 0 1px 2px rgba(18,28,69,.05), 0 1px 3px rgba(18,28,69,.06);
  --sh-lg: 0 16px 40px rgba(18,28,69,.16);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--primary); }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--bad); min-height: 1em; }
.spacer { flex: 1; }
.mt { margin-top: 14px !important; }

/* ---------- nút, ô nhập ---------- */
button { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: var(--r-sm); padding: 7px 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, border-color .15s, color .15s; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-ghost { background: var(--panel); color: var(--text); border-color: var(--line); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); }
.btn-ghost.sm, button.sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.link { background: none; color: var(--primary); padding: 3px 6px; font-size: 13px; }
.link:hover { background: var(--primary-50); }
.link.danger { color: var(--bad); } .link.danger:hover { background: var(--bad-50); }
.icon-btn { background: none; padding: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--line-2); color: var(--text); }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; background: #fff;
  color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
input:disabled, textarea:disabled { background: var(--line-2); }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; accent-color: var(--primary); }
input[type=color] { padding: 2px; width: 44px; height: 36px; }
label { display: block; margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 500; }
label > input, label > textarea, label > select { margin-top: 4px; color: var(--text); font-size: 14px; }
label.inl { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
label.inl input { width: auto; margin: 0; }
label.chk { display: inline-flex; align-items: center; margin: 0; white-space: nowrap; font-size: 13px; }

/* ---------- đăng nhập ---------- */
.login { display: grid; grid-template-columns: 1.1fr 1fr; height: 100%; }
.login-brand { background: radial-gradient(1200px 600px at -10% -10%, #2b55c2 0%, transparent 60%), linear-gradient(160deg, #0f1d3a 0%, #142857 100%);
  color: #dfe7fb; padding: 56px 64px; display: flex; flex-direction: column; justify-content: center; }
.login-brand h1 { font-size: 34px; color: #fff; margin: 18px 0 10px; }
.login-brand p { font-size: 16px; max-width: 460px; color: #b9c6e6; margin: 0 0 22px; }
.login-brand ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.login-brand li { display: flex; gap: 10px; align-items: center; color: #dfe7fb; }
.login-brand li svg { color: #7fb0ff; }
.logo-big { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); display: grid; place-items: center; box-shadow: 0 8px 24px rgba(36,87,214,.45); }
.logo-big svg { width: 28px; height: 28px; color: #fff; fill: rgba(255,255,255,.15); }
.login-side { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; background: var(--panel); padding: 32px; border-radius: 14px; box-shadow: var(--sh-lg); border: 1px solid var(--line); }
.login-box h2 { font-size: 22px; } .login-box > p { margin: 4px 0 20px; }
.login-box button { margin-top: 8px; padding: 10px; }

/* ---------- khung chính ---------- */
#app { display: flex; height: 100%; }
.rail { width: 84px; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 8px; gap: 2px; flex: none; overflow-y: auto; }
.rail-logo { width: 40px; height: 40px; border-radius: 11px; background: var(--primary); display: grid; place-items: center; margin-bottom: 14px; box-shadow: 0 6px 16px rgba(36,87,214,.5); }
.rail-logo svg { color: #fff; fill: rgba(255,255,255,.15); width: 20px; height: 20px; }
.rail .tab, .rail-out { position: relative; width: 68px; flex-direction: column; gap: 4px; padding: 9px 4px; background: none; color: var(--rail-text); font-size: 11px; font-weight: 500; border-radius: 10px; }
.rail .tab svg, .rail-out svg { width: 21px; height: 21px; }
.rail .tab:hover, .rail-out:hover { background: var(--rail-2); color: #fff; }
.rail .tab.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(36,87,214,.4); }
.rail-badge { position: absolute; top: 4px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #f04438; color: #fff; font-size: 10px; line-height: 18px; font-weight: 700; }
.rail-me { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.top-title { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.top-title strong { font-size: 17px; }
.sync-info { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; gap: 10px; }
.sync-info .dot { display: inline-flex; align-items: center; gap: 5px; }
.sync-info .dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.sync-info .dot.ok::before { background: #12b76a; } .sync-info .dot.bad::before { background: #f04438; }
.me-box { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.role-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--primary-50); color: var(--primary); }

/* ảnh đại diện chữ cái */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; position: relative; letter-spacing: .02em; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; border: 2px solid rgba(255,255,255,.15); }
.avatar .ch-dot { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; font-size: 8px; display: grid; place-items: center; font-weight: 800; }

/* ---------- hộp thư ---------- */
.inbox { flex: 1; display: grid; grid-template-columns: 360px minmax(0, 1fr) 320px; min-height: 0; }
.col-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.views { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 3px; background: var(--line-2); padding: 3px; border-radius: 9px; }
.views::-webkit-scrollbar { display: none; }
.view { background: none; color: var(--muted); padding: 5px 6px; font-size: 12.5px; font-weight: 600; border-radius: 7px; white-space: nowrap; }
.view:hover { color: var(--text); }
.view.active { background: var(--panel); color: var(--text); box-shadow: var(--sh); }
.view b { font-weight: 700; font-size: 11px; color: var(--muted); }
.view b:not(:empty) { background: var(--line); padding: 0 6px; border-radius: 8px; }
.view[data-view=waiting] b:not(:empty) { background: #f04438; color: #fff; }
.view[data-view=stale] b:not(:empty) { background: var(--warn-50); color: var(--warn); }
.filters { display: grid; gap: 8px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.search input { padding-left: 34px; background: var(--bg); border-color: transparent; }
.search input:focus { background: #fff; }
.filter-row { display: flex; gap: 10px; align-items: center; }
.filter-row select { flex: 1; padding: 6px 8px; font-size: 13px; }
.stale-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--warn-50); color: var(--warn); font-size: 12px; border-bottom: 1px solid #fde0cc; }
.conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 10px; border-radius: 10px; cursor: pointer; margin-bottom: 2px; position: relative; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--primary-50); }
.conv.active::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--primary); }
.conv .body { flex: 1; min-width: 0; }
.conv .l1 { display: flex; gap: 6px; align-items: baseline; }
.conv .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .name { font-weight: 700; }
.conv .time { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.conv.is-wait .time { color: var(--warn); font-weight: 600; }
.conv .l2 { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.conv .l3 { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.conv-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.conv-empty svg { width: 36px; height: 36px; color: var(--ok); margin-bottom: 8px; }
.conv-empty b { display: block; color: var(--text); margin-bottom: 2px; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--line-2); color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.badge.wait { background: var(--warn-50); color: var(--warn); }
.badge.ch { background: var(--primary-50); color: var(--primary); }
.badge.misa { background: var(--ok-50); color: var(--ok); }
.badge.grp { background: var(--violet-50); color: var(--violet); }

.col-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.empty-ico { width: 72px; height: 72px; border-radius: 20px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-ico svg { width: 34px; height: 34px; }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 4px; }
.empty p { margin: 0; }
#thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 64px; }
.t-info { min-width: 0; }
.t-title { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.t-sub .w { color: var(--warn); font-weight: 600; }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 11.5px; color: var(--muted); margin: 14px 0 8px; background: var(--panel); border: 1px solid var(--line); padding: 2px 12px; border-radius: 12px; font-weight: 500; }
.msg { max-width: min(72%, 620px); padding: 8px 12px; border-radius: 14px; background: var(--in); box-shadow: var(--sh); white-space: pre-wrap; word-wrap: break-word; align-self: flex-start; border-bottom-left-radius: 4px; margin-top: 2px; }
.msg.out { align-self: flex-end; background: var(--out); color: #fff; border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.msg.out .meta { color: rgba(255,255,255,.75); }
.msg.ai { background: var(--violet-50); color: var(--text); border: 1px solid #e0dbf7; box-shadow: none; }
.msg.out.ai { background: #ece9fb; }
.msg.out.ai .meta { color: var(--violet); }
.msg.system, .msg.call { align-self: center; background: transparent; box-shadow: none; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.msg.call { background: var(--ok-50); border: 0; color: var(--ok); font-weight: 600; }
.msg .meta { font-size: 11px; color: var(--faint); margin-top: 3px; }
.reply { display: flex; gap: 10px; padding: 12px 18px 16px; background: var(--bg); align-items: flex-end; }
.reply textarea { resize: none; border-radius: 12px; padding: 11px 14px; min-height: 48px; max-height: 180px; box-shadow: var(--sh); border-color: var(--line); }
.reply .send { height: 46px; padding: 0 18px; border-radius: 12px; }
.reply-off { display: flex; gap: 10px; align-items: center; margin: 0 18px 16px; padding: 11px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.reply-off svg { color: var(--faint); }

.col-side { border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--sh); }
.card h3 { font-size: 11.5px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.card textarea { resize: vertical; }
.card form textarea { margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tag:hover { border-color: var(--primary-100); }
.tag.on { color: #fff; border-color: transparent; }
.notes .note { background: #fffaeb; border: 1px solid #fde9b4; border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; font-size: 13px; white-space: pre-wrap; }
.notes .note .meta { margin-top: 3px; }
.misa-box { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.misa-ok { display: flex; gap: 8px; align-items: flex-start; }
.misa-ok .ic { width: 26px; height: 26px; border-radius: 50%; background: var(--ok-50); color: var(--ok); display: grid; place-items: center; flex: none; }
.misa-ok .ic svg { width: 14px; height: 14px; stroke-width: 3; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }

/* ---------- trang ---------- */
.page { padding: 24px 28px 40px; overflow: auto; flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; } .page-head p { margin: 4px 0 0; font-size: 13px; max-width: 760px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--sh); display: flex; gap: 14px; align-items: center; }
.tile-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-50); color: var(--primary); }
.tile-ic svg { width: 22px; height: 22px; }
.tile.c-ok .tile-ic { background: var(--ok-50); color: var(--ok); }
.tile.c-warn .tile-ic { background: var(--warn-50); color: var(--warn); }
.tile.c-violet .tile-ic { background: var(--violet-50); color: var(--violet); }
.tile.c-bad .tile-ic { background: var(--bad-50); color: var(--bad); }
.tile-v { font-size: 25px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-t { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile.bad .tile-v { color: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh); margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; }
.pad { padding: 16px 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .panel { margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { border-bottom: 1px solid var(--line-2); padding: 10px 14px; text-align: left; font-size: 13px; vertical-align: middle; }
.grid th { background: #f8f9fc; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.grid tbody tr:hover { background: #fafbfd; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.total td { font-weight: 700; background: #f8f9fc; }
.grid tr.off td { color: var(--faint); }
.grid .acc-name { font-weight: 600; white-space: nowrap; }
.bad { color: var(--bad); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-50); color: var(--ok); }
.pill.bad { background: var(--bad-50); color: var(--bad); }
.pill.idle { background: var(--line-2); color: var(--muted); }
.pill.warn { background: var(--warn-50); color: var(--warn); }
.sources { display: grid; }
.src { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.src:last-child { border-bottom: 0; }
.src-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--line-2); display: grid; place-items: center; color: var(--muted); }
.src-name { font-weight: 600; }
.src-detail { font-size: 12.5px; color: var(--muted); }
.src-right { text-align: right; display: grid; gap: 3px; justify-items: end; }
.src-time { font-size: 11.5px; color: var(--faint); }
.sources.compact .src { padding: 9px 0; grid-template-columns: 1fr auto; }
.sources.compact .src-ic { display: none; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.quick { display: flex; gap: 4px; background: var(--line-2); padding: 3px; border-radius: 9px; }
.chip { background: none; color: var(--muted); padding: 5px 11px; font-size: 12.5px; font-weight: 600; border-radius: 7px; }
.chip.active { background: var(--panel); color: var(--text); box-shadow: var(--sh); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line-2); background: #fbfcfe; }
.pad .form-row { padding: 14px 0 0; border: 0; background: none; }
.form-row input, .form-row select { width: auto; flex: 1 1 150px; }
.form-row input[type=color] { flex: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
pre.code { background: #0f1d3a; color: #cfe0ff; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; }
.nick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; padding: 16px 18px; }
.nick { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(460px, 92vw); box-shadow: var(--sh-lg); }
dialog::backdrop { background: rgba(15,29,58,.45); }
dialog h3 { font-size: 17px; margin-bottom: 6px; }
dialog .acc-pick { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; }
dialog .acc-pick label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; margin: 6px 0; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #101828; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--sh-lg); opacity: 0; transition: .25s; z-index: 50; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 1280px) { .inbox { grid-template-columns: 330px minmax(0, 1fr) 290px; } }
.ai-btn { color: var(--violet); border-color: #e0dbf7; background: var(--violet-50); }
.ai-btn:hover:not(:disabled) { background: #e6e1fb; color: var(--violet); border-color: #cfc6f5; }
.ai-box { margin: 0 18px 4px; background: var(--panel); border: 1px solid #d9d2f6; border-radius: 12px; box-shadow: var(--sh); padding: 10px 14px 12px; }
.ai-head { display: flex; align-items: center; gap: 8px; color: var(--violet); }
.ai-head b { font-size: 13px; } .ai-head .icon-btn { padding: 3px; }
.ai-text { white-space: pre-wrap; font-size: 14px; margin: 6px 0 10px; max-height: 220px; overflow-y: auto; }
.ai-text.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.ai-text.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #d9d2f6; border-top-color: var(--violet); animation: quay .8s linear infinite; }
.ai-text.err { color: var(--bad); }
@keyframes quay { to { transform: rotate(360deg); } }
.ai-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.info-btn, .side-head, .side-backdrop { display: none; }
.info-btn.has-misa::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #12b76a; margin-left: -2px; }
/* màn hình nhỏ: thông tin khách mở dạng ngăn kéo bên phải (nút "Khách" ở đầu hội thoại) */
@media (max-width: 1100px) {
  .inbox { grid-template-columns: 320px minmax(0, 1fr); } .two-col { grid-template-columns: 1fr; }
  .info-btn { display: inline-flex; }
  .col-side { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 40; border-left: 0; box-shadow: var(--sh-lg);
    transform: translateX(105%); transition: transform .22s ease; padding-top: 0; }
  .inbox.side-open .col-side { transform: none; }
  .side-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1;
    background: var(--bg); padding: 12px 0 4px; font-size: 15px; }
  .side-backdrop { position: fixed; inset: 0; background: rgba(15,29,58,.4); z-index: 39; }
  .inbox.side-open .side-backdrop { display: block; }
}
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-brand { display: none; } }
@media (max-width: 720px) {
  #app { flex-direction: column-reverse; }
  .rail { width: 100%; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; overflow-x: auto; overflow-y: hidden; }
  .rail-logo, .rail .spacer, #meAvatar { display: none; }
  .rail .tab, .rail-out { width: auto; flex: 1; padding: 6px 2px; font-size: 10.5px; }
  .rail-me { flex-direction: row; flex: 1; }
  .rail-badge { right: 18%; }
  .top { height: 50px; padding: 0 14px; }
  .sync-info, .me-box #meName { display: none; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .back { display: inline-flex !important; }
  .inbox.open .col-list { display: none; } .inbox:not(.open) .col-thread { display: none; }
  .msgs { padding: 12px; } .msg { max-width: 86%; }
  .thread-head { padding: 8px 10px; gap: 6px; } #tDone span, .ai-btn span { display: none; } .info-btn, .ai-btn { padding: 7px 10px; } .ai-box { margin: 0 10px 4px; }
  .page { padding: 16px; }
  .reply { padding: 10px 10px 12px; }
}

/* 0.5: ảnh trong hội thoại, chuông, nút tải thêm */
.msg.media { padding: 4px; background: transparent; box-shadow: none; }
.msg.media.out { background: transparent; }
.msg.media .meta { padding: 0 6px 2px; color: var(--faint) !important; }
.msg img.anh { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 12px; cursor: zoom-in; background: var(--line-2); min-width: 80px; min-height: 60px; object-fit: cover; }
.msg .file-link { display: inline-flex; gap: 6px; align-items: center; color: inherit; text-decoration: underline; }
.msg.out .file-link { color: #fff; }
.notif-btn.on { color: var(--primary); background: var(--primary-50); }
.me-box { background: none; border: 0; padding: 6px 8px; border-radius: 8px; color: var(--text); }
.me-box:hover { background: var(--line-2); }
.me-box .me-key { width: 14px; height: 14px; color: var(--faint); }
.more-li { list-style: none; padding: 8px 6px 14px; text-align: center; }
.sub-h { font-size: 12px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 720px) { .me-box .me-key { display: none; } }

/* 0.6: trang Nick Zalo */
.nick-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.nick-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh); padding: 16px; display: grid; gap: 12px; }
.nick-card.off { opacity: .75; }
.nick-top { display: flex; gap: 12px; align-items: center; }
.nick-top .t { flex: 1; min-width: 0; }
.nick-top .t b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nick-top .t span { font-size: 12px; color: var(--muted); }
.nick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.nick-stats div { background: var(--bg); border-radius: 9px; padding: 8px 4px; }
.nick-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.nick-stats span { font-size: 11.5px; color: var(--muted); }
.nick-err { font-size: 12px; color: var(--bad); background: var(--bad-50); border-radius: 8px; padding: 7px 10px; }
.nick-tog { display: flex; gap: 8px; flex-wrap: wrap; }
.tog { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px; background: var(--line-2); color: var(--muted); border: 1px solid transparent; }
.tog::before { content: ""; width: 26px; height: 15px; border-radius: 8px; background: #cfd5df; box-shadow: inset 0 0 0 2px #cfd5df; transition: .15s; background-image: radial-gradient(circle at 7px 7.5px, #fff 5px, transparent 5.5px); }
.tog.on { background: var(--ok-50); color: var(--ok); }
.tog.on::before { background-color: #12b76a; box-shadow: inset 0 0 0 2px #12b76a; background-image: radial-gradient(circle at 18px 7.5px, #fff 5px, transparent 5.5px); }
.tog:disabled { cursor: default; }
.nick-empty { grid-column: 1 / -1; text-align: center; padding: 36px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13.5px; }
.qr-box { display: grid; place-items: center; gap: 10px; padding: 8px 0; text-align: center; }
.qr-box img { width: 240px; height: 240px; border-radius: 12px; border: 1px solid var(--line); image-rendering: pixelated; }
.qr-box .spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--primary-100); border-top-color: var(--primary); animation: quay .8s linear infinite; }
.qr-ok { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-50); color: var(--ok); display: grid; place-items: center; }
.qr-ok svg { width: 28px; height: 28px; stroke-width: 3; }

/* ---- đợt 1: nhãn, hẹn, tiềm năng, mẫu, đơn hàng ---- */
.view[data-view=hen] b:not(:empty) { background: var(--violet-50); color: var(--violet); }
.view[data-view=tiem_nang] b:not(:empty) { background: var(--ok-50); color: var(--ok); }
.badge.lbl { color: #fff; }
.badge.hen { background: var(--violet-50); color: var(--violet); }
.badge.hen.qua { background: var(--bad-50); color: var(--bad); }
.filter-row select { min-width: 0; flex: 1; }
.tag-groups h4 { font-size: 11px; color: var(--faint); margin: 8px 0 5px; font-weight: 600; }
.tag-groups h4:first-child { margin-top: 0; }
.hen-now { font-size: 13px; margin-bottom: 8px; }
.hen-now .on { background: var(--violet-50); color: var(--violet); padding: 8px 10px; border-radius: 8px; }
.hen-now .on.qua { background: var(--bad-50); color: var(--bad); }
.hen-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-b { font-size: 12px; padding: 4px 9px; border-radius: 12px; background: var(--line-2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.chip-b:hover { border-color: var(--primary-100); color: var(--primary); }
.btn-pair { display: flex; gap: 8px; margin-top: 4px; }
.don-box { margin-top: 10px; }
.don-sum { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.don-sum .no { color: var(--bad); }
.don { border-top: 1px solid var(--line-2); padding: 6px 0; font-size: 12.5px; }
.don .l1 { display: flex; justify-content: space-between; gap: 8px; }
.don .l1 b { font-weight: 600; }
.don .sp { color: var(--muted); font-size: 12px; }
.don .st { font-size: 11px; color: var(--muted); }
.reply { position: relative; }
.mau-btn { height: 46px; border-radius: 12px; }
.mau-pop { position: absolute; left: 18px; right: 18px; bottom: calc(100% - 6px); max-height: 300px; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); z-index: 20; padding: 6px; }
.mau-it { display: block; width: 100%; text-align: left; background: none; padding: 7px 9px; border-radius: 8px; font-size: 13px; color: var(--text); }
.mau-it b { color: var(--primary); margin-right: 6px; }
.mau-it .rieng { font-size: 11px; color: var(--violet); margin-left: 4px; }
.mau-it .nd { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mau-it.sel, .mau-it:hover { background: var(--primary-50); }
.mau-foot { border-top: 1px solid var(--line-2); margin-top: 4px; padding: 6px 4px 2px; display: flex; justify-content: space-between; align-items: center; }
.mau-dlg textarea { width: 100%; min-height: 120px; }
.mau-dlg label { display: block; margin-bottom: 10px; }
@media (max-width: 760px) { .mau-btn span { display: none; } .mau-btn { padding: 0 12px; } }

/* ---- đợt 2: tra sản phẩm, phễu ---- */
.sp-pop { padding: 8px; }
.sp-pop input { width: 100%; margin-bottom: 6px; }
.sp-it { border-radius: 8px; padding: 7px 9px; cursor: pointer; }
.sp-it:hover, .sp-it.sel { background: var(--primary-50); }
.sp-it .t { font-weight: 600; font-size: 13px; }
.sp-it .g { font-size: 12.5px; color: var(--ok); font-weight: 600; }
.sp-it .g.misa { color: var(--muted); font-weight: 500; }
.sp-it .m { font-size: 11.5px; color: var(--muted); }
.sp-it .m a { color: var(--primary); }
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 14px 16px; }
.fn { background: var(--line-2); border-radius: 10px; padding: 12px 14px; }
.fn b { display: block; font-size: 22px; font-weight: 700; }
.fn span { font-size: 12px; color: var(--muted); }
.fn em { font-style: normal; font-size: 12px; color: var(--primary); font-weight: 600; margin-left: 6px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 6px 16px 22px; overflow-x: auto; }
.bar { flex: 1 0 14px; max-width: 34px; position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar i { display: block; background: var(--primary-100); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar i.don { background: var(--ok); position: absolute; bottom: 0; left: 25%; right: 25%; border-radius: 3px 3px 0 0; }
.bar s { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--faint); text-decoration: none; white-space: nowrap; }
.phieu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); gap: 14px; padding: 0 16px 16px; }

/* ---- đợt 3: dashboard, sao, AI từng khách, giai đoạn, sự kiện ---- */
.view[data-view=sao] b:not(:empty) { background: #fef3c7; color: #b45309; }
.sao-btn svg { fill: none; }
.sao-btn.on { color: #f59e0b; }
.sao-btn.on svg { fill: #f59e0b; stroke: #f59e0b; }
.badge.sao { background: #fef3c7; color: #b45309; }
.badge.gd { background: var(--ok-50); color: var(--ok); }
.ai-ban { display: flex; align-items: center; gap: 10px; margin: 0 18px 8px; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  background: var(--violet-50); color: var(--violet); }
.ai-ban.off { background: var(--line-2); color: var(--muted); }
.ai-ban .spacer { flex: 1; }
.msg.ev { align-self: center; background: none; border: none; box-shadow: none; color: var(--faint); font-size: 12px; padding: 2px 8px; max-width: 90%; text-align: center; }
.msg .rep { color: var(--ok); font-weight: 600; }
.msg .rep.cham { color: var(--warn); }
.page-head .quick { margin-right: 8px; }
.dash-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
@media (max-width: 1000px) { .dash-2 { grid-template-columns: 1fr; } }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend .lk, .chart .k { background: #93c5fd; fill: #93c5fd; }
.legend .ln, .chart .n { background: var(--primary); fill: var(--primary); }
.legend .la, .chart .a { background: var(--violet); fill: var(--violet); }
.chart { padding: 10px 16px 14px; }
.chart svg { width: 100%; height: 240px; display: block; }
.chart text { font-size: 10px; fill: var(--faint); }
.chart line { stroke: var(--line-2); }
.recent { padding: 4px 8px 10px; }
.rc { display: flex; gap: 10px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.rc:hover { background: var(--primary-50); }
.rc .b { min-width: 0; flex: 1; }
.rc .l1 { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.rc .l1 b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc .l1 span { color: var(--faint); font-size: 11.5px; white-space: nowrap; }
.rc .l2 { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc .l3 { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }

/* ---- AI Agent ---- */
.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.agent-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh); padding: 18px; display: grid; gap: 12px; }
.agent-card.off { opacity: .7; }
.agent-top { display: flex; gap: 12px; align-items: center; }
.agent-logo { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 19px; flex: none; }
.agent-top h2 { font-size: 19px; margin: 0; }
.agent-top .spacer { flex: 1; }
.agent-info { font-size: 13px; color: var(--muted); display: grid; gap: 3px; }
.agent-info b { color: var(--text); font-weight: 600; }
.agent-kenh { display: flex; flex-wrap: wrap; gap: 5px; }
.agent-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.agent-dlg { width: min(640px, 94vw); }
.agent-form label { display: block; margin-bottom: 9px; font-size: 13px; }
.agent-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.agent-form textarea { width: 100%; }
.agent-form .acc-pick label { margin: 4px 0; }
.thu-log { max-height: 320px; overflow-y: auto; display: grid; gap: 8px; margin: 10px 0; }
.thu-log .q { justify-self: end; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 12px; max-width: 85%; font-size: 13.5px; }
.thu-log .a { background: var(--violet-50); color: var(--text); padding: 8px 12px; border-radius: 12px; max-width: 85%; font-size: 13.5px; white-space: pre-wrap; }
.thu-log .e { color: var(--bad); font-size: 13px; }

/* ---- đợt 5: ticket, website, tích hợp, báo cáo nhân viên ---- */
.rail .tab, .rail-out { padding: 7px 4px; }
@media (max-width: 760px) { .rail .tab { min-width: 58px; } }
.view[data-view=binh_luan] b:not(:empty) { background: #e0f2fe; color: #0369a1; }
.tile .chg { font-size: 11.5px; font-weight: 600; margin-left: 6px; }
.chg.up { color: var(--ok); } .chg.down { color: var(--bad); } .chg.up.xau { color: var(--bad); } .chg.down.tot { color: var(--ok); }
.ticket-mini { display: grid; gap: 6px; margin-bottom: 8px; font-size: 12.5px; }
.ticket-mini .tk { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.ticket-mini .tk:hover { border-color: var(--primary-100); }
.pill.tk-mo { background: #e0f2fe; color: #0369a1; } .pill.tk-cho { background: var(--warn-50); color: var(--warn); } .pill.tk-xong { background: var(--ok-50); color: var(--ok); }
.tk-gap { color: var(--bad); font-weight: 700; }
#tkBody tr { cursor: pointer; }
.quick b:not(:empty) { background: var(--line); padding: 0 6px; border-radius: 8px; font-size: 11px; margin-left: 3px; }
.ticket-form label { display: block; margin-bottom: 9px; font-size: 13px; }
.ticket-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ticket-form textarea { width: 100%; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; margin-bottom: 16px; }
.w-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 12px 14px; }
.w-tabs { display: flex; gap: 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 8px; flex-wrap: wrap; }
.w-tabs button { background: none; padding: 6px 0; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.w-tabs button.on { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.bar-list { display: grid; gap: 4px; }
.bar-row { position: relative; display: flex; justify-content: space-between; gap: 8px; padding: 6px 9px; font-size: 12.5px; border-radius: 7px; overflow: hidden; }
.bar-row i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary-50); z-index: 0; border-radius: 7px; }
.bar-row span, .bar-row b { position: relative; z-index: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row b { font-weight: 600; flex: none; }
.heat { padding: 10px 14px 14px; overflow-x: auto; }
.heat table { border-collapse: separate; border-spacing: 2px; font-size: 10.5px; color: var(--faint); }
.heat td { width: 26px; height: 14px; border-radius: 3px; }
.w-funnel { padding: 12px 16px; display: grid; gap: 10px; }
.w-funnel .st { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 3px; }
.w-funnel .bar { height: 26px; background: var(--line-2); border-radius: 7px; overflow: hidden; }
.w-funnel .bar i { display: block; height: 100%; background: var(--violet); border-radius: 7px; }
.th-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.th-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh); padding: 18px; display: grid; gap: 10px; align-content: start; }
.th-card .top { display: flex; gap: 12px; align-items: center; }
.th-card .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.th-card h2 { font-size: 16px; margin: 0; flex: 1; }
.th-card p { font-size: 13px; color: var(--muted); margin: 0; }
.th-card .nhom { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.donut-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }
.donut-wrap .lg { display: grid; gap: 4px; font-size: 12.5px; min-width: 0; flex: 1; }
.donut-wrap .lg div { display: flex; gap: 6px; align-items: center; }
.donut-wrap .lg i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.donut-wrap .lg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pad0 { padding: 0 16px 12px; }

/* ---- Tự động hoá ---- */
#flNhom { margin-top: 8px; }
.fl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 14px; }
.fl-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh); padding: 18px; display: grid; gap: 10px; align-content: start; }
.fl-card.off { opacity: .8; }
.fl-card .nhom { justify-self: start; font-size: 11.5px; padding: 2px 9px; border-radius: 8px; background: var(--violet-50); color: var(--violet); font-weight: 600; }
.fl-card h2 { font-size: 16.5px; margin: 0; }
.fl-card p { margin: 0; font-size: 13px; color: var(--muted); }
.fl-buoc { display: grid; gap: 4px; font-size: 12.5px; }
.fl-buoc div { display: flex; gap: 6px; align-items: baseline; }
.fl-buoc b { flex: none; min-width: 34px; color: var(--primary); font-size: 11px; text-transform: uppercase; }
.fl-meta { font-size: 12px; color: var(--faint); }
.fl-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fl-form h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.fl-form label { display: block; margin-bottom: 8px; font-size: 13px; }
.fl-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fl-form textarea { width: 100%; }
.fl-hd { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: grid; gap: 6px; }
.fl-hd .row1 { display: flex; gap: 8px; align-items: center; }
.fl-hd .row1 select { flex: 1; }
.fl-kenh { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; max-height: 110px; overflow: auto; }
.fl-kenh label { display: inline-flex; gap: 4px; margin: 0; }
.fl-log td { font-size: 12.5px; }

/* ---- chia khách: thương hiệu, giao / nhận / chuyển, đang trực ---- */
.brand-row { margin-bottom: 8px; display: flex; gap: 6px; }
.brand-row select { flex: 1; min-width: 0; }
#fBrand { font-weight: 600; }
.giao-wrap { position: relative; }
.giao-btn span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.giao-btn.chua { color: var(--warn); border-color: var(--warn-50); }
.giao-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-height: 420px; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); z-index: 30; padding: 6px; }
.gp-it { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; padding: 8px; border-radius: 9px; color: var(--text); }
.gp-it:hover { background: var(--primary-50); }
.gp-it .b { min-width: 0; flex: 1; }
.gp-it .t { font-weight: 600; font-size: 13.5px; display: flex; gap: 6px; align-items: center; }
.gp-it .s { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-it .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.gp-it .dot.nghi { background: #cbd5e1; }
.gp-it.on { background: var(--ok-50); }
.gp-sep { border-top: 1px solid var(--line-2); margin: 4px 0; }
.gp-load { font-size: 11px; color: var(--faint); white-space: nowrap; }
.truc-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--ok-50); color: var(--ok); font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 16px; margin-right: 6px; }
.truc-btn i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.truc-btn.nghi { background: var(--line-2); color: var(--muted); }
.chia-sel { width: 100%; }
.pc-form label { display: block; margin-bottom: 8px; font-size: 13px; }
.pc-form .chk-list { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-bottom: 8px; }
.pc-form .chk-list label { display: inline-flex; gap: 5px; margin: 0; }
@media (max-width: 760px) { .truc-btn span { display: none; } .giao-btn span { max-width: 70px; } .giao-pop { right: -60px; width: 300px; } }

.chu-nick { width: 100%; font-size: 13px; }

/* ---- gửi ảnh, tệp ---- */
.tep-ds { position: absolute; left: 18px; right: 18px; bottom: calc(100% - 6px); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(15,23,42,.12); z-index: 15; max-height: 190px; overflow: auto; }
.tep-it { position: relative; width: 92px; font-size: 11px; color: var(--muted); }
.tep-it .hinh { width: 92px; height: 70px; border-radius: 8px; background: var(--line-2) center/cover no-repeat; display: grid; place-items: center; font-weight: 700; color: var(--primary); font-size: 12px; }
.tep-it .ten { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.tep-it .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #0f172a; color: #fff; font-size: 12px; line-height: 20px; padding: 0; }
.tep-it.dang { opacity: .55; }
.tep-it.loi .hinh { background: var(--bad-50); color: var(--bad); }
.reply.keo { outline: 2px dashed var(--primary); outline-offset: -4px; }


/* ================= 0.18: giao diện HSVN (màu và logo HSVN, bản điện thoại, cài như app) ================= */
button, input, select, textarea { font-family: var(--font); }
.btn-primary { background: linear-gradient(180deg, #2b3f8f 0%, var(--primary) 100%); box-shadow: 0 1px 2px rgba(18,28,69,.2); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-ghost.danger { color: var(--bad); } .btn-ghost.danger:hover:not(:disabled) { background: var(--bad-50); border-color: #f6caca; color: var(--bad); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(35,52,119,.14); }

/* đăng nhập */
.login-brand { position: relative; overflow: hidden;
  background: radial-gradient(900px 520px at 0% 0%, rgba(84,116,220,.38), transparent 60%),
              radial-gradient(700px 520px at 110% 110%, rgba(201,207,220,.16), transparent 60%),
              linear-gradient(155deg, #121c45 0%, #233477 100%); }
.login-brand::after { content: ""; position: absolute; right: -110px; bottom: -80px; width: 460px; height: 390px;
  background: url(/static/logo-hs.png) center / contain no-repeat; opacity: .08; filter: grayscale(1) brightness(4); pointer-events: none; }
.login-brand > * { position: relative; z-index: 1; }
.brand-logo { width: 78px; height: 66px; border-radius: 18px; background: #fff; display: grid; place-items: center; box-shadow: 0 12px 30px rgba(0,0,0,.28); }
.brand-logo img { width: 58px; display: block; }
.login-brand h1 { font-size: 36px; font-weight: 700; }
.login-brand li svg { color: var(--silver); }
.login-side { background: var(--bg); }
.login-logo { display: block; height: 46px; margin: 0 0 22px; }
.login-box { border-radius: 18px; padding: 34px 32px 26px; }
.login-box button { padding: 12px; border-radius: 10px; font-size: 15px; }

/* thanh menu dọc */
.rail { background: linear-gradient(180deg, #121c45 0%, #18255c 100%); }
.rail-logo { width: 54px; height: 46px; border-radius: 13px; background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.3); margin-bottom: 16px; }
.rail-logo img { width: 40px; display: block; }
.rail .tab.active { background: #fff; color: var(--primary); box-shadow: 0 6px 16px rgba(0,0,0,.28); font-weight: 600; }
.tab-more, .top-logo { display: none; }

/* thanh trên, danh sách */
.top { box-shadow: 0 1px 0 var(--line); border-bottom: 0; }
.top-title strong { font-weight: 700; }
.conv.active { background: var(--primary-50); }
.view.active { color: var(--primary); }
.msg.out:not(.ai):not(.media) { background: linear-gradient(135deg, #2c4192 0%, var(--primary) 100%); }
.empty-ico { background: var(--primary-50); color: var(--primary); }

/* ô soạn tin: một thẻ, chữ ở trên, công cụ và nút Gửi ở dưới */
.reply { display: grid; grid-template-columns: auto auto auto 1fr auto; gap: 4px 6px; align-items: center;
  margin: 0 18px 16px; padding: 6px 8px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh); }
.reply:focus-within { border-color: #c3cbe6; box-shadow: 0 0 0 3px rgba(35,52,119,.08), var(--sh); }
.reply textarea { grid-column: 1 / -1; grid-row: 1; border: 0; box-shadow: none !important; background: transparent; padding: 8px 8px 4px; min-height: 44px; border-radius: 10px; }
.reply .mau-btn { grid-row: 2; height: 34px; padding: 0 11px; border-radius: 9px; font-size: 13px; background: var(--bg); border-color: transparent; color: var(--muted); }
.reply .mau-btn:hover:not(:disabled) { background: var(--primary-50); color: var(--primary); border-color: transparent; }
.reply .send { grid-row: 2; grid-column: 5; height: 36px; padding: 0 18px; border-radius: 10px; }
.reply .mau-pop { left: 0; right: 0; }
.reply .tep-ds { left: 0; right: 0; }

/* bảng "Thêm" (điện thoại) */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-bg { position: absolute; inset: 0; background: rgba(18,28,69,.45); animation: hien .2s ease; }
.sheet-box { position: absolute; left: 0; right: 0; bottom: 0; max-height: 85vh; overflow-y: auto; background: var(--panel); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--sh-lg); animation: len .24s cubic-bezier(.2,.8,.2,1); }
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.sheet-me { display: flex; align-items: center; gap: 12px; padding: 0 4px 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.sheet-me b { display: block; font-size: 15px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sheet-it { flex-direction: column; gap: 7px; padding: 16px 6px 13px; background: var(--bg); color: var(--text); border-radius: 16px; font-size: 12.5px; font-weight: 600; text-align: center; }
.sheet-it svg { width: 24px; height: 24px; color: var(--primary); }
.sheet-it.active { background: var(--primary-50); box-shadow: inset 0 0 0 2px var(--primary-100); }
.sheet-foot { display: flex; gap: 10px; margin-top: 16px; }
.sheet-foot button { flex: 1; padding: 11px; border-radius: 12px; }
@keyframes len { from { transform: translateY(100%); } }
@keyframes hien { from { opacity: 0; } }

/* ---------- điện thoại ---------- */
@media (max-width: 720px) {
  html, body { height: 100dvh; overscroll-behavior: none; }
  input, select, textarea { font-size: 16px; }      /* iPhone không tự phóng to khi chạm ô nhập */
  #app { height: 100dvh; }
  /* thanh dưới: 4 mục chính + Thêm */
  .rail { background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(18,28,69,.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); overflow: visible; justify-content: space-around; z-index: 20; }
  .rail .tab:not(.m-main), .rail-me, .rail .spacer { display: none !important; }
  .rail .tab, .tab-more { display: inline-flex; flex: 1; flex-direction: column; align-items: center; width: auto; min-width: 0; max-width: 86px;
    gap: 2px; padding: 2px 0; background: none !important; box-shadow: none !important; color: var(--muted); font-size: 11px; font-weight: 500; border-radius: 12px; }
  .rail .tab svg, .tab-more svg { width: 54px; height: 30px; padding: 4px 16px; border-radius: 15px; transition: background .15s; }
  .rail .tab.active, .tab-more.active { color: var(--primary); font-weight: 700; }
  .rail .tab.active svg, .tab-more.active svg { background: var(--primary-50); }
  .rail .tab:hover, .tab-more:hover { color: var(--primary); }
  .rail-badge { top: -2px; right: calc(50% - 26px); border: 2px solid #fff; height: 20px; line-height: 16px; }
  /* trong một hội thoại: ẩn thanh dưới cho rộng chỗ gõ */
  #app:has(#tab-inbox.open:not(.hidden)) .rail { display: none; }

  /* thanh trên màu navy */
  .top { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0 12px; gap: 6px;
    background: linear-gradient(135deg, #18255c 0%, var(--primary) 100%); color: #fff; box-shadow: none; position: relative; z-index: 5; }
  .top-logo { display: block; width: 40px; height: 34px; padding: 4px 6px; background: #fff; border-radius: 10px; object-fit: contain; }
  .top-title { align-items: center; gap: 10px; }
  .top-title strong { font-size: 17.5px; color: #fff; }
  .top .icon-btn { color: #dfe5f6; } .top .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
  .notif-btn.on { background: rgba(255,255,255,.16); color: #fff; }
  .truc-btn { margin-right: 0; padding: 7px 10px; background: rgba(18,183,106,.2); color: #b7f3d6; }
  .truc-btn.nghi { background: rgba(255,255,255,.12); color: #cbd3ea; }
  .me-box { display: none; }

  /* hộp thư */
  .list-head { padding: 10px 12px 8px; gap: 8px; }
  .brand-row { margin-bottom: 0; }
  .views { display: flex; gap: 6px; overflow-x: auto; background: none; padding: 1px 12px 2px; margin: 0 -12px; border-radius: 0; scrollbar-width: none; }
  .view { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
  .view.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: none; }
  .view.active b:not(:empty) { background: rgba(255,255,255,.22); color: #fff; }
  .view.active[data-view=waiting] b:not(:empty) { background: #f04438; }
  .search input { padding-top: 9px; padding-bottom: 9px; border-radius: 12px; }
  .filter-row { gap: 8px; } .filter-row select { font-size: 14px; padding: 8px; }
  .conv-list { padding: 4px 6px 10px; }
  .conv { padding: 12px 10px; gap: 12px; border-radius: 14px; }
  .conv .avatar { width: 46px; height: 46px; font-size: 15px; }
  .conv .name { font-size: 15px; } .conv .l2 { font-size: 13.5px; }

  /* hội thoại */
  .thread-head { min-height: 58px; padding: 6px 6px 6px 4px; gap: 4px; }
  .thread-head .avatar { width: 38px; height: 38px; font-size: 13px; }
  .t-title { font-size: 15px; } .t-sub { font-size: 12px; }
  .thread-head .btn-ghost { padding: 7px 9px; }
  .thread-head .icon-btn { padding: 7px; }
  .msgs { padding: 12px 10px; }
  .reply { margin: 0 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 18px; }
  .reply .mau-btn { padding: 0 12px; }
  .reply-off { margin: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .ai-box { margin: 0 8px 6px; }
  .col-side { width: 100vw; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  /* các trang */
  .page { padding: 14px 12px 28px; }
  .page-head { flex-wrap: wrap; margin-bottom: 14px; } .page-head h1 { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .tile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 13px; border-radius: 14px; }
  .tile-ic { width: 36px; height: 36px; border-radius: 10px; } .tile-ic svg { width: 19px; height: 19px; }
  .tile-v { font-size: 22px; }
  .panel { border-radius: 14px; margin-bottom: 14px; }
  .panel-head { padding: 12px 14px; } .pad { padding: 14px; }
  .grid th, .grid td { padding: 9px 10px; }
  .toolbar { gap: 8px; } .quick { overflow-x: auto; max-width: 100%; }
  .nick-cards { grid-template-columns: minmax(0, 1fr); }
  /* hộp thoại thành bảng trượt từ dưới lên */
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh;
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); }
  dialog[open] { animation: len .24s cubic-bezier(.2,.8,.2,1); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
}
@media (max-width: 360px) { .rail .tab svg, .tab-more svg { width: 46px; padding: 4px 12px; } .rail .tab, .tab-more { font-size: 10.5px; } }
.thread-head .btn-ghost { white-space: nowrap; } .thread-head .t-info { min-width: 0; flex: 0 1 auto; }
@media (max-width: 1280px) { #tDone span { display: none; } }
@media (max-width: 720px) {
  .thread-head .t-info { flex: 1 1 auto; } .thread-head > .spacer, .thread-head > .avatar { display: none; }
  .thread-head .btn-ghost span, .thread-head .btn-ghost #tGiaoTen { display: none; }
  .thread-head .btn-ghost, .thread-head .icon-btn { padding: 8px; border-radius: 10px; }
  .t-sub { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .t-sub > * { flex: none; }
}
@media (max-width: 720px) { #app { overflow: hidden; } .main { min-height: 0; } }
.chip { white-space: nowrap; }
@media (max-width: 860px) { .login-side { background: linear-gradient(180deg, #18255c 0, var(--primary) 240px, var(--bg) 240px); padding-top: calc(24px + env(safe-area-inset-top)); } }

/* ---- danh bạ Zalo ---- */
.db-list { display: grid; }
.db-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.db-row:last-child { border-bottom: 0; }
.db-row:hover { background: #fafbfd; }
.db-row .avatar { width: 44px; height: 44px; }
.db-av { border-radius: 50%; object-fit: cover; background: var(--line-2); display: block; }
.db-info { min-width: 0; display: grid; }
.db-info b, .db-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.db-search { flex: 1 1 240px; }
.db-nick { width: auto; min-width: 170px; }
.db-list .conv-empty { display: grid; gap: 4px; }
@media (max-width: 720px) {
  .db-row { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 10px 12px; gap: 4px 12px; }
  .db-row .avatar { grid-row: 1 / span 2; }
  .db-tags { grid-column: 2; grid-row: 2; justify-content: flex-start; }
  .db-tags:empty { display: none; }
  .db-row > button { grid-column: 3; grid-row: 1 / span 2; }
  .db-nick { flex: 1 1 100%; }
}

/* 0.20 hành trình xem trang của khách web */
.web-ht { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.web-lbl { font-size: 11.5px; font-weight: 600; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: .03em; margin-top: 6px; }
.web-sp { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-sp { background: #e8f0fe; color: #1e3a8a; border-radius: 10px; padding: 3px 10px; font-size: 12px; line-height: 1.4; max-width: 100%; overflow-wrap: anywhere; }
.web-ds { list-style: none; margin: 0; padding: 0; }
.web-ds li { border-top: 1px solid var(--line-2, #eef1f5); padding: 5px 0; display: flex; flex-direction: column; gap: 1px; }
.web-ds li.hidden { display: none; }
.web-ds li .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-ds li.sp .t { font-weight: 600; color: #1e3a8a; }
.web-ds li .m { font-size: 11.5px; color: var(--muted, #64748b); }
