/* Giao diện theo số đo trang Hội thoại của Pancake (docs/pancake-so-do-bo-cuc.md) */
:root {
  --top: #506dad;
  --sel: rgba(29, 41, 57, .45);
  --bg: #ecedf4;
  --panel: #ffffff;
  --line: #eaecf0;
  --line2: #d0d5dd;
  --text: #1d2939;
  --text2: #344054;
  --muted: #667085;
  --brand: #105ce2;
  --blue: #2d65c3;
  --chat-bg: #e5ded8;
  --me: #dcf8c6;
  --them: #ffffff;
  --field: #eaecf0;
  --field2: #f2f4f8;
  --warn: #c27c00;
  --danger: #ff4d4f;
  --ok: #00bd00;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.5 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 6px 14px; background: var(--brand); color: #fff; }
button:disabled { opacity: .6; cursor: default; }
button.ghost { background: var(--panel); color: var(--text2); border: 1px solid var(--line2); }
button.primary { background: var(--brand); color: #fff; }
button.gray { background: var(--field2); color: #8496b4; }
button.small { padding: 4px 10px; font-size: 12px; }
input, textarea, select { font: inherit; font-size: 13px; color: inherit; background: var(--field2); border: 1px solid transparent; border-radius: 4px; padding: 4px 11px; width: 100%; }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:focus, textarea:focus, select:focus { outline: none; border-color: #84adff; background: var(--panel); }
.hidden { display: none !important; }
.sub { color: var(--muted); font-size: 12px; }
.err { color: #f5222d; font-size: 13px; }
.err:empty { display: none; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.center { text-align: center; }
label.inline { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; cursor: pointer; }
label.inline input { width: auto; margin: 0; }
.svgi { width: 20px; height: 20px; display: block; flex: none; }

/* Đăng nhập */
.login { display: grid; place-items: center; height: 100%; background: linear-gradient(160deg, var(--top), #2c4482); }
.login-box { background: var(--panel); padding: 32px; border-radius: 12px; width: min(360px, 92vw); display: grid; gap: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.login-box h1 { margin: 0; font-size: 22px; font-weight: 500; }
.login-box p { margin: 0; color: var(--muted); }
.login-box input { height: 36px; }
.fb-btn { display: block; text-align: center; background: #1877f2; color: #fff; text-decoration: none; border-radius: 8px; padding: 6px 14px; }
.row .fb-btn { display: inline-block; }

/* ===== Bố cục: thanh trên 56 | cột icon 52 | danh sách 320 | chat | cột phải 370 ===== */
.app { display: grid; grid-template-rows: 56px 1fr; grid-template-columns: 52px 320px 1fr 370px; height: 100vh; background: var(--top); }
.app.side-hidden { grid-template-columns: 52px 320px 1fr 0; }
.app.side-hidden .side { display: none; }
.app.list-collapsed { grid-template-columns: 52px 0 1fr 370px; }
.app.list-collapsed .list { display: none; }
.app.list-collapsed.side-hidden { grid-template-columns: 52px 0 1fr 0; }

/* Thanh trên */
.topbar { grid-column: 1 / -1; background: var(--top); color: #fff; display: flex; align-items: center; padding: 0 24px 0 6px; min-width: 0; position: relative; z-index: 6; }
.hamburger { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; background: transparent; color: #f2f4f7; border-radius: 8px; flex: none; }
.hamburger .svgi { width: 24px; height: 24px; }
.hamburger:hover { background: rgba(29, 41, 57, .25); }
.brand { display: flex; align-items: center; gap: 8px; height: 30px; min-width: 140px; margin: 0 24px 0 4px; font-weight: 500; font-size: 20px; white-space: nowrap; }
.brand .logo .svgi { width: 30px; height: 30px; }
.topnav { display: flex; gap: 9px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-top: 4px; }
.nav { position: relative; height: 38px; background: transparent; color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 400; white-space: nowrap; }
.nav:hover { background: rgba(29, 41, 57, .25); }
.nav.active { background: var(--sel); }
.nbadge { position: absolute; top: -4px; right: -6px; min-width: 16px; height: 16px; line-height: 16px; background: var(--danger); color: #fff; font-size: 12px; border-radius: 10px; padding: 0 4px; text-align: center; box-shadow: 0 0 0 1px #fff; }
.page-stack { display: flex; align-items: center; gap: 8px; background: transparent; padding: 10px 12px; border-radius: 8px; color: #f2f4f7; }
.page-stack:hover, .page-stack.open { background: rgba(29, 41, 57, .25); }
.page-stack .avatars { display: flex; }
.pav { position: relative; width: 34px; height: 34px; margin-left: -15px; flex: none; }
.pav:first-child { margin-left: 0; }
.pav img { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #fff; object-fit: cover; background: #fff; display: block; }
.pav i { position: absolute; inset: 0; border-radius: 50%; background: rgba(0, 0, 0, .3); color: #fff; font-style: normal; font-size: 15px; display: grid; place-items: center; z-index: 1; }
.me { font-size: 14px; color: #f2f4f7; white-space: nowrap; }
.top-bell { position: relative; width: 40px; height: 40px; border-radius: 20px; background: rgba(29, 41, 57, .25); display: grid; place-items: center; margin-left: 8px; color: #f2f4f7; flex: none; }
.top-bell .svgi { width: 20px; height: 20px; }
.top-bell b { position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 5px; line-height: 16px; font-weight: 400; }

/* Danh sách chọn Page */
.page-menu { position: absolute; top: 53px; right: 70px; width: 260px; background: #fff; color: var(--text); border-radius: 6px; box-shadow: 0 6px 8px rgba(0, 0, 0, .15); padding: 7px; z-index: 30; }
.pm-list { max-height: 60vh; overflow-y: auto; }
.pm-row { position: relative; display: flex; align-items: center; gap: 16px; width: 100%; height: 54px; padding: 8px 8px 8px 12px; background: transparent; color: var(--text); border-radius: 8px; text-align: left; font-size: 14px; }
.pm-row:hover, .pm-row.on { background: #eaecf0; }
.pm-strip { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 5px; height: 25px; }
.pm-av { position: relative; width: 40px; height: 40px; flex: none; }
.pm-av img { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #fff; object-fit: cover; }
.pm-all { border-radius: 50%; background: var(--top); color: #fff; display: grid; place-items: center; }
.pm-fb { position: absolute; left: 26px; top: 20px; }
.pm-fb .svgi { width: 20px; height: 20px; }
.pm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-badge { min-width: 20px; height: 20px; border-radius: 10px; background: #f5222d; color: #fff; font-size: 12px; font-weight: 400; display: grid; place-items: center; padding: 0 5px; }
.page-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.pm-link { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 12px; background: transparent; color: var(--text); font-size: 14px; border-radius: 8px; }
.pm-link:hover { background: #eaecf0; }
.pm-account { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 10px; border-radius: 8px; background: #f9fafb; }
.pm-account img { width: 36px; height: 36px; border-radius: 50%; }
.pm-account div { flex: 1; min-width: 0; display: grid; }
.pm-account small { font-size: 11px; color: var(--muted); }
.pm-account b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-logout { background: transparent; color: var(--text2); padding: 6px; }

/* ===== Cột icon bên trái ===== */
.rail { background: var(--top); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0; overflow-y: auto; scrollbar-width: none; }
.ri { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; background: transparent; color: #f2f4f7; border-radius: 8px; flex: none; }
.ri .svgi { width: 24px; height: 24px; }
.ri:hover { background: rgba(29, 41, 57, .3); }
.ri.active { background: rgba(29, 41, 57, .65); color: #fff; }
.rail-menu, .drop-menu { position: fixed; left: 56px; z-index: 40; background: #fff; border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, .16); padding: 6px; min-width: 230px; display: grid; gap: 2px; }
.rail-menu label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); padding: 2px 6px; }
.rail-menu .primary { margin: 6px; }
.rm-title { font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px; }
.rm-item { display: flex; align-items: center; gap: 8px; justify-content: flex-start; width: 100%; background: transparent; color: var(--text); padding: 7px 10px; border-radius: 6px; text-align: left; font-size: 14px; }
.rm-item .svgi { width: 16px; height: 16px; }
.rm-item .svgi:last-child:not(:first-child) { margin-left: auto; }
.rm-item:hover { background: #eaecf0; }
.rm-item.on { background: #e6f4ff; color: #1677ff; }
.rm-quick { display: flex; gap: 4px; flex-wrap: wrap; padding: 2px 6px 6px; }
.rm-quick button { background: var(--field); color: var(--text2); font-size: 12px; padding: 3px 10px; border-radius: 6px; }

/* ===== Danh sách hội thoại ===== */
.list { background: #fff; border-right: 1px solid var(--line2); display: flex; flex-direction: column; min-width: 0; min-height: 0; border-top-left-radius: 12px; overflow: hidden; }
.list-head { height: 48px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; position: relative; box-shadow: 0 1px 4px rgba(0, 0, 0, .16); z-index: 2; flex: none; }
.search { width: 157px; flex: none; height: 32px; display: flex; align-items: center; gap: 6px; background: #eaecf0; border-radius: 6px; padding: 5px 8px; color: #1d2939; }
.search .svgi { width: 20px; height: 20px; }
.search input { background: transparent; border: 0; padding: 0; font-size: 14px; min-width: 0; }
.tag-dots { display: flex; flex-wrap: wrap; gap: 4px 6px; width: 138px; flex: none; }
.tag-dots button { width: 18px; height: 16px; padding: 0; border-radius: 4px; background: color-mix(in srgb, var(--c) 40%, transparent); }
.tag-dots button:hover, .tag-dots button.on { background: var(--c); }
.tag-dots .tag-more { background: transparent; color: #475467; display: grid; place-items: center; }
.tag-dots .tag-more .svgi { width: 16px; height: 16px; }
.tag-menu { position: absolute; top: 46px; right: 6px; z-index: 10; background: #fff; border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, .16); padding: 6px; width: 230px; max-height: 60vh; overflow-y: auto; }
.tag-menu button { display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; color: var(--text); padding: 6px 8px; text-align: left; font-size: 13px; border-radius: 6px; }
.tag-menu button:hover, .tag-menu button.on { background: #eaecf0; }
.tag-menu i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.list-title { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 12px; color: var(--muted); background: #f9fafb; border-bottom: 1px solid var(--line); }
.list-title b { color: var(--text); }
.list-title .clear { margin-left: auto; background: transparent; color: var(--muted); padding: 2px; }
.list-title .clear .svgi { width: 14px; height: 14px; }
.conv-list { overflow-y: auto; flex: 1; }
.conv { position: relative; display: flex; height: 86px; cursor: pointer; align-items: flex-start; }
.conv::after { content: ""; position: absolute; left: 72px; right: 12px; bottom: 0; height: 1px; background: #eaecf0; }
.conv.unread::after { background: #d0d5dd; }
.conv:hover { background: #eaecf0; }
.conv.unread { background: #dde1e7; }
.conv.unread:hover { background: #d0d5dd; }
.conv.active { background: #d2ebff; }
.conv.active:hover { background: #bae0ff; }
.border-fake { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 0 5px 5px 0; }
.conv:hover .border-fake { width: 6px; }
.conv .av { position: relative; flex: none; padding: 5px 14px 5px 8px; }
.conv .avatar { width: 50px; height: 50px; margin-top: 13px; border: 1px solid #fff; background: #eee; }
.conv .cnt { position: absolute; left: 42px; top: 52px; min-width: 18px; height: 18px; line-height: 18px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 12px; font-weight: 400; text-align: center; padding: 0 4px; }
.conv .body { flex: 1; min-width: 0; padding: 10px 12px 10px 0; }
.conv .top { display: flex; align-items: center; gap: 4px; height: 22px; }
.conv .nm { flex: 1; min-width: 0; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: #344054; }
.conv.unread .nm { font-weight: 500; }
.conv .star-ic .svgi { width: 13px; height: 13px; color: #fadb14; fill: #fadb14; }
.conv .tm { color: #4a646c; font-size: 12px; flex: none; }
.conv .sn { display: flex; align-items: center; gap: 2px; height: 16px; margin-top: 4px; color: #000; white-space: nowrap; overflow: hidden; font-size: 13px; line-height: 16px; }
.conv.unread .sn { font-weight: 500; }
.conv .sn .rp .svgi { width: 16px; height: 16px; color: #475467; }
.conv .sn .tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.conv .bottom { display: flex; align-items: center; gap: 4px; height: 20px; margin-top: 4px; }
.pills { flex: 1; display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.pill { height: 16px; font-size: 10px; line-height: 16px; padding: 0 6px; border-radius: 8px; color: #fff; white-space: nowrap; }
.pill.more { background: #e6f7ff; color: #1677ff; }
.conv .icons { display: flex; gap: 4px; align-items: center; flex: none; margin-left: auto; }
.conv .ic { color: #98a2b3; display: grid; place-items: center; }
.conv .ic .svgi { width: 22px; height: 22px; }
.conv .ic.ph { background: #12b76a; color: #fff; border-radius: 4px; width: 16px; height: 16px; }
.conv .ic.ph .svgi { width: 11px; height: 11px; }
.conv .ic.cmt .svgi { width: 20px; height: 20px; }
.conv .ic.new { color: #ff5722; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #eee; object-fit: cover; flex: none; }

/* ===== Khung chat ===== */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.empty { margin: auto; color: var(--muted); }
.chat-box { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { position: relative; display: flex; gap: 10px; align-items: center; height: 74px; padding: 8px 12px; background: #fff; border-bottom: 1px solid #dddddd; flex: none; }
.chat-head .avatar { width: 45px; height: 45px; }
.chat-head .who { min-width: 0; flex: 1 1 auto; }
.chat-head .name { display: inline-block; max-width: 100%; font-weight: 500; font-size: 14px; color: #344054; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-radius: 6px; padding: 0 2px; }
.chat-head .name:hover { background: #eaecf0; }
.seen { font-size: 11px; color: #667085; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.mini-icons { display: flex; gap: 6px; align-items: center; margin-top: 3px; color: #475467; padding: 0 2px; }
.mini-icons > span[data-ic], .dot-on { cursor: pointer; }
.mini-icons .svgi { width: 14px; height: 14px; }
.dot-on { width: 12px; height: 12px; border-radius: 50%; border: 3px solid #12b76a; display: inline-block; margin-left: 4px; }
.dot-on.off { border-color: #98a2b3; }
.head-icons { display: flex; gap: 4px; align-items: center; }
.vsep { width: 1px; height: 12px; background: #d0d5dd; margin: 0 6px; }
.hicon { background: transparent; color: #344054; padding: 0; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.hicon .svgi { width: 20px; height: 20px; }
.hicon:hover { background: #eaecf0; }
.hicon.on { background: #e6f4ff; color: #1890ff; border-radius: 50%; }
.hicon.round { border-radius: 1000px; background: #fff; }
.hicon.round:hover { background: #eaecf0; }
.chat-head .drop-menu { position: absolute; top: 64px; left: auto; right: 12px; width: 300px; }
.chat-head .hist-menu { right: auto; left: 60px; max-height: 360px; overflow-y: auto; }
.hm-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 10px; font-size: 13px; border-top: 1px solid var(--line); }
.hm-row span { color: var(--muted); }
.hm-row b { font-weight: 500; text-align: right; }
.hist-menu .hm-row { flex-direction: column; gap: 0; }
.hist-menu .hm-row span { color: var(--text); }
.hist-menu .hm-row small { color: var(--muted); font-size: 11px; }
.badge { font-size: 11px; padding: 0 8px; border-radius: 99px; background: var(--field); white-space: nowrap; margin-left: 4px; }
.badge.warn { color: var(--warn); background: #fff4dc; } .badge.bad { color: #f5222d; background: #fde8e8; }
#btnBack, .close-side { display: none; }
.msg-wrap { flex: 1; min-height: 0; position: relative; display: flex; }
.messages { flex: 1; overflow-y: auto; padding: 0 16px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.msg { display: flex; gap: 4px; align-items: flex-end; }
.msg.customer { max-width: calc(70% + 36px); }
.msg.page { max-width: 70%; align-self: flex-end; justify-content: flex-end; }
.msg.gfirst, .msg.single { margin-top: 6px; }
.mcol { display: flex; flex-direction: column; min-width: 0; }
.msg.page .mcol { align-items: flex-end; }
.mavatar { width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .38); }
.bubble { padding: 6px 12px; border-radius: 12px; background: var(--them); white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 21px; color: #000; text-decoration: none; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); }
.msg.page .bubble { background: var(--me); }
/* Bo góc theo vị trí trong nhóm tin */
.msg.page.gfirst .bubble { border-radius: 12px 12px 4px 12px; }
.msg.page.gmid .bubble { border-radius: 12px 4px 4px 12px; }
.msg.page.glast .bubble { border-radius: 12px 4px 12px 12px; }
.msg.customer.gfirst .bubble { border-radius: 12px 12px 12px 4px; }
.msg.customer.gmid .bubble { border-radius: 4px 12px 12px 4px; }
.msg.customer.glast .bubble { border-radius: 4px 12px 12px 12px; }
.phone-tag { background: #ff8100; color: #fff; padding: 2px 5px 1.5px; border-radius: 4px; }
.msg.hidden-c .bubble { opacity: .5; font-style: italic; }
.msg.deleted .bubble { text-decoration: line-through; opacity: .5; }
.msg img.att { max-width: 220px; border-radius: 12px; margin-top: 2px; border: 2px solid var(--me); }
.meta { font-size: 11px; color: var(--muted); display: none; gap: 8px; }
.msg:hover .meta { display: flex; }
.meta a { color: var(--blue); cursor: pointer; }
.read-av { align-self: flex-end; width: 14px; height: 14px; border-radius: 50%; margin-top: 2px; }
.daysep { position: sticky; top: 0; z-index: 2; align-self: center; padding: 8px 0 4px; }
.daysep span { display: block; height: 24px; font-size: 14px; color: #344054; background: rgba(255, 255, 255, .5); padding: 1px 12px; border-radius: 8px; }
.card-row { margin: 6px 10px 2px 0; }
.adcard { width: 346px; max-width: 100%; background: #ffffea; border-radius: 12px; padding: 8px; box-shadow: 1px 2px 1px rgba(0, 0, 0, .1); }
.ad-head { display: flex; align-items: center; gap: 8px; min-height: 52px; background: #f1f1d4; border-radius: 8px; padding: 6px 8px 6px 12px; }
.ad-logo .svgi { width: 18px; height: 18px; }
.ad-info { flex: 1; min-width: 0; display: grid; }
.ad-info b { font-size: 14px; font-weight: 500; color: #101828; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-info span { font-size: 12px; color: #667085; }
.ad-open { width: 24px; height: 24px; padding: 3px; border-radius: 6px; color: #344054; }
.ad-open:hover { background: rgba(0, 0, 0, .06); }
.ad-open .svgi { width: 18px; height: 18px; }
.ad-img { margin-top: 8px; padding: 0 4px; }
.ad-img img { width: 100%; height: 176px; object-fit: cover; border-radius: 8px; display: block; background: #fff; }
.content-note { margin-top: 8px; padding: 0 2px; font-size: 14px; color: #000; line-height: 22px; }
.cn-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.content-note.open .cn-text { display: block; }
.content-note .more { color: #2d65c3; cursor: pointer; }
.content-note.open .more { display: none; }
.to-bottom { position: absolute; right: 16px; bottom: 12px; width: 32px; height: 32px; border-radius: 50%; padding: 0; background: #fff; color: #344054; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); display: grid; place-items: center; }

/* ===== Thanh thẻ màu ===== */
.tagbar { background: #d5d5d5; padding: 2px 2px 0; box-shadow: 0 -2px 4px rgba(0, 0, 0, .12); flex: none; position: relative; z-index: 1; }
.tagbar:empty { display: none; }
.row_tag { display: flex; gap: 1px; height: 20px; margin-bottom: 1px; }
.btn-tag { position: relative; flex: 0 1 auto; height: 20px; font-size: 10px; line-height: 20px; padding: 0 8px; border-radius: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--c) 40%, transparent); color: #fff; }
.btn-tag:hover { background: color-mix(in srgb, var(--c) 70%, transparent); }
.btn-tag.on { background: var(--c); }
.btn-tag.on::before { content: ""; position: absolute; left: 3px; top: 3px; width: 4px; height: 4px; border-radius: 50%; background: #fff; }

.quick { display: flex; gap: 6px; padding: 4px 10px; overflow-x: auto; background: #fff; border-top: 1px solid var(--line); flex: none; }
.quick:empty { display: none; }
.quick button { background: var(--field); color: var(--text); white-space: nowrap; font-size: 12px; padding: 3px 10px; border-radius: 99px; }

/* ===== Ô trả lời ===== */
.composer { background: #fff; min-height: 88px; padding: 9px 9px 4px; flex: none; }
.reply-row { display: flex; gap: 8px; align-items: flex-start; }
.pavatar { width: 24px; height: 24px; border-radius: 3px; background: var(--field); flex: none; object-fit: cover; }
.composer textarea { resize: none; height: 48px; min-height: 48px; max-height: 160px; background: transparent; border: 0; padding: 3px 5px 0; font-size: 14px; }
.tools { display: flex; align-items: center; gap: 8px; height: 28px; }
.tool { background: transparent; color: #adb5c2; padding: 0; width: 24px; height: 24px; border-radius: 4px; display: grid; place-items: center; }
.tool:hover { color: #475467; }
.tool .svgi { width: 24px; height: 24px; }
.tool.like { color: #1877f2; }
.reply-mode { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; font-size: 13px; }
.reply-mode input { width: auto; }

/* ===== Cột phải ===== */
.side { background: #fff; border-left: 1px solid #dddddd; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid #dddddd; flex: none; }
.tab { flex: 1; height: 45px; background: transparent; color: #4a4a4a; border-radius: 0; padding: 0; border-bottom: 2px solid transparent; font-size: 15px; }
.tab.active { color: #1677ff; border-bottom-color: #2f80ed; }
.tab-body { flex: 1; overflow-y: auto; padding: 12px 31px; display: flex; flex-direction: column; gap: 12px; }
.notes { display: grid; gap: 6px; }
.note { background: #fff8db; border-radius: 6px; padding: 6px 8px; font-size: 13px; white-space: pre-wrap; }
.note .sub { display: block; }
.note-input { position: relative; }
.note-input textarea { resize: none; height: 48px; background: #eaecf0; border-radius: 4px; padding: 6px 34px 6px 8px; font-size: 12px; }
.note-img { position: absolute; right: 8px; top: 6px; filter: grayscale(1); opacity: .6; }
.divider { display: flex; align-items: center; gap: 12px; color: rgba(0, 0, 0, .65); font-weight: 500; font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid #dddddd; }
.empty-state { text-align: center; color: #667085; padding: 18px 6px 8px; font-size: 14px; }
.empty-state .ico { font-size: 56px; opacity: .45; filter: grayscale(1); line-height: 1.2; }
.empty-state.small { padding: 40px 6px; }
.empty-state.small .ico { font-size: 32px; }
#btnOrder { width: 99px; height: 32px; padding: 0; background: #105ce2; border-radius: 8px; font-size: 14px; }
.order { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.order .money { color: #f5222d; }
.hist { font-size: 12px; }
.hist:empty { display: none; }
.hist .box { background: var(--field2); padding: 6px 10px; border-radius: 6px; }
.hist .warn { color: #f5222d; font-weight: 700; }
.st { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 99px; background: #e6f4ff; color: #1677ff; }
.cust-edit summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.cust { display: grid; gap: 6px; margin-top: 6px; }
.cust-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-foot { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 12px; border-top: 1px solid var(--line); font-size: 14px; color: rgba(0, 0, 0, .65); flex: none; }
.side-foot:empty { display: none; }
.side-foot span { display: flex; align-items: center; gap: 3px; }
.sf-phone { color: #12b76a; }
.sf-phone .svgi { width: 20px; height: 20px; }
.side-foot .sf-pill { display: block; background: #722ed1; color: #fff; border: 1px solid #fff; border-radius: 10px; padding: 0 5px; font-size: 10px; line-height: 16px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-ok .svgi { width: 16px; height: 16px; color: var(--ok); }
.sf-bad .svgi { width: 16px; height: 16px; color: #ff0000; }
.side-foot b { font-weight: 400; }
.sf-report { background: transparent; padding: 2px; color: #fa8c16; }
.sf-report .svgi { width: 14px; height: 14px; }

/* ===== Tab Tạo đơn ===== */
.order-tab { padding: 0; gap: 0; background: #fff; }
.order-tab section { background: #fff; padding: 8px 10px 10px; display: grid; gap: 8px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; padding: 8px 10px; border-bottom: 1px solid #d9dbea; font-weight: 500; font-size: 14px; }
.sec-head i { font-style: normal; color: #475467; margin-right: 6px; }
.sec-icons { display: flex; gap: 6px; }
.sq { background: transparent; color: #2d65c3; width: 26px; height: 24px; padding: 0; border-radius: 4px; font-size: 13px; }
.sq:hover { background: #e6f4ff; }
.sec-link { color: #2d65c3; font-size: 14px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.sec-link .wh { width: auto; max-width: 170px; color: #2d65c3; background: transparent; padding: 0 2px; font-size: 14px; font-weight: 500; border: 0; appearance: none; text-align: right; cursor: pointer; }
.order-tab input, .order-tab select { height: 24px; padding: 2px 11px; background: #f2f4f8; font-size: 13px; }
.order-tab textarea { background: #f2f4f8; }
.cust-card { display: flex; align-items: center; gap: 10px; background: #eef3fb; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.cust-card img { width: 32px; height: 32px; border-radius: 50%; background: #fff; }
.cc-body { display: grid; min-width: 0; }
.cc-body b { font-weight: 500; }
.cc-phone { color: #2d65c3; font-size: 13px; }
.carrier { display: inline-block; background: #ffe7ba; color: #d46b08; font-size: 12px; border-radius: 4px; padding: 0 6px; margin-left: 6px; line-height: 18px; }
.cust-card .chev { color: var(--muted); }
.ptable { border: 1px solid var(--line); border-radius: 2px; overflow: hidden; min-height: 300px; display: flex; flex-direction: column; }
.prow { display: grid; grid-template-columns: 1fr 50px 84px 86px; gap: 6px; align-items: center; padding: 4px 8px; font-size: 13px; }
.phead { background: #ecedf4; font-weight: 500; font-size: 13px; color: #344054; height: 28px; }
.prow input { padding: 2px 5px; text-align: right; }
#oItems { flex: 1; display: flex; flex-direction: column; }
#oItems .empty-state.small { margin: auto; }
.pitem { border-bottom: 1px solid var(--line); }
.pname { font-weight: 500; }
.line { text-align: right; }
.pmeta { display: flex; gap: 10px; align-items: center; padding: 0 8px 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pmeta label { display: flex; gap: 4px; align-items: center; }
.pmeta input[type=number] { width: 72px; padding: 1px 5px; }
.pmeta input[type=checkbox] { width: auto; height: auto; }
.pmeta .del { color: #f5222d; cursor: pointer; margin-left: auto; }
.gift { font-size: 10px; background: #fde68a; color: #7c5800; padding: 0 5px; border-radius: 3px; }
.stock { font-size: 11px; color: #12b76a; white-space: nowrap; }
.stock.low { color: var(--warn); }
.stock.bad { color: #f5222d; font-weight: 600; }
.results { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 12px rgba(0, 0, 0, .08); }
.results:empty { display: none; }
.results div { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.results div:hover { background: #e6f4ff; }
.results div.out { opacity: .55; }
.psearch { display: flex; gap: 6px; align-items: center; }
.sbox { flex: 1; display: flex; align-items: center; gap: 4px; background: #f2f4f8; border-radius: 4px; padding: 0 4px 0 8px; height: 32px; }
.sbox span { opacity: .5; font-size: 12px; }
.order-tab .sbox input { background: transparent; border: 0; padding: 0 4px; height: 30px; }
.combo { background: #fff; color: #344054; border: 1px solid var(--line2); padding: 0 8px; height: 24px; font-size: 12px; border-radius: 4px; white-space: nowrap; }
.plus { width: 32px; height: 32px; padding: 0; font-size: 18px; border-radius: 6px; background: #2d65c3; }
.checks2 { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.order-tab label.inline input { width: auto; height: auto; }
.pay { display: grid; grid-template-columns: 1fr 120px; gap: 6px 10px; align-items: center; font-size: 14px; }
.pay input { text-align: right; }
.pay b { text-align: right; font-weight: 500; }
.other .kv { display: flex; justify-content: space-between; font-size: 13px; color: #475467; }
.other .kv b { font-weight: 400; color: var(--text); }
.order-foot { position: sticky; bottom: 0; background: #fff; padding: 8px 10px 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.cod { text-align: right; }
.cod b { color: #f5222d; font-size: 16px; font-weight: 500; }
.foot-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot-btns button { height: 32px; padding: 0; font-size: 14px; font-weight: 500; border-radius: 8px; }
.foot-btns .gray { background: #f2f4f8; color: #8496b4; }
.foot-btns .primary { background: #2d65c3; }

/* ===== Trang Đơn hàng / Bài viết / Thống kê ===== */
.app.view-page { grid-template-columns: 1fr; }
.app.view-page .rail, .app.view-page .list, .app.view-page .chat, .app.view-page .side { display: none !important; }
.page-view { grid-column: 1 / -1; background: #ecedf4; overflow-y: auto; min-width: 0; }
.pv-wrap { max-width: 1216px; margin: 32px auto; padding: 0 16px; display: grid; gap: 16px; }
.pv-card { background: #fff; border-radius: 12px; padding: 16px 20px; }
.pv-card.flush { padding: 0; overflow: hidden; }
.pv-title { font-size: 16px; font-weight: 500; color: #1d2939; }
.pv-tools { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pv-search { display: flex; align-items: center; gap: 6px; height: 32px; width: 280px; background: #eaecf0; border-radius: 6px; padding: 0 8px; color: #1d2939; }
.pv-search.wide { width: 340px; }
.pv-search .svgi { width: 18px; height: 18px; }
.pv-search input { background: transparent; border: 0; padding: 0; font-size: 14px; }
.pv-icon { width: 32px; height: 32px; padding: 0; background: #eaecf0; color: #344054; border-radius: 8px; display: grid; place-items: center; }
.pv-icon .svgi { width: 18px; height: 18px; }
.pv-cols { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
.pv-filters { display: grid; gap: 16px; }
.pf-merge { display: flex; align-items: center; gap: 8px; color: #1d2939; }
.pf-merge .svgi { color: #2d65c3; }
.pf-merge b { font-weight: 500; }
.pf-pages { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 40px; margin-top: 10px; background: #fff; color: #344054; border: 1px solid #d0d5dd; border-radius: 8px; font-weight: 500; }
.pf-pages .svgi { width: 16px; height: 16px; }
.pf-group { font-size: 12px; font-weight: 500; color: #667085; padding: 12px 0 6px; border-top: 1px solid var(--line); }
.pf-group:first-child { border-top: 0; padding-top: 0; }
.pf-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 5px 8px; background: transparent; color: #1d2939; border-radius: 6px; text-align: left; }
.pf-item:hover, .pf-item.on { background: #eaecf0; }
.pf-item i { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; color: #fff; }
.pf-item i .svgi { width: 13px; height: 13px; }
.pf-radio { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 14px; cursor: pointer; }
.pf-radio input { width: auto; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
.tbl th { text-align: left; background: #fff; font-weight: 500; padding: 16px; color: #344054; white-space: nowrap; border-bottom: 1px solid #dde1e7; }
.tbl td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .c { text-align: center; }
.tbl tr[data-conv], .tbl tr[data-post] { cursor: pointer; }
.tbl tbody tr:hover td { background: #eaecf0; }
.tbl .money { white-space: nowrap; text-align: right; }
.tbl .oid { color: #0050b3; font-weight: 500; }
.tbl td.empty { text-align: center; padding: 30px; color: var(--muted); }
.posts tr[data-post]:hover .pr-title { color: #105ce2; }
.pr-main { display: flex; gap: 12px; align-items: center; min-height: 77px; }
.pr-thumb { width: 58px; height: 50px; border-radius: 8px; background: #eaecf0; display: grid; place-items: center; overflow: hidden; flex: none; color: #667085; }
.pr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pr-text { min-width: 0; display: grid; gap: 2px; }
.pr-title { font-weight: 500; color: #101828; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.pr-date { font-size: 12px; color: #475467; }
.pr-stats { display: flex; gap: 12px; font-size: 14px; font-weight: 500; color: #475467; }
.pr-stats span { display: flex; align-items: center; gap: 4px; }
.pr-stats .svgi { width: 14px; height: 14px; }
.pr-stats .warn { color: #f5222d; }
.copy-id { cursor: pointer; }
.pr-by { display: flex; align-items: center; gap: 8px; }
.pr-by img { width: 24px; height: 24px; border-radius: 50%; }

.stat-layout { display: grid; grid-template-columns: 280px 1fr; min-height: 100%; }
.stat-menu { background: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-menu h1, .set-menu h1 { font-size: 24px; font-weight: 500; color: #1d2939; margin: 0 8px 12px; }
.merge-card { border: 1px solid #eaecf0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.stat-item, .set-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 16px; background: transparent; color: #1d2939; border-radius: 8px; font-size: 14px; text-align: left; text-decoration: none; flex: none; }
.stat-item:hover, .set-item:hover { background: #f2f4f7; }
.stat-item.on, .set-item.active { background: #e3f2fd; color: #2d65c3; font-weight: 500; }
.stat-body { padding: 32px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.stat-body h2 { margin: 0; font-size: 20px; font-weight: 500; }
.stat-tools { display: flex; gap: 8px; background: #fff; border-radius: 8px; padding: 12px 16px; }
.stat-tools select { width: auto; height: 32px; background: #eaecf0; border-radius: 6px; }
.card { background: #fff; border-radius: 8px; padding: 24px; min-width: 0; }
.card-title { font-size: 16px; font-weight: 500; color: #101828; }
.card-sub { font-size: 12px; color: #667085; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; align-items: start; }
.stat-grid > div { display: grid; gap: 16px; }
svg.chart-svg { width: 100%; height: auto; display: block; }
svg.chart-svg text { font-size: 11px; fill: #667085; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: #475467; margin-top: 6px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; }
.big-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.big-row span { flex: 1; color: #475467; }
.big-row b { font-size: 18px; font-weight: 500; }
.ill { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; }
.ill.b1 { background: #e6f4ff; color: #1677ff; } .ill.b2 { background: #fff7e6; color: #fa8c16; }
.tag-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.tag-row span { flex: 1; }
.tag-row .svgi { width: 16px; height: 16px; }
.tag-row b { font-weight: 500; }
.tag-row b.hot { color: #fa541c; }
.kpi4 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.kpi4 div { display: grid; border-left: 1px solid var(--line); padding-left: 12px; }
.kpi4 span { font-size: 13px; color: #475467; }
.kpi4 b { font-size: 24px; font-weight: 500; }
.top-staff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.top-staff div { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 0 8px; }
.top-staff small { grid-column: 2; font-size: 13px; color: #667085; display: flex; gap: 4px; align-items: center; }
.top-staff small .svgi { width: 14px; height: 14px; }
.rank { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; background: #eaecf0; display: grid; place-items: center; font-size: 12px; font-weight: 500; }
.rank.r1 { background: #fadb14; color: #fff; } .rank.r2 { background: #bfbfbf; color: #fff; } .rank.r3 { background: #d48806; color: #fff; }
.hours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; height: 140px; }
.hours > div { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.hours .col { width: 70%; background: linear-gradient(#5cdbd3, #e6fffb); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.hours .col span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 12px; }
.hours small { font-size: 11px; color: #667085; }
.hbar { display: grid; grid-template-columns: 160px 1fr 80px; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.hbar b { font-weight: 400; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hbar b .svgi { width: 14px; height: 14px; }
.hbar > div { height: 10px; background: #f2f4f7; border-radius: 5px; overflow: hidden; }
.hbar > div i { display: block; height: 100%; background: #91caff; border-radius: 5px; }
.hbar span { text-align: right; color: #475467; }
.stat-tbl th { background: #f9fafb; padding: 10px 12px; font-size: 13px; white-space: normal; }
.stat-tbl td { padding: 8px 12px; font-size: 13px; }
.stat-tbl tr.total td { font-weight: 700; background: #f9fafb; }

/* ===== Cài đặt ===== */
.settings-view { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: 280px 1fr; background: #ecedf4; }
.set-menu { background: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.set-item { height: 42px; padding: 10px 16px; border-radius: 6px; }
.set-body { overflow-y: auto; padding: 32px max(24px, calc((100% - 936px) / 2)); display: grid; gap: 24px; align-content: start; }
.set-title { display: flex; align-items: center; }
.set-title h2 { margin: 0; font-size: 20px; font-weight: 500; }
.set-card { background: #fff; border-radius: 8px; padding: 24px; display: grid; gap: 10px; scroll-margin-top: 16px; }
#adminOnly { display: grid; gap: 24px; }
.set-card-title { font-size: 16px; font-weight: 500; color: #1d2939; }
.set-card input, .set-card select, .set-card textarea { padding: 6px 11px; }
.dlg label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.dlg label.inline { display: flex; }
.lbl { font-size: 12px; color: var(--muted); }
.grid2, .grid3 { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr 1fr; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.checks input { width: auto; }
.checks label { display: flex; gap: 4px; align-items: center; color: var(--text); font-size: 13px; }
.pg { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid #e4e7ec; flex-wrap: wrap; }
.pg img { width: 32px; height: 32px; border-radius: 6px; }
.pg .nm { flex: 1; min-width: 160px; }
.pg button { padding: 4px 10px; font-size: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2939; color: #f2f4f7; padding: 8px 12px; border-radius: 8px; z-index: 99; max-width: 90vw; font-size: 14px; }

@media (max-width: 1250px) {
  .app { grid-template-columns: 52px 300px 1fr 340px; }
  .app.side-hidden { grid-template-columns: 52px 300px 1fr 0; }
  .tab-body { padding: 12px 16px; }
  .brand { min-width: 0; margin-right: 10px; }
}
/* Điện thoại / máy tính bảng */
@media (max-width: 900px) {
  .app, .app.side-hidden, .app.list-collapsed { grid-template-columns: 1fr; grid-template-rows: 50px auto 1fr; }
  .topbar { padding: 0 6px; }
  .brand, .me, .hamburger { display: none; }
  .nav { padding: 6px 8px; font-size: 13px; height: 34px; }
  .topnav { gap: 2px; padding-top: 0; }
  .page-stack { padding: 6px; }
  .pav, .pav img { width: 30px; height: 30px; }
  .top-bell { width: 34px; height: 34px; margin-left: 2px; }
  .page-menu { right: 6px; top: 48px; }
  .rail { flex-direction: row; overflow-x: auto; padding: 4px 6px 6px; gap: 6px; }
  .ri { width: 36px; height: 36px; }
  .rail-menu { left: 6px !important; top: 100px !important; }
  .list { border-radius: 0; }
  .list-head { gap: 6px; }
  .search { flex: 1; width: auto; }
  .chat, .list { grid-row: 3; }
  .app.open .list, .app.open .rail { display: none; }
  .app.open .chat { grid-row: 2 / -1; }
  .app:not(.open) .chat { display: none; }
  .app.list-collapsed .list { display: flex; }
  #btnBack, .close-side { display: grid; }
  .head-icons .hicon:not(#btnPanel):not(#hInfo), .vsep { display: none; }
  .chat-head .drop-menu { width: min(300px, 90vw); }
  .side, .app.side-hidden .side { position: fixed; inset: 50px 0 0 0; z-index: 5; display: none; }
  .app.side-open .side { display: flex; }
  .msg.customer, .msg.page { max-width: 88%; }
  .tab-body { padding: 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .ptable { min-height: 160px; }
  .page-view { grid-row: 2 / -1; }
  .pv-wrap { margin: 12px auto; padding: 0 10px; }
  .pv-cols, .stat-layout, .stat-grid { grid-template-columns: 1fr; }
  .stat-body { padding: 12px; }
  .tbl { display: block; overflow-x: auto; }
  .settings-view { top: 50px; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .set-menu { flex-direction: row; overflow-x: auto; padding: 8px; }
  .set-menu h1 { display: none; }
  .set-item { white-space: nowrap; width: auto; }
  .set-body { padding: 12px; }
}

/* Nhiều shop, trang công khai */
.login-links { font-size: 12px; color: var(--muted); text-align: center; }
.login-links a { color: var(--muted); }
.set-card .warn { color: #f5222d; font-weight: 500; }
.rm-item.danger { color: #f5222d; }
.rm-item.danger svg { color: #f5222d; }
