:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6f4f2;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --warn: #a16207;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-border: #bbf7d0;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #5b6574;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --focus: 0 0 0 3px rgba(15, 118, 110, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; vertical-align: -0.2em; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.content:focus-visible { outline: none; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 9px;
  border: 1px solid transparent; background: none; color: inherit;
  font: inherit; font-weight: 600; font-size: 14.5px; text-decoration: none;
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; color: var(--text); }
.btn-ghost { color: var(--brand); padding-inline: 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }
.btn-light { background: #fff; color: var(--danger); }
.btn-light:hover { background: #fff5f5; color: var(--danger); }
.btn-danger-outline { background: var(--card); border-color: var(--danger-border); color: var(--danger); }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-soft); }
.link { background: none; border: 0; padding: 2px 4px; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; border-radius: 4px; }

/* ---------- Ô nhập ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
input, select {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: var(--text);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover { border-color: #94a3b8; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.code-input { font-family: var(--mono); font-size: 24px; letter-spacing: 0.4em; text-align: center; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); column-gap: 16px; }
.form-actions { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* ---------- Thông báo ---------- */
.live:empty { display: none; }
.live { margin: 4px 0 12px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 9px; border: 1px solid; font-size: 14px; margin: 8px 0;
}
.notice .icon { margin-top: 2px; }
.notice-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.notice-warn { background: var(--warn-soft); border-color: var(--warn-border); color: #854d0e; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.notice-info { background: var(--brand-soft); border-color: #b7e0db; color: var(--brand-dark); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 13.5px; font-weight: 600; line-height: 1.4;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: #854d0e; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-idle { background: #f1f5f9; color: var(--muted); }
.tag { font-size: 12.5px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #cbd5e1; border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } * { transition: none !important; } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* ---------- Đăng nhập / thiết lập ---------- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), var(--bg) 70%);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); padding: 32px 28px;
}
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 20px; }
.auth-card form { margin-top: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--brand-dark); margin-bottom: 24px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff;
}
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 16px;
  padding: 8px 12px; border-radius: 9px; background: var(--bg); font-size: 14px; }
.who > span { display: inline-flex; align-items: center; gap: 6px; }
.hint { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 14px; color: var(--brand-dark);
  background: var(--brand-soft); border-radius: 9px; padding: 10px 12px; }
.hint .icon { margin-top: 3px; }
.auth-alt { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--border); }

/* ---------- Khung ---------- */
/* Thanh bên sticky chỉ cao 100vh; nền + viền tô cho cả cột lưới để trang dài hơn màn hình vẫn liền mạch. */
.layout {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--card) 239px, var(--border) 239px 240px, transparent 240px);
}
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--border); padding: 18px 12px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 16px; }
.side-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-brand-text > span { overflow-wrap: anywhere; }
.side-brand-text small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: '/'; margin-right: 4px; }
.crumbs li[aria-current='page'] { color: var(--text); }
.nav-more-group { display: flex; flex-direction: column; gap: 2px; }
.nav-more-group + .nav-more-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.nav-more-menu { max-height: calc(100vh - 90px); overflow-y: auto; }
/* Danh sách hàng dùng chung cho các trang giai đoạn 7 (Liên hệ, Lịch hẹn, Trí nhớ, Kho tri thức…). */
.row-list { list-style: none; margin: 8px 0 0; padding: 0; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.row-item:last-child { border-bottom: 0; }
.row-main { display: flex; flex-direction: column; flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.row-tags .badge { padding: 2px 8px; font-size: 12.5px; }
/* Insight nhóm */
.chart-bar-soft { fill: var(--brand-soft); }
.heat { border-collapse: separate; border-spacing: 2px; width: 100%; table-layout: fixed; font-size: 12px; }
.heat th { font-weight: 500; color: var(--muted); text-align: left; padding: 0 2px; }
.heat td { height: 14px; border-radius: 3px; background: #f1f5f9; }
.heat td.heat-1 { background: color-mix(in srgb, var(--brand) 25%, #fff); }
.heat td.heat-2 { background: color-mix(in srgb, var(--brand) 50%, #fff); }
.heat td.heat-3 { background: color-mix(in srgb, var(--brand) 75%, #fff); }
.heat td.heat-4 { background: var(--brand); }
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
/* Second brain */
.sb-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow-y: auto; font-size: 14px; background: #f8fafc; padding: 12px; border-radius: 8px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: underline; }
.link-btn:focus-visible { outline: none; box-shadow: var(--focus); }
/* Giai đoạn 7B: dải chờ khởi động lại, Agent, Theo dõi agent */
.restart-banner { margin-bottom: 16px; }
.restart-banner p { margin: 0 0 8px; }
.soul-edit { width: 100%; min-height: 280px; font-size: 13.5px; line-height: 1.5; }
.trace-box { flex: 1 1 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.trace-turns { list-style: none; margin: 0; padding: 0; }
.trace-turns > li + li { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }
.trace-turn p { margin: 2px 0; overflow-wrap: anywhere; }
.trace-tools { margin: 4px 0; padding-left: 18px; }
.trace-tools li { margin: 2px 0; overflow-wrap: anywhere; }
/* Trí nhớ */
.mem-editor { flex: 1 1 100%; margin-top: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.mem-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; margin-bottom: 6px; }
.mem-text { white-space: pre-wrap; }
.mem-block + .mem-block { margin-top: 16px; }
.nav { display: flex; flex-direction: column; flex: 1; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 4px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #667080; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-size: 14.5px; font-weight: 500; white-space: nowrap;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 650; }
.nav-item.active .icon { color: var(--brand); }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus); }
.mnav { display: none; }
.mnav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px;
  border-radius: 9px; color: var(--text); text-decoration: none; font-size: 12.5px; font-weight: 600; line-height: 1.25; cursor: pointer; list-style: none;
}
.mnav-item > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mnav-item:hover { background: #f1f5f9; color: var(--text); }
.mnav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.mnav-item.active .icon { color: var(--brand); }
.mnav-item:focus-visible { outline: none; box-shadow: var(--focus); }
.nav-more { position: relative; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: flex; flex-direction: column; gap: 2px;
  min-width: 240px; padding: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
}
.nav-more-menu .nav-item { min-height: 44px; }
.nav-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.me { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.me small { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
/* Thẻ tài khoản cuối thanh bên: ô chữ cái tròn cùng cỡ ô biểu tượng, hai dòng chữ không tràn. */
.nav-foot .nav-item { gap: 10px; padding: 8px; }
.nav-foot .avatar-sm { width: 30px; height: 30px; font-size: 13px; }
.me > span, .me small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me > span { font-weight: 600; font-size: 14px; }
.me small { font-size: 12.5px; }
.nav-item.active .avatar { background: rgba(255, 255, 255, .22); color: #fff; }
.nav-item.active .me small { color: rgba(255, 255, 255, .82); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.strip {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 28px; font-size: 14.5px; font-weight: 600; border-bottom: 1px solid transparent;
}
.strip-text { display: inline-flex; align-items: center; gap: 8px; }
.strip-danger { background: var(--danger); color: #fff; }
.strip-warn { background: #fbbf24; color: #422006; }
.strip-ok { background: var(--ok); color: #fff; }
.strip-idle { background: #e2e8f0; color: var(--muted); }
/* Màn hình rộng: dùng hết bề ngang (chỉ chặn ở màn siêu rộng để dòng chữ không quá dài). */
.content { padding: 28px; max-width: 2200px; width: 100%; }
.page-head { margin-bottom: 20px; }
.page-head p { margin-top: 4px; }

/* ---------- Thẻ ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px;
}
.card > h2 { margin-bottom: 14px; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-top { align-items: start; }
.grid-qr { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.stat-head { display: flex; align-items: center; gap: 10px; }
.stat-icon { display: inline-flex; padding: 8px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.facts { margin: 0; display: grid; gap: 10px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.last-error { margin: 10px 0 6px; font-weight: 600; }
.empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 24px; }
.empty .icon { color: var(--muted); }
.empty h1 { font-size: 20px; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700;
}
.avatar-sm { width: 30px; height: 30px; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; font-size: 26px; }
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.account-info { flex: 1; min-width: 180px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.account > .live { flex-basis: 100%; }
.link-out { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.reset-row td { background: #f8fafc; white-space: normal; }
.reset-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.reset-form .field { margin: 0; min-width: 220px; }
.reset-form .live { flex-basis: 100%; margin: 0; }
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- QR ---------- */
.steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 8px; }
.steps + .notice { margin-bottom: 16px; }
.qr-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.qr-box {
  width: 296px; height: 296px; max-width: 100%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 14px; background: #fff; padding: 8px;
}
.qr-img { width: 280px; height: 280px; max-width: 100%; image-rendering: pixelated; }
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.qr-placeholder.ok { color: var(--ok); font-weight: 600; }
.qr-progress { width: 240px; height: 6px; margin-top: 8px; appearance: none; border: 0; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.qr-progress::-webkit-progress-bar { background: #e2e8f0; border-radius: 999px; }
.qr-progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.qr-progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.table th.th-wrap { white-space: normal; }

.subhead { font-size: 14px; font-weight: 650; margin: 16px 0 6px; }
.list .push { margin-left: auto; white-space: nowrap; }

/* ---------- Phiên chat ---------- */
textarea {
  width: 100%; min-height: 64px; padding: 9px 12px; resize: vertical;
  border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: var(--text); font: inherit;
}
textarea:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; height: calc(100vh - 190px); min-height: 480px; }
.chat > .card { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.chat-search { display: flex; gap: 8px; margin-bottom: 8px; }
.conv-list { list-style: none; margin: 0 -8px; padding: 0; overflow-y: auto; flex: 1; }
.conv {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 10px 8px; border: 0; border-radius: 9px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.conv:hover { background: #f1f5f9; }
.conv.active { background: var(--brand-soft); }
.conv:focus-visible { outline: none; box-shadow: var(--focus); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.conv-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-preview { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.conv mark { background: #fde68a; color: var(--text); border-radius: 3px; padding: 0 1px; }
.found-head { justify-content: space-between; margin-bottom: 6px; }
.thread-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
/* Nút "← Danh sách" và nhãn không bị bóp/xuống dòng; tên dài tự xuống dòng trong phần còn lại. */
.thread-head > .btn, .thread-head > .tag { flex: none; white-space: nowrap; }
.thread-head > h2 { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.msgs { list-style: none; margin: 0; padding: 12px 2px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msgs-top { align-self: center; }
.msg { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 78%; }
.msg-self { align-self: flex-end; align-items: flex-end; }
.msg-from { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.msg-bubble { padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: #f1f5f9; overflow-wrap: anywhere; }
.msg-self .msg-bubble { background: var(--brand); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg-self .msg-bubble a { color: #fff; }
.msg-text { white-space: pre-wrap; }
.msg-kind { font-style: italic; opacity: .85; }
.msg-time { font-size: 12.5px; color: var(--muted); }
.compose { border-top: 1px solid var(--border); padding-top: 12px; }
.compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.compose-foot > .attach-btn { margin-left: auto; }
.compose.is-drag { outline: 2px dashed var(--brand); outline-offset: 4px; border-radius: 8px; }
.attach-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attach-item { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.attach-item > img, .attach-ico { flex: none; width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }
.attach-ico { display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); }
.attach-name { display: flex; flex-direction: column; min-width: 0; max-width: 220px; font-size: 13px; }
.attach-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-empty { margin: auto; }
.only-mobile { display: none; }

/* Phiên chat: ảnh, tệp, video, tìm trong hội thoại, bảng Ảnh/Video · Tệp · Link */
.chat-thread { position: relative; }
.thread-head .head-tool { flex: none; color: var(--muted); }
.thread-head .head-tool.active { background: var(--brand-soft); color: var(--brand-dark); }
.msgs { position: relative; }
.msg-media { padding: 6px; }
.msg-media .msg-text { display: block; padding: 6px 6px 2px; }
.msg-bubble.msg-focus, .msg-focus .msg-bubble { box-shadow: 0 0 0 3px #f59e0b; transition: box-shadow .4s; }
.thumb-btn { display: block; padding: 0; border: 0; background: none; border-radius: 10px; overflow: hidden; cursor: zoom-in; }
.thumb-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.thumb img { display: block; width: 240px; max-width: 100%; height: 180px; object-fit: cover; background: #e2e8f0; }
.thumb-broken { display: flex; align-items: center; gap: 8px; width: 240px; max-width: 100%; padding: 12px; border-radius: 10px;
  background: #e2e8f0; color: var(--text); font-size: 13.5px; }
.msg-self .msg-bubble .thumb-broken a, .msg-self .msg-bubble .file-card a { color: var(--brand-dark); }
.file-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: #fff; color: var(--text); max-width: 360px; }
.file-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.file-card .btn { flex: none; }
.file-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 8px;
  background: #475569; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.file-ico-pdf { background: #b91c1c; }
.file-ico-doc { background: #1d4ed8; }
.file-ico-xls { background: #15803d; }
.file-ico-ppt { background: #c2410c; }
.file-ico-zip { background: #6d28d9; }
.video-card, .msg-self .msg-bubble .video-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  background: #0f172a; color: #fff; font-weight: 600; text-decoration: none; }
.video-card:hover { background: #1e293b; color: #fff; }
.video-play { display: inline-flex; }
.jump-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }

.side-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; width: min(360px, 100%); display: flex; flex-direction: column;
  padding: 14px 16px; background: var(--card); border-left: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.side-head h3 { font-size: 15px; }
.side-body { flex: 1; min-height: 0; overflow-y: auto; }
.side-body .conv-list { margin: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.tab { flex: 1; min-height: 40px; padding: 8px 6px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab:focus-visible { outline: none; box-shadow: var(--focus); }
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.media-tile { display: block; width: 100%; aspect-ratio: 1; border-radius: 6px; overflow: hidden; }
.media-tile img { display: block; width: 100%; height: 100%; object-fit: cover; background: #e2e8f0; }
.media-tile.thumb-broken { flex-direction: column; justify-content: center; gap: 4px; padding: 6px; font-size: 12px; text-align: center; color: var(--muted); }
.media-tile.thumb-broken a { display: block; }
/* Màn hình rộng: bảng bên nằm cạnh khung tin, không che tin (màn hẹp hơn thì bảng phủ lên khung tin). */
@media (min-width: 1200px) {
  /* 360px của bảng − 22px lề thẻ + 14px khoảng thở */
  .chat-thread:has(> .side-panel) > :not(.side-panel) { margin-right: 352px; }
  .chat-thread:has(> .side-panel) .head-tool-label { display: none; }
}
.media-video { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #0f172a; color: #fff;
  font-size: 12.5px; font-weight: 600; text-decoration: none; }
.media-video:hover { color: #fff; background: #1e293b; }
.media-list { list-style: none; margin: 0; padding: 0; }
.media-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.media-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.media-link { color: inherit; text-decoration: none; border-radius: 6px; }
.media-link:hover { background: #f1f5f9; color: inherit; }
.link-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-dark); }
.link-host { font-size: 13.5px; font-weight: 700; overflow-wrap: anywhere; }
.link-text { color: var(--brand); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-more { display: flex; margin: 10px auto 0; }
.panel-empty { padding: 12px 0; }

.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: rgba(15, 23, 42, 0.94); color: #fff; }
.lightbox-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.lightbox-count { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox .lightbox-btn { color: #fff; }
.lightbox .lightbox-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); color: #fff; }
.lightbox-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px 16px; }
.lightbox-img { min-width: 0; max-width: calc(100% - 128px); max-height: 100%; object-fit: contain; border-radius: 4px; }
.lightbox-nav { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff; cursor: pointer; }
.lightbox-nav:disabled { opacity: .3; cursor: default; }
.lightbox-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
body.no-scroll { overflow: hidden; }
.thumb-pending { display: block; background: #e2e8f0; border-radius: 10px; }
.thumb.thumb-pending { width: 240px; max-width: 100%; height: 180px; }
.thumb-retry { border: 0; cursor: pointer; font: inherit; text-align: left; }
.thumb-retry:focus-visible { outline: none; box-shadow: var(--focus); }
.lightbox-retry { flex: none; }
.lightbox-broken { flex: 1; min-width: 0; max-width: 420px; text-align: center; }
.lightbox-caption { padding: 0 16px 16px; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Nhật ký ---------- */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.audit-day + .audit-day { margin-top: 18px; }
.audit-day-head { font-size: 14px; font-weight: 700; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.audit-list { list-style: none; margin: 0; padding: 0; }
.audit-item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: 0; }
.audit-time { flex: none; width: 44px; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.audit-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.audit-fail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; }
.audit-tech summary { display: inline-flex; align-items: center; min-height: 32px; color: var(--brand); font-size: 13px; font-weight: 600; cursor: pointer; }
.load-more { margin-top: 12px; }

/* ---------- Phân quyền Bot ---------- */
.perm { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.perm > .card { margin: 0; display: flex; flex-direction: column; min-height: 0; }
/* Cột trái dính khi cuộn khung sửa dài (dưới dải trạng thái). */
.perm-list { position: sticky; top: 64px; max-height: calc(100vh - 84px); }
.perm-list .conv-name .icon { margin-right: 4px; }
.perm-list .conv-top { align-items: center; }
.perm-list .badge { flex: none; white-space: nowrap; padding: 2px 8px; font-size: 12.5px; }
.perm-note { margin-top: 12px; }
.perm-note-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.perm-note-row .perm-note { flex: 1 1 260px; }
.perm-note-row .btn { margin-top: 8px; flex: none; }
/* Hộp: fieldset có legend, hoặc <details> gập được có summary tóm tắt "a/b đang bật". */
.perm-box { border: 1px solid var(--border); border-radius: 10px; margin: 14px 0; padding: 6px 14px 10px; min-width: 0; background: var(--card); }
.perm-box legend { padding: 0 6px; font-weight: 650; font-size: 14px; }
details.perm-box { padding: 0 14px; }
details.perm-box > summary {
  display: flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; list-style: none;
  font-weight: 650; font-size: 14px; border-radius: 8px;
}
details.perm-box > summary::-webkit-details-marker { display: none; }
details.perm-box > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.perm-box[open] > summary::before { transform: rotate(90deg); }
details.perm-box[open] > summary { border-bottom: 1px solid var(--border); }
details.perm-box > summary:focus-visible { outline: none; box-shadow: var(--focus); }
details.perm-box > .perm-grid { padding: 4px 0 10px; }
.perm-box-sum { font-weight: 500; }
.perm-grid { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 24px; }
@media (min-width: 1100px) { .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Ô bị tắt: chỉ làm mờ ô check, chữ giữ đủ tương phản; lý do nằm ở thông báo phía trên hộp. */
fieldset:disabled .check { cursor: not-allowed; }
fieldset:disabled .check input { opacity: .45; }
.perm-row { display: flex; flex-direction: column; gap: 0; padding: 2px 0 6px; border-bottom: 1px solid var(--border); }
.perm-row:last-child, .perm-grid > .perm-row { border-bottom: 0; }
.perm-row .check { min-height: 44px; }
.perm-row small, .perm-row .more-hint { padding-left: 28px; }
.more-hint summary { display: inline-flex; align-items: center; min-height: 32px; padding: 0 4px; color: var(--brand); font-size: 13px; font-weight: 600; cursor: pointer; }
.more-hint p { margin-bottom: 4px; }
.check input[type="radio"] { accent-color: var(--brand); }
/* Ai được nhắn: ba thẻ chọn ngang (máy tính), dọc (điện thoại); chỉ hiện gợi ý của lựa chọn đang chọn. */
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
.radio-card {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 11px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: 14.5px; line-height: 1.4;
}
.radio-card:hover { border-color: #94a3b8; }
.radio-card.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.radio-card:has(input:focus-visible) { box-shadow: var(--focus); }
.radio-card input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
fieldset:disabled .radio-card { cursor: not-allowed; }
/* Danh sách người: hàng gập ~56px, mở một người một lúc. */
.dm-add-box > summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; cursor: pointer; list-style: none;
  color: var(--brand); font-weight: 650; border-radius: 8px;
}
.dm-add-box > summary::-webkit-details-marker { display: none; }
.dm-add-box > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.dm-add-box[open] { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.dm-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.dm-add input, .dm-add select { flex: 1 1 180px; min-width: 0; }
.dm-add .btn { flex: none; }
.dm-add-error { color: var(--danger); margin: 6px 0 0; }
.dm-add-error:empty { display: none; }
.dm-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 4px; }
.dm-filter input { flex: 1 1 200px; min-width: 0; }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.dm-people { list-style: none; margin: 4px 0 0; padding: 0; }
.dm-person { border-bottom: 1px solid var(--border); }
.dm-person:last-child { border-bottom: 0; }
.dm-row { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 3px 0; }
.dm-who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.dm-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-who small { flex: none; }
.dm-row .badge { flex: none; white-space: nowrap; padding: 2px 8px; font-size: 12.5px; }
.dm-row .btn { flex: none; min-width: 72px; }
.dm-person.open .dm-row .btn { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.dm-panel { margin: 0 0 12px; padding: 4px 0 4px 14px; border-left: 2px solid var(--brand); }
.dm-panel-actions { margin-top: 6px; }
.dm-more { margin-top: 6px; }
.dm-empty { margin: 8px 0; }
/* Xưởng tạo sản phẩm (spec §17): ô số lượt, ghi chú, nút bị máy chủ khoá, nút xưởng riêng từng người, Hạn mức xưởng. */
.studio-note { margin: 8px 0 0; }
.studio-foot { margin: 0 0 10px; }
.studio-quota { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0 10px; }
.studio-quota label { font-weight: 600; }
.studio-quota input, .quota-input { width: 5.5em; flex: none; }
.studio-quota small { flex: 1 1 100%; }
.studio-quota-error { color: var(--danger); }
.studio-today { margin: 0 0 8px; }
.check:has(input:disabled) { cursor: not-allowed; }
.check input:disabled { opacity: .45; }
.dm-studio-head { margin: 8px 0 0; font-weight: 650; }
.quota-row { flex-wrap: wrap; row-gap: 0; }
.quota-edit { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.quota-use { flex: 1 1 100%; margin: -4px 0 4px; }
.quota-use:empty { display: none; }
.studio-recent-head { font-size: 15px; margin: 16px 0 4px; }
/* Thanh Lưu dính đáy khung sửa: luôn thấy số thay đổi + Hoàn tác + Lưu. */
.perm-form { display: flex; flex-direction: column; }
.save-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin: 12px -22px -20px; padding: 12px 22px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 -6px 12px -10px rgba(15, 23, 42, 0.25);
}
.save-bar-text { margin-right: auto; font-weight: 600; font-size: 14px; }
.save-bar .live { flex-basis: 100%; margin: 0; }
.save-bar .notice { margin: 0 0 4px; }

/* ---------- Thương hiệu ---------- */
.logo-img { object-fit: contain; background: transparent; }
.powered { margin-top: 16px; font-size: 12.5px; color: var(--muted); text-align: center; }
.nav-foot .powered { margin-top: 8px; }
.logo-pick { display: flex; gap: 14px; align-items: flex-start; margin: 12px 0 4px; }
.logo-pick .field { margin-bottom: 8px; min-width: 0; }
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.file-btn { position: relative; }
.file-btn:has(input:focus-visible) { box-shadow: var(--focus); }
.file-btn:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.file-name { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.brand-colors { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.brand-colors legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.swatch {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.swatch:hover { background: #f1f5f9; }
.swatch.selected { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); font-weight: 600; }
.swatch-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--swatch); }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type="color"] { width: 48px; height: 40px; padding: 2px; flex: none; cursor: pointer; }
.color-row input:not([type]) { max-width: 140px; }
.contrast { display: flex; gap: 6px; align-items: flex-start; margin-top: 8px; font-size: 14px; }
.contrast .icon { margin-top: 3px; flex: none; }
.contrast-ok { color: var(--ok); }
.contrast-bad { color: var(--danger); }
.form-end { margin-top: 18px; }
.brand-preview {
  display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; margin-top: 14px; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg); pointer-events: none;
}
.pv-side { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.pv-side .side-brand { padding: 0 6px 10px; font-size: 14px; }
.pv-side .side-brand > span:last-child { display: inline; overflow-wrap: anywhere; }
.pv-login {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 10px;
  background: radial-gradient(400px 200px at 50% -10%, var(--brand-soft), var(--card) 70%);
}
.pv-login .auth-brand { margin-bottom: 0; overflow-wrap: anywhere; }
.brand-col { min-width: 0; }
@media (max-width: 760px) {
  .brand-preview { grid-template-columns: minmax(0, 1fr); }
  .nav-foot .powered { display: none; }
}

/* ---------- Chủ nhân bot ---------- */
.banner { flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.banner > div { flex: 1 1 260px; }
.restart-progress { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; }
.restart-progress .spinner { flex: none; }
.notice p { margin: 0 0 4px; }
.fix-steps { margin: 0; padding-left: 20px; }
.fix-steps code, .notice p code { overflow-wrap: anywhere; }
.owner-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.owner-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.owner-list li:last-child { border-bottom: 0; }
.owner-list .avatar { width: 32px; height: 32px; }
.owner-list .btn { flex: none; }
.owner-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; overflow-wrap: anywhere; }

/* ---------- Sức khoẻ máy chủ ---------- */
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-ok { color: var(--ok); }
.stat-warn { color: var(--warn); }
.stat-danger { color: var(--danger); }
.stat-idle { color: var(--muted); }
.charts { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 12px; }
.chart-box { margin: 0; min-width: 0; }
.chart-box figcaption { margin-bottom: 6px; }
/* Chiều cao cố định, giãn ngang theo khung (preserveAspectRatio="none"); nét vẽ không co giãn theo. */
.chart { display: block; width: 100%; height: 110px; overflow: visible; }
.chart-bars .chart { height: 140px; }
.chart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-limit { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-bar { fill: var(--brand); }
.chart-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.chart-bars { margin-bottom: 12px; }
.chart-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; }
.chart-main { min-width: 0; }
/* Nhãn trục Y: 100 % ở vạch trên, 50 % giữa, 0 % đáy — cùng chiều cao với .chart. */
.chart-y { display: flex; flex-direction: column; justify-content: space-between; height: 126px; margin-top: -8px;
  font-size: 12.5px; line-height: 16px; color: var(--muted); text-align: right; }
.usage-days { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 12px; }
.usage-day { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.usage-day .stat-value { margin-top: 4px; }
.svc-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.svc-list li:last-child { border-bottom: 0; }
.svc-main { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Điện thoại ---------- */
@media (max-width: 760px) {
  /* Thanh trên cùng chỉ cao đúng nội dung; phần còn lại của màn hình thuộc về nội dung (trang ngắn không bị giãn thanh). */
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; background: none; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible;
  }
  /* Nhường chỗ cho đủ chữ 5 mục điều hướng; tên và logo thương hiệu vẫn ở trang đăng nhập. */
  .side-brand { display: none; }
  /* 4 mục chính + "Thêm ▾" thay cho thanh cuộn ngang 11 mục. */
  .nav { display: none; }
  .mnav { display: flex; flex: 1; min-width: 0; gap: 2px; }
  .mnav > a, .mnav > .nav-more { flex: 1 1 0; min-width: 0; }
  .strip { padding: 10px 16px; }
  .content { padding: 20px 16px; }
  .card { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  h1 { font-size: 21px; }
  .chat { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .chat.has-thread .chat-list, .chat:not(.has-thread) .chat-thread { display: none; }
  .chat-list { max-height: calc(100vh - 220px); }
  .chat-thread { height: calc(100vh - 240px); height: calc(100dvh - 240px); min-height: 400px; }
  .only-mobile { display: inline-flex; }
  .perm { grid-template-columns: minmax(0, 1fr); }
  .perm.has-sel .perm-list, .perm:not(.has-sel) .perm-edit { display: none; }
  .perm-list { position: static; max-height: none; }
  .save-bar { margin: 12px -16px -18px; padding-inline: 16px; }
  .radio-cards { grid-template-columns: minmax(0, 1fr); }
  .dm-row { flex-wrap: wrap; gap: 4px 10px; }
  .dm-who { flex: 1 1 100%; }
  .dm-row .bulk-check + .dm-who { flex-basis: calc(100% - 28px); }
  .dm-row .btn { margin-left: auto; }
  /* Vùng bấm tối thiểu 44px trên màn cảm ứng. */
  .btn, .btn-sm { min-height: 44px; }
  input, select { min-height: 44px; }
  .more-hint summary, .audit-tech summary { min-height: 44px; }
  .msg { max-width: 90%; }
  /* Bảng tìm và bảng Ảnh/Video · Tệp · Link phủ cả màn hình; nút trên đầu khung tin chỉ còn biểu tượng. */
  .side-panel { position: fixed; inset: 0; z-index: 50; width: auto; border: 0; border-radius: 0; padding: 12px 16px; }
  .head-tool-label { display: none; }
  .thread-head { gap: 6px; }
  .lightbox-stage { gap: 4px; padding: 0 4px 12px; }
  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-img { max-width: calc(100% - 96px); }

  /* Bảng → thẻ xếp chồng (vẫn là <table> cho trình đọc màn hình) */
  .table-cards { font-size: 15px; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tbody tr { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin-bottom: 12px; background: #fff; }
  .table-cards tbody tr:hover { background: #fff; }
  .table-cards td { white-space: normal; overflow-wrap: anywhere; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .table-cards tbody tr td:last-child, .table-cards tbody tr:last-child td:last-child { border-bottom: 0; }
  .table-cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .table-cards .actions { flex-wrap: wrap; justify-content: flex-start; }
  .table-cards .reset-row { background: #f8fafc; }
  .table-cards .reset-row td { padding: 8px 0; border-bottom: 0; }
}

/* Cửa sổ chi tiết (<dialog>, ui.js Dialog) — dùng ở Kho tri thức. */
.dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.dialog-wide { width: min(820px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { padding: 16px 18px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.icon-btn { min-width: 36px; justify-content: center; }
.stack > * + * { margin-top: 12px; }
.stack .field { margin-bottom: 0; }
.field > span:first-child, .field > legend { font-weight: 600; font-size: 14px; }
fieldset.field { border: 0; padding: 0; margin: 0; }
.input-suffix, .input-row { display: flex; gap: 8px; align-items: center; }
.input-suffix input, .input-row input { flex: 1 1 auto; min-width: 0; }
.doc-editor { width: 100%; min-height: 260px; resize: vertical; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; max-height: 260px; overflow: auto; padding: 4px 0; }
.check-grid .check { font-weight: 400; }
.kb-find { margin-top: 10px; }
.kb-find > summary { display: inline-flex; align-items: center; min-height: 36px; color: var(--brand); font-size: 14px; font-weight: 600; cursor: pointer; }
.kb-find[open] > input { width: 100%; margin: 6px 0; }
.kb-folder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.kb-folder-bar .folder-filter { flex: 0 1 auto; min-width: 0; }
.row-main small .fchip { margin-right: 6px; vertical-align: middle; max-width: 60%; }

/* Theo dõi agent gọn: chi tiết số liệu và từng lượt chỉ hiện khi bấm. */
.trace-meta { flex: 1 1 100%; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.trace-turn > summary { display: flex; gap: 8px; align-items: baseline; cursor: pointer; list-style: none; min-height: 32px; }
.trace-turn > summary::-webkit-details-marker { display: none; }
.trace-turn > summary::before { content: "▸"; color: var(--muted); flex: none; transition: transform .15s; }
.trace-turn[open] > summary::before { transform: rotate(90deg); }
.trace-q { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-turn[open] .trace-q { white-space: normal; overflow-wrap: anywhere; }
.trace-detail { padding: 4px 0 4px 18px; }

/* Theo dõi agent: cả dòng là nút mở/thu. */
.trace-chat { border-bottom: 1px solid var(--border); }
.trace-chat:last-child { border-bottom: 0; }
.trace-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 4px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.trace-row:hover { background: var(--bg); }
.trace-row:focus-visible { outline: none; box-shadow: var(--focus); }
.trace-caret { flex: none; color: var(--muted); transition: transform .15s; }
.trace-row[aria-expanded="true"] .trace-caret { transform: rotate(90deg); }
.trace-chat > .trace-box { margin: 0 0 10px; }

/* Nhật ký: tab "Có lỗi" không có lỗi; tab "Hoạt động AI" nhúng Theo dõi agent. */
.audit-clean { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 12px 14px; border: 1px solid var(--ok-border); border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.trace-embedded > .toolbar { margin-bottom: 4px; }

/* Lịch hẹn: lịch tuần kéo thả (7 cột; điện thoại xếp dọc theo ngày). */
.week-nav strong { min-width: 110px; text-align: center; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 8px 0 14px; }
.week-col { display: flex; flex-direction: column; gap: 6px; min-height: 140px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); transition: background .15s, border-color .15s; }
.week-col.is-today { border-color: var(--brand); }
.week-col.is-over { background: var(--brand-soft); border-color: var(--brand); border-style: dashed; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.week-empty { margin: 4px 0; text-align: center; }
.job-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 8px; background: var(--card); color: inherit; font: inherit; text-align: left; cursor: grab; overflow-wrap: anywhere; }
.job-card:hover { box-shadow: var(--shadow); }
.job-card:focus-visible { outline: none; box-shadow: var(--focus); }
.job-card:active { cursor: grabbing; }
.job-card.job-warn { border-left-color: var(--warn); opacity: .75; }
.job-card.job-danger { border-left-color: var(--danger); }
.job-card.job-idle { border-left-color: var(--muted); opacity: .6; }
.job-time { font-weight: 700; font-size: 13px; }
.job-name { font-size: 13px; line-height: 1.3; }
.time-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.time-item { display: inline-flex; align-items: center; gap: 2px; }
@media (max-width: 900px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-col { min-height: 0; }
}

/* Trí nhớ: thẻ người + bộ nhớ trợ lý dạng câu (bấm để sửa trong cửa sổ). */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 8px; }
.person-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: inherit; font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.person-card:hover { box-shadow: var(--shadow); border-color: var(--brand); }
.person-card:focus-visible { outline: none; box-shadow: var(--focus); }
.person-note { font-size: 14px; color: var(--text); }
.person-card .chips { gap: 4px; }
.mem-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.mem-place { grid-column: 1 / -1; margin-top: -4px; }
.mem-usage { width: 100%; height: 6px; margin: 2px 0 8px; accent-color: var(--brand); }
.mem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mem-line { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: inherit; font: inherit; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; }
.mem-line:hover { border-color: var(--brand); }
.mem-line:focus-visible { outline: none; box-shadow: var(--focus); }

.job-card.is-busy { cursor: progress; opacity: .6; }
/* Màn cảm ứng không kéo thả được: bỏ câu hướng dẫn kéo, mọi việc làm qua cửa sổ sửa. */
@media (hover: none) { .drag-hint { display: none; } }

/* Lịch hẹn › Luồng: mỗi lịch hẹn một làn node Khi nào → Bot làm gì → Gửi vào; bảng nhóm để kéo vào. */
.flow-board { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; align-items: start; }
.flow-board.is-busy { cursor: progress; }
.flow-lanes { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.flow-lane { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1.3fr) 28px minmax(0, 1.2fr); align-items: center; padding: 10px; border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: var(--radius); background: var(--bg); }
.flow-lane.lane-warn { border-left-color: var(--warn); }
.flow-lane.lane-danger { border-left-color: var(--danger); }
.flow-lane.lane-idle { border-left-color: var(--muted); opacity: .7; }
.flow-node { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: inherit; font: inherit; font-size: 13px; text-align: left; overflow-wrap: anywhere; box-shadow: var(--shadow); }
button.flow-node { cursor: pointer; }
button.flow-node:hover { border-color: var(--brand); }
.flow-node:focus-visible { outline: none; box-shadow: var(--focus); }
.flow-node small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.node-head { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.node-when { border-top: 3px solid #6366f1; }
.node-do { border-top: 3px solid var(--brand); }
.flow-edge { position: relative; height: 2px; background: var(--muted); margin: 0 2px; }
.flow-edge::after { content: ""; position: absolute; right: -2px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--muted); border-right: 0; }
.flow-targets { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 6px; border: 1px dashed transparent; border-radius: 10px; transition: background .15s, border-color .15s; }
.flow-targets.is-over { background: var(--brand-soft); border-color: var(--brand); }
.node-to { flex-direction: row; align-items: center; justify-content: space-between; border-top: 3px solid #f59e0b; cursor: grab; }
.node-to[draggable="false"] { cursor: default; }
.flow-add { font-size: 13px; min-height: 34px; }
.tag-x { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; margin-left: 4px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.tag-x:hover { color: var(--danger); background: var(--danger-soft); }
.target-tag { display: inline-flex; align-items: center; }
.flow-palette { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); max-height: 70vh; overflow: auto; }
.flow-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.flow-chip { cursor: grab; user-select: none; }
@media (max-width: 900px) {
  .flow-board { grid-template-columns: 1fr; }
  .flow-palette { display: none; }
  .flow-lane { grid-template-columns: 1fr; gap: 0; }
  .flow-edge { width: 2px; height: 16px; margin: 0 auto; }
  .flow-edge::after { right: -4px; top: auto; bottom: -2px; border: 5px solid transparent; border-top: 7px solid var(--muted); border-bottom: 0; }
}

/* Khoá API & Model: thẻ theo chức năng, kết quả Thử/Kiểm tra. */
.ai-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.ai-card { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.ai-card h3 { margin: 0; font-size: 14px; color: var(--muted); }
.ai-card .field { margin: 6px 0 0; }
.ai-model { margin: 0; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.ai-result { margin: 4px 0 0; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.ai-result.is-ok { background: var(--ok-soft); color: var(--ok); }
.ai-result.is-bad { background: var(--danger-soft); color: var(--danger); }
.row-full { flex: 1 1 100%; }

/* Khoá API: danh sách khoá dự phòng của một dịch vụ. */
.key-pool { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.key-entry { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.key-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.key-err { flex: 1 1 100%; }
.key-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.key-events { margin: 0; padding-left: 18px; }

/* Skill */
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skill-md { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 55vh; overflow-y: auto; font-family: var(--mono); font-size: 13px; background: var(--bg, #f8fafc); padding: 12px; border-radius: 8px; margin: 0; }
.card-sub { padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }
.card-sub h3 { margin: 0 0 4px; }

/* Kết nối MCP */
.mcp-cat-form { flex: 1 1 100%; padding: 10px 0 4px; }

/* Ủng hộ tác giả */
.donate { text-align: center; }
.donate-qr { display: block; margin-left: auto; margin-right: auto; width: 240px; height: 240px; max-width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.donate-info { display: inline-grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; text-align: left; }
.donate-info dt { color: var(--muted); }
.donate-info dd { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* Ủng hộ tác giả */
.donate { text-align: center; }
.donate-qr { display: block; margin-left: auto; margin-right: auto; width: 240px; height: 240px; max-width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.donate-info { display: inline-grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; text-align: left; }
.donate-info dt { color: var(--muted); }
.donate-info dd { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.strip-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.donate-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 14px; border: 0; border-radius: 999px;
  background: #fff; color: #be123c; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18); transition: transform .15s ease, box-shadow .15s ease;
}
.donate-pill svg { color: #e11d48; fill: #e11d48; }
.donate-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(15, 23, 42, .25); }
.donate-pill:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.strip .dialog { font-weight: 400; font-size: 15px; }
@media (prefers-reduced-motion: reduce) { .donate-pill { transition: none; } .donate-pill:hover { transform: none; } }
/* Cộng đồng 2Anh: viên thuốc xanh Zalo cạnh nút Ủng hộ, mở nhóm Zalo trong tab mới. */
.community-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 14px; border-radius: 999px;
  background: #0068ff; color: #fff; font-size: 14px; font-weight: 700; text-decoration: none;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18); transition: transform .15s ease, box-shadow .15s ease;
}
.community-pill .icon { color: #fff; }
.community-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(15, 23, 42, .25); }
.community-pill:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .community-pill { transition: none; } .community-pill:hover { transform: none; } }
.community-links { border-top: 1px solid var(--border); padding-top: 10px; }
.community-links ul { margin: 6px 0 0; padding-left: 18px; }
.community-links li { margin: 4px 0; }
.update-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .18); color: inherit; border: 1px solid rgba(255, 255, 255, .55);
  font-size: 14px; font-weight: 700; text-decoration: none;
}
a.update-pill:hover { background: rgba(255, 255, 255, .3); }
.strip-warn .update-pill, .strip-idle .update-pill { border-color: currentColor; background: transparent; }

/* ---------- Điện thoại: thanh điều hướng dưới, khung chat toàn màn hình, gọn chỗ (2026-10) ---------- */
@media (max-width: 760px) {
  :root { --mnav-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); }
  /* Thanh điều hướng cố định dưới đáy, trong tầm ngón cái; chừa vùng an toàn của máy có "tai thỏ"/thanh home. */
  .sidebar {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 4px 6px calc(4px + var(--safe-b)); border-bottom: 0; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
  }
  .layout { grid-template-rows: 1fr; }
  .main-col { padding-bottom: calc(var(--mnav-h) + var(--safe-b)); }
  .mnav-item { min-height: 52px; font-size: 12px; }
  /* "Thêm" mở thành tấm trượt từ dưới lên, các mục xếp 2 cột cho dễ bấm. */
  .nav-more-menu {
    position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(var(--mnav-h) + var(--safe-b) + 6px);
    max-height: min(70vh, calc(100dvh - var(--mnav-h) - 80px)); min-width: 0; padding: 10px;
    border-radius: 16px; box-shadow: 0 -10px 40px rgba(15, 23, 42, .22);
  }
  .nav-more-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .nav-more-group > .nav-label { grid-column: 1 / -1; }
  .nav-more-menu .nav-item { min-height: 48px; white-space: normal; line-height: 1.25; font-size: 14px; }
  /* Nền mờ phía sau tấm "Thêm" (bóng đổ, không chặn chạm: bấm ra ngoài vẫn đóng như cũ). */
  .nav-more[open] > .nav-more-menu { box-shadow: 0 -10px 40px rgba(15, 23, 42, .22), 0 0 0 100vmax rgba(15, 23, 42, .38); }

  /* Thanh trạng thái: một dòng gọn, nút ngắn bên phải. */
  .strip { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; font-size: 13.5px; line-height: 1.35; }
  .strip-text { flex: 1 1 auto; min-width: 0; }
  .strip-actions { flex: none; flex-wrap: nowrap; gap: 6px; }
  .strip .btn-light { padding-inline: 10px; }
  .donate-pill, .update-pill { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .donate-more { display: none; }
  .community-pill { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .community-more { display: none; }
  .update-pill .update-more { display: none; }

  /* Gọn lề: nhiều chỗ hơn cho nội dung. */
  .content { padding: 14px 12px 20px; }
  .card { padding: 16px 14px; border-radius: 14px; }
  .card-sub { padding: 12px; }
  .page-head { margin-bottom: 14px; }
  .page-head p { font-size: 14px; }
  .crumbs ol { margin-bottom: 2px; }
  .save-bar { margin: 12px -14px -16px; padding-inline: 14px; }

  /* Phiên chat: danh sách tràn ngang; mở một hội thoại thì khung tin chiếm trọn màn hình (ẩn tiêu đề trang). */
  .chat > .card { border-radius: 12px; }
  .content:has(.chat.has-thread) { padding: 0; }
  .content:has(.chat.has-thread) > .crumbs, .content:has(.chat.has-thread) > .page-head { display: none; }
  .chat.has-thread .chat-thread {
    height: calc(100dvh - var(--mnav-h) - var(--safe-b) - 54px); min-height: 360px;
    padding: 8px 10px 10px; border: 0; border-radius: 0; box-shadow: none;
  }
  .chat-list { max-height: none; }
  .thread-head { padding-bottom: 8px; }
  .thread-head > h2, .thread-name > h2 { font-size: 16px; }
  .msgs { padding: 10px 0; }
  .msg { max-width: 88%; }
  /* Ô soạn: hàng nút công cụ gọn, ô chữ + nút Gửi trên một hàng như app nhắn tin. */
  .compose { padding-top: 4px; }
  .compose-help { display: none; }
  .compose-row textarea { max-height: 30vh; resize: none; }
  .ctool { min-width: 44px; height: 44px; }
}

/* Hàng tab (chips) đứng đầu thẻ: cách khối nội dung bên dưới. */
.card > .chips + * { margin-top: 12px; }

/* Phiên chat: trả lời / nhắc tên / chép từng tin; thanh "Đang trả lời"; gợi ý @ thành viên */
.msg-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msg-self .msg-row { flex-direction: row-reverse; }
.msg-row > .msg-bubble { min-width: 0; }
.msg-actions { display: none; flex: none; gap: 4px; }
.msg:focus-within .msg-actions, .msg-active .msg-actions { display: inline-flex; }
/* Rê chuột chỉ trên máy có chuột thật — điện thoại giữ trạng thái hover sau khi chạm, sẽ làm nút chớp tắt. */
@media (hover: hover) { .msg:hover .msg-actions { display: inline-flex; } }
.msg-act {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; min-width: 32px; justify-content: center; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.msg-act:hover { color: var(--brand-dark); border-color: var(--brand); }
.msg-act:focus-visible { outline: none; box-shadow: var(--focus); }
.msg-act > span:last-child:not([aria-hidden]) { display: none; }
.msg-active .msg-bubble { box-shadow: 0 0 0 2px var(--brand); }
.reply-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 6px 6px 10px; border-left: 3px solid var(--brand); border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); }
.reply-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-list { list-style: none; margin: 0 0 8px; padding: 4px; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 6px 20px rgba(15, 23, 42, .1); }
.mention-item { display: block; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--text); }
.mention-item:hover, .mention-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.mention-empty { padding: 8px 10px; }
@media (max-width: 760px) {
  /* Điện thoại: bấm giữ tin → hàng nút có chữ, đủ to để chạm; bỏ menu chọn chữ của hệ điều hành (đã có nút Chép). */
  .msg-row { flex-wrap: wrap; }
  .msg-active .msg-actions { flex-basis: 100%; justify-content: flex-start; margin-top: 4px; }
  .msg-self.msg-active .msg-actions { justify-content: flex-end; }
  .msg-act { min-height: 40px; padding: 6px 12px; }
  .msg-act > span:last-child:not([aria-hidden]) { display: inline; }
  .msg-bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .attach-name { max-width: 150px; }
}
.msg-act-danger:hover { color: var(--danger); border-color: var(--danger); }

/* ===================== Giao diện kiểu macOS (v2.10): màu theo mục, ô biểu tượng màu, thẻ nền xám ===================== */
:root {
  --bg: #ffffff;
  --panel: #f4f4f6;
  --side-bg: #f6f6f8;
  --radius: 18px;
}
.tint-blue { --tint: #0b6bcb; }
.tint-green { --tint: #1a8a3d; }
.tint-red { --tint: #d63045; }
.tint-orange { --tint: #c2570c; }
.tint-yellow { --tint: #a66b00; }
.tint-teal { --tint: #0f766e; }
.tint-cyan { --tint: #0e7490; }
.tint-purple { --tint: #7c3aed; }
.tint-pink { --tint: #c2185b; }
.tint-indigo { --tint: #4f46e5; }
.tint-brown { --tint: #92400e; }
.tint-gray { --tint: #5b6574; }

/* Thanh bên: nền xám nhạt, mỗi mục một ô biểu tượng màu, mục đang mở tô màu thương hiệu. */
.sidebar { background: var(--side-bg); }
.layout { background: linear-gradient(90deg, var(--side-bg) 239px, var(--border) 239px 240px, var(--bg) 240px); }
.nav-ico {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: 7px; background: var(--tint, var(--muted)); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 1px 2px rgba(15, 23, 42, .12);
}
.nav-ico .icon { color: #fff; }
.nav-item { gap: 10px; padding: 7px 8px; }
.nav-item > span:not(.nav-ico):not(.nav-val):not(.avatar) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: rgba(15, 23, 42, .05); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item.active .nav-ico { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45); }
.nav-item.active .icon { color: #fff; }
.nav-val { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-val { color: rgba(255, 255, 255, .85); }

/* Thẻ: nền xám, không viền, bo góc lớn; phần tử bên trong (ô nhập, thẻ con) vẫn trắng để nổi lên. */
.card { background: var(--panel); border-color: transparent; box-shadow: none; border-radius: var(--radius); }
.card .card, .card-sub { background: var(--card); }
.card-sub { border-style: solid; border-color: transparent; }
/* Tiêu đề thẻ mang màu của mục đang mở. */
.content[class*="tint-"] .card > h2, .content[class*="tint-"] .card-sub > h3, .content[class*="tint-"] .mem-block > h3 { color: var(--tint); }

/* Thẻ số liệu (Tổng quan): ô biểu tượng + tiêu đề màu, nhãn nhỏ, số lớn, 3 chỉ số phụ, biểu đồ chấm. */
.metric { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
a.metric:hover { color: inherit; background: #eeeef1; }
.metric-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.metric-head .nav-ico { width: 30px; height: 30px; border-radius: 8px; }
.metric-title { flex: 1; font-size: 17px; font-weight: 700; color: var(--tint); }
.metric-go { color: var(--muted); }
.metric-label { font-size: 14px; color: var(--muted); }
.metric-big { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 40px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-big small { font-size: 18px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.metric-big.is-text { font-size: 24px; letter-spacing: -.01em; }
.metric-pill { margin-left: auto; align-self: center; display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.metric-pill.is-warn { background: #fdecc8; color: #8a5300; }
.metric-pill.is-danger { background: #fde2e4; color: #b4232f; }
.metric-pill.is-ok { background: #dcf3e3; color: #156b33; }
.metric-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 4px; }
.metric-facts dt { font-size: 13px; color: var(--muted); }
.metric-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dots {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: repeat(4, 6px); gap: 4px 2px; justify-items: center; overflow: hidden;
  margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--tint) 9%, #fff);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--tint) 22%, #fff); }
.dot.on { background: var(--tint); }
.bars { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.bar-top span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top span:last-child { flex: none; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; margin-top: 6px; border-radius: 999px; background: color-mix(in srgb, var(--tint) 18%, #fff); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--tint); }
.bar-w-0 { width: 0; } .bar-w-1 { width: 10%; } .bar-w-2 { width: 20%; } .bar-w-3 { width: 30%; } .bar-w-4 { width: 40%; } .bar-w-5 { width: 50%; }
.bar-w-6 { width: 60%; } .bar-w-7 { width: 70%; } .bar-w-8 { width: 80%; } .bar-w-9 { width: 90%; } .bar-w-10 { width: 100%; }
@media (max-width: 760px) {
  .layout { background: var(--bg); }
  .metric-big { font-size: 34px; }
  .metric-facts { gap: 6px; }
  .dots { grid-template-rows: repeat(4, 5px); gap: 3px; padding: 10px; }
  .dot { width: 5px; height: 5px; }
}

/* Cách gọi bot: từ khoá dạng thẻ có nút xoá */
.word-chips { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.word-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-weight: 600; }
.word-x { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.word-x:hover { background: var(--danger-soft); color: var(--danger); }
.word-x:focus-visible { outline: none; box-shadow: var(--focus); }
.word-add { display: flex; flex-wrap: wrap; gap: 8px; }
.word-add input { flex: 1 1 200px; min-width: 0; }
@media (max-width: 760px) { .word-x { width: 34px; height: 34px; } .word-chip { font-size: 14px; } }

/* Bảng Quyền trong Phiên chat: một cột, thanh Lưu dính đáy bảng (không tràn lề như trong thẻ của tab Phân quyền). */
.perms-panel .perm-grid { grid-template-columns: minmax(0, 1fr); }
.perms-panel .save-bar { margin: 12px 0 0; padding: 10px 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); border-radius: 0; box-shadow: none; }
.perms-more { margin: 14px 0 4px; }
/* Bảng Quyền nổi đè lên khung tin (không đẩy khung tin hẹp lại — tên nhóm dài bị dọc từng chữ). */
@media (min-width: 1200px) { .chat-thread:has(> .perms-panel) > :not(.side-panel) { margin-right: 0; } .perms-panel { width: min(400px, 100%); } }
/* Nút Quyền: ô khiên cùng màu mục Phân quyền Bot ở thanh bên; đang mở thì nền nhạt cùng màu. */
.perms-ico { width: 22px; height: 22px; border-radius: 6px; }
.thread-head .head-perms { gap: 6px; }
.thread-head .head-perms.active { background: color-mix(in srgb, var(--tint) 12%, transparent); color: var(--tint); }
.perms-title { display: inline-flex; align-items: center; gap: 8px; }

/* Thư mục nhóm (Phân quyền Bot): tiêu đề mục trong danh sách, nhãn thư mục của nhóm, danh sách chọn nhóm. */
.conv-list > .folder-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 4px 4px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.conv-list > .folder-empty { padding: 4px 8px 8px; }
.conv-folder .conv-name { display: inline-flex; align-items: center; gap: 6px; }
.folder-tag { display: inline-flex; align-items: center; gap: 3px; color: var(--brand-dark); font-weight: 600; }
.folder-members { list-style: none; margin: 8px 0; padding: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.folder-members li + li { border-top: 1px solid var(--border); }
.folder-members label { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 9px 12px; cursor: pointer; min-height: 44px; text-align: left; }
.folder-members input[type="checkbox"] { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.folder-members label > span { flex: 1; min-width: 0; }
.folder-members label:hover { background: var(--bg); }
.folder-edit .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.folder-edit .thread-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.folder-settings-head { margin: 16px 0 4px; font-size: 15px; }
.folder-edit details > summary + p { margin-top: 10px; }
.mem-use { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; margin: 2px 0 6px; }
.mem-use select { flex: 1; min-width: 0; max-width: 360px; }

/* Cấu hình › Phong cách trả lời: chọn màu chữ (màu khớp thẻ màu Zalo). */
.rs-label { font-weight: 600; font-size: 14px; }
.rs-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.field .rs-color { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; cursor: pointer; }
.rs-color::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.rs-red { color: #db342e; } .rs-green { color: #15a85f; } .rs-orange { color: #f27806; } .rs-yellow { color: #b88600; }
.rs-color input { margin: 0; }

/* Trí nhớ › Bộ nhớ của trợ lý: thẻ loại "[Loại] …". */
.mtag { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6; vertical-align: 1px; white-space: nowrap; background: #f1f5f9; color: #475569; }
.mtag-blue { background: #dbeafe; color: #1e40af; } .mtag-indigo { background: #e0e7ff; color: #3730a3; }
.mtag-green { background: #dcfce7; color: #166534; } .mtag-teal { background: #ccfbf1; color: #115e59; }
.mtag-pink { background: #fce7f3; color: #9d174d; } .mtag-orange { background: #ffedd5; color: #9a3412; }
.mtag-purple { background: #f3e8ff; color: #6b21a8; } .mtag-red { background: #fee2e2; color: #991b1b; }
.mtag-gray { background: #f1f5f9; color: #475569; } .mtag-none { background: transparent; color: var(--muted); border: 1px dashed var(--border); }
.mtag-filter { margin: 4px 0 12px; }
.chip.mtag-chip[aria-pressed="true"] { border-color: currentColor; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mem-line-static { cursor: default; }
.mem-list-plain { gap: 4px; }
.mem-list-plain .mem-line { padding: 6px 10px; font-size: 14px; }
.organize-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.organize-cols h4 { margin: 0 0 6px; }
.organize-log .row-main { min-width: 0; }
.mtag-edit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mtag-edit li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mtag-edit input { flex: 1 1 160px; min-width: 0; }
.mtag-edit select { flex: 0 1 140px; }
.mtag-edit .mtag { min-width: 90px; text-align: center; }

/* Phân quyền Bot › Thư mục › Người trong thư mục. */
.folder-people { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.folder-people li { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }

/* Thư mục có màu (Phân quyền Bot, Phiên chat). Nền/chữ dùng lại .mtag-<màu>. */
.fdot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; }
.fdot-blue { background: #2563eb; } .fdot-green { background: #16a34a; } .fdot-orange { background: #ea580c; }
.fdot-purple { background: #9333ea; } .fdot-pink { background: #db2777; } .fdot-teal { background: #0d9488; }
.fdot-red { background: #dc2626; } .fdot-indigo { background: #4f46e5; } .fdot-gray { background: #64748b; }
.fchip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-weight: 700; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fchip-sm { font-size: 11.5px; line-height: 1.6; }
.folder-filter { margin: 8px 0; }
.fchip-btn { display: inline-flex; align-items: center; gap: 6px; }
.fchip-btn[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: -2px; }
.folder-colors { gap: 8px; }
.color-swatch { width: 32px; height: 32px; min-width: 32px; border-radius: 50%; border: 2px solid transparent; color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.color-swatch.on { border-color: var(--text, #0f172a); }
.color-swatch:focus-visible { outline: none; box-shadow: var(--focus); }
.conv-folder .conv-name .fdot { margin-right: 2px; }
.conv-sub .fchip { flex: none; max-width: 55%; margin-right: 6px; }
.fchip-btn.mtag-blue, .fchip-btn.mtag-green, .fchip-btn.mtag-orange, .fchip-btn.mtag-purple, .fchip-btn.mtag-pink,
.fchip-btn.mtag-teal, .fchip-btn.mtag-red, .fchip-btn.mtag-indigo, .fchip-btn.mtag-gray { border-color: transparent; }

/* Phiên chat: số tin hôm nay của hội thoại + dòng thống kê đầu khung tin. */
.conv-count { flex: none; min-width: 20px; padding: 0 6px; margin-left: auto; margin-right: 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; }
/* Đầu khung tin hai hàng: tên (+ nhãn "Nhóm") một hàng riêng; dưới là thống kê bên trái, nút công cụ bên phải. */
.thread-head-stack { flex-direction: column; align-items: stretch; gap: 4px; }
.thread-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread-name > h2 { margin: 0; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-name > .btn, .thread-name > .tag { flex: none; white-space: nowrap; }
.thread-bar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.thread-stats { flex: 1 1 0; min-width: 0; margin: 0; }
/* Khung tin hẹp (màn nhỏ, hoặc đang mở bảng bên) → nút chỉ còn biểu tượng để dòng thống kê đủ chỗ. */
.chat-thread { container-type: inline-size; }
@container (max-width: 620px) { .thread-bar .head-tool-label { display: none; } }
.rs-toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.rs-toggle input { margin-top: 4px; width: 18px; height: 18px; flex: none; }

/* Agent › Tính cách: chọn mẫu vai trò. */
.soul-group { border: 0; padding: 0; margin: 0 0 12px; }
.soul-group legend { font-weight: 700; font-size: 14px; margin-bottom: 6px; padding: 0; }
.soul-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.soul-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); cursor: pointer; }
.soul-card input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.soul-card span { display: flex; flex-direction: column; gap: 2px; }
.soul-card.on { border-color: var(--brand); background: var(--brand-soft); }
.soul-advanced > summary { cursor: pointer; list-style: revert; }
.soul-advanced h2.inline { display: inline; font-size: 16px; }

/* Tổng quan (v2.28): dải tình trạng · Cần chú ý · hội thoại hôm nay · lịch sắp chạy · AI hôm nay · lối tắt. */
.ov-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ov-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: inherit; text-decoration: none; }
.ov-pill.is-ok { color: var(--ok); } .ov-pill.is-warn { color: var(--warn); background: var(--warn-soft); } .ov-pill.is-danger { color: var(--danger); background: var(--danger-soft); }
.ov-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ov-head h2 { margin: 0; font-size: 17px; flex: 1; }
.ov-more { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.ov-attention { margin-bottom: 14px; }
.ov-attention.is-ok { border-color: var(--ok); }
.ov-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ov-items > li { padding: 10px 12px; border-radius: 10px; background: var(--bg, #f8fafc); border-left: 4px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.ov-items > li.is-danger { border-left-color: var(--danger); } .ov-items > li.is-warn { border-left-color: var(--warn); } .ov-items > li.is-info { border-left-color: var(--brand); }
.ov-items a { color: inherit; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.ov-items button { align-self: flex-start; }
.ov-requests { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ov-requests li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ov-req-name { flex: 1 1 160px; display: flex; flex-direction: column; min-width: 0; }
.ov-grid { align-items: start; }
.ov-chats, .ov-jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ov-chat { width: 100%; text-align: left; border: 0; background: none; padding: 8px 6px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; color: inherit; font: inherit; }
.ov-chat:hover { background: var(--brand-soft); }
.ov-chat-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ov-chat-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-chat-top time { font-size: 12px; color: var(--muted); }
.ov-chat-sub { display: flex; gap: 6px; }
.ov-jobs li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.ov-jobs li:last-child { border-bottom: 0; }
.ov-jobs time { flex: none; width: 112px; font-weight: 700; font-size: 13px; }
.ov-jobs span { display: flex; flex-direction: column; min-width: 0; }
.ov-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; }
.ov-facts div { display: flex; flex-direction: column; }
.ov-facts dt { font-size: 12px; color: var(--muted); }
.ov-facts dd { margin: 0; font-size: 20px; font-weight: 800; }
.ov-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ov-q { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; color: inherit; text-decoration: none; font-weight: 600; min-height: 44px; }
.ov-q:hover { border-color: var(--brand); }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ov-side { display: flex; flex-direction: column; gap: 16px; }
.ov-side .card, .ov-grid > .card { margin: 0; }
.ov-facts dd.ov-small { font-size: 15px; white-space: nowrap; }
.ov-grid > .ov-uses-card { grid-column: 1 / -1; }
/* Cấu hình trên PC rộng: các nhóm cài đặt chia 2 cột thay vì ô nhập kéo dài hết màn hình. */
@media (min-width: 1400px) {
  .settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .settings-form > .mem-block { min-width: 0; margin: 0; }
  .settings-form > :not(.mem-block) { grid-column: 1 / -1; }
}
/* PC rộng: Hội thoại · (Lịch hẹn, AI, Lối tắt) · Khách dùng bot thành 3 cột. */
@media (min-width: 1500px) {
  .ov-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.15fr); }
  .ov-grid > .ov-uses-card { grid-column: auto; }
  .ov-uses-card .ov-boards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }

/* Tạo ảnh & video (Khoá API & Model). */
.media-key { padding: 12px 14px; margin: 4px 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--brand-soft); }
.media-key h3 { margin: 0 0 4px; }
.media-key p { margin: 6px 0 0; }
.media-key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.media-engines .key-main { flex: 1 1 260px; }
.media-note { flex: 1 1 100%; }
.media-switch { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 13.5px; cursor: pointer; }
.media-switch input { width: 18px; height: 18px; }
.media-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.media-edit input { flex: 1 1 220px; min-width: 0; }
.media-preview { display: block; width: 160px; max-width: 100%; margin-top: 6px; border-radius: 10px; border: 1px solid var(--border); }
.gen-video { display: flex; flex-direction: column; gap: 10px; }
.gen-video-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.gen-video-row .field { flex: 1 1 200px; margin: 0; }
.media-engines + h3, .gen-video + p { margin-top: 18px; }
.media-key + h3 { margin-top: 6px; }

/* Chọn nhiều cùng lúc (người vào thư mục, danh sách nhắn riêng, hạn mức xưởng; nhóm vào thư mục). */
.multi-pick { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.multi-pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.multi-pick-bar input { flex: 1 1 220px; min-width: 0; }
.multi-pick-list { list-style: none; margin: 0; padding: 4px 8px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.multi-pick-list li { padding: 2px 0; }
.multi-pick-item { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.multi-pick-item input { width: 18px; height: 18px; flex: none; }
.multi-pick > .btn { align-self: flex-start; }
.multi-pick-head { margin: 10px 0 0; font-size: 14px; }
.bulk-bar { margin: 4px 0 8px; }
.bulk-bar > .muted { flex: 1 1 auto; }
.bulk-check { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.conv-pick { flex-direction: row; align-items: flex-start; gap: 10px; }
.conv-pick > input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 3px 0 0; padding: 0; accent-color: var(--brand); }
.conv-pick-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bulk-choice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.bulk-choice select { flex: none; width: auto; min-width: 120px; }
.bulk-panel { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.bulk-panel .row { flex-wrap: wrap; }
.bulk-progress { margin: 6px 0; }
.welcome-row { display: flex; align-items: flex-start; gap: 10px; }
.welcome-row > .bulk-check { margin-top: 16px; }
.welcome-row > details { flex: 1; min-width: 0; }
.bulk-bar .bulk-select { flex: none; width: auto; min-width: 140px; }
.mem-pick { display: flex; align-items: flex-start; gap: 10px; }
.mem-pick > .bulk-check { margin-top: 12px; }
.mem-pick > .mem-line { flex: 1; min-width: 0; }
.row-item > .bulk-check { align-self: center; }
.person-card[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.pick-mark { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 8px; border: 1.5px solid var(--border); border-radius: 4px; font-size: 13px; line-height: 1; vertical-align: -3px; }
.person-card[aria-pressed="true"] .pick-mark { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Tổng quan › Khách dùng bot. */
.ov-uses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ov-boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 10px; }
.ov-board h3 { margin: 0 0 6px; font-size: 14px; }
.ov-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ov-rank-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.ov-rank-row:hover:not(:disabled) { background: var(--brand-soft); }
.ov-rank-row:disabled { cursor: default; }
.ov-rank-no { flex: none; width: 22px; text-align: center; font-weight: 700; color: var(--muted); }
.ov-rank-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ov-rank-who strong, .ov-rank-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Phiên chat kiểu Zalo (v2.41) ===================== */
.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700;
  line-height: 1; overflow: hidden; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.av-sm { width: 36px; height: 36px; font-size: 15px; }
.av-md { width: 44px; height: 44px; font-size: 18px; }
.av-lg { width: 64px; height: 64px; font-size: 26px; }
.av-0 { background: #2563eb; }
.av-1 { background: #0d9488; }
.av-2 { background: #7c3aed; }
.av-3 { background: #db2777; }
.av-4 { background: #ea580c; }
.av-5 { background: #16a34a; }
.av-6 { background: #0891b2; }
.av-7 { background: #9333ea; }
.av-8 { background: #dc2626; }
.av-9 { background: #ca8a04; }
/* Danh sách hội thoại: ảnh đại diện + 2 dòng. */
.conv.conv-ava { flex-direction: row; align-items: center; gap: 10px; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* Đầu khung chat: ảnh, tên, dòng phụ, nút Tìm · Quyền · Thông tin. */
.chat-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-main h2 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-sub { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-tools { flex: none; display: flex; gap: 2px; }
.chat-head .head-tool { flex: none; min-width: 38px; color: var(--muted); }
.chat-head .head-tool.active { background: var(--brand-soft); color: var(--brand-dark); }
.chat-head .head-perms.active { background: color-mix(in srgb, var(--tint) 12%, transparent); color: var(--tint); }
.chat-back { flex: none; }
/* Khung tin: nền nhạt, tin gộp theo người gửi, dải ngày ở giữa. */
.msgs { gap: 3px; padding: 12px; margin-top: 8px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 5%, var(--card)); }
.msg-lead { margin-top: 10px; }
.msg-ava { flex-direction: row; align-items: flex-start; gap: 8px; }
.msg-ava-slot { flex: none; width: 36px; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; max-width: 100%; }
.msg-self .msg-body { align-items: flex-end; }
.msg-bubble { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 7px 12px 5px; }
.msg-self .msg-bubble { background: var(--brand-soft); color: var(--text); border-color: color-mix(in srgb, var(--brand) 25%, transparent); border-radius: 12px; }
.msg-self .msg-bubble a { color: var(--brand-dark); }
.msg-bubble .msg-from { display: block; margin-bottom: 2px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.msg-bubble .msg-time { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.msg-media .msg-from, .msg-media .msg-time { padding: 0 6px; }
.msg-day { align-self: center; margin: 14px 0 4px; }
.msg-day > span { display: inline-block; padding: 2px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); }
/* Ô soạn: hàng nút công cụ phía trên, ô chữ + Gửi một hàng. */
.compose { padding-top: 6px; }
.compose-tools { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; min-width: 0; }
.ctool { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 6px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; }
.ctool:hover { background: var(--brand-soft); color: var(--brand-dark); }
.ctool:focus-visible { outline: none; box-shadow: var(--focus); }
.ctool:disabled { opacity: .5; cursor: default; }
.compose-help { flex: 1; min-width: 0; margin-left: 8px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-row { display: flex; align-items: flex-end; gap: 8px; }
.compose-row > textarea { flex: 1; min-width: 0; min-height: 44px; margin: 0; resize: vertical; }
.compose-row > .send-btn { flex: none; min-height: 44px; }
/* Bảng Thông tin hội thoại (cột phải). */
.info-panel .side-body { margin: 0 -16px; padding: 0 16px; }
.info-id { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0 12px; text-align: center; }
.info-name { font-size: 16px; overflow-wrap: anywhere; }
.info-stats { max-width: 100%; }
.info-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0 -16px; padding: 0 16px 12px; border-bottom: 6px solid var(--bg); }
.info-act { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border: 0; border-radius: 8px; background: none;
  color: var(--text); font: inherit; font-size: 12.5px; text-align: center; cursor: pointer; }
.info-act:hover { background: var(--brand-soft); }
.info-act:focus-visible { outline: none; box-shadow: var(--focus); }
.info-act-ico { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); }
.info-sec { margin: 0 -16px; padding: 2px 16px 10px; border-bottom: 6px solid var(--bg); }
.info-sec:last-child { border-bottom: 0; }
.info-sec-head { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 42px; padding: 0; border: 0; background: none;
  color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.info-sec-head:focus-visible { outline: none; box-shadow: var(--focus); }
.info-caret { display: inline-flex; transition: transform .15s; }
.info-caret.open { transform: rotate(90deg); }
.info-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.info-all { width: 100%; margin-top: 8px; justify-content: center; }
.info-panel .media-row { padding: 6px 0; }
@media (max-width: 760px) {
  .chat-head { gap: 8px; padding-bottom: 8px; }
  .chat-head .av-md { width: 36px; height: 36px; font-size: 15px; }
  .chat-head-main h2 { font-size: 16px; }
  .msgs { padding: 10px 8px; }
  .msg-ava-slot { width: 30px; }
  .msg-ava-slot .av-sm { width: 30px; height: 30px; font-size: 13px; }
}
/* Bước 2: tin ghim, bảng tin, mô tả nhóm. */
.chat-head-sub .icon { vertical-align: -2px; }
.pin-bar { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.pin-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 2px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pin-main:disabled { cursor: default; }
.pin-main:focus-visible, .pin-row:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.pin-ico { flex: none; display: inline-flex; color: var(--brand-dark); }
.pin-text { min-width: 0; display: flex; flex-direction: column; }
.pin-text > strong { font-size: 13px; }
.pin-text > span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-more { flex: none; }
.pin-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 6; list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 10px 28px rgba(15, 23, 42, .14); }
.pin-row { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pin-row:hover:not(:disabled) { background: var(--brand-soft); }
.pin-row:disabled { cursor: default; opacity: .75; }
.info-desc { max-width: 100%; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.board-item { display: flex; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; }
button.board-item { cursor: pointer; }
button.board-item:hover:not(:disabled) { background: var(--brand-soft); }
button.board-item:disabled { cursor: default; }
.board-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--bg); color: var(--brand-dark); }
.board-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.board-text { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.poll-opts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.poll-opts li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 6px; border-radius: 6px; background: var(--bg); }
.board-rows { list-style: none; margin: 0; padding: 0; }
.board-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 6px; border: 0; border-radius: 8px; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.board-row:hover:not(:disabled) { background: var(--brand-soft); }
.board-row:disabled { cursor: default; }
.board-row:focus-visible, .board-item:focus-visible { outline: none; box-shadow: var(--focus); }
.board-label { flex: 1; min-width: 0; }
.board-rows .board-list { margin: 2px 0 8px 40px; }
/* Bước 3: ghim hội thoại, nhắc hẹn. */
.info-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.info-act.is-on .info-act-ico { background: var(--brand-soft); color: var(--brand-dark); }
.info-act:disabled { opacity: .55; cursor: default; }
.conv-pin { flex: none; display: inline-flex; color: var(--muted); margin-left: 4px; }
/* Liên hệ: chọn thư mục khi đồng ý kết bạn / chuyển nhiều người. */
.folder-select { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.folder-select select { width: auto; min-width: 220px; max-width: min(360px, 100%); }
.bulk-bar .folder-select { margin: 0; }
/* Tổng quan › Sử dụng AI */
.ov-grid > .ov-ai-card { grid-column: 1 / -1; }
.ov-ai-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 10px; }
@media (max-width: 760px) { .ov-ai-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ov-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
.ov-table th, .ov-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.ov-table th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ov-table .num { text-align: right; white-space: nowrap; }
.ov-table code { font-size: 12.5px; overflow-wrap: anywhere; }
.ov-ai-card .ov-rank-row { cursor: default; }
