:root {
  /* iOS palette — Long Phase M */
  --primary: #007aff;
  --primary-dark: #0066d6;
  --primary-light: #e6f0ff;
  --success: #34c759;
  --success-light: #e8f7ee;
  --danger: #ff3b30;
  --danger-light: #ffe5e3;
  --warning: #ff9500;
  --warning-light: #fff4e0;
  --info: #5ac8fa;
  --gray-50: #f9f9fb;
  --gray-100: #f2f2f7;
  --gray-200: #e5e5ea;
  --gray-300: #d1d1d6;
  --gray-400: #aeaeb2;
  --gray-500: #8e8e93;
  --gray-600: #6e6e73;
  --gray-700: #48484a;
  --gray-800: #1c1c1e;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Phase AS bis-73: Bỏ overscroll-behavior-y: none — cho phép native iOS pull-to-refresh.
   Bottom-tab-bar dùng position:fixed nên không bounce theo body. */
html, body { overscroll-behavior-y: auto; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", "Segoe UI", "Roboto", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  background: var(--gray-100); color: var(--gray-800); font-size: 15px;
}
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.022em; }
h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.018em; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.014em; }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #0891b2 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px;
  width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
  width: 72px; height: 72px; background: linear-gradient(135deg, #2563eb, #0891b2);
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px; box-shadow: 0 4px 16px rgba(37,99,235,.4);
}
.logo-icon i { color: #fff; font-size: 30px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.login-logo p { color: var(--gray-500); font-size: 13px; }
.login-hint { text-align: center; margin-top: 16px; color: var(--gray-400); }
/* Phase AS bis-76: .login-forgot CSS removed — link đã xoá khỏi login. */
.password-wrap { position: relative; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--gray-400); padding: 4px;
}
.eye-btn:hover { color: var(--primary); }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.form-group label i { margin-right: 6px; color: var(--primary); }
/*bis-293: input:not([type]) — input trần (thiếu type) cũng phải ăn chuẩn form HRM,
  fix modal Sửa bài học + Wiki/CTKM/Nội quy có input không khai type*/
input:not([type]), input[type=text], input[type=password], input[type=date], input[type=tel],
input[type=number], input[type=email], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--gray-300);
  border-radius: 8px; font-size: 14px; transition: border .2s, box-shadow .2s;
  background: #fff; outline: none;
  font-family: inherit; /*bis-293: form control kế thừa font app, không rơi về font mặc định browser (textarea Chrome = monospace)*/
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.btn-success {
  background: linear-gradient(135deg, var(--success), #15803d);
  color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,.4); }
.btn-danger {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-warning {
  background: linear-gradient(135deg, var(--warning), #b45309);
  color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-ghost {
  background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-600);
  padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; gap: 7px; transition: all .2s;
}
.btn-ghost:hover { background: var(--gray-100); }
.btn-full { width: 100%; justify-content: center; }
.error-msg { background: var(--danger-light); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: #1e293b; color: #e2e8f0; z-index: 100;
  display: flex; flex-direction: column; transition: transform .3s;
  box-shadow: 2px 0 10px rgba(0,0,0,.15);
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-header {
  padding: 0 16px; height: var(--topbar-h); display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid #334155;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand i { color: #60a5fa; font-size: 20px; }
.sidebar-toggle { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 18px; padding: 4px; }
.sidebar-toggle:hover { color: #fff; }
.user-info-sidebar {
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #334155; background: #0f172a;
}
.user-avatar-sm i { font-size: 36px; color: #60a5fa; }
.sidebar-user-name { font-weight: 600; font-size: 13px; color: #f1f5f9; }
.sidebar-user-role { font-size: 11px; color: #94a3b8; text-transform: uppercase; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { padding: 14px 16px 4px; font-size: 10px; text-transform: uppercase; color: #64748b; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  cursor: pointer; border-radius: 0; color: #94a3b8; transition: all .15s;
  font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-item:hover { background: #0f172a; color: #e2e8f0; border-left-color: #475569; }
.nav-item.active { background: #0f172a; color: #60a5fa; border-left-color: #2563eb; font-weight: 600; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

/* ===== TOPBAR ===== */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin .3s;
  width: calc(100% - var(--sidebar-w));
}
.main-content.expanded { margin-left: 0; width: 100%; }
.topbar {
  position: sticky; top: 0; height: var(--topbar-h); background: #fff;
  display: flex; align-items: center; padding: 0 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1); z-index: 50; gap: 12px;
}
.topbar-menu-btn { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-600); padding: 4px 8px; }
.topbar-title { flex: 1; font-weight: 700; font-size: 16px; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.notif-btn { position: relative; background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-500); padding: 6px; border-radius: 8px; transition: all .2s; }
.notif-btn:hover { background: var(--gray-100); color: var(--primary); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; background: var(--danger);
  color: #fff; border-radius: 50%; width: 16px; height: 16px;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.btn-logout { background: none; border: 1.5px solid var(--gray-300); cursor: pointer; font-size: 16px; color: var(--gray-500); padding: 6px 12px; border-radius: 8px; transition: all .2s; }
.btn-logout:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 20px; min-height: calc(100vh - var(--topbar-h)); }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
  border-left: 4px solid transparent; transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.stat-blue { border-color: var(--primary); }
.stat-blue .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-blue .stat-value { color: var(--primary); }
.stat-green { border-color: var(--success); }
.stat-green .stat-icon { background: var(--success-light); color: var(--success); }
.stat-green .stat-value { color: var(--success); }
.stat-yellow { border-color: var(--warning); }
.stat-yellow .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-yellow .stat-value { color: var(--warning); }
.stat-red { border-color: var(--danger); }
.stat-red .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-red .stat-value { color: var(--danger); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
/* Phase AS bis-62: Shift close mobile cards — chỉ hiện trên mobile (media query). */
.sc-mobile-cards { display: none; }
/* Phase AS bis-73: Custom pull-refresh indicator removed — dùng native iOS pull-to-refresh. */

/* Phase AS bis-65: Month lock badge — hiện cạnh month picker khi tháng locked. */
.lock-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 12px;
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.lock-badge i { font-size: 12px; }

/* Phase AS bis-66: Payroll detail expand/collapse sections. */
.pd-sections { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.pd-section {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 12px;
  overflow: hidden; transition: box-shadow .15s;
}
.pd-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; cursor: pointer; user-select: none;
}
.pd-section:not(.pd-total-section) .pd-head:hover { background: #f9fafb; }
.pd-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pd-total { font-size: 15px; }
.pd-chev { font-size: 11px; color: var(--gray-400); transition: transform .25s ease; margin-left: 4px; }
.pd-section[data-open="1"] .pd-chev { transform: rotate(180deg); color: #4338ca; }
.pd-body {
  max-height: 0; overflow: hidden; transition: max-height .25s ease, padding .25s ease;
  padding: 0 14px; font-size: 13px; line-height: 1.85;
}
.pd-section[data-open="1"] .pd-body { max-height: 500px; padding: 4px 14px 12px; border-top: 1px dashed var(--gray-200); }
.pd-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pd-row span { color: var(--gray-500); }
.pd-row strong { color: var(--gray-800); }
.pd-total-section {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}
.pd-total-section .pd-head { cursor: default; }
.pd-total-section .pd-title { color: #065f46; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead th {
  background: var(--gray-50); padding: 10px 14px; text-align: left;
  font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200); white-space: nowrap;
}
/* bis-274: sticky thead bảng Chốt ca — thead được JS translateY theo scroll, nổi trên tbody */
.sc-sticky-head thead { position: relative; z-index: 5; will-change: transform; }
.sc-sticky-head thead.sc-floating th { box-shadow: 0 2px 6px rgba(0,0,0,.08); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); font-size: 13.5px; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar input, .filter-bar select { max-width: 200px; flex: 1; }
.filter-bar input { max-width: 280px; }
/* bis-376: trang NV — search + 2 filter + nút Thêm NV chung 1 hàng ngang desktop */
.emp-toolbar { flex-wrap: nowrap; }
.emp-toolbar input#empSearch { flex: 1 1 auto; max-width: none; min-width: 0; }
.emp-toolbar .ios-picker { flex: 0 0 200px; min-width: 0; }
.emp-toolbar .btn-primary { flex: 0 0 auto; white-space: nowrap; height: 48px; }
@media (max-width: 768px) {
  .emp-toolbar { flex-wrap: wrap; }
  .emp-toolbar input#empSearch,
  .emp-toolbar .ios-picker,
  .emp-toolbar .btn-primary { flex: 1 1 100%; width: 100%; }
}

/* ===== MODAL ===== */
/* ============================================================
   iOS-STYLE MODAL (Phase L)
   Áp dụng cho modal có class .ios-modal trong .modal-box
   ============================================================ */
.ios-modal {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", "Segoe UI", "Roboto", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  color: #1c1c1e;
}
.ios-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid #e5e5ea;
  position: sticky; top: 0; background: #fff; z-index: 2;
}
.ios-modal-title {
  font-size: 17px; font-weight: 600; color: #1c1c1e; letter-spacing: -0.022em;
}
.ios-modal-title small { color: #8e8e93; font-weight: 500; font-size: 13px; margin-left: 6px; }
.ios-modal-close {
  width: 30px; height: 30px; border-radius: 50%; background: #f2f2f7;
  border: none; cursor: pointer; color: #8e8e93; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ios-modal-close:hover { background: #e5e5ea; color: #1c1c1e; }

.ios-body { padding: 22px 24px 16px; display: flex; flex-direction: column; gap: 20px; }

.ios-section { display: flex; flex-direction: column; gap: 12px; }
.ios-section-label {
  font-size: 12px; font-weight: 600; color: #8e8e93; text-transform: uppercase;
  letter-spacing: 0.04em; padding-left: 4px;
}

.ios-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.ios-row.single { grid-template-columns: 1fr; }

.ios-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ios-field label {
  font-size: 13px; font-weight: 600; color: #6e6e73;
  padding-left: 4px; letter-spacing: -0.01em;
}
.ios-field label small { color: #8e8e93; font-weight: 500; font-size: 11px; margin-left: 4px; }

.ios-input, .ios-select {
  width: 100%; padding: 12px 14px;
  border: 1px solid #d1d1d6; border-radius: 12px;
  background: #fff; font-size: 16px; font-weight: 500; color: #1c1c1e;
  font-family: inherit; transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.ios-input:hover, .ios-select:hover { border-color: #c7c7cc; }
.ios-input:focus, .ios-select:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 4px rgba(0,122,255,0.12);
  background: #fff;
}
.ios-input::placeholder { color: #c7c7cc; font-weight: 400; }
.ios-input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0; }
.ios-input.readonly, .ios-input:disabled {
  background: #f2f2f7; color: #6e6e73; cursor: default; border-color: transparent;
}

.ios-select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 10px;
}

.ios-help {
  font-size: 12px; color: #8e8e93; line-height: 1.45; padding: 0 4px;
  margin-top: 2px;
}

/* Lịch sử ca làm — iOS card */
.ios-card {
  background: #f2f2f7; border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.ios-card-head {
  display: flex; align-items: center; justify-content: space-between;
}
.ios-card-title {
  font-size: 13px; font-weight: 600; color: #1c1c1e; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 6px;
}
.ios-card-title i { color: #007aff; font-size: 14px; }

.ios-shift-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: #fff; border-radius: 10px;
  transition: background .15s;
  position: relative;
}
.ios-shift-row:hover { background: #f9f9fb; }
.ios-shift-row .delete-btn {
  opacity: 0; transition: opacity .15s;
  background: none; border: none; cursor: pointer;
  color: #ff3b30; font-size: 13px; padding: 4px 8px;
}
.ios-shift-row:hover .delete-btn { opacity: 1; }

.ios-shift-pill {
  background: #e5e5ea; color: #1c1c1e;
  padding: 4px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0;
  white-space: nowrap;
}
.ios-shift-dates {
  flex: 1; font-size: 12.5px; color: #6e6e73;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ios-shift-dates strong { color: #1c1c1e; font-weight: 600; }
.ios-shift-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.ios-shift-badge.active  { background: #e8f7ee; color: #1f9d4f; }
.ios-shift-badge.future  { background: #fff4e0; color: #d97706; }
.ios-shift-badge.expired { background: #f2f2f7; color: #8e8e93; }
.ios-shift-badge.pending { background: #fff4e0; color: #d97706; border: 1px dashed #d97706; }
.ios-shift-row.pending   { background: #fffaf0; border-left: 3px solid #d97706; padding-left: 8px; }

/* Footer buttons iOS */
.ios-footer {
  padding: 14px 24px 22px; border-top: 1px solid #e5e5ea;
  display: flex; gap: 10px; background: #fff;
  position: sticky; bottom: 0;
}
.ios-btn {
  flex: 1; padding: 13px 16px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em; font-family: inherit;
  transition: background .15s, transform .05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.ios-btn:active { transform: scale(0.985); }
.ios-btn-primary { background: #007aff; color: #fff; }
.ios-btn-primary:hover { background: #0066d6; }
.ios-btn-secondary { background: #f2f2f7; color: #007aff; }
.ios-btn-secondary:hover { background: #e5e5ea; }

/* Khi modal-box.ios-mode → ẩn header mặc định, dùng custom iOS header trong body */
/* Phase AS bis-17: Long chốt lại — DESKTOP centered min(94vw, 500px), MOBILE full-screen 100vw×100vh */
.modal-box.ios-mode {
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  width: min(94vw, 500px);
  max-width: min(94vw, 500px);
  margin: 3vh auto;
  max-height: 94vh;
  overflow-x: hidden;
  overflow-y: auto;
}
.modal-box.ios-mode > .modal-header { display: none; }
.modal-box.ios-mode > .modal-body { padding: 0; overflow-x: hidden; }
/* Không cho phép bất cứ child nào bên trong ios-mode overflow ngang */
.modal-box.ios-mode * { max-width: 100%; box-sizing: border-box; }
/* Phase AS bis-18: ios-body dùng overflow visible — modal-box lo scroll.
   Nếu set overflow-x:hidden trên ios-body → browser tự chuyển overflow-y:auto → CLIP dropdown. */
.modal-box.ios-mode .ios-body { overflow: visible; }

@media (max-width: 480px) {
  .ios-row { grid-template-columns: 1fr; }
  /* Phase AS bis-39: RADICAL fix — flex layout thuần, KHÔNG position:absolute.
     Header + Body + Footer là 3 flex siblings. Body flex-1 auto scroll. Footer static, KHÔNG đè content. */
  .modal-box.ios-mode {
    border-radius: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    height: var(--app-vh, 100vh) !important;
    max-height: var(--app-vh, 100vh) !important;
    margin: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    position: static !important;
    animation: fadeScaleInIos .18s ease;
  }
  .modal-box.ios-mode > .modal-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: static !important;
  }
  .modal-box.ios-mode .ios-modal {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: static !important;
  }
  .modal-box.ios-mode .ios-modal-header {
    flex-shrink: 0 !important;
    padding: 16px 18px 12px !important;
    background: #fff !important;
    position: static !important;
  }
  .modal-box.ios-mode .ios-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px 18px 20px !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    gap: 18px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .modal-box.ios-mode .ios-footer {
    position: static !important;
    flex-shrink: 0 !important;
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom, 20px)) !important;
    background: #fff !important;
    border-top: 1px solid #e5e5ea !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04) !important;
    display: flex !important;
    gap: 10px !important;
    z-index: 1 !important;
  }
  .modal-overlay:has(.modal-box.ios-mode) {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    height: var(--app-vh, 100vh) !important;
  }
}
@keyframes fadeScaleInIos { from { opacity: 0; } to { opacity: 1; } }

/* Phase AS bis-16/17: Force overlay center-align cho ios-mode DESKTOP */
@media (min-width: 481px) {
  .modal-overlay:has(.modal-box.ios-mode) { align-items: center !important; padding: 0 !important; }
}

/* ========================================================================
   INLINE DROPDOWN PICKER (Phase AS bis-18)
   Xổ xuống ngay dưới trigger — thay bottom sheet cũ.
   ======================================================================== */
.picker-open-wrap { position: relative; }
.dropdown-options {
  /* Phase AS bis-44: position:fixed set qua JS + toạ độ tính từ trigger rect.
     KHÔNG dùng top/left/right cứng — JS override runtime. */
  position: fixed;
  background: #fff;
  border: 1px solid #d1d1d6; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 10000;                 /* trên bottom tab bar (z-index 100) + modal (1000) */
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .22s ease, opacity .18s ease;
}
.dropdown-options.open {
  max-height: var(--dd-max-h, 320px);
  opacity: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Phase AS bis-46: Force visible scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(107,114,128,0.55) transparent;
}
.dropdown-options.open::-webkit-scrollbar {
  width: 8px;
  -webkit-appearance: none;
  display: block;
}
.dropdown-options.open::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
  border-radius: 4px;
}
.dropdown-options.open::-webkit-scrollbar-thumb {
  background: rgba(107,114,128,0.55);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.dropdown-options.open::-webkit-scrollbar-thumb:hover {
  background: rgba(107,114,128,0.75);
  background-clip: content-box;
}

/* Phase AS bis-48: Long chốt bỏ text "Cuộn xem thêm" / "Cuộn lên".
   Giữ SUBTLE gradient fade ở edge để hint scrollable — không có text. */
.dropdown-options.has-scroll:not(.at-bottom)::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  display: block;
  height: 20px;
  margin-top: -20px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.88));
  pointer-events: none;
  z-index: 2;
}
.dropdown-options.has-scroll:not(.at-top)::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0; right: 0;
  display: block;
  height: 20px;
  margin-bottom: -20px;
  background: linear-gradient(to top, transparent, rgba(255,255,255,0.88));
  pointer-events: none;
  z-index: 2;
}
/* Phase AS bis-35: Drop-up variant khi trigger gần đáy viewport */
.dropdown-options.drop-up {
  top: auto; bottom: calc(100% + 4px);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
}
.dropdown-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer; min-height: 48px;
  border-bottom: 1px solid #f2f2f7;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.dropdown-option:last-child { border-bottom: none; }
.dropdown-option:hover { background: #f9f9fb; }
.dropdown-option:active { background: #f2f2f7; }
.dropdown-option.selected { background: #eff6ff; }
.dropdown-option-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dropdown-option-label { font-size: 15px; font-weight: 500; color: #1c1c1e; }
.dropdown-option-sub { font-size: 12px; color: #8e8e93; }
.dropdown-check { color: #007aff; font-size: 14px; margin-left: 12px; flex-shrink: 0; }

/* Payroll Detail stats grid (Phase AS bis-21) */
.pd-stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.pd-stat {
  background: #f2f2f7; border-radius: 12px; padding: 12px 8px; text-align: center;
  min-width: 0;
}
.pd-stat-value {
  font-size: 22px; font-weight: 800; line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pd-stat-label {
  font-size: 10px; color: #8e8e93; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 480px) {
  .pd-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Trigger state khi picker đang mở */
.ios-picker.open {
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0,122,255,0.10);
}
.ios-picker.open .ios-picker-chevron { transform: rotate(180deg); }
.ios-picker-chevron { transition: transform .22s ease; }

/* Custom picker trigger — looks like ios-select but tap opens bottom sheet */
.ios-picker {
  width: 100%; padding: 12px 14px;
  border: 1px solid #d1d1d6; border-radius: 12px;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; min-height: 46px;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.ios-picker:hover { border-color: #c7c7cc; }
.ios-picker:active { border-color: #007aff; background: #f9fafb; }
.ios-picker-value {
  color: #1c1c1e; font-size: 16px; font-weight: 500;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* Phase AS bis-49: center align text (đồng bộ với date input center) */
  text-align: center;
}
.ios-picker-value.placeholder { color: #c7c7cc; font-weight: 400; }
.ios-picker-chevron { color: #8e8e93; font-size: 12px; flex-shrink: 0; }

/* Date input tighten — tránh cắt placeholder trên mobile */
.ios-input[type="date"] {
  font-variant-numeric: tabular-nums;
  width: 100%;
  min-width: 0;                 /* WebKit adds min-width — force 0 để không tràn */
  -webkit-appearance: none;
  appearance: none;
}
/* WebKit datetime-edit padding fix — hiển thị đủ dd/mm/yyyy */
.ios-input[type="date"]::-webkit-datetime-edit { padding: 0; }
.ios-input[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; opacity: 0.6; }

/* Phase AS bis-33: Long chốt CENTER align cho tất cả date input trong app (placeholder + value).
   Áp dụng cả type=date và type=text đóng vai type-swap picker. */
.ios-input[type="date"],
.ios-input[type="text"][placeholder="Chọn ngày"],
input[type="date"],
#s_date, #e_start, #ee_start, #ar_date, #as_date, #al_from, #al_to,
#l_from, #l_to, #res_date, #ns_eff, #ot_date, #ot_date_to {
  text-align: center;
}
/* Center placeholder text (native styling) */
.ios-input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit { text-align: center; width: 100%; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overscroll-behavior: contain; /* bis-281: cuộn hết modal không lan ra trang phía sau */
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; background: #fff;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.modal-header button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--gray-400); padding: 4px; border-radius: 6px; }
.modal-header button:hover { background: var(--gray-100); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== NOTIFICATIONS ===== */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-item {
  padding: 14px 16px; border-radius: var(--radius); border-left: 4px solid;
  background: #fff; box-shadow: var(--shadow); cursor: pointer; transition: all .2s;
  display: flex; align-items: flex-start; gap: 12px;
}
.notif-item:hover { transform: translateX(3px); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.type-success { border-color: var(--success); }
.notif-item.type-info { border-color: var(--primary); }
.notif-item.type-warning { border-color: var(--warning); }
.notif-item.type-error, .notif-item.type-danger { border-color: var(--danger); }
.notif-item.type-welcome { border-color: #8b5cf6; }
.notif-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.notif-content { flex: 1; }
.notif-title { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.notif-msg { font-size: 13px; color: var(--gray-600); line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--gray-400); margin-top: 5px; }

/* ===== RULES ===== */
.rule-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.rule-header {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; border-bottom: 1px solid transparent; transition: background .2s;
}
.rule-header:hover { background: var(--gray-50); }
.rule-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.rule-body { padding: 16px 18px; border-top: 1px solid var(--gray-200); font-size: 13.5px; line-height: 1.8; color: var(--gray-700); white-space: pre-line; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 12px 20px; border-radius: 10px; color: #fff; font-weight: 600;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); min-width: 250px;
  display: flex; align-items: center; gap: 8px; animation: slideUp .3s ease;
}
.toast.success { background: linear-gradient(135deg, var(--success), #15803d); }
.toast.error { background: linear-gradient(135deg, var(--danger), #b91c1c); }
.toast.info { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.toast.warning { background: linear-gradient(135deg, var(--warning), #b45309); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; }

/* ===== SECTION TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--gray-500);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== PROFILE ===== */
.profile-card {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff; border-radius: 14px; padding: 28px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 20px;
}
.profile-avatar { width: 80px; height: 80px; background: rgba(255,255,255,.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 40px; flex-shrink: 0; }
.profile-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.profile-sub { opacity: .85; font-size: 13px; }
.profile-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.profile-badge { background: rgba(255,255,255,.25); padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ===== RESPONSIVE / MOBILE FIRST OVERRIDES =====
   Mọi rule mobile gom ở cuối file để override.
*/
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
}

/* STATUS LINE */
.status-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--success-light); border-radius: 8px; margin-bottom: 16px; font-size: 13px; color: var(--success); font-weight: 600; }
.status-bar i { font-size: 16px; }
.status-bar.warn { background: var(--warning-light); color: var(--warning); }

/* ===== PERMISSIONS PAGE ===== */
.perm-matrix {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.perm-matrix-header {
  display: grid; grid-template-columns: 1fr repeat(3, 140px);
  background: #1e293b; color: #fff;
}
.perm-col-head {
  padding: 14px 12px; text-align: center; font-size: 13px; font-weight: 700;
  border-left: 1px solid rgba(255,255,255,.1);
}
.perm-col-head:first-child { text-align: left; border-left: none; padding-left: 20px; }
.perm-col-head .role-icon { font-size: 22px; display: block; margin-bottom: 4px; }
.perm-col-head .role-lbl { font-size: 12px; opacity: .9; }
.perm-module-head {
  grid-column: 1 / -1; background: var(--gray-100); padding: 8px 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--gray-500); border-top: 1px solid var(--gray-200);
}
.perm-row {
  display: grid; grid-template-columns: 1fr repeat(3, 140px);
  border-top: 1px solid var(--gray-100); transition: background .15s;
}
.perm-row:hover { background: var(--gray-50); }
.perm-row-label { padding: 12px 20px; font-size: 13px; color: var(--gray-700); display: flex; align-items: center; gap: 8px; }
.perm-row-label i { color: var(--primary); width: 16px; text-align: center; }
.perm-cell { display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--gray-100); }

/* Toggle switch */
.toggle-wrap { position: relative; width: 42px; height: 24px; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--gray-300); border-radius: 24px;
  cursor: pointer; transition: .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-wrap input:checked + .toggle-slider { background: var(--primary); }
.toggle-wrap input:checked + .toggle-slider::before { transform: translateX(18px); }

.perm-save-bar {
  padding: 16px 20px; background: var(--gray-50); border-top: 2px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.perm-col-save {
  display: grid; grid-template-columns: 1fr repeat(3, 140px);
  background: var(--gray-50); border-top: 2px solid var(--gray-200);
  padding: 12px 0;
}
.perm-save-cell { display: flex; justify-content: center; }

/* Role badges */
.badge-purple { background: #f3e8ff; color: #7c3aed; }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* ===== TIMESHEET ===== */

/* Toolbar */
.ts-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 8px;
}
.ts-toolbar-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ts-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ts-view-btns { display: flex; border: 1px solid var(--gray-200); border-radius: 7px; overflow: hidden; }
.ts-view-btn {
  padding: 6px 14px; font-size: 12px; font-weight: 500; border: none; background: #fff;
  cursor: pointer; color: var(--gray-600); transition: background .15s;
}
.ts-view-btn:hover   { background: var(--gray-100); }
.ts-view-btn.active  { background: var(--primary); color: #fff; }

.ts-nav { display: flex; align-items: center; gap: 4px; }
.ts-nav-btn {
  width: 30px; height: 30px; border: 1px solid var(--gray-200); border-radius: 6px;
  background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--gray-600); transition: background .15s;
}
.ts-nav-btn:hover { background: var(--gray-100); }
.ts-nav-label { font-size: 13px; font-weight: 600; color: var(--gray-700); padding: 0 8px; white-space: nowrap; }

/* Legend */
.ts-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 4px; }
.ts-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gray-600); cursor: default; }
.ts-dot-lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Table */
.ts-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
.ts-table { border-collapse: collapse; min-width: 100%; font-size: 12px; }
.ts-table thead th { background: #1e293b; color: #fff; padding: 6px 3px; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.08); }

.ts-num-head  { width: 32px; text-align: center; }
.ts-emp-head  { min-width: 180px; text-align: left; padding: 8px 12px; position: sticky; left: 0; z-index: 3; background: #1e293b; }
.ts-day-head  { min-width: 60px; text-align: center; }
.ts-day-head.ts-weekend { background: #334155 !important; }
.ts-day-head.ts-today   { background: var(--primary) !important; }
.ts-dow    { font-size: 10px; color: #94a3b8; margin-bottom: 1px; }
.ts-daynum { font-weight: 700; font-size: 13px; }
.ts-summary-head { min-width: 48px; text-align: center; }

.ts-table tbody tr:hover .ts-emp-cell { background: #f8fafc; }
.ts-table tbody tr:hover .ts-num { background: #f8fafc; }

.ts-num { width: 32px; text-align: center; font-size: 11px; color: var(--gray-400);
  border-right: 1px solid var(--gray-100); padding: 0 4px; }

.ts-emp-cell {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-right: 2px solid var(--gray-100);
  position: sticky; left: 0; background: #fff; z-index: 2;
  min-width: 180px; transition: background .1s;
}
.ts-emp-name { font-size: 12px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.ts-emp-sub  { font-size: 10px; color: var(--gray-400); white-space: nowrap; }

.ts-cell {
  text-align: center; padding: 3px 2px; border: 1px solid rgba(0,0,0,.04);
  min-width: 60px; cursor: default; vertical-align: middle;
  transition: filter .1s; position: relative;
}
.ts-cell:hover  { filter: brightness(.93); z-index: 2; }
.ts-cell.ts-weekend { opacity: .65; }
.ts-cell.ts-today { outline: 2px solid var(--primary); outline-offset: -2px; }

.ts-cell-badge {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; flex-shrink: 0;
}
.ts-cell-icon { font-size: 14px; display: block; }
.ts-absent-mark { font-size: 13px; color: #d1d5db; }
.ts-time2 { display: block; font-size: 9px; color: #374151; line-height: 1.2; }
.ts-time-out { color: #64748b; }
.ts-pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.ts-summary-cell { text-align: center; padding: 4px 6px; border-left: 1px solid var(--gray-100); white-space: nowrap; }
.ts-sum-days  { font-weight: 700; font-size: 13px; color: var(--gray-700); }
.ts-sum-label { font-size: 10px; color: var(--gray-400); }

/* ===== CUSTOM TOOLTIP (hiện ngay, không delay) ===== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 9999;
}
[data-tip]:hover::after { opacity: 1; }

/* ===== SHIFT PAGE ===== */
.shift-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 4px;
}
/* Phase AS bis-34: Bảng lương giờ 3 card. */
.shift-stats.payroll-3stats { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) {
  .shift-stats.payroll-3stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .shift-stats.payroll-3stats .shift-stat-num { font-size: 15px; }
  .shift-stats.payroll-3stats .shift-stat-lbl { font-size: 11px; }
}
.shift-stat-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; cursor: pointer; border-left: 4px solid var(--gray-300);
  transition: transform .15s, box-shadow .15s;
}
.shift-stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.shift-stat-card.pending  { border-color: #f59e0b; }
.shift-stat-card.approved { border-color: #10b981; }
.shift-stat-card.rejected { border-color: #ef4444; }
.shift-stat-num { font-size: 28px; font-weight: 800; color: var(--gray-800); line-height: 1; }
.shift-stat-lbl { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.shift-stat-card.pending  .shift-stat-num { color: #d97706; }
.shift-stat-card.approved .shift-stat-num { color: #059669; }
.shift-stat-card.rejected .shift-stat-num { color: #dc2626; }

.shift-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--gray-100); gap: 10px;
}
.shift-tabs { display: flex; gap: 4px; }
.shift-tab {
  padding: 6px 14px; border: none; background: transparent; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--gray-600); font-weight: 500;
  display: flex; align-items: center; gap: 6px; transition: background .15s;
}
.shift-tab:hover { background: var(--gray-100); }
.shift-tab.active { background: var(--primary); color: #fff; }
.shift-tab-badge {
  background: var(--gray-300); color: #fff; border-radius: 20px;
  padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.shift-tab.active .shift-tab-badge { background: rgba(255,255,255,.35); }
.shift-filters { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.shift-filters button { white-space: nowrap; }

.shift-type-badge {
  background: #eff6ff; color: #1d4ed8; border-radius: 6px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.emp-name-cell { display: flex; align-items: center; gap: 10px; }
.emp-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.text-muted { color: var(--gray-500); font-size: 12px; }
.btn-outline {
  padding: 5px 10px; border: 1px solid var(--gray-300); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--gray-600);
  transition: background .15s;
}
.btn-outline:hover { background: var(--gray-100); }

/* ===== TIMESHEET MOBILE CARDS ===== */
.ts-mobile-cards-wrap { display: none; }
.ts-mobile-card {
  background: #fff; border-radius: 14px; padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  border: 1px solid var(--gray-100);
}
.ts-mobile-card:active { transform: scale(.985); box-shadow: var(--shadow-md); }
.ts-mobile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ts-mobile-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.ts-mobile-stat {
  background: var(--gray-50); border-radius: 10px;
  padding: 10px 8px; text-align: center;
}
.ts-mobile-stat-val { font-size: 17px; font-weight: 800; color: var(--gray-800); line-height: 1.1; }
.ts-mobile-stat-lbl { font-size: 11px; color: var(--gray-500); margin-top: 4px; font-weight: 600; }
.ts-mobile-stat-lbl i { margin-right: 3px; color: var(--primary); }

/* ===== ACCORDION CARD EXPAND ===== */
.card-detail-expand {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .25s ease, margin .25s ease;
  border-top: 1px dashed transparent;
  padding: 0;
  margin-top: 0;
}
.card-detail-expand.open {
  max-height: 3000px;
  border-top-color: var(--gray-200);
  padding: 14px 4px 4px;
  margin-top: 12px;
}
/* bis-369: icon flex-center (hết lệch), expanded GIỮ màu xanh dương — bỏ đổi xanh lá */
.expand-toggle { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.expand-toggle i { transition: transform .25s ease; }
.expand-toggle.expanded i { transform: rotate(90deg); }

.expand-summary {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-around;
  padding: 8px 10px; background: var(--gray-50); border-radius: 8px;
  font-size: 13px; color: var(--gray-700); font-weight: 600; margin-bottom: 10px;
}
.expand-summary i { color: var(--primary); margin-right: 4px; }

/* ── CKDT (chiết khấu doanh thu Sapo) ── */
.payroll-ckdt-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 9px 12px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe; border-radius: 10px;
  font-size: 13px;
}
.payroll-ckdt-row .ckdt-lbl { color: #5b21b6; font-weight: 600; }
.payroll-ckdt-row .ckdt-lbl small { color: #7c3aed; font-weight: 500; opacity: .85; margin-left: 4px; font-size: 11px; }
.payroll-ckdt-row .ckdt-val { color: #6d28d9; font-size: 14px; font-weight: 700; }
.payroll-ckdt-row i { color: #7c3aed; margin-right: 4px; }

.expand-ckdt {
  margin: 8px 0 10px; padding: 8px 12px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe; border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.expand-ckdt-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: #5b21b6;
}
.expand-ckdt-row strong { color: #6d28d9; font-size: 13px; }
.expand-ckdt-row small { color: #7c3aed; font-weight: 500; opacity: .85; margin-left: 3px; font-size: 10.5px; }
.expand-ckdt-row i { color: #7c3aed; margin-right: 4px; }
.ckdt-breakdown {
  margin-top: 4px; padding-top: 6px;
  border-top: 1px dashed #c4b5fd;
  display: flex; flex-direction: column; gap: 3px;
}
.ckdt-bd-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: #6b21a8;
}
.ckdt-bd-row small { color: #7c3aed; opacity: .9; }
.ckdt-bd-row strong { color: #6d28d9; font-weight: 700; }

/* ── Wiki module (Phase AR) ──────────────────────────────────────────────── */
.wiki-search-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.wiki-search-bar input {
  flex: 1; min-width: 200px;
  padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 8px;
  font-size: 14px;
}
.wiki-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.wiki-cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px; border: 1.5px solid var(--gray-200); border-radius: 12px;
  background: white; cursor: pointer; transition: all .2s;
  text-align: center; position: relative;
}
.wiki-cat-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.wiki-cat-card.active { border-color: var(--primary); background: #eff6ff; }
.wiki-cat-card i { font-size: 24px; color: var(--primary); }
.wiki-cat-name { font-size: 12.5px; font-weight: 600; color: var(--gray-700); line-height: 1.3; }
.wiki-cat-count {
  position: absolute; top: 8px; right: 8px;
  background: var(--gray-100); color: var(--gray-600);
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.wiki-art-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.wiki-art-card {
  border: 1px solid var(--gray-200); border-radius: 12px;
  padding: 14px; background: white; cursor: pointer; transition: all .2s;
}
.wiki-art-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,.08); }
.wiki-art-cat { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 6px; }
.wiki-art-cat i { margin-right: 4px; }
.wiki-art-title { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 6px; }
.wiki-art-snippet { font-size: 12.5px; color: var(--gray-500); line-height: 1.4; }
.wiki-art-meta {
  display: flex; gap: 12px; margin-top: 8px;
  font-size: 11px; color: var(--gray-400);
}

.wiki-detail-cat { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.wiki-detail-title { font-size: 24px; font-weight: 800; color: var(--gray-900); margin: 0 0 8px; }
.wiki-detail-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--gray-500); margin-bottom: 12px; flex-wrap: wrap;
}
.wiki-detail-tags { margin-bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.wiki-tag { background: #f3f4f6; color: #6b7280; font-size: 11px; padding: 3px 8px; border-radius: 6px; }
.wiki-content { font-size: 14px; line-height: 1.7; color: var(--gray-800); }
.wiki-content h2 { font-size: 18px; margin: 18px 0 8px; color: var(--gray-900); }
.wiki-content h3 { font-size: 15px; margin: 14px 0 6px; color: var(--gray-800); }
.wiki-content ul, .wiki-content ol { margin: 6px 0 10px 24px; }
.wiki-content li { margin: 4px 0; }
.wiki-content strong { font-weight: 700; }
.wiki-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12.5px; }
.wiki-content blockquote { border-left: 3px solid var(--primary); padding-left: 12px; color: var(--gray-600); margin: 8px 0; }

.wiki-file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #f9fafb; border-radius: 8px;
  margin-bottom: 6px; text-decoration: none; color: var(--gray-800);
  transition: all .2s;
}
.wiki-file-row:hover { background: #eff6ff; }
.wiki-file-row i.fa-file-word { color: #2563eb; font-size: 18px; }
.wiki-file-name { flex: 1; font-weight: 600; font-size: 13px; }
.wiki-file-size { font-size: 11px; color: var(--gray-500); }

@media (max-width: 640px) {
  .wiki-cat-grid { grid-template-columns: repeat(2, 1fr); }
  .wiki-art-list { grid-template-columns: 1fr; }
  .wiki-detail-title { font-size: 20px; }
}

.card-expand-list { display: flex; flex-direction: column; gap: 4px; }
.expand-day-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px;
  padding: 9px 10px;
  background: #fff;
  border-radius: 7px;
  border-left: 3px solid var(--gray-300);
  font-size: 13px;
  align-items: center;
  min-height: 40px;
}
.expand-day-row.ok      { border-left-color: var(--success); background: #f0fdf4; }
.expand-day-row.late    { border-left-color: var(--warning); background: #fffbeb; }
.expand-day-row.absent  { border-left-color: var(--danger);  background: #fef2f2; }
.expand-day-row.missing { border-left-color: var(--info);    background: #ecfeff; }
.expand-day-row.future  { border-left-color: var(--gray-300); background: var(--gray-50); opacity: .6; }
.expand-day-row.today   { box-shadow: 0 0 0 2px rgba(37,99,235,.15) inset; }
.expand-day-row.weekend .day-date { color: var(--danger); }
/* bis-363 (Long 27/7/2026): đồng nhất font list chấm công — bỏ monospace ở giờ vào/ra,
   bỏ italic ở trạng thái. Tất cả dùng font chuẩn app, chỉ khác weight/màu. */
.day-date  { font-weight: 700; color: var(--gray-700); font-size: 12.5px; }
.day-time  { color: var(--gray-700); font-family: inherit; font-size: 12.5px; white-space: nowrap; }
.day-hours { font-weight: 700; color: var(--gray-800); font-size: 12.5px; text-align: right; }
.day-status, .day-note {
  grid-column: 2 / -1; color: var(--gray-600); font-size: 11.5px; margin-top: 2px;
}
/* bis-372: dòng OT trong list ngày chấm công — 3 ô grid thẳng cột với dòng giờ gốc */
.day-ot-lbl { color: #b45309; font-weight: 700; font-size: 11.5px; }
.day-time.day-ot { color: #b45309; font-size: 11.5px; }
.day-hours.day-ot { color: #b45309; font-size: 11.5px; }
.expand-day-row.absent .day-status { color: var(--danger); font-weight: 600; }
.expand-day-row.late   .day-note   { color: var(--warning); font-weight: 600; }
.expand-day-row.missing .day-status { color: var(--info); font-weight: 600; }

/* ============================================================
   MOBILE — toàn diện cho mọi trang HRM (≤ 768px)
   Triết lý: card pattern, touch-friendly, anti-zoom inputs.
   ============================================================ */
@media (max-width: 768px) {
  /* ── GLOBAL OVERFLOW GUARD ── */
  html, body { overflow-x: hidden !important; max-width: 100vw !important; }
  #appPage, .main-content { overflow-x: hidden !important; max-width: 100vw !important; }
  /* Chặn mọi child wider than viewport */
  .page-content > * { max-width: 100% !important; }
  .page-content { overflow-x: hidden !important; max-width: 100% !important; }
  /* Card luôn fit viewport */
  .card { overflow-x: hidden !important; max-width: 100% !important; }
  /* Mọi flex container trong card đều wrap */
  .card .shift-toolbar,
  .card .rule-header,
  .card .filter-bar,
  .card .ts-toolbar { flex-wrap: wrap !important; }
  /* Mọi DIRECT child của card có nội dung dài → flex 1 1 100% */
  .card > .shift-toolbar > *,
  .card > div > .rule-header > *,
  .card .rule-header > * { flex: 1 1 100% !important; min-width: 0 !important; max-width: 100% !important; }
  /* Sidebar không contribute scrollWidth khi collapsed */
  .sidebar { will-change: transform; }

  /* ── ROOT / TYPOGRAPHY ── */
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }

  /* ── SIDEBAR mobile drawer ── */
  .sidebar { width: min(82vw, 320px); transform: translateX(-100%); }
  .sidebar.open, .sidebar.collapsed.open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 99;
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .sidebar-backdrop.active { opacity: 1; pointer-events: auto; }
  .nav-item { padding: 14px 18px; font-size: 15px; min-height: 48px; }
  .nav-item i { font-size: 17px; }

  /* ── MAIN/TOPBAR ── */
  .main-content { margin-left: 0 !important; width: 100% !important; }
  .topbar { padding: 0 12px; gap: 8px; position: sticky; top: 0; }
  /* Phase AS bis-24: Bỏ hamburger ☰ trên mobile — bottom tab bar + "Khác" drawer đã cover. */
  .topbar-menu-btn { display: none !important; }
  .topbar-title { font-size: 15px; }
  .topbar-right { gap: 4px; }
  .btn-logout { padding: 8px 10px; font-size: 14px; min-height: 40px; }

  /* ── PAGE CONTENT ── */
  .page-content { padding: 12px 10px; }

  /* ── CARDS ── */
  .card { padding: 14px 12px; border-radius: 12px; margin-bottom: 12px; }
  .card-header { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .card-title { font-size: 15px; }

  /* ── STATS GRID ── */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }

  /* ── FORM (anti iOS auto-zoom) ── */
  .form-row, .form-row-3 { grid-template-columns: 1fr !important; gap: 10px; }
  input:not([type]), input[type=text], input[type=password], input[type=date], input[type=tel],
  input[type=number], input[type=email], input[type=month], input[type=time],
  select, textarea {
    font-size: 16px !important;          /* ≥16px chặn iOS zoom on focus */
    padding: 12px 14px; min-height: 44px;
  }
  .form-group label { font-size: 13px; }

  /* ── BUTTONS ── touch target ≥ 44px ── */
  .btn-primary, .btn-ghost, .btn-success, .btn-danger, .btn-warning {
    min-height: 44px; padding: 10px 16px; font-size: 15px;
  }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }
  .btn-outline { min-height: 36px; padding: 8px 12px; font-size: 13px; }

  /* ── FILTER BAR ── */
  .filter-bar { gap: 8px; }
  .filter-bar input, .filter-bar select { max-width: none; width: 100%; flex: 1 1 100%; }

  /* ── TABLE — giữ scroll ngang nhưng có hint, ưu tiên card layout khi có ── */
  .table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--gray-200); border-radius: 10px;
    background: linear-gradient(90deg, #fff 30%, rgba(255,255,255,0)),
                linear-gradient(90deg, rgba(255,255,255,0), #fff 70%) 100% 0,
                radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.12), rgba(0,0,0,0)),
                radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.12), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat; background-size: 30px 100%, 30px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  table { min-width: 560px; font-size: 13px; }
  thead th, tbody td { padding: 10px 10px; }
  .td-actions { gap: 6px; }
  .td-actions .btn-sm { padding: 8px; min-width: 36px; min-height: 36px; }

  /* ── MODAL — bottom-sheet trên mobile ── */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0;
    width: 100%; animation: slideUpModal .25s ease;
  }
  @keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-header { padding: 14px 16px; }
  .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column-reverse; gap: 8px; }
  .modal-footer button { width: 100%; min-height: 46px; }

  /* ── TOAST — full bottom strip ── */
  .toast { left: 12px; right: 12px; bottom: 16px; min-width: 0; width: auto; justify-content: center; }

  /* ── EMPTY STATE ── */
  .empty-state { padding: 32px 16px; }
  .empty-state i { font-size: 36px; }
  .empty-state p { font-size: 14px; }

  /* ── LOGIN ── */
  .login-page { padding: 20px; }
  .login-card { width: 100%; padding: 28px 20px; border-radius: 14px; }
  .logo-icon { width: 64px; height: 64px; }
  .logo-icon i { font-size: 26px; }
  .login-logo h1 { font-size: 20px; }

  /* ── PROFILE ── */
  .profile-card { flex-direction: column; text-align: center; padding: 22px 16px; gap: 14px; }
  .profile-avatar { width: 72px; height: 72px; font-size: 34px; }
  .profile-name { font-size: 19px; }
  .profile-badges { justify-content: center; }

  /* ── PERMISSIONS MATRIX — chuyển sang stacked block ── */
  .perm-matrix-header, .perm-row, .perm-col-save { grid-template-columns: 1fr; }
  .perm-row { padding: 8px 0; border-top: 8px solid var(--gray-100); }
  .perm-row-label { padding: 10px 14px; font-weight: 700; font-size: 14px; }
  .perm-cell { justify-content: flex-start; padding: 8px 14px; border-left: none; border-top: 1px dashed var(--gray-200); }
  .perm-cell::before {
    content: attr(data-role-label);
    margin-right: auto; font-size: 12px; color: var(--gray-500); text-transform: uppercase;
  }
  .perm-col-head:not(:first-child) { display: none; }

  /* ── TIMESHEET / PAYROLL / NHÂN SỰ: ẩn bảng desktop, hiện cards ── */
  .ts-wrap, .table-wrap { display: none !important; }
  .ts-mobile-cards-wrap { display: block !important; }
  /* Phase AS bis-62: Shift close mobile cards */
  .sc-mobile-cards { display: flex !important; flex-direction: column; gap: 12px; padding: 12px 0; }
  .sc-card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 14px; cursor: pointer; transition: box-shadow .15s;
  }
  .sc-card:active { background: #f9fafb; }
  .sc-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
  .sc-card-name { font-size: 15px; }
  .sc-card-meta { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
  .sc-card-total { text-align: right; min-width: 105px; }
  .sc-card-body { font-size: 13px; line-height: 1.9; }
  .sc-row { display: flex; justify-content: space-between; align-items: center; }
  .sc-row span { color: var(--gray-500); }

  /* ── TIMESHEET — chuyển sang card per NV ── */
  .ts-toolbar { gap: 8px; }
  .ts-toolbar-left, .ts-toolbar-right { width: 100%; }
  .ts-toolbar-right select, .ts-toolbar-right input { width: 100%; }
  .ts-view-btns { width: 100%; }
  .ts-view-btn { flex: 1; min-height: 40px; }
  .ts-nav { flex: 1; justify-content: space-between; }
  .ts-nav-btn { min-width: 44px; min-height: 44px; }
  /* Compact table (giữ horizontal scroll) */
  .ts-wrap { font-size: 11.5px; }
  .ts-emp-head, .ts-emp-cell { min-width: 130px; max-width: 130px; }
  .ts-emp-name { max-width: 100px; font-size: 12px; }
  .ts-emp-sub { font-size: 10px; }
  .ts-day-head, .ts-summary-head { min-width: 44px; }
  .ts-day-head .ts-dow { font-size: 10px; }
  .ts-day-head .ts-daynum { font-size: 12px; }

  /* ── BANNER SYNC (Payroll/Timesheet) — stack vertical ── */
  #yunattBanner { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; font-size: 12.5px; }
  #yunattBanner > div { flex: 1 1 100%; }
  #yunattBanner > span:last-child { margin-left: 0 !important; }
  #yunattStatusBadge { display: inline-flex; align-items: center; gap: 6px; }

  /* ── EMP NAME CELL — narrower avatar ── */
  .emp-avatar-sm { width: 32px; height: 32px; font-size: 13px; }

  /* ── BADGES ── */
  .badge { padding: 4px 10px; font-size: 12px; }

  /* ── TABS ── */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-btn { flex: 0 0 auto; min-height: 44px; }

  /* ── NOTIF LIST ── */
  .notif-item { padding: 12px 14px; gap: 10px; }
  .notif-title { font-size: 14px; }
  .notif-msg { font-size: 13px; }

  /* ── HIDE LESS IMPORTANT TABLE COLUMNS ── */
  .hide-on-mobile { display: none !important; }

  /* ── SHIFT/LEAVE STATS ── */
  .shift-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .shift-stat-card { padding: 10px 8px; }
  .shift-stat-num { font-size: 16px; }
  .shift-stat-lbl { font-size: 11px; }
  /* Phase AS bis-64: 3 stat card Bảng lương → stack dọc, full-width. */
  .shift-stats.payroll-3stats { grid-template-columns: 1fr !important; gap: 10px; }
  .shift-stats.payroll-3stats .shift-stat-card { padding: 14px 18px; text-align: left; }
  .shift-stats.payroll-3stats .shift-stat-num { font-size: 22px; }
  .shift-stats.payroll-3stats .shift-stat-lbl { font-size: 13px; }

  /* ── SHIFT TOOLBAR — chuyển sang column, mọi con full width ── */
  .shift-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .shift-toolbar > * { width: 100% !important; max-width: 100% !important; min-width: 0 !important; flex: 0 0 auto !important; }
  /* Phase AS bis-66: Payroll toolbar giữ ROW — month picker trái, nút Chốt lương phải. */
  .shift-toolbar.payroll-toolbar {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .shift-toolbar.payroll-toolbar > * { width: auto !important; max-width: none !important; }
  .shift-toolbar.payroll-toolbar .btn-success { min-width: 0 !important; padding: 8px 14px !important; }
  .shift-filters {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: wrap !important;
    flex-shrink: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
  }
  .shift-filters > * { width: 100% !important; max-width: 100% !important; min-width: 0 !important; flex: 0 0 auto !important; }
  .shift-filters input, .shift-filters select { width: 100% !important; max-width: 100% !important; }
  .shift-filters button { width: 100% !important; max-width: 100% !important; }
  .shift-tabs { flex-wrap: wrap !important; gap: 6px !important; }
  .shift-tab { flex: 1 1 auto !important; min-width: 0 !important; }

  /* ── RULE HEADER — column stack ── */
  .rule-header {
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .rule-header > * { width: 100% !important; max-width: 100% !important; min-width: 0 !important; flex: 0 0 auto !important; }
  .rule-title { word-break: break-word; }
  .rule-header > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .rule-header button {
    flex: 1 1 auto !important;
    max-width: 100% !important;
    white-space: nowrap;
    min-height: 38px;
  }

  /* ── EYE-CATCH TOPBAR notif badge ── */
  .notif-btn { min-width: 44px; min-height: 44px; }
}

/* iPhone xs / SE narrower (≤ 380px) — compact thêm */
@media (max-width: 380px) {
  .topbar-title { font-size: 14px; }
  .stat-value { font-size: 16px; }
  .login-card { padding: 22px 16px; }
  .nav-item { font-size: 14px; }
  table { min-width: 480px; font-size: 12.5px; }
}

/* ===== TRAINING (Đào tạo) ===== */
.tr-progress-bar {
  width: 100%; height: 10px; background: rgba(255,255,255,.18);
  border-radius: 12px; overflow: hidden; position: relative;
}
.tr-progress-bar.mini { height: 6px; background: var(--gray-200); }
.tr-progress-fill {
  height: 100%; background: #fff; border-radius: 12px; transition: width .4s ease;
}

.tr-level-switch { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tr-level-btn {
  padding: 8px 14px; border: 1.5px solid var(--gray-200); background: #fff;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--gray-600); transition: all .15s;
}
.tr-level-btn:hover { border-color: var(--primary); color: var(--primary); }
.tr-level-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tr-lesson-list { display: flex; flex-direction: column; gap: 10px; }
.tr-lesson-card {
  display: flex; align-items: stretch; gap: 14px; padding: 14px 16px;
  background: var(--gray-50); border-radius: var(--radius);
  border-left: 4px solid var(--gray-300); cursor: pointer; transition: all .15s;
}
.tr-lesson-card:hover { background: #fff; box-shadow: var(--shadow-md); transform: translateX(2px); }
.tr-lesson-card.status-in_progress { border-left-color: var(--warning); background: var(--warning-light); }
.tr-lesson-card.status-completed { border-left-color: var(--success); background: var(--success-light); }
.tr-lesson-num {
  width: 38px; height: 38px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: var(--primary); flex-shrink: 0;
  box-shadow: var(--shadow);
}
.tr-lesson-card.status-completed .tr-lesson-num { background: var(--success); color: #fff; }
.tr-lesson-body { flex: 1; min-width: 0; }
.tr-lesson-title { font-weight: 700; font-size: 14px; color: var(--gray-800); margin-bottom: 4px; }
.tr-lesson-desc { font-size: 12.5px; color: var(--gray-600); margin-bottom: 6px; line-height: 1.4; }
.tr-lesson-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--gray-500); } /*bis-309: "Bắt buộc" + badge trạng thái căn ngang nhau*/
.tr-lesson-arrow { display: flex; align-items: center; color: var(--gray-400); }

.tr-skill-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.tr-skill-card {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 14px; transition: all .15s;
}
.tr-skill-card.earned { background: var(--success-light); border-color: var(--success); }
.tr-skill-card.optional { border-style: dashed; }
.tr-skill-head { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-800); margin-bottom: 6px; }
.tr-skill-desc { font-size: 12px; color: var(--gray-600); line-height: 1.5; margin-bottom: 10px; min-height: 32px; }
.tr-skill-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--gray-500); }
.tr-skill-meta .tr-progress-bar { flex: 1; }

.tr-lesson-meta-bar {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 12px;
  background: var(--gray-50); border-radius: 8px; margin-bottom: 14px;
  font-size: 12.5px; color: var(--gray-600); align-items: center;
}

.tr-outcomes {
  background: var(--primary-light); border-left: 4px solid var(--primary);
  padding: 12px 14px; border-radius: 8px; margin-bottom: 16px;
  font-size: 13px; color: var(--gray-700); line-height: 1.55;
}

/* Markdown render */
.tr-content { font-size: 14px; line-height: 1.7; color: var(--gray-700); }
.tr-content h2.tr-h2 { font-size: 18px; font-weight: 800; color: var(--gray-800); margin: 18px 0 8px; }
.tr-content h3.tr-h3 { font-size: 15px; font-weight: 700; color: var(--primary); margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--gray-200); }
.tr-content p { margin-bottom: 10px; }
.tr-content strong { color: var(--gray-800); }
.tr-content ul.tr-ul, .tr-content ol.tr-ol { margin: 8px 0 12px 22px; }
.tr-content ul.tr-ul li, .tr-content ol.tr-ol li { margin-bottom: 5px; }
.tr-content pre.tr-code {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px;
  border-radius: 8px; overflow-x: auto; font-size: 12.5px;
  line-height: 1.55; font-family: 'Menlo','Consolas',monospace; margin: 10px 0;
}
.tr-content code.tr-inline {
  background: var(--gray-100); padding: 2px 6px; border-radius: 4px;
  font-size: 12.5px; font-family: 'Menlo','Consolas',monospace; color: var(--danger);
}
.tr-content blockquote.tr-quote {
  border-left: 3px solid var(--primary); background: var(--primary-light);
  padding: 8px 14px; margin: 10px 0; border-radius: 0 6px 6px 0; font-size: 13px;
}
/* bis292: ảnh minh họa bài học — 2 ảnh cùng dòng tự đứng cạnh nhau, mobile tự wrap */
.tr-content figure.tr-fig {
  display: inline-block; vertical-align: top;
  margin: 6px 10px 8px 0; max-width: min(100%, 300px);
}
.tr-content figure.tr-fig img {
  width: 100%; display: block; border-radius: 12px;
  border: 1px solid var(--gray-200); background: var(--gray-50);
}
.tr-content figure.tr-fig figcaption {
  font-size: 12px; color: var(--gray-500); text-align: center; margin-top: 4px; line-height: 1.4;
}
.tr-content table.tr-table {
  width: 100%; min-width: auto; border-collapse: collapse; margin: 12px 0;
  font-size: 13px; border-radius: 6px; overflow: hidden;
}
.tr-content table.tr-table th {
  background: var(--gray-100); padding: 8px 12px; text-align: left;
  font-size: 12px; font-weight: 700; color: var(--gray-700);
  text-transform: uppercase; border-bottom: 2px solid var(--gray-200);
}
.tr-content table.tr-table td { padding: 8px 12px; border-bottom: 1px solid var(--gray-100); }
.tr-content .tr-check {
  display: block; padding: 6px 10px; background: var(--gray-50);
  border-radius: 6px; margin-bottom: 4px; font-size: 13.5px; color: var(--gray-700);
}
.tr-content .tr-check.done { background: var(--success-light); color: var(--success); text-decoration: line-through; }
.tr-content .tr-check i { margin-right: 6px; color: var(--gray-400); }
.tr-content .tr-check.done i { color: var(--success); }

/* Admin skill picker */
.tr-skill-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tr-skill-pick-item {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 10px; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 20px; font-size: 12px; color: var(--gray-700);
}
.tr-skill-pick-item:hover { background: var(--primary-light); border-color: var(--primary); }
.tr-skill-pick-item input { margin: 0; }

@media (max-width: 768px) {
  .tr-skill-grid { grid-template-columns: 1fr; }
  .tr-lesson-card { padding: 12px; gap: 10px; }
  .tr-lesson-num { width: 32px; height: 32px; font-size: 14px; }
}

/* ============================================================
   Phase M — iOS overlay: soft component refinements
   Áp toàn app, KHÔNG đụng HTML markup.
   ============================================================ */

/* Card softer */
.card {
  border-radius: 14px !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
  background: #fff;
  padding: 16px 18px;
  border: 1px solid #efeff4;
}

/* Buttons flat iOS */
.btn-primary, .btn-success, .btn-danger, .btn-warning {
  background: var(--primary) !important;
  background-image: none !important;
  border-radius: 12px !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  letter-spacing: -0.01em;
  padding: 11px 18px !important;
  box-shadow: none !important;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--primary-dark) !important; transform: none !important; }
.btn-success { background: var(--success) !important; }
.btn-success:hover { background: #2eb04a !important; transform: none !important; }
.btn-danger  { background: var(--danger)  !important; }
.btn-danger:hover { background: #e0322a !important; transform: none !important; }
.btn-warning { background: var(--warning) !important; }
.btn-warning:hover { background: #e58300 !important; transform: none !important; }
.btn-sm { padding: 7px 12px !important; font-size: 13px !important; border-radius: 10px !important; }

.btn-outline, .btn-ghost {
  background: #f2f2f7 !important;
  color: var(--primary) !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 11px 16px !important;
  font-weight: 600 !important;
  font-size: 15px !important;
}
.btn-outline:hover, .btn-ghost:hover { background: #e5e5ea !important; }

/* Inputs iOS softer (chỉ áp khi không có class .ios-input đặt riêng) */
input:not([type]):not(.ios-input), /*bis-293*/
input[type=text]:not(.ios-input),
input[type=password]:not(.ios-input),
input[type=date]:not(.ios-input),
input[type=tel]:not(.ios-input),
input[type=number]:not(.ios-input),
input[type=email]:not(.ios-input),
input[type=month]:not(.ios-input),
select:not(.ios-select), textarea {
  background: #f2f2f7 !important;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  padding: 11px 14px !important;
  font-size: 16px;
  color: var(--gray-800);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input:not(.ios-input):focus,
select:not(.ios-select):focus, textarea:focus {
  border-color: var(--primary) !important;
  background: #fff !important;
  box-shadow: 0 0 0 4px rgba(0,122,255,0.12) !important;
}

/* Form group label iOS */
.form-group label {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--gray-600) !important;
  letter-spacing: -0.01em;
}

/* Tables — softer header */
table th {
  background: #f9f9fb !important;
  color: var(--gray-600);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 11.5px;
}
table tr { border-bottom: 1px solid #efeff4; }

/* Sidebar iOS */
.sidebar { border-right: 1px solid #efeff4; background: #fff !important; }
.sidebar a, .sidebar .nav-item { font-weight: 500; letter-spacing: -0.01em; }
.sidebar .active, .sidebar a.active {
  background: rgba(0,122,255,0.1) !important;
  color: var(--primary) !important;
  border-radius: 10px;
}

/* Phase AA — Badge số ca chờ duyệt cạnh menu Đăng ký ca làm */
.nav-item { position: relative; }
.nav-badge {
  margin-left: auto;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Phase W — Sidebar footer logout button */
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-footer {
  margin-top: auto;            /* đẩy logout xuống cuối */
  border-top: 1px solid #efeff4;
  padding: 8px 0 14px;
  background: #fff;
}
.nav-logout {
  color: #ff3b30 !important;       /* iOS red */
  font-weight: 500 !important;
  border-left-color: transparent !important;
}
.nav-logout:hover {
  background: rgba(255,59,48,0.08) !important;
  color: #ff3b30 !important;
  border-left-color: transparent !important;
}
.nav-logout .lucide-icon {
  width: 18px; height: 18px;
  stroke: #ff3b30; stroke-width: 1.7;
}

/* Phase W — Profile page logout button */
.btn-profile-logout {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: #ff3b30;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: background .15s;
}
.btn-profile-logout:hover,
.btn-profile-logout:active {
  background: rgba(255,59,48,0.08);
}
.btn-profile-logout .lucide-icon {
  stroke: #ff3b30; stroke-width: 1.7;
  width: 20px; height: 20px;
}

/* Phase W — More drawer logout (mobile) */
.md-item.md-logout {
  color: #ff3b30 !important;
  border: 1px solid rgba(255,59,48,0.2);
}
.md-item.md-logout:hover,
.md-item.md-logout:active {
  background: rgba(255,59,48,0.08);
}
.md-item.md-logout .lucide-icon {
  stroke: #ff3b30; stroke-width: 1.7;
  width: 22px; height: 22px;
}

/* Topbar */
.topbar { background: rgba(255,255,255,0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid #efeff4; }

/* Login page iOS */
.login-page {
  background: linear-gradient(180deg, #f2f2f7 0%, #ffffff 100%) !important;
}
.login-card {
  border-radius: 20px !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.06) !important;
  border: 1px solid #efeff4;
  padding: 36px 32px !important;
}
.logo-icon {
  background: linear-gradient(135deg, #007aff, #5ac8fa) !important;
  box-shadow: 0 6px 18px rgba(0,122,255,0.25) !important;
}
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.022em; }
.login-logo p { color: var(--gray-500); font-size: 14px; }
.login-card .btn-primary {
  width: 100%; padding: 14px !important; font-size: 16px !important; margin-top: 8px;
}

/* KPI dashboard cards */
.stat-card {
  background: #fff;
  border-radius: 14px !important;
  padding: 18px 16px !important;
  border: 1px solid #efeff4 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stat-card .stat-num, .stat-card-num, .stat-num {
  font-size: 26px !important;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--gray-800);
}
.stat-card-label, .stat-lbl, .stat-card-lbl {
  font-size: 13px !important;
  color: var(--gray-500) !important;
  font-weight: 500;
  margin-top: 4px;
}

/* Stats grid responsive mobile 2x2 */
.stats-grid, .dashboard-stats, .shift-stats {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 12px;
}
@media (max-width: 768px) {
  .stats-grid, .dashboard-stats, .shift-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Badge iOS */
.badge, .status-badge {
  border-radius: 8px !important;
  padding: 3px 9px !important;
  font-size: 11.5px !important;
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* Modal box border-radius bigger */
.modal-box { border-radius: 18px !important; }
.modal-header { border-bottom: 1px solid #efeff4 !important; }
.modal-header h3 { font-size: 17px !important; font-weight: 600; letter-spacing: -0.014em; }
.modal-footer { border-top: 1px solid #efeff4 !important; padding-top: 16px; }

/* Empty state iOS */
.empty-state { color: var(--gray-500) !important; padding: 24px; text-align: center; }
.empty-state i { color: var(--gray-300) !important; }

/* Mobile sidebar drawer giữ pattern cũ, polish */
@media (max-width: 768px) {
  .card { border-radius: 12px !important; padding: 14px 14px; }
  .btn-primary, .btn-success, .btn-danger, .btn-warning,
  .btn-outline, .btn-ghost { padding: 10px 14px !important; font-size: 14px !important; }
}

/* Card header iOS */
.card-header {
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid #efeff4;
}
.card-title {
  font-size: 16px !important; font-weight: 600 !important;
  letter-spacing: -0.012em; color: var(--gray-800);
  display: inline-flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--primary); font-size: 15px; }

/* ============================================================
   Phase N3 — Lesson modal fullscreen mobile (≤480px)
   Đánh dấu modal bằng class .lesson-modal trên .modal-box
   ============================================================ */
/*bis-301: Long chốt 23/7 — tiêu đề bài học KHÔNG ghim khi cuộn, cuộn theo nội dung
  (mọi màn hình). Override sticky mặc định của .modal-header.*/
.modal-box.lesson-modal > .modal-header { position: static !important; }
/*bis-302: bỏ 'contain' (bis-281) riêng cho modal bài học — kéo xuống ở đỉnh bài phải
  lan ra được document để native pull-to-refresh (F5) chạy*/
.modal-box.lesson-modal { overscroll-behavior-y: auto; }
/*bis-303: khôi phục bài sau refresh — hiện ngay, không chạy animation trượt lên*/
.modal-box.lesson-modal.lesson-restore { animation: none !important; }
@media (max-width: 480px) {
  .modal-box.lesson-modal {
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    /*bis-296: 100vh trên iOS Safari CAO HƠN viewport thật (thanh URL/toolbar) → mép dưới
      modal bị cắt, cuộn không tới cuối bài. Dùng --app-vh (đo từ visualViewport, app.js
      setVH) — fallback dvh rồi vh cho browser cũ/JS chưa chạy.*/
    height: 100vh; max-height: 100vh;
    height: 100dvh; max-height: 100dvh;
    height: var(--app-vh, 100dvh); max-height: var(--app-vh, 100dvh);
    margin: 0;
    /*bis-301: bỏ flex column (header cố định) — box tự cuộn cả header + nội dung*/
    display: block;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: lessonSlideUp .28s cubic-bezier(0.32, 0.72, 0.16, 1);
  }
  .modal-box.lesson-modal > .modal-header {
    padding: 14px 16px;
    background: rgba(255,255,255,0.96);
    border-bottom: 1px solid #efeff4 !important;
  }
  .modal-box.lesson-modal > .modal-header h3 {
    font-size: 15px !important; line-height: 1.3;
  }
  .modal-box.lesson-modal > .modal-body {
    padding: 16px;
    padding-bottom: 100px;  /* room for sticky bottom button */
    overflow: visible;
  }
  .modal-overlay { padding: 0 !important; }
  /*bis-305: kéo xuống pull-to-refresh trong bài học — rubber band hé khoảng trên modal,
    lộ backdrop tối phía sau. Modal bài học fullscreen nên overlay chuyển trắng luôn cho sạch.*/
  .modal-overlay:has(.modal-box.lesson-modal) {
    background: #fff;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
}
@keyframes lessonSlideUp {
  from { transform: translateY(100%) } to { transform: translateY(0) }
}

/* ============================================================
   Phase N2 — Bottom tab bar mobile (≤768px)
   ============================================================ */
.bottom-tab-bar { display: none; }

@media (max-width: 768px) {
  .sidebar { display: none !important; }
  /* Phase AS bis-73: BODY-SCROLL PATTERN — native iOS pull-to-refresh works.
     - Body scroll tự nhiên (không position:fixed, không overflow:hidden).
     - Bottom-tab-bar position:fixed → luôn nằm dưới, page-content padding-bottom để không đè.
     - Topbar sticky top:0 → header luôn hiện. */
  html, body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    position: static !important;
    width: 100% !important;
    overscroll-behavior-y: auto;  /* Cho phép native pull-to-refresh */
  }
  #appPage {
    min-height: 100dvh;
    display: flex; flex-direction: column;
  }
  .main-content {
    margin-left: 0 !important;
    padding-bottom: 74px !important;  /* space cho bottom-tab-bar fixed */
    display: flex; flex-direction: column;
  }
  .topbar {
    position: sticky !important;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
  }
  .page-content {
    padding: 12px 10px;
  }
  .topbar-menu-btn { display: none; }

  .bottom-tab-bar {
    display: flex !important;
    position: fixed !important;
    left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0,0,0,0.06);
    padding: 6px 4px max(6px, env(safe-area-inset-bottom)) 4px;
    z-index: 100;
    justify-content: space-around;
  }
  .bt-item {
    flex: 1 1 0; background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 4px; color: #8e8e93;
    font-family: inherit;
    border-radius: 10px;
    transition: color .15s, background .15s;
  }
  .bt-item i { font-size: 20px; line-height: 1; }
  .bt-item span { font-size: 10.5px; font-weight: 500; letter-spacing: -0.01em; }
  .bt-item.active { color: var(--primary); }
  .bt-item.active i { transform: scale(1.05); }
  .bt-item:active { background: rgba(0,122,255,0.06); }
}

/* More drawer (sheet from bottom) */
.more-drawer { display: none; }
.more-drawer.open { display: block; }
.more-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.32);
  z-index: 200; animation: fadeIn .2s;
}
.more-drawer-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 8px 16px max(20px, env(safe-area-inset-bottom)) 16px;
  z-index: 201; max-height: 78vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(0.32,0.72,0.16,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
}
.more-drawer-handle {
  width: 36px; height: 5px; background: #d1d1d6;
  border-radius: 3px; margin: 6px auto 16px;
}
.more-drawer-title {
  font-size: 15px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 8px 12px;
}
.more-drawer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.md-item {
  background: #f2f2f7; border: none; cursor: pointer;
  border-radius: 14px; padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--gray-800); font-family: inherit;
  transition: background .15s, transform .05s;
}
.md-item:active { background: #e5e5ea; transform: scale(0.97); }
.md-item i { font-size: 22px; color: var(--primary); }
.md-item span { font-size: 12px; font-weight: 500; text-align: center; letter-spacing: -0.01em; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp {
  from { transform: translateY(100%) } to { transform: translateY(0) }
}

/* ============================================================
   Phase N4 — Permissions cards iOS
   ============================================================ */
.perm-card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.perm-card {
  background: #fff; border-radius: 16px; border: 1px solid #efeff4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  overflow: hidden;
}
.perm-card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid #efeff4;
  background: linear-gradient(180deg, #fafafd, #fff);
}
.perm-card-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(0,122,255,0.1); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.perm-card-meta { flex: 1; min-width: 0; }
.perm-card-name {
  font-size: 16px; font-weight: 600; letter-spacing: -0.014em;
  color: var(--gray-800);
}
.perm-card-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.perm-card-body { padding: 8px 18px 14px; }

.perm-group { margin-top: 12px; }
.perm-group:first-child { margin-top: 4px; }
.perm-group-label {
  font-size: 11px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 0 6px;
}
.perm-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0;
  border-top: 1px solid #efeff4;
  cursor: pointer;
}
.perm-group .perm-toggle-row:first-of-type { border-top: none; }
.perm-toggle-label {
  font-size: 14px; color: var(--gray-800); flex: 1;
  letter-spacing: -0.01em;
}

/* iOS-style switch */
.ios-switch {
  position: relative; display: inline-block;
  width: 50px; height: 30px; flex-shrink: 0;
}
.ios-switch input {
  opacity: 0; width: 0; height: 0;
}
.ios-switch-slider {
  position: absolute; inset: 0;
  background: #e5e5ea; border-radius: 999px;
  transition: background .2s;
  cursor: pointer;
}
.ios-switch-slider::before {
  content: ''; position: absolute;
  width: 26px; height: 26px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.18);
}
.ios-switch input:checked + .ios-switch-slider { background: var(--success); }
.ios-switch input:checked + .ios-switch-slider::before { transform: translateX(20px); }

@media (max-width: 480px) {
  .perm-card-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Phase P — Banner "Cấp tài khoản"
   ============================================================ */
.account-warn-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff4e0 0%, #fff8eb 100%);
  border: 1px solid #fde8b3;
  border-radius: 16px; padding: 14px 18px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.account-warn-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--warning); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.account-warn-body { flex: 1; min-width: 0; }
.account-warn-title {
  font-size: 15px; font-weight: 600; color: #7c4400; letter-spacing: -0.012em;
}
.account-warn-sub {
  font-size: 13px; color: #92560a; margin-top: 2px;
}
.account-warn-banner button {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .account-warn-banner { flex-wrap: wrap; }
  .account-warn-banner button { width: 100%; margin-top: 4px; }
}

/* ============================================================
   Phase Q — Onboarding page
   ============================================================ */
.onboarding-page {
  position: fixed; inset: 0; z-index: 1500;
  background: linear-gradient(180deg, #f2f2f7 0%, #ffffff 100%);
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", "Segoe UI", "Roboto", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
.onb-container {
  max-width: 560px; margin: 0 auto; padding: 40px 18px;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.onb-card {
  width: 100%;
  background: #fff; border-radius: 20px;
  border: 1px solid #efeff4;
  box-shadow: 0 10px 40px rgba(0,0,0,0.06);
  overflow: hidden;
}
.onb-header {
  text-align: center; padding: 32px 24px 20px;
  border-bottom: 1px solid #efeff4;
}
.onb-header .logo-icon {
  margin: 0 auto 14px; width: 60px; height: 60px;
}
.onb-title {
  font-size: 22px; font-weight: 700; letter-spacing: -0.022em;
  color: var(--gray-800);
}
.onb-sub {
  font-size: 14px; color: var(--gray-500); margin-top: 4px;
}
.onb-body { padding: 24px; display: flex; flex-direction: column; gap: 22px; }
.onb-section {
  display: flex; gap: 14px;
  padding: 16px; background: #f9f9fb; border-radius: 14px;
  border: 1px solid #efeff4;
}
.onb-step-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.onb-step-content { flex: 1; min-width: 0; }
.onb-step-title {
  font-size: 15px; font-weight: 600; color: var(--gray-800);
  letter-spacing: -0.012em;
}
.onb-step-sub {
  font-size: 12.5px; color: var(--gray-500); margin: 2px 0 12px;
}
.onb-branch-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 4px;
}
.onb-branch-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 2px solid #efeff4; border-radius: 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: #fff;
}
.onb-branch-card:hover { border-color: #d1d1d6; }
.onb-branch-card input {
  width: 18px; height: 18px; accent-color: var(--primary);
}
.onb-branch-card:has(input:checked) {
  border-color: var(--primary); background: rgba(0,122,255,0.05);
}
.onb-branch-name {
  font-size: 14px; font-weight: 600; color: var(--gray-800); letter-spacing: -0.012em;
}
.onb-branch-tag {
  font-size: 11px; color: var(--gray-500); margin-top: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0;
}
.onb-footer {
  padding: 14px 24px 24px; border-top: 1px solid #efeff4;
}
.onb-footer .ios-btn { width: 100%; padding: 14px; font-size: 16px; }

@media (max-width: 480px) {
  .onb-container { padding: 16px 12px; }
  .onb-header { padding: 24px 18px 16px; }
  .onb-body { padding: 18px; gap: 16px; }
  .onb-section { padding: 14px; gap: 12px; }
  .onb-branch-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Phase T — Outline icons + lighter weight
   ============================================================ */
.lucide-icon { width: 22px; height: 22px; stroke-width: 1.75; vertical-align: middle; display: inline-block; }
.bt-item .lucide-icon { width: 22px; height: 22px; stroke-width: 1.6; }
.bt-item.active .lucide-icon { stroke-width: 2; }
.topbar .lucide-icon { width: 22px; height: 22px; stroke-width: 1.75; }
.notif-btn .lucide-icon { color: var(--gray-700); }
.notif-btn:hover .lucide-icon { color: var(--primary); }

/* Khi dùng Font Awesome, ưu tiên outline weight (fa-regular) cho icon chính */
.bt-item i.fas, .topbar i.fas { font-weight: 400 !important; }

/* ============================================================
   Phase S — Shift preset chips (Đăng ký ca làm)
   ============================================================ */
.shift-preset-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 6px;
}
.shift-preset-card {
  position: relative;
  background: #f2f2f7; border: 2px solid transparent;
  border-radius: 14px; padding: 14px 12px;
  cursor: pointer; transition: border-color .15s, background .15s, transform .05s;
  text-align: center; font-family: inherit;
  color: var(--gray-800);
  display: flex; flex-direction: column; gap: 4px;
}
.shift-preset-card:hover { background: #e5e5ea; }
.shift-preset-card:active { transform: scale(0.98); }
.shift-preset-card.selected {
  background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,122,255,0.10);
}
.shift-preset-label {
  font-size: 16px; font-weight: 700; letter-spacing: -0.014em;
  color: var(--gray-800);
}
.shift-preset-sub {
  font-size: 12px; color: var(--gray-500); font-weight: 500;
}
.shift-preset-check {
  position: absolute; top: 8px; right: 10px;
  color: var(--primary); font-size: 16px; opacity: 0;
  transition: opacity .15s;
}
.shift-preset-card.selected .shift-preset-check { opacity: 1; }

@media (max-width: 360px) {
  .shift-preset-grid { grid-template-columns: 1fr; }
}

.ios-grant-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #efeff4;
}
.ios-grant-row:first-of-type { border-top: none; }
.ios-grant-left { flex: 1; min-width: 0; }
.ios-grant-name {
  font-size: 14px; font-weight: 600; color: var(--gray-800); letter-spacing: -0.012em;
}
.ios-grant-meta {
  font-size: 12px; color: var(--gray-500); margin-top: 2px;
}


/* bis-161 (Long chốt 13/7/2026 17:38): filter row chốt ca — responsive
   Desktop: 6 element 1 hàng ngang [Từ ngày][Đến ngày][NV][Trạng thái][Xoá lọc][Áp dụng]
   Mobile:  4 filter grid 2x2, 2 button hàng dưới */
.sc-filter-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding: 8px 4px 12px;
  flex-wrap: nowrap;
}
.sc-filter-row .sc-filter-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sc-filter-row .sc-filter-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}
@media (max-width: 640px) {
  /* bis-162 (Long chốt 13/7/2026 17:45): mobile vertical stack, buttons ở cuối bên phải */
  .sc-filter-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .sc-filter-row .sc-filter-col {
    flex: unset;
    width: 100%;
  }
  /* bis-163: force width để date input không overflow */
  .sc-filter-row .sc-filter-col input,
  .sc-filter-row .sc-filter-col > button {
    height: 48px !important;
    font-size: 14px !important;
    padding: 0 14px !important;
    border-radius: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .sc-filter-row .sc-filter-col input[type="date"] {
    -webkit-appearance: none !important;
    appearance: none !important;
  }
  .sc-filter-row .sc-filter-col label {
    font-size: 12px !important;
  }
  .sc-filter-row .sc-filter-actions {
    justify-content: flex-end;
    width: 100%;
    margin-top: 4px;
  }
  .sc-filter-row .sc-filter-actions button {
    height: 44px !important;
    font-size: 14px !important;
  }
}


/* bis-166: dropdown Nhân viên/Trạng thái phải overlay ra ngoài card cha */
.sc-filter-row,
.sc-filter-col {
  overflow: visible !important;
}
.card:has(#scUserBox),
.card:has(#scStatusBox),
div:has(> #scUserBox),
div:has(> #scStatusBox) {
  overflow: visible !important;
}
/* Ancestors 3 tầng trở lên (thường là các div wrapper) */
.card:has(.sc-filter-row) {
  overflow: visible !important;
}


/* bis-167: đồng nhất font + control size DESKTOP với mobile, GIỮ bố cục 1 hàng ngang */
@media (min-width: 641px) {
  .sc-filter-row .sc-filter-col input,
  .sc-filter-row .sc-filter-col > button {
    height: 48px !important;
    font-size: 14px !important;
    padding: 0 14px !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }
  .sc-filter-row .sc-filter-col input[type="date"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    text-align: center !important;
  }
  .sc-filter-row .sc-filter-actions button {
    height: 48px !important;
    font-size: 14px !important;
    padding: 0 18px !important;
    border-radius: 14px !important;
  }
  /* Dropdown item cùng font-size để đồng nhất */
  .sc-filter-col [style*="position:absolute"] > div {
    font-size: 14px !important;
  }
}


/* bis-mobile-round2 */
@media (max-width: 768px) {
  .hide-on-mobile { display: none !important; }
  .ts-wrap { display: none !important; }
  #yunattBanner { display: none !important; }
  #shiftMobileCards { display: block; margin-top: 12px; }
}
@media (min-width: 769px) {
  #shiftMobileCards { display: none; }
}


/* bis-mobile-round3-hide-shift-toolbar */
@media (max-width: 768px) {
  /* Ca làm mobile — bỏ filter chips + search + 2 buttons "Duyệt tất cả" + "Đăng ký ca". */
  /* Giữ .shift-stats (4 cards) + #shiftMobileCards (list). */
  .shift-toolbar { display: none !important; }
}


/* bis-mobile-round4-shift-card */
.shift-card-mobile {
  background: var(--white, #fff);
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.shift-card-mobile .scm-head {
  display: flex; align-items: center; gap: 8px;
}
.shift-card-mobile .scm-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.shift-card-mobile .scm-title { flex: 1; min-width: 0; }
.shift-card-mobile .scm-name {
  font-weight: 700; font-size: 14px; color: var(--gray-800, #1f2937);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shift-card-mobile .scm-sub {
  font-size: 11.5px; color: var(--gray-500, #6b7280);
  margin-top: 1px; line-height: 1.2;
}
.shift-card-mobile .scm-status { flex-shrink: 0; }
.shift-card-mobile .scm-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin-top: 6px; font-size: 12.5px; color: var(--gray-700, #374151);
}
.shift-card-mobile .scm-time i {
  color: var(--primary, #3b82f6); margin-right: 4px;
}
.shift-card-mobile .scm-swap {
  color: #6d28d9; font-weight: 600;
}
.shift-card-mobile .scm-note {
  margin-top: 4px; font-size: 11.5px; color: var(--gray-500, #6b7280);
}
.shift-card-mobile .scm-actions {
  margin-top: 8px; display: flex; gap: 6px;
}
.shift-card-mobile .scm-actions .btn-sm { flex: 1; }
/* bis-239: card NV mobile — actions compact icon-only right-aligned, không full-width khổng lồ */
.shift-card-mobile .scm-actions.emp-actions-compact { justify-content: flex-end; gap: 8px; margin-top: 6px; }
.shift-card-mobile .scm-actions.emp-actions-compact .btn-sm {
  flex: 0 0 auto; min-width: 44px; min-height: 32px !important; padding: 6px 14px !important; font-size: 13px !important;
}

/* bis-321 (Long chốt 24/7/2026): modal có class .center-mobile trên overlay → hiện GIỮA màn hình
   cả trên mobile (thay bottom-sheet mặc định) — dùng cho popup xác nhận thu tiền mặt chốt ca. */
@media (max-width: 768px) {
  .modal-overlay.center-mobile { padding: 20px !important; align-items: center !important; }
  .modal-overlay.center-mobile .modal-box {
    width: 100%; max-width: 400px; border-radius: 18px;
    animation: popInModal .18s ease;
  }
}
@keyframes popInModal { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* bis-328: element chỉ hiện trên mobile (đối xứng với .hide-on-mobile) */
@media (min-width: 769px) { .only-mobile { display: none !important; } }

/* bis-333: modal Bộ lọc chốt ca trên mobile — KHOÁ chiều cao ~2/3 màn hình, mở dropdown
   list dài thì cuộn bên trong modal chứ không phình sheet lên full màn hình. */
@media (max-width: 768px) {
  .modal-overlay.sc-filter-sheet .modal-box { max-height: 66vh !important; }
}

/* bis-343 (Long chốt 24/7/2026): CHẶN PAN NGANG toàn modal ở tầng CSS native — giữ popup kéo
   sang 2 bên là viewport pan ngang, touch-action pan-y cấm hẳn trục ngang cho mọi gesture
   bắt đầu trong overlay. Cuộn ngang BÊN TRONG (.ctkm-sapo-tblwrap, .ctkm-tabs, .table-wrap)
   không bị ảnh hưởng: gesture đó do container con xử lý, chain không đi qua overlay. */
.modal-overlay { touch-action: pan-y; }

/* bis-345 (Long chốt 24/7/2026): modal-box chỉ khai báo overflow-y → overflow-x tự = auto,
   iOS rubber-band NGANG chéo trong scroller dọc → nội dung popup trượt qua lại "lung tung".
   Khoá cứng trục ngang cho box + body. Cuộn ngang bên trong (.ctkm-sapo-tblwrap...) là
   container con riêng, không ảnh hưởng. */
.modal-box { overflow-x: hidden !important; overscroll-behavior-x: none; touch-action: pan-y; }
.modal-body { overflow-x: hidden; }

/* bis-347→348: toolbar chốt ca mobile — bỏ hẳn bằng hide-on-mobile trong app.js (bis-348),
   rule collapse padding cũ không cần nữa. */

/* bis-349 (Long chốt 24/7/2026): mobile — bỏ vỏ card trắng bao list chốt ca, list nằm
   thẳng dưới topbar (card con từng báo cáo có nền/viền riêng rồi). Desktop giữ nguyên. */
@media (max-width: 768px) {
  .sc-main-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* bis-397: icon Lucide nét mỏng toàn app (shim thinIcons trong app.js) */
svg.lucide { width: 1em; height: 1em; stroke-width: 1.8; vertical-align: -0.145em; flex-shrink: 0; }
.lucide-spin { animation: luspin 0.9s linear infinite; }
@keyframes luspin { to { transform: rotate(360deg); } }
.nav-item svg.lucide { width: 18px; height: 18px; }
.bt-item svg.lucide { width: 20px; height: 20px; }
.md-item svg.lucide { width: 22px; height: 22px; color: var(--primary); }
.empty-state svg.lucide { width: 44px; height: 44px; display: block; margin: 0 auto 12px; }
.logo-icon svg.lucide { width: 28px; height: 28px; color: #fff; }
.user-avatar-sm svg.lucide { width: 34px; height: 34px; color: #60a5fa; }
.brand svg.lucide { color: #60a5fa; width: 20px; height: 20px; }
.card-title svg.lucide { color: var(--primary); }
.wiki-cat-card svg.lucide { width: 24px; height: 24px; color: var(--primary); }
.form-group label svg.lucide { margin-right: 6px; color: var(--primary); }

/* bis-400: nút Duyệt + ✕ trong cột THAO TÁC nằm ngang 1 hàng, không wrap dọc */
.td-actions { white-space: nowrap; }
.td-actions .btn-sm { vertical-align: middle; }
