:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #171717;
  --bg-soft: #262626;
  --line: #333333;
  --line-strong: #525252;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --gold: #ffffff;
  --blue: #60a5fa;
  --shadow: none;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 40px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #000000;
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-button {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.session-panel {
  min-width: 200px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

.meta-chip {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.meta-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.ghost-button,
.primary-button,
.pill-button {
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.ghost-button {
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text);
  background: transparent;
  border-color: var(--line);
  font-weight: 500;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: var(--bg-soft);
}

.primary-button:hover,
.pill-button:hover,
.segmented button:hover,
.market-row:hover,
.featured-card:hover {
  opacity: 0.85;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.95fr);
  gap: 20px;
}

.primary-column,
.detail-column {
  display: grid;
  gap: 20px;
}

.hero-panel,
.section-card,
.detail-card {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  animation: rise-fade 300ms ease both;
}

.hero-panel {
  overflow: hidden;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(200px, 0.8fr);
  gap: 24px;
}

.hero-copy h2 {
  margin: 0;
  max-width: 14ch;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 700;
}

.hero-text {
  max-width: 56ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 14px 0 0;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.stat-card {
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
}

.section-card,
.detail-card {
  padding: 22px;
}

.section-heading,
.ticket-summary-row,
.portfolio-header,
.position-row,
.book-row,
.trade-row,
.market-row-head,
.market-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h3,
.detail-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.compact {
  margin-bottom: 12px;
}

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

.featured-card,
.market-row,
.position-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  padding: 16px;
  transition: border-color 120ms ease, background 120ms ease;
}

.featured-card {
  cursor: pointer;
  min-height: 160px;
}

.featured-card.active,
.market-row.active {
  border-color: var(--line-strong);
  background: #2a2a2a;
}

.featured-card h4,
.market-row h4,
.market-detail-title {
  margin: 6px 0 0;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
}

.featured-card p,
.market-row p,
.detail-subtitle {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.85rem;
}

.price-strip {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.price-pill {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  min-width: 76px;
  text-align: center;
  font-size: 0.85rem;
}

.yes-pill {
  background: var(--green-soft);
  color: var(--green);
}

.no-pill {
  background: var(--red-soft);
  color: var(--red);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-button {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  font-size: 0.85rem;
  font-weight: 500;
}

.pill-button.active {
  background: var(--bg-soft);
  border-color: var(--text);
  color: var(--text);
}

.market-list {
  display: grid;
  gap: 10px;
}

.market-row {
  cursor: pointer;
}

.market-row-head {
  align-items: flex-start;
}

.market-row-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.market-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-stat {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  font-size: 0.85rem;
}

.mini-stat span,
.detail-caption,
.muted {
  color: var(--muted);
}

.detail-stack,
.book-grid,
.recent-trades,
.positions-grid,
.portfolio-stats {
  display: grid;
  gap: 14px;
}

.detail-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.detail-pill {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.8rem;
}

.sparkline {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 12px;
}

.sparkline svg {
  width: 100%;
  height: 100%;
}

.book-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.book-card,
.trades-card,
.portfolio-box {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 14px;
}

.book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.book-row,
.trade-row,
.position-row {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.book-row:first-of-type,
.trade-row:first-of-type,
.position-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.depth-bar {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  height: 6px;
  background: var(--bg-elevated);
  margin-top: 6px;
}

.depth-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.depth-bar.yes span {
  background: var(--green);
  opacity: 0.5;
}

.depth-bar.no span {
  background: var(--red);
  opacity: 0.5;
}

.ticket-card {
  position: sticky;
  top: 24px;
}

.ticket-form {
  display: grid;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.segmented button {
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}

.segmented button.active {
  background: var(--bg-elevated);
  color: var(--text);
}

.segmented.dual button:first-child.active {
  background: var(--green-soft);
  color: var(--green);
}

.segmented.dual button:last-child.active {
  background: var(--red-soft);
  color: var(--red);
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

.field input,
.field textarea,
.field select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--line-strong);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.inline-form-row,
.support-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form-row .field {
  flex: 1 1 160px;
}

.ticket-summary {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.85rem;
}

.ticket-summary strong,
.portfolio-key-metric {
  font-size: 1.15rem;
}

.ticket-form .button-row {
  justify-content: stretch;
  flex-wrap: wrap;
}

.ticket-form .button-row > * {
  flex: 1 1 140px;
}

.primary-button {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: #ffffff;
  color: #000000;
  font-weight: 600;
}

.form-message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-pill.clear {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.25);
}

.status-pill.watch {
  background: rgba(250, 204, 21, 0.1);
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.2);
}

.status-pill.blocked {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.25);
}

.secondary-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.case-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.case-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.case-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.case-row p {
  margin: 4px 0 0;
}

.hidden {
  display: none;
}

.portfolio-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.portfolio-box {
  min-height: 80px;
}

#onboardingPanel .portfolio-box {
  display: grid;
  gap: 12px;
  min-height: auto;
}

#onboardingPanel p {
  margin: 0;
}

.positions-grid {
  margin-top: 14px;
}

.position-card {
  padding: 14px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

@keyframes rise-fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .ticket-card {
    position: static;
  }
}

@media (max-width: 920px) {
  .featured-grid,
  .book-grid,
  .market-stats,
  .portfolio-stats,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-meta,
  .topbar-actions,
  .button-row {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
}

/* -- 6529 profile identity -- */

.session-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-pfp {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

/* -- Wallet picker modal -- */

.wallet-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
}

.wallet-modal-overlay.hidden {
  display: none;
}

.wallet-modal {
  width: min(380px, calc(100vw - 32px));
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 22px;
  animation: rise-fade 200ms ease both;
}

.wallet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.wallet-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.wallet-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.wallet-modal-close:hover {
  color: var(--text);
}

.wallet-modal-options {
  display: grid;
  gap: 10px;
}

.wallet-modal-option {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease;
}

.wallet-modal-option:hover {
  border-color: var(--line-strong);
}

.wallet-modal-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.wallet-modal-hint {
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 16px, 100%);
  }

  .section-card,
  .detail-card,
  .hero-panel {
    padding: 16px;
  }

  .price-strip {
    flex-wrap: wrap;
  }
}
