/* LOT Protocol UI — Binance-style gold / dark theme (from aptos_finance_ui) */

:root {
  --gold: #e0a82e;
  --gold-bright: #fcd535;
  --gold-deep: #f0b90b;
  --ink: #eaecef;
  --muted: #848e9c;
  --bg: #0b0e11;
  --surface: #1e2329;
  --surface-2: #2b3139;
  --line: #2b3139;
  --ok: #0ecb81;
  --warn: #e0a82e;
  --err: #f6465d;
  --on-gold: #181a20;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --glow: 0 0 24px rgba(252, 213, 53, 0.12);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --chrome: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mx: 50%;
  --my: 40%;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  overflow-x: clip;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.is-tapped {
  animation: tapPulse 0.28s ease;
}

a {
  color: var(--gold-bright);
}

/* ---- App shell / sidebar / top (aptos chrome) ---- */
.shell,
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.shell[hidden],
.app[hidden] {
  display: none !important;
}

.sidebar {
  background: #0b0e11;
  color: #fff;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  margin: 4px 8px 8px;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
}

.brand img,
.brand .mark {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(252, 213, 53, 0.4));
  transition: transform 0.35s var(--ease);
}

.brand:hover img {
  transform: rotate(-8deg) scale(1.06);
}

.subbrand {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 8px 22px 58px;
  text-transform: uppercase;
}

.sidebar-head {
  margin-bottom: 4px;
}

.nav-wrap,
nav.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-wrap .nav,
nav.nav > button,
button.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #b8ae95;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition:
    background 0.2s var(--ease),
    color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.15s var(--ease);
}

.nav-ico,
.nav .glyph {
  width: 1.15em;
  text-align: center;
  font-size: 0.95em;
  color: var(--gold);
  opacity: 0.85;
}

.nav-wrap .nav:hover,
nav.nav > button:hover,
button.nav:hover {
  background: rgba(252, 213, 53, 0.08);
  color: var(--gold-bright);
  border-color: rgba(252, 213, 53, 0.22);
  transform: translateX(2px);
}

.nav-wrap .nav.active,
nav.nav > button.active,
button.nav.active {
  background: var(--surface-2);
  color: var(--gold-bright);
  border-color: transparent;
  box-shadow: inset 3px 0 0 var(--gold-bright);
}

.nav-wrap .nav:hover .nav-ico,
.nav-wrap .nav.active .nav-ico,
nav.nav > button:hover .nav-ico,
nav.nav > button.active .nav-ico {
  color: var(--gold-bright);
  opacity: 1;
}

.nav[hidden],
button.nav[hidden],
nav.nav > button[hidden] {
  display: none !important;
}

.support,
.sidebar-bottom {
  margin-top: auto;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.support .dot,
.sidebar-bottom .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
  box-shadow: 0 0 8px rgba(14, 203, 129, 0.6);
}

main,
.main {
  padding: 22px;
  min-width: 0;
}

.top,
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.top-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.top h1,
.topbar h1 {
  margin: 0 0 5px;
  font-size: 25px;
  color: #eaecef;
}

.page-subtitle {
  margin: 6px 0 0;
  max-width: 520px;
}

.right-actions,
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(30, 35, 41, 0.95);
  color: var(--gold-bright);
  cursor: pointer;
  font-size: 18px;
}

.menu-toggle:hover {
  background: rgba(252, 213, 53, 0.1);
  border-color: rgba(252, 213, 53, 0.35);
}

.nav-backdrop {
  display: none;
}

.eyebrow,
.crumb {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.caption {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  border: 1px solid var(--line);
  background: rgba(30, 35, 41, 0.95);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--ink);
}

.pill.warning {
  border-color: rgba(252, 213, 53, 0.4);
  color: var(--gold-bright);
  background: rgba(252, 213, 53, 0.08);
}

/* ---- Buttons ---- */
.primary,
button.primary {
  background: var(--gold-bright);
  color: var(--on-gold);
  border: 0;
  border-radius: 6px;
  padding: 12px 17px;
  font-weight: 700;
  transition:
    background 0.2s var(--ease),
    transform 0.15s var(--ease);
  box-shadow: none;
}

.primary:hover:not(:disabled),
button.primary:hover:not(:disabled) {
  background: var(--gold-deep);
  transform: translateY(-1px);
}

.secondary,
button.secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 600;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.15s var(--ease);
}

.secondary:hover:not(:disabled),
button.secondary:hover:not(:disabled) {
  border-color: rgba(252, 213, 53, 0.35);
  color: var(--gold-bright);
  transform: translateY(-1px);
}

.danger,
button.danger {
  background: rgba(246, 70, 93, 0.15);
  color: #ff8a9a;
  border: 1px solid rgba(246, 70, 93, 0.35);
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
}

.danger:hover:not(:disabled) {
  background: rgba(246, 70, 93, 0.25);
}

.small,
button.small,
.sm {
  padding: 6px 10px;
  font-size: 12px;
}

.full {
  width: 100%;
}

.primary i,
.secondary i,
.danger i {
  margin-right: 6px;
}

/* ---- Cards / panels / views ---- */
.view[hidden] {
  display: none !important;
}

.view:not([hidden]) {
  animation: page-in 0.3s var(--ease);
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 19px;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    transform 0.28s var(--ease);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    420px 180px at var(--mx) var(--my),
    rgba(252, 213, 53, 0.1),
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

.card.is-lit::before,
.card:hover::before {
  opacity: 1;
}

.card:hover,
.panel:hover {
  border-color: #474d57;
}

.card h2,
.panel h2 {
  margin: 0;
  font-size: 17px;
  color: #eaecef;
}

.card.empty,
.empty {
  color: var(--muted);
  text-align: center;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.balance-card {
  position: relative;
  background:
    linear-gradient(145deg, rgba(252, 213, 53, 0.14), transparent 55%),
    var(--surface);
  border: 1px solid rgba(252, 213, 53, 0.28);
  border-radius: 14px;
  padding: 22px;
  overflow: hidden;
  min-height: 180px;
}

.balance-card .shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(252, 213, 53, 0.08) 48%,
    transparent 62%
  );
  background-size: 220% 100%;
  animation: login-card-shine 7s ease-in-out infinite;
  pointer-events: none;
}

.balance-card .label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}

.balance-card .amount {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 16px;
  font-size: 15px;
  color: var(--muted);
}

.balance-card .amount b {
  font-size: 36px;
  letter-spacing: -1px;
  color: var(--gold-bright);
  font-weight: 800;
}

.wallet-balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.wallet-balances strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.balance-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.income-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 180px;
}

.income-card .amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--gold-bright);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
  width: 100%;
}

/* Overview: full desktop row of 6 cards */
#view-portfolio > .stat-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat {
  min-width: 0;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.stat .caption {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.stat strong {
  font-size: clamp(16px, 2.4vw, 22px);
  font-weight: 800;
  color: var(--gold-bright);
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: transform 0.2s var(--ease);
}

.grid-two {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.explorer-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  width: 100%;
}

.lot-card {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 250px;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
  background: linear-gradient(155deg, var(--surface) 30%, #181c22 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition:
    transform 0.28s var(--ease),
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.lot-card:hover {
  transform: translateY(-4px);
  border-color: rgba(252, 213, 53, 0.35);
  box-shadow: var(--glow);
}

.lot-card .between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.lot-card .pill {
  max-width: 62%;
  white-space: normal;
  text-align: right;
  line-height: 1.25;
}

.lot-card .lot-price,
.lot-price {
  font-size: 21px;
  margin: 7px 0;
  font-weight: 800;
  color: var(--gold-bright);
  letter-spacing: -0.5px;
}

.lot-card p.caption {
  margin: 5px 0;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.lot-card button {
  min-height: 38px;
  margin-top: auto;
}

.lot-art {
  height: 82px;
  border-radius: 12px;
  background:
    radial-gradient(80px 60px at 70% 30%, rgba(252, 213, 53, 0.35), transparent 70%),
    var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
}

.lot-art span {
  display: block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--gold);
  transform: rotate(30deg);
  box-shadow:
    10px -6px 0 -1px var(--surface-2),
    10px -6px 0 0 rgba(252, 213, 53, 0.45);
  position: relative;
  animation: gem 6s ease-in-out infinite;
}

.lot-art span:after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(252, 213, 53, 0.35);
}

/* ---- Forms / fields / tables ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.field label,
label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  background: #0b0e11;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    background 0.2s var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: #5e6673;
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #3d4550;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.14);
  background: #12161c;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #14181e;
}

input[type="number"],
input[type="search"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

input[type="file"] {
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 7px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    background 0.2s var(--ease);
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(240, 185, 11, 0.08);
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 3px),
    calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

select option {
  background: #1e2329;
  color: var(--ink);
}

input.mono,
.mono {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #0b0e11 inset;
  box-shadow: 0 0 0 1000px #0b0e11 inset;
  caret-color: var(--ink);
  border: 1px solid var(--gold);
  transition: background-color 99999s ease-out;
}

.amount-input-note,
.inline-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(11, 14, 17, 0.55);
}

td {
  color: #e8e0cc;
}

td.mono,
.address {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 10px;
  margin: 0 -10px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.2s ease;
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row:hover {
  background: rgba(252, 213, 53, 0.05);
}

.metric-row strong {
  font-weight: 700;
  text-align: right;
  color: var(--gold-bright);
}

.between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.progress {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--line);
}

#progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
  border-radius: inherit;
  transition: width 0.4s var(--ease);
}

.row-buttons,
.row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.notice {
  padding: 12px;
  background: rgba(14, 203, 129, 0.1);
  color: var(--ok);
  border: 1px solid rgba(14, 203, 129, 0.25);
  border-radius: 9px;
  margin-bottom: 14px;
  font-size: 13px;
}

.notice.err,
.notice.error {
  background: rgba(246, 70, 93, 0.12);
  color: var(--err);
  border-color: rgba(246, 70, 93, 0.25);
}

.notice.warn,
.notice.warning {
  background: rgba(252, 213, 53, 0.1);
  color: var(--warn);
  border-color: rgba(252, 213, 53, 0.28);
}

.connection-prompt {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  background: rgba(30, 35, 41, 0.9);
  border: 1px dashed rgba(252, 213, 53, 0.35);
  padding: 18px 23px;
  border-radius: 14px;
  margin: 0 0 16px;
}

.connection-prompt p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.connection-prompt[hidden],
.notice[hidden],
.shell[hidden],
.auth-screen[hidden],
.nav[hidden],
button.nav[hidden],
#roleBadge[hidden],
#connectionSettings[hidden],
[hidden] {
  display: none !important;
}

body:not([data-role="admin"]) [data-admin-only] {
  display: none !important;
}

.lot-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 14px 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.lot-filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  flex: 1;
  color: var(--muted);
}

.lot-filter-bar input,
.lot-filter-bar select {
  min-height: 42px;
  padding: 10px 12px;
  background: #0b0e11;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lot-filter-bar input:focus,
.lot-filter-bar select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.14);
}

.code-result {
  white-space: pre-wrap;
  word-break: break-all;
  font: 12px/1.6 var(--mono);
  background: #0b0e11;
  border: 1px solid var(--line);
  color: #e8e0cc;
  padding: 18px;
  border-radius: 12px;
  max-height: 480px;
  overflow: auto;
  min-height: 130px;
  margin: 12px 0 0;
}

.contract-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.contract-link {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.settings {
  margin-top: 18px;
  text-align: left;
}

.settings summary {
  cursor: pointer;
  color: var(--gold-bright);
  font-weight: 700;
}

.settings-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 36px;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mobile bottom tab bar — hidden on desktop */
.mobile-footer-nav {
  display: none;
}

.history-progress {
  margin: 8px 0 12px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 8px 14px;
  font-size: 13px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  word-break: break-all;
  color: #efe7d2;
}

/* ---- Auth / gate screens ---- */
.auth-screen,
.gate-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(252, 213, 53, 0.12), transparent 55%),
    var(--bg);
}

.auth-screen[hidden] {
  display: none !important;
}

.auth-card,
.gate-screen {
  max-width: 480px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45), var(--glow);
  animation: gate-in 0.45s var(--ease);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.login-gate {
  border: 1px solid rgba(252, 213, 53, 0.22);
  background: linear-gradient(165deg, rgba(30, 35, 41, 0.98) 0%, rgba(11, 14, 17, 0.99) 100%);
}

.login-gate-glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 55%;
  background: radial-gradient(ellipse at 50% 0%, rgba(252, 213, 53, 0.18), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.login-gate-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(252, 213, 53, 0.07) 48%,
    transparent 62%
  );
  background-size: 220% 100%;
  animation: login-card-shine 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.login-gate > *:not(.login-gate-glow):not(.login-gate-shine) {
  position: relative;
  z-index: 1;
}

.gate-brand,
.auth-card .brand {
  justify-content: center;
  margin: 0 0 18px;
}

.auth-card h1,
.gate-screen h1,
.gate-screen h2 {
  margin: 0 0 10px;
  font-size: 26px;
  color: #eaecef;
}

.auth-steps {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 11px;
  color: var(--muted);
}

.auth-steps .now {
  color: var(--gold-bright);
  font-weight: 700;
}

.auth-card .primary,
.auth-card .secondary,
.gate-screen .primary,
.gate-screen .secondary {
  width: 100%;
  margin-top: 10px;
}

.gate-form {
  text-align: left;
  margin-top: 8px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  right: 28px;
  bottom: 25px;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 15px 20px;
  z-index: 50;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  word-break: break-word;
}

.toast:not([hidden]) {
  animation: toast-in 0.35s var(--ease);
}

.toast.error {
  border-left-color: var(--err);
  background: #2a1518;
}

.toast[hidden] {
  display: none !important;
}

/* ---- Dialog ---- */
dialog#lotHistoryDialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  max-width: min(920px, calc(100vw - 48px));
  width: min(920px, calc(100vw - 48px));
}

dialog::backdrop {
  background: rgba(11, 14, 17, 0.72);
}

@media (min-width: 861px) {
  #lotHistoryDialog {
    left: 240px;
    width: min(920px, calc(100vw - 240px - 48px));
  }
}

#lotHistoryDialog .table-wrap {
  max-height: min(60vh, 520px);
  overflow: auto;
}

/* ---- Mobile wallet menu ---- */
.mobile-wallet-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  z-index: 40;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  flex-direction: column;
  gap: 6px;
}

.mobile-wallet-menu.open {
  display: flex;
}

.mobile-wallet-wrap {
  position: relative;
}

#refresh.is-spinning .refresh-ico,
#refresh.is-spinning i {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ---- Animations ---- */
@keyframes gate-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes login-card-shine {
  0%,
  100% {
    background-position: 120% 0;
  }
  50% {
    background-position: -20% 0;
  }
}

@keyframes gem {
  0%,
  100% {
    transform: rotate(30deg) translateY(0);
  }
  50% {
    transform: rotate(34deg) translateY(-3px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tapPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

/* ---- Responsive ---- */
/* Marketplace lot cards: 4 → 3 → 2 → 1 by screen width */
@media (max-width: 1440px) {
  #view-portfolio > .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .market-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1050px) {
  .shell,
  .app {
    grid-template-columns: 200px 1fr;
  }

  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .stat strong {
    font-size: clamp(15px, 2.8vw, 20px);
  }

  .grid-two,
  .admin-grid,
  .explorer-grid,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .shell,
  .app {
    display: block;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(11, 14, 17, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease);
  }

  .shell.menu-open .nav-backdrop,
  .app.menu-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .shell.menu-open .nav-backdrop[hidden],
  .app.menu-open .nav-backdrop[hidden] {
    display: block !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: min(288px, 86vw);
    height: 100vh;
    height: 100dvh;
    padding: 18px 14px 90px;
    overflow: auto;
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  .shell.menu-open .sidebar,
  .app.menu-open .sidebar {
    transform: translateX(0);
  }

  main,
  .main {
    padding: 16px 14px calc(88px + var(--safe-b));
  }

  .mobile-footer-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 4px calc(6px + var(--safe-b));
    background: rgba(11, 14, 17, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }

  .mobile-footer-nav .nav {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 8px 2px 6px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.15;
    box-shadow: none;
    transform: none;
  }

  .mobile-footer-nav .nav .nav-ico {
    width: auto;
    font-size: 1.15rem;
    opacity: 0.9;
  }

  .mobile-footer-nav .nav .nav-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-footer-nav .nav:hover {
    background: rgba(252, 213, 53, 0.08);
    color: var(--gold-bright);
    border-color: transparent;
    transform: none;
  }

  .mobile-footer-nav .nav.active {
    background: rgba(252, 213, 53, 0.12);
    color: var(--gold-bright);
    border-color: transparent;
    box-shadow: none;
  }

  .mobile-footer-nav .nav.active .nav-ico,
  .mobile-footer-nav .nav:hover .nav-ico {
    color: var(--gold-bright);
    opacity: 1;
  }

  .top h1,
  .topbar h1 {
    font-size: 20px;
  }

  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .lot-card {
    min-height: 220px;
    padding: 14px;
  }

  .lot-art {
    height: 72px;
  }

  .lot-card .lot-price,
  .lot-price {
    font-size: 18px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .balance-card .amount b {
    font-size: 28px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-height: 96px;
    padding: 14px;
  }

  .stat strong {
    font-size: clamp(15px, 4.2vw, 18px);
  }

  #lotHistoryDialog {
    left: 16px;
    width: calc(100vw - 32px);
    max-width: none;
  }
}

@media (max-width: 520px) {
  .market-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .lot-card {
    min-height: 0;
    padding: 14px;
  }

  .lot-art {
    height: 88px;
  }

  .lot-card .lot-price,
  .lot-price {
    font-size: 20px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat {
    min-height: 0;
  }

  .stat strong {
    font-size: 20px;
  }

  .wallet-balances {
    grid-template-columns: 1fr;
  }

  .auth-card,
  .gate-screen {
    padding: 28px 20px;
  }

  .mobile-footer-nav {
    padding: 4px 2px calc(4px + var(--safe-b));
  }

  .mobile-footer-nav .nav {
    padding: 6px 1px 4px;
    font-size: 9px;
    gap: 3px;
  }

  .mobile-footer-nav .nav .nav-ico {
    font-size: 1.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
