/* HAMBURGER */
.hamburger{display:none;flex-direction:column;gap:4px;cursor:pointer;padding:6px;border-radius:8px;background:var(--card);border:1px solid var(--border)}
.hamburger span{display:block;width:18px;height:2px;background:var(--text);border-radius:2px;transition:all .3s}
.sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:99}
.sidebar-overlay.show{display:block}

/* MOBILE */
@media(max-width:1300px){
  /* At medium desktop, reduce col-side and give col-main more room */
  .col-side{width:240px;min-width:240px}
}
@media(max-width:1150px){
  /* Invest 6-col stat cards → 3 cols at medium viewports */
  .stat-cards[style*="repeat(6"]{grid-template-columns:1fr 1fr 1fr !important}
  /* Tighten col-side further */
  .col-side{width:220px;min-width:220px}
  /* Reduce stat card padding so content fits */
  .stat-card{padding:12px}
  .stat-val{font-size:18px}
  /* Reduce slider grid gap */
  .slider-grid{gap:12px}
}
@media(max-width:960px){
  /* Further compress */
  .col-side{width:200px;min-width:200px}
  .stat-cards[style*="repeat(6"]{grid-template-columns:1fr 1fr !important}
  .stat-card{padding:10px 12px}
  .stat-val{font-size:16px}
  /* Slider grid → 1 col at near-tablet */
  .slider-grid{grid-template-columns:1fr 1fr}
  /* Reduce AI card padding */
  .ai-card{padding:12px}
}
@media(max-width:768px){
  body{overflow:auto;flex-direction:column;height:auto}
  .sidebar{position:fixed;left:-220px;top:0;z-index:100;height:100vh;transition:left .3s;width:210px}
  .sidebar.open{left:0}
  .hamburger{display:flex}
  .main{flex:1;min-width:0}
  .topbar{padding:14px 14px 0;gap:10px}
  .topbar-left h2{font-size:15px}
  .topbar-right{font-size:10px;padding:5px 10px}
  .content{flex-direction:column;flex-wrap:nowrap;padding:12px 12px 20px;gap:12px}
  .page-foot{flex:0 0 auto}
  .col-side{width:100%;min-width:0}
  .stat-cards{grid-template-columns:1fr 1fr}
  /* Override inline repeat(6,1fr) on invest stat cards */
  .stat-cards[style*="repeat(6"]{grid-template-columns:1fr 1fr 1fr !important}
  .stat-card{padding:12px 14px}
  .stat-val{font-size:20px}
  .slider-grid{grid-template-columns:1fr}
  .charts-row{grid-template-columns:1fr}
  /* Charts: show on mobile with proper sizing */
  .chart-card{display:block !important}
  .donut-card{display:block !important}
  /* Explicit mobile canvas heights — prevents Chart.js 0px collapse */
  .chart-h140{height:180px !important;min-height:180px}
  .chart-h160{height:190px !important;min-height:190px}
  .chart-h170{height:190px !important;min-height:190px}
  .chart-h200{height:200px !important;min-height:200px}
  /* Donut: show and size correctly on mobile */
  .donut-wrap{display:block !important;width:110px;height:110px}
  .param-col{max-height:none !important}
  .table-scroll{max-height:280px;overflow-x:auto}
  .num-input{width:80px !important}
  /* AI card mobile */
  .ai-card{padding:12px}
  .ai-chips{flex-wrap:wrap}
  .ai-row{flex-direction:row}
  .ai-row input{min-width:0}
  /* Table mobile - ensure horizontal scroll */
  table{min-width:520px}
  .table-card{overflow:hidden}
}
@media(max-width:480px){
  .stat-cards{grid-template-columns:1fr 1fr}
  /* Override inline repeat(6,1fr) on invest stat cards → 2-col on small phones */
  .stat-cards[style*="repeat(6"]{grid-template-columns:1fr 1fr !important}
  .topbar-right{display:none}
  /* Narrower sliders on small screens */
  .sl-name{font-size:10px}
  .num-input{width:70px !important;font-size:10px}
  /* Stack AI row on very small screens */
  .ai-row{flex-direction:column}
  .ai-row input{width:100%}
  .ai-row button{width:100%;padding:9px}
  /* Tighter topbar */
  .topbar-left h2{font-size:14px}
  .brand-name{font-size:15px}
  /* Stat card text scaling */
  .stat-val{font-size:18px}
  .stat-lbl{font-size:9px}
  .stat-sub{font-size:9px}
  /* Nudge popup full-width on small screens */
  #signupNudge{width:calc(100vw - 24px);right:12px;bottom:12px}
}

/* MOBILE TOOLS CARD — shown only when sidebar is hidden (≤768px) */
.mobile-tools-card{display:none}
@media(max-width:768px){
  .mobile-tools-card{
    display:block;
    order:98;
    flex:1 0 100%;
    width:100%;
    background:var(--card);
    border-radius:16px;
    padding:18px 16px 14px;
    box-shadow:var(--shadow);
    border:1px solid var(--border);
    margin-top:4px;
  }
  .mobile-tools-title{
    font-size:11px;
    font-weight:600;
    letter-spacing:.06em;
    color:var(--text3);
    margin-bottom:12px;
  }
  .mobile-tools-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
  }
  .mobile-tool-btn{
    display:flex;
    align-items:center;
    gap:9px;
    padding:11px 12px;
    background:var(--bg);
    border:1px solid var(--border);
    border-radius:12px;
    cursor:pointer;
    transition:background .18s, border-color .18s;
    text-align:left;
    font-family:'DM Sans',sans-serif;
    width:100%;
  }
  .mobile-tool-btn:hover,.mobile-tool-btn:active{
    background:#1c1c1e;
    border-color:transparent;
  }
  .mobile-tool-btn:hover .mtb-label,.mobile-tool-btn:active .mtb-label{color:#fff}
  .mobile-tool-btn:hover .mtb-icon,.mobile-tool-btn:active .mtb-icon{color:rgba(255,255,255,0.7)}
  .mobile-tool-btn.active-tool{
    background:#1c1c1e;
    border-color:transparent;
  }
  .mobile-tool-btn.active-tool .mtb-label{color:#fff}
  .mobile-tool-btn.active-tool .mtb-icon{color:rgba(255,255,255,0.65)}
  .mtb-icon{
    color:var(--text3);
    flex-shrink:0;
    line-height:0;
    transition:color .18s;
  }
  .mtb-label{
    font-size:12px;
    font-weight:500;
    color:var(--text);
    line-height:1.3;
    transition:color .18s;
  }
  body.dark .mobile-tool-btn{border-color:rgba(255,255,255,0.08)}
  body.dark .mobile-tool-btn:hover,.dark .mobile-tool-btn:active{background:#f0f0ee;border-color:transparent}
  body.dark .mobile-tool-btn:hover .mtb-label,.dark .mobile-tool-btn:active .mtb-label{color:#1c1c1e}
  body.dark .mobile-tool-btn:hover .mtb-icon,.dark .mobile-tool-btn:active .mtb-icon{color:rgba(28,28,30,0.6)}
  body.dark .mobile-tool-btn.active-tool{background:#f0f0ee}
  body.dark .mobile-tool-btn.active-tool .mtb-label{color:#1c1c1e}
  body.dark .mobile-tool-btn.active-tool .mtb-icon{color:rgba(28,28,30,0.55)}
}

