* Hệ thiết kế: lưới 4px, ưu tiên thao tác trên điện thoại. */
:root {
  --primary:#4f46e5; --primary-hover:#4338ca; --primary-soft:#eef2ff;
  --success:#10b981; --warning:#f59e0b; --danger:#ef4444;
  --slate-50:#f8fafc; --slate-100:#f1f5f9; --slate-200:#e2e8f0;
  --slate-300:#cbd5e1; --slate-400:#94a3b8; --slate-500:#64748b;
  --slate-600:#475569; --slate-700:#334155; --slate-800:#1e293b; --slate-900:#0f172a;
  --background:#fafafa; --surface:#ffffff; --border:#e2e8f0;
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px; --space-6:24px; --space-8:32px;
  --radius:16px; --shadow:0 2px 4px #0f172a03,0 8px 24px #0f172a03;
  --ease:180ms ease; --sidebar:232px;
}
* { box-sizing:border-box; }
html { scroll-padding-top:88px; }
body { margin:0; background:var(--background); color:var(--slate-900); font:400 14px/1.6 Inter,system-ui,sans-serif; -webkit-font-smoothing:antialiased; }
a { color:var(--primary); text-decoration:none; }
button,input,select,textarea { font:inherit; }
a,button,summary { touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
a,button,summary,input,select { transition:background var(--ease),color var(--ease),border-color var(--ease),box-shadow var(--ease),transform var(--ease); }
:focus-visible { outline:3px solid var(--primary); outline-offset:4px; }
h1,h2,h3,p { margin:0; }
h1 { font-size:24px; line-height:1.25; letter-spacing:-.8px; font-weight:700; overflow-wrap:anywhere; }
h2 { font-size:20px; line-height:1.4; letter-spacing:-.4px; }
h3 { font-size:16px; line-height:1.5; font-weight:600; overflow-wrap:anywhere; }
p,.muted { color:var(--slate-500); }
small,.small,.meta { font-size:12px; }
.meta { margin-top:4px; }
.eyebrow { color:var(--primary); font-size:12px; font-weight:600; letter-spacing:1px; }
.sr-only,.skip-link:not(:focus) { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.skip-link:focus { position:fixed; top:12px; left:16px; z-index:100; padding:12px 16px; background:white; border-radius:8px; }
/* Thanh tài khoản và điều hướng thích ứng theo không gian màn hình. */
.top-bar { height:72px; position:sticky; top:0; z-index:30; display:flex; justify-content:space-between; align-items:center; gap:16px; padding:0 16px; border-bottom:1px solid var(--border); background:#ffffffed; backdrop-filter:blur(16px); }
.brand { display:flex; align-items:center; gap:12px; min-height:48px; color:var(--slate-900); font-size:16px; font-weight:700; }
.brand small { display:block; font-size:12px; font-weight:400; color:var(--slate-500); }
.brand-mark { display:grid; place-items:center; flex-shrink:0; width:40px; height:40px; border-radius:12px; background:var(--primary); color:white; box-shadow:0 4px 12px #4f46e526; }
.icon { display:block; width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.brand-mark .icon { width:24px; height:24px; }
.user-menu { position:relative; }
.user-menu summary { display:flex; align-items:center; gap:8px; min-width:48px; min-height:48px; padding:4px; cursor:pointer; list-style:none; border-radius:12px; }
.user-menu summary::-webkit-details-marker { display:none; }
.user-menu[open] summary { background:var(--slate-100); }
.avatar { display:grid; place-items:center; width:40px; height:40px; flex-shrink:0; border:1px solid #c7d2fe; border-radius:50%; background:var(--primary-soft); color:var(--primary); font-weight:600; }
.user-name { display:none; }
.user-popover { position:absolute; right:0; top:56px; width:272px; max-width:calc(100vw - 32px); padding:16px; border:1px solid var(--border); border-radius:16px; background:white; box-shadow:0 16px 48px #0f172a1a; overflow-wrap:anywhere; }
.user-popover p { margin:4px 0 12px; font-size:12px; }
.user-popover a,.user-popover button { display:flex; align-items:center; width:100%; min-height:48px; padding:12px; border:0; border-radius:8px; background:transparent; color:var(--slate-700); text-align:left; cursor:pointer; }
.user-popover a:hover,.user-popover button:hover { background:var(--slate-100); }
.main { max-width:1440px; margin:auto; padding:24px 16px calc(104px + env(safe-area-inset-bottom)); min-width:0; }
.bottom-nav { position:fixed; bottom:0; left:0; right:0; z-index:40; display:flex; justify-content:space-around; gap:4px; padding:8px 8px calc(8px + env(safe-area-inset-bottom)); border-top:1px solid var(--border); background:#fffffffa; backdrop-filter:blur(16px); }
.nav-item { display:flex; flex:1; flex-direction:column; align-items:center; justify-content:center; gap:4px; min-height:56px; border-radius:12px; color:var(--slate-500); font-size:12px; font-weight:500; }
.nav-item.active { background:var(--primary-soft); color:var(--primary); }
.nav-item:hover { background:var(--slate-100); }
.nav-caption,.nav-footer { display:none; }
/* Tiêu đề, số liệu và thẻ dùng chung nhịp khoảng cách. */
.page-header { margin-bottom:24px; }
.page-header p { margin-top:8px; max-width:600px; }
.eyebrow { margin-bottom:8px; }
.header-row,.section-header,.card-top,.card-row { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; }
.header-row { align-items:flex-start; }
.section { margin-top:24px; }
.section-header { margin-bottom:16px; }
.section-header a { display:inline-flex; align-items:center; min-height:48px; font-weight:500; }
.welcome { padding:24px; border:1px solid #e0e7ff; border-radius:20px; background:radial-gradient(ellipse at top right,#e0e7ff 0,transparent 65%),white; }
.stat-scroll { display:grid; grid-auto-flow:column; grid-auto-columns:minmax(172px,1fr); gap:12px; overflow-x:auto; padding-bottom:8px; scroll-snap-type:x proximity; }
.stat-card { padding:16px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow); scroll-snap-align:start; }
.stat-card .label,.stat-card .hint { font-size:12px; color:var(--slate-500); }
.stat-card .label { font-weight:500; }
.stat-card .value { margin:12px 0 8px; font-size:32px; font-weight:600; line-height:1.25; letter-spacing:-1px; font-variant-numeric:tabular-nums; }
.stat-card.accent { background:var(--primary); border-color:var(--primary); color:white; }
.stat-card.accent .label,.stat-card.accent .hint { color:#e0e7ff; }
.card-grid,.stack { display:grid; gap:16px; }
.card,.schedule-card { position:relative; min-width:0; padding:16px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow); }
.card-link { display:block; color:inherit; }
.card-top { align-items:flex-start; margin-bottom:16px; gap:12px; }
.card-top>div { min-width:0; flex:1; }
.card-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-top:16px; padding-top:16px; border-top:1px solid var(--slate-100); color:var(--slate-500); font-size:12px; }
.card-footer strong { color:var(--primary); font-weight:600; }
.card-footer form,.card-footer form .btn { width:100%; }
.badge { display:inline-flex; align-items:center; gap:4px; padding:4px 8px; border-radius:6px; background:var(--slate-100); color:var(--slate-600); font-size:12px; font-weight:500; white-space:nowrap; }
.badge:before { content:''; width:6px; height:6px; background:currentColor; border-radius:50%; }
.badge.success,.badge.da_chot { background:#ecfdf5; color:#047857; }
.badge.warning,.badge.cho_dang_ky { background:#fffbeb; color:#92400e; }
.badge.danger,.badge.huy { background:#fef2f2; color:#b91c1c; }
.badge.nhap { background:var(--primary-soft); color:var(--primary); }
.officers { display:flex; flex-wrap:wrap; gap:8px; }
.officer-chip { display:inline-flex; padding:4px 8px; border-radius:8px; background:var(--slate-100); color:var(--slate-600); font-size:12px; overflow-wrap:anywhere; }
.officer-chip.lanh_dao { background:var(--primary-soft); color:var(--primary); }
.officer-chip.chi_huy { background:#ecfdf5; color:#047857; }
.shift-preview,.shift-layout { display:flex; align-items:flex-start; gap:16px; }
.shift-preview { padding:12px 0; border-top:1px solid var(--slate-100); }
.shift-time { color:var(--primary); font-size:16px; font-weight:600; font-variant-numeric:tabular-nums; }
.shift-layout>.shift-time { min-width:64px; padding:8px; border-radius:8px; background:var(--primary-soft); text-align:center; }
.shift-time small { display:block; color:var(--slate-500); font-size:12px; font-weight:400; }
.shift-info { min-width:0; flex:1; }
.shift-info .officers { margin-top:12px; }
.day-group { margin-top:24px; }
.day-header { display:flex; align-items:center; gap:12px; margin-bottom:12px; font-size:14px; }
.day-header:after { content:''; height:1px; flex:1; background:var(--border); }
/* Các nút hỗ trợ bàn phím và vùng chạm tối thiểu 48px. */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:12px 16px; border:1px solid var(--border); border-radius:10px; background:white; color:var(--slate-700); font-weight:500; text-align:center; cursor:pointer; }
.btn:hover { border-color:var(--slate-400); background:var(--slate-50); }
.btn-primary { border-color:var(--primary); background:var(--primary); color:white; box-shadow:0 2px 4px #4f46e51a; }
.btn-primary:hover { border-color:var(--primary-hover); background:var(--primary-hover); }
.btn-danger { border-color:#fecaca; color:#b91c1c; }
.btn:active,.list-item:active { transform:translateY(1px); }
button:disabled { cursor:wait; opacity:.6; }
.actions { display:flex; flex-wrap:wrap; gap:8px; }
.actions form { margin:0; }
.field { display:grid; gap:8px; flex:1; min-width:0; }
label { font-size:14px; font-weight:500; }
input:not([type=hidden]),select,textarea { width:100%; min-width:0; min-height:48px; padding:12px; border:1px solid var(--border); border-radius:10px; background:white; color:var(--slate-900); font-size:16px; }
input:hover,select:hover { border-color:var(--slate-400); }
input[aria-invalid=true] { border-color:var(--danger); }
.filter-form { display:flex; flex-wrap:wrap; align-items:end; gap:12px; margin-bottom:24px; padding:16px; border:1px solid var(--border); border-radius:16px; background:white; }
.filter-form .field { flex-basis:100%; }
.empty-state { grid-column:1/-1; padding:48px 24px; border:1px dashed var(--slate-300); border-radius:16px; background:var(--surface); text-align:center; }
.empty-icon { display:grid; place-items:center; width:56px; height:56px; margin:0 auto 16px; border-radius:16px; background:var(--primary-soft); color:var(--primary); font-size:24px; }
.empty-state p { max-width:400px; margin:8px auto 16px; }
.list-group { overflow:hidden; border:1px solid var(--border); border-radius:16px; background:white; box-shadow:var(--shadow); }
.list-item { display:flex; align-items:center; gap:16px; min-height:96px; padding:20px 16px; color:inherit; }
.list-item+.list-item { border-top:1px solid var(--slate-100); }
a.list-item:hover { background:var(--slate-50); }
.list-item:focus-visible { outline-offset:-4px; }
.list-icon { display:grid; place-items:center; width:48px; height:48px; flex-shrink:0; border:1px solid #e0e7ff; border-radius:12px; background:var(--primary-soft); font-size:20px; }
.list-item .content { flex:1; min-width:0; }
.list-item .title { font-size:16px; font-weight:600; }
.list-item .subtitle { margin-top:4px; color:var(--slate-500); font-size:12px; }
.chevron { color:var(--slate-400); font-size:24px; }
.alert { margin-bottom:16px; padding:16px; border:1px solid #c7d2fe; border-radius:12px; background:var(--primary-soft); color:var(--primary); }
.alert-error,.alert-danger { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }
.alert-warning { background:#fffbeb; color:#92400e; border-color:#fde68a; }
.alert-success { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.pagination { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:12px; margin-top:24px; }
.metric-list { display:flex; flex-wrap:wrap; gap:24px; }
.metric-list strong { display:block; font-size:20px; font-variant-numeric:tabular-nums; }
.metric-list span { color:var(--slate-500); font-size:12px; }
.progress { display:block; width:100%; height:8px; margin:16px 0 0; accent-color:var(--primary); }
.stat-card.accent .progress { accent-color:#a5b4fc; }
.login-page { display:grid; place-items:center; min-height:100svh; padding:32px 16px; background:radial-gradient(ellipse at 10% 10%,#c7d2fe80,transparent 55%),radial-gradient(ellipse at 90% 90%,#ddd6fe80,transparent 55%),#f8fafc; }
.login-card { width:100%; max-width:440px; padding:32px 24px; border:1px solid white; border-radius:24px; background:#ffffffed; box-shadow:0 24px 80px #312e8112; }
.login-card .brand-mark { width:48px; height:48px; margin-bottom:24px; }
.login-card h1 { margin:8px 0; }
.login-card form { display:grid; gap:20px; margin-top:24px; }
.login-card .help { margin-top:24px; padding-top:24px; border-top:1px solid var(--border); font-size:12px; text-align:center; }
.login-card .alert { margin-top:16px; }
.errorlist { padding:0; margin:0; list-style:none; color:#b91c1c; font-size:12px; }
.htmx-request,[aria-busy=true] { opacity:.65; cursor:progress; }
@media (hover:hover) {
  .card-link:hover { border-color:#a5b4fc; box-shadow:0 8px 24px #4f46e50c; transform:translateY(-2px); }
  .list-item:hover .chevron { color:var(--primary); }
}
@media (min-width:640px) {
  .main { padding:32px 24px 112px; }
  .card-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .user-name { display:block; max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .filter-form .field { flex-basis:200px; }
  .stat-scroll { gap:16px; }
  .login-card { padding:40px 32px; }
}
@media (min-width:1024px) {
  h1 { font-size:32px; }
  .top-bar { padding:0 32px; }
  .main { margin-left:var(--sidebar); padding:40px 40px 64px; }
  .bottom-nav { top:72px; right:auto; width:var(--sidebar); flex-direction:column; justify-content:flex-start; gap:8px; padding:24px 16px; border-top:0; border-right:1px solid var(--border); background:white; }
  .nav-item { flex:none; flex-direction:row; justify-content:flex-start; gap:12px; min-height:48px; padding:12px 16px; font-size:14px; }
  .nav-caption { display:block; padding:0 12px 12px; color:var(--slate-500); font-size:12px; }
  .nav-footer { display:block; margin-top:auto; padding:16px 12px; border-top:1px solid var(--border); color:var(--slate-500); font-size:12px; }
  .welcome { padding:32px; }
  .management-menu { max-width:800px; }
  .list-item { padding:20px 24px; }
}
@media (prefers-reduced-motion:reduce) {
  *,*:before,*:after { transition:none!important; animation:none!important; scroll-behavior:auto!important; }
}
