/* Shared responsive fixes — index + customer/jeweller dashboards */

/* ── Global safety ─────────────────────────────────────────────── */
html {
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* ── Index — tablet nav & ticker (768–991px) ───────────────────── */
@media (max-width: 991px) {
  body.pub-layout:not(:has(.shell)) .nav-links {
    display: none;
  }

  body.pub-layout:not(:has(.shell)) .nav-burger {
    display: flex;
  }

  body.pub-layout:not(:has(.shell)) .nav {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  body.pub-layout:not(:has(.shell)) .nav-end {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
  }

  body.pub-layout:not(:has(.shell)) .ticker-bar {
    gap: 0;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  /* Hide static label on mobile/tablet — give full width to scrolling rates */
  body.pub-layout:not(:has(.shell)) .ticker-bar .ticker-live {
    display: none;
  }

  body.pub-layout:not(:has(.shell)) .ticker-scroll {
    animation-duration: 20s;
  }

  body.pub-layout:not(:has(.shell)) .pub-shell-ticker {
    gap: 0;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  body.pub-layout:not(:has(.shell)) .pub-shell-ticker .ticker-live {
    display: none;
  }

  body.pub-layout:not(:has(.shell)) .pub-shell-ticker .ticker-track {
    min-width: 0;
    max-width: 100%;
  }

  body.pub-layout:not(:has(.shell)) .invest-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
  }

  body.pub-layout:not(:has(.shell)) .invest-tabs::-webkit-scrollbar {
    display: none;
  }

  body.pub-layout:not(:has(.shell)) .hero-visual {
    min-width: 0;
    max-width: 100%;
  }

  body.pub-layout:not(:has(.shell)) .hv-grams {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
  }

  body.pub-layout:not(:has(.shell)) .idx-portfolio-card {
    padding: 22px 18px;
  }

  body.pub-layout:not(:has(.shell)) .jw-split {
    gap: 32px;
  }
}

/* Index — very small phones */
@media (max-width: 359px) {
  body.pub-layout:not(:has(.shell)) .nav-brand {
    font-size: 0.82rem;
  }

  body.pub-layout:not(:has(.shell)) .nav-mark {
    width: 30px;
    height: 30px;
  }

  body.pub-layout:not(:has(.shell)) .hero-h1 {
    font-size: 1.65rem;
  }

  body.pub-layout:not(:has(.shell)) .fstrip-inner {
    grid-template-columns: 1fr;
  }

  body.pub-layout:not(:has(.shell)) .stats-row {
    grid-template-columns: 1fr;
  }

  body.pub-layout:not(:has(.shell)) .stat-col:nth-child(odd) {
    border-right: none;
  }
}

/* ── Dashboard shell — tablet (768–991px) ──────────────────────── */
@media (min-width: 768px) and (max-width: 991px) {
  .shell .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--th);
    padding: 8px 16px;
    row-gap: 8px;
    align-content: center;
  }

  .shell .tb-crumb {
    display: none;
  }

  .shell .tb-ticker {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .shell .tb-ticker::-webkit-scrollbar {
    display: none;
  }

  .shell .main {
    padding: 20px 16px 40px;
  }

  .shell .stat-row,
  .shell .lg-summary,
  .shell .ln-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .shell .g2 {
    grid-template-columns: 1fr;
  }

  .shell .g3,
  .shell .g4 {
    grid-template-columns: 1fr 1fr;
  }

  .shell .sb-proof-grid,
  .shell .acct-req-grid,
  .shell .acct-quiet-grid {
    grid-template-columns: 1fr;
  }

  .shell .acct-hero {
    flex-wrap: wrap;
  }

  .shell .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .shell .tbl {
    min-width: 480px;
  }

  .shell .tbl.tbl-sm {
    min-width: 0;
    width: 100%;
  }

  .shell .row,
  .shell .row-b,
  .shell .pr-filters-row,
  .shell .lg-filters-row {
    flex-wrap: wrap;
  }

  .shell .seg,
  .shell .tabs {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .shell .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
  }

  .shell .hero-stat {
    padding: 0;
    border-right: none;
  }
}

/* Dashboard — narrow desktop (992–1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .shell .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--th);
    padding: 8px 20px;
    row-gap: 8px;
  }

  .shell .tb-ticker {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .shell .tb-ticker::-webkit-scrollbar {
    display: none;
  }

  .shell .main {
    padding: 24px 20px 44px;
  }

  .shell .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .shell .g4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .shell .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* Dashboard — all widths: prevent content blowout */
.shell .col,
.shell .main,
.shell .panel,
.shell .card,
.shell .card-p,
.shell .hero,
.shell .ph,
.shell .notice,
.shell .bc-hd,
.shell .bc-body {
  min-width: 0;
}

.shell .notice span:last-child,
.shell .tb-crumb,
.shell .ph p {
  overflow-wrap: break-word;
}

/* Modals — safe on every viewport */
.modal,
.modal--pay,
.modal--pr-add,
.modal--sb-proof,
.modal--gt-scan {
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

/* Dashboard mobile — extra polish (extends inline rules) */
@media (max-width: 767px) {
  .shell .topbar {
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }

  .shell .main {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .shell .bnav-inner {
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .shell .modal-acts .btn,
  .shell .pr-form-foot .btn {
    flex: 1 1 auto;
    min-width: min(100%, 140px);
  }

  .shell .acct-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .shell .jc-rates,
  .shell .vc-grid {
    grid-template-columns: 1fr 1fr;
  }

  .shell .row > .search,
  .shell .row-b > .search {
    flex: 1 1 100%;
    min-width: 0 !important;
  }

  .shell .row > .sel,
  .shell .row-b > .sel {
    flex: 1 1 100%;
    max-width: none !important;
    width: 100%;
  }
}

/* ── Notification tray (customer + jeweller dashboards) ─────────── */
.shell .tb-notif-wrap {
  position: relative;
  flex-shrink: 0;
}

.shell .ib.is-on {
  background: var(--hover);
  color: var(--ink);
}

.shell .ib .nb[data-count] {
  width: auto;
  min-width: 14px;
  height: 14px;
  top: 4px;
  right: 4px;
  padding: 0 3px;
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shell .ib .nb:not([hidden]):not([data-count]) {
  width: auto;
  min-width: 14px;
  height: 14px;
  top: 4px;
  right: 4px;
  padding: 0 3px;
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shell .notif-tray {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - var(--th, 56px) - 32px));
  background: var(--s0);
  border: 1px solid var(--b0);
  border-radius: var(--r2, 10px);
  box-shadow: var(--float-shadow, 0 12px 40px rgba(0, 0, 0, 0.18));
  z-index: 460;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shell .notif-tray[hidden] {
  display: none !important;
}

.shell .notif-tray-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}

.shell .notif-tray-hd h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.shell .notif-tray-mark {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold, #a67a28);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--t1, 0.15s);
}

.shell .notif-tray-mark:hover {
  background: var(--hover);
}

.shell .notif-tray-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--ink2);
  flex-shrink: 0;
  transition: background var(--t1, 0.15s), color var(--t1, 0.15s);
}

.shell .notif-tray-close svg {
  width: 16px;
  height: 16px;
}

.shell .notif-tray-close:hover {
  background: var(--hover);
  color: var(--ink);
}

.shell .notif-tray-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.shell .notif-tray-item {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: background var(--t1, 0.15s);
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
}

.shell .notif-tray-item:hover {
  background: var(--hover);
}

.shell .notif-tray-item.is-unread {
  background: rgba(212, 168, 92, 0.08);
}

.shell .notif-tray-item.is-unread:hover {
  background: rgba(212, 168, 92, 0.14);
}

.shell .notif-tray-ico {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
  background: var(--s2);
}

.shell .notif-tray-item.is-unread .notif-tray-ico {
  background: rgba(212, 168, 92, 0.18);
}

.shell .notif-tray-body {
  flex: 1;
  min-width: 0;
}

.shell .notif-tray-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.shell .notif-tray-desc {
  font-size: 0.7rem;
  color: var(--ink2);
  margin-top: 2px;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.shell .notif-tray-time {
  font-size: 0.62rem;
  color: var(--t-mu, var(--ink2));
  margin-top: 4px;
}

.shell .notif-tray-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold, #a67a28);
  flex-shrink: 0;
  margin-top: 6px;
  opacity: 0;
}

.shell .notif-tray-item.is-unread .notif-tray-dot {
  opacity: 1;
}

.shell .notif-tray-empty-wrap {
  list-style: none;
}

.shell .notif-tray-empty-wrap[hidden] {
  display: none;
}

.shell .notif-tray-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 0.74rem;
  color: var(--ink2);
}

.shell .notif-tray-foot {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}

.shell .notif-tray-foot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink2);
  transition: background var(--t1, 0.15s), color var(--t1, 0.15s);
}

.shell .notif-tray-foot-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.shell .notif-tray-foot-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

@media (max-width: 767px) {
  .shell .notif-tray {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: min(72vh, 560px);
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .shell .notif-tray-close {
    display: flex;
  }
}

@media (max-width: 399px) {
  .shell .g4,
  .shell .g3,
  .shell .jc-rates {
    grid-template-columns: 1fr;
  }

  .shell .hero-grid,
  .shell .stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .shell .tb-logo-name {
    font-size: 0.74rem;
  }

  .shell .btab {
    font-size: 0.48rem;
    padding: 4px 2px;
  }
}

/* ── Public pages: bottom nav replaces hamburger on mobile ── */
@media (max-width: 767px) {
  /* Hide hamburger on any page with the bottom nav active */
  body.has-pub-bnav .nav-burger {
    display: none !important;
  }

  /* Prevent drawer from showing (it shouldn't — no trigger anymore) */
  body.has-pub-bnav .nav-drawer {
    display: none !important;
  }

  /* Compact home-page top nav: tighter padding */
  body.has-pub-bnav.pub-layout .nav {
    padding: 0 max(12px, env(safe-area-inset-left, 0px));
    gap: 8px;
  }

  body.has-pub-bnav.pub-layout .nav-brand {
    font-size: 0.88rem;
  }

  body.has-pub-bnav.pub-layout .nav-mark {
    width: 30px;
    height: 30px;
  }
}

/* ── Public pages: mobile/tablet width safety ───────────────── */

/* Prevent any oversized child from causing horizontal scroll.
   clip (not hidden) avoids creating a scroll container on the body,
   which breaks native touch scrolling on iOS Safari. */
.pub-page {
  overflow-x: clip;
}

/* Non-enterprise inner pages: safe-area horizontal padding */
@media (max-width: 767px) {
  .pub-page-main:not(.pub-enterprise-main) {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  /* Enterprise body content: safe-area padding */
  .pub-enterprise-main .inner-wide {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  /* All pub-page-main content: prevent element blowout */
  .pub-page-main,
  .pub-page-main .inner,
  .pub-enterprise-main .inner-wide {
    min-width: 0;
    max-width: 100%;
  }

  /* Subnav pills: full-width scroll row */
  .pub-subnav {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .pub-subnav::-webkit-scrollbar {
    display: none;
  }
}

/* Tablet (768-991px): safe-area insets for enterprise pages */
@media (min-width: 768px) and (max-width: 991px) {
  .pub-enterprise-main .inner-wide {
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
  }

  .pub-page-main:not(.pub-enterprise-main) {
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
  }
}
