/* ===================================================================
   CRM MINI MAP - MOBILE & RESPONSIVE STYLESHEET (SAAS GRADE)
   Thiết kế Chuẩn SaaS Đẳng Cấp - Tương thích 100% Mobile (iOS & Android)
   - Mobile Native Bottom Navigation Bar & FAB Action Button
   - Native Bottom Sheet Modals với Drag Handle & Sticky Header/Footer
   - Vùng chạm chuẩn Human Interface (Touch Targets >= 36px - 44px)
   - Hệ thống thẻ tương tác mượt mà, Active Touch Feedback
   - Bản đồ di động tối ưu Safe-Area Insets (Tai thỏ & Home Bar)
   =================================================================== */

/* ===================================================================
   1. ĐIỀU CHỈNH CHUNG & BẢO VỆ GIAO DIỆN DI ĐỘNG (< 860px)
   =================================================================== */
@media (max-width: 860px) {
    /* Ngăn chặn triệt để hiện tượng Auto-Zoom trên iPhone/iPad khi chạm vào input */
    input, select, textarea, .form-input, .form-select, .form-textarea {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
    }

    /* Ẩn chữ phụ trên di động */
    .text-desktop-only {
        display: none !important;
    }

    /* ===============================================================
       2. TOP NAVBAR TRÊN MOBILE (SIÊU TINH GỌN, CHUẨN SAAS)
       =============================================================== */
    .crm-top-navbar {
        height: auto;
        min-height: unset;
        padding: 8px 12px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background: var(--glass-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 90;
    }

    .crm-top-navbar-main {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        height: 36px;
        gap: 8px;
    }

    .crm-nav-left {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .crm-nav-right {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .brand-logo {
        gap: 6px;
        display: flex;
        align-items: center;
    }

    .brand-icon-box {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

    .brand-icon-box svg {
        width: 16px;
        height: 16px;
    }

    .brand-title {
        font-size: 0.92rem;
        font-weight: 700;
        letter-spacing: -0.02em;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .badge-pro-status {
        font-size: 0.58rem;
        padding: 2px 6px;
        border-radius: var(--radius-full);
        line-height: 1.1;
        cursor: pointer;
    }

    /* Các nút trên Top Header Mobile có touch target >= 34px */
    .btn-switch-map {
        height: 34px;
        padding: 0 10px;
        font-size: 0.74rem;
        font-weight: 600;
        gap: 4px;
        border-radius: var(--radius-btn);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .btn-switch-map:active {
        transform: scale(0.96);
    }

    .btn-switch-map svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .map-badge-count {
        font-size: 0.65rem;
        padding: 1px 5px;
        border-radius: var(--radius-btn-sm);
    }

    .btn-add-header {
        height: 34px;
        padding: 0 10px;
        font-size: 0.74rem;
        font-weight: 600;
        gap: 4px;
        border-radius: var(--radius-btn);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .btn-add-header:active {
        transform: scale(0.96);
    }

    .btn-add-header svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .theme-icon-btn {
        width: 34px;
        height: 34px;
        padding: 0;
        border-radius: var(--radius-btn);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .theme-icon-btn:active {
        transform: scale(0.94);
    }

    .theme-icon-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Ẩn Tabs cũ trên Top Header khi trên Mobile, nhường quyền cho Bottom Nav */
    .crm-tabs-bar {
        display: none !important;
    }

    /* ===============================================================
       3. NATIVE MOBILE BOTTOM NAVIGATION BAR & FAB (CHUẨN SAAS)
       =============================================================== */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(58px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        align-items: center;
        justify-content: space-around;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-muted);
        padding: 6px 0;
        gap: 3px;
        cursor: pointer;
        transition: all var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        position: relative;
    }

    .mobile-nav-btn:active {
        transform: scale(0.92);
    }

    .mobile-nav-btn.active {
        color: var(--cyan);
    }

    .mobile-nav-btn.active svg {
        stroke: var(--cyan);
        filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.4));
    }

    .mobile-nav-icon-wrap {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
    }

    .mobile-nav-icon-wrap svg {
        width: 20px;
        height: 20px;
        transition: transform var(--transition-fast);
    }

    .mobile-nav-label {
        font-size: 0.65rem;
        font-weight: 500;
        letter-spacing: -0.01em;
        line-height: 1;
    }

    .mobile-nav-btn.active .mobile-nav-label {
        font-weight: 700;
    }

    .mobile-nav-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        background: var(--cyan);
        color: #000;
        font-size: 0.58rem;
        font-weight: 700;
        padding: 1px 4px;
        border-radius: var(--radius-full);
        min-width: 14px;
        text-align: center;
        line-height: 1.1;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    }

    /* Nút Nổi FAB Trung Tâm (Thêm Khách Nhanh) */
    .mobile-nav-fab {
        width: 46px;
        height: 46px;
        border-radius: var(--radius-full);
        background: linear-gradient(135deg, var(--cyan) 0%, var(--emerald) 100%);
        color: #09090b;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px rgba(6, 182, 212, 0.45);
        cursor: pointer;
        flex-shrink: 0;
        margin: -16px 4px 0 4px;
        transition: transform var(--transition-fast), box-shadow var(--transition-fast);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-fab:active {
        transform: scale(0.92) rotate(45deg);
        box-shadow: 0 2px 8px rgba(6, 182, 212, 0.6);
    }

    .mobile-nav-fab svg {
        stroke: #09090b;
    }

    /* ===============================================================
       4. THÂN NỘI DUNG CRM (PADDING AN TOÀN TRÁNH BOTTOM NAV)
       =============================================================== */
    .crm-body-container {
        padding: 10px 10px calc(115px + env(safe-area-inset-bottom, 0px)) 10px !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ===============================================================
       5. DÃY THỐNG KÊ PHỄU (SAAS METRIC PILLS - SIÊU TINH GỌN MOBILE)
       =============================================================== */
    .pipeline-stats-row {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 5px;
        margin-bottom: 8px;
        padding: 2px 0;
    }

    .pipeline-stats-row::-webkit-scrollbar {
        display: none;
    }

    .pipeline-stat-card {
        flex: 0 0 auto;
        min-width: 82px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 2px;
        padding: 6px 10px;
        border-radius: 10px;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        transition: all var(--transition-fast);
        touch-action: manipulation;
    }

    .pipeline-stat-card[data-stage="all"] {
        background: rgba(255, 255, 255, 0.03);
    }

    .pipeline-stat-card[data-stage="lead"] {
        background: rgba(6, 182, 212, 0.07);
        border-color: rgba(6, 182, 212, 0.22);
    }

    .pipeline-stat-card[data-stage="scheduled"] {
        background: rgba(245, 158, 11, 0.07);
        border-color: rgba(245, 158, 11, 0.22);
    }

    .pipeline-stat-card[data-stage="met"] {
        background: rgba(16, 185, 129, 0.07);
        border-color: rgba(16, 185, 129, 0.22);
    }

    .pipeline-stat-card[data-stage="won"] {
        background: rgba(139, 92, 246, 0.07);
        border-color: rgba(139, 92, 246, 0.22);
    }

    .pipeline-stat-card[data-stage="followup"] {
        background: rgba(244, 63, 94, 0.07);
        border-color: rgba(244, 63, 94, 0.22);
    }

    .pipeline-stat-card:active {
        transform: scale(0.95);
    }

    .pipeline-stat-card.active {
        border-color: var(--cyan);
        box-shadow: 0 0 0 1.5px var(--cyan), 0 4px 12px rgba(6, 182, 212, 0.25);
        background: var(--bg-surface-elevated);
    }

    .stat-number {
        font-size: 0.94rem;
        font-weight: 700;
        margin-bottom: 0;
        line-height: 1;
    }

    .stat-label {
        font-size: 0.65rem;
        font-weight: 500;
        color: var(--text-muted);
        white-space: nowrap;
    }

    /* ===============================================================
       6. THANH CÔNG CỤ TÌM KIẾM, SẮP XẾP & TAG CLOUD (TINH GỌN)
       =============================================================== */
    .crm-filter-toolbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px;
        margin-bottom: 6px;
    }

    .crm-search-box {
        flex: 1 1 100%;
        min-width: 0;
        height: 34px;
        padding: 0 10px;
        border-radius: var(--radius-full);
        gap: 6px;
    }

    .crm-search-box svg {
        width: 14px;
        height: 14px;
    }

    .crm-search-box input {
        font-size: 16px !important;
    }

    .crm-sort-box {
        flex: 1 1 auto;
        max-width: 125px;
        height: 28px;
        padding: 0 6px;
        border-radius: var(--radius-btn);
        gap: 4px;
    }

    .crm-sort-box svg {
        width: 12px;
        height: 12px;
    }

    .crm-sort-box select {
        font-size: 0.7rem;
        padding: 2px 0;
        width: 100%;
    }

    .crm-toolbar-action-group {
        display: flex !important;
        align-items: center;
        gap: 4px;
        flex: 1;
        justify-content: flex-end;
    }

    .btn-export-toolbar,
    .btn-import-toolbar,
    .btn-sample-toolbar {
        height: 28px;
        padding: 0 7px;
        font-size: 0.68rem;
        font-weight: 600;
        gap: 3px;
        border-radius: var(--radius-btn);
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    .btn-export-toolbar:active,
    .btn-import-toolbar:active,
    .btn-sample-toolbar:active {
        transform: scale(0.95);
    }

    .btn-export-toolbar svg,
    .btn-import-toolbar svg,
    .btn-sample-toolbar svg {
        width: 12px;
        height: 12px;
    }

    .crm-active-tag-bar {
        padding: 4px 8px;
        margin-bottom: 6px;
        font-size: 0.7rem;
        border-radius: var(--radius-btn-sm);
    }

    .crm-tags-cloud-bar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding-bottom: 6px;
        margin-bottom: 4px;
        gap: 5px;
    }

    .crm-tag-chip {
        padding: 3px 8px;
        font-size: 0.68rem;
        border-radius: var(--radius-btn-sm);
        touch-action: manipulation;
    }

    .crm-tag-chip:active {
        transform: scale(0.95);
    }

    .crm-tag-popover-menu {
        left: 0;
        right: auto;
        min-width: 260px;
        max-width: calc(100vw - 20px);
        max-height: 55vh;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }

    /* ===============================================================
       7. LƯỚI KHÁCH HÀNG SIÊU TINH GỌN (ULTRA COMPACT SAAS CARDS)
       =============================================================== */
    .crm-customer-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .customer-card-item {
        padding: 8px 10px;
        border-radius: 10px;
        border-left-width: 3.5px;
        gap: 4px;
        transition: transform var(--transition-fast), border-color var(--transition-fast);
        touch-action: manipulation;
    }

    .customer-card-item:active {
        transform: scale(0.99);
    }

    .card-top {
        margin-bottom: 0;
    }

    .customer-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.72rem;
        font-weight: 700;
        border-radius: 7px;
        flex-shrink: 0;
    }

    .customer-name {
        font-size: 0.84rem;
        font-weight: 600;
        letter-spacing: -0.01em;
        line-height: 1.25;
    }

    .stage-badge {
        font-size: 0.6rem;
        font-weight: 600;
        padding: 1.5px 6px;
        border-radius: var(--radius-full);
        line-height: 1.2;
    }

    .customer-staff-pill {
        font-size: 0.58rem;
        color: var(--text-muted);
        opacity: 0.85;
    }

    .card-meta-row {
        margin-top: 1px;
    }

    .card-meta {
        font-size: 0.68rem;
        color: var(--text-muted);
        gap: 4px;
        line-height: 1.2;
    }

    .card-meta svg {
        width: 11px;
        height: 11px;
        flex-shrink: 0;
        opacity: 0.8;
    }

    .customer-card-note {
        font-size: 0.68rem;
        color: var(--text-muted);
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-top: 1px;
        opacity: 0.85;
    }

    .card-tags {
        gap: 3px;
        margin-top: 1px;
    }

    .tag-pill {
        font-size: 0.58rem;
        padding: 1px 5px;
        border-radius: 4px;
        line-height: 1.2;
    }

    /* Cụm Phím Thao Tác Nhanh Tinh Gọn Trên Mobile (Height 28px, 1 Hàng Duy Nhất) */
    .card-quick-actions {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: 4px;
        padding-top: 5px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .action-chip-btn span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .action-chip-btn {
        flex: 1;
        min-width: 0;
        height: 28px;
        min-height: 28px;
        justify-content: center;
        padding: 0 4px;
        font-size: 0.68rem;
        font-weight: 600;
        border-radius: 6px;
        gap: 3px;
        touch-action: manipulation;
        white-space: nowrap;
        transition: transform 0.12s ease, opacity 0.12s ease;
    }

    .action-chip-btn:active {
        transform: scale(0.95);
        opacity: 0.85;
    }

    .action-chip-btn svg {
        width: 11px;
        height: 11px;
        flex-shrink: 0;
    }

    .action-chip-btn-call {
        background: rgba(16, 185, 129, 0.12);
        color: var(--emerald);
        border: 1px solid rgba(16, 185, 129, 0.3);
    }

    .action-chip-btn-zalo {
        background: rgba(14, 165, 233, 0.12);
        color: #38bdf8;
        border: 1px solid rgba(14, 165, 233, 0.3);
    }

    .action-chip-btn-map {
        background: rgba(6, 182, 212, 0.12);
        color: var(--cyan);
        border: 1px solid rgba(6, 182, 212, 0.3);
    }

    .action-chip-btn-pin {
        background: rgba(245, 158, 11, 0.12);
        color: var(--amber);
        border: 1px solid rgba(245, 158, 11, 0.3);
    }

    .action-chip-btn-detail {
        background: rgba(255, 255, 255, 0.06);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
    }

    /* ===============================================================
       8. CHI TIẾT KHÁCH HÀNG (CUSTOMER DETAIL DOSSIER)
       =============================================================== */
    .detail-top-nav {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }

    .detail-top-nav .btn-secondary,
    .detail-top-nav .btn-switch-map {
        height: 36px;
        font-size: 0.76rem;
        padding: 0 12px;
        border-radius: var(--radius-btn);
    }

    .detail-hero-card {
        padding: 14px 14px;
        border-radius: 14px;
    }

    .detail-quick-tiles {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        margin: 12px 0;
    }

    .sheet-action-tile {
        padding: 10px 4px;
        font-size: 0.72rem;
        font-weight: 600;
        min-height: 52px;
        gap: 4px;
        border-radius: 10px;
        touch-action: manipulation;
    }

    .sheet-action-tile:active {
        transform: scale(0.94);
    }

    .sheet-action-tile svg {
        width: 18px;
        height: 18px;
    }

    /* ===============================================================
       9. LỊCH HẸN & CÀI ĐẶT
       =============================================================== */
    .section-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 10px;
    }

    .section-header-row h2 {
        font-size: 1rem;
        font-weight: 700;
        letter-spacing: -0.01em;
    }

    .section-header-row p {
        font-size: 0.74rem;
    }

    .section-header-row .btn-primary {
        width: 100%;
        height: 38px;
        justify-content: center;
        font-size: 0.78rem;
        font-weight: 600;
        border-radius: var(--radius-btn);
    }

    .meetings-filter-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 10px;
    }

    .meetings-filter-toolbar .meetings-filter-tabs {
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 2px;
    }

    .meeting-filter-btn {
        height: 32px;
        padding: 0 10px;
        font-size: 0.74rem;
        font-weight: 600;
        border-radius: var(--radius-btn-sm);
        gap: 4px;
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .meeting-date-picker-wrap {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .meeting-date-input-box {
        flex: 1;
        height: 34px;
        padding: 4px 10px;
        font-size: 0.74rem;
        border-radius: var(--radius-btn-sm);
    }

    .meeting-date-input-box input[type="date"] {
        width: 100%;
        font-size: 16px !important;
    }

    .settings-grid-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .settings-card-box {
        padding: 14px 16px;
        border-radius: 14px;
        gap: 10px;
    }

    .settings-box-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .settings-box-icon svg {
        width: 16px;
        height: 16px;
    }

    .settings-card-box h3 {
        font-size: 0.88rem;
        font-weight: 600;
    }

    .settings-card-box p {
        font-size: 0.72rem;
    }

    .settings-actions-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .settings-actions-group .btn-secondary,
    .settings-actions-group .btn-danger,
    .settings-card-box .btn-primary {
        height: 38px;
        font-size: 0.78rem;
        font-weight: 600;
        padding: 0 14px;
        border-radius: var(--radius-btn);
    }

    /* ===============================================================
       10. MAP WORKSPACE TRÊN MOBILE (TOÀN CẢNH, TIỆN DỤNG)
       =============================================================== */
    .map-top-bar {
        top: calc(8px + env(safe-area-inset-top, 0px));
        left: 8px;
        right: 56px;
        height: 38px;
        gap: 6px;
    }

    .btn-back-to-crm {
        height: 38px;
        padding: 0 12px;
        font-size: 0.78rem;
        font-weight: 600;
        gap: 4px;
        border-radius: var(--radius-full);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
        touch-action: manipulation;
    }

    .btn-back-to-crm:active {
        transform: scale(0.96);
    }

    .btn-back-to-crm svg {
        width: 15px;
        height: 15px;
    }

    .map-quick-search-box {
        height: 38px;
        padding: 0 12px;
        border-radius: var(--radius-full);
        font-size: 16px !important;
    }

    .map-count-pill {
        display: none;
    }

    .map-floating-capsule {
        top: calc(8px + env(safe-area-inset-top, 0px));
        right: 8px;
        padding: 2px;
        border-radius: var(--radius-full);
    }

    .capsule-btn {
        width: 36px;
        height: 36px;
        border-radius: var(--radius-full);
        touch-action: manipulation;
    }

    .capsule-btn:active {
        transform: scale(0.92);
    }

    .capsule-btn svg {
        width: 16px;
        height: 16px;
    }

    /* ===============================================================
       11. MAP BOTTOM CAROUSEL & FLOATING MINI CARD
       =============================================================== */
    .map-stage-filter-bar {
        top: calc(56px + env(safe-area-inset-top, 0px));
        left: 8px;
        right: 8px;
        max-width: calc(100% - 16px);
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding: 4px 6px;
        border-radius: var(--radius-full);
        backdrop-filter: blur(14px);
    }

    .map-stage-chip {
        padding: 5px 10px;
        font-size: 0.72rem;
        font-weight: 600;
        border-radius: var(--radius-full);
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .map-stage-chip:active {
        transform: scale(0.95);
    }

    .btn-toggle-map-carousel {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        left: 10px;
        padding: 10px 14px;
        font-size: 0.78rem;
        font-weight: 600;
        border-radius: var(--radius-full);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
        touch-action: manipulation;
    }

    .btn-toggle-map-carousel:active {
        transform: scale(0.96);
    }

    .map-bottom-carousel-container {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: 8px;
        right: 8px;
        padding: 12px 14px;
        border-radius: 16px;
    }

    .map-carousel-track {
        gap: 8px;
        scroll-snap-type: x mandatory;
    }

    .map-carousel-card {
        min-width: 195px;
        max-width: 215px;
        padding: 10px 12px;
        gap: 8px;
        border-radius: 12px;
        scroll-snap-align: start;
        touch-action: manipulation;
    }

    .map-pin-name-badge {
        font-size: 0.62rem;
        padding: 2px 6px;
        border-radius: 4px;
    }

    /* Khi mở Mini Card hoặc Carousel trên Map, ẩn triệt để các nút nổi khác để không che nút */
    #map-workspace.has-mini-card .map-floating-fab,
    #map-workspace.has-carousel .map-floating-fab,
    #map-workspace.has-mini-card .btn-toggle-map-carousel,
    #map-workspace:has(#map-floating-mini-card:not([style*="display: none"])) .map-floating-fab,
    #map-workspace:has(#map-bottom-carousel-container:not([style*="display: none"])) .map-floating-fab {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    /* Floating Mini Card khi Chạm Marker Bản Đồ */
    .map-floating-mini-card {
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 16px);
        max-width: 420px;
        padding: 12px 14px;
        border-radius: 16px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
        z-index: 600 !important;
    }

    .map-bottom-carousel-container {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: 8px;
        right: 8px;
        padding: 12px 14px;
        border-radius: 16px;
        z-index: 600 !important;
    }

    .mini-card-title {
        font-size: 0.92rem;
        font-weight: 700;
    }

    .mini-card-actions {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .mini-btn {
        height: 36px;
        min-height: 36px;
        padding: 0 4px;
        font-size: 0.72rem;
        font-weight: 600;
        gap: 3px;
        border-radius: 8px;
        touch-action: manipulation;
    }

    .mini-btn:active {
        transform: scale(0.95);
    }

    .mini-btn svg {
        width: 13px;
        height: 13px;
    }

    /* ===============================================================
       12. NATIVE BOTTOM SHEET MODAL VỚI DRAG HANDLE (CHUẨN SAAS)
       =============================================================== */
    .modal-backdrop {
        position: fixed !important;
        inset: 0 !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        z-index: 99999 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        padding: 0 !important;
    }

    .modal-backdrop.show {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important;
        align-items: center !important;
        padding: 0 !important;
        margin: 0 !important;
        background: rgba(0, 0, 0, 0.75) !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
        z-index: 99999 !important;
    }

    /* Ẩn triệt để Mobile Bottom Nav khi có bất kỳ modal nào đang mở để không che nút Lưu/Đóng */
    body.modal-open,
    body:has(.modal-backdrop.show) {
        overflow: hidden !important;
    }

    body.modal-open .mobile-bottom-nav,
    body:has(.modal-backdrop.show) .mobile-bottom-nav,
    #app-container:has(.modal-backdrop.show) .mobile-bottom-nav,
    .modal-backdrop.show ~ .mobile-bottom-nav,
    .modal-backdrop.show ~ #crm-workspace .mobile-bottom-nav {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    .modal-dialog {
        width: 100% !important;
        width: 100vw !important;
        max-width: 100% !important;
        margin: 0 !important;
        margin-top: auto !important;
        max-height: calc(88dvh - env(safe-area-inset-top, 0px)) !important;
        height: auto !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        position: relative !important;
        bottom: 0 !important;
        animation: slideUpModal 0.24s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.5) !important;
        z-index: 100000 !important;
        box-sizing: border-box !important;
    }

    .modal-drag-handle {
        display: block !important;
        width: 44px !important;
        height: 5px !important;
        border-radius: var(--radius-full) !important;
        background: rgba(255, 255, 255, 0.25) !important;
        margin: 8px auto 4px auto !important;
        flex-shrink: 0 !important;
    }

    html[data-theme="light"] .modal-drag-handle {
        background: rgba(0, 0, 0, 0.2) !important;
    }

    .modal-dialog form,
    .modal-dialog > form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    @keyframes slideUpModal {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .modal-header {
        flex-shrink: 0 !important;
        padding: 10px 16px 12px 16px !important;
        background: var(--bg-surface) !important;
        border-bottom: 1px solid var(--border-color) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        z-index: 10 !important;
    }

    .modal-title {
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        letter-spacing: -0.01em !important;
    }

    .modal-close-btn {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
        touch-action: manipulation !important;
    }

    .modal-close-btn:active {
        transform: scale(0.92) !important;
    }

    .modal-close-btn svg {
        width: 15px !important;
        height: 15px !important;
    }

    .modal-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding: 12px 16px 20px 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        gap: 10px;
        box-sizing: border-box !important;
    }

    .modal-footer {
        flex-shrink: 0 !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 100001 !important;
        background: var(--bg-surface) !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 10px 16px !important;
        padding-bottom: max(12px, calc(10px + env(safe-area-inset-bottom, 0px))) !important;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    .modal-footer button {
        height: 38px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        padding: 0 14px !important;
        border-radius: 10px !important;
        touch-action: manipulation;
    }

    .modal-footer button:active {
        transform: scale(0.97) !important;
    }

    /* Tối ưu riêng cho bảng giá PRO / RESELLER trong #pro-modal trên màn hình Mobile */
    #pro-modal .modal-body > div:first-child {
        gap: 8px !important;
    }

    #pro-modal .modal-body > div:first-child > div {
        padding: 8px 10px !important;
    }

    #pro-modal .modal-body ul {
        margin: 6px 0 8px 12px !important;
        font-size: 0.7rem !important;
        line-height: 1.4 !important;
    }

    #pro-modal .modal-body ul li {
        margin-bottom: 2px !important;
    }

    #pro-modal .modal-body button[data-action="quick-fill-code"] {
        padding: 4px 6px !important;
        font-size: 0.68rem !important;
        height: 28px !important;
    }

    .form-row-2 {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .form-group {
        gap: 4px;
    }

    .form-label {
        font-size: 0.74rem;
        font-weight: 600;
    }

    .form-input, .form-select, .form-textarea {
        padding: 8px 12px;
        border-radius: 10px;
        min-height: 38px;
    }

    /* ===============================================================
       13. MAP RADAR PRO MOBILE STYLES
       =============================================================== */
    .radar-form-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .radar-setup-card {
        padding: 14px 14px;
        gap: 10px;
        border-radius: 12px;
    }

    .radar-execute-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .radar-limit-group {
        max-width: 100%;
    }

    .btn-radar-start {
        width: 100%;
        justify-content: center;
        height: 40px;
        font-size: 0.82rem;
        font-weight: 600;
        border-radius: 10px;
    }

    .radar-chips-container {
        gap: 5px;
    }

    .radar-pill-chip {
        font-size: 0.72rem;
        padding: 4px 10px;
        border-radius: var(--radius-full);
    }

    .radar-results-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .radar-results-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }

    .radar-results-actions button {
        flex: 1;
        justify-content: center;
        font-size: 0.76rem;
        font-weight: 600;
        padding: 6px 8px;
        height: 36px;
        border-radius: 8px;
    }

    .radar-places-table th,
    .radar-places-table td {
        padding: 8px 10px;
        font-size: 0.76rem;
    }
}


    /* Nút Nổi FAB Trên Bản Đồ (Thêm khách nhanh từ Map) */
    .map-floating-fab {
        position: absolute;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        right: 14px;
        width: 48px;
        height: 48px;
        border-radius: var(--radius-full);
        background: linear-gradient(135deg, var(--cyan) 0%, #0284c7 100%);
        color: #ffffff;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
        cursor: pointer;
        z-index: 500;
        transition: transform var(--transition-fast), box-shadow var(--transition-fast);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .map-floating-fab:active {
        transform: scale(0.92);
        box-shadow: 0 2px 10px rgba(2, 132, 199, 0.6);
    }

    .map-floating-fab svg {
        stroke: #ffffff;
    }

/* ===================================================================
   TINH CHỈNH CHO MÀN HÌNH SIÊU NHỎ (< 360px)
   =================================================================== */
@media (max-width: 360px) {
    .btn-switch-map {
        padding: 0 6px;
    }
    .btn-switch-map-text {
        display: none;
    }
    .btn-add-header {
        padding: 0 6px;
    }
    .mobile-nav-label {
        font-size: 0.6rem;
    }
    .mobile-nav-fab {
        width: 42px;
        height: 42px;
        margin-top: -12px;
    }
}

/* ===================================================================
   TINH CHỈNH CHO PRO RESELLER HUB TRÊN MOBILE
   =================================================================== */
@media (max-width: 640px) {
    .crm-staff-dropdown-box {
        flex: 1 1 auto;
        max-width: 135px;
        height: 32px;
        padding: 0 8px;
    }
    .crm-staff-dropdown-box select {
        font-size: 0.74rem;
        padding: 4px 0;
        width: 100%;
    }
    .reseller-staff-grid {
        grid-template-columns: 1fr;
        max-height: 55vh;
        gap: 8px;
    }
    .modal-dialog-reseller {
        max-height: calc(90dvh - env(safe-area-inset-top, 0px)) !important;
    }
}
