@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --bg: #faf8f5;
  --card: #ffffff;
  --border: #ece6dd;
  --border-strong: #dbd2c5;
  --primary: #d40d12;
  --primary-dark: #7b090c;
  --primary-mid: #b00b10;
  --primary-light: #fdeded;
  --accent: #ffe600;
  --accent-light: #fff9c2;
  --scarf-red: #d90d11;
  --scarf-yellow: #ffec0a;
  --ok: #15803d;
  --ok-light: #dcfce7;
  --text: #211616;
  --muted: #756a68;
  --shadow-sm: 0 1px 2px rgba(33,22,22,.05), 0 6px 16px -8px rgba(33,22,22,.14);
  --shadow-md: 0 22px 46px -24px rgba(123,9,12,.45);
  --ring: 0 0 0 3px rgba(212,13,18,.18);
  --hero-bg:
    radial-gradient(60% 90% at 100% 0%, rgba(255,236,10,.22), transparent 62%),
    linear-gradient(160deg, #a30a0e, #d40d12 58%, #e72322);
  --topbar-h: 53px;
  --radius: 18px;

  --badge-tim-bg: #ede9fe; --badge-tim-fg: #7c3aed;
  --badge-xanh-duong-bg: #dbeafe; --badge-xanh-duong-fg: #2563eb;
  --badge-xanh-ngoc-bg: #cffafe; --badge-xanh-ngoc-fg: #0891b2;
  --badge-do-bg: #fee2e2; --badge-do-fg: #dc2626;
  --badge-xam-bg: #f1f5f9; --badge-xam-fg: #64748b;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(212,13,18,.2); }

/* ---- icon SVG net mong, thay cho emoji ---- */
.icon { width: 1em; height: 1em; vertical-align: -0.15em; flex-shrink: 0; }

/* ---- thanh dieu huong tren cung, xuat hien o moi trang ---- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 10px 18px; background: rgba(255,255,255,.82); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.5) blur(14px); -webkit-backdrop-filter: saturate(1.5) blur(14px);
  font-size: .85rem; position: sticky; top: 0; z-index: 30;
}
.topbar::-webkit-scrollbar { display: none; }
.topbar-brand {
  font-weight: 800; color: var(--text); display: inline-flex; align-items: center; gap: 9px;
  letter-spacing: -.01em; flex-shrink: 0; white-space: nowrap;
}
.topbar-brand:hover { color: var(--primary); text-decoration: none; }
.topbar-sep { color: var(--border-strong); flex-shrink: 0; }
.topbar-crumb {
  color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 45vw; flex-shrink: 1;
}
.topbar-crumb:hover { color: var(--primary); }
.topbar-crumb-current { color: var(--text); }
.topbar-logout { margin-left: auto; flex-shrink: 0; }
.topbar-logout button {
  border: 1px solid var(--border); background: var(--card); color: var(--muted); font: inherit; font-size: .78rem; font-weight: 600;
  cursor: pointer; padding: 5px 12px; border-radius: 999px; transition: background .15s, color .15s, border-color .15s;
}
.topbar-logout button:hover { background: var(--primary-light); color: var(--primary-mid); border-color: transparent; }

/* logo nho (hinh leu tren nen gradient) dung o thanh tren, dang nhap, trang chu */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  background: var(--scarf-red); box-shadow: 0 4px 10px -3px rgba(176,11,16,.5);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-mark-lg { width: 60px; height: 60px; border-radius: 19px; box-shadow: 0 14px 28px -10px rgba(60,4,6,.6); }
.brand-mark-lg svg { width: 38px; height: 38px; }

/* ============ HERO (trang chuong trinh + trang chu) ============ */
.hero, .home-hero {
  position: relative; overflow: hidden; color: white; text-align: left; background: var(--hero-bg);
}
.hero::after, .home-hero::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 9px; height: 5px; background: var(--scarf-yellow); /* vạch vàng chạy dọc mép khăn */
}
.hero { padding: 52px 20px 96px; }
.hero .badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 5px 14px; font-size: .74rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: 14px; backdrop-filter: blur(4px);
}
.hero h1 { font-size: 2.2rem; margin: 4px 0 10px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.hero p { opacity: .82; max-width: 640px; line-height: 1.6; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* ---- thanh so lieu noi (4 cot), noi len tren mep duoi cua hero ---- */
.stats {
  position: relative; z-index: 2; margin-top: -46px;
  display: flex; flex-wrap: wrap;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-md); border: 1px solid rgba(255,255,255,.6);
}
.stats .stat {
  flex: 1 1 130px; display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; border-right: 1px solid var(--border);
}
.stats .stat:last-child { border-right: none; }
.stats .stat-icon {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.stats .stat-icon .icon { width: 18px; height: 18px; }
.stats .stat b { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.stats .stat span { font-size: .76rem; color: var(--muted); }

/* ---- tab dang pill (dung chung: trang chuong trinh + trang admin) ---- */
.tab-bar {
  display: inline-flex; gap: 3px; padding: 4px; background: var(--card);
  border: 1px solid var(--border); border-radius: 999px; margin: 22px 0 20px; box-shadow: var(--shadow-sm);
  overflow-x: auto; scrollbar-width: none; max-width: 100%;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; white-space: nowrap; background: none; border: none; cursor: pointer;
  font-size: .85rem; font-weight: 700; color: var(--muted);
  padding: 9px 18px; border-radius: 999px; transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: white; background: var(--primary); box-shadow: 0 4px 12px -4px rgba(212,13,18,.6); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in .18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---- o tim kiem ---- */
.search-box {
  position: relative; max-width: 360px; margin-bottom: 18px;
}
.search-box .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 10px 14px 10px 38px; border: 1px solid var(--border);
  border-radius: 10px; font-size: .88rem; font-family: inherit; background: var(--card); color: var(--text);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

section { margin: 36px 0; }
section h2 { font-size: 1.15rem; margin-bottom: 4px; font-weight: 800; letter-spacing: -.015em; }
section .sub { color: var(--muted); font-size: .88rem; margin-bottom: 16px; }

/* ---- danh sach nhan su ---- */
.grid-nhansu {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr)); gap: 12px;
}
.nhansu-card {
  position: relative;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.nhansu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  z-index: 2;
}
.nhansu-card .name { font-weight: 700; font-size: .92rem; }
.nhansu-card .meta { font-size: .78rem; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nhansu-card .info { flex: 1; min-width: 0; }
.nhansu-card .card-arrow { color: var(--border); flex-shrink: 0; transition: color .15s, transform .15s; }
.nhansu-card:hover .card-arrow { color: var(--primary); transform: translateX(2px); }
.link-like {
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: left;
}
.link-like:hover { color: var(--primary); text-decoration: underline; }

/* ---- badge cap hieu, mau theo tung cap ---- */
.badge-cap {
  display: inline-flex; align-items: center; font-size: .68rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; letter-spacing: .01em; white-space: nowrap;
}
.badge-tim { background: var(--badge-tim-bg); color: var(--badge-tim-fg); }
.badge-xanh-duong { background: var(--badge-xanh-duong-bg); color: var(--badge-xanh-duong-fg); }
.badge-xanh-ngoc { background: var(--badge-xanh-ngoc-bg); color: var(--badge-xanh-ngoc-fg); }
.badge-do { background: var(--badge-do-bg); color: var(--badge-do-fg); }
.badge-xam { background: var(--badge-xam-bg); color: var(--badge-xam-fg); }

/* ---- avatar dang nut bam (mo popup) - hover nhe nhang hon ---- */
.avatar-btn {
  border: none; padding: 0; background: none; cursor: pointer; border-radius: 50%;
  flex-shrink: 0; line-height: 0; transition: transform .2s ease;
}
.avatar-btn img {
  width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--primary-light);
  display: block; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--border); transition: box-shadow .2s ease;
}
.avatar-btn:hover { transform: translateY(-1px); }
.avatar-btn:hover img { box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--primary); }
.avatar-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.avatar-btn-sm img { width: 26px; height: 26px; border-radius: 7px; }
.avatar-btn-lg img { width: 52px; height: 52px; border-radius: 14px; }

.day-block { margin-bottom: 30px; }
.day-title {
  font-weight: 700; background: var(--primary-light); color: var(--primary-mid);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 999px; margin-bottom: 16px; font-size: .88rem;
}

/* ---- timeline dang duong ke doc + cham moc ---- */
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { position: relative; display: flex; gap: 14px; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-marker { position: relative; width: 14px; flex-shrink: 0; display: flex; justify-content: center; }
.tl-marker::before {
  content: ''; position: absolute; top: 16px; bottom: -16px; width: 2px;
  background: var(--border);
}
.tl-item:last-child .tl-marker::before { display: none; }
.tl-dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 4px;
  background: var(--card); border: 2px solid var(--primary); flex-shrink: 0; z-index: 1;
}
.tl-content {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; transition: box-shadow .18s ease, border-color .18s ease;
}
.tl-content:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.tl-time {
  font-size: .74rem; color: var(--primary-mid); font-weight: 700; letter-spacing: .02em;
  display: flex; align-items: center; gap: 8px;
}
.tl-dur { color: var(--muted); font-weight: 500; }
.tl-title { font-weight: 700; margin: 4px 0 4px; }
.tl-desc { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }

.pc-list { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.pc-row { display: flex; align-items: center; gap: 10px; }
.pc-avatars { display: flex; flex-shrink: 0; }
.pc-avatars .avatar-btn + .avatar-btn { margin-left: -10px; }
.pc-avatars .avatar-btn img { box-shadow: 0 0 0 2px var(--card); }
.pc-text { min-width: 0; font-size: .82rem; display: flex; flex-direction: column; }
.pc-nv { color: var(--muted); }
.pc-who { font-weight: 600; }

.tailieu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 10px; }
.tailieu {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px;
  transition: box-shadow .18s ease, border-color .18s ease;
}
.tailieu:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); text-decoration: none; }
.tailieu .tailieu-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.tailieu .tailieu-icon .icon { width: 16px; height: 16px; }
.tailieu .ten { font-weight: 700; font-size: .92rem; color: var(--text); }
.tailieu .ghichu { font-size: .78rem; color: var(--muted); margin-top: 2px; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 30px 0 50px; }

/* ============ TRANG CHU ============ */
.home-hero { padding: 64px 20px 104px; text-align: center; }
.home-hero-inner { position: relative; z-index: 1; }
.home-badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 6px 15px; margin-bottom: 20px; backdrop-filter: blur(4px);
}
.home-hero .home-icon { display: flex; justify-content: center; margin-bottom: 14px; }
.home-hero h1 { font-size: 2.3rem; margin: 0 0 12px; letter-spacing: -.03em; font-weight: 800; line-height: 1.15; }
.home-hero p { opacity: .82; max-width: 480px; margin: 0 auto; line-height: 1.6; font-size: .95rem; }
.home-hero .home-count {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 18px;
  font-size: .82rem; opacity: .85;
}

.home-wrap { max-width: 720px; margin: -50px auto 60px; padding: 0 20px; position: relative; z-index: 1; }
.home-list { display: grid; gap: 14px; }
.home-card {
  position: relative; display: flex; align-items: center; gap: 16px; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px 20px 24px; box-shadow: var(--shadow-md);
  transition: transform .2s ease, box-shadow .2s ease;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--scarf-red), var(--scarf-yellow));
}
.home-card:hover { transform: translateY(-2px); text-decoration: none; }
.home-card-body { flex: 1; min-width: 0; }
.home-card .ten, .home-card .name { font-weight: 800; font-size: 1.12rem; color: var(--text); letter-spacing: -.015em; line-height: 1.3; }
.home-card .meta-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.home-card .meta-row span { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; color: var(--muted); }
.home-card .mo-ta { font-size: .84rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.home-card-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.home-card-stats span {
  display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700;
  background: var(--primary-light); color: var(--primary-mid); padding: 4px 10px; border-radius: 999px;
}
.home-card .arrow-btn {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  transition: background .18s ease, color .18s ease;
}
.home-card:hover .arrow-btn { background: var(--primary); color: white; }

/* ---- badge + mau rieng cho chuong trinh da "hoan tat" (khac voi trang_thai) ---- */
.badge-hoan-tat {
  display: inline-flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 700;
  background: #e2e8f0; color: #475569; padding: 2px 9px; border-radius: 999px;
  margin-left: 6px; vertical-align: middle;
}
.badge-hoan-tat .icon { width: 10px; height: 10px; }
.home-card-hoan-tat { opacity: .8; }
.home-card-hoan-tat::before { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }
.home-card-hoan-tat .home-card-stats span { background: #f1f5f9; color: #64748b; }
.home-card-hoan-tat .arrow-btn { background: #f1f5f9; color: #64748b; }
.admin-row-hoan-tat { background: var(--bg); }
.admin-row-hoan-tat .name { color: var(--muted); }

.home-empty { text-align: center; color: var(--muted); padding: 50px 0; }
.home-manage-link { text-align: center; margin-top: 22px; }
.home-manage-link a { font-size: .82rem; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.home-manage-link a:hover { color: var(--primary); }

/* ---- trang dang nhap ---- */
.login-wrap {
  position: relative; overflow: hidden; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 420' preserveAspectRatio='none'%3E%3Cpath d='M-30 -10 L500 400 L1030 -10' fill='none' stroke='%23ffec0a' stroke-width='6' stroke-linejoin='round' vector-effect='non-scaling-stroke' opacity='.92'/%3E%3C/svg%3E") center / 100% 100% no-repeat, var(--hero-bg);
}
.login-wrap-glow { position: absolute; border-radius: 50%; filter: blur(80px); pointer-events: none; }
.login-wrap-glow-1 { width: 340px; height: 340px; background: rgba(255,236,10,.20); top: -110px; left: -90px; }
.login-wrap-glow-2 { width: 300px; height: 300px; background: rgba(255,255,255,.14); bottom: -130px; right: -70px; }

.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px; background: var(--card);
  border-radius: 24px; box-shadow: 0 36px 70px -24px rgba(60,4,6,.65); padding: 38px 32px; text-align: center;
}
.login-icon { display: flex; justify-content: center; margin: 0 auto 16px; }
.login-card h1 { font-size: 1.35rem; margin: 0 0 6px; font-weight: 800; }
.login-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 24px; line-height: 1.5; }
.login-card form { text-align: left; }
.login-card .field { margin-bottom: 16px; }
.login-back { text-align: center; margin-top: 18px; }

.input-icon { position: relative; }
.input-icon > .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.input-icon input {
  width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--border); border-radius: 10px;
  font-size: .92rem; font-family: inherit; background: var(--card); color: var(--text);
}
.input-icon input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
/* input[type=text] chung (o .field input[type=text]...) dac hieu cao hon,
   de tay den mat padding-trai o day - ep lai bang ID cho chac chan thang. */
#user, #pass { padding-left: 40px !important; }
.input-icon-pass input { padding-right: 40px; }
/* nut con mat tu lam, thay cho icon mac dinh cua trinh duyet (moi noi 1 kieu) */
.toggle-pass {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; background: none; color: var(--muted);
  cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.toggle-pass:hover { background: var(--bg); color: var(--text); }
.toggle-pass .icon { width: 16px; height: 16px; }
/* an icon con mat rieng cua Edge/IE va nut xoa chu X, tranh chong len nut cua minh */
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; }

/* Chrome/Safari to mau vang cho o duoc trinh duyet tu dien (autofill) - ep
   lai mau nen/chu theo dung theme, khong de no lech mau so voi o ben canh. */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--card) inset;
  box-shadow: 0 0 0 1000px var(--card) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: .92rem; }
.error-box { display: flex; align-items: center; gap: 6px; }
.error-box .icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ---- trang 404 ---- */
.notfound-wrap {
  min-height: 70vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 40px 20px;
}
.notfound-wrap .code {
  font-size: 4.5rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--scarf-red), #f59e0b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.notfound-wrap h1 { font-size: 1.25rem; margin: 10px 0 6px; }
.notfound-wrap p { color: var(--muted); margin-bottom: 22px; max-width: 380px; }

@media (max-width: 480px) {
  /* Luoi 2x2 thay vi xep 4 hang doc - do gon, do phai cuon */
  .stats { display: grid; grid-template-columns: repeat(2, 1fr); }
  .stats .stat { padding: 14px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .stats .stat:nth-child(2n) { border-right: none; }
  .stats .stat:nth-last-child(-n+2) { border-bottom: none; }
  .hero h1 { font-size: 1.6rem; }
  .home-hero h1 { font-size: 1.8rem; }
  .home-card { flex-wrap: wrap; }
}

/* ============ TRANG QUAN TRI / NHAP LIEU ============ */
.admin-wrap { max-width: 720px; margin: 30px auto; padding: 0 20px 60px; }
.admin-wrap-wide { max-width: 860px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.admin-top h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.025em; font-weight: 800; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 11px; padding: 9px 16px;
  font-size: .88rem; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(123,9,12,.35), 0 8px 16px -8px rgba(212,13,18,.7), inset 0 1px 0 rgba(255,255,255,.16); }
.btn-primary:hover { background: var(--primary-mid); text-decoration: none; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { text-decoration: none; border-color: var(--primary); color: var(--primary-mid); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }

.flash {
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
  padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 16px;
}
.error-box {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 16px;
}

.admin-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; padding: 11px 15px; margin-bottom: 8px;
  transition: box-shadow .18s ease;
}
.admin-row:hover { box-shadow: var(--shadow-sm); }
.admin-row img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; background: var(--primary-light); flex-shrink: 0; }
.admin-row .info { flex: 1; min-width: 0; }
.admin-row .name { font-weight: 700; font-size: .92rem; }
.admin-row .meta { font-size: .78rem; color: var(--muted); }
.admin-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.user-list .info { overflow-wrap: anywhere; }
.user-list .password-action { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.form-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input[type=text], .field input[type=url], .field input[type=date], .field input[type=time],
.field input[type=password], .field input[type=email], .field input[type=tel],
.field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 11px;
  font-size: .92rem; font-family: inherit; background: var(--card); color: var(--text);
}
.field textarea { resize: vertical; min-height: 44px; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.field .check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text); font-weight: normal; }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
/* gio bat dau + gio ket thuc - luon canh nhau 1 hang, khong bao gio co ve
   1 cot nhu .field-row (moi ben chi la 1 cap select gon, du cho ngay tren
   dien thoai hep nhat). */
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- cap dropdown chon gio/phut (thay cho go tay, tranh nhap sai) ---- */
.time-select {
  display: inline-flex; align-items: center; gap: 2px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.time-select:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.time-select select {
  border: none; background: transparent; font-size: .88rem; font-weight: 700;
  font-variant-numeric: tabular-nums; padding: 7px 0; color: var(--text);
  cursor: pointer; text-align: center; font-family: inherit;
  width: 34px; flex-shrink: 0;
}
.time-select select:focus { outline: none; }
.time-select-noi { color: var(--muted); font-weight: 700; padding: 0 1px; }
.field .time-select { width: 100%; justify-content: center; }
.field .time-select select { flex: 1; min-width: 0; width: auto; }

/* ---- nhap nhieu muc lich trinh cung luc (1 ngay, nhieu hoat dong noi tiep
   nhau dang timeline, giong bo cuc hien thi o trang chinh) ---- */
.hang-list { list-style: none; margin: 0; padding: 0; }
.hang-lich-trinh { display: flex; gap: 12px; position: relative; }
.hang-marker { width: 26px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.hang-marker::before {
  content: ''; position: absolute; top: 26px; bottom: -12px; left: 13px; width: 2px; background: var(--border);
}
.hang-lich-trinh:last-child .hang-marker::before { display: none; }
.hang-so {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary-mid); font-size: .78rem; font-weight: 700;
}
.hang-body {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 14px; transition: border-color .18s ease;
}
.hang-body:focus-within { border-color: var(--primary); }
/* gio bat dau - gio ket thuc - nut xoa: luon 1 hang, khong bao gio vo dong.
   Man hinh cuc hep (~320px) neu van khong vua thi cho cuon ngang trong dung
   hang nay, khong de vo bo cuc ca trang hay tran ra ngoai the. */
.hang-gio {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hang-gio::-webkit-scrollbar { display: none; }
.hang-gio-noi { color: var(--muted); flex-shrink: 0; }
.hang-ten, .hang-ghichu {
  display: block; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; margin-bottom: 8px; background: var(--card);
}
.hang-ten:focus, .hang-ghichu:focus { outline: none; border-color: var(--primary); }
.hang-ghichu { margin-bottom: 0; font-size: .82rem; }
.hang-xoa {
  margin-left: auto; flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: var(--bg); color: var(--muted); cursor: pointer; font-size: .8rem;
  line-height: 1;
}
.hang-xoa:hover { background: #fee2e2; color: #b91c1c; }

.checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 8px;
  max-height: 260px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--border); border-radius: 10px;
}
.checkbox-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px;
  font-size: .85rem; font-weight: normal; cursor: pointer;
}
.checkbox-item:hover { background: var(--bg); }
.checkbox-item img { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; background: var(--primary-light); flex-shrink: 0; }
.checkbox-item input { flex-shrink: 0; }
.avatar-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar-preview img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--primary-light); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.back-link { font-size: .85rem; color: var(--muted); }
.field-help { font-size: .76rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.mode-switch { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.membership-role { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.membership-role legend, .membership-account legend { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.membership-role-options { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 6px; }
.membership-role-options label { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1 1 120px; min-width: 0; min-height: 38px; padding: 7px 10px; border-radius: 4px; cursor: pointer; font-size: .85rem; }
.membership-role-options label:has(input:checked) { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.membership-role-options input { width: 16px; height: 16px; flex-shrink: 0; margin: 0; }
.membership-account { border: 0; border-top: 1px solid var(--border); padding: 12px 0 0; margin: 4px 0 0; min-width: 0; }
.membership-account-ready { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.manager-picker {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px;
  max-height: 260px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
}
.manager-option { align-items: flex-start; padding: 7px; border-radius: 6px; }
.user-pick-list { display: grid; gap: 6px; max-height: min(50vh, 380px); overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.field .user-pick { display: flex; flex-direction: row; color: var(--text); font-size: .88rem; align-items: flex-start; gap: 10px; min-width: 0; margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-weight: 400; cursor: pointer; }
.field .user-pick:hover { background: var(--bg); }
.field .user-pick:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.field .user-pick input { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }
.field .user-pick span { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.field .user-pick b { font-weight: 700; }
.field .user-pick small { color: var(--muted); }
.manager-option:hover { background: var(--bg); }
.manager-option span { display: grid; gap: 2px; }
.manager-option small { color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.manager-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.manager-fieldset legend { font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.manager-picker-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.manager-search { flex: 1; min-width: 0; width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; background: var(--card); color: var(--text); }
.manager-selected-count { flex-shrink: 0; font-size: .8rem; color: var(--muted); }
.manager-candidate { display: flex; align-items: center; min-width: 0; border: 1px solid var(--border); border-radius: 6px; }
.manager-candidate[hidden] { display: none; }
.manager-candidate:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.manager-candidate .manager-option { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; margin: 0; font-weight: 400; cursor: pointer; }
.manager-candidate .manager-option span { min-width: 0; overflow-wrap: anywhere; }
.manager-option input { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }
.manager-candidate .manager-status { color: #9f1239; }
.manager-account-link { width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.manager-account-link:hover { color: var(--primary); }
.manager-page .manager-picker { max-height: min(55vh, 560px); }
.manager-page-heading { flex-wrap: wrap; }
.manager-page-heading h1 { margin-bottom: 4px; }
.manager-page-heading .sub { margin: 0; }
.project-list .admin-row { flex-wrap: wrap; }
.project-list .info { flex: 1 1 260px; overflow-wrap: anywhere; }
.project-list .actions { flex: 0 1 auto; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.project-dashboard > .admin-top { flex-wrap: wrap; gap: 12px; }
.project-dashboard > .admin-top h1 { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.topbar-account { margin-left: auto; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.topbar-account + .topbar-logout { margin-left: 0; }

/* ---- popup cong viec cua 1 nguoi (native <dialog>) ---- */
dialog#dlg-cong-viec {
  width: min(560px, 92vw); max-height: 82vh; padding: 0; border: none; border-radius: 20px;
  box-shadow: 0 30px 60px -20px rgba(60,4,6,.4); color: var(--text); overflow: hidden;
}
dialog#dlg-cong-viec::backdrop { background: rgba(40,8,8,.55); backdrop-filter: blur(3px); }
dialog#dlg-cong-viec[open] { animation: dlg-in .18s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.dlg-head {
  display: flex; align-items: center; gap: 12px; padding: 22px 20px; background: var(--hero-bg); color: white;
}
.dlg-head .avatar-btn { pointer-events: none; }
.dlg-head .avatar-btn img { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.dlg-name { font-weight: 800; font-size: 1.05rem; }
.dlg-meta { font-size: .8rem; opacity: .85; margin-top: 2px; }
.dlg-close {
  margin-left: auto; border: none; background: rgba(255,255,255,.16); color: white;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: .9rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.dlg-close:hover { background: rgba(255,255,255,.3); }

.dlg-body {
  padding: 18px 20px 20px; overflow-y: auto; max-height: calc(82vh - 88px);
  overscroll-behavior: contain; /* khong cho scroll "chay" tiep ra trang nen khi het noi dung */
}
html.dlg-locked, html.dlg-locked body { overflow: hidden; }
.dlg-empty { color: var(--muted); font-size: .88rem; }
.dlg-day-title {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700;
  background: var(--primary-light); color: var(--primary-mid); padding: 5px 12px; border-radius: 999px;
  margin: 16px 0 10px;
}
.dlg-day-title:first-child { margin-top: 0; }
.dlg-cv {
  position: relative; padding: 12px 14px 12px 22px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 12px;
}
.dlg-cv::before {
  content: ''; position: absolute; left: 10px; top: 17px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
}
.dlg-cv-time { font-size: .74rem; font-weight: 700; color: var(--primary-mid); letter-spacing: .02em; }
.dlg-cv-title { font-weight: 700; margin: 3px 0 2px; }
.dlg-cv-role { font-size: .85rem; color: var(--muted); }
.dlg-checklist { margin: 8px 0 0; padding-left: 18px; font-size: .82rem; color: var(--text); }
.dlg-checklist li { margin-bottom: 3px; }
.dlg-cv-note { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.dlg-cv-dongsu {
  font-size: .76rem; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  text-transform: uppercase; letter-spacing: .02em; font-weight: 700;
}
.dlg-cv-dongsu-names { text-transform: none; font-weight: 600; color: var(--primary-mid); letter-spacing: 0; }

/* ======================= Sa mạc (chương trình tổng) ======================= */
.unit-chip {
  --c: #475569; --bg: #f1f5f9;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em; line-height: 1.5;
  color: var(--c); background: var(--bg); box-shadow: inset 0 0 0 1px var(--c);
}
.unit-chip-support { background: transparent; font-weight: 600; }
.uc-xanh-la { --c: #15803d; --bg: #dcfce7; }
.uc-xanh-duong { --c: #1d4ed8; --bg: #dbeafe; }
.uc-tim { --c: #6d28d9; --bg: #ede9fe; }
.uc-cam { --c: #c2410c; --bg: #ffedd5; }
.uc-hong { --c: #be185d; --bg: #fce7f3; }
.uc-xanh-ngoc { --c: #0e7490; --bg: #cffafe; }
.uc-do { --c: #b91c1c; --bg: #fee2e2; }
.uc-vang { --c: #a16207; --bg: #fef9c3; }
.cov-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.cov-ok { background: #16a34a; }
.cov-partial { background: #f59e0b; }
.cov-none { background: #dc2626; }
.unit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tl-lead { font-size: .84rem; color: var(--text); margin-top: 2px; }
.tl-lead b { color: var(--muted); font-weight: 600; }
.day-theme { font-weight: 600; color: var(--muted); margin-left: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); margin: 0 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.unit-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.unit-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
}
.unit-card .name { font-weight: 800; margin: 6px 0 2px; }
.unit-card .meta { font-size: .8rem; color: var(--muted); }
.unit-card .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.staff-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.staff-list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
}
.staff-list .who { font-weight: 700; flex: 1; min-width: 160px; }
.staff-list .role { font-size: .74rem; font-weight: 700; color: var(--primary-dark); background: var(--primary-light); border-radius: 999px; padding: 2px 10px; }
.staff-list a.tel { font-weight: 700; white-space: nowrap; }

.slot-units { display: grid; gap: 8px; }
.slot-unit-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; background: var(--card);
}
.slot-unit-row label.check { margin: 0; flex: 1; min-width: 180px; }
.slot-unit-row select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }

.summary-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.summary-bar .pill {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; font-size: .84rem; color: var(--muted);
}
.summary-bar .pill b { display: block; font-size: 1.25rem; color: var(--text); line-height: 1.2; }

.badge-tong { font-size: .7rem; font-weight: 700; color: #1d4ed8; background: #dbeafe; border-radius: 999px; padding: 2px 8px; margin-left: 6px; white-space: nowrap; }
.home-section-title { font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.home-card-sa-mac::before { background: linear-gradient(90deg, var(--scarf-yellow), var(--scarf-red) 60%); }

@media (max-width: 640px) {
  .unit-grid { grid-template-columns: 1fr; }
  .slot-unit-row { align-items: flex-start; }
}
.field .slot-unit-row select { width: auto; min-width: 130px; flex: none; }

/* ---------- Tổng quan sa mạc / ma trận ---------- */
.bar { height: 8px; background: #f0e9dd; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ffc400, var(--scarf-yellow)); border-radius: 999px; }
.panel-title { font-size: 1.05rem; margin: 0 0 10px; }

.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.todo-warn { border-color: #fcd34d; background: #fffbeb; }
.todo-text { flex: 1; font-size: .9rem; }

.ban-table { display: grid; gap: 10px; margin-top: 12px; }
.ban-row {
  display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) auto; gap: 10px 18px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px 18px; box-shadow: var(--shadow-sm);
}
.ban-main { display: flex; align-items: flex-start; gap: 12px; }
.ban-main .unit-chip { min-width: 48px; justify-content: center; margin-top: 2px; }
.ban-main > div { min-width: 0; flex: 1; }
.ban-name { font-weight: 800; }
.ban-meta { font-size: .8rem; color: var(--muted); }
.ban-row .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ban-row .actions form { margin: 0; }
@media (max-width: 820px) {
  .ban-row { grid-template-columns: 1fr; }
  .ban-row .actions { justify-content: flex-start; }
}

.sm-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.sm-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.sm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sm-name { font-weight: 800; font-size: 1.05rem; }
.sm-status { font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.sm-meta { font-size: .82rem; color: var(--muted); }
.sm-stats { display: flex; gap: 16px; font-size: .88rem; }
.sm-stats b { font-size: 1.15rem; }
.sm-warn { font-size: .84rem; font-weight: 600; color: #92400e; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; padding: 6px 10px; }
.sm-card .actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.empty-card { background: var(--card); border: 1px dashed var(--border); border-radius: 14px; padding: 18px 20px; color: var(--muted); }

.template-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); margin-bottom: 8px; cursor: pointer; }
.template-option span { display: flex; flex-direction: column; }
.template-option small { color: var(--muted); font-size: .8rem; }
.template-option:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.template-copy { margin-top: 10px; }

.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .82rem; }
.matrix th, .matrix td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.matrix thead th { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.matrix .mx-time { position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left; min-width: 230px; max-width: 300px; font-weight: 400; }
.matrix thead .mx-time { background: #f8fafc; z-index: 3; }
.mx-hour { display: block; font-size: .72rem; font-weight: 700; color: var(--primary-mid); }
.mx-title { display: block; font-weight: 700; color: var(--text); line-height: 1.3; }
.matrix td { min-width: 52px; }
.matrix td.mx-on { border-radius: 10px; }
.matrix td.mx-on.mx-lead { background: var(--bg); box-shadow: inset 0 0 0 2px var(--c); }
.matrix td.mx-on.mx-support { background: transparent; box-shadow: inset 0 0 0 2px var(--bg); }
.matrix tbody tr:hover td, .matrix tbody tr:hover th.mx-time { background-color: #f8f3ec; }

.no-manager { color: #b45309; font-weight: 700; }
a.no-manager { text-decoration: underline; }

/* ---------- Phân công trưởng ban ---------- */
.head-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; font-size: .88rem; }
.head-label { color: var(--muted); font-size: .8rem; }
.head-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-light); border-radius: 999px; padding: 2px 4px 2px 10px; }
.head-chip form { margin: 0; display: inline; }
.chip-x { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 6px; border-radius: 999px; }
.chip-x:hover { color: #b91c1c; }
.head-add { display: inline-flex; gap: 6px; margin: 0; }
.head-input { min-width: 0; width: 15rem; max-width: 100%; padding: 5px 10px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: .85rem; background: var(--card); }
.head-more { font-size: .78rem; color: var(--muted); text-decoration: underline; }
@media (max-width: 520px) { .head-add { display: flex; width: 100%; } .head-input { flex: 1; width: auto; } }
.mgr-list { display: grid; gap: 4px; min-width: 0; }
.mgr-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; overflow-wrap: anywhere; }
.mgr-list .no-manager, .mgr-item b { font-size: .92rem; }
.mgr-ban { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.mgr-contact { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.user-state { font-size: .76rem; font-weight: 700; }
.user-state-ok { color: #15803d; }
.user-state-warn { color: #b45309; }
.user-tag { font-style: normal; font-size: .7rem; font-weight: 700; color: var(--primary-dark); background: var(--primary-light); border-radius: 999px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.field .user-pick .user-state-ok { color: #15803d; }
.field .user-pick .user-state-warn { color: #b45309; }

/* điện thoại nhỏ: để 4 tab (Lịch tổng / Theo ban / Các ban / Liên hệ) vừa một hàng */
@media (max-width: 480px) {
  .tab-btn { padding: 9px 11px; font-size: .8rem; }
  .tab-btn .icon { display: none; }
}

.url-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.url-input:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.url-prefix { display: inline-flex; align-items: center; padding: 0 10px; background: #f1f5f9; color: var(--muted); font-size: .9rem; border-right: 1px solid var(--border); white-space: nowrap; }
.field .url-input input { border: 0; box-shadow: none; flex: 1; min-width: 0; }
.topbar-login { margin-left: auto; font-weight: 700; color: var(--primary-dark); }

/* ---------- Nhập lịch từ PDF ---------- */
.import-summary { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; line-height: 1.6; }
.import-note { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: 12px; padding: 10px 14px; font-size: .86rem; margin: 10px 0 14px; line-height: 1.55; }
.upload-card { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.save-msg { font-size: .88rem; color: var(--muted); }
.import-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.import-table { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 980px; }
.import-table th { background: #f8fafc; text-align: left; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 8px; position: sticky; top: 0; }
.import-table td { border-top: 1px solid var(--border); padding: 6px 8px; vertical-align: top; }
.import-table input[type=text], .import-table input[type=date], .import-table input[type=time], .import-table select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
.import-table .t-time { min-width: 150px; } .import-table .t-time input { width: 70px; display: inline-block; }
.import-table .t-title { min-width: 280px; } .import-table .t-units { min-width: 260px; }
.import-table tr.row-off td { opacity: .45; }
.import-table tr.row-error td { background: #fef2f2; }
.flag { font-size: .76rem; margin-top: 3px; } .flag-warn { color: #92400e; } .flag-error { color: #b91c1c; } .flag-info { color: var(--muted); }
.chip-check { display: inline-flex; align-items: center; gap: 3px; margin: 0 6px 4px 0; cursor: pointer; }
.chip-check input { margin: 0; } .chip-new .unit-chip { box-shadow: inset 0 0 0 1px var(--c); border-style: dashed; background: transparent; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 6px auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.import-wait { text-align: center; padding: 28px; }

/* trang xem lại PDF cần rộng hơn các trang quản lý khác (nhiều cột, 9+ ô ban) */
.admin-wrap-xl { max-width: 1500px; }
.import-table { min-width: 1180px; }
.import-table .t-time { min-width: 210px; }
.import-table .t-time input { width: 96px; }
.import-table td:nth-child(2) { min-width: 150px; }
.import-table .t-title { min-width: 300px; }
.import-table .t-units { min-width: 330px; }

/* ---------- tìm kiếm trong danh sách ---------- */
[data-q][hidden], [data-search-group][hidden] { display: none !important; }
.search-box-wide { max-width: 520px; margin-bottom: 16px; }
.search-box .search-count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: .76rem; color: var(--muted); pointer-events: none; }
.search-box input[type=search] { padding-right: 56px; }
.panel-toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.panel-toolbar .search-box { flex: 1; min-width: 240px; margin-bottom: 16px; }
.topbar-link { margin-left: auto; color: var(--primary-dark); font-weight: 700; font-size: .8rem; white-space: nowrap; padding: 4px 8px; border-radius: 6px; flex-shrink: 0; }
.topbar-link:hover { background: var(--bg); text-decoration: none; }
.topbar-link + .topbar-account { margin-left: 0; }
.user-row .badge-role { font-size: .7rem; font-weight: 700; color: #1d4ed8; background: #dbeafe; border-radius: 999px; padding: 1px 8px; margin-left: 6px; }

/* trang chủ: 3 tab (Sa mạc / Chương trình / Người dùng) chia đều hết bề ngang điện thoại, chữ tự xuống dòng thay vì bị cắt */
@media (max-width: 480px) {
  .home-wrap .tab-bar { display: flex; width: 100%; border-radius: 22px; }
  .home-wrap .tab-btn { flex: 1 1 0; white-space: normal; line-height: 1.2; padding: 8px 4px; font-size: .78rem; text-align: center; border-radius: 18px; }
}

/* thanh trên cùng: lối tắt "Người dùng" chỉ còn biểu tượng trên điện thoại để không đẩy nút Đăng xuất ra khỏi màn hình */
.topbar-link { display: inline-flex; align-items: center; gap: 5px; }
.topbar-link .icon { width: 15px; height: 15px; }
@media (max-width: 480px) { .topbar-link span { display: none; } .topbar-link { padding: 6px 8px; } }

/* ---------- Đăng nhập Google / Tài khoản ---------- */
.login-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: .8rem; }
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
a.topbar-account { text-decoration: none; }
a.topbar-account:hover { color: var(--text); text-decoration: underline; }
.topbar-me { display: inline-flex; align-items: center; gap: 7px; }
.topbar-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--primary-light); }
.topbar-avatar-initial { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; color: var(--primary-dark); }

/* ---------- Trang cá nhân ---------- */
.profile { max-width: 920px; margin: 0 auto; padding: 28px 16px 48px; }
.profile section { margin: 0; } /* ghi đè quy tắc chung `section { margin: 36px 0 }` */
.profile-hero {
  position: relative; display: flex; align-items: center; gap: 22px; padding: 28px 28px 26px; margin-bottom: 18px; border-radius: 24px; color: #fff;
  background: var(--hero-bg); box-shadow: var(--shadow-md);
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover; display: block; background: var(--primary-light);
  border: 4px solid rgba(255,255,255,.9); box-shadow: 0 10px 24px -8px rgba(0,0,0,.4);
}
.profile-avatar[hidden] { display: none; }
.profile-avatar-initial { display: flex; align-items: center; justify-content: center; font-size: 2.8rem; font-weight: 800; color: var(--primary-dark); }
.avatar-edit {
  position: absolute; right: 0; bottom: 2px; width: 38px; height: 38px; border-radius: 50%; border: 3px solid #8f0a0d;
  background: #fff; color: var(--primary-dark); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 10px -3px rgba(0,0,0,.4);
  transition: transform .12s ease;
}
.avatar-edit:hover { transform: scale(1.08); }
.avatar-edit:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.profile-id { min-width: 0; flex: 1; }
.profile-id h1 { margin: 0 0 8px; font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.profile-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: .74rem; font-weight: 700; border-radius: 999px; padding: 3px 11px; background: rgba(255,255,255,.18); color: #fff; backdrop-filter: blur(4px); }
.chip-ok { background: rgba(220,252,231,.95); color: var(--ok); }
.profile-sub { margin: 10px 0 0; color: rgba(255,255,255,.8); font-size: .9rem; overflow-wrap: anywhere; }
.profile-remove { position: absolute; top: 14px; right: 18px; margin: 0; }
.link-btn { background: none; border: 0; color: rgba(255,255,255,.85); font: inherit; font-size: .82rem; text-decoration: underline; cursor: pointer; padding: 4px; }
.link-btn:hover { color: #fff; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.pcard { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow-sm); }
.pcard-wide { grid-column: 1 / -1; }
.pcard h2 { margin: 0 0 14px; font-size: 1.02rem; font-weight: 800; }
.profile-hero { margin-bottom: 0; }
.info-list { margin: 0 0 12px; display: grid; gap: 10px; }
.info-list > div { display: flex; flex-direction: column; gap: 1px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.info-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.info-list dt { font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.info-list dd { margin: 0; font-size: .96rem; overflow-wrap: anywhere; }
.pcard-state { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: .95rem; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: #16a34a; box-shadow: 0 0 0 4px var(--ok-light); }
.dot-off { background: #cbd5e1; box-shadow: 0 0 0 4px #f1f5f9; }
.pw-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; align-items: end; }
.pw-form .field { margin: 0; }
.pw-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--card); color: var(--text); }
.pw-form input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.pw-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.crop-dlg { border: 0; border-radius: 20px; padding: 22px; width: min(340px, 92vw); text-align: center; box-shadow: 0 30px 60px -20px rgba(60,4,6,.5); }
.crop-dlg::backdrop { background: rgba(40,8,8,.55); backdrop-filter: blur(3px); }
.crop-dlg h3 { margin: 0 0 4px; }
.crop-dlg canvas { width: 280px; max-width: 100%; aspect-ratio: 1; border-radius: 50%; touch-action: none; cursor: grab; background: #fff; margin: 8px 0 12px; box-shadow: 0 0 0 4px var(--primary-light); }
.crop-dlg canvas:active { cursor: grabbing; }
.crop-dlg input[type=range] { width: 100%; accent-color: var(--primary); }
.crop-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.error-text { color: #b91c1c; font-size: .85rem; margin: 8px 0 0; }

@media (max-width: 640px) {
  .profile-hero { flex-direction: column; text-align: center; padding: 26px 18px 22px; }
  .profile-chips { justify-content: center; }
  .profile-grid { grid-template-columns: 1fr; }
  .pcard { padding: 18px; }
  .topbar-me span { display: none; } /* điện thoại: chỉ giữ ảnh/chữ cái, nhường chỗ cho nút Đăng xuất */
}

/* nút quay về sa mạc ở đầu trang ban */
.hero-back {
  display: flex; width: fit-content; align-items: center; gap: 6px; margin-bottom: 14px; padding: 6px 14px; border-radius: 999px; font-size: .82rem; font-weight: 700;
  color: #fff; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); backdrop-filter: blur(4px); text-decoration: none;
}
.hero-back .icon { transform: rotate(180deg); }
.hero-back:hover { background: rgba(255,255,255,.26); text-decoration: none; }

/* Details of unit work, shared by overview and schedule matrix. */
.ban-work-list { grid-column:1/-1; font-size:.85rem; }
.ban-work-list summary { cursor:pointer; color:var(--primary-mid); font-weight:700; }
.ban-work-item { padding:10px 0; border-bottom:1px solid var(--border); overflow-wrap:anywhere; }
.ban-work-item > b,.ban-work-item > span { display:block; }
.work-assignment { border-left:3px solid var(--border); padding:6px 10px; margin:8px 0; text-align:left; overflow-wrap:anywhere; }
.matrix-detail-button { display:flex; align-items:center; justify-content:center; margin:auto; min-width:36px; min-height:36px; border:0; border-radius:8px; background:transparent; cursor:pointer; }
.matrix-detail-button:hover,.matrix-detail-button:focus-visible { background:var(--primary-light); outline:2px solid var(--primary-mid); }
.work-dialog { width:min(520px,calc(100vw - 32px)); max-height:80vh; overflow:auto; box-sizing:border-box; padding:20px; border:1px solid var(--border); border-radius:16px; background:var(--card); color:var(--text); text-align:left; box-shadow:var(--shadow-sm); }
.work-dialog::backdrop { background:rgba(15,23,42,.5); }
.work-dialog-header { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; }
.work-dialog-header h3 { margin:0; }
.work-dialog-header form { margin:0; }

.timeline-staffing { margin:8px 0; padding:8px 12px; border-left:3px solid var(--primary-mid); background:var(--bg); font-size:.85rem; line-height:1.6; overflow-wrap:anywhere; }
.staffing-form { margin:18px 0; }
.staffing-form h2 { margin-top:0; font-size:1.1rem; }
.staffing-form .staffing-primary { width:100%; }
.staffing-form .checkbox-item:has(input:disabled) { opacity:.5; }
