/* mkt-tool - giao dien. Token truoc, thanh phan sau. Xem docs/DESIGN.md */
:root {
  --bg: #F5F6FA; --surface: #FFFFFF; --surface-2: #F8FAFC; --ink: #0F172A; --muted: #475569; --line: #D9DFE8; --line-strong: #B6C0CF;
  --primary: #4338CA; --primary-ink: #FFFFFF; --primary-soft: #EEF0FF; --primary-hover: #3730A3;
  --ok: #15803D; --ok-soft: #DCFCE7; --warn: #92400E; --warn-soft: #FEF3C7; --danger: #B91C1C; --danger-soft: #FEE2E2; --off: #475569; --off-soft: #E5E9F0;
  --focus: #1D4ED8;
  --r: 8px; --r-lg: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.06); --shadow-lg: 0 12px 40px rgba(15,23,42,.25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --fs: 15px; --top-h: 60px; --side-w: 236px; --bottom-h: 60px;
  --gc: #334155; /* mau nhom cua tai khoan dang chon */
}
:root[data-theme="dark"] {
  --bg: #0B1020; --surface: #141B2D; --surface-2: #1A2338; --ink: #E8ECF5; --muted: #A9B4C8; --line: #2A3550; --line-strong: #3C4A6B;
  --primary: #8B93FF; --primary-ink: #0B1020; --primary-soft: #1E2547; --primary-hover: #A5ABFF;
  --ok: #4ADE80; --ok-soft: #12361F; --warn: #FBBF24; --warn-soft: #3A2A0A; --danger: #FCA5A5; --danger-soft: #3F1417; --off: #B6C0D4; --off-soft: #232D45;
  --focus: #93C5FD; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs)/1.5 var(--font); color: var(--ink); background: var(--bg); min-height: 100vh; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; min-height: 44px; display: inline-flex; align-items: center; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 999; }
.skip:focus { left: 8px; top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .mono { font-family: var(--mono); font-size: .9em; }
.right { margin-left: auto; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 28px; height: 28px; }
[hidden] { display: none !important; }

/* ---------- Tien ich (thay cho style inline, CSP) ---------- */
.d-block { display: block; } .gap-8 { gap: 8px; } .gap-4 { gap: 4px; } .fw-4 { font-weight: 400; } .fw-7 { font-weight: 700; } .t-danger { color: var(--danger); } .t-center { text-align: center; }
.pad-20 { padding: 20px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-8 { margin-bottom: 8px; } .w-full { width: 100%; } .minw-0 { min-width: 0; } .t-ok { color: var(--ok); }
.w-120 { width: 120px; } .w-160 { width: 160px; } .no-wrap { white-space: nowrap; }

/* ---------- Nut ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn.lg { min-height: 52px; padding: 0 28px; font-size: 1.05rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.left { justify-content: flex-start; }
.btn.icon-only { padding: 0; width: 40px; } .btn.icon-only.sm { width: 34px; }
.kbd { font: 600 .75rem var(--mono); padding: 1px 6px; border: 1px solid currentColor; border-radius: 5px; opacity: .85; white-space: nowrap; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .85rem; color: var(--muted); }
.field .err { font-size: .875rem; color: var(--danger); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=email], input[type=url], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); }
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.seg { align-self: flex-start; max-width: 100%; overflow-x: auto; display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 16px; cursor: pointer; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }

/* ---------- The, huy hieu ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card > h2, .card > .card-h { margin-bottom: 12px; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--off-soft); color: var(--off); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); } .badge.info { background: var(--primary-soft); color: var(--primary); }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 22px; }
.count.soft { background: var(--primary-soft); color: var(--primary); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 6px; font-size: .8rem; font-weight: 600; background: color-mix(in srgb, var(--gc, #475569) 14%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--gc, #475569) 35%, var(--surface)); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--gc, #475569); }
.g0 { --gc: #3730A3; } .g1 { --gc: #0F766E; } .g2 { --gc: #B45309; } .g3 { --gc: #BE123C; } .g4 { --gc: #6D28D9; } .g5 { --gc: #0369A1; } .gx { --gc: #334155; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gc); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; text-transform: uppercase; }
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }

/* ---------- Khung ung dung ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "top top" "banners banners" "side main"; }
.top { grid-area: top; position: sticky; top: 0; z-index: 30; height: var(--top-h); background: var(--gc); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; transition: background .25s; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; width: calc(var(--side-w) - 16px); letter-spacing: .2px; }
.top .brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--gc); display: grid; place-items: center; }
.top .btn { color: #fff; border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.12); }
.top .btn:hover { background: rgba(255,255,255,.24); border-color: #fff; }
.top .btn.stop { background: #fff; color: #991B1B; border-color: #fff; font-weight: 800; }
.top .btn.stop:hover { background: #FEE2E2; }
.top .btn.stop.on { background: #7F1D1D; color: #fff; border-color: #fff; }
.acct-btn { display: flex; align-items: center; gap: 12px; min-height: 46px; max-width: 460px; padding: 4px 14px 4px 6px; border-radius: 999px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.6); color: #fff; cursor: pointer; text-align: left; }
.acct-btn:hover { background: rgba(255,255,255,.28); }
.acct-btn .avatar { background: #fff; color: var(--gc); width: 36px; height: 36px; }
.acct-btn .nm { font-size: 1.15rem; font-weight: 800; line-height: 1.1; }
.acct-btn .sub { font-size: .78rem; opacity: .92; }
.top .count { background: #fff; color: #991B1B; }
.menu-wrap { position: relative; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.pop button, .pop a { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; text-decoration: none; color: var(--ink); }
.pop button:hover, .pop a:hover { background: var(--primary-soft); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.pop .who { padding: 8px 12px; }
.side { grid-area: side; padding: 14px 10px; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); align-self: start; display: flex; flex-direction: column; gap: 3px; }
.nav-a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.nav-a:hover { background: var(--primary-soft); }
.nav-a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.nav-a .count { margin-left: auto; }
.nav-a > span:not(.count) { white-space: nowrap; }
.side .foot { margin-top: auto; padding: 8px 12px; font-size: .8rem; color: var(--muted); }
.main { grid-area: main; padding: 22px 26px 40px; min-width: 0; max-width: 1280px; width: 100%; }
.banners { grid-area: banners; position: sticky; top: var(--top-h); z-index: 25; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 20px; font-weight: 600; }
.banner.bad { background: #991B1B; color: #fff; } .banner.warn { background: #FDE68A; color: #451A03; } .banner.info { background: #E0E7FF; color: #1E1B4B; }
.banner .btn { color: inherit; background: rgba(255,255,255,.2); border-color: currentColor; min-height: 34px; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h h1 { margin-right: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 0 16px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.bottom { display: none; }

/* ---------- Tong quan ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--primary); }
.stat .n { font-size: 2.1rem; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--muted); font-weight: 600; }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); } .stat.bad .n { color: var(--danger); } .stat.info .n { color: var(--primary); }
.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; padding: 12px 16px; border-radius: var(--r); border: 1px solid; }
.alert.bad { background: var(--danger-soft); border-color: var(--danger); } .alert.warn { background: var(--warn-soft); border-color: #D97706; } .alert.info { background: var(--primary-soft); border-color: var(--primary); } .alert.ok { background: var(--ok-soft); border-color: var(--ok); }
.alert .icon, .alert .btn { flex: none; }
.alert > :not(.icon):not(.btn) { flex: 1; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }

/* ---------- Bang/danh sach ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 240px; position: relative; max-width: 380px; }
.toolbar .search input { padding-left: 38px; } .toolbar .search .icon { position: absolute; left: 11px; top: 11px; color: var(--muted); pointer-events: none; }
.toolbar select { width: auto; min-width: 140px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.tbl th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.dim td { opacity: .62; }
.tbl tr.sel td { background: var(--primary-soft); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.cell-acct { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-acct b { display: block; }
.acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .big { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty p { max-width: 460px; color: var(--muted); }
.error-box { padding: 14px 16px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-weight: 600; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border: 1px solid var(--danger); }
.skel { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 6px; height: 16px; }
.skel.blk { height: 56px; margin-bottom: 8px; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }
.progress { height: 16px; background: var(--off-soft); border-radius: 999px; overflow: hidden; display: flex; }
.progress > i { display: block; height: 100%; transition: width .4s; }
.progress .p-ok { background: var(--ok); } .progress .p-bad { background: var(--danger); } .progress .p-warn { background: #D97706; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; }
.legend b { font-size: 1.1rem; }
.steps { list-style: none; padding: 0; margin: 0 0 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; color: var(--muted); }
.step i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--off-soft); font-size: .85rem; }
.step.on { color: var(--primary); border-color: var(--primary); } .step.on i { background: var(--primary); color: var(--primary-ink); }
.step.done i { background: var(--ok); color: #fff; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
pre.raw { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: var(--r); overflow: auto; max-height: 260px; font: .82rem/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; }

/* ---------- Hop thu ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; height: calc(100vh - var(--top-h) - 190px); min-height: 460px; }
.inbox .list { border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.conv { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; min-height: 64px; }
.conv:hover { background: var(--surface-2); } .conv[aria-current="true"] { background: var(--primary-soft); }
.conv .t { font-weight: 700; } .conv.unread .t::after { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); margin-left: 8px; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column-reverse; gap: 8px; background: var(--surface-2); }
.msg { max-width: min(560px, 82%); padding: 9px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--gc); color: #fff; border-color: transparent; }
.msg time { display: block; font-size: .72rem; opacity: .8; margin-top: 2px; }
.msg.pending { opacity: .65; } .msg.failed { outline: 2px solid var(--danger); }
.composer { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 160px; }
.back-only { display: none; }

/* ---------- Dang & tuong tac ---------- */
.post { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.post + .post { margin-top: 12px; }
.post .meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.post .media { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; } .post .media img, .post .media video { max-width: 100%; max-height: 320px; border-radius: var(--r); }
.post .foot { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.comments { margin-top: 10px; padding-left: 12px; border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2); }
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); }
.file progress { flex: 1; height: 10px; }
.pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 300px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: var(--r); }
.pickgrid .check { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }

/* ---------- Hop thoai ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); max-width: min(560px, calc(100vw - 24px)); width: 100%; max-height: calc(100vh - 32px); overflow: auto; }
dialog::backdrop { background: rgba(15,23,42,.55); }
dialog.wide { max-width: min(760px, calc(100vw - 24px)); }
.dlg-h { padding: 18px 22px 0; display: flex; align-items: center; gap: 12px; } .dlg-h h2 { flex: 1; }
.dlg-b { padding: 14px 22px; } .dlg-f { padding: 12px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.summary-box { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
dialog.switcher { max-width: 640px; margin-top: 8vh; border-top: 6px solid var(--gc); }
.sw-search { padding: 14px 16px 8px; position: relative; } .sw-search .icon { position: absolute; left: 28px; top: 27px; color: var(--muted); } .sw-search input { padding-left: 42px; min-height: 48px; font-size: 1.05rem; }
.sw-list { max-height: min(56vh, 460px); overflow: auto; padding: 4px 8px 8px; }
.sw-h { padding: 8px 10px 4px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sw-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 10px; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; }
.sw-item[aria-selected="true"], .sw-item:hover { background: var(--primary-soft); }
.sw-item.dim .avatar, .sw-item.dim .nm { opacity: .55; }
.sw-foot .close { margin-left: auto; }
.sw-foot { padding: 8px 16px 12px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: var(--r); background: #0F172A; color: #fff; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; border-left: 5px solid #818CF8; animation: tin .2s; }
.toast.ok { border-left-color: #4ADE80; } .toast.bad { border-left-color: #F87171; } .toast.warn { border-left-color: #FBBF24; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dang nhap ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #1E1B4B, #3730A3 55%, #4F46E5); }
.login .card { width: 100%; max-width: 420px; padding: 32px; }
.login.overlay { position: fixed; inset: 0; z-index: 200; min-height: 0; background: rgba(15,23,42,.88); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Tablet / Mobile ---------- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  input[type=text], input[type=password], input[type=number], input[type=search], input[type=email], input[type=url], input[type=datetime-local], input[type=date], select { min-height: 44px; }
  .seg button { min-height: 44px; } .skip:focus { min-height: 44px; display: inline-flex; align-items: center; } .tabs a, .tabs button { min-height: 48px; } .nav-a, .pop button, .pop a { min-height: 44px; } .check { min-height: 44px; } .acct-btn { min-height: 48px; }
  .alert { flex-wrap: wrap; }
  .linklist a { display: inline-flex; align-items: center; min-height: 44px; }
  :root { --fs: 16px; --top-h: 56px; --side-w: 0px; }
  .shell { display: block; padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); }
  .side, .top .brand, .top .hide-m, .acct-btn .kbd { display: none; }
  .top { padding: 0 10px; gap: 8px; } .acct-btn { flex: 1; min-width: 0; max-width: none; } .acct-btn .nm { font-size: 1.05rem; }
  .top .btn.stop span.lbl { display: none; } .top .btn.stop { min-width: 44px; min-height: 44px; padding: 0 12px; }
  .main { padding: 14px 12px 28px; }
  .bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); }
  .bottom a, .bottom button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 700; min-height: 48px; cursor: pointer; }
  .bottom [aria-current="page"] { color: var(--primary); }
  .bottom .count { position: absolute; top: 4px; left: calc(50% + 6px); }
  .btn { min-height: 44px; } .btn.sm { min-height: 44px; } .btn.icon-only, .btn.icon-only.sm { width: 44px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stats { gap: 10px; } .stat .n { font-size: 1.7rem; } .stat { padding: 12px 14px; }
  .toolbar .search { flex: 1 1 100%; max-width: none; } .toolbar select { flex: 1 1 calc(50% - 10px); min-width: 0; width: auto; } .toolbar input[type=text], .toolbar input[type=date] { flex: 1 1 calc(50% - 10px); width: auto; min-width: 0; }
  .hide-m { display: none !important; }
  .step:not(.on) .lbl { display: none; } .step:not(.on) { padding-right: 6px; }
  .card-h .right.row { margin-left: 0; width: 100%; } .card-h .right.row .btn { flex: 1; }
  .inbox-head.chat-open { display: none; } .inbox.chat-open { height: calc(100dvh - var(--top-h) - var(--bottom-h) - 24px - env(safe-area-inset-bottom)); }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl { border: 0; background: none; } .tbl thead { display: none; }
  .tbl tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 10px; padding: 8px 4px; box-shadow: var(--shadow); }
  .tbl td { border: 0; padding: 4px 12px; } .tbl td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
  .tbl td.acts-c { padding-top: 8px; } .acts { justify-content: flex-start; }
  .inbox { display: block; height: calc(100dvh - var(--top-h) - var(--bottom-h) - 190px); min-height: 400px; }
  .inbox .list, .inbox .chat { height: 100%; border: 0; } .inbox.chat-open .list, .inbox:not(.chat-open) .chat { display: none; }
  .back-only { display: inline-flex; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; }
  dialog { max-width: 100vw; width: 100vw; margin: auto 0 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  dialog.switcher { margin-top: auto; border-top: 0; }
  dialog.center { margin: auto; width: calc(100vw - 24px); border-radius: var(--r-lg); }
  .sw-item { min-height: 56px; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--bottom-h) + 12px); max-width: none; }
  .page-h h1 { font-size: 1.25rem; }
  .pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(var(--bottom-h) + 8px); }
}
@media print { .top, .side, .bottom { display: none; } }
