/* Tab Giao dịch (#tonghop-tab) — mobile ≤768px; desktop không đổi */

@media (min-width: 769px) {
    #tonghop-tab .th-mobile-nav,
    #tonghop-tab .th-mobile-sheet-backdrop,
    #tonghop-tab .th-mobile-sheet-head {
        display: none !important;
    }

    #tonghop-tab .th-detail-body {
        display: block;
        flex: none;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    #tonghop-tab.active {
        min-height: calc(100dvh - var(--str-tabs-height, 52px));
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #tonghop-tab .th-container {
        padding: 8px 8px calc(62px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
        height: auto !important;
        max-height: none !important;
        min-height: calc(100dvh - var(--str-tabs-height, 52px) - 16px);
        overflow: visible !important;
        border-radius: 10px;
    }

    #tonghop-tab .th-ticker-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 0 2px 4px;
    }

    #tonghop-tab .th-ticker-bar-label {
        font-size: 11px;
        font-weight: 700;
        color: var(--str-text-muted, #64748b);
    }

    #tonghop-tab .th-ticker-toggle {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 11px;
        touch-action: manipulation;
    }

    #tonghop-tab .th-ticker-wrap.collapsed .th-ticker {
        display: none;
    }

    #tonghop-tab .th-ticker {
        gap: 6px;
        padding-bottom: 4px;
    }

    #tonghop-tab .th-ticker-card {
        min-width: 108px;
        max-width: 124px;
        padding: 6px 8px;
        touch-action: manipulation;
    }

    #tonghop-tab .th-main {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        gap: 0;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #tonghop-tab .th-left,
    #tonghop-tab .th-right {
        display: none;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
    }

    #tonghop-tab .th-center {
        flex: 1;
        min-height: 320px;
        gap: 8px;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #tonghop-tab.th-m-view-chart .th-table-wrap {
        display: none !important;
    }

    #tonghop-tab.th-m-view-list .th-chart-wrap {
        display: none !important;
    }

    #tonghop-tab.th-m-view-chart .th-chart-wrap {
        flex: 1;
        min-height: min(52dvh, 420px);
        max-height: 58dvh;
    }

    #tonghop-tab.th-m-view-list .th-table-wrap {
        flex: 1;
        min-height: min(58dvh, 480px);
        display: flex;
        flex-direction: column;
    }

    #tonghop-tab .th-chart-head {
        padding: 8px 10px;
        gap: 8px;
    }

    #tonghop-tab .th-chart-title {
        font-size: 12px;
        flex: 1 1 100%;
        line-height: 1.35;
    }

    #tonghop-tab .th-chart-tfs {
        flex: 1 1 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    #tonghop-tab .th-chart-tfs::-webkit-scrollbar {
        display: none;
    }

    #tonghop-tab .th-tf-btn {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 4px 10px;
        font-size: 11px;
        touch-action: manipulation;
    }

    #tonghop-tab .th-open-full-chart {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 6px 10px;
        font-size: 11px;
        touch-action: manipulation;
    }

    #tonghop-tab #th-chart.th-chart,
    #tonghop-tab .th-chart {
        min-height: 200px;
    }

    #tonghop-tab .th-table-tabs {
        padding: 6px 8px;
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #tonghop-tab .th-table-tabs::-webkit-scrollbar {
        display: none;
    }

    #tonghop-tab .th-cat-btn,
    #tonghop-tab .th-order-subfilter-btn {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 6px 12px;
        font-size: 11px;
        touch-action: manipulation;
    }

    #tonghop-tab .th-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #tonghop-tab .th-table .th-m-hide {
        display: none !important;
    }

    #tonghop-tab .th-table th.th-col-code,
    #tonghop-tab .th-table td.td-code {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--str-bg-surface, #f8fafc);
        box-shadow: 3px 0 8px rgba(0, 0, 0, 0.08);
    }

    #tonghop-tab .th-table th.th-col-name,
    #tonghop-tab .th-table td.td-name {
        position: sticky;
        left: 52px;
        z-index: 1;
        background: var(--str-bg-surface, #f8fafc);
        max-width: 96px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #tonghop-tab .th-table thead th {
        z-index: 3;
    }

    #tonghop-tab .th-order-table {
        font-size: 11px;
        min-width: 640px;
    }

    #tonghop-tab .th-order-table th,
    #tonghop-tab .th-order-table td {
        padding: 8px 6px;
    }

    /* Sheet Chi tiết / Đặt lệnh */
    #tonghop-tab.th-m-sheet-detail .th-left,
    #tonghop-tab.th-m-sheet-order .th-right {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 10060;
        margin: 0;
        padding: 0;
        border-radius: 0;
        background: var(--str-bg-base, #0a0a0a);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }

    #tonghop-tab .th-mobile-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
        flex-shrink: 0;
        border-bottom: 1px solid var(--str-border-subtle, rgba(255, 255, 255, 0.12));
        background: var(--str-bg-surface, rgba(15, 23, 42, 0.85));
        color: var(--str-text-main, #f8fafc);
    }

    #tonghop-tab .th-mobile-sheet-close {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        border: 1px solid var(--str-border-subtle, rgba(255, 255, 255, 0.15));
        background: var(--str-bg-card, #141414);
        color: inherit;
        font-size: 1.2rem;
        line-height: 1;
        cursor: pointer;
        touch-action: manipulation;
    }

    #tonghop-tab .th-detail-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px 12px 16px;
    }

    #tonghop-tab.th-m-sheet-order .th-right #sps-order-drawer.inline {
        flex: 1;
        min-height: 0;
        display: flex !important;
        flex-direction: column;
    }

    #tonghop-tab.th-m-sheet-order .th-right #sps-order-drawer.inline .sps-drawer-content {
        flex: 1;
        min-height: 0;
        max-height: none !important;
        height: auto !important;
        border-radius: 0 !important;
        padding: 8px 10px 16px !important;
    }

    #tonghop-tab .th-mobile-sheet-backdrop {
        position: fixed;
        inset: 0;
        z-index: 10050;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    #tonghop-tab .th-mobile-sheet-backdrop[hidden] {
        display: none !important;
    }

    body.th-mobile-sheet-open {
        overflow: hidden;
    }

    /* Bottom nav */
    #tonghop-tab .th-mobile-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10040;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        gap: 4px;
        background: linear-gradient(to top, var(--str-bg-base, #0a0a0a) 88%, transparent);
        border-top: 1px solid var(--str-border-subtle, rgba(255, 255, 255, 0.1));
        box-sizing: border-box;
    }

    #tonghop-tab .th-mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 48px;
        padding: 4px 2px;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--str-text-muted, #94a3b8);
        font-size: 10px;
        font-weight: 700;
        line-height: 1.2;
        cursor: pointer;
        touch-action: manipulation;
    }

    #tonghop-tab .th-mobile-nav-btn span:first-child {
        font-size: 16px;
        line-height: 1;
    }

    #tonghop-tab .th-mobile-nav-btn.active {
        background: var(--str-accent-soft, rgba(59, 130, 246, 0.2));
        color: var(--str-accent, #3b82f6);
    }
}
