/* Portal polish layer — dashboard + admin.
   Owns: setup checklist, status strip, photo nudge, attention strip,
   ticker containment, card metrics and the layout fixes the base
   stylesheet (three stacked design systems) gets wrong. */

/* ---------- FX ticker: contain it, never let it push the viewport ---------- */
.fx-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 7px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  max-width: 100%;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%);
}
.fx-strip::-webkit-scrollbar { display: none; }
.fx-strip__tag { flex: 0 0 auto; white-space: nowrap; }
.fx-item { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fx-strip__time {
  flex: 0 0 auto;
  padding-right: 18px;
  white-space: nowrap;
  font-size: 10.5px;
  opacity: .75;
}

/* leave room for the floating language pill + learn-more chip */
.main-content { padding-bottom: 76px; }

/* ---------- account / routing figures stay verbatim ---------- */
.mini-stat-value { font-variant-numeric: tabular-nums; }
.mini-stat-value[data-live-skip] {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- greeting meta ---------- */
.pmeta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: rgba(255,255,255,.62); }
.pmeta span { display: inline-flex; align-items: center; gap: 6px; }
.pmeta i { font-size: 10px; color: var(--secondary, #c9a850); }

/* ---------- stat cards: one metric system, no dead gaps ---------- */
.stat-card { padding: 18px 20px !important; }
.stat-card-header { margin-bottom: 8px !important; align-items: center; }
.stat-card-icon { width: 40px !important; height: 40px !important; font-size: 17px !important; border-radius: 10px !important; }
.stat-card-value,
.stat-value { font-variant-numeric: tabular-nums; line-height: 1.15; margin-bottom: 2px; }
.stat-card-label { margin-top: 2px; }
.stat-card-trend:empty { display: none; }
.stat-card:hover { transform: none !important; }

/* ---------- setup checklist ---------- */
.pcheck {
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  margin: 0 0 22px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.pcheck__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.pcheck__title { font-size: 14px; font-weight: 700; color: var(--primary, #0d1b2a); }
.pcheck__count { font-size: 12px; color: #6b7280; }
.pcheck__list { display: grid; gap: 8px; }
.pcheck__item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: #374151; line-height: 1.35;
  padding: 9px 12px; border-radius: 10px; background: #f8fafc;
  border: 1px solid transparent; cursor: pointer; text-align: left;
  width: 100%; font-family: inherit;
}
.pcheck__item:hover { border-color: rgba(13,27,42,.14); }
.pcheck__item i.dot {
  width: 18px; height: 18px; flex: 0 0 18px;
  border-radius: 50%; border: 2px solid #cbd5e1;
  display: grid; place-items: center;
  font-size: 9px; line-height: 1; color: transparent;
}
.pcheck__item .lbl { flex: 1 1 auto; text-decoration-skip-ink: none; text-decoration-thickness: 1px; }
.pcheck__item.done { color: #6b7280; }
.pcheck__item.done i.dot { background: #16a34a; border-color: #16a34a; color: #fff; }
.pcheck__item.done .lbl { text-decoration: line-through; }

/* ---------- photo nudge ---------- */
.pnudge {
  display: flex; align-items: center; gap: 12px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 13px;
}
.pnudge span { flex: 1 1 auto; }
.pnudge button { margin-left: auto; border: 0; background: #92400e; color: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.pnudge .x { background: transparent; color: #92400e; margin-left: 4px; font-size: 16px; padding: 2px 6px; }

/* ---------- grids that used to blow the viewport ---------- */
.plans-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
@media (max-width: 1024px) { .plans-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 700px) { .plans-grid { grid-template-columns: 1fr !important; } }
.stats-row, .stats-grid { min-width: 0; }
.stats-row > *, .stats-grid > * { min-width: 0; }

/* split layout: inline `1fr 360px` wrappers have a 360px floor and the 1fr
   child keeps min-width:auto, so on phones they blew the page out. */
[class=""] {}
[style*="grid-template-columns:1fr 360px"],
[style*="grid-template-columns: 1fr 360px"] { grid-template-columns: minmax(0, 1fr) 360px !important; }
[style*="grid-template-columns:1fr 360px"] > div:first-child,
[style*="grid-template-columns: 1fr 360px"] > div:first-child { min-width: 0; }

@media (max-width: 900px) {
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- virtual card: no clipped bank name ---------- */
.vc-bank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- admin attention strip ---------- */
.pattention { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.pattention__card {
  background: #fff; border: 1px solid #e5e7eb; border-left: 3px solid var(--secondary, #c9a850);
  border-radius: 10px; padding: 14px 16px; cursor: pointer;
}
.pattention__card:hover { border-color: #d1d5db; box-shadow: 0 2px 6px rgba(16,24,40,.06); }
.pattention__n { font-size: 22px; font-weight: 800; color: var(--primary, #0d1b2a); line-height: 1; font-variant-numeric: tabular-nums; }
.pattention__l { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin-top: 6px; }
.pattention__card.zero { border-left-color: #d1d5db; opacity: .7; cursor: default; }

/* KPI placeholder shimmer while the first payload lands */
.stat-value[data-pending="1"] { color: transparent; background: linear-gradient(90deg,#eee 25%,#f6f6f6 37%,#eee 63%); background-size: 400% 100%; border-radius: 4px; animation: pshimmer 1.2s ease-in-out infinite; }
@keyframes pshimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------- language pill never sits on the bottom nav ---------- */
@media (max-width: 900px) {
  #ctgmc_lang_widget { bottom: 82px !important; right: 12px !important; }
  .pattention { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- admin KPI grid: 10 cards, no orphan half-row ---------- */
@media (min-width: 1240px) { #admin-dashboard .stats-grid { grid-template-columns: repeat(5, minmax(0,1fr)) !important; } }
@media (min-width: 901px) and (max-width: 1239px) {
  #admin-dashboard .stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)) !important; }
  #admin-dashboard .stat-card:nth-child(9),
  #admin-dashboard .stat-card:nth-child(10) { grid-column: span 2; }
}
@media (max-width: 900px) { #admin-dashboard .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }
#admin-dashboard .stat-card { min-height: 96px; }
#admin-dashboard .stat-change[hidden] { display: none !important; }

/* wide tables scroll inside their card instead of being clipped */
.p-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 100%; min-width: 0; }
.p-table-scroll > table { min-width: 640px; }
/* grid/flex items default to min-width:auto, so a 640px table stretched the card */
.content-grid, .content-grid-3, .profile-grid, .stats-row, .stats-grid, .card, .main-content, .page-content { min-width: 0; }
@media (min-width: 901px) {
  .p-table-scroll > table { min-width: 0; }
}

/* ---------- phones: every two-track layout grid stacks ----------
   The base stylesheet only re-declares some of these, and where it does it
   leaves `1fr` (min-width:auto) so the track grows to the widest child and the
   card is clipped. Force one column and let the items shrink. */
@media (max-width: 900px) {
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:1fr 380px"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns:1fr auto"],
  [style*="grid-template-columns:1fr auto 1fr"],
  .transfer-page-grid,
  .content-grid,
  .content-grid-3,
  .profile-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start;
  }
  [style*="grid-template-columns"] > *,
  .transfer-page-grid > *,
  .content-grid > *,
  .profile-grid > * { min-width: 0; }

  /* 3+ up widget rows: two per line, never more */
  [style*="repeat(3,1fr)"],
  [style*="repeat(4,1fr)"],
  [style*="repeat(5,1fr)"],
  [style*="repeat(7,1fr)"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* toggle rows: label gets the room, switch keeps its size */
  .mini-stat .mini-stat-label { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
  .mini-stat .toggle-switch { flex: 0 0 auto; }
  .card-body > .btn-block { width: 100%; }
}

/* ---------- phones: header fits, chips wrap ---------- */
@media (max-width: 640px) {
  .main-content .topbar { gap: 6px !important; padding-right: 14px !important; }
  .topbar-left { flex: 1 1 auto; min-width: 0; gap: 10px; }
  .topbar-title { font-size: 17px !important; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { flex: 0 0 auto; gap: 8px; }
  .topbar-user { flex: 0 0 auto; }
  .topbar-user-info { display: none; }
  /* quick-amount chips: two per line instead of squeezing five into one row */
  #section-transfer .form-group > div[style*="display:flex"],
  #section-wire .form-group > div[style*="display:flex"] { flex-wrap: wrap; }
  #section-transfer .form-group > div[style*="display:flex"] > .btn,
  #section-wire .form-group > div[style*="display:flex"] > .btn {
    flex: 1 1 calc(50% - 4px); min-width: 0; white-space: nowrap;
  }
}

@media (max-width: 900px) {
  /* tighter setting rows: 65px per toggle was mostly padding */
  #section-settings .mini-stat { padding: 10px 0; }
  /* the language pill sat on the last card / nav: lift and shrink it */
  #ctgmc_lang_widget { bottom: 96px !important; right: 10px !important; padding: 5px 8px !important; }
  /* narrower fade so the last ticker value isn't sliced mid-glyph */
  .fx-strip { -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 16px), transparent 100%);
              mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 16px), transparent 100%); }
}

@media (max-width: 900px) {
  /* profile banner is a fixed row (avatar + text + buttons) — it has to wrap */
  .profile-banner { flex-wrap: wrap; gap: 14px !important; padding: 22px 18px !important; }
  .profile-banner > div:last-child { margin-left: 0 !important; width: 100%; }
  .profile-banner > div:last-child .btn { flex: 1 1 auto; }
  .profile-name { font-size: 22px !important; }
}

@media (max-width: 900px) {
  /* any button row inside a card wraps instead of pushing past the edge */
  .card-body > div[style*="display:flex"] { flex-wrap: wrap; }
  .card-body > div[style*="display:flex"] > .btn { flex: 1 1 auto; min-width: 0; }
}
@media (max-width: 900px) {
  .card-body { flex-wrap: wrap; }
  .card-body > .btn { flex: 1 1 auto; min-width: 0; max-width: 100%; }
}

/* cards size to their content instead of stretching to the tallest sibling */
#section-settings > div[style*="grid-template-columns"] { align-items: start; }

/* ---------- drawer veil: single source of truth ----------
   The inline #sidebarOverlay style could stay visible while the panel was
   still off-canvas (a full-screen dark veil with nothing in it). The veil is
   now tied to the same body class that moves the panel. */
@media (max-width: 900px) {
  /* the overlay element IS the veil: both it and the panel follow .snav-open */
  #sidebarOverlay { display: none !important; }
  body.snav-open #sidebarOverlay { display: block !important; }
  body.snav-open .sidebar { left: 0 !important; }
  body.snav-open { overflow: hidden; }
}

/* ---------- compositing ----------
   style.css blurs the backdrop of every modal overlay; with 20+ fixed overlays
   in the dashboard that is 20 full-screen composited layers on Android and
   Chrome starts dropping paints (content goes blank while scrolling). Blur only
   the one that is open. */
.modal-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.modal-overlay.active {
  backdrop-filter: blur(3px) !important;
  -webkit-backdrop-filter: blur(3px) !important;
}
/* keep the native bounce: contain felt like the page was stuck */
html { scroll-behavior: smooth; }

/* ---------- motion that cannot strand content ----------
   Transform-only entrance on the section (transient class), press feedback and
   hover lift back on. Nothing here depends on an animation finishing. */
.db-section.sec-in { animation: secRise .3s cubic-bezier(.22,1,.36,1); }
@keyframes secRise { from { transform: translateY(9px); } to { transform: none; } }

.btn:active,
button:not(.modal-close):not(.topbar-menu-btn):active { transform: scale(.975); }

@media (hover: hover) {
  .card:hover, .stat-card:hover, .mini-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(8,20,32,.10);
  }
}

/* native, momentum scrolling everywhere it matters */
.page-content, .table-wrap, .p-table-scroll, .modal-body, .sidebar {
  -webkit-overflow-scrolling: touch;
}
.sidebar { overscroll-behavior: contain; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .db-section.sec-in { animation: none; }
  .card:hover, .stat-card:hover, .mini-stat:hover { transform: none; }
}

/* long translated words must not widen the page (German/Polish etc.) */
#section-transfer .form-label,
#section-transfer .card-title,
#section-transfer .p-table th,
#section-transfer .stat-card-label,
.dashboard-shell .card-title,
.dashboard-shell .form-label{overflow-wrap:anywhere;word-break:break-word}
#section-transfer input,#section-transfer select,#section-transfer textarea{min-width:0;max-width:100%}

/* tabs / buttons with long translated labels must wrap, not push the page */
.transfer-tabs{flex-wrap:wrap}
.transfer-tab{white-space:normal;font-size:12px;line-height:1.25;padding-left:10px;padding-right:10px}
#section-invest-banking .btn{white-space:normal;line-height:1.25;max-width:100%}
.dashboard-shell .btn,.db-section .btn{max-width:100%}
