/* =========================================================
   DSP Pooling Wallet — Universal CSS (Mobile-first)
========================================================= */

:root{
  --g1:#0F6EDE; --g2:#6A5BFF;
  --bg1:#0F6EDE; --bg2:#2B89FF;
  --text:#fff; --line:rgba(255,255,255,.18);
  --cap:999px; --r:14px; --content-w:960px;
}

*{ box-sizing:border-box; margin:0; padding:0 }
html{ height:auto; min-height:100%; height:-webkit-fill-available }
body{
  font-family:'Inter','Segoe UI',system-ui,Roboto,Arial,sans-serif;
  color:var(--text);
  background:linear-gradient(180deg,var(--bg1),var(--bg2));
  -webkit-tap-highlight-color:transparent;
  height:auto; min-height:100svh; min-height:-webkit-fill-available;
  overflow-y:auto; overflow-x:hidden; -webkit-overflow-scrolling:touch;
  padding-bottom:max(40px,env(safe-area-inset-bottom));
}
img{display:block;max-width:100%}
.img-protect{-webkit-user-drag:none;-webkit-touch-callout:none;user-select:none}

/* ===== Header ===== */
.appbar{
  position:sticky; top:0; z-index:100; width:100%;
  background:linear-gradient(90deg,var(--g1),var(--g2));
  box-shadow:0 4px 14px rgba(0,0,0,.16);
}
.appbar__inner{
  display:grid; grid-template-columns:auto 1fr auto; align-items:center;
  gap:8px; padding:10px 14px; max-width:1200px; margin:0 auto;
}
.brand{ height:26px; width:auto; object-fit:contain }
.status-cap{
  justify-self:end;
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 12px; border-radius:999px;
  background:linear-gradient(90deg,#5C7CFF99,#6A5BFFAA);
  border:1px solid rgba(255,255,255,.25);
  font-weight:800; font-size:12.5px; white-space:nowrap;
  color:#fff; box-shadow:0 0 12px rgba(0,0,0,.2)
}
.dot{ width:9px; height:9px; border-radius:50% }
.ok{ background:#36f092 } .err{ background:#ff6b6b }
.sep{ opacity:.7 }
@media (max-width:360px){ #hdrTz{ display:none } }

/* ===== Shared width ===== */
.pagehead,.container,.note{ width:min(var(--content-w),94vw); margin:0 auto }

/* ===== Page head ===== */
.pagehead{
  margin:18px auto 12px; text-align:center;
  background:rgba(255,255,255,.08); border:1px solid var(--line);
  border-radius:var(--r); padding:20px 16px; box-shadow:0 4px 14px rgba(0,0,0,.12);
}
.title{ margin:0; font-weight:900; line-height:1.2; text-wrap:balance; font-size:clamp(20px,5vw,26px) }
.title em{ font-style:normal; opacity:.96; font-weight:800; font-size:clamp(16px,4vw,20px) }
.subtitle{ margin:8px 0 12px; opacity:.85; font-size:13px }
.actions{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; margin-top:10px }
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:12px 22px; border-radius:999px;
  font-weight:700; font-size:13px; text-decoration:none; color:#fff;
  border:1px solid var(--line); transition:transform .08s ease, filter .25s ease;
}
.btn.primary{ background:linear-gradient(90deg,#2d8cff,#6a5bff); border:none; box-shadow:0 6px 16px rgba(0,178,255,.28) }
.btn:active{ transform:translateY(1px) }

/* Copy button */
.copy-btn{ background:linear-gradient(90deg,#0ea5e9,#6366f1); border:none; cursor:pointer }
.copy-btn .checkmark{ opacity:0; transform:scale(.5); transition:all .25s cubic-bezier(.4,0,.2,1) }
.copy-btn.copied{ background:linear-gradient(90deg,#22c55e,#16a34a) }
.copy-btn.copied .checkmark{ opacity:1; transform:scale(1) }
.copy-btn.copied .label::after{ content:" Copied"; font-weight:800; margin-left:4px }

/* Toast */
.toast{
  position:fixed; bottom:24px; left:50%;
  transform:translateX(-50%) translateY(100%);
  background:rgba(0,0,0,.82); color:#fff;
  padding:10px 18px; border-radius:999px; font-size:14px; font-weight:600;
  opacity:0; pointer-events:none; transition:all .35s ease; z-index:9999;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0) }

/* ===== KPI Card ===== */
.container{ margin-top:0 }
.card{
  background:rgba(255,255,255,.08); border:1px solid var(--line);
  border-radius:var(--r); padding:20px 16px; box-shadow:0 6px 16px rgba(0,0,0,.15);
}
.row{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px }
.badge{ width:40px; height:40px; object-fit:contain }
.chip{ padding:6px 14px; border-radius:var(--cap); background:rgba(255,255,255,.18); border:1px solid rgba(255,255,255,.28); font-weight:800; font-size:12px }
.kpi{ display:flex; justify-content:center; align-items:baseline; gap:10px; margin-top:6px }
.kpi-num{ font-weight:900; font-size:clamp(28px,8vw,46px) }
.kpi-unit{ font-weight:700; opacity:.95; font-size:clamp(14px,4.2vw,20px) }
.kpi-sub{ margin-top:8px; text-align:center; font-size:clamp(13px,4vw,18px); opacity:.9 }

/* ===== Sparkline + Hologram ===== */
.spark-wrap{
  position:relative; margin-top:12px; height:180px;
  border-top:1px solid var(--line); padding-top:10px; overflow:hidden;
  border-bottom-left-radius:calc(var(--r) - 2px);
  border-bottom-right-radius:calc(var(--r) - 2px);
  isolation:isolate;
}
#flow3d,#spark{ position:absolute; inset:0; display:block }
#flow3d{ z-index:1; pointer-events:none; image-rendering:auto }
#spark { z-index:2; pointer-events:auto; mix-blend-mode:screen; opacity:.98 }
@media (min-width:640px){ .spark-wrap{ height:200px } }

/* Spinner */
.spinner{ display:inline-block; width:1em; height:1em; border:3px solid rgba(255,255,255,.35); border-top-color:#fff; border-radius:50%; animation:spin 1s linear infinite }
@keyframes spin{ to{ transform:rotate(360deg) } }

/* Footer note */
.note{ margin:14px auto 0; font-size:12.5px; opacity:.85; border-top:1px solid var(--line); padding-top:10px }
/* === Image hard-protect (DSP Logo & DSP Lock) === */
.img-protect {
  -webkit-user-drag: none !important;
  -webkit-touch-callout: none !important;
  user-select: none !important;
  pointer-events: none !important;
  position: relative;
}

/* Guard overlay to block right-click / context menu */
.img-guard::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: auto;  /* absorb mouse events */
}

/* Hide image toolbar icons in Chrome/Brave/Safari */
img.img-protect::-webkit-media-controls-panel,
img.img-protect::-webkit-media-controls,
img.img-protect::-webkit-media-controls-enclosure {
  display: none !important;
}
/* ==== Narrow devices fixes (drop-in, keeps your classes) ==== */

/* 1) Always push the status pill to the far right on tiny widths */
@media (max-width: 380px){
  .appbar__inner{
    display: grid;                 /* keep grid but make it stricter */
    grid-template-columns: auto 1fr; /* brand | flexible right column */
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .brand{ min-width: 0 }
  .status-cap{
    justify-self: end;             /* force right edge */
    max-width: 80vw;               /* prevent overflow */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 5px 10px;
    font-size: 12px;
    gap: 6px;
  }
  /* hide timezone only when it would wrap */
  #hdrTz{ display:inline }
  @supports (width: 1cqw){ /* very small safe cut if needed */
    #hdrTz{ display:none }
  }
}

/* 2) Card typography & buttons breathing room on 320–360px */
@media (max-width: 360px){
  .pagehead{ padding: 16px 12px }
  .title{
    font-size: clamp(18px, 5.5vw, 22px);
    line-height: 1.22;
    text-wrap: balance;
  }
  .subtitle{ font-size: 12px }
  .actions{ gap: 8px }
  .actions .btn{
    padding: 10px 16px;
    font-size: 12.5px;
    min-width: 44%;
  }

  .chip{ font-size: 11px; padding: 5px 12px }
  .kpi{ gap: 8px }
  .kpi-num{ font-size: clamp(26px, 8.5vw, 34px) }
  .kpi-unit{ font-size: clamp(12px, 4vw, 16px) }
  .kpi-sub{ font-size: clamp(12px, 3.8vw, 14px) }

  .spark-wrap{
    height: 150px;                 /* a bit shorter to avoid squeeze */
  }
}

/* 3) Ultra-narrow legacy (≤ 320px): stack buttons nicely and guard header */
@media (max-width: 330px){
  .actions{ justify-content: stretch }
  .actions .btn{ flex: 1 1 100%; min-width: 0 }
  .status-cap{ font-size: 11.5px; padding: 4px 10px }
}

/* 4) Make sure canvases never overflow their parent on tiny DPR devices */
#flow3d, #spark{
  max-width: 100%;
  max-height: 100%;
  contain: layout paint size;      /* stop layout thrash on Android 360px */
}