/* ============================================================
   Es CRM — Design System  (AG owns this file)
   MD3 token + light/dark + component classes cho nghiệp vụ BĐS.
   Dùng cùng Tailwind CDN (utility) — file này chỉ định nghĩa
   biến màu + component dùng lại nhiều lần.
   ============================================================ */

:root {
  --primary: #0c56d0;
  --primary-grad: var(--primary); /* gradient cho nút/fab/brand; mặc định = màu phẳng */
  --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);
  --primary-line: color-mix(in srgb, var(--primary) 35%, transparent);

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --surface-3: #e7eaf3;
  --text: #181b23;
  --text-soft: #5a6072;
  --text-dim: #8b91a3;
  --line: #e2e6f0;
  --line-soft: #eef0f6;

  --green: #0f9d6b;  --green-bg: #e6f7f0;
  --red:   #e23b4e;  --red-bg:   #fdeaec;
  --amber: #e08a00;  --amber-bg: #fdf3e2;
  --cyan:  #0aa2c0;  --cyan-bg:  #e3f6fa;
  --purple:#7c3aed;  --purple-bg:#f1eafe;
  --slate: #64748b;  --slate-bg: #eef1f6;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
  --shadow:    0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.16);
  --dyn-p: 1.5rem;
  --pad-card: 20px;
  --pad-cell: 12px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-head: var(--font);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Mật độ hiển thị — 4 cấp (đặt trên <html> bằng data-density) */
html[data-density="ultra"]    { --dyn-p: .7rem;   --pad-card: 11px; --pad-cell: 6px; }
html[data-density="compact"]  { --dyn-p: 1rem;    --pad-card: 14px; --pad-cell: 8px; }
html[data-density="standard"] { --dyn-p: 1.5rem;  --pad-card: 20px; --pad-cell: 12px; }
html[data-density="spacious"] { --dyn-p: 2.25rem; --pad-card: 28px; --pad-cell: 17px; }

.dark {
  --primary-soft: color-mix(in srgb, var(--primary) 22%, transparent);
  --bg: #0e1117;
  --surface: #161b22;
  --surface-2: #1c2230;
  --surface-3: #232b3a;
  --text: #e7eaf3;
  --text-soft: #aab2c5;
  --text-dim: #767f93;
  --line: #2a3344;
  --line-soft: #222a38;
  --green-bg: rgba(15,157,107,.16);
  --red-bg: rgba(226,59,78,.16);
  --amber-bg: rgba(224,138,0,.16);
  --cyan-bg: rgba(10,162,192,.16);
  --purple-bg: rgba(124,58,237,.16);
  --slate-bg: rgba(100,116,139,.18);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 4px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s, color .25s;
}
h1, h2, h3, .page-title, .card-title, .metric-value { font-family: var(--font-head); }
.font-mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; user-select: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* ---------- Layout shell ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 256px; flex-shrink: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; padding: 16px 12px;
  transition: transform .25s, background .25s;
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  height: 62px; flex-shrink: 0; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.page { flex: 1; overflow-y: auto; padding: var(--dyn-p); }
@media (max-width: 1024px){ :root{ --dyn-p: 1rem; } }

/* ---------- Sidebar nav ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 14px; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-grad); color: #fff;
  display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.nav-group-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-soft); cursor: pointer; font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s; user-select: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item .material-symbols-outlined { font-size: 21px; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-item.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--primary); color: #fff; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: filter .15s, background .15s, border-color .15s; font-family: var(--font); }
.btn .material-symbols-outlined { font-size: 19px; }
.btn-primary { background: var(--primary-grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }
.btn-sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-icon.btn-sm { width: 31px; height: 31px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); }
.card-pad { padding: var(--pad-card); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12.5px; color: var(--text-soft); }

.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad-card); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.metric-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.metric-label { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.metric-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.metric-delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.metric-delta.up { color: var(--green); } .metric-delta.down { color: var(--red); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.4; }
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-green  { color: var(--green);  background: var(--green-bg); }
.badge-red    { color: var(--red);    background: var(--red-bg); }
.badge-amber  { color: var(--amber);  background: var(--amber-bg); }
.badge-cyan   { color: var(--cyan);   background: var(--cyan-bg); }
.badge-purple { color: var(--purple); background: var(--purple-bg); }
.badge-slate  { color: var(--slate);  background: var(--slate-bg); }
.badge-primary{ color: var(--primary);background: var(--primary-soft); }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-dim); padding: var(--pad-cell) 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.data-table td { padding: var(--pad-cell) 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Forms ---------- */
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s; }
.form-textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-input::placeholder { color: var(--text-dim); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input { width: 100%; height: 40px; padding: 0 14px 0 40px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; outline: none; }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box .material-symbols-outlined { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 20px; }

/* Topbar actions (luôn căn phải) + avatar + chấm thông báo */
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.topbar-actions .btn-icon { color: var(--text-soft); width: 40px; height: 40px; border-radius: 12px; }
.topbar-actions .btn-icon:hover { color: var(--text); background: var(--surface-2); }
.topbar-actions .material-symbols-outlined { font-size: 22px; font-variation-settings: 'wght' 300; }
#userAvatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; overflow: hidden; margin-left: 4px; }
#notifBtn { position: relative; }
#notifBtn .notif-dot { position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 99px; background: var(--red); border: 1.5px solid var(--surface); }
.topbar .page-title { font-size: 19px; }
@media (max-width: 768px){ .topbar .page-title { font-size: 16px; } .topbar { padding: 0 12px; gap: 8px; } .topbar-actions { gap: 2px; } .topbar-actions .btn-icon { width: 38px; height: 38px; } }

/* ---------- Tabs / segmented ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.tab { padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-soft);
  cursor: pointer; border: none; background: transparent; transition: background .15s, color .15s; }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col { flex: 0 0 290px; background: var(--surface-2); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kanban-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 13px; font-weight: 700; }
.kanban-col-head .count { margin-left: auto; font-size: 12px; color: var(--text-soft);
  background: var(--surface); padding: 1px 9px; border-radius: 99px; }
.kanban-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 10px 12px; overflow-y: auto; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, transform .1s; }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .5; cursor: grabbing; }
.kanban-col.drop-target { outline: 2px dashed var(--primary-line); outline-offset: -3px; }

/* ---------- Modal / drawer ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,14,22,.55); backdrop-filter: blur(3px);
  z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; border: 1px solid var(--line);
  animation: pop .18s ease; }
.modal-lg { max-width: 860px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.drawer-overlay { position: fixed; inset: 0; background: rgba(10,14,22,.5); z-index: 90; display: none; }
.drawer-overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 95; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1); }
.drawer.open { transform: translateX(0); }

/* ---------- Activity timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.activity-item { position: relative; padding-bottom: 18px; }
.activity-item::before { content: ''; position: absolute; left: -22px; top: 3px; width: 14px; height: 14px;
  border-radius: 99px; background: var(--surface); border: 2px solid var(--primary); }
.activity-item .time { font-size: 12px; color: var(--text-dim); }

/* ---------- Misc ---------- */
.stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px;
  background: var(--surface-2); font-size: 13px; font-weight: 600; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.avatar { border-radius: 99px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty .material-symbols-outlined { font-size: 46px; opacity: .5; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--text-soft); font-size: 13.5px; margin-top: 2px; }
.divider { height: 1px; background: var(--line); border: none; margin: 0; }
.muted { color: var(--text-soft); }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0%{ background-position:100% 0 } 100%{ background-position:-100% 0 } }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 240px; max-width: 360px;
  font-size: 14px; display: flex; align-items: center; gap: 10px; animation: slideIn .25s ease; }
.toast.success { border-left-color: var(--green); } .toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive sidebar */
#menuToggle { display: none; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(10,14,22,.45); z-index: 59; display: none; }
.sidebar-overlay.open { display: block; }
@media (max-width: 768px){
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); box-shadow: var(--shadow-lg); width: 76vw; max-width: 320px; }
  .sidebar.open { transform: translateX(0); }
  #menuToggle { display: inline-flex; }
  .topbar .search-box { display: none; }
}
@media (min-width: 769px){ .sidebar-overlay { display: none !important; } }

/* ============================================================
   Style themes — data-style trên <html> (Cài đặt → Giao diện)
   ============================================================ */
/* Clean & Trust = mặc định (không override) */
html[data-style="minimalist"] { --radius: 8px; --radius-sm: 6px; --shadow-sm: none; --shadow: none; --shadow-lg: 0 10px 34px rgba(0,0,0,.10); }
html[data-style="minimalist"] .card, html[data-style="minimalist"] .metric-card { box-shadow: none; }
html[data-style="modern"] { --radius: 20px; --radius-sm: 15px; --shadow-sm: 0 2px 10px rgba(16,24,40,.07); --shadow: 0 10px 28px rgba(16,24,40,.13); --shadow-lg: 0 24px 60px rgba(16,24,40,.20); }
html[data-style="modern"] .btn { border-radius: 13px; }
html[data-style="classic"] { --radius: 6px; --radius-sm: 5px; --shadow-sm: 0 1px 2px rgba(0,0,0,.06); --shadow: 0 1px 3px rgba(0,0,0,.10); --shadow-lg: 0 8px 24px rgba(0,0,0,.16); --font-head: 'Playfair Display', Georgia, serif; }
html[data-style="premium"] { --bg: #f5f2ec; --surface: #fffdf8; --surface-2: #f3eee3; --surface-3: #ece4d4; --line: #e7ddc9; --line-soft: #efe9dc;
  --radius: 16px; --shadow: 0 10px 30px rgba(80,60,20,.10); --shadow-lg: 0 24px 60px rgba(80,60,20,.18); --font-head: 'Playfair Display', Georgia, serif; }
html[data-style="premium"].dark { --bg: #15130f; --surface: #1d1a14; --surface-2: #262218; --surface-3: #2f2a1d; --line: #3a3326; --line-soft: #2a261c; }
html[data-style="glass"] { --radius: 18px; --shadow: 0 8px 32px rgba(31,38,135,.14); --shadow-lg: 0 16px 48px rgba(31,38,135,.22); }
html[data-style="glass"] body { background: linear-gradient(135deg, #dbeafe, #f0f9ff 42%, #fae8ff); background-attachment: fixed; }
html[data-style="glass"].dark body { background: linear-gradient(135deg, #0b1220, #0e1117 45%, #1a1230); background-attachment: fixed; }
html[data-style="glass"] .card, html[data-style="glass"] .metric-card, html[data-style="glass"] .sidebar,
html[data-style="glass"] .topbar, html[data-style="glass"] .kanban-col, html[data-style="glass"] #aiPanel {
  background: color-mix(in srgb, var(--surface) 60%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-color: color-mix(in srgb, var(--text) 8%, transparent); }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Utility layer (đủ dùng, không cần Tailwind) ---------- */
.flex { display: flex; } .iflex { display: inline-flex; } .grid { display: grid; }
.col { flex-direction: column; } .wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; } .justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; } .shrink-0 { flex-shrink: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; } .ml-auto { margin-left: auto; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px){ .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
/* Mobile: thẻ chỉ số giữ 2 cột (gọn, ít hàng); chỉ grid-2 (chart/khối lớn) mới về 1 cột */
@media (max-width: 720px){
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-card { padding: 12px; border-radius: 12px; }
  .metric-value { font-size: 19px; }
  .metric-label { font-size: 11.5px; }
  .metric-icon { width: 30px; height: 30px; border-radius: 9px; }
  .metric-icon .material-symbols-outlined { font-size: 18px; }
}
@media (max-width: 380px){ .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-base { font-size: 14px; } .text-lg { font-size: 16px; } .text-xl { font-size: 19px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; } .font-extrabold { font-weight: 800; }
.text-soft { color: var(--text-soft); } .text-dim { color: var(--text-dim); } .text-right { text-align: right; } .text-center { text-align: center; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-primary { color: var(--primary); }
.w-full { width: 100%; } .hidden { display: none; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; } .rounded { border-radius: 10px; } .rounded-full { border-radius: 999px; }
.section-gap > * + * { margin-top: 16px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: none; } .kv .k { color: var(--text-soft); font-size: 13px; } .kv .v { font-weight: 600; font-size: 13.5px; text-align: right; }

/* ---------- Auth screen ---------- */
.auth-root { position: fixed; inset: 0; z-index: 500; display: none; background: var(--bg); }
.auth-brand { flex: 1; background: linear-gradient(150deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #0aa2c0)); color: #fff; display: none; align-items: center; padding: 48px; }
.auth-brand-inner { max-width: 460px; }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-dim); font-size: 12.5px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
@media (min-width: 900px) { .auth-brand { display: flex; } }

/* ---------- Bộ lọc nâng cao ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--text); }
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.has-value { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.filter-pop { position: absolute; z-index: 60; margin-top: 6px; min-width: 230px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px; }
.filter-count { font-size: 12px; background: var(--primary); color: #fff; border-radius: 99px; padding: 0 7px; height: 18px; display: inline-grid; place-items: center; }
/* Gom bộ lọc trên mobile: desktop hiển thị inline; mobile ẩn sau nút "Lọc" */
.filter-toggle { display: none; }
.filter-extra { display: contents; }
@media (max-width: 768px) {
  .filter-toggle { display: inline-flex; }
  .filter-extra { display: none; width: 100%; flex-wrap: wrap; gap: 10px; margin-top: 2px; }
  .filter-extra.open { display: flex; }
  .filter-extra .form-select, .filter-extra .filter-chip, .filter-extra .search-box { width: 100%; max-width: none; flex: 1 1 100%; }
}

/* ---------- Plan badge ---------- */
.plan-tag { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; }
.plan-free { background: var(--slate-bg); color: var(--slate); }
.plan-pro { background: var(--primary-soft); color: var(--primary); }
.plan-business { background: var(--purple-bg); color: var(--purple); }
.plan-enterprise, .plan-custom { background: linear-gradient(90deg,#b8860b,#d4af37); color: #fff; }
.price-card.popular { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow); }
.style-sw { transition: border-color .15s, box-shadow .15s; }
.style-sw.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.color-sw.sel { border-color: var(--text) !important; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.user-menu { position: absolute; top: 54px; right: 16px; z-index: 70; width: 240px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }

/* ---------- AI Live Chat ---------- */
#aiFab { position: fixed; right: 22px; bottom: 22px; z-index: 110; width: 56px; height: 56px; border-radius: 99px;
  background: var(--primary-grad); color: #fff; border: none; cursor: pointer; box-shadow: var(--shadow-lg);
  display: grid; place-items: center; transition: transform .15s; }
#aiFab:hover { transform: scale(1.07); }
#aiFab .material-symbols-outlined { font-size: 28px; }
#aiPanel { position: fixed; right: 22px; bottom: 88px; z-index: 110; width: 390px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 120px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.ai-head { background: var(--primary); color: #fff; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.ai-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-welcome { background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: 13.5px; color: var(--text-soft); }
.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg.user { justify-content: flex-end; }
.ai-ava { color: var(--primary); font-size: 22px; flex-shrink: 0; }
#aiFab .ai-bot-img { width: 46px; height: 46px; object-fit: contain; }
.ai-bot-img-sm { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.15); }
.ai-ava-img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.ai-bubble { max-width: 80%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; }
.ai-msg.assistant .ai-bubble { background: var(--surface-2); border-top-left-radius: 4px; }
.ai-msg.user .ai-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.ai-status { font-size: 12.5px; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }
.ai-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--primary); animation: aipulse 1s infinite; }
@keyframes aipulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }
.ai-suggest { padding: 8px 12px; display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); }
.ai-chip { font-size: 12px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-soft); cursor: pointer; }
.ai-chip:hover { border-color: var(--primary); color: var(--primary); }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  font: inherit; font-size: 13.5px; background: var(--surface); color: var(--text); outline: none; max-height: 110px; }
.ai-input textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- Pricing period + SePay ---------- */
.period-toggle { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.period-toggle button { padding: 7px 16px; border: none; background: transparent; border-radius: 8px; font-weight: 600;
  font-size: 13.5px; color: var(--text-soft); cursor: pointer; }
.period-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.period-toggle .save { font-size: 10px; color: var(--green); font-weight: 700; margin-left: 4px; }
.qr-box { background: #fff; border-radius: 12px; padding: 12px; display: grid; place-items: center; border: 1px solid var(--line); }
.qr-box img { width: 220px; height: 220px; object-fit: contain; }
