/* ==========================================================================
   Mobile layout: a separate app shell shown only under the breakpoint below.
   Desktop (#app) is untouched; this never loads/renders anything different
   on desktop, it just stays display:none until the viewport is narrow.
   ========================================================================== */
#mobile-app { display: none; }

@media (max-width: 760px) {
    #app { display: none !important; }
    #ticker-bg { display: none !important; }
    #mobile-app { display: flex; flex-direction: column; height: 100vh; background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; }
}

#mobile-app * { box-sizing: border-box; }

/* ---------------- header ---------------- */
#m-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    background: var(--panel);
}
.m-header-left { display: flex; align-items: center; gap: 10px; }
.m-logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #04121c; font-size: 15px;
}
.m-title { font-size: 13.5px; font-weight: 700; letter-spacing: 0.2px; }
.m-status { font-size: 10.5px; color: var(--green); display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.m-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
.m-header-right { display: flex; align-items: center; gap: 8px; }
.m-icon-btn {
    position: relative; width: 36px; height: 36px; border-radius: 10px;
    background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
    display: flex; align-items: center; justify-content: center; font-size: 15px; cursor: pointer;
}
.m-badge {
    position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff;
    font-size: 9px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ---------------- content / views ---------------- */
#m-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 90px; -webkit-overflow-scrolling: touch; }
.m-view { display: none; }
.m-view.active { display: block; }
.m-view-title { font-size: 19px; font-weight: 800; margin: 2px 0 16px; }
.m-back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.m-back-btn { font-size: 20px; color: var(--text-dim); cursor: pointer; }

/* ---------------- bottom nav ---------------- */
#m-bottom-nav {
    display: flex; flex-shrink: 0; border-top: 1px solid var(--border); background: var(--panel);
    position: fixed; bottom: 0; left: 0; right: 0; padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 0 8px; color: var(--text-dim); font-size: 10.5px; font-weight: 600; cursor: pointer;
}
.m-nav-icon { font-size: 19px; }
.m-nav-item.active { color: var(--cyan); }

/* ---------------- stat card grid (Home) ---------------- */
.m-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.m-stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.m-stat-card .m-stat-top { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 11.5px; font-weight: 600; margin-bottom: 8px; }
.m-stat-card .m-stat-icon {
    width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.m-stat-card .m-stat-val { font-size: 19px; font-weight: 800; }
.m-stat-val.pos { color: var(--green); }
.m-stat-val.neg { color: var(--red); }

.m-section-title { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; margin: 4px 0 10px; display: flex; justify-content: space-between; align-items: center; }
.m-section-title .m-see-all { color: var(--cyan); font-size: 12px; text-transform: none; font-weight: 600; cursor: pointer; }

/* ---------------- bot / list rows ---------------- */
.m-search {
    display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; color: var(--text-dim); font-size: 13px;
}
.m-search input { flex: 1; background: none; border: none; color: var(--text); font-size: 13px; outline: none; font-family: inherit; }
.m-filter-tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.m-filter-tab {
    flex-shrink: 0; padding: 7px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
    background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; white-space: nowrap;
}
.m-filter-tab.active { background: var(--cyan-soft); color: var(--cyan); border-color: var(--cyan); }

.m-bot-row, .m-list-row {
    display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
}
.m-bot-icon {
    width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center;
    justify-content: center; font-size: 17px; background: var(--panel-2);
}
.m-bot-row-mid { flex: 1; min-width: 0; }
.m-bot-row-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-bot-row-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.m-bot-row-right { text-align: right; flex-shrink: 0; }
.m-bot-row-pnl { font-size: 13px; font-weight: 700; }
.m-status-pill { font-size: 9.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-top: 4px; display: inline-block; }
.m-status-pill.on { background: var(--green-soft); color: var(--green); }
.m-status-pill.off { background: var(--panel-2); color: var(--text-dim); }

/* ---------------- bot detail ---------------- */
.m-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.m-detail-stats .m-stat-mini { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 11px; }
.m-detail-stats .m-stat-mini .label { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.m-detail-stats .m-stat-mini .val { font-size: 14px; font-weight: 700; }
.m-tabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.m-tab { flex: 1; text-align: center; padding: 8px 0; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.m-tab.active { background: var(--panel); color: var(--text); }
.m-info-row { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.m-info-row:last-child { border-bottom: none; }
.m-info-row span:last-child { color: var(--text); font-weight: 600; }

.m-primary-btn {
    display: block; width: 100%; padding: 14px; border-radius: 12px; border: none; font-size: 14px; font-weight: 700;
    cursor: pointer; text-align: center; background: var(--blue); color: #fff; margin-top: 6px;
}
.m-primary-btn.danger { background: var(--red); }
.m-primary-btn.success { background: var(--green); color: #04231b; }
.m-secondary-btn {
    display: block; width: 100%; padding: 13px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-align: center; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); margin-top: 10px;
}

/* ---------------- positions / history cards ---------------- */
.m-trade-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; }
.m-trade-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.m-trade-symbol { font-size: 13.5px; font-weight: 700; }
.m-trade-acct { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }
.m-trade-pnl { font-size: 14px; font-weight: 800; }
.m-trade-meta { display: flex; gap: 14px; font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.m-trade-meta b { color: var(--text); font-weight: 600; }

/* ---------------- notifications ---------------- */
.m-notif-row { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.m-notif-row:last-child { border-bottom: none; }
.m-notif-icon { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.m-notif-body { flex: 1; min-width: 0; }
.m-notif-title { font-size: 13px; font-weight: 700; }
.m-notif-detail { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }
.m-notif-time { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; opacity: 0.8; }

/* ---------------- more / settings menu ---------------- */
.m-menu-group { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 16px; overflow: hidden; }
.m-menu-row {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 13.5px; font-weight: 600;
    border-bottom: 1px solid var(--border); cursor: pointer;
}
.m-menu-row:last-child { border-bottom: none; }
.m-menu-row .m-menu-icon { font-size: 16px; width: 22px; text-align: center; }
.m-menu-row .m-menu-arrow { margin-left: auto; color: var(--text-dim); }
.m-menu-row.danger { color: var(--red); }

.m-profile-card { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.m-profile-avatar {
    width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    display: flex; align-items: center; justify-content: center; font-weight: 800; color: #04121c; font-size: 18px;
}
.m-profile-name { font-size: 15px; font-weight: 700; }
.m-profile-role { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* ---------------- login screen ---------------- */
#m-view-login { padding-top: 40px; }
.m-login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 36px; }
.m-login-logo .m-logo { width: 62px; height: 62px; border-radius: 16px; font-size: 26px; margin-bottom: 14px; }
.m-login-logo .m-login-title { font-size: 18px; font-weight: 800; }
.m-login-logo .m-login-tag { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.m-field-label { font-size: 12px; color: var(--text-dim); font-weight: 600; margin: 14px 0 6px; }
.m-input {
    width: 100%; background: var(--panel); border: 1px solid var(--border); color: var(--text);
    padding: 13px 14px; border-radius: 12px; font-family: 'Inter', sans-serif; font-size: 14px;
}
.m-login-error { color: var(--red); font-size: 12.5px; margin-top: 10px; }
.m-login-note { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 20px; line-height: 1.6; }

/* ---------------- bottom sheet (confirm) ---------------- */
.m-sheet-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 60; display: none;
    align-items: flex-end; justify-content: center;
}
.m-sheet-overlay.open { display: flex; }
.m-sheet-box {
    background: var(--panel); border-radius: 20px 20px 0 0; width: 100%; max-width: 480px;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0));
}
.m-sheet-box h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.m-sheet-box p { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; margin: 0 0 18px; }

.m-empty { text-align: center; color: var(--text-dim); padding: 40px 0; font-size: 13px; }
