/* ═══════════════════════════════════════════════════════════════════════════
   GIAO DIỆN BẢN ĐIỆN THOẠI — mọi thứ scope dưới .m-app
   Không tái dùng tên class của grid desktop: app.css:663 có
   `display:none !important` dưới 768px sẽ nuốt mất markup mobile.
   Màu/bo góc/nút bám token Radzen của bản web (--rz-*) để đồng bộ hai bản.
   ═══════════════════════════════════════════════════════════════════════════ */

.m-app {
    /* Kích thước khung */
    --m-appbar-h: 54px;
    --m-tabbar-h: 58px;
    --m-safe-top: env(safe-area-inset-top, 0px);
    --m-safe-bot: env(safe-area-inset-bottom, 0px);

    /* Bảng màu — nền xám rất nhạt để thẻ trắng nổi lên */
    --m-bg: #f4f6f9;
    --m-surface: #ffffff;
    --m-surface-2: #f8fafc;
    --m-line: var(--rz-base-300, #e3e8ef);
    --m-line-soft: #eef2f7;
    --m-text: #0f172a;
    --m-muted: #64748b;
    --m-faint: #94a3b8;
    --m-primary: var(--rz-primary, #2f6bff);
    --m-primary-dark: #2559d8;
    --m-primary-soft: rgba(47,107,255,.10);
    --m-danger: #dc2626;
    --m-success: #16a34a;

    /* Bo góc — thang thống nhất */
    --m-r-sm: 8px;
    --m-r-md: 12px;
    --m-r-lg: 16px;
    --m-r-full: 999px;

    /* Đổ bóng */
    --m-sh-1: 0 1px 2px rgba(16,24,40,.05);
    --m-sh-2: 0 2px 8px rgba(16,24,40,.08);
    --m-sh-3: 0 8px 24px rgba(16,24,40,.14);

    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--m-bg);
    color: var(--m-text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Giao diện tối: .m-dark gắn trên .m-app (MobileLayout), .bm-dark trên <html>
   (bmDevice.markDark) để với tới dialog/tooltip render ngoài .m-app.
   Giữ .rz-material-dark phòng khi Radzen tự gắn ở bản sau. */
html.bm-dark .m-app,
.m-app.m-dark,
.rz-material-dark .m-app,
.m-app.rz-material-dark {
    --m-bg: #0d1117;
    --m-surface: #161b22;
    --m-surface-2: #1c232c;
    --m-line: #2b333d;
    --m-line-soft: #232b35;
    --m-text: #e6edf3;
    --m-muted: #9aa7b4;
    --m-faint: #6e7b8a;
    --m-sh-1: 0 1px 2px rgba(0,0,0,.4);
    --m-sh-2: 0 2px 8px rgba(0,0,0,.45);
    --m-sh-3: 0 8px 24px rgba(0,0,0,.55);
}

/* ── App bar ─────────────────────────────────────────────────────────────── */
.m-appbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px 0 12px;
    padding-top: var(--m-safe-top);
    height: calc(var(--m-appbar-h) + var(--m-safe-top));
    background: var(--m-surface);
    border-bottom: 1px solid var(--m-line-soft);
    z-index: 10;
}

.m-appbar-title {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
}

.m-appbar-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--m-muted);
    border-radius: var(--m-r-full);
    cursor: pointer;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-appbar-btn:active { background: var(--m-surface-2); color: var(--m-text); }
.m-appbar-btn .rzi { font-size: 22px; }

.m-balance {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 13px;
    color: var(--m-primary);
    background: var(--m-primary-soft);
    border-radius: var(--m-r-full);
    padding: 6px 12px;
    text-decoration: none;
    white-space: nowrap;
}

.m-balance .rzi { font-size: 16px; }

/* ── Vùng nội dung ───────────────────────────────────────────────────────── */
.m-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Chặn pull-to-refresh — bắt buộc, nhất là ở màn điều khiển điện thoại */
    overscroll-behavior-y: contain;
    padding: 12px 12px calc(12px + var(--m-tabbar-h) + var(--m-safe-bot));
}

/* ── Thanh tab dưới đáy ──────────────────────────────────────────────────── */
.m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: var(--m-surface);
    border-top: 1px solid var(--m-line-soft);
    padding-bottom: var(--m-safe-bot);
    height: calc(var(--m-tabbar-h) + var(--m-safe-bot));
    z-index: 200;
}

.m-tab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--m-faint);
    cursor: pointer;
    min-height: 44px;
    padding: 4px 0;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-tab.active { color: var(--m-primary); }
.m-tab:active { opacity: .6; }
.m-tab-ico { position: relative; display: inline-flex; }
.m-tab-ico .rzi { font-size: 22px; }
.m-tab-text { font-size: 10.5px; font-weight: 600; letter-spacing: -.1px; }

.m-tab-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--m-r-full);
    background: var(--m-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--m-surface);
}
/* ── Sheet toàn màn hình (thay popup nổi của desktop) ────────────────────── */
.m-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
}

.m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    background: var(--m-surface);
    animation: m-sheet-in .2s ease-out;
}

@keyframes m-sheet-in {
    from { transform: translateY(16px); opacity: .6; }
    to { transform: translateY(0); opacity: 1; }
}

/* Sheet tài khoản: nửa dưới, bo góc trên */
.m-sheet-acc {
    top: auto;
    max-height: 82vh;
    border-radius: 16px 16px 0 0;
}

.m-sheet-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    padding-top: var(--m-safe-top);
    height: calc(var(--m-appbar-h) + var(--m-safe-top));
    border-bottom: 1px solid var(--m-line);
}

.m-sheet-acc .m-sheet-head { padding-top: 0; height: var(--m-appbar-h); }

.m-sheet-title {
    flex: 1 1 auto;
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 6px;
}

.m-sheet-back,
.m-sheet-close {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--m-text);
    border-radius: 999px;
    cursor: pointer;
}

.m-sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 12px;
    padding-bottom: calc(12px + var(--m-safe-bot));
}

/* Ép các dialog cũ có bề rộng cứng nằm gọn trong sheet */
.m-app .tk-grid-dialog,
.m-sheet .tk-grid-dialog {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.m-sheet-body > * { max-width: 100%; }
.m-sheet-body table { display: block; overflow-x: auto; }

/* ── Sheet tài khoản: các dòng menu ──────────────────────────────────────── */
.m-acc-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 14px;
}

.m-acc-av {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: var(--m-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.m-acc-av img { width: 100%; height: 100%; object-fit: cover; }
.m-acc-av .rzi { font-size: 28px; color: var(--m-muted); }
.m-acc-name { font-weight: 700; font-size: 15px; }
.m-acc-bal { font-size: 13px; color: var(--m-muted); }

.m-acc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 10px 6px;
    border: 0;
    background: transparent;
    color: var(--m-text);
    font-size: 14.5px;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
}

.m-acc-item:active { background: rgba(0,0,0,.05); }
.m-acc-item .rzi { font-size: 20px; color: var(--m-muted); }
.m-acc-danger { color: var(--m-danger); }
.m-acc-danger .rzi { color: var(--m-danger); }

.m-acc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 6px;
    font-size: 14.5px;
}

.m-acc-sep { height: 1px; background: var(--m-line); margin: 8px 0; }

/* ── Danh sách dạng card (TkMobileList) ──────────────────────────────────── */
.m-list { display: flex; flex-direction: column; gap: 8px; }

.m-list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.m-card {
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.m-card.sel { border-color: var(--m-primary); box-shadow: 0 0 0 2px rgba(47,107,255,.18); }

.m-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.m-card-name {
    font-weight: 700;
    font-size: 14.5px;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dòng thông tin đậm đặc: "khoá: giá trị · khoá: giá trị" */
.m-card-facts {
    font-size: 12.5px;
    color: var(--m-muted);
    line-height: 1.5;
    word-break: break-word;
}

.m-card-facts b { color: var(--m-text); font-weight: 600; }

.m-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.m-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--m-line);
    background: var(--m-surface);
    color: var(--m-text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .08s;
    -webkit-tap-highlight-color: transparent;
}

.m-btn:active { transform: scale(.97); background: rgba(0,0,0,.04); }

.m-btn-primary {
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(47,107,255,.28);
}

.m-btn-primary:active { background: #2559d8; }
.m-btn-kebab { margin-left: auto; width: 40px; padding: 0; }
.m-btn .rzi { font-size: 18px; }

/* Nút chỉ-icon (thanh công cụ) */
.m-icobtn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--m-line);
    border-radius: 10px;
    background: var(--m-surface);
    color: var(--m-text);
    cursor: pointer;
    transition: background .15s, transform .08s;
    -webkit-tap-highlight-color: transparent;
}

.m-icobtn:active { transform: scale(.94); background: rgba(0,0,0,.05); }
.m-icobtn .rzi { font-size: 19px; }
.m-icobtn-sm { width: 32px; height: 32px; border: 0; }
.m-icobtn-sm .rzi { font-size: 17px; }

/* Ô nhập có icon dẫn */
.m-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--m-line);
    border-radius: 10px;
    background: var(--m-surface);
    transition: border-color .15s, box-shadow .15s;
}

.m-field:focus-within { border-color: var(--m-primary); box-shadow: 0 0 0 3px rgba(47,107,255,.14); }
.m-field .rzi { font-size: 18px; color: var(--m-muted); flex: 0 0 auto; }

.m-field input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--m-text);
    font-size: 15px;
}

/* Vòng quay chờ */
.m-spin {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid var(--m-line);
    border-top-color: var(--m-primary);
    border-radius: 50%;
    animation: m-spin .7s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}

@keyframes m-spin { to { transform: rotate(360deg); } }

.m-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--m-bg);
    color: var(--m-muted);
    border: 1px solid var(--m-line);
    cursor: pointer;
    white-space: nowrap;
}

.m-chip.sel { background: rgba(47,107,255,.12); color: var(--m-primary); border-color: var(--m-primary); }

.m-search {
    flex: 1 1 160px;
    min-width: 0;
    height: 38px;
    border: 1px solid var(--m-line);
    border-radius: 10px;
    padding: 0 12px;
    background: var(--m-surface);
    color: var(--m-text);
    font-size: 14px;
    outline: none;
}

.m-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    color: var(--m-muted);
    padding: 40px 12px;
    font-size: 13.5px;
}

.m-empty .rzi { font-size: 40px; opacity: .4; }

.m-loading { text-align: center; color: var(--m-muted); padding: 16px; font-size: 13px; }
.m-sentinel { height: 1px; }

/* ── RadzenTabs dùng lại từ bản desktop, đổi BỐ TRÍ cho vừa màn hẹp ────────
   ⚠ RadzenTheme chèn CSS LÚC CHẠY vào cuối <head> → nằm SAU mobile.css và
   thắng ở cùng độ ưu tiên. Vì vậy khối này phải nâng specificity (.m-app đứng
   trước) + !important ở những thuộc tính Radzen đặt sẵn.                      */
.m-app .m-tabs,
.m-app .m-tabs .rz-tabview {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.m-app .m-tabs .rz-tabview-nav {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 4px !important;
    background: var(--m-surface-2) !important;
    border: 1px solid var(--m-line) !important;
    border-radius: var(--m-r-md) !important;
    padding: 4px !important;
    margin: 0 0 12px 0 !important;
    box-shadow: none !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.m-app .m-tabs .rz-tabview-nav::-webkit-scrollbar { display: none; }

/* Radzen bọc mỗi tab trong <li>; bỏ sạch viền/nền mặc định của nó */
.m-app .m-tabs .rz-tabview-nav > li {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: var(--m-r-sm) !important;
    top: 0 !important;
}

.m-app .m-tabs .rz-tabview-nav > li > a,
.m-app .m-tabs .rz-tabview-nav > li > a:hover,
.m-app .m-tabs .rz-tabview-nav > li .rz-tabview-title {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: var(--m-r-sm) !important;
    background: transparent !important;
    color: var(--m-muted) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-transform: none !important;   /* Radzen mặc định VIẾT HOA → khó đọc, dài */
    letter-spacing: 0 !important;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: none !important;
    text-decoration: none !important;
}

.m-app .m-tabs .rz-tabview-nav > li.rz-tabview-selected > a,
.m-app .m-tabs .rz-tabview-nav > li.rz-state-active > a {
    background: var(--m-surface) !important;
    color: var(--m-primary) !important;
    box-shadow: var(--m-sh-1) !important;
}

/* Bỏ gạch chân/indicator mặc định của Radzen */
.m-app .m-tabs .rz-tabview-nav-indicator,
.m-app .m-tabs .rz-tabview-ink-bar { display: none !important; }

.m-app .m-tabs .rz-tabview-panels {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.m-app .m-tabs .rz-tabview-panel { padding: 0 !important; }

/* ── Segmented control (dùng ở nơi khác) ─────────────────────────────────── */
.m-seg {
    display: flex;
    gap: 4px;
    background: var(--m-bg);
    border: 1px solid var(--m-line);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 10px;
    overflow-x: auto;
}

.m-seg-item {
    flex: 1 0 auto;
    min-height: 36px;
    padding: 6px 12px;
    border: 0;
    background: transparent;
    color: var(--m-muted);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.m-seg-item.sel { background: var(--m-surface); color: var(--m-primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ── Ô thống kê (MDashboard) ─────────────────────────────────────────────── */
.m-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }

.m-stat {
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: 12px;
    padding: 10px 12px;
}

.m-stat-label { font-size: 11.5px; color: var(--m-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.m-stat-value { font-size: 17px; font-weight: 800; margin-top: 2px; }

.m-sec-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--m-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin: 14px 2px 8px;
}

/* Widget chat nổi của desktop không được đè lên thanh tab */
.m-app .bm-chat-fab, .m-app .bm-chat-widget { display: none !important; }

/* ── PWA: thanh mời cài + thanh báo bản mới ──────────────────────────────── */
.m-install-bar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--m-tabbar-h) + var(--m-safe-bot) + 8px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.14);
    z-index: 300;
}

.m-install-text { flex: 1 1 auto; font-size: 13px; font-weight: 600; }

.m-install-x {
    border: 0;
    background: transparent;
    color: var(--m-muted);
    font-size: 20px;
    line-height: 1;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

/* Thanh "có bản mới" dựng bằng DOM thuần → style toàn cục, không nằm trong .m-app */
.bm-update-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #111827;
    color: #fff;
    border-radius: 999px;
    padding: 8px 10px 8px 16px;
    font-size: 13.5px;
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
    z-index: 99999;
    max-width: 92vw;
}

.bm-update-bar button {
    border: 0;
    border-radius: 999px;
    background: #2f6bff;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 6px 14px;
    cursor: pointer;
}

.bm-update-bar .bm-update-x { background: transparent; font-size: 18px; padding: 2px 6px; }

.m-cfg-warn {
    margin-top: 10px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 13px;
}

/* ── Ví / nạp tiền ───────────────────────────────────────────────────────── */
.m-bal-hero {
    background: linear-gradient(135deg, #2f6bff, #1e40af);
    color: #fff;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    text-align: center;
}

.m-bal-hero-label { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.m-bal-hero-value { font-size: 30px; font-weight: 800; margin: 4px 0 12px; line-height: 1.15; }
.m-bal-cta { width: 100%; background: #fff; color: #1e40af; border-color: #fff; min-height: 44px; font-size: 15px; }

/* Dialog cũ mở toàn màn hình trên điện thoại (bản desktop cố định 812px) */
.m-dialog-full .rz-dialog,
.rz-dialog.m-dialog-full {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
}

.m-dialog-full .rz-dialog-content { max-height: none !important; overflow: auto; }

/* ═══ Các trang DÙNG LẠI bản desktop — chỉ nắn lại cho vừa màn hình hẹp ═══
   Chỉ tác dụng bên trong .m-app nên KHÔNG ảnh hưởng bản desktop.               */

.m-app, .m-app * { max-width: 100%; }
.m-body img, .m-body video, .m-body iframe { max-width: 100%; height: auto; }

/* Bảng biểu còn sót lại: cho cuộn ngang TRONG khung của nó, không đẩy cả trang */
.m-body table,
.m-body .rz-data-grid,
.m-body .rz-datatable,
.m-body pre {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.m-body .rz-row { flex-wrap: wrap; }
.m-body .rz-col, .m-body [class*="rz-col-"] { flex: 1 1 100% !important; max-width: 100% !important; }
.m-body .rz-card { padding: 12px; border-radius: var(--m-r-md); }
.m-body .rz-tabview-nav { overflow-x: auto; flex-wrap: nowrap; }
.m-body .rz-tabview-nav li { flex: 0 0 auto; }

/* Vùng chạm tối thiểu + không để iOS tự phóng to khi focus (font < 16px) */
.m-body button, .m-body .rz-button { min-height: 40px; }
.m-body input, .m-body select, .m-body textarea { font-size: 16px; max-width: 100%; }

/* ⚠ GỠ quy tắc desktop app.css@768px: nó ẩn CHỮ trong .btn-tk và co nút còn 30x30
   → trong dialog nạp tiền các nút chọn nhanh + nút QR bị TRỐNG TRƠN.
   Bản mobile có không gian riêng nên trả lại chữ và kích thước hợp ngón tay. */
.m-app .btn-tk .rz-button-text,
.m-app .btn-tk-outline .rz-button-text,
html.bm-mobile .btn-tk .rz-button-text,
html.bm-mobile .btn-tk-outline .rz-button-text {
    display: inline !important;
}

.m-app .btn-tk,
.m-app .btn-tk-outline,
html.bm-mobile .btn-tk,
html.bm-mobile .btn-tk-outline {
    width: auto !important;
    height: auto !important;
    min-height: 40px !important;
    padding: 8px 14px !important;
}

/* Dialog Radzen render NGOÀI .m-app → bám class trên <html> (bmDevice.markMobile) */
html.bm-mobile .rz-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    /* ⚠ Radzen đặt `scale: 0.5` cho hiệu ứng mở; trên mobile nó kẹt lại khiến
       dialog render chỉ 188px dù width tính ra 375px. Ép về 1. */
    scale: 1 !important;
    transform: none !important;
}

html.bm-mobile .rz-dialog-content { max-height: calc(100dvh - 56px) !important; overflow: auto; }
html.bm-mobile .tk-grid-dialog { min-width: 0 !important; width: 100% !important; }

/* Chat hỗ trợ */
.m-body .bm-chat-thread, .m-body .bm-chat-panel { height: auto; min-height: 50vh; }
.m-body .bm-chat-composer { position: sticky; bottom: 0; background: var(--m-surface); padding-bottom: 6px; }

/* Checkout / sản phẩm: 1 cột */
.m-body .checkout-grid,
.m-body .product-grid,
.m-body .tk-products-grid { grid-template-columns: 1fr !important; display: grid; gap: 10px; }


/* ═══ MÀN ĐIỀU KHIỂN ═══════════════════════════════════════════════════════
   ⚠ Thẻ .phone-mini do core-fix.js dựng. Tên class THẬT lấy từ UI/config.js:
     .info-phone-details    (KHÔNG phải .phone-info)
     .section-phone-actions (KHÔNG phải .phone-actions)
   CSS desktop đặt info absolute ĐÈ LÊN canvas + .phone-mini có margin 6px và
   border 4px xám → phải ghi đè hết thì lưới mới sát, thông tin mới xuống dưới. */

.m-pc { display: flex; flex-direction: column; gap: 10px; }
.m-pc-bar { display: flex; align-items: center; gap: 8px; }

.m-pc-bar-ctrl {
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-md);
    padding: 6px 6px 6px 14px;
    box-shadow: var(--m-sh-1);
}

.m-ctrl-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    font-size: 13px;
    color: var(--m-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Chế độ LƯỚI: các máy SÁT NHAU ─────────────────────────────────────── */
.m-pc.grid .m-pc-stage {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    align-content: start;   /* dồn lên trên, không dàn đều gây hở lớn */
}

@media (min-width: 560px) { .m-pc.grid .m-pc-stage { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 820px) { .m-pc.grid .m-pc-stage { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* Thẻ = KHÔNG viền. Viền chỉ bao quanh MÀN HÌNH MÁY (canvas), chữ nằm NGOÀI viền. */
.m-pc.grid .phone-mini {
    position: relative !important;
    display: flex !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    flex-direction: column;
    background: transparent;
    overflow: visible;
    cursor: pointer;
    box-shadow: none;
    transition: transform .1s;
    -webkit-tap-highlight-color: transparent;
}

.m-pc.grid .phone-mini:active { transform: scale(.96); }

/* KHÔNG viền — chỉ bo góc + đổ bóng rất nhẹ để thẻ không trôi trên nền trắng.
   Dấu tích là tín hiệu chọn DUY NHẤT (theo yêu cầu). */
.m-pc.grid .phone-mini canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
    background: #0b0d10;
    aspect-ratio: 394 / 800;
    object-fit: cover;
    border: 0 !important;
    border-radius: var(--m-r-md) !important;
    box-shadow: var(--m-sh-1);
    transition: box-shadow .15s;
}

.m-pc.grid .phone-mini.is-selected canvas { box-shadow: var(--m-sh-1); }

/* ── Máy đang XOAY NGANG ────────────────────────────────────────────────────
   Khung dọc + object-fit:cover cắt mất 76% màn hình (đo thực tế) — gần như
   chỉ còn dải giữa, nhìn không ra máy nào.
   Cách xử lý: XOAY màn hình máy 90° cho ĐỨNG DẬY, giữ nguyên ô cỡ chuẩn để
   lưới vẫn đều tăm tắp (không cấp ô rộng gấp đôi — sẽ so le hàng).
   Class .is-land do bmPhone.syncGridOrientation() gắn theo kích thước luồng.

   Cơ chế: canvas được bố trí theo khổ NGANG (2.0305W × W) rồi xoay quanh góc
   trái-trên và đẩy sang phải đúng 1W → phủ khít đúng vùng dọc W × 2.0305W.
   Cha lấy lại chiều cao bằng padding-top (phần trăm tính theo BỀ RỘNG cha),
   vì canvas đã ra khỏi dòng chảy nên không còn chống đỡ chiều cao thẻ. */
.m-pc.grid .phone-mini.is-land {
    position: relative;
    padding-top: calc(100% * 800 / 394);
}

.m-pc.grid .phone-mini.is-land canvas {
    position: absolute;
    top: 0;
    left: 100%;
    width: calc(100% * 800 / 394) !important;
    height: auto !important;
    /* BẮT BUỘC: luật chung `.m-app * { max-width: 100% }` kẹp bề rộng về đúng
       bề rộng ô (đo được 70px thay vì 142px) → ảnh xoay ra chỉ còn nửa ô. */
    max-width: none !important;
    aspect-ratio: 800 / 394;
    object-fit: cover;
    transform: rotate(90deg);
    transform-origin: top left;
}

/* Lớp phủ chặn chạm: ở lưới, chạm là để CHỌN máy, không lọt xuống máy thật */
.m-pc.grid .phone-mini::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
}

/* Dấu tích ở máy đang chọn — bám góc trên phải của MÀN HÌNH máy */
.m-pc.grid .phone-mini.is-selected::before {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 6;
    width: 18px;
    height: 18px;
    border-radius: var(--m-r-full);
    background: var(--m-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 1px 5px rgba(0,0,0,.35);
}

/* Thông tin nằm NGOÀI viền, ngay dưới máy (class thật: .info-phone-details) */
.m-pc.grid .phone-mini .info-phone-details {
    position: static !important;
    transform: none !important;
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 0 !important;
    padding: 5px 2px 0;
    background: transparent;
    width: auto !important;
    height: auto !important;
    overflow: hidden;
}

.m-pc.grid .phone-mini .info-phone-details span {
    font-size: 8.5px !important;
    font-weight: 500 !important;
    color: var(--m-faint) !important;
    text-shadow: none !important;
    opacity: 1 !important;
    line-height: 1.3;
    max-width: 100%;
    letter-spacing: -.2px;
    word-break: break-all;
    text-align: center;
}

.m-pc.grid .phone-mini .phone-info-index {
    font-weight: 700 !important;
    font-size: 10px !important;
    color: var(--m-primary) !important;
}

.m-pc.grid .phone-mini .phone-info-name { display: none !important; }
.m-pc.grid .phone-mini .section-phone-actions { display: none !important; }
.m-pc.grid .phone-mini .video-loading { position: absolute; inset: 0; display: grid; place-items: center; }

/* ── Thanh hành động khi ĐÃ CHỌN 1 máy ─────────────────────────────────────
   FIXED ngay trên thanh tab: luôn thấy, KHÔNG phải cuộn xuống mới thấy.      */
.m-pc-actionbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(var(--m-tabbar-h) + var(--m-safe-bot) + 10px);
    z-index: 250;
    display: flex;
    flex-direction: column;   /* 2 hàng: thông tin máy trên, 2 nút dưới */
    gap: 8px;
    padding: 10px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    box-shadow: var(--m-sh-3);
    animation: m-bar-up .18s cubic-bezier(.2,.8,.3,1);
}

@keyframes m-bar-up { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.m-ab-top { display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.m-ab-actions { display: flex; gap: 8px; }
.m-ab-actions .m-btn { flex: 1 1 0; min-width: 0; }

/* Chip hành động: icon + chữ ngắn, cao 32px — gọn hơn nhiều so với .m-btn
   (44px, chiếm cả chiều ngang). KHÔNG cho xuống dòng. */
.m-body .m-chipbtn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    /* min-height BẮT BUỘC ghi kèm: luật chung `.m-body button { min-height:40px }`
       (vùng chạm) đè mất `height` nếu chỉ khai báo một mình. 34px vẫn đủ chạm. */
    height: 34px;
    min-height: 34px;
    padding: 0 11px 0 9px;
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-full);
    background: var(--m-surface-2, transparent);
    color: var(--m-text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, border-color .15s, transform .1s;
}

.m-chipbtn:active { transform: scale(.95); }
.m-chipbtn .rzi { font-size: 16px; }

.m-chipbtn-primary {
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #fff;
}

.m-icobtn-sm { width: 30px; height: 30px; flex: 0 0 auto; }

.m-pc-actionbar .m-sel-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.m-sel-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sel-uid { font-size: 11px; color: var(--m-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Đầu trang hồ sơ ─────────────────────────────────────────────────────── */
.m-prof-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px 14px;
    margin-bottom: 12px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    box-shadow: var(--m-sh-1);
}

.m-prof-av {
    width: 62px;
    height: 62px;
    border-radius: var(--m-r-full);
    background: var(--m-primary-soft);
    display: grid;
    place-items: center;
    margin-bottom: 4px;
}

.m-prof-av .rzi { font-size: 34px; color: var(--m-primary); }
.m-prof-name { font-weight: 700; font-size: 17px; }
.m-prof-role { font-size: 12.5px; color: var(--m-faint); }
.m-prof-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.m-prof-badges .m-chip.ok { background: rgba(22,163,74,.10); color: var(--m-success); border-color: rgba(22,163,74,.35); }
.m-prof-badges .m-chip .rzi { font-size: 13px; }

/* ── Danh sách thông tin khoá–giá trị + nút sao chép ────────────────────── */
.m-kv-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-md);
    overflow: hidden;
    background: var(--m-surface);
}

.m-kv {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 6px 9px 14px;
    border-bottom: 1px solid var(--m-line-soft);
    min-height: 46px;
}

.m-kv:last-child { border-bottom: 0; }

.m-kv-k {
    flex: 0 0 34%;
    font-size: 12.5px;
    color: var(--m-faint);
    font-weight: 600;
}

.m-kv-v {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 500;
    word-break: break-all;
}

/* Dòng khoá–giá trị dùng component TkText (IsCopy) thay cho nút chép tự dựng.
   app.css cho .tk-text-container là inline-flex và .tk-grid-text có margin-top
   0.4rem (hợp bảng desktop, lệch tim trong dòng cao 46px) → chỉnh lại tại đây. */
.m-app .m-kv .tk-text-container {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.m-app .m-kv .tk-grid-text {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0 !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    word-break: break-all;
}

.m-app .m-kv .tk-copy-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--m-r-sm);
    color: var(--m-faint);
}

.m-app .m-kv .tk-copy-icon.copied { color: var(--m-primary); }

/* Ô nhập nhiều dòng trong sheet (dán proxy / lệnh ADB) */
.m-app .m-input {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    line-height: 1.45;
    color: var(--m-text);
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-md);
    resize: vertical;
    /* iOS phóng to trang khi ô nhập có cỡ chữ < 16px lúc lấy focus — cỡ 14px ở
       trên là cho khổ chữ, còn dòng này giữ trang đứng yên. */
    -webkit-text-size-adjust: 100%;
}

.m-app .m-input:focus {
    outline: none;
    border-color: var(--m-primary);
}

.m-hint {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--m-faint);
}

/* Nhóm nút dưới sheet thông tin: xếp dọc, nút chính ở cuối */
.m-sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.m-sheet-actions .m-btn { width: 100%; }

.m-kv-copy {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--m-r-sm);
    background: transparent;
    color: var(--m-faint);
    cursor: pointer;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-kv-copy:active { background: var(--m-primary-soft); color: var(--m-primary); }
.m-kv-copy .rzi { font-size: 17px; }

/* ── Chế độ ĐIỀU KHIỂN: 1 máy CĂN GIỮA ─────────────────────────────────── */
.m-pc-wrap { position: relative; display: block; }

/* ⚠ phone.css đặt `#view-phone-mini { height: 100vh }` cho bản desktop → trên
   mobile khung cao đúng 1 màn hình, đẩy thanh điều khiển + ô nhập ra ngoài
   (đo được canvas bắt đầu ở 396px, ô nhập ở 1091px). Phải ghi đè về auto. */
.m-app #view-phone-mini,
.m-pc .m-pc-stage {
    height: auto !important;
    min-height: 0 !important;
}

.m-pc.expanded .m-pc-stage { min-width: 0; }

/* Căn ĐỀU cả ngang lẫn dọc — đệm ĐỐI XỨNG.
   KHÔNG chừa lề phải cho widget: widget nổi (fixed) và KÉO ĐƯỢC, nếu chừa lề thì
   máy bị đẩy lệch hẳn sang trái (đo được 86px). */
.m-pc-stage.is-expanded {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
    /* KHÔNG đặt min-height: nó đẩy khung cao lên làm thanh điều khiển + ô nhập
       rơi khỏi màn hình (đo được canvas chạm 876px trong khung 812px). */
}

.m-pc-stage.is-expanded .phone-mini { display: none !important; }

.m-pc-stage.is-expanded .phone-mini.is-active {
    /* ⚠ KHÔNG dùng display:block — là flex item nó sẽ giãn hết chiều ngang (đo được
       thẻ 339px trong khi canvas chỉ 252px) làm canvas dạt sang TRÁI 87px.
       inline-block co đúng bằng canvas → justify-content:center căn giữa chuẩn. */
    display: inline-block !important;
    flex: 0 0 auto !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: auto !important;
    max-width: 100%;
    height: auto !important;
    margin: 0 auto !important;
    background: #0b0d10;
    border: 1px solid var(--m-line) !important;
    border-radius: var(--m-r-lg) !important;
    overflow: hidden;
    box-shadow: var(--m-sh-3);
    line-height: 0;                     /* bỏ khoảng trắng dưới canvas */
}

/* Canvas giữ ĐÚNG tỉ lệ gốc: không ép aspect-ratio, không object-fit
   (canvas tự có kích thước nội tại từ thuộc tính width/height). */
.m-pc-stage.is-expanded .phone-mini.is-active canvas {
    display: block;
    width: auto !important;
    height: auto !important;
    max-width: 100%;
    /* Trừ đủ chrome để KHÔNG phải cuộn: app bar + đệm body + thanh tên + các
       khoảng cách + thanh Back/Home/Recents + ô nhập + tab bar + safe-area.
       Tổng phần cố định = 285px (đo trên máy thật: còn thiếu 11px thì ô nhập
       đè lên thanh tab, nên cộng thêm biên an toàn). */
    max-height: calc(100dvh - var(--m-appbar-h) - var(--m-safe-top) - var(--m-tabbar-h) - var(--m-safe-bot) - 285px);
    aspect-ratio: auto !important;
    object-fit: unset !important;
    border-radius: 0 !important;
    /* BẮT BUỘC: thiếu dòng này trình duyệt chiếm cử chỉ để cuộn/zoom
       trước khi preventDefault kịp tác dụng (một số bản Android). */
    touch-action: none;
}

/* Đã phóng to thì KHÔNG chặn chạm nữa — cảm ứng phải tới được canvas */
.m-pc-stage.is-expanded .phone-mini::after,
.m-pc-stage.is-expanded .phone-mini::before { content: none; }
.m-pc-stage.is-expanded .info-phone-details,
.m-pc-stage.is-expanded .section-phone-actions { display: none !important; }

/* ── Nút THOÁT nổi ở giữa phía trên ─────────────────────────────────────── */
.m-exit {
    position: fixed;
    top: calc(var(--m-appbar-h) + var(--m-safe-top) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9100;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-full);
    background: var(--m-surface);
    color: var(--m-text);
    box-shadow: var(--m-sh-3);
    cursor: pointer;
    opacity: .95;
    transition: transform .12s, background .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-exit:active { transform: translateX(-50%) scale(.9); background: var(--m-surface-2); }
.m-exit .rzi { font-size: 22px; }

/* Toàn màn hình: nút thoát bám sát mép trên */
.m-pc:fullscreen .m-exit { top: calc(var(--m-safe-top) + 10px); }

/* ── Widget: nút tròn nổi (kéo được) → mở ra VÒNG chức năng toả đều ────────
   Thu gọn = 1 nút tròn kéo được, vị trí nhớ ở localStorage bm_rail_pos.
   Mở ra   = vòng CĂN GIỮA màn hình: tâm ở giữa, các chức năng chia đều 360°.
   Căn giữa (không neo theo nút) để vòng KHÔNG BAO GIỜ tràn mép, dù nút đang
   nằm ở góc nào.                                                              */
.m-orb-fab {
    position: fixed;
    bottom: calc(var(--m-tabbar-h) + var(--m-safe-bot) + 96px);
    right: 10px;
    z-index: 9000;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-full);
    background: var(--m-surface);
    color: var(--m-primary);
    box-shadow: var(--m-sh-3);
    cursor: grab;
    touch-action: none;
    transition: transform .12s, background .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-orb-fab:active { cursor: grabbing; transform: scale(.93); }
.m-orb-fab .rzi { font-size: 23px; }

/* Nền mờ khi mở vòng — chạm ra ngoài là đóng */
.m-radial-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9400;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(1.5px);
    animation: m-fade-in .16s ease-out;
}

@keyframes m-fade-in { from { opacity: 0; } to { opacity: 1; } }

.m-radial {
    --r: 104px;              /* bán kính vòng */
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    z-index: 9401;
}

/* ⚠ Quy tắc toàn cục `.m-app * { max-width: 100% }` sẽ bóp các mục xuống còn
   14px vì container vòng có bề rộng 0 → vòng méo thành hình elip. Phải gỡ. */
.m-radial,
.m-radial-item,
.m-orb-fab { max-width: none !important; }

/* Mỗi mục: xoay quanh tâm theo góc chia đều rồi xoay ngược để chữ luôn thẳng */
.m-radial-item {
    position: absolute;
    left: 0;
    top: 0;
    width: 74px;
    height: 74px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-full);
    background: var(--m-surface);
    color: var(--m-text);
    cursor: pointer;
    box-shadow: var(--m-sh-2);
    -webkit-tap-highlight-color: transparent;
    /* translate(-50%,-50%) đặt CUỐI → áp trong hệ toạ độ riêng của nút, nên nút
       luôn căn tâm dù kích thước bao nhiêu (không phụ thuộc margin âm cố định). */
    transform:
        rotate(calc(var(--i) * (360deg / var(--n))))
        translateY(calc(-1 * var(--r)))
        rotate(calc(-1 * var(--i) * (360deg / var(--n))))
        translate(-50%, -50%);
    animation: m-radial-in .22s cubic-bezier(.2,.8,.3,1) backwards;
    animation-delay: calc(var(--i) * .03s);
}

@keyframes m-radial-in { from { opacity: 0; scale: .5; } to { opacity: 1; scale: 1; } }

.m-radial-item:active { filter: brightness(.94); }
.m-radial-item .rzi { font-size: 22px; color: var(--m-muted); }

.m-radial-label {
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    max-width: 66px;
    letter-spacing: -.2px;
}

.m-radial-item.sel {
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #fff;
}

.m-radial-item.sel .rzi { color: #fff; }

/* Hai hành động riêng: phóng to (xanh) và thoát (đỏ) */
.m-radial-act { border-color: var(--m-primary); color: var(--m-primary); }
.m-radial-act .rzi { color: var(--m-primary); }
.m-radial-danger { border-color: rgba(220,38,38,.5); color: var(--m-danger); }
.m-radial-danger .rzi { color: var(--m-danger); }

/* Khi đã bay vào giữa: chính nút này là TÂM vòng → đổi màu cho nổi bật.
   Phải nằm TRÊN nền mờ (z-index > backdrop) để bấm đóng được. */
.m-orb-fab.at-center {
    z-index: 9402;
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #fff;
    box-shadow: 0 6px 22px rgba(47,107,255,.55);
    cursor: pointer;
}

.m-orb-fab.at-center .rzi { color: #fff; font-size: 26px; }

/* Màn hẹp → thu bán kính cho vòng nằm gọn */
@media (max-width: 359px) {
    .m-radial { --r: 92px; }
    .m-radial-item { width: 66px; height: 66px; }
}

/* Bảng chức năng con: neo cố định ở đáy (widget di động nên neo theo nó sẽ tràn khung) */
/* ⚠ z-index PHẢI lớn hơn nền mờ (.m-radial-backdrop = 9400) và vòng chức năng
   (9401/9402). Trước đây để 9010 nên bảng bị chôn DƯỚI nền mờ: nhìn thì xám xịt,
   bấm thì không ăn — người dùng tưởng chức năng bị khoá. */
.m-rail-flyout {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--m-tabbar-h) + var(--m-safe-bot) + 10px);
    width: min(320px, calc(100vw - 24px));
    z-index: 9410;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    box-shadow: var(--m-sh-3);
    overflow: hidden;
    animation: m-fly-in .18s cubic-bezier(.2,.8,.3,1);
}

@keyframes m-fly-in {
    from { transform: translate(-50%, 12px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.m-rail-flyout-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 8px 10px 14px;
    border-bottom: 1px solid var(--m-line-soft);
    font-weight: 700;
    font-size: 13.5px;
}

.m-rail-flyout-head > span { flex: 1 1 auto; }
.m-rail-flyout-head .rzi { font-size: 19px; color: var(--m-primary); }
.m-rail-flyout-body { max-height: 44vh; overflow-y: auto; padding: 6px; }

.m-rail-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 0;
    background: transparent;
    color: var(--m-text);
    font-size: 14px;
    text-align: left;
    border-radius: var(--m-r-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.m-rail-item:active { background: var(--m-surface-2); }
.m-rail-item .rzi { font-size: 19px; color: var(--m-faint); }

/* ── Thanh Back/Home/Recents ────────────────────────────────────────────── */
.m-ctrl-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 6px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-md);
    padding: 5px;
    box-shadow: var(--m-sh-1);
}

.m-navbtn {
    flex: 1 1 0;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--m-muted);
    border-radius: var(--m-r-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.m-navbtn:active { background: var(--m-surface-2); color: var(--m-text); }
.m-navbtn .rzi { font-size: 20px; }

.m-ctrl-input { display: flex; gap: 8px; align-items: center; }


/* ── Toàn màn hình: CHỈ còn màn hình máy, sát viền 100% ─────────────────────
   Bỏ hết thanh tên / ô nhập / Back-Home-Recents — hai nút phóng-to và thoát
   đã chuyển vào WIDGET tròn nên không cần thanh nào nữa.                      */
.m-pc:fullscreen {
    background: #000;
    padding: 0 !important;
    gap: 0 !important;
    width: 100vw;
    height: 100dvh;
}

.m-pc:fullscreen .m-pc-bar,
.m-pc:fullscreen .m-ctrl-input,
.m-pc:fullscreen .m-ctrl-nav,
.m-pc:fullscreen .m-exit { display: none !important; }

.m-pc:fullscreen .m-pc-wrap {
    display: block !important;
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 0 !important;
}

.m-pc:fullscreen .m-pc-stage {
    display: block !important;
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding: 0 !important;
}

.m-pc:fullscreen .phone-mini.is-active {
    display: block !important;
    width: 100vw !important;
    height: 100dvh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #000;
    /* Gỡ mọi style inline còn sót của setOrientationLock */
    transform: none !important;
    position: relative !important;
}

/* Canvas SÁT VIỀN 100%. object-fit:contain giữ đúng tỉ lệ máy (không méo hình);
   KHÔNG xoay / định vị tuyệt đối — đó là nguyên nhân màn đen trước đây.
   ⚠ `!important` là BẮT BUỘC: luật .m-pc-stage.is-expanded ở trên đặt
   `object-fit: unset !important` (khung vẫn giữ class is-expanded khi vào toàn
   màn hình) → thiếu !important ở đây thì object-fit rơi về `fill` và hình bị
   kéo giãn (đo thực tế: canvas 800×384 bị ép thành 430×932). */
.m-pc:fullscreen .phone-mini.is-active canvas {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block;
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    border-radius: 0 !important;
}

/* Bảng chức năng con neo sát đáy (không còn thanh tab khi toàn màn hình) */
.m-pc:fullscreen .m-rail-flyout {
    bottom: calc(16px + var(--m-safe-bot));
    z-index: 9510;   /* trên nền mờ 9501 và vòng 9502/9503 của chế độ toàn màn hình */
}

/* Widget PHẢI luôn thấy khi toàn màn hình (không còn thanh tab để trừ chỗ).
   JS keepOrbVisible() còn kẹp lại nếu vị trí đã kéo nằm ngoài khung mới. */
.m-pc:fullscreen .m-orb-fab {
    display: grid !important;
    bottom: calc(20px + var(--m-safe-bot));
    right: 16px;
    z-index: 9500;
}

.m-pc:fullscreen .m-radial-backdrop { z-index: 9501; }
.m-pc:fullscreen .m-radial { z-index: 9502; }
.m-pc:fullscreen .m-orb-fab.at-center { z-index: 9503; }

/* Máy XOAY NGANG: canvas thành khổ ngang. object-fit:contain giữ ĐÚNG tỉ lệ
   (không méo) và toạ độ chạm vẫn khớp vì KHÔNG dùng transform xoay.
   Trang được khoá theo chiều ngang trong enterFullscreen nên hình lấp đầy. */
@media (orientation: landscape) {
    .m-pc:fullscreen .phone-mini.is-active canvas {
        width: 100vw !important;
        height: 100dvh !important;
        object-fit: contain !important;
    }
}

/* ── LỆCH CHIỀU: máy ngang mà trang dọc (hoặc ngược lại) ────────────────────
   Khoá xoay trang (screen.orientation.lock) chỉ chạy trên Android Chrome; iOS
   Safari và trình duyệt máy tính KHÔNG hỗ trợ → nếu chỉ dùng contain thì hình
   co thành một dải mỏng giữa nền đen (430×206 trên khung 430×932).
   Cách xử lý: bố trí canvas theo chiều NGƯỢC LẠI của khung rồi xoay 90°.
   Khung bao sau khi xoay đúng bằng khung nhìn ⇒ lấp đầy, đúng tỉ lệ, không méo.
   Toạ độ chạm được bù trong core-fix.js theo data-bmrot="90" (bắt buộc — nếu
   thiếu thì chạm bị lệch 90° và mất điều khiển). */
.m-pc:fullscreen.bm-rot90 .phone-mini.is-active canvas {
    width: 100dvh !important;
    height: 100vw !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    margin: 0 !important;
    /* translate ĐỨNG TRƯỚC rotate và tính theo kích thước CHÍNH nó (chưa xoay)
       → tâm canvas trùng tâm khung nhìn ở mọi tỉ lệ. */
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center center !important;
    object-fit: contain !important;
}

.m-pc:fullscreen.bm-rot90 .phone-mini.is-active {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
}
