/**
 * XirevoBot — Mobile app chrome (phones / small tablets only).
 * Desktop layouts stay unchanged: all rules live under max-width: 768px.
 */
@media (max-width: 768px) {
    :root {
        --m-pad: .85rem;
        --m-radius: 14px;
        --m-tap: 48px;
        --m-dock-h: 64px;
        --m-safe-b: env(safe-area-inset-bottom, 0px);
    }

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        overscroll-behavior-y: contain;
    }

    /* ---- Public site ---- */
    .site-header .container-x,
    .container-x {
        padding-inline: var(--m-pad);
    }

    .btn-x,
    .btn-primary-x,
    .btn-outline-x,
    button.btn-x {
        min-height: var(--m-tap);
        padding-inline: 1rem;
        font-size: .95rem;
        border-radius: 12px;
    }

    .card-x {
        border-radius: var(--m-radius);
        padding: 1rem;
    }

    .form-control,
    .form-select,
    input.form-control,
    select.form-select,
    textarea.form-control {
        min-height: var(--m-tap);
        font-size: 16px; /* avoid iOS zoom */
        border-radius: 12px;
    }

    /* ---- Panel shell (non-immersive) ---- */
    .panel:not(.is-immersive) .panel-topbar {
        height: 56px;
        padding-inline: .75rem;
        gap: .55rem;
    }

    .panel:not(.is-immersive) .page-title {
        font-size: .98rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 42vw;
    }

    .panel:not(.is-immersive) .panel-content {
        padding: .85rem var(--m-pad) calc(var(--m-dock-h) + var(--m-safe-b) + .85rem);
    }

    .panel:not(.is-immersive) .panel-nav a {
        min-height: var(--m-tap);
        padding: .85rem 1rem;
        font-size: 1rem;
        border-radius: 12px;
    }

    .panel:not(.is-immersive) .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .55rem;
    }

    .panel:not(.is-immersive) .kpi {
        border-radius: 12px;
        padding: .75rem .85rem;
    }

    .panel:not(.is-immersive) .kpi-value {
        font-size: 1.15rem;
    }

    .panel:not(.is-immersive) .table-wrap {
        margin-inline: calc(var(--m-pad) * -0.15);
        border-radius: 12px;
    }

    .panel:not(.is-immersive) .table-x {
        min-width: 480px;
    }

    .panel:not(.is-immersive) .table-x th,
    .panel:not(.is-immersive) .table-x td {
        padding: .7rem .75rem;
        font-size: .86rem;
    }

    /* Bottom dock — client / admin panels only */
    .m-dock {
        display: flex;
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 90;
        height: calc(var(--m-dock-h) + var(--m-safe-b));
        padding: .35rem .4rem var(--m-safe-b);
        background: rgba(255, 255, 255, .96);
        border-top: 1px solid var(--border, #e8ecf1);
        box-shadow: 0 -8px 24px rgba(15, 23, 42, .08);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        justify-content: space-around;
        align-items: stretch;
        gap: .15rem;
    }

    .m-dock a {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .15rem;
        min-width: 0;
        text-decoration: none;
        color: var(--text-2, #64748b);
        font-size: .68rem;
        font-weight: 700;
        border-radius: 12px;
        padding: .35rem .2rem;
        line-height: 1.15;
        text-align: center;
    }

    .m-dock a .m-dock-ico {
        font-size: 1.15rem;
        line-height: 1;
        width: 1.4rem;
        height: 1.4rem;
        display: grid;
        place-items: center;
    }

    .m-dock a.is-on {
        color: var(--orange, #FF7A00);
        background: var(--orange-soft, rgba(255, 122, 0, .12));
    }

    .m-dock a span.m-dock-lbl {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Immersive floors: no dock */
    .body-trading-floor .m-dock,
    .panel.is-immersive ~ .m-dock,
    .panel.is-immersive .m-dock {
        display: none !important;
    }

    /* ---- Trading floor (immersive) ---- */
    .panel.is-immersive .panel-topbar.tf-topbar {
        height: auto;
        min-height: 52px;
        flex-wrap: wrap;
        padding: .45rem .65rem;
        gap: .4rem .55rem;
        row-gap: .45rem;
    }

    .panel.is-immersive .tf-brand {
        font-size: 1.05rem;
    }

    .panel.is-immersive .tf-owner-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: .35rem;
        width: 100%;
        order: 3;
        padding-bottom: .15rem;
        scrollbar-width: none;
    }

    .panel.is-immersive .tf-owner-nav::-webkit-scrollbar {
        display: none;
    }

    .panel.is-immersive .tf-owner-nav a {
        flex: 0 0 auto;
        white-space: nowrap;
        min-height: 36px;
        padding: .4rem .75rem;
        font-size: .8rem;
        border-radius: 999px;
    }

    .panel.is-immersive .panel-content.tf-content {
        padding: 0;
        overflow-x: hidden;
    }

    .tf-floor {
        display: flex;
        flex-direction: column;
        gap: 0;
        min-height: 100%;
        padding-bottom: calc(4.5rem + var(--m-safe-b));
    }

    .tf-command {
        padding: .65rem var(--m-pad);
        gap: .45rem;
    }

    .tf-command h1 {
        font-size: 1.15rem;
        margin: 0;
    }

    .tf-status-row {
        display: flex;
        flex-wrap: wrap;
        gap: .35rem;
    }

    .tf-status-row .pill {
        font-size: .72rem;
        padding: .28rem .55rem;
    }

    .tf-kpi.kpi-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        margin: 0;
        border-block: 1px solid var(--border, #e8ecf1);
    }

    .tf-kpi .kpi {
        padding: .65rem .75rem;
        border: 0;
        border-inline-end: 1px solid var(--border, #e8ecf1);
        border-bottom: 1px solid var(--border, #e8ecf1);
    }

    .tf-kpi .kpi:nth-child(2n) {
        border-inline-end: 0;
    }

    .tf-kpi .kpi-label {
        font-size: .72rem;
    }

    .tf-kpi .kpi-value {
        font-size: 1.1rem;
        font-weight: 800;
    }

    .tf-stage.is-stack,
    .tf-stage {
        display: block;
        max-height: none;
    }

    .tf-chart-card {
        border: 0;
        padding: 0;
        min-height: 0;
    }

    .ct-tf-bar,
    .ct-tf-row {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: .35rem;
        padding: .45rem var(--m-pad);
        margin: 0 !important;
        scrollbar-width: none;
    }

    .ct-tf-bar::-webkit-scrollbar,
    .ct-tf-row::-webkit-scrollbar {
        display: none;
    }

    .ct-tf-bar .btn-x,
    .ct-tf-row .btn-x,
    .ct-tf-bar a,
    .ct-tf-row a {
        flex: 0 0 auto;
        min-height: 36px;
        padding: .35rem .7rem;
        font-size: .78rem;
        white-space: nowrap;
    }

    /* Command center: chart first, then controls, then extras */
    .xcc {
        padding: .35rem 0 1rem;
    }

    .xcc-think-strip {
        margin-inline: var(--m-pad);
        border-radius: 12px;
        font-size: .8rem;
    }

    .xcc-folder {
        margin-inline: var(--m-pad);
        border-radius: 12px;
    }

    .xcc-folder > summary {
        min-height: 44px;
        font-size: .88rem;
    }

    .xcc-grid {
        display: flex;
        flex-direction: column;
        gap: .65rem;
    }

    .xcc-col-main {
        display: flex;
        flex-direction: column;
        gap: .65rem;
        order: 1;
    }

    .xcc-col-side {
        order: 3;
        display: flex;
        flex-direction: column;
        gap: .55rem;
        padding-inline: var(--m-pad);
    }

    .xcc-chart-card {
        order: -2;
        border-radius: 0;
        border-inline: 0;
        margin: 0;
    }

    .xcc-chart-head {
        padding-inline: var(--m-pad);
    }

    .xcc-chart-note {
        display: none;
    }

    .xcc-gauges {
        order: 2;
        display: grid;
        grid-template-columns: 1fr;
        gap: .55rem;
        padding-inline: var(--m-pad);
    }

    .xcc-gauge,
    .xcc-radar,
    .xcc-server-mini,
    .xcc-card {
        border-radius: var(--m-radius);
    }

    .live-chart-wrap.tf-chart-wrap,
    .tf-stage.is-stack .tf-chart-wrap,
    .tf-chart-wrap {
        height: min(48vh, 360px);
        min-height: 260px;
        border-radius: 0;
    }

    .tf-tv-caption {
        padding: .45rem var(--m-pad);
        font-size: .8rem;
        gap: .35rem;
    }

    /* Trade controls: sticky bottom dock on phone */
    .xcc-pro-under {
        order: 1;
        position: sticky;
        bottom: 0;
        z-index: 55;
        margin: 0;
        padding: .55rem var(--m-pad) calc(.55rem + var(--m-safe-b));
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid var(--border, #e8ecf1);
        box-shadow: 0 -10px 28px rgba(15, 23, 42, .1);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .xcc-pro-under .tf-pro {
        margin: 0;
        border: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    .tf-pro-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .55rem;
    }

    .tf-pro-field.tf-pro-mode,
    .tf-pro-field.tf-pro-sides,
    .tf-pro-actions {
        grid-column: 1 / -1;
    }

    .tf-pro-label {
        font-size: .75rem;
        margin-bottom: .2rem;
    }

    .tf-pro-actions {
        display: flex;
        flex-direction: column;
        gap: .45rem;
        margin-top: .15rem;
    }

    .tf-pro-actions .tf-run,
    .tf-pro-actions .btn-x {
        width: 100%;
        min-height: 52px;
        font-size: 1.05rem;
        font-weight: 800;
        border-radius: 14px;
    }

    .tf-pro-symbols,
    .od-symbol-row {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: .35rem;
        padding-bottom: .15rem;
        scrollbar-width: none;
    }

    .tf-pro-symbols::-webkit-scrollbar,
    .od-symbol-row::-webkit-scrollbar {
        display: none;
    }

    .od-sym {
        flex: 0 0 auto;
        min-height: 36px;
        padding: .4rem .7rem;
    }

    .tf-market-badge {
        margin-bottom: .45rem;
        border-radius: 14px;
    }

    .tf-market-badge-text strong {
        font-size: 1.05rem;
    }

    .tf-link-icons {
        display: none; /* checklist icons clutter phone; link status stays in pills */
    }

    .tf-bottom {
        display: flex;
        flex-direction: column;
        max-height: none;
        gap: 0;
    }

    .tf-bottom > .card-x {
        max-height: none;
        border: 0;
        border-top: 1px solid var(--border, #e8ecf1);
        border-radius: 0;
        padding: .85rem var(--m-pad) 1.1rem;
    }

    .tf-bottom .ct-section-head h3 {
        font-size: 1rem;
    }

    .tf-bottom .table-x {
        min-width: 520px;
    }

    .tf-bottom .btn-close-trade {
        min-height: 40px;
        padding: .45rem .75rem;
        font-size: .85rem;
    }

    .tf-trade-toast {
        bottom: calc(5.2rem + var(--m-safe-b));
        left: var(--m-pad);
        right: var(--m-pad);
        transform: none;
        max-width: none;
        width: auto;
    }

    /* Setup / wallet / billing pages */
    .setup-steps,
    .wallet-grid,
    .bill-grid,
    .od-grid-2,
    .od-grid-3,
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr !important;
    }

    .switch-row {
        min-height: var(--m-tap);
        gap: .75rem;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    .tf-kpi.kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .m-dock a .m-dock-lbl {
        font-size: .62rem;
    }

    .xcc-pro-under .tf-pro-controls {
        grid-template-columns: 1fr;
    }
}

/* Hide dock on desktop always */
@media (min-width: 769px) {
    .m-dock {
        display: none !important;
    }
}
