/* Giao diện chung cho trang HR và cổng nhân viên. Mọi màu lấy từ biến ở :root. */
:root {
  --brand: #c8202f;
  --brand-strong: #a3192a;
  --brand-soft: #fcebec;
  --brand-ring: rgba(200, 32, 47, .15);
  --ink: #1e2126;
  --ink-2: #3b4754;
  --muted: #6b7684;
  --line: #e4e8ec;
  --line-strong: #cfd6dd;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --side: #2b2c30;
  --side-ink: #c4c6cc;
  --side-label: #8b8e96;
  --shade: 30, 33, 38;
  --ok: #157f3b;      --ok-soft: #e8f6ed;
  --warn: #a15c07;    --warn-soft: #fdf3e2;
  --bad: #c0362c;     --bad-soft: #fdecea;
  --info: #2459c4;    --info-soft: #e9f0fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(var(--shade), .06), 0 1px 3px rgba(var(--shade), .05);
  --shadow-lg: 0 10px 30px rgba(var(--shade), .12);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink); }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- Khung trang HR ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: #fff url("../img/logo-flame.png") center / 72% no-repeat; display: block; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; font-size: 12px; color: var(--side-ink); }
.nav { padding: 4px 12px 16px; flex: 1; }
.nav-label { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-label); padding: 16px 10px 6px; }
.nav-label:hover { color: #d3d5da; }
.nav-label .icon { margin-left: auto; transition: transform .15s; }
.nav-label .count { background: #f0b429; color: #3a2a00; border-radius: 999px; font-size: 10.5px; font-weight: 700; padding: 0 7px; letter-spacing: 0; }
.nav-group.collapsed .nav-items { display: none; }
.nav-group.collapsed .nav-label .icon { transform: rotate(-90deg); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--side-ink); font-weight: 500; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(200, 32, 47, .22); color: #fff; }
.nav-item.active .icon { color: #ff6b76; }
.nav-item .count { margin-left: auto; background: #f0b429; color: #3a2a00; border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who small { display: block; color: var(--side-ink); font-weight: 400; }
.icon-btn { background: transparent; border: 0; color: inherit; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.page-head .eyebrow a { color: var(--muted); }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ---------- Thành phần ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 20px; }
.card + .card { margin-top: 16px; }
.section-note { color: var(--muted); font-size: 13px; margin-top: 2px; font-weight: 400; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.bad { background: var(--bad-soft); color: var(--bad); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 3px solid rgba(200, 32, 47, .3); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: #b9c2cb; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(var(--shade), .05); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #efc2be; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover { background: #106a31; color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; color: #fff; }
.avatar.lg { width: 48px; height: 48px; font-size: 19px; }
.avatar.xl { width: 88px; height: 88px; font-size: 34px; }
img.avatar.photo { object-fit: cover; background: var(--line, #e5e7eb); }
.avatar.t0 { background: #c8202f; } .avatar.t1 { background: #2459c4; } .avatar.t2 { background: #8a4fd1; }
.avatar.t3 { background: #d0632a; } .avatar.t4 { background: #c23a72; } .avatar.t5 { background: #3d7a1f; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { display: block; font-weight: 600; color: var(--ink); line-height: 1.25; white-space: nowrap; }
.person-sub { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
a.person:hover { text-decoration: none; }
a.person:hover .person-name { color: var(--brand); }

/* Bảng */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfafa; }
.table th.num, .table td.num { text-align: right; }
.table .group td { background: var(--surface-2); font-weight: 600; color: var(--ink-2); padding-top: 8px; padding-bottom: 8px; }
.table tr.weekend td:first-child { box-shadow: inset 3px 0 0 #f0b429; }
.table tr.row-warn td { background: var(--bad-soft); }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.table td .explain { color: var(--muted); font-size: 12.5px; max-width: 420px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { color: #a9b4bf; margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 15px; }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field .help { color: var(--muted); font-size: 12.5px; }
.field .error { color: var(--bad); font-size: 12.5px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); height: 38px; padding: 0 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7684' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }
.w-xs { width: 84px !important; } .w-sm { width: 120px !important; } .w-md { width: 170px !important; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px; width: 260px; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 32px 20px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { color: var(--brand); }
.dropzone input { display: none; }
.dropzone .file-name { font-weight: 600; color: var(--brand-strong); }

/* Thông báo */
.alerts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: #1d3f86; border: 1px solid #cddcf8; }
.alert.success { background: var(--ok-soft); color: #11552a; border-color: #c5e7d1; }
.alert.error { background: var(--bad-soft); color: #8a221b; border-color: #f4c9c5; }
.alert.warning { background: var(--warn-soft); color: #7a4405; border-color: #f2dcb4; }
.alert .icon { margin-top: 1px; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-link { padding: 3px 10px; border-radius: 999px; background: #fff; border: 1px solid #f2dcb4; color: #7a4405; font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.chip-link:hover { border-color: currentColor; }

/* Tháng */
.month-nav { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.month-nav a { display: grid; place-items: center; width: 36px; height: 36px; color: var(--ink-2); }
.month-nav a:hover { background: var(--surface-2); text-decoration: none; }
.month-nav span { padding: 0 12px; font-weight: 650; border-left: 1px solid var(--line); border-right: 1px solid var(--line); line-height: 36px; }

/* Tab */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel:not(.active) { display: none; }

details.pop { position: relative; display: inline-block; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop .pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px; width: 300px; }

/* Soát chấm công */
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.review { display: flex; flex-direction: column; overflow: hidden; }
.review-photo { aspect-ratio: 4 / 3; background: #dfe5ea center / cover no-repeat; display: block; position: relative; }
.review-photo .badge { position: absolute; left: 10px; top: 10px; }
.review-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.review-meta { display: flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 16px; }

/* Đơn từ */
.req { display: flex; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; }
.req-main { flex: 1; min-width: 0; }
.req-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.req-when { display: flex; gap: 6px; align-items: baseline; color: var(--ink-2); margin-top: 4px; }
.req-reason { color: var(--muted); margin-top: 4px; }
.req-actions { display: flex; flex-direction: column; gap: 8px; width: 260px; flex: none; }
.req-actions .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar .brand-mark { width: 30px; height: 30px; font-size: 15px; }
  .topbar-me { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
  .topbar-me:hover { background: rgba(255, 255, 255, .2); color: #fff; text-decoration: none; }
  .content { padding: 18px 16px 40px; }
  .search input { width: 100%; }
  .req { flex-direction: column; }
  .req-actions { width: 100%; }
}

/* ---------- Cổng nhân viên (điện thoại) ---------- */
.portal { background: var(--bg); min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); font-size: 15px; }
.portal-top { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 100%); color: #fff; padding: 18px 18px 64px; }
.portal-top .bar { display: flex; align-items: center; gap: 12px; max-width: 560px; margin: 0 auto; }
.portal-top .hello { flex: 1; min-width: 0; }
.portal-top .hello b { display: block; font-size: 18px; }
.portal-top .hello span { opacity: .8; font-size: 13px; }
.portal-top .avatar { border: 2px solid rgba(255, 255, 255, .5); }
.portal-top .icon-btn { color: #fff; }
.portal-top.compact { padding-bottom: 18px; }
.portal-top.compact h1 { color: #fff; font-size: 19px; flex: 1; }
.portal-main { max-width: 560px; margin: -48px auto 0; padding: 0 14px; }
.portal-top.compact + .portal-main { margin-top: 14px; }
.portal .card { border-radius: 16px; }
.portal .card + .card { margin-top: 14px; }
.portal input, .portal select, .portal textarea { font-size: 16px; height: 46px; border-radius: 10px; }
.portal textarea { height: auto; }
.portal .btn { height: 46px; font-size: 15px; border-radius: 10px; }
.portal .btn-sm { height: 34px; font-size: 13px; }

.clock-card { text-align: center; padding: 18px 16px 16px; }
.clock { font-size: 40px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.clock-date { color: var(--muted); margin-top: 4px; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.chip.done { background: var(--ok-soft); border-color: #c5e7d1; color: var(--ok); }
.chip.flag { background: var(--warn-soft); border-color: #f2dcb4; color: var(--warn); }
.today-info { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.today-line { display: flex; gap: 6px; align-items: center; }
.today-line > svg { flex: none; color: var(--muted); }
.punch-time { margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.punch-time.done { background: var(--ok-soft); color: var(--ok); }
.punch-time.flag { background: var(--warn-soft); color: var(--warn); }

.punch-area { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cam { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: max(140px, calc(100svh - 520px)); border-radius: 18px; overflow: hidden; background: #1d1e22; border: 1px solid var(--line); }
.cam[data-state="live"] { border-color: var(--brand); }
.cam video, .cam img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; color: #e9e9ec; font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.cam[data-state="live"] .cam-msg { display: none; }
.cam[data-state="error"] { background: var(--bad-soft); border-color: #f1c4bf; aspect-ratio: auto; min-height: 180px; }
.cam[data-state="error"] .cam-msg { color: #8a221b; }
.cam-hint { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.punch-btn { width: 100%; height: 62px; border-radius: 16px; border: 0; font: inherit; font-size: 19px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #de3442, var(--brand)); box-shadow: 0 8px 20px rgba(200, 32, 47, .3); display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; transition: transform .1s; }
.punch-btn:active { transform: scale(.98); }
.punch-btn:disabled { opacity: .6; box-shadow: none; cursor: not-allowed; }
.result { width: 100%; display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-weight: 500; }
.result.ok { background: var(--ok-soft); color: #11552a; }
.result.bad { background: var(--bad-soft); color: #8a221b; }
.result.busy { background: var(--surface-2); color: var(--ink-2); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; color: var(--ink); border-color: var(--line-strong); }
.tile .tile-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.tile b { font-size: 15px; }
.tile span { color: var(--muted); font-size: 12.5px; margin-top: -6px; }
.tile .tile-icon.warn { background: var(--warn-soft); color: var(--warn); }
.tile .tile-icon.info { background: var(--info-soft); color: var(--info); }


.day { display: flex; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.day:last-child { border-bottom: 0; }
.day-date { width: 46px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2); padding: 4px 0; }
.day-date b { display: block; font-size: 18px; line-height: 1.2; }
.day-date span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; }
.day-date.weekend { background: #fff6e0; }
.day-shifts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.day-shift { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.day-value { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.day-shift .times { font-weight: 600; font-variant-numeric: tabular-nums; }
.day-shift .times small { color: var(--muted); font-weight: 400; }
.day-explain { color: var(--muted); font-size: 12.5px; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.segmented label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--surface); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
.tabbar a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0; position: relative; }
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--brand); }
.tabbar .dot { position: absolute; top: 0; left: calc(50% + 6px); background: var(--bad); color: #fff; font-size: 10px; border-radius: 999px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- Đăng nhập, đã thoát, quên mật khẩu (portal/auth_base.html) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; background: var(--bg); }
.auth-side { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: 56px 8%; background: var(--side); color: #fff; }
.auth-side::before { content: ""; position: absolute; right: -14%; bottom: -12%; width: 70%; aspect-ratio: 448 / 649; background: url("../img/logo-flame.png") center / contain no-repeat; opacity: .14; transform: rotate(-8deg); }
.auth-side::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--brand); }
.auth-side-inner { position: relative; max-width: 440px; }
.auth-side-mark { display: block; width: 64px; height: 64px; margin-bottom: 28px; border-radius: 18px; background: #fff url("../img/logo-flame.png") center / 66% no-repeat; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.auth-side h2 { color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 14px; }
.auth-side p { color: var(--side-ink); font-size: 16px; line-height: 1.6; margin: 0; }
.auth-side-foot { position: absolute; left: 8%; bottom: 28px; color: var(--side-label); font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(circle at 85% 0%, var(--brand-soft) 0, transparent 40%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px 32px; border-radius: 20px; box-shadow: var(--shadow-lg); border-top: 4px solid var(--brand); }
.auth-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 26px; }
.auth-title { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-sub { color: var(--muted); text-align: center; margin-bottom: 22px; }
.auth-title + :not(.auth-sub) { margin-top: 20px; }
.auth-done { display: flex; align-items: center; gap: 10px; padding: 14px 16px; margin-bottom: 20px; border-radius: var(--radius-sm); background: var(--ok-soft); color: #11552a; font-weight: 500; }
.auth-done .icon { color: var(--ok); }
.auth input { height: 48px; font-size: 16px; }
.auth .btn { height: 48px; font-size: 16px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { align-items: start; padding: max(40px, 8vh) 16px 32px; }
  .auth-card { padding: 30px 22px 26px; box-shadow: var(--shadow); }
}

.review-grid > .card + .card { margin-top: 0; }
.inline-form.keep { flex-wrap: nowrap; }
.badge.wrap { white-space: normal; }

/* ---------- Trang quản lý (nhân viên, cơ sở, ca & lịch) ---------- */
a.stat.link { color: inherit; transition: border-color .15s, box-shadow .15s; }
a.stat.link:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
a.stat.link.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(200, 32, 47, .12); }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }

.toolbar { gap: 10px; }
.pills { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.pill { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.pill span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.pill:hover { text-decoration: none; color: var(--ink); }
.pill.on { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow); }
select.w-auto { width: auto; min-width: 180px; }
.filter-note { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 20px; background: var(--warn-soft); color: #7a4405; border-bottom: 1px solid #f2dcb4; }
.filter-note .clear { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; font-weight: 600; }

.table.clickable tbody tr[data-href] { cursor: pointer; }
.table tr.faded td { color: var(--muted); }
.table tr.faded .avatar { opacity: .5; }
.table.week th.c, .table.week td.c { text-align: center; padding-left: 6px; padding-right: 6px; }
.dot-on { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.dot-off { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; }
.template-grid > .card + .card { margin-top: 0; }
.pick-grid .cell { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.pick-grid .cell:hover { background: var(--brand-soft); }
.pick-grid input[type=checkbox] { width: 20px; height: 20px; }
.col-toggle { background: none; border: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.col-toggle:hover { background: var(--brand-soft); color: var(--brand); }

.bulk-bar { position: sticky; bottom: 16px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--side); color: #fff; padding: 10px 12px 10px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 30; }
.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.issued { border-color: #f2dcb4; margin-bottom: 20px; }
.issued .card-head { background: var(--warn-soft); border-radius: var(--radius) var(--radius) 0 0; }
code.secret { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px; font-weight: 700; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 6px; padding: 2px 8px; letter-spacing: .04em; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.split-main > .card + .card, .split-side > .card + .card { margin-top: 16px; }
.split-side { position: sticky; top: 20px; }
.side-title { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.side-title .icon { color: var(--brand); }
.split-side p { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.req-mark { color: var(--bad); }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0; margin-top: 4px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.save-bar.in-card { position: static; background: var(--surface-2); border-top: 1px solid var(--line); padding: 14px 20px; border-radius: 0 0 var(--radius) var(--radius); margin: 0; }
.card.narrow { max-width: 720px; }
.person.big { gap: 14px; }
.person.big h1 { margin-bottom: 2px; }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chips label { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 14px 7px 10px; cursor: pointer; font-weight: 500; background: var(--surface); }
.check-chips label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }

.big-number { font-size: 30px; font-weight: 700; line-height: 1.1; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.big-number small { font-size: 13px; font-weight: 500; color: var(--muted); }
.ledger { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--line); }
.ledger li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ledger li > span:first-child { width: 44px; flex: none; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ledger small { display: block; color: var(--muted); }
details.disclose > summary { cursor: pointer; font-weight: 600; color: var(--brand); display: inline-flex; gap: 6px; align-items: center; padding: 6px 0; list-style: none; }
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose[open] > summary { margin-bottom: 10px; }

.locate-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.locate-tools .grow { flex: 1; min-width: 260px; }
.locate-tools .grow input { width: 100%; }
.map { height: 380px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-top: 12px; z-index: 0; }
.help.ok { color: var(--ok); } .help.bad { color: var(--bad); } .help.warn { color: var(--warn); }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .split-side { position: static; }
}
@media (max-width: 700px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Phiếu lương */
.slip-table td.num { white-space: nowrap; }
.slip-total td { font-weight: 700; border-top: 2px solid var(--line); }
.slip-net { font-size: 22px; font-weight: 800; color: var(--brand, inherit); }
@media print {
  .sidebar, .topbar, .tabbar, .alerts, .no-print { display: none !important; }
  .app, .main, .content { display: block !important; margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
}

/* Sơ đồ tổ chức: cây khung nối bằng đường kẻ, cuộn ngang khi nhiều bộ phận */
.org-chart { overflow-x: auto; padding: 20px; }
.org-tree, .org-tree ul { display: flex; justify-content: center; padding-top: 18px; position: relative; margin: 0; list-style: none; }
.org-tree { padding-top: 0; min-width: max-content; }
.org-tree li { position: relative; padding: 18px 6px 0; display: flex; flex-direction: column; align-items: center; }
.org-tree > li { padding-top: 0; }
.org-tree li::before, .org-tree li::after { content: ""; position: absolute; top: 0; width: 50%; height: 18px; border-top: 1px solid var(--line-strong); }
.org-tree li::before { right: 50%; }
.org-tree li::after { left: 50%; border-left: 1px solid var(--line-strong); }
.org-tree li:only-child::before, .org-tree li:only-child::after, .org-tree > li::before, .org-tree > li::after { display: none; }
.org-tree li:only-child { padding-top: 18px; }
.org-tree > li:only-child { padding-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border: 0 none; }
.org-tree li:last-child::before { border-right: 1px solid var(--line-strong); }
.org-tree ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 18px; border-left: 1px solid var(--line-strong); }
.org-tree li:only-child::after { display: block; border-top: 0; width: 0; height: 18px; }
.org-box { display: flex; flex-direction: column; gap: 2px; min-width: 130px; max-width: 180px; padding: 10px 12px; border: 1px solid var(--line-strong); border-top: 3px solid var(--brand); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-align: center; font-size: 13px; }
.org-box:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.org-box.short { border-top-color: var(--warn); }
.org-head { color: var(--ink-2); }
.org-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Danh sách nhãn – giá trị (hồ sơ NV trên điện thoại) */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bad-text { color: var(--bad); }

/* Lưới tháng NV × ngày (Tổng quan, Phân ca): cột tên NV và hàng ngày dính khi cuộn */
.grid-scroll { overflow: auto; max-height: calc(100vh - 250px); }
.month-grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.month-grid th, .month-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap; min-width: 92px; vertical-align: middle; }
.month-grid th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.month-grid th small { display: block; font-weight: 500; }
.month-grid th.holiday { color: var(--bad); }
.month-grid th.today { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }
.month-grid .who { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; min-width: 220px; }
.month-grid th.who { z-index: 3; background: var(--surface-2); }
.month-grid tbody tr:hover td { background: #fbfafa; }
.month-grid td.cell-flag { background: var(--warn-soft); }
.month-grid td.cell-outside { background: var(--info-soft); }
.month-grid td.changed { box-shadow: inset 0 0 0 2px #f0b429; }
.month-grid .mark { margin-left: 4px; font-size: 10.5px; font-weight: 700; color: var(--brand); }
.month-grid a.cell { display: block; color: inherit; border-radius: 6px; padding: 2px; min-height: 22px; }
.month-grid a.cell:hover { background: var(--brand-soft); text-decoration: none; }
.shift-chip { display: block; margin: 2px 0; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; font-size: 11.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 4px; border-radius: 3px; vertical-align: -2px; }
/* Lịch tháng của NV (trang Công tháng): ô màu theo chú thích giống Base, bấm ô xem chi tiết */
/* Tổng quan chấm công: STT, D/H, ô giờ vào trên – ra dưới, sửa trực tiếp */
.punch-grid th, .punch-grid td { min-width: 58px; padding: 4px 6px; }
.punch-grid th .wd { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .02em; }
.punch-grid th.sunday { color: var(--bad); }
.punch-grid .no { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 40px; width: 40px; color: var(--muted); }
.punch-grid th.no { z-index: 3; background: var(--surface-2); }
.punch-grid .who { left: 40px; min-width: 240px; max-width: 240px; width: 240px; }
.punch-grid .who-text { min-width: 0; overflow: hidden; }
.punch-grid .who .person-sub { overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.punch-grid .dh { position: sticky; left: 280px; z-index: 2; background: var(--surface); min-width: 70px; text-align: left; font-size: 11.5px; color: var(--muted); box-shadow: 2px 0 0 var(--line); }
.punch-grid th.dh { z-index: 3; background: var(--surface-2); }
.punch-grid .dh span { display: block; }
.punch-grid .dh b { color: var(--ink); }
.punch-grid td.cell-edit { cursor: pointer; height: 46px; }
.punch-grid td.cell-edit:hover { box-shadow: inset 0 0 0 2px var(--brand); }
.punch-grid .t-in, .punch-grid .t-out { display: block; line-height: 1.35; }
.punch-grid .t-out { border-top: 1px dashed var(--line); color: var(--ink-2); }
.punch-grid td.today, .punch-grid th.today { box-shadow: inset 2px 0 0 var(--info); }
.edit-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.edit-dialog::backdrop { background: rgba(var(--shade), .35); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.dialog-body { padding: 16px 20px 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; background: var(--surface-2); border-top: 1px solid var(--line); }
.punch-list { list-style: none; margin: 8px 0 14px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.punch-list > li { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line); }
.punch-list > li:last-child { border-bottom: 0; }
.punch-list > li .btn { margin-left: auto; }
.punch-list > li.on { background: var(--warn-soft); }
.punch-list > li.muted { padding: 10px 12px; }
.punch-list > li .actions { margin-left: auto; display: flex; gap: 2px; }
.punch-list > li .actions .btn { margin-left: 0; }
.punch-list > li.removed > b { color: var(--muted); text-decoration: line-through; }
.punch-list > li.pd-row { display: block; padding: 12px; background: var(--surface-2); }
.punch-list > li.pd-row[hidden] { display: none; }
.edit-dialog:has(.pd-row:not([hidden])) { width: min(600px, calc(100vw - 32px)); }
.pd-top { display: flex; gap: 12px; align-items: flex-start; }
.pd-photo { flex: none; width: 96px; height: 120px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); border: 1px solid var(--line); display: block; }
.pd-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-photo.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 11.5px; text-align: center; padding: 6px; }
.pd-head { min-width: 0; }
.pd-time { font-size: 18px; font-weight: 700; }
.pd-time .muted { font-size: 13px; font-weight: 500; }
.pd-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pd-flag { display: flex; gap: 6px; align-items: flex-start; color: var(--warn); font-size: 12.5px; margin-top: 4px; }
.pd-sec { display: flex; align-items: center; gap: 6px; margin: 14px 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.pd-kv { display: grid; grid-template-columns: 110px 1fr; gap: 5px 12px; margin: 0; font-size: 13px; }
.pd-kv dt { color: var(--muted); }
.pd-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pd-kv dd .badge { margin-left: 4px; }
.pd-code { font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.pd-ua { font-size: 12px; color: var(--ink-2); }
.pd-history { margin: 0; padding-left: 18px; font-size: 13px; }
.pd-foot { margin: 12px 0 0; }
.pd-error { color: var(--bad); font-size: 13px; }

.portal-top .hello .profile-link { display: block; font-size: 12.5px; opacity: .75; }

/* Điện thoại: thẻ số liệu 2 cột, lưới tháng chừa chỗ cho cột ngày */
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 8px; }
  .stat > div { min-width: 0; }
  .stat-value { font-size: 17px; white-space: nowrap; }
  .page-head .sub { font-size: 13px; }
  .punch-grid .no { display: none; }
  .punch-grid .who { left: 0; min-width: 132px; max-width: 132px; width: 132px; }
  .punch-grid .who .avatar { display: none; }
  .punch-grid .who .person-sub { max-width: 116px; }
  .punch-grid .dh { left: 132px; min-width: 56px; }
  .month-grid .who { min-width: 132px; }
}
.next-punch { margin-top: 12px; padding: 9px 14px; text-align: left; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-strong); font-size: 14.5px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.next-punch.done { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
/* Ô ngày/giờ kiểu Việt Nam (static/js/vn-inputs.js): chữ của ô gốc ẩn, lớp chữ dd/mm/yyyy phủ lên trên */
.vn-input { position: relative; display: block; }
.vn-input[class*="w-"] { display: inline-block; vertical-align: middle; }
.vn-input input { display: block; color: transparent; }
.vn-input input::-webkit-datetime-edit { opacity: 0; }
.vn-input-text { position: absolute; left: 13px; top: 0; bottom: 0; display: flex; align-items: center; pointer-events: none; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vn-input-text.blank { color: var(--muted); }
.portal .vn-input-text { font-size: 16px; }
/* Ô giờ gõ tay 24h + bảng chọn giờ/phút (static/js/vn-inputs.js) */
.time-box { position: relative; display: block; }
.time-box[class*="w-"] { display: inline-block; vertical-align: middle; }
.time-box input.time-text { padding-right: 40px; font-variant-numeric: tabular-nums; }
.time-box input.time-text.invalid { border-color: var(--bad); background: var(--bad-soft); }
.time-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.time-btn:hover, .time-box.open .time-btn { color: var(--brand); background: var(--brand-soft); }
.time-pop { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; display: flex; gap: 4px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); scroll-margin: 16px 0 96px; }
.time-pop[hidden] { display: none; }
.time-col { position: relative; display: flex; flex-direction: column; width: 56px; max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.time-col + .time-col { border-left: 1px solid var(--line); padding-left: 4px; }
.time-col button { flex: none; height: 32px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer; }
.time-col button:hover { background: var(--surface-2); }
.time-col button.on { background: var(--brand); color: #fff; font-weight: 600; }
.portal .time-col button { height: 40px; font-size: 16px; }
.portal .time-col { width: 64px; max-height: 240px; }
.dt-split { display: flex; gap: 8px; }
.dt-split > .vn-input { flex: 1 1 60%; min-width: 0; }
.dt-split > .time-box { flex: 1 1 40%; min-width: 96px; }
/* Bảng thành thẻ trên điện thoại: thêm class cards-sm cho bảng, data-label cho ô; card-main = dòng tên, card-hide = ẩn */
@media (max-width: 600px) {
  .table.cards-sm thead { display: none; }
  .table.cards-sm, .table.cards-sm tbody, .table.cards-sm td { display: block; }
  .table.cards-sm tr { position: relative; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table.cards-sm td { padding: 0; border: 0; text-align: left; min-width: 0; white-space: normal; }
  .table.cards-sm td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 2px; }
  .table.cards-sm td.card-main { grid-column: 1 / -2; }
  .table.cards-sm td.card-badge { grid-column: -2 / -1; justify-self: end; align-self: center; }
  .table.cards-sm td.card-check:empty, .table.cards-sm td.card-hide { display: none; }
  .table.cards-sm td.card-check { position: absolute; right: 16px; top: 18px; }
  .table.cards-sm td.card-check + .card-main { grid-column: 1 / -1; padding-right: 32px; }
  .table.cards-sm td[colspan] { grid-column: 1 / -1; }
  .table.cards-sm.cards-2 tr { grid-template-columns: 1fr 1fr; }
  .table.cards-sm td .badge { white-space: normal; }
}

@media (max-width: 600px) {
  .pd-kv { grid-template-columns: 1fr; gap: 0; }
  .pd-kv dd { margin-bottom: 6px; }
  .pd-photo { width: 80px; height: 100px; }
}

/* ---------- Công của tôi (NV, giống app Base) ---------- */
.mm-main { max-width: 600px; }
.mm-bar { gap: 8px; }
.mm-month { display: inline-flex; align-items: center; gap: 2px; }
.mm-month a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: #fff; }
.mm-month a:hover { background: rgba(255, 255, 255, .12); }
.mm-month span { font-weight: 700; font-size: 16px; min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; }
.mm-layout { display: grid; gap: 14px; }
.mm-layout > * { min-width: 0; }
.portal .mm-layout .card + .card { margin-top: 0; }
.mm-detail { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 12px; }
.mm-detail.hidden { display: none; }

.mm-stats { display: grid; grid-template-columns: 1fr 1fr; text-align: center; }
.mm-stats > div { padding: 12px 6px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.mm-stats > div:nth-child(odd) { border-right: 1px solid var(--line); }
.mm-stats span { color: var(--muted); font-size: 12.5px; }
.mm-stats b { font-size: 15.5px; font-variant-numeric: tabular-nums; }
.mm-stats small { color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.mm-allowed { color: var(--ok); font-size: 12px; font-weight: 500; }
.mm-over { color: var(--warn); font-size: 12px; font-weight: 500; }
.mm-note { grid-column: 1 / -1; margin: 0; padding: 8px 12px 10px; color: var(--muted); font-size: 12.5px; }

.mm-cal { padding: 10px 8px 12px; }
.mm-head, .mm-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.mm-head span { text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; padding: 2px 0 8px; }
.mm-week + .mm-week { margin-top: 5px; }
.mm-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 58px; padding: 6px 1px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; }
.mm-day.out { border: 0; background: none; cursor: default; color: var(--line-strong); font-size: 13px; font-weight: 600; justify-content: flex-start; padding-top: 6px; }
.mm-num { font-size: 13.5px; font-weight: 700; line-height: 1; }
.mm-marks { display: flex; gap: 3px; min-height: 18px; }
.mm-times { display: none; font-size: 10.5px; line-height: 1.2; text-align: center; min-height: 25px; }
.mm-cal.show-times .mm-marks { display: none; }
.mm-cal.show-times .mm-times { display: block; }
.mm-day.full { background: #22a559; border-color: #22a559; color: #fff; }
.mm-day.late { background: #ee8a14; border-color: #ee8a14; color: #fff; }
.mm-day.short { background: #9056c8; border-color: #9056c8; color: #fff; }
.mm-day.zero { background: #e85d57; border-color: #e85d57; color: #fff; }
.mm-day.pending { background: var(--surface-2); border-color: var(--line-strong); }
.mm-day.holiday:not(.full):not(.late):not(.short):not(.zero) .mm-num { color: var(--bad); }
.mm-day.today { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); }
.mm-day.today .mm-num { text-decoration: underline; text-underline-offset: 2px; }
.mm-day.on { outline: 3px solid #1d4ed8; outline-offset: 1px; }
.mk-wrap { position: relative; display: inline-flex; }
.mk-pen { position: absolute; right: -1px; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #1d4ed8; box-shadow: 0 0 0 1.5px #fff; }

.mk { flex: none; vertical-align: middle; color: var(--ink-2); }
.mk .soft { fill: currentColor; fill-opacity: .28; stroke: none; }
.mm-day .mk { color: var(--muted); }
.mm-day:is(.full, .late, .short, .zero) .mk { color: #fff; }
.mm-day:is(.full, .late, .short, .zero) .mk .soft { fill-opacity: .45; }
.mm-shift-mark .mk, .mm-legend .mk { color: var(--muted); }
:is(.mm-shift-mark, .mm-legend) :is(.mk-full, .mk-no-check) { color: #1f9d55; }
:is(.mm-shift-mark, .mm-legend) :is(.mk-late, .mk-early) { color: #d27408; }
:is(.mm-shift-mark, .mm-legend) :is(.mk-missing, .mk-too-late) { color: #8a4fc4; }
:is(.mm-shift-mark, .mm-legend) :is(.mk-absent, .mk-unpaid) { color: #d6453f; }
:is(.mm-shift-mark, .mm-legend) :is(.mk-annual, .mk-holiday, .mk-outside, .mk-edited) { color: #2f6fd1; }

.mm-switch { display: flex; align-items: center; gap: 10px; margin: 14px 6px 0; font-size: 14px; cursor: pointer; }
.mm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mm-track { flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; }
.mm-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.mm-switch input:checked + .mm-track { background: #22a559; }
.mm-switch input:checked + .mm-track::after { transform: translateX(20px); }
.mm-switch input:focus-visible + .mm-track { outline: 2px solid var(--brand); outline-offset: 2px; }

.mm-title { font-size: 15.5px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.mm-title .muted { font-weight: 500; }
.mm-shift { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mm-shift:last-child { border-bottom: 0; }
.mm-shift-mark { padding-top: 1px; }
.mm-shift-body { flex: 1; min-width: 0; }
.mm-shift-name { font-weight: 600; margin-bottom: 4px; }
.mm-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 14px; }
.mm-facts dt { color: var(--muted); }
.mm-facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.mm-explain { margin-top: 6px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.mm-links { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 13.5px; color: var(--line-strong); }
.mm-links a { color: var(--muted); }
.mm-links a:hover { color: var(--brand); }
.mm-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px; color: var(--muted); }
.mm-punch { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mm-punch:last-child { border-bottom: 0; }
.mm-punch b { font-size: 16px; font-variant-numeric: tabular-nums; }
.mm-punch.removed b { text-decoration: line-through; color: var(--muted); }
.mm-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #2f80d1; margin-top: 7px; }
.mm-punch.removed .mm-dot { background: var(--line-strong); }

.mm-legend-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px 14px; font-size: 13.5px; }
.mm-legend-cols > div { display: flex; flex-direction: column; gap: 6px; }
.mm-legend-cols > div > div { display: flex; align-items: center; gap: 8px; }
.mm-swatch { flex: none; width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: var(--surface-2); border: 1px solid var(--line-strong); }
.mm-swatch.full { background: #22a559; border-color: #22a559; }
.mm-swatch.late { background: #ee8a14; border-color: #ee8a14; }
.mm-swatch.short { background: #9056c8; border-color: #9056c8; }
.mm-swatch.zero { background: #e85d57; border-color: #e85d57; }

@media (max-width: 380px) {
  .mm-head, .mm-week { gap: 3px; }
  .mm-day { min-height: 52px; }
  .mm-marks .mk { width: 15px; height: 15px; }
}
@media (min-width: 1024px) {
  .mm-main { max-width: 1240px; padding: 0 24px; }
  .mm-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr; align-items: start; }
  .mm-stats, .mm-cal, .mm-legend { grid-column: 1; }
  .mm-details { grid-column: 2; grid-row: 1 / span 3; }
  .mm-day { min-height: 74px; }
  .mm-num { font-size: 15px; }
  .mm-marks .mk { width: 20px; height: 20px; }
  .portal-top.compact .mm-bar { max-width: 1192px; }
}

/* ---------- Cơ sở: nhân viên được chấm + thiết bị ---------- */
.count-link { font-weight: 600; }
.member-tools { display: flex; flex-wrap: wrap; gap: 10px 24px; border-bottom: 1px solid var(--line); }
.member-tools select { min-width: 260px; max-width: 100%; }
.member-depts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.member-depts .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.dept-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 13px; font-weight: 600; }
.dept-chip.muted-chip { background: #eef1f4; color: var(--ink-2); }
.chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; width: 22px; height: 22px; border-radius: 999px; font-size: 12px; line-height: 1; }
.chip-x:hover { background: rgba(var(--shade), .08); }
.member-table td { vertical-align: top; }
.device-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px 0; }
.device-row + .device-row { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; }
.device-name { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
@media (max-width: 600px) {
  .table.cards-sm.cards-1 tr { grid-template-columns: 1fr; }
  .member-tools .inline-form { width: 100%; }
  .member-tools select { min-width: 0; flex: 1 1 100%; width: 100%; }
  .member-table td.num { text-align: left; }
}

@media (max-width: 600px) {
  .table.cards-sm td.card-actions { grid-column: 1 / -1; }
  .card-actions .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .card-actions .row-actions .inline-form { flex-wrap: wrap; justify-content: flex-start !important; }
  .bulk-wrap { flex-wrap: wrap; }
  .bulk-wrap .bulk-reason { width: 100%; }
  .bulk-wrap .bulk-reason input { flex: 1; min-width: 0; }
  .toolbar .inline-form.keep { flex-wrap: wrap; }
}
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.check-inline input, .member-table .col-check input { width: 16px; height: 16px; }
.member-bulk { flex-wrap: wrap; display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.member-table .col-check { width: 36px; padding-right: 0; }
@media (max-width: 600px) {
  .member-table td.col-check { position: absolute; right: 16px; top: 16px; }
}

/* ---------- Sơ đồ tổ chức: chức vụ đã xóa (xóa mềm) ---------- */
.row-removed td { color: var(--muted); }
.row-removed td a { color: var(--ink-2); }
@media (max-width: 600px) {
  .table.cards-sm td.card-wide { grid-column: 1 / -1; }
}

/* ---------- Đơn từ của NV (giống Base: tab + nút Tạo đề xuất) ---------- */
.rq-search .search input { width: 100%; }
.rq-tabs { margin: 10px 0 12px; }
.rq-notify { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.rq-list { display: grid; gap: 10px; padding-bottom: 96px; }
.rq-card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; color: var(--ink); box-shadow: var(--shadow); }
a.rq-card:hover { text-decoration: none; border-color: var(--brand); }
.rq-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rq-title { font-weight: 700; line-height: 1.3; }
.rq-line { display: flex; gap: 6px; align-items: baseline; color: var(--ink-2); font-size: 13.5px; }
.rq-line.muted { color: var(--muted); }
.rq-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.rq-go { display: inline-flex; align-items: center; color: var(--brand); font-weight: 600; font-size: 13px; }
.rq-dock { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 25; max-width: 532px; margin: 0 auto; display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(16, 24, 40, .14); }
.rq-dock .btn { flex: 1; }
.rq-balance { display: flex; flex-direction: column; align-items: center; min-width: 92px; font-size: 12px; color: var(--muted); }
.rq-balance b { font-size: 18px; color: var(--ink); }
.rq-hint { margin: 0 2px 10px; }
.rq-kinds { padding: 4px 0; }
.rq-kind { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.rq-kind:last-child { border-bottom: 0; }
.rq-kind:hover { text-decoration: none; background: var(--surface-2); }
.rq-kind .tile-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.rq-kind-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rq-kind-text span { color: var(--muted); font-size: 13px; }
.rq-rules { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.rq-rules li { color: var(--ok); }
.rq-rules li.required { color: var(--warn); }
.sp { display: flex; flex-direction: column; gap: 10px; }
.sp-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sp-add .vn-input, .sp-add .sp-date { flex: 0 1 280px; min-width: 0; }
.sp-days { display: flex; flex-direction: column; gap: 10px; }
.sp-day { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); transition: box-shadow .2s; }
.sp-day.flash { box-shadow: 0 0 0 3px var(--brand-soft); border-color: var(--brand); }
.sp-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sp-shift { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; border-top: 1px dashed var(--line); }
.sp-shift:first-child { border-top: 0; padding-top: 0; }
.sp-shift-name { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.sp .check-chips label { font-size: 14px; padding: 6px 12px 6px 9px; }
.sp .check-chips input[type=checkbox] { height: 18px; width: 18px; margin: 0; }
.sp .check-chips label.off { opacity: .55; cursor: not-allowed; }
.sp-why { font-weight: 400; font-size: 12px; }
.sp-holiday { color: var(--warn); font-size: 13px; margin-bottom: 6px; }
.sp-error { color: var(--bad); font-size: 13px; }
.sp-summary { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sp-summary.over { color: var(--bad); }
.rq-range { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rq-range .field { min-width: 0; }
.rq-range input { width: 100%; min-width: 0; }
.rq-approvers { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; }
.rq-readonly { min-height: 46px; display: flex; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
@media (max-width: 420px) {
  .rq-range { grid-template-columns: 1fr; }
}
@media (min-width: 1024px) {
  .portal-main.rq-main { max-width: 1040px; }
  .rq-main .rq-list { grid-template-columns: 1fr 1fr; }
  .rq-dock { max-width: 1012px; }
  body:has(.rq-main) .portal-top .bar { max-width: 1012px; }
  .rq-search .search input { max-width: 420px; }
}

/* ---------- Danh sách nhân sự (bảng rộng kiểu Base) ---------- */
.view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.view-tab { padding: 10px 14px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.view-tab:hover { color: var(--ink); text-decoration: none; }
.view-tab.on { color: var(--brand-strong); border-bottom-color: var(--brand); }
.view-tab.saved { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; }
.view-tab.saved a { color: inherit; display: inline-flex; align-items: center; gap: 5px; }
.view-tab.saved a:hover { text-decoration: none; color: var(--ink); }
.view-tab .view-edit { color: var(--muted); }
.view-tab.add { text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.view-sep { width: 1px; background: var(--line); margin: 8px 6px; flex: none; }
.col-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.col-picker label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 500; }
.col-group + .col-group { margin-top: 18px; }
.col-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 6px; display: flex; gap: 10px; align-items: center; }
.col-group h3 button { font: inherit; font-size: 12px; text-transform: none; letter-spacing: 0; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; }
.roster-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.roster-tools .search input { width: 280px; height: 36px; }
.tool-group { display: contents; }
.tool-toggle { display: none; }
.tool-select { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 0 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); }
.tool-select.on { border-color: var(--warn); background: var(--warn-soft); }
.tool-select > .icon { color: var(--muted); flex: none; }
.tool-select select { border: 0; background-color: transparent; height: 34px; width: auto; padding-left: 0; box-shadow: none; font-weight: 500; }
.tool-select .dir { display: inline-flex; align-items: center; gap: 3px; padding: 0 10px; height: 34px; border-left: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.roster-tools .btn-sm { height: 36px; }
.roster-tools + .filter-note { border-radius: var(--radius); margin-bottom: 12px; }
.roster-wrap { max-height: calc(100vh - 250px); min-height: 320px; overflow: auto; }
.roster { min-width: 100%; width: max-content; }
.roster th { z-index: 2; padding: 0; }
.roster th .th-sort { display: flex; align-items: center; gap: 4px; padding: 10px 14px; color: inherit; }
.roster th .th-sort:hover { color: var(--ink); text-decoration: none; }
.roster th .th-sort.on { color: var(--brand-strong); }
.roster th.stick-check { padding: 10px 11px; }
.roster td { white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.roster td.wrap { white-space: normal; min-width: 220px; max-width: 320px; }
.roster td.code { color: var(--brand-strong); font-weight: 600; }
.roster td.mono, .roster .mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.roster .stick { position: sticky; background: var(--surface); z-index: 1; }
.roster thead .stick { z-index: 3; background: var(--surface-2); }
.roster .stick-check { left: 0; width: 40px; min-width: 40px; max-width: 40px; }
.roster .stick-name { left: 40px; min-width: 240px; max-width: 300px; box-shadow: inset -1px 0 0 var(--line); }
.roster.compact td { padding-top: 5px; padding-bottom: 5px; }
.roster.compact .avatar { width: 26px; height: 26px; font-size: 12px; }
.roster.compact .person-sub { display: none; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; background: var(--muted); vertical-align: 0; }
.status-dot.ok { background: #22a559; } .status-dot.warn { background: #e59a1a; } .status-dot.info { background: var(--info); } .status-dot.muted { background: #b3bcc5; }
@media (max-width: 600px) {
  .roster-tools .search { flex: 1; min-width: 0; }
  .roster-tools .search input { width: 100%; }
  .tool-toggle { display: inline-flex; }
  .tool-group { display: none; }
  .tool-group.show { display: grid; gap: 8px; width: 100%; }
  .tool-select select { flex: 1; min-width: 0; }
  .tool-group .density { display: none; }
  .roster-wrap { max-height: none; min-height: 0; overflow: visible; }
  .roster { width: 100%; }
  .roster .stick { position: static; max-width: none; box-shadow: none; }
  .roster td, .roster td.wrap { max-width: none; min-width: 0; white-space: normal; overflow: visible; }
}

/* ---------- Khung theo màn hình ----------
   Mọi trang (HR lẫn cá nhân NV) dùng chung 1 khung (templates/base.html).
   Máy tính (> 900px): sidebar trái, nội dung rộng hết màn, không có thanh tab dưới.
   Điện thoại (≤ 900px): sidebar ẩn sau nút Menu, thanh tab dưới luôn hiện. */
.tabbar button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0; background: none; border: 0; cursor: pointer; }
@media (max-width: 900px) {
  body:has(.tabbar) { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (min-width: 901px) {
  .tabbar { display: none; }
  .portal { padding-bottom: 0; font-size: 14px; }
  .portal-top, .portal-top.compact { background: none; color: var(--ink); padding: 28px 32px 0; }
  .portal-top .bar, .portal-top.compact .mm-bar, body:has(.rq-main) .portal-top .bar { max-width: none; margin: 0; }
  .portal-top.compact h1 { color: var(--ink); font-size: 22px; }
  .portal-top .icon-btn { color: var(--ink-2); }
  .portal-top .icon-btn:hover { background: rgba(var(--shade), .05); color: var(--ink); }
  .portal-top .avatar { border-color: var(--line); }
  .portal-logout { display: none; }
  .mm-month a { color: var(--ink-2); border: 1px solid var(--line-strong); background: var(--surface); }
  .mm-month a:hover { background: var(--surface-2); color: var(--ink); }
  .portal-main, .portal-top.compact + .portal-main, .portal-main.mm-main, .portal-main.rq-main { max-width: none; margin: 0; padding: 20px 32px 48px; }

  .home-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
  .home-main > :not(.card) { grid-column: 1 / -1; }
  .portal .home-main > .card + .card { margin-top: 0; }
  .home-main .clock-card { display: flex; flex-direction: column; justify-content: center; }
  .home-main .cam { max-width: 520px; max-height: none; }
  .home-main .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; }

  .rq-list { padding-bottom: 0; }
  .rq-main { display: flex; flex-direction: column; }
  .rq-dock { position: static; max-width: none; margin: 0 0 14px; box-shadow: var(--shadow); order: -1; justify-content: space-between; }
  .rq-dock .btn { flex: none; }
}
@media (min-width: 1440px) {
  .rq-main .rq-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.tabbar a, .tabbar button { min-width: 0; white-space: nowrap; }
@media (max-width: 420px) {
  .tabbar a, .tabbar button { font-size: 10.5px; letter-spacing: -.01em; }
}
.btn-link { background: none; border: 0; padding: 2px; margin-left: 2px; color: var(--muted); cursor: pointer; vertical-align: middle; line-height: 1; border-radius: 4px; }
.btn-link:hover { color: var(--bad); background: var(--bad-soft); }
.ledger li > .grow { flex: 1; min-width: 0; }
.tool-select input[type=date] { border: 0; background: transparent; height: 34px; width: 130px; padding: 0 4px; box-shadow: none; }
.tool-select:has(input[type=date]) { padding-right: 6px; font-size: 13px; }
@media (max-width: 600px) { .tool-select input[type=date] { flex: 1; min-width: 0; width: auto; } }
@media (max-width: 600px) {
  .tool-group.show > * { min-width: 0; }
  .tool-select:has(input[type=date]) { white-space: nowrap; overflow: hidden; }
}

/* Trang Quy tắc tính công: tham số chung chia nhóm, mỗi nhóm 1 thẻ; cột cố định để các nhóm thẳng hàng */
.setting-groups.active { display: flex; flex-direction: column; gap: 16px; }
.setting-group { scroll-margin-top: 16px; }
.setting-group .card-head h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.setting-group .card-head .section-note { flex-basis: 100%; }
.setting-group-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.setting-group-nav .chip { cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600; }
.setting-group-nav .chip:hover { border-color: var(--brand); color: var(--brand); }
.setting-table { table-layout: fixed; }
.setting-table .c-name { width: 32%; }
.setting-table .c-current { width: 20%; }
.setting-table .c-upcoming { width: 14%; }
.setting-table .c-form { width: 34%; }
@media (max-width: 1280px) { .setting-table { table-layout: auto; } }
@media (max-width: 600px) {
  .setting-table.cards-sm td.card-main { grid-column: 1 / -1; }
  .setting-form { flex-wrap: wrap !important; }
  .setting-form input { flex: 1 1 0; min-width: 0; width: auto; }
  .setting-form select { flex: 1 1 100%; width: 100% !important; }
}

/* Cài app lên điện thoại (PWA): thẻ "Cài app", trang hướng dẫn, trang Không có mạng */
.install-app { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; }
.install-app-inline { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); margin: 0 0 16px; }
.install-app-icon { width: 44px; height: 44px; border-radius: 11px; border: 1px solid var(--line); flex: none; }
.install-app-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.install-app-text span { color: var(--muted); font-size: 13px; }
.install-app .btn { flex: none; }
.install-app-close { color: var(--muted); margin-left: -4px; }
@media (max-width: 420px) { .install-app { flex-wrap: wrap; } .install-app-text { flex-basis: calc(100% - 92px); } .install-app .btn { flex: 1; } }
.install-done { display: none; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 16px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
html[data-install-platform="installed"] .install-done { display: flex; }
.guide { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); }
.guide summary { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 700; cursor: pointer; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "›"; margin-left: auto; font-size: 20px; line-height: 1; color: var(--muted); transition: transform .15s; }
.guide[open] summary::after { transform: rotate(90deg); }
.guide > p { margin: 0 14px 10px; }
.guide-steps { list-style: none; counter-reset: step; margin: 0; padding: 0 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.guide-steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; }
.guide-steps li > div::before { content: "Bước " counter(step) ". "; font-weight: 700; color: var(--brand); }
.guide-key { flex: none; width: 52px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; background: var(--info-soft); color: var(--info); font-weight: 700; font-size: 14px; }
.ios-sheet { margin-top: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; font-size: 13px; }
.ios-sheet span { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--muted); }
.ios-sheet span:first-child { border-top: 0; }
.ios-sheet span.on { color: var(--ink); font-weight: 700; background: var(--brand-soft); }
.guide-notes { margin-top: 14px; font-size: 13.5px; }
.guide-notes ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.offline-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }

/* Thẻ Bật thông báo (trang Chấm công, Hồ sơ của tôi) */
.push-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.push-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand); }
.push-text { flex: 1; min-width: 180px; display: flex; flex-direction: column; line-height: 1.35; }
.push-text span { color: var(--muted); font-size: 13px; }
.push-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 420px) { .push-actions { width: 100%; } .push-actions .btn { flex: 1; } }
@media (max-width: 900px) and (max-height: 700px) {
  .clock-card { padding: 12px 14px; }
  .clock { font-size: 32px; }
  .today-info { margin-top: 8px; gap: 2px; }
  .next-punch { margin-top: 8px; padding: 6px 12px; }
  .punch-area { gap: 10px; padding: 12px; }
  .punch-btn { height: 54px; }
  .cam { max-height: max(100px, calc(100svh - 440px)); }
  .cam-hint { display: none; }
}

/* Hồ sơ của tôi: ảnh đại diện + nút sửa */
.profile-head { display: flex; gap: 18px; align-items: flex-start; }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
.profile-photo form { margin: 0; }
.profile-photo.uploading { opacity: .6; pointer-events: none; }
.side-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.side-title-row .side-title { margin-bottom: 0; }
@media (max-width: 420px) { .profile-head { flex-direction: column; align-items: center; text-align: center; } .profile-head .side-title { justify-content: center; } }
.change-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.change-row:last-child { border-bottom: 0; }

/* Ảnh đại diện ở đầu hồ sơ NV phía HR: nút máy ảnh góc dưới để HR tải/đổi ảnh hộ */
.avatar-edit { position: relative; flex: none; display: inline-flex; }
.avatar-edit form { margin: 0; }
.avatar-edit-btn { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); cursor: pointer; }
.avatar-edit-btn:hover { color: var(--brand); border-color: currentColor; }
.avatar-edit.uploading { opacity: .6; pointer-events: none; }
.avatar-remove { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
