/* ==========================================================================
   app.css — trader portal + admin console
   Builds on the tokens declared in site.css so the app and the public page
   read as one product. Loaded after site.css and motion.css.
   ========================================================================== */

:root {
  --app-gutter: clamp(1.1rem, 4vw, 3rem);
  --radius: 1.25rem;
  --radius-sm: 0.7rem;
}

body.app {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(92, 225, 255, 0.07), transparent),
    radial-gradient(900px 500px at -10% 105%, rgba(196, 107, 45, 0.09), transparent),
    var(--void);
}

/* ------------------------------------------------------------- Page heading */

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.page-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.chip strong {
  color: var(--text);
}

/* -------------------------------------------------------------------- Cards */

.panel {
  position: relative;
  padding: 1.4rem;
  background: rgba(12, 16, 24, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.45s var(--ease), box-shadow 0.5s var(--ease);
}

.panel:hover {
  border-color: rgba(92, 225, 255, 0.28);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-desc {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* --------------------------------------------------------------- Stat tiles */

.stat {
  padding: 1.15rem 1.25rem;
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.9), rgba(8, 11, 18, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.is-up { color: var(--up); }
.is-down { color: var(--down); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Market blocks */

.market-card {
  display: grid;
  gap: 0.75rem;
  padding: 1.3rem;
  background: rgba(12, 16, 24, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.4s var(--ease), transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.market-card:hover {
  border-color: rgba(92, 225, 255, 0.35);
  transform: translateY(-3px);
  box-shadow: 0 28px 70px -40px rgba(92, 225, 255, 0.6);
}

.market-card.accent-copper:hover {
  border-color: rgba(232, 160, 106, 0.4);
  box-shadow: 0 28px 70px -40px rgba(232, 160, 106, 0.5);
}

.market-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.market-symbol {
  margin: 0;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
}

.accent-copper .market-symbol { color: var(--copper); }

.market-name {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.market-price {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.market-change {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.pill {
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(92, 225, 255, 0.1);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.is-live {
  background: var(--cyan);
  color: #041018;
  box-shadow: 0 0 16px rgba(92, 225, 255, 0.45);
}

.pill.is-closed { background: rgba(138, 150, 168, 0.14); color: var(--muted); }
.pill.is-sim { background: rgba(232, 160, 106, 0.14); color: var(--copper); }
.pill.is-good { background: rgba(93, 255, 177, 0.14); color: var(--up); }
.pill.is-bad { background: rgba(255, 107, 122, 0.14); color: var(--down); }
.pill.is-warn { background: rgba(232, 160, 106, 0.16); color: var(--copper); }

/* ------------------------------------------------------------- Order ticket */

.ticket {
  position: sticky;
  top: 5.5rem;
}

.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.3rem;
  margin-bottom: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #080b12;
}

.side-tabs button {
  padding: 0.6rem 0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

.side-tabs button[aria-selected="true"] {
  color: #041018;
  background: var(--up);
}

.side-tabs button[data-side="sell"][aria-selected="true"] {
  background: var(--down);
  color: #1a0308;
}

.segmented {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.segmented button {
  padding: 0.32rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.segmented button[aria-selected="true"] {
  background: rgba(92, 225, 255, 0.16);
  color: var(--cyan);
}

.quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.quick-amounts button {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}

.quick-amounts button:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.ticket-summary {
  margin: 1.1rem 0;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 11, 18, 0.6);
}

.ticket-summary dl {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.ticket-summary div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.ticket-summary dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.ticket-summary dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.ticket-summary .total dt,
.ticket-summary .total dd {
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 0.92rem;
}

/* -------------------------------------------------------------------- Forms */

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #080b12;
  color: var(--text);
  font-family: var(--mono);
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(92, 225, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(92, 225, 255, 0.1);
  background: #0a0f18;
}

.field-hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.field-error {
  display: block;
  margin-top: 0.35rem;
  color: var(--down);
  font-size: 0.78rem;
}

.input-affix {
  position: relative;
}

.input-affix span {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--mono);
  pointer-events: none;
}

.input-affix input {
  padding-left: 2rem;
}

.input-affix.is-suffix input {
  padding-left: 0.9rem;
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  transform: translateY(-50%);
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}

.password-toggle:hover {
  color: var(--cyan);
  background: rgba(92, 225, 255, 0.08);
}

.password-meter {
  margin-top: 0.75rem;
}

.password-meter-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.password-meter-bars span {
  height: 0.28rem;
  border-radius: 999px;
  background: rgba(138, 150, 168, 0.22);
  transition: background 0.25s var(--ease);
}

.password-meter[data-score="1"] .password-meter-bars span:nth-child(-n+1),
.password-meter[data-score="2"] .password-meter-bars span:nth-child(-n+2) {
  background: var(--down);
}

.password-meter[data-score="3"] .password-meter-bars span:nth-child(-n+3) {
  background: var(--copper);
}

.password-meter[data-score="4"] .password-meter-bars span {
  background: var(--up);
}

.password-meter-label {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.password-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.password-checks li {
  position: relative;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.password-checks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(138, 150, 168, 0.45);
}

.password-checks li.is-met {
  color: var(--up);
}

.password-checks li.is-met::before {
  background: var(--up);
}

.phone-row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 0.9fr) minmax(0, 1.4fr);
  gap: 0.55rem;
}

.phone-row select,
.phone-row input {
  width: 100%;
  min-width: 0;
}

.wizard-panel[hidden] {
  display: none !important;
}

[data-register-wizard].is-enhanced .wizard-panel:not(.is-active) {
  display: none;
}

[data-register-wizard]:not(.is-enhanced) [data-wizard-next],
[data-register-wizard]:not(.is-enhanced) [data-wizard-back] {
  display: none;
}

.wizard-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.wizard-nav .button {
  flex: 1 1 8rem;
  justify-content: center;
}

.auth-card-wide {
  max-width: 32rem;
}

.auth-inline-link {
  display: flex;
  justify-content: flex-end;
  margin: -0.35rem 0 1rem;
}

.auth-inline-link a {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-decoration: none;
}

.auth-inline-link a:hover {
  text-decoration: underline;
}

.field.is-valid input,
.field.is-valid select {
  border-color: rgba(93, 255, 177, 0.45);
}

.button.button-full {
  width: 100%;
  justify-content: center;
}

.button-buy { background: var(--up); color: #04180e; }
.button-sell { background: var(--down); color: #1a0308; }
.button-ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}
.button-ghost:hover { border-color: var(--cyan); }

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* ------------------------------------------------------------------- Tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.data th {
  padding: 0.85rem 1rem;
  background: rgba(8, 11, 18, 0.9);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

table.data td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

table.data tbody tr {
  transition: background 0.25s var(--ease);
}

table.data tbody tr:hover {
  background: rgba(92, 225, 255, 0.04);
}

table.data .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.empty {
  padding: 2.5rem 1rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------ Alerts */

.alert {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

/* Tint carries the meaning; no edge stripe. */
.alert-success { background: rgba(93, 255, 177, 0.08); border-color: rgba(93, 255, 177, 0.22); color: #c9ffe6; }
.alert-error { background: rgba(255, 107, 122, 0.08); border-color: rgba(255, 107, 122, 0.24); color: #ffd7db; }
.alert-info { background: rgba(92, 225, 255, 0.07); border-color: rgba(92, 225, 255, 0.22); }
.alert-warning { background: rgba(232, 160, 106, 0.08); border-color: rgba(232, 160, 106, 0.24); color: #ffe4cd; }

/* ------------------------------------------------------------------- Wizard */

.wizard-steps {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.wizard-steps li {
  flex: 1;
  padding-top: 0.7rem;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}

.wizard-steps li.is-active {
  border-top-color: var(--cyan);
  color: var(--cyan);
}

.wizard-steps li.is-done {
  border-top-color: var(--up);
  color: var(--up);
}

.wallet-address {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #080b12;
}

.wallet-address code {
  flex: 1;
  overflow-wrap: anywhere;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.copy-btn {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.25s, border-color 0.25s;
}

.copy-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.copy-btn.is-copied { color: var(--up); border-color: var(--up); }

.method-list {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1.2rem;
  padding: 0;
  list-style: none;
}

.method-option {
  display: block;
  cursor: pointer;
}

.method-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-body {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease);
}

.method-option:hover .method-body { transform: translateY(-2px); }

.method-option input:checked + .method-body {
  border-color: var(--cyan);
  background: rgba(92, 225, 255, 0.07);
}

.method-option input:focus-visible + .method-body {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.method-code {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: rgba(92, 225, 255, 0.1);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.method-meta strong { display: block; font-size: 0.95rem; }
.method-meta span { color: var(--muted); font-family: var(--mono); font-size: 0.7rem; }

.countdown {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--copper);
}

/* ------------------------------------------------------------- Auth screens */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem 1.2rem;
}

.auth-card {
  width: 100%;
  max-width: 27rem;
  padding: 2rem;
  background: rgba(12, 16, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
}

.auth-card h1 {
  margin: 0 0 0.4rem;
  font-size: 2rem;
}

.auth-card .kicker { margin-bottom: 1.2rem; }

.auth-foot {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.auth-foot a { color: var(--cyan); text-decoration: none; }


/* --------------------------------------------------------------- Responsive */

@media (max-width: 1100px) {
  .grid-main,
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ticket { position: static; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-side nav { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); display: grid; }
}

@media (max-width: 760px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-main { grid-template-columns: minmax(0, 1fr); }

  .app-menu-toggle {
    display: inline-grid;
    margin-left: auto;
  }

  .app-nav {
    position: fixed;
    inset: 4.25rem 0 auto;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 1rem 1.2rem;
    background: rgba(5, 6, 10, 0.97);
    border-bottom: 1px solid var(--line);
  }

  .app-nav.is-open { display: flex; }
  .app-nav a { border-radius: var(--radius-sm); padding: 0.8rem 1rem; }
  .app-user { margin-left: 0; padding-left: 0; border-left: 0; }
  .app-user .app-user-meta { display: none; }
}

@media (max-width: 480px) {
  :root { --app-gutter: 0.85rem; }

  .app-main,
  .admin-main { padding-top: 1.25rem; }

  .page-head {
    align-items: stretch;
    margin-bottom: 1.25rem;
  }

  .page-head > *,
  .page-head .chip-row { width: 100%; }

  .panel,
  .stat,
  .market-card { padding: 1rem; }

  .panel-head {
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .wallet-address {
    align-items: stretch;
    flex-direction: column;
  }

  .wallet-address .copy-btn {
    width: 100%;
    min-height: 2.75rem;
  }

  .auth-page { padding: 1rem 0.85rem; }
  .auth-card,
  .auth-card-wide { padding: 1.25rem; }

  .wizard-steps {
    gap: 0.35rem;
  }

  .wizard-steps li {
    font-size: 0.6rem;
    letter-spacing: 0.06em;
  }

  .phone-row {
    grid-template-columns: 1fr;
  }

  .password-checks {
    grid-template-columns: 1fr;
  }

  .wizard-nav {
    flex-direction: column-reverse;
  }

  .wizard-nav .button {
    width: 100%;
    /* Stacking flips the main axis, so the desktop `flex: 1 1 8rem` stops
       being a minimum width and becomes a minimum *height* — an 8rem-tall
       Continue button. Reset it and let the button size to its own content. */
    flex: 0 0 auto;
  }
}
