﻿/* SGTK One — giao diện Portal. Không dùng font/CDN ngoài để chạy được trong mạng nội bộ và giữ CSP chặt. */
:root {
  --bar-h: 64px;
  --bar-bg: #0b1422;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dfe7f1;
  --text: #122033;
  --muted: #64748b;
  --primary: #1f6feb;
  --primary-soft: rgba(31, 111, 235, 0.1);
  --teal: #0d9488;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --slate: #475569;
  --slate-soft: rgba(71, 85, 105, 0.1);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
/* Thuộc tính hidden phải luôn ẩn — kể cả phần tử có display: flex / grid riêng (thẻ trang chủ, nhãn lọc, danh sách chọn…). */
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 4px 0 6px; font-size: clamp(1.5rem, 2.2vw, 2rem); }
h2 { margin: 0; }
code { padding: 1px 6px; border-radius: 6px; background: #eef2f7; font-size: 0.86em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Thanh menu trên cùng (nền sáng) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: var(--bar-h); padding: 0 20px;
  background: #fff; color: var(--text);
  border-bottom: 1px solid #e6ebf2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.04);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.brand-text strong { font-size: 1rem; font-weight: 800; color: #0f172a; letter-spacing: -0.01em; }
.brand-text small { color: #1f8a4c; font-size: 0.72rem; font-weight: 600; }
.topbar-divider { width: 1px; height: 28px; background: #e2e8f0; flex: none; }
.app-tabs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.app-tabs::-webkit-scrollbar { display: none; }
.app-tab {
  position: relative; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px;
  color: #475569; font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.app-tab .icon { width: 17px; height: 17px; color: #64748b; }
.app-tab:hover { color: #0f172a; background: #f1f5f9; text-decoration: none; }
.app-tab.active { color: #1d4ed8; background: #eaf2ff; }
.app-tab.active .icon { color: #1d4ed8; }
.app-tab.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; border-radius: 2px; background: #2563eb; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.pill-link {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 1px solid #e2e8f0; border-radius: 999px;
  background: #fff; color: #334155; font-size: 0.88rem; font-weight: 600; white-space: nowrap;
}
.pill-link .icon { width: 16px; height: 16px; }
.pill-link:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.pill-link.active { border-color: #bfd4fe; background: #eff6ff; color: #1d4ed8; }
.topbar-search { position: relative; display: flex; align-items: center; gap: 8px; width: 220px; height: 38px; padding: 0 14px; border: 1px solid #e2e8f0; border-radius: 999px; background: #f4f6f9; color: #94a3b8; }
.topbar-search:focus-within { border-color: #93b4f5; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.topbar-search .icon { width: 16px; height: 16px; }
.topbar-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.88rem; }
.topbar-search input::placeholder { color: #94a3b8; }
.search-results {
  position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: 60vh; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14); z-index: 40;
}
.search-results a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 9px; color: var(--text); }
.search-results a small { color: var(--muted); font-size: 0.76rem; white-space: nowrap; }
.search-results li[aria-selected="true"] a, .search-results a:hover { background: #eff6ff; text-decoration: none; }
.search-empty { padding: 12px 10px; color: var(--muted); font-size: 0.86rem; }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; cursor: pointer; list-style: none; border-radius: 50%; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; font-weight: 700; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 240px; padding: 8px;
  background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}
.user-menu-panel p { display: flex; flex-direction: column; margin: 4px 8px 8px; }
.user-menu-panel p small { color: var(--muted); }
.user-menu-panel a, .user-menu-panel button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: #f1f5f9; text-decoration: none; }

/* ---------- Bố cục trang ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 26px 24px 48px; }
.page-anon { min-height: 100vh; }
.hero { margin-bottom: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.section-block { margin-bottom: 26px; }
.section-title { margin: 0 0 12px; font-size: 0.8rem; font-weight: 700; color: var(--slate); letter-spacing: 0.05em; text-transform: uppercase; }

/* ---------- Thẻ phân hệ ---------- */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.app-card {
  display: flex; align-items: center; gap: 14px; padding: 20px; min-height: 104px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.app-card:hover { transform: translateY(-2px); border-color: #bcd0ea; box-shadow: 0 16px 32px rgba(15, 23, 42, 0.1); text-decoration: none; }
.app-card.disabled { opacity: 0.65; }
.app-card-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.app-card-icon .icon { width: 24px; height: 24px; }
.tone-quanlyvanban .app-card-icon { background: rgba(13, 148, 136, 0.12); color: var(--teal); }
.tone-quanlybenhvien .app-card-icon { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
.app-card-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.app-card-body strong { font-size: 1.02rem; }
.app-card-body small { color: var(--muted); }
.app-card-go { color: var(--muted); }

/* ---------- Khung mở phân hệ (iframe cùng origin) ---------- */
.shell-mode { overflow: hidden; }
.shell-main { height: calc(100vh - var(--bar-h)); height: calc(100dvh - var(--bar-h)); }
.shell { display: flex; flex-direction: column; height: 100%; }
.shell-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 44px; padding: 0 18px; background: #f8fafc; border-bottom: 1px solid #e6ebf2; font-size: 0.86rem; }
.shell-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #334155; }
.shell-title .icon { width: 16px; height: 16px; color: #64748b; }
.shell-tool { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid #e2e8f0; border-radius: 999px; background: #fff; color: #334155; font-weight: 600; font-size: 0.82rem; }
.shell-tool:hover { border-color: #cbd5e1; background: #f1f5f9; text-decoration: none; }
.shell-tool .icon { width: 14px; height: 14px; }
.shell-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Form & nút ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--slate); }
.field small { color: var(--muted); font-size: 0.76rem; }
.field input, .field select, .toolbar input, .toolbar select, .access-row select, .edit-table input, .edit-table select {
  width: 100%; padding: 10px 12px; border: 1px solid #d5deea; border-radius: 10px; background: #fff; color: var(--text); font: inherit;
}
.field input:focus, .field select:focus, .toolbar input:focus, .edit-table input:focus, .access-row select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input:disabled { background: #f1f5f9; color: var(--muted); }
.field-error { color: var(--danger); font-size: 0.78rem; }
.checks { justify-content: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 17px; height: 17px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #bcd0ea; text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, var(--primary), #3b82f6); border-color: transparent; color: #fff; box-shadow: 0 10px 22px rgba(31, 111, 235, 0.22); }
.btn.block { width: 100%; padding: 12px; }
.btn.sm { padding: 6px 12px; font-size: 0.84rem; }
.link { border: 0; background: none; color: var(--primary); font: inherit; cursor: pointer; padding: 0; }
.alert { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; font-size: 0.9rem; }
.alert.danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert.warning { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.temp-password { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.temp-password code { padding: 6px 12px; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em; background: #fff; user-select: all; }
.temp-password span { flex-basis: 100%; font-size: 0.84rem; }

/* ---------- Đăng nhập ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: radial-gradient(circle at 20% 10%, #e0f2fe 0, transparent 40%), linear-gradient(135deg, #eef4ff, #f8fafc); }
.page .auth { min-height: calc(100vh - var(--bar-h) - 80px); background: none; }
.auth-card { width: min(100%, 420px); padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.1); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.auth-brand h1 { margin: 0; font-size: 1.5rem; }
.auth-foot { margin: 16px 0 0; color: var(--muted); font-size: 0.84rem; text-align: center; }

/* ---------- Bảng & quản trị ---------- */
.sub-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.sub-tabs a { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--text); font-weight: 600; font-size: 0.9rem; }
.sub-tabs a.active { background: var(--primary-soft); border-color: rgba(31, 111, 235, 0.25); color: var(--primary); }
.sub-tabs a:hover { text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar input { max-width: 320px; }
.toolbar select { max-width: 240px; }
.count { margin-left: auto; color: var(--muted); font-size: 0.84rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 0.88rem; }
th { background: #f8fafc; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
td .sub { display: block; color: var(--muted); font-size: 0.78rem; }
td.end { text-align: right; }
td.center { text-align: center; }
td.nowrap { white-space: nowrap; }
td.wrap { max-width: 460px; word-break: break-word; }
td.empty { padding: 28px; color: var(--muted); text-align: center; }
.edit-table td { padding: 8px 6px; }
.edit-table input.narrow { width: 72px; }
.badge { display: inline-flex; align-items: center; margin: 2px 4px 2px 0; padding: 3px 9px; border-radius: 999px; background: #eef2f7; color: var(--slate); font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.slate { background: var(--slate-soft); color: var(--slate); }
.access-list { display: flex; flex-direction: column; gap: 8px; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.access-row select { max-width: 260px; }
.access-app { display: flex; align-items: center; gap: 8px; }
.access-app small { color: var(--muted); font-weight: 400; }
.danger-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.placeholder { display: flex; gap: 14px; align-items: flex-start; }
.placeholder > .icon { width: 28px; height: 28px; color: #7c3aed; }
.placeholder p { margin: 4px 0 0; }

.empty-page { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 64px 16px; text-align: center; }
.empty-page > .icon { width: 44px; height: 44px; color: var(--muted); }
.empty-page.small { padding: 24px; grid-column: 1 / -1; }

/* ---------- Phân quyền module (bố cục giống màn hình Phân quyền của QLVB) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.avatar.sm { width: 30px; height: 30px; font-size: 0.8rem; background: #e0ecff; color: var(--primary); }
.row-muted td { color: var(--muted); }
.seg { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.seg a { padding: 7px 14px; border-radius: 9px; color: var(--slate); font-weight: 600; font-size: 0.88rem; white-space: nowrap; }
.seg a.active { background: var(--primary-soft); color: var(--primary); }
.seg a:hover { text-decoration: none; }
.perm-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.perm-users { position: sticky; top: calc(var(--bar-h) + 16px); display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - var(--bar-h) - 40px); }
.perm-search input { width: 100%; padding: 9px 12px; border: 1px solid #d5deea; border-radius: 10px; font: inherit; }
.perm-user-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.perm-user { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid transparent; border-radius: 12px; color: var(--text); }
.perm-user:hover { background: #f5f9ff; text-decoration: none; }
.perm-user.active { background: var(--primary-soft); border-color: rgba(31, 111, 235, 0.25); }
.perm-user.inactive { opacity: 0.55; }
.perm-user-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.perm-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.perm-user-text small { color: var(--muted); font-size: 0.76rem; }
.perm-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.perm-head h2 { font-size: 1.25rem; }
.perm-head p { margin: 2px 0 0; }
.perm-copy { display: flex; gap: 8px; }
.perm-copy select { padding: 7px 10px; border: 1px solid #d5deea; border-radius: 10px; font: inherit; font-size: 0.86rem; }
.perm-table td { vertical-align: middle; }
.perm-table select { padding: 8px 10px; border: 1px solid #d5deea; border-radius: 10px; font: inherit; font-size: 0.88rem; min-width: 200px; }
.perm-module { display: flex; align-items: center; gap: 12px; }
.perm-module > span:last-child { display: flex; flex-direction: column; }
.perm-module small { color: var(--muted); font-size: 0.78rem; }
.perm-module-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 11px; background: rgb(var(--accent, 31 111 235) / 0.12); color: rgb(var(--accent, 31 111 235)); }
.perm-module.accent-amber .perm-module-icon, .matrix-app.accent-amber { --accent: 217 119 6; }
.perm-module.accent-violet .perm-module-icon, .matrix-app.accent-violet { --accent: 124 58 237; }
.perm-module.accent-sky .perm-module-icon, .matrix-app.accent-sky { --accent: 2 132 199; }
.perm-module.accent-teal .perm-module-icon, .matrix-app.accent-teal { --accent: 13 148 136; }
.perm-module.accent-emerald .perm-module-icon, .matrix-app.accent-emerald { --accent: 5 150 105; }
.perm-module.accent-rose .perm-module-icon, .matrix-app.accent-rose { --accent: 225 29 72; }
.form-actions .muted { margin-right: auto; align-self: center; }

.acct-input { width: 100%; min-width: 150px; padding: 8px 10px; border: 1px solid #d5deea; border-radius: 10px; font: inherit; font-size: 0.88rem; }
.acct-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 4px; border-radius: 50%; background: #e2e8f0; color: var(--slate); font-size: 0.68rem; cursor: help; }

/* Công tắc bật/tắt */
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-ui { width: 44px; height: 24px; border-radius: 999px; background: #cbd5e1; transition: background 0.18s ease; position: relative; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25); transition: transform 0.18s ease; }
.switch input:checked + .switch-ui { background: var(--success); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .switch-ui { opacity: 0.55; cursor: not-allowed; }

/* Ma trận tổng quan */
.matrix th.center, .matrix td.center { text-align: center; }
.matrix-app { display: inline-flex; align-items: center; gap: 6px; color: rgb(var(--accent, 71 85 105)); text-transform: none; letter-spacing: 0; font-size: 0.8rem; white-space: nowrap; }
.matrix-app .icon { width: 15px; height: 15px; }
.cell-on { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 0.78rem; font-weight: 700; }
.cell-on .icon { width: 14px; height: 14px; }
.cell-all { padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.76rem; font-weight: 700; }
.cell-off { color: #cbd5e1; }
.cell-role { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: #f3e8ff; color: #7c3aed; font-size: 0.78rem; font-weight: 700; }
.cell-role .icon { width: 14px; height: 14px; }
.matrix-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.role-note { display: block; margin-top: 4px; color: #7c3aed; font-size: 0.74rem; }
.toolbar select { max-width: 220px; }
.source-badge { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; background: #e0f2fe; color: #0369a1; }
.source-badge.portal { background: #f1f5f9; color: #475569; }

@media (max-width: 1280px) {
  .topbar-search { width: 170px; }
}
@media (max-width: 1100px) {
  .topbar-search { display: none; }
  .pill-link span { display: none; }
  .pill-link { width: 38px; padding: 0; justify-content: center; }
}
@media (max-width: 900px) {
  .brand-text { display: none; }
  .topbar-divider { display: none; }
  .topbar { gap: 10px; padding: 0 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .perm-layout { grid-template-columns: 1fr; }
  .perm-users { position: static; max-height: 320px; }
}
@media (max-width: 640px) {
  .app-tab span { display: none; }
  .app-tab { padding: 0 12px; }
  .page { padding: 18px 16px 36px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .access-row { flex-direction: column; align-items: stretch; }
  .access-row select { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- Thêm module ---- */
.field.span-all { grid-column: 1 / -1; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 18px; }
.choice-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line, #e2e8f0); border-radius: 12px; cursor: pointer; background: #fff; }
.choice-card:has(input:checked) { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.choice-card input { margin-top: 4px; }
.choice-card span { display: flex; flex-direction: column; gap: 4px; }
.choice-card small { color: #64748b; }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin-bottom: 18px; }
.icon-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; text-align: center; }
.icon-choice input { position: absolute; opacity: 0; pointer-events: none; }
.icon-choice-box { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; color: #334155; }
.icon-choice-box .icon { width: 22px; height: 22px; }
.icon-choice input:checked + .icon-choice-box { border-color: #2563eb; background: #eff6ff; color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.icon-choice input:focus-visible + .icon-choice-box { outline: 2px solid #2563eb; outline-offset: 2px; }
.icon-choice small { font-size: 0.74rem; color: #64748b; }
.checks.inline { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: flex-start; margin: 6px 0 4px; }

/* ---- Logo bệnh viện ---- */
.brand-mark { width: 38px; height: 38px; object-fit: contain; flex: none; }
.auth-brand.stacked { flex-direction: column; align-items: center; text-align: center; gap: 6px; margin-bottom: 14px; }
.auth-logo { width: 200px; height: auto; margin-bottom: 6px; }
@media (max-width: 480px) { .auth-logo { width: 160px; } }

/* Phân quyền website (Quản trị) */
.web-matrix th.center, .web-matrix td.center { text-align: center; }
.web-matrix th .sub { display: block; margin-top: 2px; color: #94a3b8; font-size: 0.68rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.web-matrix tr.web-group th { background: #f1f5f9; color: #334155; font-size: 0.78rem; }
.web-matrix td.wrap .sub { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-check { width: 18px; height: 18px; cursor: pointer; accent-color: #009247; }
.web-add-role .toolbar input { max-width: 280px; }
.web-scope { padding: 5px 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font: inherit; font-size: 0.8rem; }

/* Website nội bộ (Quản trị) */
.web-cat { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
.web-cat .web-side { display: flex; flex-direction: column; gap: 0; }
@media (min-width: 1100px) { .web-cat { grid-template-columns: minmax(0, 1fr) 420px; } }
.web-list .toolbar h2 { margin: 0; }
.web-list .toolbar input { max-width: 300px; }
.web-list tr.is-editing td { background: #f0fdf4; }
.web-list tr.is-off td { opacity: 0.6; }
.web-form { display: flex; flex-direction: column; gap: 12px; }
.web-active { align-self: end; padding-bottom: 10px; font-weight: 500; }
.web-scope-set { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.web-scope-set legend { padding: 0 6px; color: var(--slate); font-size: 0.82rem; font-weight: 700; }
.web-scope-set > .check { font-weight: 500; font-size: 0.88rem; }
.web-scope-set.is-public .web-pick, .web-scope-set.is-public .web-dept-pick { opacity: 0.45; pointer-events: none; }
.web-dept-pick { border-top: 1px dashed var(--line); padding-top: 8px; }
.web-dept-pick-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 7px; font-size: 0.86rem; }
.web-dept-pick-head input { margin-left: auto; width: 190px; max-width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 0.82rem; }
.web-dept-pick-list .js-dept-empty { margin: 4px 0; flex: 1 1 100%; }
.web-dept-pick-list { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 112px; overflow-y: auto; padding: 2px 4px 2px 0; }
.web-dept-pick-list .check { min-width: 180px; font-size: 0.85rem; font-weight: 600; }
.web-dept-pick-list .check small { margin-left: 2px; font-weight: 500; }
.web-pick { border-top: 1px dashed var(--line); padding-top: 8px; }
.web-pick-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.86rem; }
.web-pick-head input { margin-left: auto; max-width: 170px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 0.82rem; }
.web-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; padding-right: 4px; }
.web-pick-list .check { font-weight: 500; font-size: 0.86rem; }
.web-pick-list .check small { margin-left: 4px; }
.web-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.web-preview-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--slate); }
.web-preview select { min-width: 280px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.web-preview-result { flex-basis: 100%; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 0.88rem; }
.badge.violet { background: #f3e8ff; color: #7c3aed; }
.badge.amber { background: #fef3c7; color: #b45309; }
form.inline { display: inline; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: #fecaca; background: var(--danger-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.web-rows { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.web-rows li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.web-inline { display: flex; flex: 1; align-items: center; gap: 8px; }
.web-inline input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.web-inline input.web-sort { flex: 0 0 72px; }
.web-add { margin-top: 4px; }
.web-list tr.web-group th { background: #f1f5f9; color: #334155; font-size: 0.78rem; }

/* Ô mật khẩu có nút hiện / ẩn (portal.js) — ẩn nút riêng của Edge / IE để chỉ còn một nút, luôn hiển thị. */
input::-ms-reveal, input::-ms-clear { display: none; }
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 44px; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { background: #f1f5f9; color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pw-toggle[aria-pressed="true"] { color: var(--primary); }
.pw-toggle .icon { width: 18px; height: 18px; }

/* Thêm người dùng: tạo luôn tài khoản module, kết quả tạo, tên đăng nhập đã có */
.module-account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 10px 0 14px; }
.module-account { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fbfdff; }
.module-account-head { align-items: flex-start; }
.module-account-head input { margin-top: 3px; flex: none; }
.module-account-head small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.module-account-body { display: grid; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; max-height: 190px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pick-list .check { font-weight: 500; font-size: 0.86rem; }
.mail-choice { align-items: flex-start; margin: 4px 0 8px; }
.mail-choice small { display: block; font-weight: 400; }
.created-card, .conflict-card { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; border: 1px solid; }
.created-card { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.conflict-card { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }
.created-card h2, .conflict-card h2 { font-size: 1.05rem; margin: 0 0 10px; }
.created-card .temp-password { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; background: #fff; border-radius: 10px; border: 1px solid #bbf7d0; margin-bottom: 10px; }
.created-card code { font-size: 1.1rem; letter-spacing: 0.04em; }
.created-notes { margin: 6px 0 10px; padding-left: 20px; }
.mail-note { margin: 6px 0 12px; font-weight: 600; }
.mail-note.warn { color: var(--warning); }
.conflict-list { display: grid; gap: 8px; margin-bottom: 10px; }
.conflict-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; background: #fff; border-radius: 10px; border: 1px solid #fde68a; color: var(--text); margin-bottom: 8px; }
.conflict-options { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 10px; }
.conflict-options .muted { display: block; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
@media (max-width: 760px) { .module-account-grid { grid-template-columns: 1fr; } }

/* Menu Quản trị: 3 nhóm màu — Con người (xanh dương), Quyền truy cập (xanh ngọc), Hệ thống (xám) */
.admin-nav { display: grid; grid-template-columns: 1fr 3fr; gap: 12px; margin: 0 0 18px; }
.admin-nav-group { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: var(--panel); }
.admin-nav-title { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 8px 4px; color: var(--tone-ink); }
.admin-nav-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.admin-nav-item { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border-radius: 10px; background: var(--tone-soft); color: var(--tone-ink); text-decoration: none; border: 1px solid transparent; transition: border-color .15s, background .15s; }
.admin-nav-item:hover { border-color: var(--tone-line); text-decoration: none; }
.admin-nav-item strong { display: block; font-size: 0.88rem; line-height: 1.25; }
.admin-nav-item small { display: block; font-size: 0.72rem; color: var(--tone-sub); line-height: 1.3; margin-top: 2px; }
.admin-nav-icon { flex: none; display: inline-flex; width: 28px; height: 28px; border-radius: 8px; align-items: center; justify-content: center; background: #fff; color: var(--tone-ink); }
.admin-nav-icon svg { width: 16px; height: 16px; }
.admin-nav-item.active { background: var(--tone-ink); color: #fff; }
.admin-nav-item.active small { color: rgba(255, 255, 255, 0.82); }
.admin-nav-item.active .admin-nav-icon { background: rgba(255, 255, 255, 0.18); color: #fff; }
.tone-people { --tone-ink: #1d4f91; --tone-sub: #3b6fb6; --tone-soft: #e8f1fc; --tone-line: #9cc0ee; }
.tone-access { --tone-ink: #0b6152; --tone-sub: #178a74; --tone-soft: #e3f6f0; --tone-line: #8fd8c2; }
.tone-system { --tone-ink: #475569; --tone-sub: #64748b; --tone-soft: #f1f5f9; --tone-line: #cbd5e1; }
@media (max-width: 1100px) { .admin-nav { grid-template-columns: 1fr; } }

/* Thẻ module có màu riêng (cùng màu thẻ trang chủ) trong danh sách người dùng / trang chi tiết */
.mod-chip { display: inline-flex; align-items: center; gap: 5px; margin: 2px 4px 2px 0; padding: 3px 9px 3px 6px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap;
  background: rgb(var(--accent) / 0.12); color: rgb(var(--accent)); border: 1px solid rgb(var(--accent) / 0.22); }
.mod-chip svg { width: 13px; height: 13px; }
.mod-chip .mod-role { font-weight: 500; opacity: 0.9; }
.mod-chip.from-group { border-style: dashed; }
.mod-chip.warn { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.mod-chip.accent-amber { --accent: 217 119 6; } .mod-chip.accent-violet { --accent: 124 58 237; } .mod-chip.accent-sky { --accent: 2 132 199; }
.mod-chip.accent-teal { --accent: 13 148 136; } .mod-chip.accent-emerald { --accent: 5 150 105; } .mod-chip.accent-rose { --accent: 225 29 72; }
.head-actions { display: flex; flex: none; gap: 8px; align-items: center; }
.user-link { color: var(--text); }
.list-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 10px; }
.module-role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.module-role-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fbfdff; }
.module-role-card h3 { margin: 0 0 8px; font-size: 1rem; }
.module-role-now { margin: 6px 0 10px; }
.module-role-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.module-role-form select { min-width: 200px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
@media (max-width: 760px) { .module-role-grid { grid-template-columns: 1fr; } }
.cell-dept { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: #e3f6f0; color: #0b6152; font-size: 0.78rem; font-weight: 700; }
.cell-dept .icon { width: 14px; height: 14px; }
.reason-note { display: block; margin-top: 4px; color: #0b6152; font-size: 0.74rem; }
.sees-list { display: grid; gap: 8px; margin-bottom: 6px; }
.sees-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.sees-title { min-width: 150px; font-size: 0.8rem; font-weight: 700; color: var(--slate); }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
#web-table tr.web-group.is-system th { background: #e8f1fc; color: #1d4f91; }
.access-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 12px; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; }
.access-summary-label { font-weight: 700; font-size: 0.85rem; color: var(--slate); margin-right: 4px; }
.module-account-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); font-size: 0.82rem; }
.module-account-form label { font-weight: 600; color: var(--slate); }
.module-account-form input[name=LocalUsername] { flex: 1; min-width: 140px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }

/* ===== Website nội bộ: bảng tick theo nhóm màu ===== */
.tone-user { --g-ink: #92400e; --g-soft: #fef3c7; --g-line: #fcd34d; }
.wm-chip { display: inline-flex; align-items: center; margin: 2px 4px 2px 0; padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap;
  background: var(--g-soft); color: var(--g-ink); border: 1px solid var(--g-line); }
.wm-toolbar { flex-wrap: wrap; gap: 10px; }
.wm-toolbar .js-table-filter { max-width: 240px; }
.wm-filters { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.wm-filter { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--g-line, var(--line)); background: var(--g-soft, #fff);
  color: var(--g-ink, var(--text)); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.wm-filter span { font-weight: 600; opacity: 0.75; }
.wm-filter.is-on { background: var(--g-ink, var(--text)); color: #fff; border-color: transparent; }
.wm-filter.is-on span { opacity: 0.9; }
.wm-table th, .wm-table td { padding: 8px 8px; }
.wm-table thead th { white-space: nowrap; }
.wm-table thead .wm-head-2 th { font-size: 0.7rem; text-transform: none; letter-spacing: 0; white-space: normal; min-width: 74px; max-width: 110px; line-height: 1.25; }
.wm-table th.wm-kind-role { background: #eef4fd; color: #1d4f91; }
.wm-table th.wm-kind-dept { background: #ecf8f3; color: #0b6152; }
.wm-table th.wm-col-public, .wm-table td.wm-col-public { background: #f0fdf4; }
.wm-table tr.wm-group th { background: var(--g-soft); color: var(--g-ink); border-top: 2px solid var(--g-line); text-transform: none; letter-spacing: 0; font-size: 0.86rem; }
.wm-table tr.wm-group th small { font-weight: 500; opacity: 0.85; }
.wm-table tr.wm-row td:first-child { box-shadow: inset 4px 0 0 var(--g-line); }
.wm-table tr.wm-row:hover td { background: #fafcff; }
.wm-table tr.wm-row:hover td.wm-sticky { background: #fafcff; }
.wm-table tr.is-off td { opacity: 0.6; }
.wm-table tr.is-public td.wm-kind-role, .wm-table tr.is-public td.wm-kind-dept { opacity: 0.3; }
.wm-table tr.wm-out { display: none; }
.wm-name { min-width: 220px; max-width: 320px; }
.wm-name .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.wm-users { min-width: 240px; max-width: 340px; }
.wm-sticky { position: sticky; left: 0; z-index: 1; background: #fff; }
thead .wm-sticky { background: #f8fafc; z-index: 2; }
.wm-group-row { border-left: 4px solid var(--g-line); padding-left: 8px; }

/* ===== Popup (mở bằng đường dẫn, không cần JS) ===== */
/* Popup cuộn BÊN TRONG (tiêu đề và hàng nút luôn nhìn thấy), không bao giờ cao quá màn hình; trang phía sau đứng yên. */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px 16px; overflow: hidden; background: rgba(15, 23, 42, 0.45); }
.modal { --mp-y: 20px; --mp-x: 22px; width: min(680px, 100%); max-height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3); padding: var(--mp-y) var(--mp-x); display: flex; flex-direction: column; gap: 12px; }
.modal > * { flex-shrink: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal > .modal-head { position: sticky; top: calc(-1 * var(--mp-y)); z-index: 6; margin: calc(-1 * var(--mp-y)) calc(-1 * var(--mp-x)) 0; padding: 14px var(--mp-x) 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.modal > .form-actions { position: sticky; bottom: calc(-1 * var(--mp-y)); z-index: 6; margin: 4px calc(-1 * var(--mp-x)) calc(-1 * var(--mp-y)); padding: 12px var(--mp-x) 14px;
  background: var(--panel); border-top: 1px solid var(--line); }
.modal.modal-fill { height: 100%; }
.modal.modal-fill > .meta-scroll { flex: 1 1 auto; min-height: 160px; max-height: none; }
.modal.is-nudge { animation: modal-nudge 0.32s ease; }
@keyframes modal-nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@media (prefers-reduced-motion: reduce) { .modal.is-nudge { animation: none; } }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); font-size: 1.5rem; line-height: 1; text-decoration: none; }
.modal-close:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
body.has-modal { overflow: hidden; }

/* Ai vào được gì: cột theo nhóm website (màu), cột tên cố định khi cuộn ngang */
.am-table th.am-group { background: var(--g-soft); color: var(--g-ink); border-bottom: 2px solid var(--g-line); text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.am-table th.am-col { background: var(--g-soft); color: var(--g-ink); }
.am-table th.am-col span { display: block; min-width: 64px; max-width: 110px; white-space: normal; font-size: 0.68rem; line-height: 1.25; text-transform: none; letter-spacing: 0; }
.am-table td.am-cell { padding: 6px 4px; }
.am-table td.am-cell:nth-child(odd) { background: color-mix(in srgb, var(--g-soft) 35%, transparent); }
.am-user { min-width: 200px; }
.cell-public { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: #64748b; font-size: 0.78rem; }
.cell-public .icon { width: 14px; height: 14px; }
.am-table .cell-all { padding: 3px 7px; font-size: 0.7rem; }

/* ===== Responsive chung (điện thoại / máy tính bảng) ===== */
.table-wrap { position: relative; }            /* phần tử ẩn (sr-only) trong bảng không làm trang tràn ngang */
.page-head { flex-wrap: wrap; }
.seg { max-width: 100%; overflow-x: auto; }
.access-summary .mod-chip { white-space: normal; }
@media (max-width: 760px) {
  .page-head { gap: 12px; }
  .page-head h1 { font-size: 1.5rem; }
  .head-actions { flex-wrap: wrap; flex: 1 1 100%; }
  .head-actions .btn { flex: 1 1 auto; justify-content: center; }
  .admin-nav-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-nav-item small { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input[type=search], .toolbar select { flex: 1 1 100%; max-width: none; }
  .wm-toolbar .js-table-filter { max-width: none; }
  .web-preview select { flex: 1 1 100%; min-width: 0; }
  .web-inline { flex-wrap: wrap; }
  .web-rows li { flex-wrap: wrap; }
  .web-inline input[name=GroupName] { flex: 1 1 100%; }
  .modal { --mp-y: 16px; --mp-x: 16px; border-radius: 14px; }
  .modal-backdrop { padding: 10px 8px; }
  .grid-2 { grid-template-columns: 1fr; }
  .module-role-form select { min-width: 0; flex: 1 1 100%; }
  .wm-name { min-width: 140px; max-width: 160px; }
  .wm-name .sub { max-width: 140px; }
  .wm-name .badge { display: none; }
  .wm-table tr.wm-group th small { display: none; }
  .am-user { min-width: 150px; }
  .form-actions { flex-wrap: wrap; }
}

/* ===== Website nội bộ: bảng người × website — ghim 3 hàng tiêu đề + cột tên người ===== */
.wm-scroll { overflow: auto; max-height: calc(100vh - var(--bar-h) - 150px); min-height: 320px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.wm-users-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.wm-users-table th, .wm-users-table td { padding: 6px 6px; border-bottom: 1px solid var(--line); background-clip: padding-box; }
.wm-users-table thead th { position: sticky; z-index: 3; box-sizing: border-box; }
.wm-users-table thead tr.wm-h1 th { top: 0; height: 34px; }
.wm-users-table thead tr.wm-h2 th { top: 34px; height: 66px; }
.wm-users-table thead tr.wm-h3 th { top: 100px; height: 32px; }
.wm-users-table th.wm-corner { left: 0; top: 0; z-index: 5; min-width: 220px; background: #f8fafc; vertical-align: bottom; border-right: 1px solid var(--line); }
.wm-users-table th.wm-gh { background: var(--g-soft); color: var(--g-ink); border-bottom: 2px solid var(--g-line); text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.wm-users-table th.wm-site { background: var(--g-soft); width: 86px; min-width: 86px; max-width: 86px; vertical-align: bottom; text-transform: none; letter-spacing: 0; }
.wm-users-table th.wm-site a { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--g-ink); font-size: 0.7rem; font-weight: 700; line-height: 1.25; }
.wm-users-table th.wm-site.is-off a { opacity: 0.55; text-decoration: line-through; }
.wm-mod { display: inline-block; margin-top: 2px; padding: 0 5px; border-radius: 6px; background: #1d4f91; color: #fff; font-size: 0.6rem; }
.wm-users-table th.wm-pub { background: #f0fdf4; }
.wm-users-table th.wm-pub label { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; }
.wm-users-table th.wm-pub span { font-size: 0.58rem; color: #15803d; text-transform: none; letter-spacing: 0; }
.wm-users-table th.wm-uname { position: sticky; left: 0; z-index: 2; background: #fff; text-align: left; min-width: 220px; max-width: 260px; border-right: 1px solid var(--line);
  text-transform: none; letter-spacing: 0; font-size: 0.86rem; color: var(--text); }
.wm-users-table th.wm-uname .sub { font-weight: 400; color: var(--muted); font-size: 0.74rem; }
.wm-detail { font-size: 0.72rem; font-weight: 600; }
.wm-users-table td.wm-cell { text-align: center; }
.wm-users-table tr.wm-urow:hover td, .wm-users-table tr.wm-urow:hover th.wm-uname { background: #f5f9ff; }
.wm-users-table td.wm-cell:nth-child(even) { background: color-mix(in srgb, var(--g-soft) 40%, #fff); }
.wm-users-table td.is-pub input { opacity: 0.25; }

/* ===== Phân quyền theo một người: danh sách dọc ===== */
.wp-person-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 20px; margin-bottom: 12px; }
.wp-person-head h2 { margin: 4px 0 0; font-size: 1.2rem; }
.wp-person-head h2 small { font-size: 0.8rem; font-weight: 500; }
.wp-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; background: #f8fafc; }
.wp-copy label[for] { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.85rem; color: var(--slate); }
.wp-copy select { min-width: 220px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
.wp-toolbar input[type=search] { flex: 1 1 260px; }
.wp-group { margin: 10px 0; border: 1px solid var(--g-line); border-radius: 12px; overflow: hidden; }
.wp-group-head { padding: 8px 12px; background: var(--g-soft); color: var(--g-ink); font-weight: 700; font-size: 0.88rem; }
.wp-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.wp-item:hover { background: #fafcff; }
.wp-item input[type=checkbox] { margin-top: 2px; flex: none; }
.wp-item-text strong { font-size: 0.9rem; }
.wp-item-text .sub { display: block; color: var(--muted); font-size: 0.76rem; word-break: break-all; }
.wp-item.is-off { opacity: 0.6; }
.sticky-actions { position: sticky; bottom: 0; z-index: 4; background: var(--panel); padding: 12px 0 4px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .wm-users-table th.wm-corner, .wm-users-table th.wm-uname { min-width: 140px; max-width: 150px; }
  .wm-users-table th.wm-uname .sub { display: none; }
  .wm-scroll { max-height: calc(100vh - var(--bar-h) - 120px); }
  .wp-copy { flex: 1 1 100%; min-width: 0; }
  .wp-copy select { min-width: 0; width: 100%; max-width: 100%; flex: 1 1 100%; }
}

/* Nút Quay lại (mọi màn hình trừ trang chủ) */
.back-bar { margin: 0 0 10px; }
.btn-back { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 5px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--slate); font-size: 0.85rem; font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color .15s, color .15s, box-shadow .15s; }
.btn-back-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); transition: transform .15s, background .15s, color .15s; }
.btn-back-icon .icon { width: 15px; height: 15px; }
.btn-back:hover { border-color: rgba(31, 111, 235, 0.35); color: var(--text); text-decoration: none; box-shadow: 0 2px 8px rgba(31, 111, 235, 0.12); }
.btn-back:hover .btn-back-icon { background: var(--primary); color: #fff; transform: translateX(-2px); }
.btn-back:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.shell-back { font-weight: 700; }
.shell-back .icon { width: 15px; height: 15px; }

.wp-group-head { display: flex; align-items: center; gap: 8px; }
.wp-group-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Thẻ thông tin người dùng (trang phân quyền theo người) */
.person-card { display: flex; align-items: flex-start; gap: 14px; flex: 1 1 420px; min-width: 0; }
.person-avatar { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, #1f6feb, #0d9488);
  color: #fff; font-weight: 800; font-size: 1.1rem; letter-spacing: 0.02em; }
.person-main { min-width: 0; flex: 1; }
.person-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.person-name h2 { margin: 0; font-size: 1.25rem; }
.person-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 18px; margin: 10px 0 8px; }
.person-facts div { min-width: 0; }
.person-facts dt { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.person-facts dt .icon { width: 13px; height: 13px; }
.person-facts dd { margin: 2px 0 0; font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-facts code { font-size: 0.85rem; background: #f1f5f9; padding: 1px 6px; border-radius: 6px; }
@media (max-width: 760px) {
  .person-card { gap: 10px; }
  .person-avatar { width: 42px; height: 42px; border-radius: 13px; font-size: 0.95rem; }
  .person-name h2 { font-size: 1.1rem; }
  .person-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
}

/* Trang người dùng: khung "Module được vào" + nút Phân quyền chi tiết website */
.access-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.access-summary-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; flex: 1 1 380px; min-width: 0; }
.access-summary-note { flex: 1 1 100%; margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }
.btn-access { display: inline-flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: 14px; text-decoration: none;
  background: linear-gradient(135deg, #1f6feb, #0d9488); color: #fff; box-shadow: 0 6px 16px rgba(31, 111, 235, 0.25); transition: transform .15s, box-shadow .15s; }
.btn-access:hover { text-decoration: none; color: #fff; transform: translateY(-1px); box-shadow: 0 10px 22px rgba(31, 111, 235, 0.32); }
.btn-access:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.btn-access strong { display: block; font-size: 0.92rem; }
.btn-access small { display: block; font-size: 0.74rem; opacity: 0.88; }
.btn-access > .icon { width: 18px; height: 18px; transition: transform .15s; }
.btn-access:hover > .icon { transform: translateX(3px); }
.btn-access-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: rgba(255, 255, 255, 0.2); }
.btn-access-icon .icon { width: 19px; height: 19px; }
@media (max-width: 760px) { .btn-access { flex: 1 1 100%; } }

.access-warn { flex: 1 1 100%; display: flex; align-items: flex-start; gap: 8px; margin: 6px 0 0; padding: 8px 10px; border: 1px solid #fde68a; border-radius: 10px;
  background: var(--warning-soft); color: #78350f; font-size: 0.82rem; }
.access-warn .icon { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--warning); }
.access-warn code { font-size: 0.8rem; background: #fff; padding: 0 5px; border-radius: 5px; }

/* Số website được phân quyền (trang người dùng) */
.access-count { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 1rem; font-weight: 600; color: var(--text); }
.access-count-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); }
.access-count-icon .icon { width: 22px; height: 22px; }
.access-count-num { font-size: 1.7rem; font-weight: 800; color: var(--primary); letter-spacing: -0.01em; margin: 0 2px; }
.access-count-num span { font-size: 1.05rem; font-weight: 700; color: var(--muted); }

/* Bảng người × website: cột người dùng gọn, tên website xuống dòng (không cắt chữ) */
.wm-users-table thead tr.wm-h2 th { height: 78px; }
.wm-users-table thead tr.wm-h3 th { top: 112px; }
.wm-users-table th.wm-site { white-space: normal; width: 96px; min-width: 96px; max-width: 96px; }
.wm-users-table th.wm-site a { -webkit-line-clamp: 4; word-break: break-word; }
.wm-uname-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wm-uname-text { min-width: 0; display: flex; flex-direction: column; }
.wm-uname-text strong { font-size: 0.88rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-uname-text small { margin-top: 1px; font-size: 0.74rem; font-weight: 400; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-detail { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--slate); }
.wm-detail .icon { width: 15px; height: 15px; }
.wm-detail:hover { background: var(--primary-soft); color: var(--primary); border-color: rgba(31, 111, 235, 0.3); text-decoration: none; }
.wm-users-table th.wm-uname { min-width: 230px; max-width: 260px; }
@media (max-width: 760px) { .wm-users-table th.wm-uname { min-width: 150px; max-width: 160px; } .wm-uname-text small { display: none; } }
/* Ô tick "Công khai" ở hàng tiêu đề: căn giữa cột */
.wm-users-table th.wm-pub { text-align: center; vertical-align: middle; }
.wm-users-table th.wm-pub label { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; margin: 0 auto; }
.wm-users-table th.wm-pub input { margin: 0; }
.wm-users-table td.wm-cell input { display: block; margin: 0 auto; }
/* Tiêu đề bảng người × website: tên nhóm và tên website căn giữa cột */
.wm-users-table thead th.wm-gh, .wm-users-table thead th.wm-site { text-align: center; }
.wm-users-table th.wm-site a { text-align: center; margin: 0 auto; }
.wm-users-table th.wm-site .wm-mod { display: table; margin: 3px auto 0; }

/* ===== Màu nhóm website — MỘT bảng màu cho mọi màn hình (Services/GroupColors.cs). gc-{mã}: biến trang chủ (--acc…) + quản trị (--g-…) ===== */
.gc-emerald { --acc: #009247; --acc2: #34d399; --acc-soft: #e6f5ec; --g-ink: #047857; --g-soft: #e6f5ec; --g-line: #86efac; }
.gc-blue { --acc: #2563eb; --acc2: #60a5fa; --acc-soft: #e8f0fe; --g-ink: #1d4ed8; --g-soft: #e8f0fe; --g-line: #93c5fd; }
.gc-orange { --acc: #ea580c; --acc2: #fb923c; --acc-soft: #fff1e7; --g-ink: #c2410c; --g-soft: #fff1e7; --g-line: #fdba74; }
.gc-violet { --acc: #7c3aed; --acc2: #a78bfa; --acc-soft: #f3edff; --g-ink: #6d28d9; --g-soft: #f3edff; --g-line: #c4b5fd; }
.gc-rose { --acc: #e11d48; --acc2: #fb7185; --acc-soft: #fdeaf0; --g-ink: #be123c; --g-soft: #fdeaf0; --g-line: #fda4af; }
.gc-teal { --acc: #0d9488; --acc2: #2dd4bf; --acc-soft: #e3f7f5; --g-ink: #0f766e; --g-soft: #e3f7f5; --g-line: #5eead4; }
.gc-amber { --acc: #d97706; --acc2: #fbbf24; --acc-soft: #fff5e0; --g-ink: #b45309; --g-soft: #fff5e0; --g-line: #fcd34d; }
.gc-indigo { --acc: #4f46e5; --acc2: #818cf8; --acc-soft: #ecebfd; --g-ink: #4338ca; --g-soft: #ecebfd; --g-line: #a5b4fc; }
.gc-pink { --acc: #db2777; --acc2: #f472b6; --acc-soft: #fdebf4; --g-ink: #be185d; --g-soft: #fdebf4; --g-line: #f9a8d4; }
.gc-sky { --acc: #0284c7; --acc2: #38bdf8; --acc-soft: #e6f4fc; --g-ink: #0369a1; --g-soft: #e6f4fc; --g-line: #7dd3fc; }
.gc-lime { --acc: #65a30d; --acc2: #a3e635; --acc-soft: #f1f8e3; --g-ink: #4d7c0f; --g-soft: #f1f8e3; --g-line: #bef264; }
.gc-fuchsia { --acc: #c026d3; --acc2: #e879f9; --acc-soft: #fcf0fd; --g-ink: #a21caf; --g-soft: #fcf0fd; --g-line: #f0abfc; }
.gc-cyan { --acc: #0891b2; --acc2: #22d3ee; --acc-soft: #e2f6fa; --g-ink: #0e7490; --g-soft: #e2f6fa; --g-line: #67e8f9; }
.gc-brown { --acc: #92582a; --acc2: #c8925c; --acc-soft: #f6eee6; --g-ink: #7c4a1e; --g-soft: #f6eee6; --g-line: #dcbf9f; }
.gc-slate { --acc: #475569; --acc2: #94a3b8; --acc-soft: #eef2f6; --g-ink: #334155; --g-soft: #eef2f6; --g-line: #cbd5e1; }
.gc-swatch { flex: none; width: 18px; height: 18px; border-radius: 6px; background: var(--acc); box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.web-color { flex: 0 0 auto; max-width: 200px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 0.82rem; background: #fff; }

.field-warn { color: var(--warning) !important; font-weight: 600; }
.wm-nourl { display: table; margin: 3px auto 0; padding: 0 5px; border-radius: 6px; background: var(--warning-soft); color: var(--warning); font-size: 0.58rem; font-weight: 700; text-transform: none; letter-spacing: 0; }

/* Thanh menu: lối tắt tới mục đã ghim (màu theo nhóm) */
.app-tab.app-pin .icon { color: var(--acc); }
.app-tab.app-pin.active { background: var(--acc-soft); color: var(--g-ink); }
.app-tab.app-pin span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tabs-hint { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; color: #94a3b8; font-size: 0.8rem; white-space: nowrap; }
.app-tabs-hint .icon { width: 14px; height: 14px; color: #f59e0b; }
.app-tabs-hint[hidden] { display: none !important; }
@media (max-width: 900px) { .app-tabs-hint { display: none; } }

/* ===== Chuông thông báo (văn bản chưa xem trong QLVB) ===== */
.bell-menu { position: relative; }
.bell-menu summary {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%;
  background: #fff; color: #64748b; cursor: pointer; list-style: none; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.bell-menu summary::-webkit-details-marker { display: none; }
.bell-menu summary:hover { background: #f8fafc; border-color: #cbd5e1; }
.bell-menu summary:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.bell-menu summary .icon { width: 19px; height: 19px; }
.bell-menu.has-new summary { color: #b45309; border-color: #fcd34d; background: #fffbeb; }
.bell-menu.has-new summary .icon { animation: bell-ring 2.4s ease-in-out 1; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-12deg); } 50% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .bell-menu.has-new summary .icon { animation: none; } }
.bell-count {
  position: absolute; top: -5px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid #fff; border-radius: 999px;
  background: #dc2626; color: #fff; font-size: 0.68rem; font-weight: 800; line-height: 15px; text-align: center;
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; width: min(340px, calc(100vw - 24px)); padding: 8px;
  background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}
.bell-head { margin: 4px 8px 8px; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bell-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 10px; color: var(--text); background: #f0fdf4; }
.bell-item:hover { background: #dcfce7; text-decoration: none; }
.bell-ic { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #34d399, #009247); color: #fff; }
.bell-ic .icon { width: 17px; height: 17px; }
.bell-text { display: grid; gap: 2px; min-width: 0; }
.bell-text strong { font-size: 0.9rem; }
.bell-text small { color: var(--muted); font-size: 0.78rem; }
.bell-empty { margin: 4px 8px 8px; color: var(--muted); font-size: 0.86rem; }
.bell-empty[hidden], .bell-item[hidden] { display: none; }

/* Nhãn "N chưa xem" trên thẻ Quản lý văn bản ở trang chủ (bấm = mở danh sách chưa xem). */
.hm-unread {
  flex: none; align-self: center; margin-right: 2px; padding: 2px 9px; border-radius: 999px; background: #dc2626; color: #fff;
  font-size: 0.72rem; font-weight: 800; line-height: 18px; white-space: nowrap; box-shadow: 0 4px 10px -4px rgba(220, 38, 38, 0.6);
}
.hm-unread:hover { background: #b91c1c; color: #fff; text-decoration: none; }
@media (max-width: 560px) {
  .bell-menu { position: static; }
  .bell-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}

/* Thanh công cụ khung module: không xuống dòng; tên module co lại (…); màn hình nhỏ chỉ còn biểu tượng. */
.shell-toolbar { min-width: 0; }
.shell-tool { flex: none; white-space: nowrap; }
.shell-title { flex: 1 1 auto; justify-content: center; min-width: 0; }
.shell-title .icon { flex: none; }
.shell-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) {
  .shell-toolbar { padding: 0 10px; gap: 8px; }
  .shell-tool { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .shell-tool-text { display: none; }
  .shell-tool .icon, .shell-back .icon { width: 16px; height: 16px; }
}

/* ===== Website nội bộ: thông tin phân loại (Phân nguồn · Hình thức · Khoa phòng quản lý) ===== */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.web-meta-note { margin: -4px 0 10px; }
.modal.modal-wide { width: min(1040px, calc(100vw - 24px)); max-width: none; }
.meta-scroll { max-height: calc(100vh - 290px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.meta-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.meta-table thead th { position: sticky; top: 0; z-index: 1; padding: 9px 10px; background: #f8fafc; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.meta-table td { padding: 7px 10px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.meta-table tr:last-child td { border-bottom: 0; }
.meta-table td.meta-name { border-left: 4px solid var(--g-line, #cbd5e1); min-width: 220px; }
.meta-table td.meta-name a { color: var(--text); }
.meta-table td.meta-name .sub { display: block; color: var(--muted); font-size: 0.76rem; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-table select { width: 100%; min-width: 150px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 0.85rem; background: #fff; }
.meta-table tr.is-off td.meta-name strong { color: var(--muted); }
.wm-group-row.is-off .dept-name { color: var(--muted); }
.dept-facts { flex: none; white-space: nowrap; }
.web-inline .dept-name { flex: 1 1 180px; min-width: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr; }
  .meta-table thead { display: none; }
  .meta-table, .meta-table tbody, .meta-table tr, .meta-table td { display: block; }
  .meta-table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .meta-table td { border: 0; padding: 4px 10px; }
  .meta-table td.meta-name { border-left-width: 4px; }
}

/* Nút thao tác có biểu tượng màu (thanh công cụ Đồng bộ tài khoản): nổi hơn nút thường, mỗi việc một màu để dễ nhận. */
.btn.btn-tool { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 12px; font-size: 0.86rem; font-weight: 700;
  border-color: var(--t-line); background: var(--t-soft); color: var(--t-ink); transition: transform .15s, box-shadow .15s, background .15s; }
.btn-tool-ic { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--t-main); color: #fff; }
.btn-tool-ic .icon { width: 15px; height: 15px; }
.btn.btn-tool:hover { transform: translateY(-1px); border-color: var(--t-main); box-shadow: 0 6px 14px -6px var(--t-main); text-decoration: none; }
.btn.btn-tool:focus-visible { outline: 2px solid var(--t-main); outline-offset: 2px; }
.btn.btn-tool.is-on { background: var(--t-main); border-color: var(--t-main); color: #fff; }
.btn.btn-tool.is-on .btn-tool-ic { background: rgba(255, 255, 255, 0.22); }
.tool-blue { --t-main: #2563eb; --t-soft: #eff6ff; --t-line: #bfdbfe; --t-ink: #1e40af; }
.tool-green { --t-main: #059669; --t-soft: #ecfdf5; --t-line: #a7f3d0; --t-ink: #065f46; }
.tool-amber { --t-main: #d97706; --t-soft: #fffbeb; --t-line: #fde68a; --t-ink: #92400e; }
.tool-violet { --t-main: #7c3aed; --t-soft: #f5f3ff; --t-line: #ddd6fe; --t-ink: #5b21b6; }
/* Dòng thống kê nhường chỗ (tự xuống dòng) để 3 nút nằm cùng một hàng. */
.toolbar:has(.btn-tool) .count { flex: 1 1 220px; min-width: 0; margin-left: 0; }
@media (max-width: 720px) { .toolbar form:has(> .btn-tool), .toolbar > .btn.btn-tool { flex: 1 1 100%; } .toolbar form > .btn-tool { width: 100%; } }

/* Bảng phân quyền: ô tìm website (ẩn / hiện cột). */
.wm-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.wm-filter-label { display: inline-flex; align-items: center; gap: 6px; color: #334155; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.wm-filter-label .icon { width: 15px; height: 15px; color: var(--primary); }
.wm-toolbar .wm-filter input { width: 190px; max-width: 100%; background: #fff; }
.wm-toolbar .wm-filter input.js-wm-site-filter { width: 240px; }
.wm-toolbar .wm-filter select { width: 220px; max-width: 100%; background-color: #fff; }
@media (max-width: 720px) { .wm-filter { flex: 1 1 100%; } .wm-toolbar .wm-filter input, .wm-toolbar .wm-filter select { flex: 1 1 140px; width: auto; } }
.wm-users-table [hidden] { display: none !important; }

/* Popup "Thông tin website": ô tìm nhanh. */
.meta-toolbar { margin-bottom: 10px; }
.meta-toolbar input[type="search"] { flex: 1 1 320px; max-width: none; }
.meta-table tr[hidden] { display: none !important; }

/* ===== Nút thường (không phải nút chính): có màu nền để tách khỏi nền trắng của trang ===== */
.btn:not(.primary):not(.btn-tool) { background: #eef4ff; border-color: #c3d4f7; color: #1d3f8f; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:not(.primary):not(.btn-tool):hover { background: #dfeaff; border-color: #7ea6f0; box-shadow: 0 4px 10px -6px rgba(31, 111, 235, 0.55); }
.btn:not(.primary):not(.btn-tool) .icon { color: var(--primary); }
/* Hủy / Đóng (liên kết trong hàng nút cuối form, nút đóng khác): xám trung tính — không tranh chú ý với nút thao tác. */
.form-actions a.btn:not(.primary):not(.btn-tool), .btn.ghost { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
.form-actions a.btn:not(.primary):not(.btn-tool):hover, .btn.ghost:hover { background: #e2e8f0; border-color: #94a3b8; box-shadow: none; }
/* Xóa / thao tác nguy hiểm: đỏ nhạt. */
.btn.danger:not(.primary) { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn.danger:not(.primary):hover { background: #fee2e2; border-color: #f87171; box-shadow: none; }
.btn.danger .icon { color: inherit; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ===== Ô chọn có tìm kiếm (select.js-combo) ===== */
select.combo-native { position: absolute; left: 0; top: 0; width: 1px !important; height: 1px; min-width: 0; opacity: 0; pointer-events: none; }
.combo { position: relative; display: inline-block; min-width: 0; }
.field .combo, .grid-3 .combo { display: block; width: 100%; }
.combo-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 7px 10px 7px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); font: inherit; font-size: 0.88rem; font-weight: 600; text-align: left; cursor: pointer; }
.combo-btn:hover { border-color: #94a3b8; }
.combo-btn:focus-visible, .combo.is-open .combo-btn { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.combo-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-caret { flex: none; width: 16px; height: 16px; color: #64748b; transition: transform 0.15s; }
.combo.is-open .combo-caret { transform: rotate(180deg); }
.combo-pop { position: absolute; z-index: 80; top: calc(100% + 6px); left: 0; width: max(100%, 300px); max-width: min(380px, calc(100vw - 24px)); padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18); }
.combo-pop[hidden] { display: none; }
.combo-q { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 0.86rem; }
.combo-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 280px; overflow-y: auto; }
.combo-list li { display: flex; align-items: baseline; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: 0.86rem; cursor: pointer; }
.combo-list li span { flex: 1 1 auto; min-width: 0; }
.combo-list li small { flex: none; color: var(--muted); font-size: 0.75rem; }
.combo-list li.is-all { font-weight: 700; border-bottom: 1px dashed var(--line); border-radius: 8px 8px 0 0; margin-bottom: 2px; }
.combo-list li.is-pin { color: #64748b; font-style: italic; border-top: 1px dashed var(--line); border-radius: 0 0 8px 8px; margin-top: 2px; }
.combo-list li.is-active { background: #eff6ff; color: #1d4ed8; }
.combo-list li[aria-selected="true"] { font-weight: 700; }
.combo-list li[aria-selected="true"]::after { content: "✓"; color: var(--primary); font-weight: 800; }
.combo-empty { margin: 8px 4px 2px; color: var(--muted); font-size: 0.82rem; }
.wm-toolbar .wm-filter .combo { width: 230px; max-width: 100%; }
.modal .combo-pop { width: 100%; max-width: none; }
@media (max-width: 760px) {
  .toolbar .combo, .wm-toolbar .wm-filter .combo { flex: 1 1 100%; width: auto; }
  .combo-pop { width: 100%; max-width: none; }
}

/* ===== Chuông: khối "Website mới" ===== */
.bell-web { background: #fff7ed; cursor: default; }
.bell-web:hover { background: #fff7ed; }
.bell-ic-web { background: linear-gradient(135deg, #fb923c, #ea580c); }
.bell-web-list { display: grid; gap: 4px; margin-top: 6px; max-height: 240px; overflow-y: auto; }
.bell-web-link { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; background: #fff; color: var(--text); text-decoration: none; }
.bell-web-link:hover { background: #ffedd5; text-decoration: none; }
.bell-web-link b { font-size: 0.84rem; }
.bell-web-link small { color: var(--muted); font-size: 0.74rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bell-web-more { color: var(--muted); font-size: 0.74rem; padding: 2px 8px; }
.bell-seen { justify-self: start; margin-top: 6px; padding: 4px 10px; border: 1px solid #fdba74; border-radius: 8px; background: #fff; color: #c2410c; font: inherit; font-size: 0.76rem; font-weight: 700; cursor: pointer; }
.bell-seen:hover { background: #ffedd5; }
.bell-seen:disabled { opacity: 0.6; cursor: wait; }
.bell-web[hidden] { display: none; }
