/* ==========================================================================
   mobile.css — Global mobile responsiveness for TheProfitEra
   Loaded after all other CSS files to override on small screens.
   Breakpoints: 1024px (tablet), 768px (mobile), 480px (small mobile)
   ========================================================================== */

/* --------------------------------------------------------------------------
   GLOBAL — prevent horizontal scroll, ensure proper viewport
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;
}

/* Ensure all buttons have minimum touch target size on mobile */
@media (max-width: 768px) {
    button, .btn, .nav-link, a.btn, input[type="submit"], input[type="button"] {
        min-height: 40px;
        min-width: 40px;
    }

    /* Larger touch targets for critical actions */
    .pt-pos-btn, .pt-pag-btn, .pt-qty-quick button, .pt-qty-step {
        min-height: 44px;
        min-width: 44px;
    }

    .pt-modal-submit, .pt-modal-cancel {
        min-height: 48px;
        font-size: 0.95rem !important;
    }
}

/* --------------------------------------------------------------------------
   NAVBAR / HEADER
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .main-header .navbar-brand .brand-text {
        font-size: 1.05rem;
    }

    .main-header .navbar-brand img {
        height: 32px;
        width: 32px;
    }
}

@media (max-width: 768px) {
    .main-header.navbar {
        min-height: 50px;
        padding: 0 6px;
    }

    /* Force single-row header on mobile */
    .main-header .container-fluid {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 4px;
    }

    .main-header .navbar-brand {
        gap: 4px;
        padding: 3px 4px;
        flex-shrink: 0;
    }

    /* Hide brand text on small screens — logo only */
    .main-header .navbar-brand .brand-text {
        display: none !important;
    }

    .main-header .navbar-brand img {
        height: 28px;
        width: 28px;
    }

    .main-header .navbar-brand .brand-trademark {
        font-size: 0.5rem;
    }

    /* Compact index chips — stacked layout to save width */
    .header-index-ticker {
        gap: 3px;
        margin-left: 2px;
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .header-index-chip {
        padding: 2px 6px;
        gap: 2px;
        flex-direction: column;
        align-items: flex-start;
        line-height: 1.1;
    }

    .header-index-name {
        font-size: 0.5rem;
        line-height: 1;
    }

    .header-index-value {
        font-size: 0.6rem;
        line-height: 1;
    }

    .header-index-change {
        font-size: 0.52rem;
        line-height: 1;
    }

    /* Collapse menu — full-width dropdown */
    .navbar-collapse {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        z-index: 1030;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    }

    .navbar-collapse.show {
        max-height: 500px;
        overflow-y: auto;
    }

    .navbar-collapse .navbar-nav {
        flex-direction: column;
        padding: 10px 14px;
        gap: 4px;
    }

    .navbar-collapse .nav-link {
        padding: 12px 14px !important;
        font-size: 0.9rem;
        border-radius: 10px;
        width: 100%;
    }

    .navbar-collapse .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        background: rgba(0, 0, 0, 0.3);
        border: none;
        box-shadow: none;
        padding: 4px 0;
        margin: 4px 0;
    }

    .navbar-collapse .dropdown-item {
        color: rgba(255, 255, 255, 0.8) !important;
        padding: 10px 24px;
    }

    .navbar-toggler {
        padding: 6px 10px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
    }

    .navbar-toggler-icon {
        width: 1.2em;
        height: 1.2em;
    }

    /* User menu in mobile collapse */
    .user-menu .dropdown-menu {
        min-width: 100% !important;
    }

    .user-menu .user-header {
        padding: 14px;
    }

    .header-market-status {
        display: none !important;
    }

    .theme-toggle-btn {
        width: 36px;
        height: 36px;
    }

    .login-btn {
        padding: 10px 16px !important;
        font-size: 0.8rem !important;
        width: 100%;
        justify-content: center;
    }
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .main-footer {
        padding: 0;
    }

    .footer-inner {
        flex-direction: column;
        gap: 8px;
        padding: 10px 14px;
        text-align: center;
    }

    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .footer-links a {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .footer-disclaimer {
        font-size: 0.62rem;
        padding: 6px 14px 10px;
        text-align: center;
    }

    .footer-social {
        display: none;
    }

    .content-wrapper {
        padding-bottom: 60px;
    }
}

/* --------------------------------------------------------------------------
   LANDING PAGE (index.css overrides)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .hero-content {
        flex-direction: column;
        text-align: center;
    }

    .hero-actions {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 1.35rem !important;
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 0.8rem !important;
        line-height: 1.5;
    }

    .hero-stats {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }

    .hero-stat-card {
        min-width: 80px;
        padding: 8px 12px;
    }

    .hero-stat-value {
        font-size: 1rem;
    }

    .hero-stat-label {
        font-size: 0.6rem;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .btn-hero {
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.85rem;
    }

    .dashboard-container {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .dashboard-sidebar {
        flex-direction: column !important;
    }

    .dashboard-sidebar > .dash-card {
        min-width: 0 !important;
    }

    .movers-grid {
        grid-template-columns: 1fr !important;
    }

    .tools-grid {
        grid-template-columns: 1fr !important;
    }

    .dash-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px;
    }

    .dash-tab {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 0.72rem;
        padding: 8px 12px;
    }

    .dash-tab-content {
        height: auto !important;
        min-height: 280px !important;
    }

    .search-box-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .search-exchange-toggle {
        justify-content: center;
    }

    .index-cards-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .index-card {
        min-width: 120px;
        flex: 1 1 120px;
    }

    /* News articles horizontal scroll on mobile */
    .articles-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
    }

    .article-card {
        scroll-snap-align: start;
        min-width: 240px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.2rem !important;
    }

    .hero-stat-card {
        min-width: 70px;
        padding: 6px 10px;
    }

    .hero-stat-value {
        font-size: 0.9rem;
    }

    .btn-hero {
        font-size: 0.8rem;
        padding: 10px 16px;
    }

    .index-card {
        min-width: 100px;
        flex: 1 1 100px;
    }

    .dash-tab {
        font-size: 0.68rem;
        padding: 6px 10px;
    }
}

/* --------------------------------------------------------------------------
   PAPER TRADING PAGE
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .pt-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-areas:
            "watchlist positions"
            "dashboard positions";
    }

    .pt-panel#ptWatchlistPanel { grid-area: watchlist; }
    .pt-panel#ptPositionsPanel { grid-area: positions; }
    .pt-panel#ptDashboardPanel { grid-area: dashboard; }
}

@media (max-width: 768px) {
    .pt-grid {
        grid-template-columns: 1fr !important;
        grid-template-areas: none !important;
        height: auto !important;
        gap: 8px;
    }

    .pt-panel#ptWatchlistPanel,
    .pt-panel#ptPositionsPanel,
    .pt-panel#ptDashboardPanel {
        grid-area: auto;
    }

    .pt-panel {
        min-height: 300px;
    }

    .pt-page {
        padding: 6px !important;
    }

    .pt-mobile-tabs {
        display: flex !important;
    }

    .pt-panel.pt-mobile-hide {
        display: none !important;
    }

    /* Summary cards — 2 columns on mobile */
    .pt-summary-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px;
    }

    .pt-summary-card {
        padding: 10px 12px;
    }

    .pt-summary-card .val {
        font-size: 1rem;
    }

    .pt-summary-card .lbl {
        font-size: 0.6rem;
    }

    /* Position cards — single column */
    .pt-position-grid {
        grid-template-columns: 1fr !important;
    }

    .pt-position-card {
        padding: 12px;
    }

    .pt-position-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .pt-pos-btn {
        flex: 1 1 calc(33.33% - 6px);
        min-width: 0;
        padding: 8px 6px;
        font-size: 0.7rem;
    }

    /* Tabs — scrollable */
    .pt-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pt-tab {
        white-space: nowrap;
        flex: 0 0 auto;
        font-size: 0.78rem;
        padding: 8px 12px;
    }

    /* Watchlist items */
    .pt-wl-item {
        padding: 10px 12px;
    }

    .pt-wl-item .wl-symbol {
        font-size: 0.85rem;
    }

    .pt-wl-item .wl-price {
        font-size: 0.8rem;
    }

    .pt-wl-item .wl-change {
        font-size: 0.7rem;
    }

    /* Dashboard panel */
    .pt-dash-section {
        padding: 12px;
    }

    .pt-funds-row {
        padding: 8px 10px;
    }

    .pt-funds-row .val {
        font-size: 0.9rem;
    }

    /* Chart */
    .pt-chart-wrap {
        height: 200px;
    }

    /* Pagination */
    .pt-tab-pagination, .pt-wl-pagination {
        padding: 6px 10px;
    }

    .pt-pag-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.72rem;
    }

    .pt-pag-info {
        font-size: 0.62rem;
    }

    /* Search */
    .pt-search-wrap {
        flex-direction: column;
    }

    .pt-search-input {
        width: 100%;
    }

    /* Position actions — buy/sell/exit buttons */
    .pt-position-actions .pt-pos-btn {
        flex: 1 1 100%;
        margin-bottom: 4px;
    }
}

@media (max-width: 480px) {
    .pt-summary-row {
        grid-template-columns: 1fr !important;
    }

    .pt-pos-btn {
        font-size: 0.68rem;
        padding: 8px 4px;
    }

    .pt-tab {
        font-size: 0.72rem;
        padding: 6px 10px;
    }

    .pt-panel {
        min-height: 250px;
    }
}

/* --------------------------------------------------------------------------
   TRADE MODALS — mobile bottom sheet style
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .pt-modal .modal-dialog {
        max-width: 100%;
        margin: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .pt-modal .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pt-modal-banner {
        padding: 16px 20px;
        border-radius: 20px 20px 0 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .pt-modal .modal-body {
        padding: 16px 20px;
    }

    .pt-modal .modal-footer {
        padding: 0 20px 20px;
        position: sticky;
        bottom: 0;
        background: var(--pt-bg);
        border-top: 1px solid var(--pt-border);
    }

    .pt-modal .modal-footer .btn {
        padding: 14px 16px;
        font-size: 0.9rem;
        min-height: 50px;
    }

    .pt-modal-stock {
        padding: 12px 14px;
    }

    .pt-modal-stock .pt-modal-symbol {
        font-size: 1.2rem;
    }

    .pt-modal-stock .pt-modal-price {
        font-size: 1rem;
    }

    .pt-qty-step {
        width: 52px;
        min-width: 52px;
        height: 52px;
    }

    .pt-qty-input {
        font-size: 1.2rem !important;
        padding: 14px 8px !important;
    }

    .pt-qty-quick button {
        min-height: 44px;
        font-size: 0.8rem;
    }

    .pt-modal-total .val {
        font-size: 1.25rem;
    }

    /* Upgrade plan modal */
    .pt-modal-banner-upgrade {
        border-radius: 20px 20px 0 0;
    }
}

@media (max-width: 480px) {
    .pt-modal-banner .pt-modal-title {
        font-size: 1rem;
    }

    .pt-modal .modal-footer .btn {
        font-size: 0.85rem;
        padding: 12px 14px;
    }

    .pt-qty-quick button {
        font-size: 0.72rem;
        padding: 6px;
    }
}

/* --------------------------------------------------------------------------
   AUTH PAGES (Login / Register)
   -------------------------------------------------------------------------- */
@media (max-width: 800px) {
    .auth-shell {
        grid-template-columns: 1fr !important;
    }

    .auth-showcase {
        min-height: 280px;
        padding: 24px 22px;
    }

    .auth-form-panel {
        padding: 24px 22px;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: 12px 8px 24px;
    }

    .auth-shell {
        min-height: auto;
        border-radius: 14px;
    }

    .auth-showcase {
        min-height: 220px;
        padding: 20px 18px;
    }

    .auth-brand img {
        height: 44px;
        width: 44px;
    }

    .auth-brand-name {
        font-size: 1.3rem;
    }

    .auth-showcase h1 {
        font-size: 1.35rem;
    }

    .auth-showcase p {
        font-size: 0.82rem;
    }

    .auth-benefits, .auth-perks {
        gap: 8px;
    }

    .auth-benefit, .auth-perk {
        font-size: 0.78rem;
        padding: 8px;
    }

    .auth-form-panel {
        padding: 20px 18px;
    }

    .auth-form-heading h2 {
        font-size: 1.2rem;
    }

    .auth-input {
        padding: 12px 14px;
        font-size: 0.9rem;
        min-height: 48px;
    }

    .auth-submit {
        padding: 14px;
        font-size: 0.9rem;
        min-height: 50px;
    }

    .auth-register, .auth-security {
        font-size: 0.78rem;
    }

    .auth-form-row {
        grid-template-columns: 1fr !important;
    }
}

/* --------------------------------------------------------------------------
   CALCULATOR PAGES (SIP / EMI)
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .calculator-grid {
        grid-template-columns: 1fr !important;
    }

    .calculator-card {
        position: static !important;
    }
}

@media (max-width: 768px) {
    .calculator-page {
        padding: 8px;
    }

    .calculator-shell {
        padding: 12px;
    }

    .calculator-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .calculator-heading h1 {
        font-size: 1.3rem;
    }

    .calculator-heading p {
        font-size: 0.8rem;
    }

    .calculator-brand {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .calculator-card {
        padding: 14px;
    }

    .calculator-card h2 {
        font-size: 1rem;
    }

    .calc-field label {
        font-size: 0.78rem;
    }

    .calc-input {
        padding: 12px 14px;
        font-size: 0.9rem;
        min-height: 48px;
    }

    .calc-result-card {
        padding: 14px;
    }

    .calc-result-value {
        font-size: 1.3rem;
    }

    .calc-note {
        font-size: 0.7rem;
    }

    /* Table responsive — make scrollable */
    .calc-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.calc-table {
        font-size: 0.72rem;
        min-width: 500px;
    }

    /* Chart */
    .calc-chart-wrap {
        height: 220px;
    }
}

@media (max-width: 480px) {
    .calculator-heading h1 {
        font-size: 1.15rem;
    }

    .calc-input {
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    .calc-result-value {
        font-size: 1.1rem;
    }

    table.calc-table {
        font-size: 0.68rem;
    }
}

/* --------------------------------------------------------------------------
   ADMIN LAYOUT
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .main-sidebar {
        position: fixed;
        top: 56px;
        left: -250px;
        width: 250px;
        height: calc(100vh - 56px);
        z-index: 1030;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    /* AdminLTE adds .sidebar-open to body — match that */
    body.sidebar-open .main-sidebar,
    .main-sidebar.sidebar-open {
        left: 0;
    }

    /* Overlay when sidebar is open on mobile */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1029;
    }

    .content-wrapper {
        margin-left: 0 !important;
    }

    .main-footer {
        margin-left: 0 !important;
    }
}

/* --------------------------------------------------------------------------
   TICKER
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .ticker-wrapper, .pt-ticker-bar {
        height: 34px;
    }

    .ticker-label {
        font-size: 0.62rem;
        padding: 0 8px;
    }

    .ticker-label .live-dot {
        width: 6px;
        height: 6px;
    }

    .stockTickerContainer {
        animation-duration: 60s !important;
    }

    .pt-ticker-bar .stockTickerContainer {
        animation-duration: 60s !important;
    }

    .stock-box {
        padding: 3px 10px;
        font-size: 0.68rem;
    }

    .stock-box .stock-symbol {
        font-size: 0.7rem;
    }

    .stock-box .stock-price {
        font-size: 0.68rem;
    }

    .stock-box .stock-change {
        font-size: 0.62rem;
    }
}

/* --------------------------------------------------------------------------
   TOAST / MESSAGE BOXES
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .pt-toast {
        right: 10px !important;
        left: 10px !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    .pt-message {
        margin: 8px;
        padding: 12px 14px;
        font-size: 0.82rem;
    }
}

/* --------------------------------------------------------------------------
   FORMS — general input sizing for mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .form-control, input[type="text"], input[type="email"],
    input[type="password"], input[type="number"], select, textarea {
        font-size: 16px !important; /* prevents iOS zoom on focus */
        min-height: 44px;
    }

    /* Prevent zoom on input focus for iOS */
    @supports (-webkit-touch-callout: none) {
        .form-control, input[type="text"], input[type="email"],
        input[type="password"], input[type="number"], select, textarea {
            font-size: 16px !important;
        }
    }
}

/* --------------------------------------------------------------------------
   MISC — ensure modals work on mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .modal {
        padding: 0 !important;
    }

    .modal-dialog {
        margin: 0 auto;
    }

    .modal-content {
        border-radius: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    .modal-footer .btn {
        min-height: 48px;
        font-size: 0.88rem;
    }
}

/* Hidden on desktop; enabled as inner navigation on mobile. */
.overview-mobile-tabs {
    display: none;
}

/* --------------------------------------------------------------------------
   FINAL MOBILE OVERRIDES — compact cards and true tab layouts
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Keep account controls in the top bar, never below the menu */
    .main-header .navbar-actions {
        order: 2 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap;
        gap: 4px;
        margin-left: auto !important;
        padding: 0;
    }

    .main-header .navbar-actions .nav-item {
        margin: 0 !important;
    }

    .main-header .navbar-actions .theme-toggle-btn {
        width: 38px;
        height: 38px;
    }

    .main-header .navbar-actions .nav-link {
        padding: 4px !important;
        min-height: 42px;
    }

    .main-header .navbar-actions .login-btn {
        width: auto;
        min-height: 40px;
        padding: 9px 12px !important;
        white-space: nowrap;
    }

    .main-header .navbar-toggler {
        order: 3 !important;
    }

    .main-header .navbar-actions .user-menu > .nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border: 1px solid rgba(148, 163, 184, 0.22);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.06);
    }

    .main-header .navbar-actions .user-menu > .nav-link::after {
        display: none;
    }

    .main-header .navbar-actions .user-menu .nav-user-avatar {
        width: 30px;
        height: 30px;
        margin: 0;
    }

    .main-header .navbar-actions .user-menu .dropdown-menu {
        position: absolute;
        top: 48px;
        right: 0;
        left: auto;
        width: min(300px, calc(100vw - 20px)) !important;
        min-width: 0 !important;
        max-height: calc(100vh - 75px);
        overflow-y: auto;
    }

    /* Landing page is a real tab view: only selected panel is visible */
    .dashboard-container {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }

    .dashboard-main {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .dashboard-main > .dash-tabs {
        order: 0;
        position: sticky;
        top: 56px;
        z-index: 20;
        background: var(--card-bg, #fff);
        border: 1px solid var(--card-border, #e5e7eb);
        box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
    }

    .dashboard-main > .dash-tab-content {
        display: none !important;
        order: 1;
        width: 100%;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    .dashboard-main > .dash-tab-content.active {
        display: flex !important;
    }

    .dashboard-sidebar {
        order: 2;
        width: 100%;
        min-width: 0;
    }

    .news-full-card {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        height: auto !important;
    }

    .news-full-card .news-body,
    .news-full-card .news-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .news-full-card .news-body {
        display: block !important;
        padding: 0 !important;
    }

    .news-full-card .news-container {
        overflow: visible !important;
        max-height: none !important;
        padding: 10px 12px !important;
    }

    .news-full-card .news-item h6,
    .news-full-card .news-item p {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    /* Trending ticker compact on mobile */
    .news-trending-ticker {
        padding: 6px 10px !important;
        gap: 6px !important;
    }

    .trending-label {
        font-size: 0.62rem !important;
    }

    .trending-track .trending-item {
        font-size: 0.7rem !important;
        padding: 0 8px !important;
    }

    /* Compact landing cards */
    .dash-card {
        border-radius: 12px;
    }

    .dash-card-header {
        padding: 10px 12px;
    }

    .dash-card-header h3 {
        font-size: 0.88rem;
    }

    .dash-card-body {
        padding: 10px 12px;
    }

    .card-helper-text, .market-status, .dash-badge {
        font-size: 0.62rem;
    }

    .index-card {
        padding: 10px;
        min-width: 108px;
    }

    .index-card h4 {
        font-size: 0.68rem;
    }

    .index-card .index-value {
        font-size: 0.95rem;
    }

    .index-card .index-change {
        font-size: 0.62rem;
    }

    .mover-item, .active-stock-item, .sector-card {
        padding: 9px 10px;
    }

    .mover-symbol, .active-stock-symbol, .sector-name {
        font-size: 0.75rem;
    }

    .mover-price, .active-stock-price, .sector-value {
        font-size: 0.7rem;
    }

    .mover-change, .active-stock-change, .sector-change {
        font-size: 0.66rem;
    }

    .news-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        flex-wrap: nowrap !important;
        background: var(--card-bg-alt) !important;
        border-bottom: 1px solid var(--card-border) !important;
    }

    .news-tabs::-webkit-scrollbar {
        display: none;
    }

    .news-tab {
        flex: none !important;
        padding: 10px 4px !important;
        font-size: 0.72rem !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        text-align: center !important;
        border-radius: 0 !important;
        border: none !important;
        border-bottom: 2px solid transparent !important;
        background: transparent !important;
        color: var(--text-secondary) !important;
        transition: var(--transition) !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .news-tab.active {
        color: var(--primary) !important;
        background: transparent !important;
        border-bottom: 2px solid var(--primary) !important;
        font-weight: 700 !important;
    }

    .news-container {
        max-height: none !important;
        overflow-y: visible !important;
        padding: 10px 12px !important;
    }

    .news-item {
        padding: 12px 14px;
    }

    .news-item h6 {
        font-size: 0.86rem;
        line-height: 1.35;
    }

    .news-item p {
        font-size: 0.76rem;
        line-height: 1.4;
    }
}

@media (max-width: 480px) {
    .main-header .navbar-brand .brand-text {
        font-size: 0.88rem;
    }

    .main-header .navbar-brand img {
        width: 28px;
        height: 28px;
    }

    .main-header .navbar-actions .login-btn {
        font-size: 0.72rem !important;
        padding: 8px 10px !important;
    }

    .main-header .navbar-actions .theme-toggle-btn {
        width: 34px;
        height: 34px;
    }

    .dash-card-header h3 {
        font-size: 0.82rem;
    }

    .dash-card-body {
        padding: 8px 10px;
    }

    .dash-tab {
        font-size: 0.66rem;
        padding: 7px 9px;
    }
}

/* --------------------------------------------------------------------------
   PROFILE PAGE — compact mobile layout
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .profile-page {
        padding: 0 8px 20px !important;
        overflow: hidden;
    }

    .profile-cover {
        height: 105px !important;
        border-radius: 0 0 14px 14px;
    }

    .profile-header-card {
        display: grid !important;
        grid-template-columns: 64px 1fr !important;
        gap: 10px !important;
        align-items: center;
        padding: 14px !important;
        margin-top: -26px !important;
        border-radius: 14px !important;
    }

    .profile-avatar-wrap {
        width: 64px !important;
        height: 64px !important;
        grid-row: span 2;
    }

    .profile-avatar {
        width: 64px !important;
        height: 64px !important;
        font-size: 1.4rem !important;
    }

    .profile-header-info h1 {
        font-size: 1.25rem !important;
        line-height: 1.2;
        margin-bottom: 2px !important;
    }

    .profile-header-email {
        font-size: 0.78rem !important;
        overflow-wrap: anywhere;
    }

    .profile-header-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 5px !important;
        margin-top: 6px !important;
    }

    .profile-badge {
        padding: 5px 8px !important;
        font-size: 0.62rem !important;
    }

    .profile-header-actions {
        grid-column: 1 / -1;
        width: 100%;
    }

    .profile-action-btn {
        width: 100%;
        min-height: 42px;
        padding: 9px 12px !important;
        font-size: 0.78rem !important;
    }

    .profile-tabs {
        display: flex !important;
        overflow-x: auto;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        margin: 12px 0 !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .profile-tabs::-webkit-scrollbar {
        display: none;
    }

    .profile-tab {
        flex: 0 0 auto !important;
        min-height: 42px;
        padding: 9px 12px !important;
        font-size: 0.72rem !important;
        white-space: nowrap;
    }

    .profile-content {
        width: 100%;
    }

    .profile-card {
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }

    .profile-card-header {
        padding: 12px 14px !important;
    }

    .profile-card-header h2 {
        font-size: 0.92rem !important;
    }

    .profile-card-body {
        padding: 12px !important;
    }

    .profile-info-grid, .profile-security-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .profile-info-item, .profile-security-item {
        padding: 10px !important;
    }

    .profile-info-label, .profile-security-title {
        font-size: 0.62rem !important;
    }

    .profile-info-value, .profile-security-status {
        font-size: 0.78rem !important;
        overflow-wrap: anywhere;
    }

    .profile-form-row {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Overview becomes a compact inner tab view */
    .overview-mobile-tabs {
        display: flex;
        gap: 4px;
        overflow-x: auto;
        padding: 4px;
        margin-bottom: 2px;
        background: var(--card-bg-alt, #f8fafc);
        border: 1px solid var(--card-border, #e5e7eb);
        border-radius: 10px;
        scrollbar-width: none;
    }

    .overview-mobile-tabs::-webkit-scrollbar {
        display: none;
    }

    .overview-mobile-tab {
        flex: 1 0 auto;
        min-height: 38px;
        padding: 7px 12px;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--text-muted, #64748b);
        font-size: 0.7rem;
        font-weight: 700;
        white-space: nowrap;
    }

    .overview-mobile-tab.active {
        background: var(--primary, #2563eb);
        color: #fff;
        box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
    }

    #tab-overview .overview-mobile-panel {
        display: none !important;
        margin: 0;
        flex-direction: column !important;
    }

    #tab-overview .overview-mobile-panel.active {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Turn market/index card rails into compact list rows */
    #tab-overview .index-scroll-wrapper {
        display: block;
        position: relative;
    }

    #tab-overview .index-scroll-wrapper > .scroll-btn {
        display: none;
    }

    #tab-overview .index-cards {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 4px;
        width: 100%;
        max-height: none;
        overflow: visible;
        overflow-x: hidden;
        padding: 0;
        scroll-behavior: smooth;
    }

    #tab-overview .index-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 6px;
        width: 100%;
        min-width: 0;
        min-height: 36px;
        padding: 6px 8px;
        border-radius: 8px;
        text-align: left;
        flex: none;
    }

    #tab-overview .index-card h4 {
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.68rem;
    }

    #tab-overview .index-card .index-value {
        font-size: 0.74rem;
        white-space: nowrap;
    }

    #tab-overview .index-card .index-change {
        font-size: 0.58rem;
        white-space: nowrap;
    }

    /* Compact overview widgets */
    #tab-overview .overview-row {
        gap: 8px;
    }

    #tab-overview .overview-row > .dash-card {
        width: 100%;
        min-height: auto !important;
    }

    #tab-overview .sentiment-advdec-body {
        flex-direction: column !important;
        gap: 8px !important;
        padding: 8px 10px !important;
    }

    #tab-overview .sentiment-advdec-divider {
        width: 100% !important;
        height: 1px !important;
    }

    #tab-overview .sentiment-widget {
        width: 100% !important;
    }

    #tab-overview .sentiment-gauge {
        max-width: 160px !important;
        height: 10px !important;
    }

    #tab-overview .sentiment-label {
        font-size: 0.82rem !important;
    }

    #tab-overview .sentiment-score {
        font-size: 0.66rem !important;
    }

    #tab-overview .adv-dec-bar {
        height: 18px !important;
    }

    #tab-overview .adv-count,
    #tab-overview .dec-count,
    #tab-overview .unch-count {
        font-size: 0.88rem !important;
    }

    #tab-overview .adv-label,
    #tab-overview .dec-label,
    #tab-overview .unch-label {
        font-size: 0.56rem !important;
    }

    #tab-overview .tools-grid {
        gap: 6px;
    }

    #tab-overview .tool-tile {
        min-height: 62px;
        padding: 8px;
        font-size: 0.68rem;
    }

    /* Force the indices sub-tab content to use the full mobile width. */
    #tab-overview #subtab-live-nifty,
    #tab-overview #subtab-market-indices {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    #tab-overview #subtab-live-nifty:not(.active),
    #tab-overview #subtab-market-indices:not(.active) {
        display: none !important;
    }

    /* Remove the inner section box — sub-tab already labels the content */
    #tab-overview .index-list-section {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }

    /* Hide the redundant heading on mobile — sub-tab shows the name */
    #tab-overview .index-list-heading {
        display: none !important;
    }

    #tab-overview .index-list-section .index-cards {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        gap: 4px !important;
    }

    #tab-overview .index-list-section .index-card {
        display: grid !important;
        grid-template-columns: minmax(70px, 1fr) auto minmax(85px, 1fr) !important;
        width: 100% !important;
        margin: 0 !important;
        overflow: hidden !important;
        gap: 6px !important;
        min-height: 36px !important;
        padding: 6px 8px !important;
    }

    #tab-overview .index-list-section .index-card .index-change {
        font-size: 0.58rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        text-align: right !important;
    }

    #tab-overview .index-list-section .index-card h4 {
        font-size: 0.68rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Compact the combined indices body on mobile */
    #tab-overview .combined-indices-body {
        padding: 8px 8px !important;
    }

    /* Compact the sub-tabs on mobile */
    #tab-overview .indices-sub-tabs {
        margin-bottom: 8px !important;
        gap: 3px !important;
    }

    #tab-overview .indices-sub-tabs .sub-tab {
        padding: 6px 8px !important;
        font-size: 0.72rem !important;
    }

    /* Compact the market legend on mobile */
    #tab-overview .market-legend {
        margin-top: 6px !important;
        font-size: 0.58rem !important;
        padding: 4px 0 !important;
    }
}

