/* ============================================================================
 * MOBILE RESPONSIVE — Giao diện di động cho toàn bộ ứng dụng.
 * File NÀY chỉ THÊM responsive overrides, KHÔNG GHI ĐÈ bất kỳ style desktop nào
 * khi chạy trên màn hình lớn. Mọi rule nằm trong @media queries.
 * Prefix: .mob- cho các class JS tạo ra (bottom nav, mobile header).
 * ========================================================================== */

/* ========================================
   BIẾN CSS — Mobile
   ======================================== */
:root {
    --mob-nav-h: 60px;         /* chiều cao bottom nav */
    --mob-header-h: 52px;      /* chiều cao mobile header */
    --mob-radius: 14px;
    --mob-blue: #1a56a8;
    --mob-safe-b: env(safe-area-inset-bottom, 0px);
}

/* ========================================
   TABLET: 768px trở xuống
   ======================================== */
@media (max-width: 768px) {

    /* --- Body: để lại chỗ cho bottom nav --- */
    body:not(.auth-page) {
        padding-bottom: calc(var(--mob-nav-h) + var(--mob-safe-b));
    }

    /* --- HEADER: gọn lại nhưng logo vẫn rõ --- */
    .header {
        height: var(--mob-header-h);
        padding: 0 12px;
        gap: 8px;
    }
    .header-logo {
        height: 42px;
        width: auto;
        max-width: 42px;
        object-fit: contain;
    }
    /* Ẩn phần user info (tên, avatar) trên mobile — giữ nút đăng xuất */
    .header-user-name { display: none; }
    .header-user-avatar { width: 28px; height: 28px; font-size: 12px; }
    .header-status { display: none; }
    .btn-logout { font-size: 12px; padding: 5px 10px; }

    /* --- Desktop nav: ẩn trên mobile, dùng bottom nav thay thế --- */
    .header-nav {
        top: var(--mob-header-h) !important;
        max-height: calc(100vh - var(--mob-header-h)) !important;
        max-height: calc(100dvh - var(--mob-header-h)) !important;
    }

    /* --- TOOLBAR (phân ca): 1 dòng Tháng/Năm + nút Thao tác --- */
    .toolbar {
        padding: 8px 10px;
        gap: 6px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        white-space: nowrap;
    }
    .toolbar .toolbar-label {
        font-size: 12px;
        font-weight: 600;
    }
    .toolbar select {
        font-size: 13px;
        padding: 6px 8px;
        border-radius: 6px;
        min-height: 34px;
        width: auto;
        flex: 0 0 auto;
    }
    /* Ẩn toàn bộ nút chức năng — hiện qua dropdown */
    .toolbar .btn {
        display: none;
    }
    /* Toggle button (JS tạo) */
    .mob-toolbar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin-left: auto;
        padding: 7px 12px;
        font-size: 12px;
        font-weight: 600;
        color: #fff;
        background: var(--mob-blue, #1a56a8);
        border: none;
        border-radius: 6px;
        cursor: pointer;
        min-height: 34px;
    }
    .mob-toolbar-toggle svg {
        width: 14px;
        height: 14px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        transition: transform .2s;
    }
    .mob-toolbar-toggle.open svg {
        transform: rotate(180deg);
    }
    /* Panel dropdown chứa các nút */
    .mob-toolbar-panel {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 4px;
        padding: 6px 0 2px;
        order: 99;
    }
    .mob-toolbar-panel.open {
        display: flex;
    }
    .mob-toolbar-panel .btn {
        display: block !important;
        padding: 10px 10px;
        font-size: 12.5px;
        border-radius: 8px;
        min-height: 40px;
        text-align: center;
        white-space: normal;
        line-height: 1.3;
        width: 100%;
    }

    /* --- MAIN CONTENT: full height trừ header + bottom nav --- */
    .main-content {
        height: calc(100dvh - var(--mob-header-h) - var(--mob-nav-h) - var(--mob-safe-b));
        min-height: 0;
    }

    /* --- BẢNG PHÂN CA: ultra-compact, bao quát tối đa --- */
    .table-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    .schedule-table {
        font-size: 7px;
    }
    .schedule-table th,
    .schedule-table td {
        padding: 1px 1px;
        min-width: 16px;
    }
    .schedule-table td {
        height: 18px;
        min-width: 16px;
    }
    /* STT: ultra-compact */
    .schedule-table th.col-stt-header,
    .schedule-table td.col-stt {
        width: 14px;
        min-width: 14px;
        font-size: 6px;
    }
    /* Tên NV: gọn tối đa */
    .schedule-table th.col-name,
    .schedule-table td.col-name {
        min-width: 70px;
        max-width: 85px;
        font-size: 7px;
        padding-left: 2px;
        left: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Nhóm (cột 3): thu gọn tối đa */
    .schedule-table thead th:nth-child(3),
    .schedule-table tbody tr:not(.group-header-row) td:nth-child(3) {
        font-size: 6px;
        min-width: 14px;
        max-width: 20px;
        padding: 0 1px;
    }
    /* Shift cells: nhỏ nhất có thể */
    .shift-cell {
        font-size: 6px;
        padding: 1px 1px;
        border-radius: 2px;
        min-width: 14px;
    }
    /* Thống kê cuối bảng */
    .schedule-table td.col-stats {
        font-size: 6px;
        min-width: 16px;
    }
    /* Header ngày: gọn */
    .schedule-table thead th {
        font-size: 7px;
        padding: 2px 1px;
        line-height: 1.1;
    }
    /* Section headers (TRƯỞNG CA, GDV, Tổ 1...) */
    .schedule-table .group-header td {
        font-size: 8px;
        padding: 2px 4px;
    }

    /* --- LEGEND (chú thích): ẩn mặc định trên mobile, show khi cần --- */
    .legend {
        display: none;
        position: fixed;
        bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 8px);
        left: 8px;
        right: 8px;
        z-index: 150;
        background: #fff;
        border-radius: var(--mob-radius);
        box-shadow: 0 -4px 24px rgba(0,0,0,.15);
        padding: 14px;
        max-height: 50vh;
        overflow-y: auto;
    }
    .legend.mob-show { display: flex; }

    /* --- MODAL: full-screen trên mobile --- */
    .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        height: 100dvh;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    /* --- TOAST: nằm giữa, trên bottom nav --- */
    .toast {
        bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 12px);
        left: 16px;
        right: 16px;
        width: auto;
    }

    /* --- LOADING: z-index trên bottom nav --- */
    .loading { z-index: 3500; }

    /* --- FOOTER: ẩn trên mobile (thông tin trong Settings/About) --- */
    .footer { display: none; }
}

/* ========================================
   PHONE: 480px trở xuống
   ======================================== */
@media (max-width: 480px) {
    .header {
        padding: 0 8px;
    }
    .header-logo {
        height: 36px;
        max-width: 36px;
    }
    .header-user-avatar { width: 24px; height: 24px; font-size: 11px; }
    .btn-logout { font-size: 11px; padding: 4px 8px; }

    /* Toolbar: panel buttons nhỏ hơn */
    .mob-toolbar-panel .btn {
        padding: 8px 6px;
        font-size: 11px;
    }

    /* Bảng phân ca: micro-compact trên phone nhỏ */
    .schedule-table { font-size: 6px; }
    .schedule-table th,
    .schedule-table td { padding: 1px 0; min-width: 14px; }
    .schedule-table td { height: 16px; }
    .schedule-table td.col-name,
    .schedule-table th.col-name {
        min-width: 60px;
        max-width: 75px;
        font-size: 6px;
    }
    .shift-cell {
        font-size: 5.5px;
        padding: 0 1px;
        min-width: 12px;
        border-radius: 1px;
    }
}

/* ========================================
   MODULE CÔNG VIỆC — Mobile overrides
   ======================================== */
@media (max-width: 768px) {
    /* Topbar: stack + cuộn */
    .cv-topbar {
        gap: 8px;
        padding: 10px 4px;
        margin: -4px -4px 10px;
    }
    .cv-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
    }
    .cv-tab {
        padding: 7px 11px;
        font-size: 12.5px;
        flex-shrink: 0;
    }
    .cv-actions {
        width: 100%;
        gap: 6px;
    }
    .cv-search {
        min-width: 0;
        flex: 1;
        font-size: 14px;
        padding: 10px 12px;
    }
    .cv-select-sm {
        font-size: 13px;
        padding: 10px 10px;
    }

    /* Box chips (Hộp thư): cuộn ngang */
    .cv-boxchips {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        padding-bottom: 4px;
    }
    .cv-boxchip {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Danh sách thẻ: nhỏ gọn hơn */
    .cv { padding: 8px 10px 24px; }
    .cv-card {
        padding: 12px;
        border-radius: 12px;
    }
    .cv-card-title {
        font-size: 14px;
        line-height: 1.4;
    }

    /* Layout 2 cột → 1 cột */
    .cv-layout {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
    }
    .cv-side {
        position: static !important;
        max-height: none !important;
        padding: 6px !important;
        overflow: visible !important;
    }
    .cv-side-me { display: none; }
    .cv-side .cv-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    /* DRAWER chi tiết: full-screen trên mobile */
    .cv-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
    }
    .cv-drawer-head {
        padding: 14px 16px 0;
    }
    .cv-drawer-head .cv-detail-title {
        font-size: 17px;
    }
    .cv-drawer-body {
        padding: 14px 16px 20px;
    }
    .cv-drawer-foot {
        padding: 10px 16px;
        padding-bottom: calc(10px + var(--mob-safe-b));
    }

    /* Tab bar trong drawer: nhỏ hơn */
    .cv-tabbar-main .cv-subtab {
        font-size: 13px;
        padding: 9px 14px;
    }

    /* Actions trên đầu drawer */
    .cv-head-acts {
        gap: 6px;
    }
    .cv-head-main {
        font-size: 13px;
        padding: 9px 16px;
    }
    .cv-head-menu-btn {
        width: 36px;
        height: 36px;
    }

    /* Lưới thông tin chi tiết */
    .cv-fact-grid {
        grid-template-columns: 1fr;
    }
    .cv-fact {
        padding: 10px 14px;
    }

    /* Bảng phân công (Dispatch) */
    .cv-dsp-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px;
        padding: 10px;
    }
    .cv-dsp-4col .cv-dsp-row,
    .cv-dsp-5col .cv-dsp-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    /* Thông tin gửi nhận */
    .cv-io-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        padding: 10px 12px;
    }

    /* Quá trình xử lý: compact */
    .cv-flow-block {
        padding: 14px 12px 14px 20px;
    }
    .cv-fb-grid {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .cv-fb-chips {
        gap: 5px;
    }
    .cv-chip-person {
        font-size: 12.5px;
    }

    /* Modal công việc: full-screen */
    .cv-modal-overlay .cv-modal {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    /* Form công việc */
    .cv-form-row {
        grid-template-columns: 1fr;
    }

    /* Thanh toolbar công việc */
    .cv-toolbar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    .cv-toolbar-tools {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .cv-toolbar-side {
        width: 100%;
        gap: 6px;
    }
    .cv-searchbox {
        max-width: none;
        flex-basis: 100%;
    }

    /* Danh sách công việc: card layout */
    .cv-row.cv-row-head { display: none; }
    .cv-row {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 8px !important;
        padding: 12px !important;
    }
    .cv-row-main { grid-area: unset; }
    .cv-row-due { grid-area: unset; }
    .cv-row-prog { grid-area: unset; }
    .cv-row-quick { grid-area: unset; justify-content: flex-start; }
}

/* ========================================
   MODULE SCORECARD — Mobile overrides
   ======================================== */
@media (max-width: 768px) {
    /* Sub-tab switcher */
    #scSubTabs {
        padding: 0 10px !important;
    }
    .sc-sub-tab {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }

    /* Scorecard page */
    .sc-page { padding: 0; }
    .sc-top {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }
    .sc-logo { font-size: 14px; }
    .sc-select { font-size: 12px; padding: 6px 8px; }
    .sc-btn-sm { font-size: 12px; padding: 6px 10px; }

    /* Scorecard grid */
    .sc-grid {
        grid-template-columns: 1fr !important;
    }

    /* Scorecard info/legend box: cuộn ngang nếu quá rộng */
    .sc-info, .sc-legend-box, .sc-summary {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .sc-page table {
        font-size: 11px;
    }
    .sc-page table th,
    .sc-page table td {
        padding: 6px 8px;
        white-space: nowrap;
    }
    .sc-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
}

/* ========================================
   MODULE 3CX / USER ACTIVITY — Mobile overrides
   ======================================== */
@media (max-width: 768px) {
    .tcx { padding: 8px 10px 24px; }

    /* Bộ lọc: stack lại */
    .tcx-filters { padding: 12px; border-radius: 12px; }
    .tcx-filters-row { gap: 8px; }
    .tcx-field { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .tcx-field-grow { flex: 1 1 100%; }
    .tcx-field input, .tcx-field select {
        padding: 10px 10px;
        font-size: 14px; /* input 16px tránh zoom trên iOS */
    }
    .tcx-field-actions { margin-left: 0; width: 100%; }
    .tcx-field-actions .btn { flex: 1; }

    /* KPI: 2 cột trên tablet */
    .tcx-kpis {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .tcx-kpi { padding: 12px 14px; gap: 10px; }
    .tcx-kpi-ico { width: 38px; height: 38px; }
    .tcx-kpi-val { font-size: 20px; }

    /* Bảng: cuộn ngang */
    .tcx-table-wrap {
        border-radius: 8px;
    }
    .tcx-card { border-radius: 12px; margin-top: 12px; }

    /* Quick range: cuộn ngang */
    .tcx-quickrange {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .tcx-chip { flex-shrink: 0; }

    /* User Activity bộ lọc */
    .uaf { border-radius: 12px; }
    .uaf-grid { gap: 8px; }
    .uaf-field { min-width: 0; }
    .uaf-grow { flex-basis: 100%; }
    .uaf-foot { flex-direction: column; gap: 8px; align-items: stretch; }
    .uaf-actions { width: 100%; }
    .uaf-actions .btn { flex: 1; }
}

@media (max-width: 480px) {
    /* KPI: 1 cột trên phone */
    .tcx-kpis {
        grid-template-columns: 1fr;
    }
    .tcx-kpi-val { font-size: 24px; }
}

/* ========================================
   MODULE MIDESK — Mobile overrides
   ======================================== */
@media (max-width: 768px) {
    .midesk-panel {
        padding: 10px;
    }
    .midesk-toolbar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    .midesk-toolbar-actions {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    .midesk-toolbar-actions .btn {
        flex: 1;
        min-width: 0;
    }

    /* Bảng Midesk: cuộn ngang */
    .midesk-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Midesk edit mode */
    .midesk-edit-topbar {
        padding: 12px 2px 10px;
    }
    .midesk-edit-topbar-row {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .midesk-edit-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .midesk-assign-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .midesk-checklist {
        grid-template-columns: 1fr;
        max-height: 200px;
    }
    .midesk-vio-row2 {
        grid-template-columns: 1fr;
    }

    /* Accordion */
    .midesk-acc-head { padding: 12px 14px; gap: 10px; }
    .midesk-acc-icon { width: 32px; height: 32px; font-size: 16px; }
    .midesk-acc-body-inner { padding: 0 14px; }
    .midesk-acc-item.open .midesk-acc-body-inner { padding: 14px; }
}

/* ========================================
   MODULE MULTICHANNEL — Mobile overrides
   ======================================== */
@media (max-width: 768px) {
    #scSubViewMc {
        border-radius: 0 !important;
    }
    #mcRoot {
        font-size: 13px;
    }
}

/* ========================================
   LOGIN PAGE — Mobile: form hiện đầu tiên
   ======================================== */
@media (max-width: 768px) {
    .auth-bg {
        padding: 16px 12px;
        align-items: flex-start;
    }
    .auth-container {
        flex-direction: column;
        min-height: auto;
        border-radius: 16px;
    }
    /* FORM lên đầu */
    .auth-left {
        padding: 28px 20px;
        order: -1;
    }
    /* BRANDING xuống sau, gọn lại */
    .auth-right {
        padding: 20px 16px;
        order: 0;
    }
    .auth-logo-wide {
        max-width: 240px;
        margin-bottom: 12px;
    }
    /* Ẩn Tầm nhìn/Sứ mệnh trên mobile — không cần thiết cho đăng nhập */
    .auth-mission {
        display: none;
    }
    .auth-form-wrapper {
        max-width: 100%;
    }
    .auth-form-wrapper h2 {
        font-size: 24px;
        margin-bottom: 4px;
    }
    .auth-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
    .auth-form-wrapper form .form-group label {
        font-size: 13px;
    }
    .auth-form-wrapper form input[type="text"],
    .auth-form-wrapper form input[type="password"] {
        padding: 14px 14px;
        font-size: 16px;
        border-radius: 10px;
    }
    .btn-auth {
        padding: 14px;
        font-size: 16px;
        border-radius: 10px;
    }
    .auth-copyright {
        font-size: 11px;
    }
}

/* ========================================
   BOTTOM NAVIGATION BAR
   ======================================== */
.mob-bottom-nav,
.mob-more-menu,
.mob-more-backdrop {
    display: none; /* ẩn mặc định trên desktop */
}

@media (max-width: 768px) {
    .mob-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 500;
        height: calc(var(--mob-nav-h) + var(--mob-safe-b));
        padding-bottom: var(--mob-safe-b);
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -2px 12px rgba(0,0,0,.08);
        align-items: stretch;
        justify-content: space-around;
    }

    .mob-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        appearance: none;
        border: none;
        background: none;
        color: #64748b;
        font-family: inherit;
        font-size: 10px;
        font-weight: 600;
        cursor: pointer;
        padding: 6px 2px;
        transition: color .15s;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }
    .mob-nav-item:active {
        background: rgba(26, 86, 168, .06);
    }
    .mob-nav-item.active {
        color: var(--mob-blue);
    }
    .mob-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2.5px;
        background: var(--mob-blue);
        border-radius: 0 0 2px 2px;
    }

    .mob-nav-icon {
        width: 22px;
        height: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }
    .mob-nav-icon svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mob-nav-label {
        display: block;
        line-height: 1;
        letter-spacing: .02em;
    }

    /* Badge trên icon */
    .mob-nav-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        background: #ef4444;
        color: #fff;
        border-radius: 999px;
        font-size: 10px;
        font-weight: 800;
        display: none;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
    .mob-nav-badge.show {
        display: inline-flex;
    }

    /* More menu (dropdown lên trên) */
    .mob-more-menu {
        display: none;
        position: fixed;
        bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 4px);
        right: 8px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: var(--mob-radius);
        box-shadow: 0 -4px 24px rgba(0,0,0,.14);
        padding: 6px;
        z-index: 501;
        min-width: 200px;
    }
    .mob-more-menu.open {
        display: block;
        animation: mob-slide-up .2s cubic-bezier(.22, .61, .36, 1) both;
    }
    @keyframes mob-slide-up {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .mob-more-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 11px 14px;
        border: none;
        background: none;
        font-family: inherit;
        font-size: 14px;
        font-weight: 600;
        color: #334155;
        cursor: pointer;
        border-radius: 9px;
        text-align: left;
    }
    .mob-more-item:hover,
    .mob-more-item:active {
        background: rgba(26, 86, 168, .06);
        color: var(--mob-blue);
    }
    .mob-more-item svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        flex-shrink: 0;
    }
    .mob-more-sep {
        height: 1px;
        background: #f1f5f9;
        margin: 4px 8px;
    }

    /* Overlay behind more menu */
    .mob-more-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 499;
        background: rgba(0,0,0,.2);
    }
    .mob-more-backdrop.open { display: block; }
}

/* ========================================
   TOUCH IMPROVEMENTS — pointer:coarse
   ======================================== */
@media (pointer: coarse) {
    /* Vùng chạm tối thiểu 44px cho các nút quan trọng */
    .btn, .btn-sm, .header-nav-item {
        min-height: 44px;
    }

    /* Input fields 16px+ tránh zoom trên iOS */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px;
    }

    /* Scrollbar mỏng hơn trên touch */
    ::-webkit-scrollbar { width: 3px; height: 3px; }
}

/* ========================================
   PULL-TO-REFRESH indicator (optional)
   ======================================== */
@media (max-width: 768px) {
    .mob-ptr {
        display: none;
        position: fixed;
        top: var(--mob-header-h);
        left: 50%;
        transform: translateX(-50%);
        z-index: 450;
        background: #fff;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        box-shadow: 0 2px 12px rgba(0,0,0,.12);
        align-items: center;
        justify-content: center;
    }
    .mob-ptr.active {
        display: flex;
    }
    .mob-ptr-spin {
        width: 18px;
        height: 18px;
        border: 2px solid #e2e8f0;
        border-top-color: var(--mob-blue);
        border-radius: 50%;
        animation: spin .7s linear infinite;
    }
}

/* ========================================
   LANDSCAPE phone: thêm padding ngang
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    body:not(.auth-page) {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
    .mob-bottom-nav {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* ========================================
   HR / KH360 modules — Mobile basics
   ======================================== */
@media (max-width: 768px) {
    .hr-page, .kh360-page {
        padding: 10px;
    }
}

/* ========================================
   DESKTOP ≤1500px: header nav gọn lại tránh tràn
   ======================================== */
@media (max-width: 1500px) {
    .header {
        padding: 6px 16px;
        gap: 6px;
        overflow: hidden;
    }
    .header-logo {
        height: 50px;
        max-width: 300px;
    }
    .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: 6px 10px;
        font-size: 13px;
    }
    .header-nav {
        flex-shrink: 1;
        min-width: 0;
    }
    .header-user-name {
        font-size: 13px;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .btn-logout {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ========================================
   PRINT: ẩn bottom nav
   ======================================== */
@media print {
    .mob-bottom-nav { display: none !important; }
}
