/* ════════════════════════════════════════════════════════════
   MOBILE LAYER — loaded on every page after the main styles.
   Dashboard drawer, stacked tables, touch ergonomics, homepage
   helpers. Desktop (≥992px) is untouched.
   ════════════════════════════════════════════════════════════ */

/* ── Back-to-top (all sizes, shows after scrolling) ── */
#mtTopBtn{
  position:fixed; right:16px; bottom:86px; z-index:1200;
  width:44px; height:44px; border-radius:50%; border:none; cursor:pointer;
  background:#0a1f5c; color:#fff; font-size:18px;
  box-shadow:0 6px 18px rgba(8,26,82,.45);
  opacity:0; visibility:hidden; transition:.25s;
}
#mtTopBtn.show{ opacity:1; visibility:visible; }

/* ── Desktop: mobile-only drawer controls off ──
   mobile.js body-appends #mtSbToggle + #mtSbBackdrop on dashboard pages.
   Without a base rule they render as in-flow default elements below the
   footer (white strip + stray hamburger). Hide on desktop; the mobile
   media-query below turns them back on. ── */
#mtSbToggle, #mtSbBackdrop{ display:none; }

/* ── Collapsible sections (mobile accordions) ── */
.m-collapse-btn{ display:none; }
@media (max-width: 991.98px){
  .m-collapse-btn{
    display:flex; align-items:center; justify-content:space-between; width:100%;
    background:#fff; border:1.5px solid #dbe1f0; border-radius:12px;
    padding:13px 16px; font-weight:700; color:#0a1f5c; font-size:15px; cursor:pointer;
  }
  .m-collapse-btn .chev{ transition:.25s; color:#e8681a; }
  .m-collapse-btn.open .chev{ transform:rotate(180deg); }
  .m-collapse-body{ display:none; margin-top:14px; }
  .m-collapse-body.open{ display:block; }
}
@media (min-width: 992px){ .m-collapse-body{ display:block !important; } }

@media (max-width: 991.98px){

  /* ── Fix horizontal overflow: .row.g-5 gutters (−24px) exceed the
        mobile container padding (12px), widening the page past the
        viewport and clipping text at the right edge ── */
  .row.g-5{ --bs-gutter-x: 1.5rem; }

  /* ── Touch ergonomics ─────────────────────────────────── */
  input.form-control-custom, select.form-control-custom, textarea.form-control-custom,
  .fc, .form-control, .form-select { font-size:16px !important; }   /* stops iOS zoom-on-focus */
  .btn-primary-custom, .btn-navy { min-height:46px; }
  input[type="radio"], input[type="checkbox"]{ width:20px; height:20px; }

  /* ── DASHBOARD SIDEBAR → slide-in drawer ──────────────── */
  .dashboard-wrapper .sidebar{
    display:block !important;
    position:fixed; top:0; left:0; bottom:0; z-index:2050;
    width:82%; max-width:320px; min-height:100vh;
    transform:translateX(-100%); transition:transform .3s cubic-bezier(.4,0,.2,1);
    overflow-y:auto; box-shadow:8px 0 40px rgba(0,0,0,.55);
  }
  .dashboard-wrapper .sidebar.open{ transform:translateX(0); }
  #mtSbToggle{
    display:flex; align-items:center; justify-content:center;
    position:fixed; left:12px; bottom:16px; z-index:2040;
    width:52px; height:52px; border-radius:50%; border:none; cursor:pointer;
    background:linear-gradient(135deg,#e8681a,#c2520e); color:#fff; font-size:20px;
    box-shadow:0 8px 22px rgba(232,104,26,.55);
  }
  #mtSbBackdrop{
    display:block;
    position:fixed; inset:0; background:rgba(3,8,30,.55); z-index:2045;
    opacity:0; visibility:hidden; transition:opacity .3s;
  }
  #mtSbBackdrop.show{ opacity:1; visibility:visible; }
  body.mt-sb-locked{ overflow:hidden; }

  /* ── STACKED TABLES (.stack-mobile) — each row becomes a card ── */
  table.stack-mobile{ min-width:0 !important; }
  table.stack-mobile thead{ display:none; }
  table.stack-mobile, table.stack-mobile tbody{ display:block; width:100%; }
  table.stack-mobile tr{
    display:block; background:#fff; border:1.5px solid #dbe1f0; border-radius:12px;
    margin:0 0 12px; padding:10px 12px; box-shadow:0 2px 8px rgba(8,26,82,.06);
  }
  table.stack-mobile td{
    display:block; width:100% !important; min-width:0 !important;
    border:none !important; padding:7px 2px !important; text-align:left !important;
  }
  table.stack-mobile td[data-label]::before{
    content:attr(data-label);
    display:block; font-size:11.5px; font-weight:700; color:#64748b;
    text-transform:none; margin-bottom:3px;
  }
  table.stack-mobile td:empty{ display:none; }

  /* ── File inputs: preview thumbnails ── */
  .mt-file-preview{ display:flex; align-items:center; gap:8px; margin-top:6px; font-size:12px; color:#16a34a; }
  .mt-file-preview img{ width:44px; height:44px; object-fit:cover; border-radius:8px; border:1px solid #dbe1f0; }

  /* ── Homepage helpers ─────────────────────────────────── */
  /* quick actions under hero */
  .mt-quick{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; padding:14px 14px 4px; }
  .mt-quick a{
    display:flex; flex-direction:column; align-items:center; gap:6px;
    background:#fff; border:1.5px solid #dbe1f0; border-radius:14px;
    padding:14px 6px; text-decoration:none; color:#0a1f5c; font-weight:700; font-size:12.5px;
    box-shadow:0 2px 10px rgba(8,26,82,.07);
  }
  .mt-quick a i{ font-size:20px; color:#e8681a; }
  /* section chips */
  .sec-chips{ display:flex; gap:8px; overflow-x:auto; padding:10px 14px 12px; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .sec-chips::-webkit-scrollbar{ display:none; }
  .sec-chips a{
    flex-shrink:0; background:#eef2ff; color:#0a1f5c; border-radius:20px;
    padding:8px 15px; font-size:13px; font-weight:600; text-decoration:none; white-space:nowrap;
  }
  /* sticky register FAB */
  #mtRegFab{
    position:fixed; right:16px; bottom:16px; z-index:1200;
    display:inline-flex; align-items:center; gap:8px;
    background:linear-gradient(135deg,#e8681a,#c2520e); color:#fff;
    border-radius:30px; padding:13px 20px; font-weight:800; font-size:14.5px;
    text-decoration:none; box-shadow:0 10px 26px rgba(232,104,26,.55);
  }
  /* compact countdown: hide year/month/second boxes on phones */
  #cdbox_y, #cdbox_mo, #cdbox_s{ display:none !important; }
  /* hide extra news beyond first 3 until "more" tapped */
  .news-extra{ display:none; }
  body.show-all-news .news-extra{ display:block; }
}

@media (min-width: 992px){
  .mt-quick, .sec-chips, #mtRegFab, #newsMoreBtn{ display:none !important; }
}

/* very small phones: subsidy info cards one per row */
@media (max-width: 420px){
  .subsidy-row > .col-6{ width:100%; }
}
