:root {
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #e2e8f0;
    --text: #1e293b;
    --text-muted: #4b5563;
    --border: #cbd5e1;
    --primary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --orange: #f97316;
    --tc-blue: #1a56a8;
    --tc-blue-dark: #0d3b7a;
    --tc-red: #dc2626;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
/* App chính: khóa chiều cao = viewport để vùng bảng (#view-table) tự cuộn nội bộ
   -> header thead position:sticky mới ghim được. Trang đăng nhập (.auth-page)
   giữ nguyên min-height để không bị cắt nội dung. */
body:not(.auth-page) {
    height: 100vh;
    overflow: hidden;
}

/* ══════════════════════════════════════════════
   HEADER — Tân Cảng style (white, professional)
   ══════════════════════════════════════════════ */
.header {
    background: #ffffff;
    border-bottom: 2px solid var(--tc-blue);
    padding: 6px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 80px;
    animation: indexSlideDown 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) both;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    transition: box-shadow var(--transition-smooth);
}

.header-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}
.header-logo {
    height: 80px;
    width: auto;
    max-width: 500px;
    object-fit: contain;
    margin-right: 16px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0;
}
.header-nav-item,
a.header-nav-item,
a.header-nav-item:link,
a.header-nav-item:visited,
a.header-nav-item:hover,
a.header-nav-item:active {
    padding: 8px 18px;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    border-radius: 6px;
    transition: color var(--transition-fast), background var(--transition-fast);
    border: none;
    background: none;
    white-space: nowrap;
    position: relative;
    line-height: 1;
    letter-spacing: 0.2px;
    text-decoration: none !important;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
}
.header-nav-item::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    right: 50%;
    height: 2.5px;
    background: var(--tc-blue);
    border-radius: 2px;
    transition: left var(--transition-smooth), right var(--transition-smooth);
}
.header-nav-item:hover {
    color: var(--tc-blue);
    background: rgba(26,86,168,0.05);
}
.header-nav-item.active {
    color: var(--tc-blue);
    font-weight: 700;
}
.header-nav-item.active::after {
    left: 14px;
    right: 14px;
}
.header-nav-sep {
    width: 1px;
    height: 16px;
    background: #e2e8f0;
    margin: 0 4px;
}
/* Nút hamburger — chỉ hiện ở mobile (xem media ≤768px) */
.header-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: #334155;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
    margin-right: 4px;
}
.header-burger svg { width: 24px; height: 24px; }
.header-burger:hover { background: rgba(26,86,168,0.06); color: var(--tc-blue); }
.header-burger:focus-visible { outline: 2px solid var(--tc-blue); outline-offset: 2px; }

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.header-status {
    font-size: 14px;
    color: #64748b;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-user-name {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}
.header-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tc-blue), #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(26,86,168,0.3);
    transition: transform var(--transition-spring), box-shadow var(--transition-smooth);
}
.header-user-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(26,86,168,0.4);
}
.header-auth-links {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}
.header-auth-links a {
    color: #334155;
    text-decoration: none;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}
.header-auth-links a:hover {
    color: var(--tc-blue);
    background: #f1f5f9;
}
.header-auth-sep {
    color: #cbd5e1;
    font-weight: 300;
}
.btn-logout {
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-smooth);
}
.btn-logout:hover {
    background: #fee2e2;
    color: var(--tc-red);
    border-color: #fecaca;
    box-shadow: 0 2px 8px rgba(220,38,38,0.15);
    transform: translateY(-1px);
}
.btn-logout:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ══════════════════════════════════════════
   TOOLBAR
   ══════════════════════════════════════════ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    animation: indexFadeUp 0.35s 0.15s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}
.toolbar select, .toolbar input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.toolbar select:focus, .toolbar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.toolbar-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn {
    padding: 7px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.btn-primary:hover { background: #2563eb; box-shadow: 0 4px 16px rgba(59,130,246,0.35); }
.btn-success { background: var(--success); color: white; box-shadow: 0 2px 8px rgba(34,197,94,0.25); }
.btn-success:hover { background: #16a34a; box-shadow: 0 4px 16px rgba(34,197,94,0.35); }
.btn-warning { background: var(--warning); color: black; box-shadow: 0 2px 8px rgba(245,158,11,0.25); }
.btn-warning:hover { box-shadow: 0 4px 16px rgba(245,158,11,0.35); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn-danger:hover { box-shadow: 0 4px 16px rgba(239,68,68,0.35); }
.btn-outline {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); box-shadow: var(--shadow-sm); }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
    box-shadow: none;
}

/* ══════════════════════════════════════════
   TABS
   ══════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ══════════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════════ */
.main-content {
    flex: 1;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    animation: indexFadeUp 0.35s 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

/* ══════════════════════════════════════════
   SCHEDULE TABLE
   ══════════════════════════════════════════ */
.table-container {
    overflow: auto;
    flex: 1;
    min-height: 0;
    margin: 0;
}
.schedule-table {
    border-collapse: collapse;
    font-size: 12.5px;
    width: max-content;
    min-width: 100%;
    color: #1e293b;
}
.schedule-table th, .schedule-table td {
    border: 1px solid #b0bec5;
    text-align: center;
    white-space: nowrap;
}
.schedule-table th {
    background: #1e3a5f;
    color: #ffffff;
    font-weight: 600;
    padding: 6px 4px;
    position: sticky;
    top: 0;
    z-index: 10;
    /* border-collapse làm mất viền khi ghim -> dùng box-shadow giữ đường kẻ */
    box-shadow: inset 0 -1px 0 #b0bec5, 0 2px 4px rgba(15,23,42,0.12);
}
.schedule-table th.col-stt-header {
    position: sticky;
    left: 0;
    z-index: 20;
    background: #1e3a5f;
}
.schedule-table th.col-name {
    position: sticky;
    left: 30px;
    z-index: 20;
    min-width: 160px;
    text-align: left;
    padding-left: 8px;
    background: #1e3a5f;
}
.schedule-table td {
    padding: 4px;
    min-width: 42px;
    height: 32px;
    cursor: pointer;
    transition: background var(--transition-fast), filter var(--transition-fast), box-shadow var(--transition-fast);
    color: #1e293b;
}
.schedule-table td:hover {
    filter: brightness(0.95);
    box-shadow: inset 0 0 0 1.5px rgba(26,86,168,0.25);
}
.schedule-table td.col-name {
    position: sticky;
    left: 30px;
    background: #ffffff;
    z-index: 5;
    text-align: left;
    padding-left: 8px;
    font-weight: 600;
    min-width: 160px;
    color: #0f172a;
}
.schedule-table td.col-stt {
    position: sticky;
    left: 0;
    background: #ffffff;
    z-index: 5;
    width: 30px;
    min-width: 30px;
    font-weight: 600;
    color: #475569;
}
.schedule-table td.col-stats {
    background: #f8fafc;
    font-weight: 600;
    color: #1e293b;
    font-size: 11.5px;
}

.shift-cell {
    border-radius: 4px;
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: 0.3px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.shift-cell:hover {
    transform: scale(1.12);
    z-index: 2;
    position: relative;
}
.shift-CA1 { background: #3b82f6; color: white; }
.shift-CA1:hover { box-shadow: 0 2px 8px rgba(59,130,246,0.4); }
.shift-CA2 { background: #f97316; color: white; }
.shift-CA2:hover { box-shadow: 0 2px 8px rgba(249,115,22,0.4); }
.shift-K { background: #22c55e; color: white; }
.shift-K:hover { box-shadow: 0 2px 8px rgba(34,197,94,0.4); }
.shift-D { background: #8b5cf6; color: white; }
.shift-D:hover { box-shadow: 0 2px 8px rgba(139,92,246,0.4); }
.shift-HC { background: #6b7280; color: #ffffff; }
.shift-HC:hover { box-shadow: 0 2px 8px rgba(107,114,128,0.4); }
.shift-HC_CT { background: #166534; color: #ffffff; }
.shift-HC_CT:hover { box-shadow: 0 2px 8px rgba(22,101,52,0.4); }
.shift-HC_S { background: linear-gradient(135deg, #818cf8, #6366f1); color: #fff; }
.shift-HC_S:hover { box-shadow: 0 2px 8px rgba(99,102,241,0.4); }
.shift-HC_C { background: linear-gradient(135deg, #38bdf8, #0ea5e9); color: #fff; }
.shift-HC_C:hover { box-shadow: 0 2px 8px rgba(14,165,233,0.4); }
.shift-P { background: #facc15; color: #000; }
.shift-P:hover { box-shadow: 0 2px 8px rgba(250,204,21,0.5); }
.shift-NKL { background: #f59e0b; color: #000; }
.shift-NKL:hover { box-shadow: 0 2px 8px rgba(245,158,11,0.4); }
.shift-NS { background: #64748b; color: white; }
.shift-NS:hover { box-shadow: 0 2px 8px rgba(100,116,139,0.4); }
.shift-NO { background: #6d4c41; color: white; }
.shift-NO:hover { box-shadow: 0 2px 8px rgba(109,76,65,0.4); }

.shift-pgd.shift-CA1,
.shift-pgd.shift-CA2,
.shift-pgd.shift-D,
.shift-pgd.shift-K,
.shift-pgd.shift-HC,
.shift-pgd.shift-HC_S,
.shift-pgd.shift-HC_C {
    background: #dc2626;
    color: white;
}
.shift-pgd.shift-CA1:hover,
.shift-pgd.shift-CA2:hover,
.shift-pgd.shift-D:hover,
.shift-pgd.shift-K:hover,
.shift-pgd.shift-HC:hover,
.shift-pgd.shift-HC_S:hover,
.shift-pgd.shift-HC_C:hover {
    box-shadow: 0 2px 8px rgba(220,38,38,0.4);
}

.shift-tc.shift-D {
    background: #ec4899;
    color: white;
}
.shift-tc.shift-D:hover {
    box-shadow: 0 2px 8px rgba(236,72,153,0.4);
}

.shift-D-red {
    background: #dc2626 !important;
    color: white !important;
}
.shift-D-red:hover {
    box-shadow: 0 2px 8px rgba(220,38,38,0.4) !important;
}

/* ── Cuối tuần nổi bật: viền dọc khung cột + màu riêng cho T7 / CN ── */
.schedule-table th.weekend-col,
.schedule-table td.weekend-col {
    border-left: 2px solid #475569 !important;
    border-right: 2px solid #475569 !important;
}
/* Thứ 7 & Chủ nhật — cùng một sắc vàng nhạt */
.schedule-table th.sat-col,
.schedule-table th.sun-col {
    background: #d4a017 !important;
    color: #ffffff !important;
}
.schedule-table td.sat-col,
.schedule-table td.sun-col {
    background: #fefce8 !important;
}
.schedule-table td.sat-col:hover,
.schedule-table td.sun-col:hover {
    background: #fef9c3 !important;
}
/* Ô tiêu đề ngày bấm được để đánh dấu lễ/tết */
.schedule-table th.day-th { cursor: pointer; user-select: none; }
.schedule-table th.day-th:hover { outline: 2px solid #f59e0b; outline-offset: -2px; }
.schedule-table th.holiday-col {
    background: #dc2626 !important;
    color: #ffffff !important;
}
.holiday-badge {
    display: inline-block;
    font-size: 8px;
    line-height: 1;
    background: #ffffff;
    color: #dc2626;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 700;
    margin-top: 1px;
}
/* Ô đã khóa (chỉnh tay) - giữ nguyên khi phân ca tự động */
.schedule-table td.cell-locked {
    position: relative;
    box-shadow: inset 0 0 0 2px #f59e0b;
}
.lock-badge {
    position: absolute;
    top: 0;
    right: 1px;
    font-size: 8px;
    line-height: 1;
    pointer-events: none;
    opacity: 0.85;
}
.group-header {
    background: linear-gradient(90deg, #e8f0fe, #f0f4ff) !important;
    font-weight: 700;
    color: var(--primary);
    text-align: left !important;
    padding-left: 8px !important;
    font-size: 13px;
    border-left: 3px solid var(--tc-blue) !important;
}
.team-header {
    background: linear-gradient(90deg, #fef3c7, #fef9e7) !important;
    font-weight: 600;
    color: #92400e;
    text-align: left !important;
    padding-left: 20px !important;
    font-size: 12px;
    border-left: 3px solid #f59e0b !important;
}
.group-header-row td {
    position: sticky;
    left: 0;
}

/* ══════════════════════════════════════════
   CALENDAR VIEW
   ══════════════════════════════════════════ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 16px 20px;
}
.cal-header {
    text-align: center;
    font-weight: 700;
    padding: 10px 4px;
    color: var(--text-muted);
    font-size: 14px;
    letter-spacing: 0.3px;
}
.cal-day {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    min-height: 200px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.cal-day:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(59,130,246,0.3);
}
.cal-day.weekend { background: #fefbfb; border-color: rgba(239, 68, 68, 0.2); }
.cal-day.weekend:hover { border-color: rgba(239, 68, 68, 0.4); }
.cal-day-num {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.cal-shift {
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 5px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.15s ease;
}
.cal-shift:hover {
    opacity: 0.8;
}

/* ══════════════════════════════════════════
   LEGEND
   ══════════════════════════════════════════ */
/* Chú thích màu ca — ĐÓNG KHUNG, đặt DƯỚI CÙNG trang (sau .main-content).
   LƯU Ý: khung phải là CHÍNH phần tử .legend, KHÔNG bọc thêm div bên ngoài — hàm
   applyScheduleChrome() ẩn/hiện đúng phần tử .legend theo tab; nếu bọc thêm lớp
   ngoài thì khi sang tab khác sẽ còn trơ lại một cái khung rỗng.
   Độ trễ hiệu ứng 0.3s cho khớp thứ tự xuất hiện (header -> công cụ -> bảng -> chú thích). */
.legend {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin: 10px 24px 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    flex: 0 0 auto;
    animation: indexFadeUp 0.3s 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}
/* Nhãn "CHÚ THÍCH" + vạch dọc ngăn với các mục -> nhìn ra ngay đây là phần chú giải */
.legend-title {
    display: flex;
    align-items: center;
    align-self: stretch;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--tc-blue);
    padding-right: 12px;
    border-right: 2px solid var(--border);
    white-space: nowrap;
}
/* Mỗi mục là một thẻ nhỏ có viền nhạt -> 15 mục không dính vào nhau khi xuống dòng */
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 9px;
    border: 1px solid #e8edf3;
    border-radius: 8px;
    background: #fbfcfe;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                transform var(--transition-fast);
    cursor: default;
}
.legend-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    transform: translateY(-1px);
}
.legend-color {
    width: 24px;
    height: 16px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform var(--transition-fast);
}
.legend-item:hover .legend-color {
    transform: scale(1.15);
}

/* ══════════════════════════════════════════
   SHIFT PICKER — chọn loại ca bằng thẻ màu
   (modal "Chỉnh sửa ca trực", thay cho <select> chữ trơn)
   ══════════════════════════════════════════ */
.shift-picker {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 44vh;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
}
.shift-pick-group {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 6px 3px;
}
.shift-pick-group:first-child { padding-top: 3px; }
.shift-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: none;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.shift-pick:hover { background: var(--bg-hover); }
.shift-pick[aria-selected="true"] {
    border-color: var(--primary);
    background: var(--bg-card);
    font-weight: 600;
}
.shift-pick:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.shift-pick:hover .shift-pick-badge { transform: scale(1.08); }
/* CHỈ hình dạng — nền và màu chữ do các lớp .shift-* cấp, nên ô chọn, bảng
   phân ca và dải chú thích luôn dùng chung một nguồn màu duy nhất. */
.shift-pick-badge {
    flex: 0 0 auto;
    width: 42px;
    height: 22px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}
.shift-pick-badge.shift-none {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
}

/* ══════════════════════════════════════════
   STATS PANEL
   ══════════════════════════════════════════ */
.stats-overview {
    padding: 20px 24px;
}

/* --- Summary cards row --- */
.stats-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stats-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 16px;
    text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: statFadeIn 0.5s ease both;
}
.stats-summary-card:nth-child(1) { animation-delay: 0s; }
.stats-summary-card:nth-child(2) { animation-delay: 0.08s; }
.stats-summary-card:nth-child(3) { animation-delay: 0.16s; }
.stats-summary-card:nth-child(4) { animation-delay: 0.24s; }
.stats-summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.stats-summary-num {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}
.stats-summary-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes statFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Horizontal bar chart (minimalist) --- */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 8px;
    animation: statFadeIn 0.5s ease 0.3s both;
}
.chart-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
}
.chart-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.2px;
}
.chart-total {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.chart-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chart-row {
    display: grid;
    grid-template-columns: 100px 1fr 48px 52px;
    align-items: center;
    gap: 12px;
    opacity: 0;
    animation: chartRowIn 0.45s ease calc(var(--row-i) * 0.08s + 0.4s) both;
}
@keyframes chartRowIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}
.chart-row-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    text-align: right;
}
.chart-row-bar-wrap {
    height: 28px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.chart-row-bar {
    height: 100%;
    border-radius: 6px;
    width: 0;
    animation: barSlide 0.7s cubic-bezier(0.25, 0.8, 0.25, 1) calc(var(--row-i) * 0.08s + 0.5s) forwards;
    position: relative;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}
.chart-row:hover .chart-row-bar {
    opacity: 1;
}
.chart-row-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.2), transparent);
    border-radius: 6px 6px 0 0;
}
@keyframes barSlide {
    to { width: var(--bar-w); }
}
.chart-row-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.chart-row-pct {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- Stats detail header + search --- */
.stats-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.stats-search {
    width: 260px;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}
.stats-search:focus {
    outline: none;
    border-color: var(--tc-blue);
    box-shadow: 0 0 0 3px rgba(26,86,168,0.1);
}
.stats-search::placeholder {
    color: #94a3b8;
}

/* ══════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(0);
    visibility: hidden;
    pointer-events: none;
    transition: background var(--transition-smooth), backdrop-filter var(--transition-smooth), visibility 0s linear 0.3s;
}
.modal-overlay.active {
    visibility: visible;
    pointer-events: auto;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    transition: background var(--transition-smooth), backdrop-filter var(--transition-smooth), visibility 0s linear 0s;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform var(--transition-spring), opacity var(--transition-smooth);
}
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.modal h3 {
    margin-bottom: 16px;
    font-size: 18px;
    position: relative;
    padding-bottom: 12px;
}
.modal h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--tc-blue);
    border-radius: 2px;
}
.modal label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; margin-top: 12px; }
.modal select, .modal input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.modal select:focus, .modal input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

#empAddToggle {
    margin-bottom: 12px;
}
.emp-add-form {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    animation: formSlideDown 0.25s ease-out;
}
@keyframes formSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.emp-add-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.emp-add-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.emp-add-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.emp-add-field label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.emp-add-form input, .emp-add-form select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.emp-add-form input:focus, .emp-add-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.modal select[size] { overflow-y: auto; scrollbar-width: thin; }
.modal select[size] option { padding: 6px 8px; }
.modal select[size] option:checked { background: var(--primary); color: white; }

/* User account management */
.user-form {
    margin: 14px 0;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    animation: formSlideDown 0.25s ease-out;
}
.user-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 14px;
    align-items: end;
}
.user-form-field { display: flex; flex-direction: column; gap: 4px; }
.user-form-field label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin: 0; }
.user-form input, .user-form select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.user-form input:focus, .user-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.user-form input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
.user-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.user-status-on { background: #dcfce7; color: #15803d; }
.user-status-off { background: #fee2e2; color: #b91c1c; }
@media (max-width: 640px) {
    .user-form-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 3500;
    transform: translateY(100px) scale(0.9);
    opacity: 0;
    transition: all var(--transition-spring);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
}
.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast.success { background: linear-gradient(135deg, #22c55e, #16a34a); color: white; }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.toast.info { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; }

/* Scrollbar light */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══════════════════════════════════════════
   LOADING
   ══════════════════════════════════════════ */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(0);
    visibility: hidden;
    pointer-events: none;
    transition: background var(--transition-smooth), backdrop-filter var(--transition-smooth), visibility 0s linear 0.3s;
}
.loading.active {
    visibility: visible;
    pointer-events: auto;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
    transition: background var(--transition-smooth), backdrop-filter var(--transition-smooth), visibility 0s linear 0s;
}
.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(59,130,246,0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    padding: 32px 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    opacity: 0;
    transition: transform var(--transition-spring), opacity var(--transition-smooth);
}
.loading.active .loading-content {
    transform: scale(1);
    opacity: 1;
}
.loading-text {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

/* ══════════════════════════════════════════════
   FOOTER — Tân Cảng gradient style
   ══════════════════════════════════════════════ */
.footer {
    background: linear-gradient(135deg, #0d3b7a 0%, #1a56a8 40%, #2563eb 100%);
    color: #ffffff;
    margin-top: auto;
    position: relative;
    overflow: hidden;
}
.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--tc-red), #f97316, var(--tc-red));
}

.footer-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}
.footer-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}
.footer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.footer-info p {
    font-size: 11.5px;
    line-height: 1.4;
    color: rgba(255,255,255,0.85);
}
.footer-info a {
    color: #93c5fd;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-info a:hover {
    color: #ffffff;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
.footer-hotline {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
}
.footer-hotline span {
    font-size: 14px;
    font-weight: 700;
    color: #fbbf24;
}
.footer-social {
    display: flex;
    gap: 6px;
}
.footer-social-icon {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.1);
}
.footer-social-icon:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding: 8px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}
.footer-bottom span,
.footer-bottom a {
    font-size: 10.5px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-bottom a:hover {
    color: #ffffff;
}
.footer-bottom .footer-sep {
    color: rgba(255,255,255,0.25);
}

/* ══════════════════════════════════════════════════════
   AUTH PAGES — Login / Register with background image
   ══════════════════════════════════════════════════════ */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-bg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: url('/static/img/bg-auth.png') center/cover no-repeat;
    padding: 40px 20px 50px;
}
.auth-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(15,23,42,0.7) 0%, rgba(26,86,168,0.4) 100%);
    z-index: 0;
}

.auth-container {
    position: relative;
    z-index: 1;
    display: flex;
    width: 880px;
    max-width: 100%;
    min-height: 500px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
    animation: authSlideIn 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes authSlideIn {
    from { opacity: 0; transform: translateY(50px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-left {
    flex: 1;
    background: rgba(30,41,59,0.95);
    padding: 44px 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    animation: authFadeRight 1.3s 0.6s ease both;
}
.auth-right {
    flex: 1;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 44px 32px;
    animation: authFadeLeft 1.3s 0.8s ease both;
}

.auth-app-icon {
    font-size: 32px;
    margin-bottom: 6px;
}
.auth-form-wrapper h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #ffffff;
    animation: authFadeUp 1.0s 1.2s ease both;
}
.auth-subtitle {
    color: #cbd5e1;
    font-size: 15px;
    margin-bottom: 28px;
    animation: authFadeUp 1.0s 1.5s ease both;
}
.auth-form-wrapper form {
    animation: authFadeUp 1.2s 1.8s ease both;
}
.auth-link {
    animation: authFadeUp 1.0s 2.4s ease both;
}
.auth-logo-wide {
    max-width: 400px;
    width: 100%;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
    animation: authFadeUp 1.2s 1.2s ease both;
}
.auth-mission {
    text-align: center;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.mission-card {
    padding: 14px 20px;
    animation: authFadeUp 1.1s 1.6s ease both;
}
.mission-card:last-child { animation-delay: 2.2s; }
.auth-mission h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--tc-blue);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2.5px;
}
.auth-mission blockquote {
    font-size: 13.5px;
    line-height: 1.9;
    color: var(--tc-blue);
    font-style: italic;
    font-weight: 500;
    margin: 0;
    padding: 0;
}
.mission-separator {
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--tc-blue), transparent);
    opacity: 0.3;
    margin: 2px auto;
    animation: authFadeUp 1.0s 1.9s ease both;
}
@keyframes authFadeUp {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes authFadeRight {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes authFadeLeft {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes indexSlideDown {
    from { opacity: 0; transform: translate3d(0, -20px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes indexFadeUp {
    from { opacity: 0; transform: translate3d(0, 12px, 0); }
    /* Kết thúc ở 'none' (không phải translate3d 0) để KHÔNG để lại transform dính
       trên ancestor — transform tồn dư phá vỡ position:sticky của header bảng. */
    to { opacity: 1; transform: none; }
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    color: #e2e8f0;
    margin-bottom: 5px;
    font-weight: 500;
}
.form-group label .required { color: #f87171; }
.form-group input {
    width: 100%;
    background: rgba(15,23,42,0.5);
    border: 1px solid rgba(148,163,184,0.3);
    color: #ffffff;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 14px;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), background var(--transition-smooth);
}
.form-group input:hover {
    border-color: rgba(148,163,184,0.5);
    background: rgba(15,23,42,0.6);
}
.form-group input:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
    background: rgba(15,23,42,0.7);
}
.form-group input::placeholder { color: #94a3b8; }

.btn-auth {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    margin-top: 6px;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 12px rgba(220,38,38,0.25);
    position: relative;
    overflow: hidden;
}
.btn-auth::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}
.btn-auth:hover::before {
    left: 100%;
}
.btn-auth:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(220,38,38,0.4);
}
.btn-auth:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(220,38,38,0.2);
}

.auth-link {
    text-align: center;
    font-size: 13px;
    color: #cbd5e1;
    margin-top: 20px;
}
.auth-link a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
}
.auth-link a:hover { text-decoration: underline; }

.auth-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
}
.auth-success {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.3);
    color: #86efac;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* Auth page header */
.auth-header {
    background: #ffffff;
    border-bottom: 2px solid var(--tc-blue);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.auth-header .header-brand { text-decoration: none; }
.auth-header .header-logo { height: 50px; max-width: 340px; }

.auth-copyright {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 1;
}
.auth-copyright span {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
}

/* Auth page footer (minimal — hidden) */
.auth-footer {
    background: linear-gradient(135deg, #0d3b7a 0%, #1a56a8 40%, #2563eb 100%);
    padding: 14px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}
.auth-footer span,
.auth-footer a {
    font-size: 11.5px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
}
.auth-footer a:hover { color: #ffffff; }
.auth-footer .footer-sep { color: rgba(255,255,255,0.25); }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .header { padding: 0 16px; }
    .header-logo { height: 26px; max-width: 220px; }
    .header-nav-item { padding: 6px 8px; font-size: 12px; }
    .footer-main { flex-direction: column; gap: 20px; padding: 24px 20px 16px; }
    .footer-right { align-items: flex-start; }
}

@media (max-width: 768px) {
    .toolbar { padding: 8px 12px; }
    .schedule-table { font-size: 11px; }
    .stats-summary-row { grid-template-columns: repeat(2, 1fr); }
    .chart-row { grid-template-columns: 80px 1fr 40px 44px; gap: 8px; }
    .chart-row-label { font-size: 12px; }
    .chart-row-bar-wrap { height: 24px; }

    .header { height: 44px; padding: 0 12px; }
    .header-logo { height: 22px; max-width: 180px; }

    /* Nav -> drawer mở bằng hamburger (thay vì ẩn hẳn) */
    .header-burger { display: inline-flex; }
    .header-nav {
        display: none;
        position: absolute;
        top: 44px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        background: #fff;
        box-shadow: var(--shadow-lg);
        border-top: 1px solid var(--border);
        padding: 8px;
        max-height: calc(100vh - 44px);
        overflow-y: auto;
        z-index: 200;
    }
    .header-nav.open { display: flex; }
    .header-nav-item {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
        padding: 12px 14px;
        font-size: 15px;
        border-radius: 8px;
    }
    .header-nav-item::after { display: none; }
    .header-nav-sep { width: auto; height: 1px; margin: 6px 8px; background: #eef2f7; }
    /* Dropdown Midesk: hiển thị khối, submenu xổ ngay trong drawer */
    .header-nav-dd { display: block; width: 100%; }
    .header-nav-menu {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        padding: 0 0 4px 14px;
        min-width: 0;
    }
    .header-nav-dd.open .header-nav-menu { display: block; }
    .hn-menu-item { font-size: 14px; padding: 10px 14px; }

    .auth-container { flex-direction: column; min-height: auto; }
    .auth-left { padding: 28px 20px; }
    .auth-right { padding: 24px 20px; order: -1; }
    .auth-logo { max-width: 140px; }

    .auth-header { padding: 0 12px; height: 44px; }
    .auth-header .header-logo { height: 22px; max-width: 180px; }

    .footer-bottom { padding: 12px 16px; gap: 12px; }
    .auth-footer { padding: 12px 16px; }
}

@media (max-width: 480px) {
    .auth-bg { padding: 20px 12px; }
    .auth-left { padding: 24px 16px; }
    .auth-right { padding: 20px 16px; }
    .auth-form-wrapper h2 { font-size: 20px; }
    .header-logo { height: 20px; max-width: 160px; }
}

/* ══════════════════════════════════════════════
   CALENDAR — Notes & Expand/Collapse
   ══════════════════════════════════════════════ */
.cal-shift-hidden {
    display: none;
}
.cal-expand-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(59,130,246,0.06);
    border: 1px solid rgba(59,130,246,0.15);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.cal-expand-btn:hover {
    background: rgba(59,130,246,0.12);
}
.cal-note-text {
    font-size: 10px;
    color: #ffffff;
    font-style: italic;
    margin-left: 2px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
    animation: notePulse 2s ease-in-out infinite;
}

@keyframes notePulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
    50% { box-shadow: 0 0 0 4px rgba(245,158,11,0.1); }
}

/* ══════════════════════════════════════════════
   GLOBAL SMOOTH SELECTION
   ══════════════════════════════════════════════ */
::selection {
    background: rgba(26,86,168,0.2);
    color: inherit;
}

a { transition: color var(--transition-fast); }

.table-container {
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ══════════════════════════════════════════════
   DRAG & DROP — Row reorder
   ══════════════════════════════════════════════ */
.drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 13px;
    transition: color var(--transition-fast);
    user-select: none;
}
.drag-handle:hover {
    color: var(--tc-blue);
}
tr[draggable="true"] {
    transition: opacity var(--transition-fast), background var(--transition-fast);
}
tr.dragging {
    opacity: 0.4;
    background: rgba(59,130,246,0.05) !important;
}
tr.drag-over-top {
    box-shadow: inset 0 2px 0 0 var(--tc-blue);
}
tr.drag-over-bottom {
    box-shadow: inset 0 -2px 0 0 var(--tc-blue);
}
tr[draggable="true"]:active {
    cursor: grabbing;
}

/* ========== MIDESK TRACKING ========== */
.midesk-panel {
    padding: 24px 28px;
}

/* Header */
.midesk-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.midesk-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--tc-blue);
    margin: 0;
    letter-spacing: -0.3px;
}
.midesk-subtitle {
    font-size: 15px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}
.midesk-stat-badges {
    display: flex;
    gap: 8px;
}
.midesk-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
}
.badge-total {
    background: #dcfce7;
    color: #15803d;
}

/* Toolbar */
.midesk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.midesk-shift-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.midesk-shift-btn {
    padding: 8px 22px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}
.midesk-shift-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.6);
}
.midesk-shift-btn.active {
    background: var(--tc-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(26,86,168,0.25);
}
.midesk-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-sm {
    padding: 6px 16px !important;
    font-size: 13px !important;
    min-height: 34px;
    border-radius: 8px !important;
}
.midesk-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 16px;
}

/* Calendar grid */
.midesk-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 24px;
}
.midesk-cal-header {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.midesk-cal-header-weekend {
    color: var(--danger);
}
.midesk-cal-empty {
    min-height: 80px;
}
.midesk-cal-day {
    background: var(--bg-card);
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    min-height: 80px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
}
.midesk-cal-day:hover {
    border-color: var(--tc-blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.midesk-cal-day:active {
    transform: translateY(0);
}
.midesk-cal-day.weekend {
    background: #fff5f5;
    border-color: #fecaca;
}
.midesk-cal-day.has-data {
    border-color: #86efac;
    background: linear-gradient(to bottom, #f0fdf4, #ffffff);
}
.midesk-cal-day.has-data.weekend {
    background: linear-gradient(to bottom, #fefce8, #ffffff);
    border-color: #fcd34d;
}
.midesk-cal-day.selected {
    border-color: var(--tc-blue) !important;
    box-shadow: 0 0 0 3px rgba(26, 86, 168, 0.15), var(--shadow-md);
    background: linear-gradient(to bottom, #eff6ff, #ffffff) !important;
    transform: translateY(-2px);
}
.midesk-cal-day.today {
    box-shadow: inset 0 0 0 2px var(--tc-blue);
}
.midesk-cal-day.today .midesk-cal-num {
    color: #fff;
    background: var(--tc-blue);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.midesk-cal-day.today.selected {
    box-shadow: inset 0 0 0 2px var(--tc-blue), 0 0 0 3px rgba(26, 86, 168, 0.15), var(--shadow-md);
}
.midesk-cal-weekday {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.midesk-cal-day.weekend .midesk-cal-weekday {
    color: var(--danger);
}
.midesk-cal-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.midesk-cal-count {
    font-size: 12px;
    color: #16a34a;
    font-weight: 600;
    margin-top: 2px;
    background: #dcfce7;
    padding: 1px 8px;
    border-radius: 10px;
}
.midesk-cal-nodata {
    font-size: 13px;
    color: #cbd5e1;
    margin-top: 2px;
}

/* Detail view */
.midesk-detail {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-top: 8px;
    box-shadow: var(--shadow-md);
    animation: mideskSlideIn 0.25s ease-out;
}
@keyframes mideskSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.midesk-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
}
.midesk-detail-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.midesk-detail-icon {
    font-size: 22px;
    line-height: 1;
}
.midesk-detail-header h4 {
    font-size: 17px;
    font-weight: 700;
    color: var(--tc-blue);
    margin: 0;
}
.midesk-detail-count {
    font-size: 13px;
    font-weight: 600;
    color: #16a34a;
    background: #dcfce7;
    padding: 3px 12px;
    border-radius: 12px;
}
.midesk-detail-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
.midesk-no-data {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 15px;
}
.midesk-table {
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
}
.midesk-table td, .midesk-table th {
    padding: 10px 12px;
}
.midesk-table tbody tr {
    transition: background var(--transition-fast);
}
.midesk-table tbody tr:hover {
    background: #f8fafc;
}
.midesk-position {
    display: inline-block;
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    color: #0c4a6e;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.group-header-info {
    background: linear-gradient(135deg, #dbeafe, #e0f2fe) !important;
    color: #1e40af !important;
}
.group-header-warn {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    color: #991b1b !important;
}
.midesk-row-unassigned {
    opacity: 0.55;
    font-style: italic;
}
.midesk-row-unassigned .midesk-position {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #64748b;
}
.midesk-empty-section {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}
.midesk-empty-good {
    color: #16a34a;
    font-style: normal;
}
.midesk-sub-header td {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px !important;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════════
   MIDESK — Responsive
   ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .midesk-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .midesk-toolbar { flex-wrap: wrap; gap: 8px; }
    .midesk-toolbar-actions { flex-wrap: wrap; gap: 6px; }
    .midesk-calendar { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .midesk-cal-day { padding: 6px 4px; min-height: 70px; }
}
@media (max-width: 768px) {
    .midesk-panel { padding: 12px; }
    .midesk-calendar { gap: 3px; }
    .midesk-cal-day { padding: 4px 2px; min-height: 60px; border-radius: 6px; }
    .midesk-cal-num { font-size: 14px; }
    .midesk-cal-count { font-size: 9px; }
    .midesk-cal-header { font-size: 11px; padding: 4px 0; }
    .midesk-shift-toggle { width: 100%; }
    .midesk-shift-btn { flex: 1; }
    .midesk-detail { padding: 12px; }
    .midesk-detail-header { flex-direction: column; gap: 6px; }
    .midesk-table { font-size: 11px; }
    .midesk-table th, .midesk-table td { padding: 6px 4px; }
    .midesk-stat-badges { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .midesk-toolbar-actions { width: 100%; }
    .midesk-toolbar-actions .btn { flex: 1; font-size: 11px; padding: 6px 4px; }
    .midesk-cal-weekday { display: none; }
    .midesk-position { padding: 2px 6px; font-size: 11px; }
}

/* ══════════════════════════════════════════════
   MODAL — Close button & responsive
   ══════════════════════════════════════════════ */
.modal { position: relative; }
.modal-close {
    position: absolute; top: 16px; right: 16px; z-index: 10;
    background: none; border: none; font-size: 18px;
    color: var(--text-muted); cursor: pointer; line-height: 1;
    padding: 4px 6px; border-radius: 4px;
    transition: color var(--transition-fast), background var(--transition-fast);
}
.modal-close:hover { color: var(--danger); background: #fee2e2; }

/* ══════════════════════════════════════════════
   FOCUS-VISIBLE — Accessibility
   ══════════════════════════════════════════════ */
.btn:focus-visible,
.header-nav-item:focus-visible,
.midesk-shift-btn:focus-visible,
.cal-expand-btn:focus-visible,
.btn-logout:focus-visible,
.btn-auth:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ══════════════════════════════════════════════
   TABLE — Responsive max-height
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .table-container { max-height: calc(100vh - 180px); }
}
@media (max-width: 480px) {
    .table-container { max-height: calc(100vh - 150px); }
}

/* ══════════════════════════════════════════════
   GROUP HEADER — z-index fix for sticky overlap
   ══════════════════════════════════════════════ */
.group-header-row td {
    z-index: 6;
}

/* ══════════════════════════════════════════════
   LEAVE — Modal
   ══════════════════════════════════════════════ */
.leave-modal {
    width: min(1300px, 97vw) !important;
    max-height: 96vh;
    font-size: 15px;
}
.leave-modal-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.leave-modal-form {
    min-width: 0;
}
.leave-modal-history {
    display: flex;
    flex-direction: column;
}
.leave-section-title {
    font-size: 17px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 3px solid #cbd5e1;
}
.leave-tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-bottom: 2px solid #e2e8f0;
}
.leave-tab {
    flex: 1;
    padding: 13px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    margin-bottom: -2px;
    letter-spacing: 0.01em;
}
.leave-tab:hover {
    color: #334155;
    background: #fef2f2;
}
.leave-tab.active {
    color: #dc2626;
    border-bottom-color: #dc2626;
    background: #fef2f2;
}
.leave-history-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.leave-filter-input {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 15px;
    width: 220px;
    flex: 0 0 220px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.leave-filter-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.leave-filter-select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 15px;
    font-weight: 600;
    background: #fff;
    cursor: pointer;
    flex: 0 0 auto;
    width: auto;
    max-width: 220px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.leave-filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.leave-export-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(22,163,74,0.25);
}
.leave-export-btn:hover { background: linear-gradient(135deg, #15803d, #16a34a); box-shadow: 0 3px 10px rgba(22,163,74,0.35); }
.leave-filter-count {
    font-size: 14px;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
}
.leave-history-scroll {
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
}
.leave-history-empty {
    text-align: center;
    color: #64748b;
    font-size: 15px;
    padding: 48px 16px;
}
.leave-history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 15px;
}
.leave-history-table thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 800;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 14px 18px;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
    z-index: 1;
}
.leave-history-table tbody td {
    padding: 13px 18px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    line-height: 1.5;
}
.leave-history-table tbody tr:hover {
    background: #f0f5ff;
}
.leave-history-table tbody tr:nth-child(even) {
    background: #fafbfd;
}
.leave-history-table tbody tr:nth-child(even):hover {
    background: #f0f5ff;
}
.leave-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.leave-type-badge.lt-P { background: #facc15; color: #000; }
.leave-type-badge.lt-NKL { background: #f59e0b; color: #000; }
.leave-type-badge.lt-NO { background: #6d4c41; color: #fff; }
.leave-type-badge.lt-NS { background: #64748b; color: #fff; }
.leave-type-badge.lt-HC { background: #6b7280; color: #fff; }
.leave-type-badge.lt-HC_CT { background: #166534; color: #fff; }
.leave-type-badge.lt-DEM { background: #8b5cf6; color: #fff; }
.leave-type-badge.lt-KHAC { background: #94a3b8; color: #fff; }
.leave-type-badge.lt-CA1 { background: #3b82f6; color: #fff; }
.leave-type-badge.lt-CA2 { background: #f97316; color: #fff; }
.leave-type-badge.lt-K { background: #22c55e; color: #fff; }
.leave-type-badge.lt-D { background: #8b5cf6; color: #fff; }
.leave-type-badge.lt-HC_S { background: linear-gradient(135deg, #818cf8, #6366f1); color: #fff; }
.leave-type-badge.lt-HC_C { background: linear-gradient(135deg, #38bdf8, #0ea5e9); color: #fff; }
.leave-history-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 14px;
    margin-left: 8px;
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(220,38,38,0.25);
}
.leave-delete-btn {
    padding: 6px 16px;
    font-size: 14px;
    color: #dc2626;
    border: 2px solid #fca5a5;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s;
    white-space: nowrap;
}
.leave-delete-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
    box-shadow: 0 2px 6px rgba(220,38,38,0.12);
}
@media (max-width: 700px) {
    .leave-modal-form .leave-modal-body { display: flex; flex-direction: column; gap: 2px; }
    .leave-history-scroll { max-height: 280px; }
    .leave-history-toolbar { flex-direction: column; align-items: stretch; }
    .leave-export-btn { margin-left: 0; }
}
.leave-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--bg);
}
.leave-modal-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(220,38,38,0.25);
}
.leave-modal-header h3 {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.leave-modal-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin: 4px 0 0;
    line-height: 1.4;
}
.leave-modal-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.leave-modal-body label {
    font-weight: 700;
    font-size: 15px;
    color: #334155;
    margin-top: 10px;
}
.leave-modal-body input[type="text"],
.leave-modal-body input[type="date"],
.leave-modal-body select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.leave-modal-body input:focus,
.leave-modal-body select:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}
.leave-modal-body select#leaveEmployee {
    font-size: 15px;
    padding: 6px 10px;
}
#leaveType {
    font-size: 16px;
    font-weight: 600;
    padding: 11px 14px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    border-left: 5px solid #94a3b8;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
#leaveType:focus {
    box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
    border-color: #dc2626;
}
#leaveType.lt-clr-P { border-left-color: #f59e0b; background: #fffbeb; }
#leaveType.lt-clr-NO { border-left-color: #ec4899; background: #fdf2f8; }
#leaveType.lt-clr-NS { border-left-color: #10b981; background: #ecfdf5; }
#leaveType.lt-clr-NKL { border-left-color: #f97316; background: #fff7ed; }
#leaveType.lt-clr-CA1 { border-left-color: #3b82f6; background: #eff6ff; }
#leaveType.lt-clr-CA2 { border-left-color: #ea580c; background: #fff7ed; }
#leaveType.lt-clr-K { border-left-color: #d97706; background: #fffbeb; }
#leaveType.lt-clr-HC { border-left-color: #2563eb; background: #eff6ff; }
#leaveType.lt-clr-HC_CT { border-left-color: #166534; background: #f0fdf4; }
#leaveType.lt-clr-HC_S { border-left-color: #059669; background: #ecfdf5; }
#leaveType.lt-clr-HC_C { border-left-color: #16a34a; background: #f0fdf4; }
#leaveType.lt-clr-D { border-left-color: #7c3aed; background: #f5f3ff; }
#leaveType.lt-clr-KHAC { border-left-color: #64748b; background: #f8fafc; }
/* Custom leave-type dropdown */
.ltype-dropdown {
    position: relative;
}
.ltype-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-size: 15px;
}
.ltype-trigger:hover {
    border-color: #cbd5e1;
    background: #fafbfd;
}
.ltype-trigger.ltype-open {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}
.ltype-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ltype-label {
    flex: 1;
    font-weight: 600;
    color: #1e293b;
    font-size: 15px;
}
.ltype-arrow {
    color: #94a3b8;
    font-size: 16px;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.ltype-trigger.ltype-open .ltype-arrow {
    transform: rotate(180deg);
}
.ltype-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 10px 36px rgba(0,0,0,0.14);
    z-index: 120;
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 6px;
}
.ltype-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.1s;
}
.ltype-option:hover {
    background: #f1f5f9;
}
.ltype-option.ltype-active {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #bfdbfe;
}
.ltype-opt-text {
    font-size: 15px;
    font-weight: 600;
    color: #334155;
}
.ltype-option.ltype-active .ltype-opt-text {
    color: #1e40af;
    font-weight: 700;
}
.leave-date-row {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    align-items: flex-end;
}
.leave-cal-btn {
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 700;
    color: #1e40af;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 2px solid #93c5fd;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    margin-bottom: 1px;
    box-shadow: 0 2px 6px rgba(59,130,246,0.15);
}
.leave-cal-btn:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #60a5fa;
    box-shadow: 0 3px 10px rgba(59,130,246,0.25);
}
.lcal-popup {
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 14px;
    padding: 16px;
    margin-top: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}
.lcal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 17px;
    color: #1e293b;
}
.lcal-header button {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 15px;
    color: #475569;
    font-weight: 600;
    transition: all 0.1s;
}
.lcal-header button:hover { background: #e2e8f0; border-color: #cbd5e1; }
.lcal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.lcal-dn {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    padding: 6px 0;
    text-transform: uppercase;
}
.lcal-d {
    text-align: center;
    padding: 10px 2px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.1s;
    font-variant-numeric: tabular-nums;
}
.lcal-d:hover:not(.lcal-empty) { background: #f0f5ff; }
.lcal-empty { cursor: default; }
.lcal-today { font-weight: 800; box-shadow: inset 0 0 0 2px #3b82f6; }
.lcal-sel { background: #dbeafe; color: #1e40af; font-weight: 600; }
.lcal-start { background: #3b82f6 !important; color: #fff !important; font-weight: 700; border-radius: 8px 0 0 8px; }
.lcal-end { background: #3b82f6 !important; color: #fff !important; font-weight: 700; border-radius: 0 8px 8px 0; }
.lcal-hint {
    text-align: center;
    font-size: 13px;
    color: #64748b;
    margin-top: 10px;
    font-style: italic;
}
.leave-date-field {
    flex: 1;
}
.leave-date-field label {
    margin-top: 0 !important;
}

/* Accordion (admin grouped by employee) */
.leave-accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.leave-acc-group {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    border-left: 5px solid #3b82f6;
    transition: box-shadow 0.2s;
}
.leave-acc-group:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}
.leave-acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    background: #fff;
    transition: background 0.15s;
    gap: 14px;
    user-select: none;
}
.leave-acc-header:hover {
    background: #f8fafc;
}
.leave-acc-header.leave-acc-open {
    background: #f0f5ff;
    border-bottom: 1px solid #e2e8f0;
}
.leave-acc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.leave-acc-arrow {
    display: inline-block;
    font-size: 11px;
    color: #64748b;
    transition: transform 0.2s;
    width: 14px;
    text-align: center;
}
.leave-acc-name {
    font-weight: 800;
    font-size: 17px;
    color: #0f172a;
    white-space: nowrap;
}
.leave-acc-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 13px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(59,130,246,0.25);
}
.leave-acc-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.leave-acc-range {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.leave-acc-body {
    background: #fafbfd;
}
.leave-acc-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px 12px 46px;
    border-top: 1px solid #f1f5f9;
}
.leave-acc-row:hover {
    background: #f0f5ff;
}
.leave-acc-row-date {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 95px;
}
.leave-acc-row-note {
    flex: 1;
    font-size: 15px;
    color: #475569;
    min-width: 0;
}
/* Non-admin card list */
.leave-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.leave-card-item {
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
    background: #fff;
    transition: box-shadow 0.15s;
}
.leave-card-item:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.07);
}
.leave-card-item-main {
    display: flex;
    align-items: center;
    gap: 14px;
}
.leave-card-date {
    font-weight: 700;
    font-size: 16px;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}
.leave-card-note {
    margin-top: 8px;
    font-size: 14px;
    color: #475569;
    padding-left: 2px;
}
@media (max-width: 700px) {
    .leave-acc-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
    .leave-acc-row { padding-left: 14px; flex-wrap: wrap; gap: 8px; }
    .leave-acc-row-date { min-width: auto; }
}

/* ══════════════════════════════════════════════
   STAFFING CONFIG — Button, Modal & Table
   ══════════════════════════════════════════════ */
.staffing-modal {
    width: min(1180px, 96vw) !important;
}
.staffing-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--bg);
}
.staffing-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--tc-blue), #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(26,86,168,0.2);
}
.staffing-modal-desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
    line-height: 1.4;
}
.staffing-modal-body {
    overflow-x: auto;
    margin: 0 -4px;
    padding: 0 4px;
}

.staffing-cfg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 15px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.staffing-cfg-table thead th {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #fff;
    padding: 13px 16px;
    text-align: center;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--tc-blue);
}
.staffing-cfg-table thead th:first-child {
    text-align: left;
    min-width: 240px;
    padding-left: 16px;
}
.staffing-cfg-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
    vertical-align: middle;
}
.staffing-cfg-table tbody td:first-child {
    text-align: left;
    font-size: 15px;
    color: var(--text);
}
.staffing-cfg-table tbody tr:last-child td {
    border-bottom: none;
}
.staffing-cfg-table tbody tr:hover td {
    background: #f8fafc;
}

.staffing-section td {
    background: linear-gradient(90deg, var(--tc-blue), #2563eb) !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 16px !important;
    border-bottom: none !important;
}
.staffing-section:hover td {
    background: linear-gradient(90deg, var(--tc-blue), #2563eb) !important;
}
.staffing-hint td {
    background: #eff6ff !important;
    color: #475569;
    font-size: 12px;
    padding: 6px 16px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    line-height: 1.5;
}
.staffing-hint:hover td {
    background: #eff6ff !important;
}
.staffing-role-label {
    padding-left: 20px !important;
    font-weight: 500;
    position: relative;
}
.staffing-role-label::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--tc-blue);
}

.staffing-input {
    width: 74px;
    padding: 9px 6px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    background: #fff;
    color: var(--text);
    transition: all 0.15s ease;
}
.staffing-input:focus {
    outline: none;
    border-color: var(--tc-blue);
    box-shadow: 0 0 0 3px rgba(26,86,168,0.12);
    background: #f0f7ff;
}
.staffing-input:hover {
    border-color: #94a3b8;
}
.staffing-input::-webkit-inner-spin-button {
    opacity: 1;
}

/* ══════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════ */
@media print {
    .header, .toolbar, .legend, .loading, .toast, .modal-overlay { display: none !important; }
    .main-content { overflow: visible; }
    .table-container { max-height: none; overflow: visible; }
    .schedule-table { font-size: 9px; width: 100%; }
    .schedule-table th, .schedule-table td { padding: 2px 3px; }
    body { background: white; }
}

/* ===== PHÂN QUYỀN THEO TÀI KHOẢN (bổ sung) ===================================
   Bảng tick quyền trong modal "Phân quyền" + nhãn GỐC ở danh sách tài khoản.
   LƯU Ý: mọi luật ở đây phải có tiền tố .modal / .perm-matrix để THẮNG quy tắc
   `.modal label { display:block }` ở trên — nếu không, mỗi dòng quyền bị đổ về
   display:block, mất khoảng cách và chữ DÍNH LIỀN vào nhau. */
.user-root-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    font-size: 11px;
    letter-spacing: 0.4px;
}

.modal .perm-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin: 2px 0 14px;
    line-height: 1.55;
}

.modal .perm-matrix {
    max-height: 620px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.perm-matrix .perm-group + .perm-group {
    border-top: 2px solid var(--border);
}
.perm-matrix .perm-group-title {
    background: linear-gradient(90deg, var(--tc-blue), #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 10px 18px;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Dòng quyền: 1 hàng ngang [tick] [tên quyền] [nhãn] [mặc định] */
.modal .perm-matrix .perm-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 12px 18px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
}
.modal .perm-matrix .perm-row:last-child { border-bottom: none; }
.modal .perm-matrix .perm-row:hover { background: #f8fafc; }
.modal .perm-matrix .perm-row-locked { cursor: not-allowed; opacity: 0.6; }

.modal .perm-matrix .perm-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    cursor: inherit;
    accent-color: var(--tc-blue);
}
.perm-matrix .perm-name {
    flex: 1 1 auto;
    line-height: 1.4;
}

.perm-matrix .perm-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex: 0 0 auto;
}
.perm-matrix .perm-tag-diff { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.perm-matrix .perm-tag-root { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

.perm-matrix .perm-def {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 128px;
    text-align: right;
    flex: 0 0 auto;
}

@media (max-width: 720px) {
    .perm-matrix .perm-def { display: none; }
    .modal .perm-matrix .perm-row { font-size: 14px; padding: 10px 12px; }
}

/* ===== BẢNG TRONG CÁC MODAL CHỨC NĂNG CON ====================================
   Dùng chung cho: Quản lý tài khoản, Quản lý NV, Lịch sử thay đổi, Mồi dư/thiếu,
   Nhật ký ghi Midesk, Ghép nhân viên Midesk.
   Tách khỏi .schedule-table — lớp đó là LƯỚI PHÂN CA cả tháng nên cố tình dày đặc
   (font 12.5px, padding 4px); dùng lại cho bảng danh sách thì chữ quá nhỏ.
   LƯU Ý LỖI ĐÃ SỬA: cột thao tác từng đặt display:flex THẲNG lên ô <td> -> ô mất
   tư cách table-cell nên nút tràn ra ngoài và CHỒNG LÊN hàng dưới. Nay bọc trong
   <div class="user-actions">. */
.modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15.5px;
    color: #1e293b;
}
.modal-table th {
    background: #1e3a5f;
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 12px 14px;
    border: 1px solid #b0bec5;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 5;
}
.modal-table td {
    border: 1px solid #b0bec5;
    padding: 12px 14px;
    text-align: center;
    vertical-align: middle;
}
.modal-table tbody tr:hover td { background: #f8fafc; }
.modal-table .ut-left { text-align: left; }
.modal-table .ut-user { font-weight: 600; font-size: 16px; }
.modal-table .user-status-badge { font-size: 13px; padding: 4px 12px; }

/* Nút bên trong ô bảng: cỡ vừa phải, không cần style nội tuyến ở mỗi nút. */
.modal-table .btn {
    padding: 6px 14px;
    font-size: 13px;
    white-space: nowrap;
}
/* Ô nhập / danh sách chọn trong bảng: gọn lại so với form (mặc định .modal input
   là width:100% + padding 8px 12px, quá cồng kềnh khi nằm trong ô bảng). */
.modal-table select,
.modal-table input[type="text"],
.modal-table input[type="number"] {
    padding: 6px 10px;
    font-size: 14px;
}
.modal-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--tc-blue);
    cursor: pointer;
}

.user-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.user-actions .btn {
    padding: 6px 14px;
    font-size: 13px;
    white-space: nowrap;
}
.user-note-root {
    font-size: 12.5px;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .modal-table { font-size: 14px; }
    .modal-table td, .modal-table th { padding: 9px 8px; }
    .modal-table .btn, .user-actions .btn { padding: 5px 10px; font-size: 12px; }
}

/* ===== REPORT MODAL (kiểm tra kết quả phân ca) ===== */
.rpt-summary {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 15px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rpt-ok { background: #dcfce7; color: #166534; }
.rpt-warn { background: #fef3c7; color: #92400e; }
.rpt-icon { font-size: 20px; }
.rpt-section { margin-bottom: 18px; }
.rpt-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.rpt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.rpt-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.rpt-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.rpt-table tbody tr:hover { background: var(--bg); }

/* ============================================================
   BÁO CÁO "Kiểm tra kết quả phân ca"
   Dựng lại theo THỨ BẬC: kết luận -> số liệu -> việc cần làm ->
   bảng tra cứu (gấp lại). Bản trước mọi mục cùng cỡ chữ, cùng
   khung, xếp chồng ngang hàng nên nhìn rối.
   ============================================================ */
.rpt {
    font-size: 14px;
    line-height: 1.55;
    color: #1e293b;
    /* Chữ số dùng bảng đều để các cột số thẳng hàng khi đọc lướt. */
    font-variant-numeric: tabular-nums;
}
.rpt-loading { text-align: center; padding: 40px 24px; color: var(--text-muted); font-size: 14px; }

/* --- 1. Kết luận --- */
.rpt-hero { border-radius: 12px; padding: 16px 20px; margin-bottom: 18px; border-left: 5px solid; }
.rpt-hero-top { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.rpt-hero-sub { font-size: 14px; margin-top: 5px; opacity: 0.88; }
.rpt-hero-ok   { background: #f0fdf4; border-color: #16a34a; color: #14532d; }
.rpt-hero-act  { background: #eff6ff; border-color: #2563eb; color: #1e3a5f; }
.rpt-hero-warn { background: #fffbeb; border-color: #d97706; color: #78350f; }

/* --- 2. Bốn ô số liệu --- */
.rpt-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
@media (max-width: 640px) { .rpt-stats { grid-template-columns: repeat(2, 1fr); } }
.rpt-stat {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.rpt-stat-num { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; color: #0f172a; }
.rpt-stat-lab { font-size: 11.5px; color: #64748b; text-transform: uppercase; letter-spacing: 0.4px; }
.rpt-stat-lab i { font-style: normal; text-transform: none; letter-spacing: 0; font-size: 11px; opacity: 0.85; }
.rpt-stat.is-ok  { background: #f0fdf4; border-color: #bbf7d0; }
.rpt-stat.is-ok  .rpt-stat-num { color: #15803d; }
.rpt-stat.is-bad { background: #fef2f2; border-color: #fecaca; }
.rpt-stat.is-bad .rpt-stat-num { color: #b91c1c; }

/* --- 3. Lời khuyên --- */
.rpt-advice { margin-bottom: 20px; }
.rpt-advice-row {
    background: #fffbeb; border-left: 3px solid #f59e0b; border-radius: 0 6px 6px 0;
    padding: 9px 13px; margin-bottom: 7px; font-size: 13.5px; color: #78350f;
}
.rpt-advice-row b { font-weight: 700; }

/* --- 4. Gợi ý từng ngày --- */
.rpt-h {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
    color: #94a3b8; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0;
}
.gy-ngay { margin-bottom: 16px; }
.gy-tieude { font-size: 14.5px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.gy-tieude span { font-weight: 500; color: #94a3b8; font-size: 12.5px; margin-left: 4px; }
.gy-muc { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 5px; font-size: 13px; }
.gy-vai { font-weight: 600; color: #334155; }
.gy-sl { color: #64748b; font-size: 12.5px; }
.gy-thieu { color: #dc2626; font-weight: 700; font-size: 12.5px; }
.gy-hd {
    background: #f0fdf4; border-left: 3px solid #22c55e; border-radius: 0 6px 6px 0;
    padding: 8px 12px; margin: 5px 0; font-size: 13.5px; color: #14532d;
}
/* Làm được nhưng có hệ quả -> vàng, không phải xanh */
.gy-hd.is-warn { background: #fffbeb; border-left-color: #f59e0b; color: #78350f; }
/* Không cách nào lấp -> xám, không doạ người đọc bằng màu đỏ */
.gy-hd.is-none { background: #f8fafc; border-left-color: #cbd5e1; color: #64748b; font-style: italic; }

.gy-chan { margin: 6px 0 0; font-size: 12.5px; }
.gy-chan summary {
    cursor: pointer; color: #64748b; user-select: none; padding: 3px 0;
    list-style: none; display: inline-flex; align-items: center; gap: 5px;
}
.gy-chan summary::-webkit-details-marker { display: none; }
.gy-chan summary::before { content: "▸"; font-size: 10px; transition: transform .15s; }
.gy-chan[open] summary::before { transform: rotate(90deg); }
.gy-chan summary:hover { color: #2563eb; }
.gy-chan-body { padding: 6px 0 2px 14px; border-left: 2px solid #f1f5f9; margin-top: 4px; }
.gy-chan-row { margin-bottom: 7px; }
.gy-chan-row b { display: block; color: #475569; font-weight: 600; font-size: 12.5px; }
.gy-chan-row span { display: block; color: #94a3b8; font-size: 12px; padding-left: 10px; }

/* --- 5-6. Bảng tra cứu gấp lại --- */
.rpt-fold { border-top: 1px solid #e2e8f0; padding-top: 12px; margin-top: 18px; }
.rpt-fold summary {
    cursor: pointer; user-select: none; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px; color: #64748b;
    list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.rpt-fold summary::-webkit-details-marker { display: none; }
.rpt-fold summary::before { content: "▸"; font-size: 10px; transition: transform .15s; }
.rpt-fold[open] summary::before { transform: rotate(90deg); }
.rpt-fold summary:hover { color: #2563eb; }
.rpt-fold-body { padding-top: 12px; }
.rpt .rpt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rpt .rpt-table th {
    background: #f8fafc; font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.3px; color: #64748b; padding: 7px 9px; text-align: center;
    border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
.rpt .rpt-table td { padding: 6px 9px; border-bottom: 1px solid #f1f5f9; text-align: center; }
.rpt .rpt-table td.l, .rpt .rpt-table th.l { text-align: left; }
.rpt .rpt-table td.r { color: #dc2626; font-weight: 700; }
.rpt .rpt-table td.g { color: #16a34a; font-weight: 700; }
.rpt .rpt-table td.o { color: #d97706; font-weight: 700; }
.rpt .rpt-table i.r { color: #dc2626; font-size: 11px; font-style: normal; }
.rpt .rpt-table tbody tr:hover { background: #f8fafc; }

/* Hộp thoại báo cáo: rộng và cao hơn hẳn. Bản trước 1100px + trần 60vh nên
   bảng bị ép nhỏ, phải cuộn trong một khung con — theo dõi rất khó. */
.modal-rpt #reportContent { max-height: 78vh; overflow-y: auto; padding-right: 6px; }
.modal-rpt h3 { font-size: 20px; margin-bottom: 14px; }

/* Cỡ chữ toàn báo cáo tăng một nấc so với bản trước */
.rpt { font-size: 15px; }
.rpt-hero-top { font-size: 21px; }
.rpt-hero-sub { font-size: 15px; }
.rpt-stat { padding: 14px 16px; }
.rpt-stat-num { font-size: 30px; }
.rpt-stat-lab { font-size: 12.5px; }
.rpt-stat-lab i { font-size: 12px; }
.rpt-advice-row { font-size: 14.5px; padding: 11px 15px; }
.rpt-h { font-size: 13px; }
.gy-tieude { font-size: 16px; }
.gy-tieude span { font-size: 13.5px; }
.gy-muc { font-size: 14px; }
.gy-sl, .gy-thieu { font-size: 13.5px; }
.gy-hd { font-size: 14.5px; padding: 9px 14px; }
.gy-chan, .gy-chan summary { font-size: 13.5px; }
.gy-chan-row b { font-size: 13.5px; }
.gy-chan-row span { font-size: 13px; }
.rpt-fold summary { font-size: 13px; }
.rpt .rpt-table { font-size: 14px; }
.rpt .rpt-table th { font-size: 12px; padding: 9px 11px; }
.rpt .rpt-table td { padding: 8px 11px; }

/* Cảnh báo thành nhãn nhỏ bên phải, không nối vào cuối câu cho dài ra */
.gy-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gy-tag {
    flex: 0 0 auto; font-size: 12px; font-weight: 600; padding: 2px 9px;
    border-radius: 999px; background: #fef3c7; color: #92400e; white-space: nowrap;
}
/* Lý do chặn: xếp ngang, gọn, không xuống dòng lê thê */
.gy-chan-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; }
.gy-chan-row b { display: inline; min-width: 150px; }
.gy-chan-row span { display: inline; padding-left: 0; }
.gy-chan-row span::before { content: "·"; margin-right: 6px; color: #cbd5e1; }

/* ------------------------------------------------------------------
   Hộp thoại BÁO CÁO: gần như toàn màn hình.
   Lớp .modal nền có max-width:90vw và max-height:80vh — hai trần này
   GHI ĐÈ mọi chiều rộng đặt nội tuyến, nên bảng luôn bị bó nhỏ dù đã
   nới. Phải ghi đè hẳn ở đây thì mới thật sự rộng ra.
   ------------------------------------------------------------------ */
.modal.modal-rpt {
    width: min(1900px, 98vw);
    max-width: 98vw;
    max-height: 96vh;
    padding: 22px 26px;
    overflow: hidden;                 /* cuộn ở #reportContent, không cuộn hai lớp */
    display: flex;
    flex-direction: column;
}
.modal.modal-rpt h3 { font-size: 22px; margin: 0 0 14px; flex: 0 0 auto; }
.modal.modal-rpt #reportContent {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    padding-right: 10px;
}
.modal.modal-rpt .modal-actions { flex: 0 0 auto; margin-top: 14px; }

/* Cỡ chữ tăng thêm một nấc nữa cho dễ theo dõi */
.rpt { font-size: 16px; line-height: 1.6; }
.rpt-hero { padding: 18px 24px; }
.rpt-hero-top { font-size: 24px; }
.rpt-hero-sub { font-size: 16px; }
.rpt-stats { gap: 14px; }
.rpt-stat { padding: 16px 20px; }
.rpt-stat-num { font-size: 36px; }
.rpt-stat-lab { font-size: 13px; }
.rpt-stat-lab i { font-size: 12.5px; }
.rpt-advice-row { font-size: 15.5px; padding: 13px 18px; }
.rpt-h { font-size: 14px; }
.gy-tieude { font-size: 18px; }
.gy-tieude span { font-size: 14.5px; }
.gy-muc { font-size: 15px; }
.gy-sl, .gy-thieu { font-size: 14.5px; }
.gy-hd { font-size: 15.5px; padding: 11px 18px; }
.gy-tag { font-size: 13px; padding: 3px 11px; }
.gy-chan, .gy-chan summary { font-size: 14.5px; }
.gy-chan-row b { font-size: 14.5px; min-width: 200px; }
.gy-chan-row span { font-size: 14px; }
.rpt-fold summary { font-size: 14px; }
.rpt .rpt-table { font-size: 15px; }
.rpt .rpt-table th { font-size: 13px; padding: 11px 14px; }
.rpt .rpt-table td { padding: 10px 14px; }

/* Màn hình nhỏ thì trả về cỡ vừa, không để tràn */
@media (max-width: 900px) {
    .modal.modal-rpt { width: 98vw; padding: 16px; }
    .rpt { font-size: 14.5px; }
    .rpt-stat-num { font-size: 28px; }
    .rpt-hero-top { font-size: 19px; }
}

/* ------------------------------------------------------------------
   Cỡ chữ tương xứng với hộp thoại đã nới lên 1900px.
   Hộp rộng gần hết màn hình mà chữ vẫn 15-16px thì nhìn loãng và vẫn
   khó theo dõi — chữ phải to lên theo.
   ------------------------------------------------------------------ */
.rpt { font-size: 18px; line-height: 1.65; }

.rpt-hero { padding: 22px 28px; border-left-width: 6px; border-radius: 14px; }
.rpt-hero-top { font-size: 28px; }
.rpt-hero-sub { font-size: 18px; margin-top: 7px; }

.rpt-stat { padding: 18px 22px; border-radius: 12px; }
.rpt-stat-num { font-size: 44px; line-height: 1.1; }
.rpt-stat-lab { font-size: 14px; }
.rpt-stat-lab i { font-size: 13.5px; }

.rpt-advice-row { font-size: 17px; padding: 15px 20px; border-left-width: 4px; }

.rpt-h { font-size: 15px; margin-bottom: 14px; padding-bottom: 8px; }
.gy-ngay { margin-bottom: 22px; }
.gy-tieude { font-size: 20px; margin-bottom: 8px; }
.gy-tieude span { font-size: 16px; }
.gy-muc { font-size: 17px; margin: 12px 0 7px; }
.gy-sl, .gy-thieu { font-size: 16px; }
.gy-hd { font-size: 17px; padding: 13px 20px; border-left-width: 4px; margin: 7px 0; }
.gy-tag { font-size: 14px; padding: 4px 13px; }
.gy-chan { font-size: 16px; margin-top: 8px; }
.gy-chan summary { font-size: 16px; padding: 5px 0; }
.gy-chan-body { padding: 8px 0 4px 18px; }
.gy-chan-row { font-size: 16px; margin-bottom: 8px; }
.gy-chan-row b { font-size: 16px; min-width: 230px; }
.gy-chan-row span { font-size: 15.5px; }

.rpt-fold { padding-top: 16px; margin-top: 24px; }
.rpt-fold summary { font-size: 15px; }
.rpt .rpt-table { font-size: 17px; }
.rpt .rpt-table th { font-size: 14px; padding: 13px 16px; }
.rpt .rpt-table td { padding: 12px 16px; }

@media (max-width: 900px) {
    .rpt { font-size: 15px; }
    .rpt-hero-top { font-size: 20px; }
    .rpt-hero-sub { font-size: 15px; }
    .rpt-stat-num { font-size: 30px; }
    .rpt .rpt-table { font-size: 14px; }
    .rpt .rpt-table th { font-size: 12px; padding: 8px 10px; }
    .rpt .rpt-table td { padding: 8px 10px; }
    .gy-hd, .gy-muc, .gy-chan-row { font-size: 14.5px; }
    .gy-tieude { font-size: 16px; }
    .gy-chan-row b { min-width: 150px; }
}

/* N = nghỉ CÓ LÀM BÙ ngày khác. Vàng NHẠT + viền đứt để phân biệt ngay với
   P (vàng đậm): cùng họ "nghỉ" nhưng N KHÔNG trừ công chuẩn. */
.shift-N { background: #fef3c7; color: #92400e; border: 1px dashed #d97706; }
.shift-N:hover { box-shadow: 0 2px 8px rgba(217,119,6,0.35); }
