﻿/* ================= ONE MSG DKTK — trang chủ dạng thẻ phẳng =================
   Bố cục thẻ bám theo màn hình Quản lý bệnh viện (lưới ≥250px, cách 12px, icon 40px, bo 14px, viền trái màu nhóm).
   Màu nhận diện MSG: Emerald #009247. Font iCiel Graphit nếu máy đã cài, không thì dùng font hệ thống. CSP chặt: không style nội tuyến. */
.theme-home {
  --msg: #009247; --msg-600: #007a3b; --msg-50: #e6f5ec;
  --hm-line: #e2e8f0; --hm-muted: #64748b;
  background: #f4f7f5;
  font-family: "iCiel Graphit", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
.theme-home .page { max-width: 1280px; }
.theme-home a:hover { text-decoration: none; }

/* ---- Màu thẻ: module (theo "Màu nhấn" trong Danh mục module) và nhóm website (12 sắc độ luân phiên theo mã nhóm) ---- */
.app-emerald { --acc: #009247; --acc2: #34d399; --acc-soft: #e6f5ec; }
.app-violet  { --acc: #6d28d9; --acc2: #a78bfa; --acc-soft: #f3edff; }
.app-sky     { --acc: #0284c7; --acc2: #38bdf8; --acc-soft: #e6f4fc; }
.app-amber   { --acc: #d97706; --acc2: #fbbf24; --acc-soft: #fff5e0; }
.app-rose    { --acc: #dc2626; --acc2: #f87171; --acc-soft: #fdeaea; }
.app-slate   { --acc: #475569; --acc2: #94a3b8; --acc-soft: #eef2f6; }
.app-teal    { --acc: #0d9488; --acc2: #2dd4bf; --acc-soft: #e3f7f5; }
.app-indigo  { --acc: #4338ca; --acc2: #818cf8; --acc-soft: #ecebfd; }
.acc-0  { --acc: #0891b2; --acc2: #22d3ee; --acc-soft: #e2f6fa; }
.acc-1  { --acc: #ea580c; --acc2: #fb923c; --acc-soft: #fff1e7; }
.acc-2  { --acc: #9333ea; --acc2: #c084fc; --acc-soft: #f5ebfe; }
.acc-3  { --acc: #db2777; --acc2: #f472b6; --acc-soft: #fdebf4; }
.acc-4  { --acc: #4338ca; --acc2: #818cf8; --acc-soft: #ecebfd; }
.acc-5  { --acc: #0d9488; --acc2: #2dd4bf; --acc-soft: #e3f7f5; }
.acc-6  { --acc: #d97706; --acc2: #fbbf24; --acc-soft: #fff5e0; }
.acc-7  { --acc: #16a34a; --acc2: #4ade80; --acc-soft: #e8f7ee; }
.acc-8  { --acc: #be123c; --acc2: #fb7185; --acc-soft: #fdeaf0; }
.acc-9  { --acc: #0284c7; --acc2: #38bdf8; --acc-soft: #e6f4fc; }
.acc-10 { --acc: #7c3aed; --acc2: #a78bfa; --acc-soft: #f1ebfe; }
.acc-11 { --acc: #65a30d; --acc2: #a3e635; --acc-soft: #f1f8e3; }

/* ---- Đầu trang ---- */
.hm-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  margin-top: 6px; padding: 22px 28px; border-radius: 22px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #36c47a 0%, transparent 55%), linear-gradient(120deg, #00783a 0%, #009247 45%, #12a86a 100%);
  box-shadow: 0 18px 40px -18px rgba(0, 146, 71, 0.55);
}
.hm-hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); pointer-events: none; }
.hm-logo { padding: 10px 14px; border-radius: 14px; background: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.hm-logo img { display: block; width: auto; height: 58px; }
.hm-hero h1 { margin: 0; color: #fff; font-size: 1.9rem; font-weight: 800; letter-spacing: 0.02em; }
.hm-tagline { margin: 4px 0 0; font-size: 0.98rem; }
.hm-tagline b:nth-child(1) { color: #d9f99d; }
.hm-tagline b:nth-child(2) { color: #bae6fd; }
.hm-tagline b:nth-child(3) { color: #fde68a; }
.hm-greet { margin: 10px 0 0; font-size: 0.9rem; opacity: 0.94; }
.hm-greet strong { color: #fff; }
.hm-stats { position: relative; z-index: 1; display: flex; gap: 10px; margin: 0; }
.hm-stats div { display: flex; flex-direction: column-reverse; align-items: center; min-width: 86px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.14); }
.hm-stats dd { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.hm-stats dt { font-size: 0.76rem; opacity: 0.9; }
.hm-flash { margin: 16px 0 0; }

/* ---- Tìm kiếm + dạng xem ---- */
.hm-toolbar { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; }
.hm-search { position: relative; flex: 1; }
.hm-search > .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--hm-muted); }
.hm-search input {
  width: 100%; height: 46px; padding: 0 44px; border: 1px solid var(--hm-line); border-radius: 999px; background: #fff;
  color: #0f172a; font: inherit; font-size: 0.96rem; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.hm-search input:focus { border-color: var(--msg); box-shadow: 0 0 0 4px rgba(0, 146, 71, 0.12); }
.hm-search kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); padding: 1px 7px; border: 1px solid var(--hm-line); border-radius: 6px; background: #f8fafc; color: var(--hm-muted); font-size: 0.76rem; }
.hm-view { display: inline-flex; padding: 3px; border: 1px solid var(--hm-line); border-radius: 12px; background: #fff; }
.hm-view button { display: grid; place-items: center; width: 38px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--hm-muted); cursor: pointer; }
.hm-view button:hover { color: var(--msg); }
.hm-view button.is-on { background: var(--msg); color: #fff; box-shadow: 0 4px 10px rgba(0, 146, 71, 0.3); }

/* ---- Nhãn nhóm (lọc) ---- */
.hm-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.hm-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--hm-line); border-radius: 999px;
  background: #fff; color: #334155; font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.hm-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06); }
.hm-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--acc); }
.hm-chip em { padding: 0 7px; border-radius: 999px; background: var(--acc-soft); color: var(--acc); font-size: 0.7rem; font-style: normal; line-height: 18px; }
.hm-chip.is-on { border-color: var(--acc); background: var(--acc); color: #fff; }
.hm-chip.is-on i { background: #fff; }
.hm-chip.is-on em { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* ---- Dùng gần đây ---- */
.hm-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 6px; }
.hm-recent-label { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; color: var(--hm-muted); font-size: 0.8rem; font-weight: 700; }
.hm-recent-label .icon { width: 15px; height: 15px; }
.hm-recent-item {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 5px 10px; border: 1px solid var(--acc-soft); border-radius: 10px;
  background: #fff; color: #1e293b; font-size: 0.82rem; font-weight: 600;
}
.hm-recent-item .icon { width: 15px; height: 15px; color: var(--acc); }
.hm-recent-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-recent-item:hover { border-color: var(--acc); color: var(--acc); }

/* ---- Khu vực + lưới thẻ ---- */
.hm-section-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 12px; color: #0f172a; font-size: 0.96rem; font-weight: 800; }
.hm-section-title .icon { color: var(--msg); }
.hm-section-title em { padding: 0 8px; border-radius: 999px; background: var(--msg-50); color: var(--msg-600); font-size: 0.76rem; font-style: normal; }
.hm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.hm-grid.is-list { grid-template-columns: 1fr; gap: 8px; }

.hm-tile {
  position: relative; overflow: hidden; display: flex; align-items: flex-start;
  border: 1px solid var(--hm-line); border-left: 4px solid var(--acc); border-radius: 14px;
  background: linear-gradient(135deg, var(--acc-soft) 0%, #fff 62%);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: hm-rise 0.35s ease both;
}
.hm-tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.6) 50%, transparent 60%); transform: translateX(-120%);
}
.hm-tile:hover::after { transform: translateX(120%); transition: transform 0.7s ease; }
.hm-tile:hover, .hm-tile:focus-within { transform: translateY(-3px); box-shadow: 0 14px 28px -12px var(--acc), 0 4px 10px rgba(15, 23, 42, 0.06); }
.hm-tile-link { display: flex; flex: 1; align-items: center; gap: 11px; min-width: 0; padding: 8px 4px 8px 12px; color: inherit; outline: none; }
.hm-tile-link:focus-visible { box-shadow: inset 0 0 0 2px var(--acc); border-radius: 10px; }
.hm-ic {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, var(--acc2), var(--acc)); box-shadow: 0 6px 14px -6px var(--acc); transition: transform 0.2s;
}
.hm-ic .icon { width: 18px; height: 18px; }
.hm-tile:hover .hm-ic { transform: scale(1.07) rotate(-4deg); }
.hm-body { display: grid; flex: 1; gap: 3px; min-width: 0; align-self: center; }
.hm-title { color: #0f172a; font-size: 0.93rem; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hm-tile:hover .hm-title { color: var(--acc); }
.hm-desc { color: var(--hm-muted); font-size: 0.76rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.hm-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hm-badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border: 1px solid var(--acc-soft); border-radius: 999px; background: #fff; color: var(--acc); font-size: 0.7rem; font-weight: 700; line-height: 18px; }
.hm-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }
.hm-where { display: inline-flex; align-items: center; gap: 3px; color: var(--hm-muted); font-size: 0.7rem; }
.hm-where .icon { width: 11px; height: 11px; }
.hm-star {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin: 6px 6px 0 0; border: 0; border-radius: 8px;
  background: transparent; color: #94a3b8; cursor: pointer; opacity: 0.5; transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.hm-star .icon { width: 16px; height: 16px; }
.hm-tile:hover .hm-star, .hm-star:focus-visible, .hm-star.is-on { opacity: 1; }
.hm-star:hover { background: #fef3c7; color: #d97706; }
.hm-star.is-on { color: #f59e0b; }
.hm-star.is-on .icon { fill: currentColor; }
.hm-star:disabled { cursor: progress; }

.hm-grid.is-list .hm-tile, .hm-grid.is-list .hm-tile-link { align-items: center; }
.hm-grid.is-list .hm-body { display: flex; align-items: center; gap: 12px; }
.hm-grid.is-list .hm-title { flex: 0 1 34%; -webkit-line-clamp: 1; }
.hm-grid.is-list .hm-desc { flex: 1; }
.hm-grid.is-list .hm-star { margin: 0 8px 0 0; }

.hm-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 18px auto 0; padding: 32px 24px; border: 1px dashed var(--hm-line); border-radius: 16px; background: #fff; color: var(--hm-muted); text-align: center; }
.hm-empty .icon { width: 34px; height: 34px; }
.hm-empty h2 { margin: 0; color: #0f172a; font-size: 1.1rem; }
.hm-empty p { margin: 0; }

.hm-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 28px; padding: 12px 16px; border: 1px solid var(--hm-line); border-radius: 14px; background: #fff; font-size: 0.86rem; }
.hm-admin-label { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; color: #334155; font-weight: 700; }
.hm-admin-label .icon { width: 16px; height: 16px; color: var(--msg); }
.hm-admin a { padding: 5px 10px; border-radius: 9px; background: #f1f5f9; color: #1e293b; font-weight: 600; }
.hm-admin a:hover { background: var(--msg-50); color: var(--msg-600); }
.hm-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--hm-line); color: var(--hm-muted); font-size: 0.78rem; }

@keyframes hm-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hm-tile { animation: none; } .hm-tile:hover::after { transition: none; } }

@media (max-width: 900px) {
  .hm-hero { grid-template-columns: 1fr; justify-items: center; padding: 20px; text-align: center; }
}
@media (max-width: 560px) {
  .hm-hero h1 { font-size: 1.5rem; }
  .hm-logo img { height: 46px; }
  .hm-stats { width: 100%; }
  .hm-stats div { flex: 1; min-width: 0; padding: 8px; }
  .hm-toolbar { flex-wrap: wrap; }
  .hm-search { flex-basis: 100%; }
  .hm-search kbd { display: none; }
  /* Màn hình nhỏ: nhãn nhóm tự xuống hàng (không kéo ngang), nhỏ gọn hơn một chút. */
  .hm-chips { flex-wrap: wrap; gap: 6px; }
  .hm-chip { flex: none; padding: 6px 11px; font-size: 0.82rem; }
  .hm-grid { grid-template-columns: 1fr; }
  .hm-grid.is-list .hm-body { display: grid; }
  .hm-grid.is-list .hm-desc { display: none; }
}

/* Liên kết ngoài trên menu: icon mũi tên nhỏ báo "mở tab mới" (dùng ở mọi trang) */
.app-tab .icon + span + .icon { width: 12px; height: 12px; opacity: 0.6; }

/* Thẻ gọn: nhãn nhóm + mô tả cùng một dòng (thẻ thấp hơn) */
.hm-meta { flex-wrap: nowrap; min-width: 0; }
.hm-meta .hm-badge { flex: none; }
.hm-meta .hm-desc { flex: 1; min-width: 0; -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; display: block; }

/* Khu "Đã ghim": mặc định thu gọn, bấm tiêu đề để sổ ra (đang tìm / lọc thì tự mở) */
.hm-collapse { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 0; border-radius: 10px; background: transparent;
  color: inherit; font: inherit; font-weight: inherit; cursor: pointer; }
.hm-collapse:hover { background: #f1f5f9; }
.hm-collapse:focus-visible { outline: 2px solid var(--primary, #1f6feb); outline-offset: 2px; }
.hm-collapse-hint { font-size: 0.74rem; font-weight: 500; color: var(--hm-muted, #64748b); }
.hm-chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
.js-section-pin:not(.is-collapsed) .hm-chevron, .js-section-pin.is-forced-open .hm-chevron { transform: rotate(180deg); }
.js-section-pin.is-collapsed:not(.is-forced-open) .js-grid-pin { display: none; }
.hm-section-title .hm-chevron { color: var(--hm-muted, #64748b); }
/* Dạng danh sách: nhãn nhóm một cột rộng cố định → mô tả các dòng thẳng hàng */
.hm-grid.is-list .hm-meta { flex: 1; display: grid; grid-template-columns: 136px minmax(0, 1fr); align-items: center; gap: 10px; }
.hm-grid.is-list .hm-meta .hm-badge { justify-self: start; max-width: 136px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .hm-grid.is-list .hm-meta { display: flex; } }

/* ===== Mascot "Trợ lý ONE" (trang chủ) — đứng yên ở góc phải dưới, bấm mở khung chat ===== */
.mi-bot {
  position: fixed; z-index: 70; right: 14px; bottom: 36px; width: 104px; height: 104px; padding: 0; border: 0; background: none;
  cursor: grab; -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none;
}
/* Kéo thả (portal.js): đang kéo thì không nhún, không chọn ảnh; ảnh không tự bị trình duyệt kéo đi. */
.mi-bot.is-dragging { cursor: grabbing; }
.mi-bot.is-dragging .mi-img { transform: scale(1.08); transition: none; }
.mi-img { -webkit-user-drag: none; pointer-events: none; }
/* Mascot ở nửa trái / sát mép trên: bong bóng lời chào và khung chat mở về phía còn chỗ. */
.mi-bot.is-leftside .mi-bubble { right: auto; left: 4px; border-radius: 14px 14px 14px 4px; }
.mi-bot.is-topside .mi-bubble { bottom: auto; top: calc(100% + 6px); }
.mi-chat.is-leftside { right: auto; left: 16px; }
.mi-bot:focus-visible { outline: 2px solid #2563eb; outline-offset: 4px; border-radius: 16px; }
.mi-img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(15, 23, 42, 0.22)); transition: transform 0.2s ease; }
.mi-bot:hover .mi-img { transform: translateY(-4px) scale(1.06); }
/* Ảnh không tải được: nút tròn xanh có chữ thay cho ô ảnh vỡ. */
.mi-bot.is-noimg .mi-img { display: none; }
.mi-bot.is-noimg { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 10px 22px -8px rgba(5, 150, 105, 0.7); }
.mi-bot.is-noimg::after { content: "Trợ lý"; color: #fff; font-size: 0.8rem; font-weight: 800; }
/* Trang có mascot: chừa chỗ cuối trang để mascot không che dòng cuối (nút ghim của thẻ cuối). */
body:has(.js-mi) main.page { padding-bottom: 132px; }
.mi-bot.is-wave .mi-img { animation: mi-hop 0.45s ease-in-out 3; }
@keyframes mi-hop { 0%, 100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-8px) rotate(-5deg); } 70% { transform: translateY(0) rotate(4deg); } }
.mi-bubble {
  position: absolute; bottom: calc(100% + 6px); right: 4px; width: max-content; max-width: 230px; padding: 8px 12px; border: 1px solid #a7f3d0; border-radius: 14px 14px 4px 14px;
  background: #fff; color: #064e3b; font-size: 0.82rem; font-weight: 600; line-height: 1.4; text-align: left; box-shadow: 0 10px 24px -10px rgba(4, 120, 87, 0.45);
}
.mi-bubble[hidden] { display: none; }

.mi-chat {
  position: fixed; z-index: 71; right: 16px; bottom: 148px; display: flex; flex-direction: column; width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - 218px));
  border: 1px solid #d1fae5; border-radius: 18px; background: #fff; box-shadow: 0 24px 60px -18px rgba(15, 23, 42, 0.35); overflow: hidden;
}
.mi-chat[hidden] { display: none; }
.mi-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.mi-head-avatar { flex: none; width: 40px; height: 40px; padding: 2px; border-radius: 50%; background: #fff; object-fit: cover; }
.mi-head-text { display: grid; flex: 1; min-width: 0; line-height: 1.25; }
.mi-head-text small { color: #d1fae5; font-size: 0.72rem; }
.mi-icon-btn { flex: none; border: 0; border-radius: 9px; background: rgba(255, 255, 255, 0.18); color: #fff; cursor: pointer; }
.mi-icon-btn { display: grid; place-items: center; width: 30px; height: 30px; }
.mi-icon-btn .icon { width: 16px; height: 16px; }
.mi-icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.mi-log { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 14px; overflow-y: auto; background: #f8fafc; }
.mi-msg { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.mi-msg.is-bot { align-self: flex-start; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; background: #fff; color: #0f172a; }
.mi-msg.is-user { align-self: flex-end; border-bottom-right-radius: 4px; background: #059669; color: #fff; }
.mi-msg.is-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.mi-msg a { color: #047857; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.mi-l-code { font-weight: 700; color: #065f46; }
.mi-l-warn { color: #b45309; font-weight: 600; }
.mi-l-ic { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 6px; border-radius: 50%; background: #d97706; color: #fff; font-size: 0.7rem; font-weight: 800; line-height: 1; vertical-align: 1px; }
.mi-l-warn.is-danger { color: #dc2626; font-weight: 700; }
.mi-l-warn.is-danger .mi-l-ic { background: #dc2626; }
.mi-l-ok { color: #047857; font-weight: 700; }
.mi-l-ok .mi-l-ic { background: #059669; }
.mi-l-src { color: #94a3b8; font-size: 0.74rem; }
.mi-go { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; white-space: normal; }
.mi-go-btn { display: inline-flex; align-items: center; padding: 6px 11px; border-radius: 10px; background: #059669; color: #fff !important; font-size: 0.8rem; font-weight: 700; text-decoration: none !important; }
.mi-go-btn:hover { background: #047857; }
.mi-go-note { display: block; margin-top: 6px; color: #64748b; font-size: 0.74rem; white-space: normal; }
.mi-go-note button { padding: 0; border: 0; background: none; color: #dc2626; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.mi-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.mi-typing i { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: mi-dot 1s infinite ease-in-out; }
.mi-typing i:nth-child(2) { animation-delay: 0.15s; } .mi-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mi-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.mi-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: #fff; }
.mi-chips[hidden] { display: none; }
.mi-chip { padding: 5px 10px; border: 1px solid #a7f3d0; border-radius: 999px; background: #ecfdf5; color: #047857; font: inherit; font-size: 0.76rem; font-weight: 600; cursor: pointer; }
.mi-chip:hover { background: #d1fae5; }
.mi-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; background: #fff; }
.mi-form textarea {
  flex: 1; min-height: 40px; max-height: 120px; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 12px; font: inherit; font-size: 0.88rem; line-height: 1.4; resize: none;
}
.mi-form textarea:focus { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.mi-send { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 12px; background: #059669; color: #fff; cursor: pointer; }
.mi-send:hover { background: #047857; }
.mi-send:disabled { background: #94a3b8; cursor: wait; }
.mi-send .icon { width: 18px; height: 18px; }
.mi-note { margin: 0; padding: 0 12px 10px; background: #fff; color: #94a3b8; font-size: 0.7rem; }
@media (max-width: 560px) {
  .mi-bot { right: 8px; bottom: 22px; width: 76px; height: 76px; }
  .mi-chat.is-leftside { left: 12px; }
  .mi-bot.is-noimg { width: 56px; height: 56px; }
  .mi-bubble { max-width: min(230px, calc(100vw - 32px)); }
  body:has(.js-mi) main.page { padding-bottom: 100px; }
  .mi-chat { right: 12px; left: 12px; width: auto; bottom: 104px; height: min(520px, calc(100vh - 176px)); }
}
@media (prefers-reduced-motion: reduce) {
  .mi-img { transition: none; }
  .mi-bot.is-wave .mi-img, .mi-typing i { animation: none; }
}
/* Cửa sổ thấp (thu nhỏ trình duyệt, điện thoại xoay ngang): khung chat phủ gần hết chiều cao, che mascot — đóng bằng nút ×. */
@media (max-height: 560px) {
  .mi-chat { top: 8px; bottom: 8px; height: auto; }
  .mi-chips { flex-wrap: nowrap; overflow-x: auto; }
  .mi-chip { flex: none; }
}
@media (max-height: 400px) {
  .mi-bot { width: 60px; height: 60px; }
  .mi-note { display: none; }
  .mi-head { padding-top: 8px; padding-bottom: 8px; }
}

/* ===== Danh sách 4 cột: Phân nguồn · Hình thức · Chức năng · Khoa phòng quản lý ===== */
.hm-filter { flex: none; height: 40px; padding: 0 10px; border: 1px solid var(--hm-line, #e2e8f0); border-radius: 12px; background: #fff; color: #334155; font: inherit; font-size: 0.86rem; font-weight: 600; }
.hm-filter:focus-visible { outline: 2px solid var(--msg, #009247); outline-offset: 1px; }
.hm-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #f1f5f9; color: #334155; font-size: 0.72rem; font-weight: 700; line-height: 18px; white-space: nowrap; }
.hm-tag-kind { background: #eef2ff; color: #4338ca; }
.hm-none { color: #cbd5e1; }
.hm-list-head { display: none; }
/* Dạng thẻ: tên một dòng riêng, các nhãn nằm cạnh nhau, chức năng xuống dòng dưới; ô trống ("—") không hiện. */
.hm-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.hm-body .hm-title { flex: 1 0 100%; }
.hm-body .hm-desc { flex: 1 0 100%; order: 5; }
.hm-body .hm-desc:empty, .hm-body .hm-col:has(> .hm-none) { display: none; }
.hm-col-dept .hm-badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 901px) {
  /* Dạng danh sách (màn hình rộng): một dòng 5 cột thẳng hàng với dòng tiêu đề. */
  .hm-grid.is-list .hm-list-head, .hm-grid.is-list .hm-body {
    display: grid; grid-template-columns: minmax(170px, 1.35fr) 132px 104px minmax(0, 2fr) minmax(120px, 0.9fr); align-items: center; gap: 12px;
  }
  .hm-grid.is-list .hm-list-head {
    padding: 0 44px 2px 63px; color: var(--hm-muted, #64748b); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  }
  .hm-grid.is-list .hm-body .hm-title, .hm-grid.is-list .hm-body .hm-desc { flex: none; order: 0; }
  .hm-grid.is-list .hm-body .hm-title { -webkit-line-clamp: 2; }
  .hm-grid.is-list .hm-body .hm-desc { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hm-grid.is-list .hm-body .hm-desc:empty, .hm-grid.is-list .hm-body .hm-col:has(> .hm-none) { display: block; }
  .hm-grid.is-list .hm-col { min-width: 0; }
}
@media (max-width: 900px) {
  .hm-grid.is-list .hm-body { display: flex; }
  .hm-grid.is-list .hm-body .hm-title { flex: 1 0 100%; }
}
@media (max-width: 560px) {
  .hm-filter { flex: 1; min-width: 0; }
  /* Điện thoại: vẫn hiện Chức năng (một dòng) dưới các nhãn. */
  .hm-grid.is-list .hm-body .hm-desc:not(:empty) { display: -webkit-box; }
}
@media (min-width: 901px) {
  /* Nhãn "N chưa xem" ở dạng danh sách: chỉ còn số, gắn trên góc biểu tượng — không chiếm chỗ của các cột. */
  .hm-grid.is-list .hm-unread { position: absolute; left: 36px; top: 3px; z-index: 1; margin: 0; padding: 0 6px; font-size: 0.66rem; line-height: 16px; }
  .hm-grid.is-list .hm-unread span { display: none; }
}

/* ===== Thanh công cụ trang chủ: ô tìm ngắn lại, thêm lọc Khoa phòng quản lý; thiếu chỗ thì các ô lọc tự xuống hàng ===== */
.hm-toolbar { flex-wrap: wrap; row-gap: 10px; }
.hm-search { flex: 1 1 260px; min-width: 220px; max-width: 440px; }
.hm-filter { max-width: 220px; text-overflow: ellipsis; }
.hm-filter-dept { width: 210px; }
.hm-toolbar .hm-view { margin-left: auto; }
/* Máy tính bảng: ô tìm chiếm trọn một hàng, các ô lọc chia đều hàng dưới. */
@media (max-width: 900px) {
  .hm-search { flex-basis: 100%; max-width: none; }
  .hm-filter, .hm-filter-dept { flex: 1 1 150px; width: auto; max-width: none; min-width: 0; }
}
/* Điện thoại: mỗi hàng 2 ô lọc, nút đổi kiểu hiển thị nằm cuối. */
@media (max-width: 560px) {
  .hm-toolbar { gap: 8px; }
  .hm-filter, .hm-filter-dept { flex: 1 1 calc(50% - 4px); height: 38px; font-size: 0.82rem; }
}

/* ===== Website mới (người dùng chưa mở): số tròn CAM ở góc nhãn khoa phòng (giống số trên chuông) + nhãn "Mới" trên thẻ.
   Cam = "mới" — khác đỏ (văn bản chưa xem), xanh dương, xanh lá thương hiệu. Tooltip tự vẽ, nền tối, hiện ngay khi rê chuột. ===== */
.hm-chip { position: relative; }
.hm-chip-new {
  position: absolute; top: -7px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid #fff; border-radius: 999px;
  background: linear-gradient(135deg, #fb923c, #ea580c); color: #fff; font-size: 0.68rem; font-weight: 800; font-style: normal; line-height: 15px; text-align: center;
  box-shadow: 0 3px 8px -3px rgba(234, 88, 12, 0.75); pointer-events: none;
}
.hm-chip.has-new { border-color: #fdba74; }
/* Hàng nhãn nằm TRÊN các phần phía dưới (thẻ có số "chưa xem", Dùng gần đây…) để tooltip không bị đè;
   chừa chỗ cho số tròn nhô lên trên nhãn. Nhãn đang rê chuột nổi lên trên các nhãn bên cạnh. */
.hm-chips { position: relative; z-index: 30; padding-top: 6px; }
.hm-chip:hover, .hm-chip:focus-visible { z-index: 2; }
.hm-chip-tip {
  position: absolute; z-index: 40; top: calc(100% + 9px); left: 0; display: grid; gap: 6px; width: max-content; min-width: 220px; max-width: 320px;
  padding: 10px 12px; border: 1px solid #fed7aa; border-radius: 12px; background: linear-gradient(180deg, #fff7ed, #ffffff 70%); color: #431407;
  box-shadow: 0 18px 36px -14px rgba(234, 88, 12, 0.45), 0 4px 12px rgba(15, 23, 42, 0.08);
  font-size: 0.8rem; font-weight: 500; line-height: 1.4; text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; transform: translateY(-3px); transition: opacity 0.08s ease, transform 0.08s ease, visibility 0s linear 0.08s; pointer-events: none;
}
/* Mũi tên: viền cam nhạt + lòng màu nền. */
.hm-chip-tip::before, .hm-chip-tip::after { content: ""; position: absolute; left: 18px; border: 7px solid transparent; border-top: 0; }
.hm-chip-tip::before { top: -7px; border-bottom-color: #fed7aa; }
.hm-chip-tip::after { top: -6px; border-bottom-color: #fff7ed; }
.hm-chip.tip-left .hm-chip-tip { left: auto; right: 0; }
.hm-chip.tip-left .hm-chip-tip::before, .hm-chip.tip-left .hm-chip-tip::after { left: auto; right: 18px; }
.hm-chip:hover .hm-chip-tip, .hm-chip:focus-visible .hm-chip-tip { opacity: 1; visibility: visible; transform: none; transition: opacity 0.08s ease, transform 0.08s ease; }
.hm-tip-head { color: #c2410c; font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.hm-tip-row { display: grid; gap: 1px; padding: 6px 8px; border-left: 3px solid #fb923c; border-radius: 6px; background: #fff; }
.hm-tip-row b { color: #1e293b; font-weight: 700; }
.hm-tip-row small { color: #64748b; font-size: 0.74rem; }
.hm-tip-more { color: #9a3412; font-size: 0.74rem; }
@media (hover: none) { .hm-chip-tip { display: none; } }   /* điện thoại: không có rê chuột — danh sách xem ở chuông */
.hm-new { display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 999px; background: linear-gradient(135deg, #fb923c, #ea580c); color: #fff; font-size: 0.66rem; font-weight: 800; line-height: 17px; vertical-align: 2px; text-transform: uppercase; letter-spacing: 0.02em; }
.hm-tile.is-new { box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.3), 0 6px 16px -10px rgba(234, 88, 12, 0.6); }
