/* ============================================================
   Platinum Heritage - Responsive layer (all devices)
   Loaded LAST on every page. Mobile-first fixes + breakpoints:
   1200 / 1024 / 900 / 768 / 600 / 480 / 360
   ============================================================ */

/* ---------- global safety ---------- */
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas, iframe { max-width: 100%; }
img, video { height: auto; }
input, select, textarea, button { max-width: 100%; font-size: 16px; } /* 16px stops iOS zoom-on-focus */
h1, h2, h3, p, a, td, th, li { overflow-wrap: anywhere; word-break: normal; }
.wrap, .container, .nav-inner, .util-inner { width: 100%; }
.table-wrapper, .tbl-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table, .stitch-table, .dtable { min-width: 560px; }
.dtable { min-width: 480px; }
.article .dtable-wrap, .article { overflow-x: auto; }
.btn { max-width: 100%; white-space: normal; text-align: center; }
.sw input { font-size: 0; }

/* ---------- brand / logo ---------- */
.pub-nav .nav-logo { text-transform: uppercase; font-size: 1.05rem; letter-spacing: .1em; white-space: nowrap; }
.pub-nav .nav-logo small { letter-spacing: .24em; }
.pub-footer .nav-logo { text-transform: uppercase; font-size: 1.05rem; letter-spacing: .1em; }
.mobile-menu-btn { display: none; background: var(--navy); color: #fff; border: 0; border-radius: 8px; width: 42px; height: 42px; font-size: 1.25rem; line-height: 1; cursor: pointer; }

/* ---------- mobile nav panel ---------- */
.mobile-nav { position: fixed; left: 0; right: 0; top: 72px; background: #fff; border-bottom: 1px solid var(--outline); box-shadow: 0 18px 30px rgba(13,27,54,.18); max-height: calc(100vh - 72px); overflow-y: auto; z-index: 99; display: none; flex-direction: column; padding: .5rem var(--space-lg) 1rem; }
.mobile-nav.active { display: flex; }
.mobile-nav a { padding: .9rem .25rem; border-bottom: 1px solid var(--outline-variant); font-weight: 600; color: var(--on-surface); }
.mobile-nav a.text-primary { color: var(--navy); }

/* ---------- <= 1200 ---------- */
@media (max-width: 1200px) {
  .pub-nav .nav-links { gap: 1.1rem; }
  .nav-actions .btn { padding: .6rem .9rem; }
  .pub-footer .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
  .pub-footer .footer-col:last-child { display: none; }
}

/* ---------- <= 1024 (tablet landscape) ---------- */
@media (max-width: 1024px) {
  .nhero { padding: 3.5rem 0 6rem; }
  .nhero-grid, .split2 { gap: 2.25rem; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .rate-cols { grid-template-columns: repeat(2, 1fr); }
  .feature .f-body { padding: 2rem; }
  .cta-panel { padding: 2.25rem; gap: 1.75rem; }
  .pub-nav .nav-links { display: none; }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .pub-nav .nav-inner { justify-content: space-between; }
  .nav-actions { margin-left: auto; margin-right: .5rem; }
}

/* ---------- <= 900 ---------- */
@media (max-width: 900px) {
  .nhero-grid, .split2, .feature, .cta-panel, .img-quote, .legal { grid-template-columns: 1fr !important; }
  .g3, .g2 { grid-template-columns: 1fr !important; }
  #personal .wrap > div:last-child { grid-template-columns: 1fr !important; }
  .photo { max-width: 640px; margin-inline: auto; }
  .feature .f-img { min-height: 260px; }
  .img-quote .iq-img { min-height: 240px; }
  .toc { position: static; }
  .legal aside { order: -1; }
  .sec { padding: 3.5rem 0; }
  .sec-head { margin-bottom: 2rem; }
  .pub-footer .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .pub-footer .footer-col:last-child { display: block; }
}

/* ---------- <= 768 (tablet portrait / large phone) ---------- */
@media (max-width: 768px) {
  .nav-actions { display: none; }
  .mobile-menu-btn { margin-left: auto; }
  .util-bar .util-left { display: none; }
  .util-bar .util-inner { justify-content: center; padding: .45rem var(--space-md); }
  .util-bar a { margin: 0 .6rem; }
  .wrap, .nav-inner, .util-inner { padding-left: var(--space-lg); padding-right: var(--space-lg); }
  .nhero { padding: 2.75rem 0 5.5rem; }
  .nhero h1 { font-size: clamp(2rem, 8vw, 2.75rem); }
  .page-hero { padding: 2.75rem 0 3rem; }
  .light-hero { padding: 2.75rem 0 2rem; }
  .nhero .row .btn { flex: 1 1 100%; }
  .chips { gap: .45rem; }
  .rates { margin-top: -3.25rem; padding: 1.25rem; border-radius: 14px; }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .stat3 { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .stat3 b { font-size: 1.25rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .contact-card { flex-direction: column; text-align: center; }
  .float-card { position: static; margin: 0; border-radius: 0; }
  .toggle-row { gap: .75rem; }
  .article { padding: 1.4rem 1.25rem; }
  .score-card { padding: 1.4rem; }
  .cta-panel { padding: 1.75rem; border-radius: 16px; }
  .cta-panel .btns .btn { padding: .9rem 1rem; }
  .pub-footer .footer-bottom { flex-direction: column; gap: .75rem; text-align: center; }
  .footer-bottom-links { justify-content: center; flex-wrap: wrap; }
  /* dashboard / admin */
  .dash-content { padding: var(--space-md); }
  .dash-topbar, .topbar { padding-left: var(--space-md); padding-right: var(--space-md); }
  .stats-grid, .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .modal { width: calc(100% - 1.5rem); margin: .75rem; max-height: 92vh; overflow-y: auto; }
  .form-row, .form-grid { grid-template-columns: 1fr !important; }
}

/* ---------- <= 600 (phones) ---------- */
@media (max-width: 600px) {
  .g4, .rate-cols, .quick, .stat-row { grid-template-columns: 1fr; }
  .rate .n { font-size: 2rem; }
  .sec-head h2, .h2 { font-size: 1.7rem; }
  .card { padding: 1.3rem; }
  .calc { padding: 1.3rem; }
  .calc .result .amt { font-size: 2rem; }
  .tabs-pill { width: 100%; justify-content: space-between; }
  .tabs-pill button { padding: .5rem .6rem; font-size: .75rem; flex: 1; }
  .alert-strip .wrap { flex-direction: column; align-items: flex-start; }
  .bankcard { max-width: 100%; }
  .pub-footer .footer-grid { grid-template-columns: 1fr; }
  .util-bar .util-right a:not(:last-child) { display: none; }
  .stats-grid, .stat-cards { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr) !important; }
  .toast-container { left: .75rem; right: .75rem; }
}

/* ---------- <= 480 / 360 (small phones) ---------- */
@media (max-width: 480px) {
  .pub-nav { height: 64px; }
  .mobile-nav { top: 64px; max-height: calc(100vh - 64px); }
  .pub-nav .nav-logo { font-size: .9rem; gap: .5rem; }
  .pub-nav .nav-logo small { display: none; }
  .logo-mark { width: 32px; height: 32px; font-size: 1.1rem; }
  .wrap, .nav-inner, .util-inner { padding-left: var(--space-md); padding-right: var(--space-md); }
  .stat3 { grid-template-columns: 1fr; }
  .eyebrow, .pill { letter-spacing: .1em; }
  .t-card p { font-size: .9rem; }
  .article h2 { font-size: 1.3rem; }
  .auth-card, .login-card, .auth-box { padding: 1.5rem 1.25rem; }
}
@media (max-width: 360px) {
  .nhero h1 { font-size: 1.85rem; }
  .btn-lg { padding: .85rem 1rem; font-size: .875rem; }
  .pub-nav .nav-logo { font-size: .8rem; }
}

/* ---------- large screens ---------- */
@media (min-width: 1600px) { :root { --wrap: 1360px; } }

/* ---------- touch & motion ---------- */
@media (hover: none) { .card.hover:hover, .q-tile:hover, .h-card:hover { transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }


/* ============================================================
   RESPONSIVE PATCH v2 - public site, dashboard and admin
   Layout-only rules that apply at tablet / phone widths.
   Nothing here changes colours, fonts or the desktop layout.
   ============================================================ */

/* ---------- <= 1024: tablets and below ---------- */
@media (max-width: 1024px) {
  /* nothing may push the page wider than the screen */
  body { min-width: 320px; }
  .dash-main { max-width: 100%; }
  [style*="display: grid"] > *, [style*="display:grid"] > *, .dash-content > * { min-width: 0; }

  /* tables scroll sideways inside their box instead of squashing or being clipped */
  .table-wrapper > table:not(.data-table) { min-width: 640px; width: 100%; }
  .surface-card:has(> table), .glass-card:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stitch-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* dashboard + admin shell */
  .dash-sidebar { max-width: 86vw; }
  .dash-main { margin-left: 0 !important; width: 100%; }
  .dash-header-left { min-width: 0; flex: 1 1 auto; }
  .dash-page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-header-right { flex: 0 0 auto; }

  /* two-column inline layouts stack */
  [style*="1.4fr 1fr"], [style*="2fr 1fr"], [style*="1fr 2fr"] { grid-template-columns: 1fr !important; }
  .stats-bento, .card-actions-grid { grid-template-columns: repeat(2, 1fr); }
  .secure-withdrawal { max-width: 100%; }
}

/* ---------- <= 768: large phones / small tablets ---------- */
@media (max-width: 768px) {
  .dash-header { padding-left: var(--space-md); padding-right: var(--space-md); }
  .dash-header-right { gap: var(--space-sm); }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-md); }

  /* filter rows built with inline flex + min-width: one field per line */
  form[style*="flex-wrap"] > .form-group { min-width: 0 !important; flex: 1 1 100% !important; }
  form[style*="flex-wrap"] > .btn { flex: 1 1 calc(50% - var(--space-md)); text-align: center; }

  /* every remaining inline multi-column grid becomes one column
     (auto-fit grids, the 3/4-up stat rows and list rows are handled separately) */
  [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]):not([style*="auto 1fr auto"]):not([style*="repeat(3, 1fr)"]):not([style*="repeat(4, 1fr)"]) { grid-template-columns: 1fr !important; }
  [style*="repeat(4, 1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
  /* dashboard home: the Transfer / Deposit / Cards tiles stay two-up */
  .dash-bento > div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; }
  /* deposit page: QR code above the details */
  [style*="grid-template-columns: auto 1fr"] { justify-items: center; }
  [style*="grid-template-columns: auto 1fr"] > * { width: 100%; }

  /* admin activity rows */
  .audit-entry { grid-template-columns: auto minmax(0, 1fr) !important; }
  .audit-entry > :nth-child(n+3) { grid-column: 2; }

  /* chat bubbles use more of the width */
  .thread-message { max-width: 92%; }

  /* popups */
  .modal-header, .modal-footer { padding-left: var(--space-md); padding-right: var(--space-md); }
  .modal-body { padding: var(--space-md); }
  .modal-footer { flex-wrap: wrap; }
  dialog { max-width: calc(100vw - 1rem); }

  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs > * { flex: 0 0 auto; }

  .auth-page { padding: var(--space-md); }
  .auth-container, .auth-container.auth-wide { max-width: 100%; }
  .info-page .glass-card { padding: var(--space-lg) !important; }
}

/* ---------- <= 600: phones ---------- */
@media (max-width: 600px) {
  .dash-header-right .system-online { display: none; }
  .dash-header-right .btn-ghost[href$="/public/"] { padding-left: .5rem; padding-right: .5rem; }
  [style*="repeat(3, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)) !important; }
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
}

/* ---------- <= 480: small phones ---------- */
@media (max-width: 480px) {
  .dash-header { padding-left: .6rem; padding-right: .6rem; }
  .dash-header-right { gap: .15rem; }
  .dash-header-right .btn-sm { padding-left: .45rem; padding-right: .45rem; }
  .dash-header-right .theme-switch button { padding: .3rem; }
  .dash-page-title { font-size: 1rem; }
  .dash-content { padding: .75rem; }
  .admin-metrics { grid-template-columns: 1fr; }
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr !important; }
  .toast { min-width: 0; max-width: 100%; }
  .auth-header .logo { font-size: 1.35rem; }
  .cta-section { padding: var(--space-xl); }
}

/* ---------- <= 360: very small phones ---------- */
@media (max-width: 360px) {
  .dash-header-right .header-user-btn { display: none; }
  .dash-page-title { font-size: .95rem; }
}

/* ---------- landscape phones: popups stay inside the screen ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .modal, .support-widget-panel { max-height: 90dvh; }
}


/* ============================================================
   PUBLIC NAV on phones (patch v3)
   - Login / Open Account / Dashboard buttons live in the menu on
     phones, so they no longer squeeze the header
   - menu button is drawn with CSS lines and turns into an X when open
   ============================================================ */
.mobile-menu-btn { position: relative; flex: 0 0 auto; font-size: 0; }
.mobile-menu-btn::before, .mobile-menu-btn::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 2px;
  background: currentColor; border-radius: 2px;
  transition: transform .25s ease, box-shadow .25s ease;
}
.mobile-menu-btn::before { transform: translate(-50%, -50%) translateY(-6px); box-shadow: 0 6px 0 currentColor; }
.mobile-menu-btn::after  { transform: translate(-50%, -50%) translateY(6px); }
.mobile-menu-btn[aria-expanded="true"]::before { transform: translate(-50%, -50%) rotate(45deg); box-shadow: none; }
.mobile-menu-btn[aria-expanded="true"]::after  { transform: translate(-50%, -50%) rotate(-45deg); }

@media (max-width: 768px) {
  .pub-nav .nav-actions .btn { display: none; }
  .pub-nav .nav-actions { margin-right: .5rem; flex: 0 0 auto; }
  .pub-nav .mobile-menu-btn { margin-left: 0; }
  .pub-nav .nav-inner { gap: .5rem; }
  .pub-nav .nav-logo { min-width: 0; }
}
@media (max-width: 400px) {
  .pub-nav .nav-logo { font-size: .78rem; letter-spacing: .06em; gap: .4rem; }
  .pub-nav .nav-actions { margin-right: .25rem; }
  .pub-nav .theme-switch { gap: .1rem; padding: .2rem; }
  .pub-nav .theme-switch button { width: 26px; height: 26px; }
  .pub-nav .mobile-menu-btn { width: 38px; height: 38px; }
}
@media (max-width: 340px) {
  .pub-nav .nav-logo { font-size: .7rem; letter-spacing: .02em; }
}