/* =========================================================================
   Biuci — Dashboard layout (depends on styles.css tokens)
   ========================================================================= */
body.app { background: var(--bg-soft); }
body.app-guarding { overflow: hidden; }

.app-gate {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background:
    radial-gradient(44rem 24rem at 50% 0%, rgba(var(--blue-rgb), .1), transparent 62%),
    var(--bg-soft);
  transition: opacity .18s ease, visibility .18s ease;
}
.app-gate__mark {
  width: 86px; height: 86px; border-radius: 24px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  position: relative;
}
.app-gate__mark img { width: 44px; height: auto; }
.app-gate__mark::after {
  content: ""; position: absolute; inset: -8px; border-radius: 30px;
  border: 2px solid rgba(var(--blue-rgb), .15); border-top-color: var(--blue);
  animation: spin .72s linear infinite;
}
body.app-ready .app-gate { display: none; opacity: 0; visibility: hidden; pointer-events: none; }
body.app-guarding .dash { opacity: 0; visibility: hidden; pointer-events: none; }
body.app-ready .dash { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }

.dash { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }

/* Sidebar */
.side {
  background: #fff; border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  box-shadow: 1px 0 0 rgba(10, 11, 13, .02);
}
.side .brand { padding: 6px 8px 18px; }
.side .brand img { height: 28px; }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; font-size: .95rem; transition: background .16s ease, color .16s ease, transform .16s ease;
}
.side__nav a:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; transform: translateX(2px); }
.side__nav a.active { background: var(--blue-050); color: var(--blue); font-weight: 600; box-shadow: inset 3px 0 0 var(--blue); }
.side__nav a svg { width: 20px; height: 20px; flex: 0 0 20px; }
.side__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.side__user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.side__avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; }
.side__user small { color: var(--text-3); display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__signout {
  color: var(--text-2); padding: 10px 12px; display: flex; gap: 12px; align-items: center;
  border-radius: 10px; font-weight: 500; transition: background .16s ease, color .16s ease;
}
.side__signout:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.side__signout svg { flex: 0 0 20px; }

/* Main */
.main { padding: 28px 36px 64px; width: min(100%, 1120px); max-width: 100%; min-width: 0; }
.main__top { display: none; }
.page { display: none; opacity: 1; min-width: 0; max-width: 100%; }
.page.active { display: block; opacity: 1; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page__title { font-size: 1.6rem; margin-bottom: 4px; }
.page__sub { color: var(--text-2); margin-bottom: 24px; }

/* Balance hero */
.bal-hero { background: linear-gradient(135deg, #0a0b0d, #0c2f2c 60%, #0b9e8d); color: #fff; border-radius: var(--radius-lg); padding: 28px 30px; margin-bottom: 24px; position: relative; overflow: hidden; }
.bal-hero::before { content: ""; position: absolute; width: 240px; height: 240px; top: -90px; right: -40px; border-radius: 50%; background: radial-gradient(circle, rgba(236,197,100,.34), transparent 70%); pointer-events: none; }
.bal-hero::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(120deg, rgba(255,255,255,.14), transparent 30%, transparent 70%, rgba(255,255,255,.06)); opacity: .35; pointer-events: none; }
.bal-hero > * { position: relative; z-index: 1; }
.bal-hero__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.bal-hero small { opacity: .75; }
.bal-hero .bal-amt {
  display: inline-block;
  font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -.03em; margin: 4px 0 18px;
  transform-origin: left center;
}
.bal-hero .bal-amt.is-refreshing { animation: balanceRefresh .75s ease; }
.bal-hero .bal-amt.is-changing { animation: balanceChange .9s ease; }
@keyframes balanceRefresh {
  0% { opacity: 1; text-shadow: none; }
  45% { opacity: .82; text-shadow: 0 0 18px rgba(255,255,255,.38); }
  100% { opacity: 1; text-shadow: none; }
}
@keyframes balanceChange {
  0% { transform: scale(1); text-shadow: none; }
  35% { transform: scale(1.025); text-shadow: 0 0 24px rgba(236,197,100,.42); }
  100% { transform: scale(1); text-shadow: none; }
}
.price-status { font-size: .78rem; color: rgba(255,255,255,.72); margin: -10px 0 18px; }
.currency-picker {
  display: inline-grid; grid-template-columns: auto auto; align-items: center; gap: 10px;
  color: rgba(255,255,255,.78); font-size: .78rem; font-weight: 600;
}
.currency-picker__label { line-height: 1; }
.currency-picker__control {
  position: relative; display: inline-flex; align-items: center;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px;
  background: rgba(255,255,255,.14); box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.currency-picker__control::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
  border-right: 1.7px solid rgba(255,255,255,.82); border-bottom: 1.7px solid rgba(255,255,255,.82);
  transform: translateY(-64%) rotate(45deg); pointer-events: none;
}
.currency-picker select {
  min-width: 104px; border: 0; border-radius: 999px; appearance: none;
  background: transparent; color: #fff; padding: 8px 34px 8px 14px;
  font: inherit; outline: none; cursor: pointer;
}
.currency-picker__control:focus-within { box-shadow: 0 0 0 3px rgba(255,255,255,.18), inset 0 1px 0 rgba(255,255,255,.12); }
.currency-picker option { color: var(--ink); background: #fff; }
.bal-hero .row { gap: 10px; flex-wrap: wrap; }
.bal-hero .btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.bal-hero .btn-ghost:hover { background: rgba(255,255,255,.24); }

/* Signup bonus */
.bonus-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 24px;
  align-items: center; margin-bottom: 24px; border-color: rgba(11, 158, 141, .24);
  background: linear-gradient(135deg, #fff, #fbf9f2 58%, #eef8f7);
  box-shadow: 0 18px 40px rgba(10, 11, 13, .06);
}
.bonus-card--deposit { margin-bottom: 18px; }
.bonus-card h3 { margin: 12px 0 8px; font-size: 1.32rem; }
.bonus-card__copy p { color: var(--text-2); max-width: 640px; margin-bottom: 16px; }
.bonus-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.bonus-stats div {
  background: rgba(255,255,255,.78); border: 1px solid rgba(10, 11, 13, .08);
  border-radius: 10px; padding: 11px 12px;
}
.bonus-stats small { display: block; color: var(--text-3); font-size: .72rem; margin-bottom: 4px; }
.bonus-stats b { font-size: .95rem; }
.bonus-card__meter {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 12px 28px rgba(10, 11, 13, .05);
}
.bonus-progress {
  height: 12px; border-radius: 999px; overflow: hidden; background: #eceff3;
  box-shadow: inset 0 1px 2px rgba(10, 11, 13, .08);
}
.bonus-progress span {
  display: block; width: 0%; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #0b9e8d, #2f80ed, #ecc564);
  transition: width .55s cubic-bezier(.2,.8,.2,1);
}
.bonus-card.is-unlocked .bonus-progress span { animation: bonusShine 1.2s ease; }
@keyframes bonusShine {
  0% { filter: brightness(1); }
  45% { filter: brightness(1.18); }
  100% { filter: brightness(1); }
}
.bonus-marks, .bonus-preview {
  display: flex; justify-content: space-between; gap: 12px; color: var(--text-3);
  font-size: .78rem; margin-top: 8px;
}
.bonus-slider-label {
  display: block; margin-top: 18px; color: var(--text-2); font-size: .82rem; font-weight: 600;
}
.bonus-slider {
  width: 100%; accent-color: var(--blue); margin: 10px 0 2px;
}
.bonus-preview {
  align-items: center; color: var(--text-2); font-size: .86rem; margin-top: 8px;
}
.bonus-preview span {
  min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap;
}
.bonus-preview b { color: var(--ink); flex: 0 0 auto; }

/* Asset table */
.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.tbl td { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-soft); }
.tbl .asset-id .ico { width: 32px; height: 32px; flex: 0 0 32px; }
.tbl .right { text-align: right; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }

/* Deposit selector */
.asset-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.asset-pick button {
  display: flex; align-items: center; gap: 10px; padding: 12px; border: 1.5px solid var(--line-2);
  border-radius: 12px; background: #fff; cursor: pointer; font-family: inherit; font-weight: 600; color: var(--ink);
}
.asset-pick button:hover { border-color: var(--blue); }
.asset-pick button.active { border-color: var(--blue); background: var(--blue-050); }
.asset-pick .ico { width: 28px; height: 28px; flex: 0 0 28px; }
.net-pick { display: flex; flex-direction: column; gap: 8px; }
.net-pick button { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border: 1.5px solid var(--line-2); border-radius: 12px; background: #fff; cursor: pointer; font-family: inherit; }
.net-pick button:hover { border-color: var(--blue); }
.net-pick button.active { border-color: var(--blue); background: var(--blue-050); }
.qr-box { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.qr-box .qr { width: 168px; height: 168px; flex: 0 0 168px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.qr-box .qr img { width: 100%; height: 100%; }

/* Chat */
.chat { display: flex; flex-direction: column; height: min(64vh, 560px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat__head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat__status { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.chat__status.online { background: var(--green); }
.chat__body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--bg-soft); }
.msg { max-width: 76%; padding: 11px 14px; border-radius: 16px; font-size: .92rem; line-height: 1.4; }
.msg small { display: block; font-size: .68rem; opacity: .6; margin-top: 4px; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.agent { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.system { align-self: center; background: var(--bg-soft-2); color: var(--text-2); font-size: .82rem; text-align: center; max-width: 90%; }
.chat__form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat__form .input { flex: 1; }

/* Quick grid */
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Staking flow */
.stake-flow {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 18px; padding: 16px;
}
.stake-flow__step {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); padding: 14px;
}
.stake-flow__step b { display: block; margin-bottom: 4px; }
.stake-flow__step span { display: block; color: var(--text-2); font-size: .88rem; line-height: 1.4; }
.stake-status {
  display: block; margin-top: 3px; color: var(--text-3); font-size: .82rem;
}
.stake-status.ok { color: var(--green); font-weight: 600; }

/* Card application */
.card-program {
  display: grid; grid-template-columns: minmax(360px, 470px) minmax(240px, 1fr); gap: clamp(24px, 4vw, 48px);
  align-items: center; margin-bottom: 18px; overflow: hidden; min-width: 0;
}
.card-stack--app {
  width: 100%; max-width: 390px; margin: 0; padding: 24px 0;
}
.card-stack--app .bcard {
  border-radius: 14px;
}
.card-stack--app .bcard__num {
  font-size: clamp(.92rem, 2.1vw, 1.2rem);
}
.biuci-card-preview {
  background: linear-gradient(135deg, #0a0b0d, #0c3b38 58%, #0b9e8d);
  border-radius: 18px; padding: 24px; color: #fff; aspect-ratio: 1.586 / 1;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 210px;
  box-shadow: 0 20px 44px rgba(10, 11, 13, .2);
}
.biuci-card-preview strong { font-size: 1.2rem; letter-spacing: 0; }
.biuci-card-preview .badge { background: rgba(255,255,255,.16); color: #fff; }
.biuci-card-preview .tiny { color: rgba(255,255,255,.78); }
.biuci-card-preview__number {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .1em; font-size: clamp(1rem, 2.6vw, 1.28rem);
}
.card-program__copy { max-width: 520px; min-width: 0; }
.card-program__copy h3 { margin-top: 12px; }
.card-kyc, .card-review { max-width: 760px; }
.card-kyc__head { align-items: flex-start; margin-bottom: 18px; }
.card-kyc__grid { gap: 0 16px; }
.card-kyc__wide { grid-column: 1 / -1; }
.card-kyc__check { margin: 2px 0 16px; }
.card-review__head { align-items: center; margin-bottom: 16px; }
.card-review__steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0;
}
.card-review__steps div {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); padding: 14px; min-height: 96px;
}
.card-review__steps b {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: var(--blue); color: #fff; margin-bottom: 10px;
}
.card-review__steps span { color: var(--text-2); font-size: .9rem; }
.notice-note {
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm); background: var(--amber-bg);
  color: var(--text); padding: 12px 14px;
}

/* Medium dashboard widths still keep the sidebar, so dense panels need to stack early. */
@media (max-width: 1280px) {
  .main { padding: 24px 24px 64px; }
  .qgrid { grid-template-columns: 1fr; }
  .bonus-card { grid-template-columns: 1fr; }
  .card-program { grid-template-columns: 1fr; gap: 22px; }
  .card-stack--app { margin: 0; max-width: min(390px, 100%); }
  .card-program__copy { max-width: 620px; }
}

@media (max-width: 1100px) {
  .stake-flow { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .qgrid { grid-template-columns: 1fr; }
}

/* Mobile */
.side__close, .menu-btn { display: none; }
@media (max-width: 880px) {
  .dash { grid-template-columns: 1fr; }
  .side {
    position: fixed; right: 0; left: auto; top: 0; bottom: 0; width: 260px; height: 100%; z-index: 120;
    transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .side { transform: translateX(0); }
  .side__close { display: block; position: absolute; right: 12px; left: auto; top: 14px; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--text-3); }
  .main { padding: 16px 18px 80px; }
  .main__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
  .main__top .brand { order: 1; }
  .menu-btn {
    width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
    order: 2; margin-left: auto;
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  }
  .menu-btn span { display: block; width: 18px; height: 2px; background: var(--ink); margin: 0; border-radius: 2px; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(10,11,13,.4); z-index: 110; }
  body.nav-open .scrim { display: block; }
  .bal-hero__top { flex-direction: column; align-items: flex-start; }
  .currency-picker { width: 100%; grid-template-columns: 1fr auto; }
  .currency-picker select { min-width: 112px; }
  .bonus-card { grid-template-columns: 1fr; }
  .bonus-stats { grid-template-columns: 1fr; }
  .bonus-marks { font-size: .72rem; }
  .bonus-preview { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .bonus-preview span { width: 100%; justify-content: space-between; }
  .qgrid { grid-template-columns: 1fr; }
  #assets-table { display: block; width: 100%; min-width: 0; max-width: 100%; overflow: visible; }
  #assets-table .tbl { display: block; width: 100%; min-width: 0; max-width: 100%; border: 0; background: transparent; }
  #assets-table .tbl thead { display: none; }
  #assets-table .tbl tbody { display: grid; gap: 10px; }
  #assets-table .tbl tr {
    display: grid; gap: 10px; padding: 13px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  }
  #assets-table .tbl tr:hover td { background: transparent; }
  #assets-table .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0; border: 0; text-align: left; }
  #assets-table .tbl td:first-child { display: block; }
  #assets-table .tbl td:nth-child(2)::before { content: "Balance"; color: var(--text-3); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  #assets-table .tbl td:nth-child(3)::before { content: "Value"; color: var(--text-3); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  #assets-table .tbl td:last-child { justify-content: stretch; }
  #assets-table .tbl td:last-child .btn { width: 100%; justify-content: center; }
  .stake-flow { grid-template-columns: 1fr; }
  .asset-list { overflow: hidden; }
  .asset-row { grid-template-columns: 1fr; gap: 10px; align-items: start; }
  .asset-row .col-vol { display: block; }
  .asset-row > div:last-child .btn { width: 100%; justify-content: center; }
  .card-program { grid-template-columns: 1fr; }
  .card-stack--app .card-stack__back { transform: translate(10px, -26px) rotate(-7deg); }
  .card-stack--app:hover .card-stack__back { transform: translate(12px, -30px) rotate(-9deg); }
  .card-review__steps { grid-template-columns: 1fr; }
  .card-kyc__head { display: block; }
}

@media (max-width: 560px) {
  .main { padding: 14px 14px 72px; }
  body.app .card { padding: 18px; }
  .page__title { font-size: 1.35rem; }
  .page__sub { margin-bottom: 18px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; border-radius: 18px; }
  .tabs button { min-width: 0; padding: 10px 12px; white-space: normal; }
  .bal-hero { padding: 22px 20px; }
  .bal-hero .row .btn { flex: 1 1 120px; }
  .asset-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .net-pick button { display: grid; grid-template-columns: 1fr; gap: 4px; text-align: left; align-items: start; }
  .qr-box { display: grid; grid-template-columns: 1fr; }
  .qr-box .qr { width: min(168px, 100%); height: auto; aspect-ratio: 1; justify-self: center; }
  .addr-box { flex-direction: column; align-items: stretch; }
  .copy-btn { width: 100%; margin-left: 0; }
  .card-program { padding: 16px; }
  .card-program__copy .btn { width: 100%; }
  .card-stack--app { padding: 16px 0 10px; }
  .card-stack--app .bcard { padding: 18px; }
  .card-stack--app .bcard__brand { font-size: 1rem; }
  .card-stack--app .bcard__tier { font-size: .52rem; }
  .card-stack--app .bcard__chip { width: 42px; height: 33px; }
  .card-stack--app .bcard__num { font-size: clamp(.72rem, 3.2vw, .92rem); letter-spacing: .08em; }
  .card-stack--app .bcard__meta { gap: 10px; }
  .card-stack--app .bcard__meta small { font-size: .52rem; }
  .card-stack--app .bcard__meta b { font-size: .72rem; }
  .card-kyc__grid { grid-template-columns: 1fr; }
  .row-between { align-items: flex-start; }
  .chat { height: min(70vh, 560px); }
  .chat__form { flex-direction: column; }
  .chat__form .btn { width: 100%; }
  .msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .app-gate__mark::after, .page.active, .bal-hero .bal-amt.is-refreshing, .bal-hero .bal-amt.is-changing { animation: none; }
  .side__nav a:hover { transform: none; }
}
