:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #15201d;
  --muted: #65726e;
  --line: #dce3de;
  --green: #157a5a;
  --green-2: #dff3ea;
  --blue: #295d8f;
  --blue-2: #e1ecf7;
  --red: #b84a4a;
  --amber: #a46b16;
  --shadow: 0 16px 40px rgba(25, 39, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(246, 247, 243, 0.94), rgba(246, 247, 243, 1)),
    repeating-linear-gradient(90deg, rgba(21, 122, 90, 0.04) 0 1px, transparent 1px 80px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand-name {
  font-weight: 800;
}

.brand-subtitle,
.wallet-label,
.wallet-grid span,
.panel p,
.metric span,
.metric small,
.detail-stats span,
.muted {
  color: var(--muted);
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.nav-icon {
  width: 22px;
  color: var(--green);
  text-align: center;
}

.wallet {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.wallet-address {
  margin: 6px 0 12px;
  font-weight: 750;
}

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

.wallet-grid div {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.wallet-grid span,
.wallet-grid strong {
  display: block;
}

.wallet-grid span {
  margin-bottom: 4px;
  font-size: 12px;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button,
.segment {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: white;
  font-weight: 750;
}

.primary-button.full {
  width: 100%;
}

.ghost-button,
.icon-button,
.segment {
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 18px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.metric strong {
  font-size: 24px;
}

.metric small {
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.market-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.2fr) minmax(360px, 0.8fr);
  gap: 16px;
}

.lower-grid,
.portfolio-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header.compact {
  align-items: center;
}

.panel p {
  margin-top: 4px;
  font-size: 13px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented.wide {
  width: 100%;
  grid-template-columns: 1fr 1fr;
}

.segment {
  min-height: 30px;
  border-color: transparent;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(21, 32, 29, 0.08);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
  margin-bottom: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search input,
.toolbar select,
.trade-ticket input,
.trade-ticket select,
.listing-form input,
.listing-form select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.search input {
  border: 0;
  outline: 0;
}

.toolbar select {
  height: 40px;
  padding: 0 10px;
}

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

.tranche-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tranche-card.active {
  border-color: rgba(21, 122, 90, 0.55);
  background: linear-gradient(90deg, rgba(223, 243, 234, 0.8), #ffffff 42%);
}

.tranche-main {
  min-width: 0;
}

.tranche-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.tranche-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.tranche-quote {
  display: grid;
  min-width: 108px;
  text-align: right;
}

.tranche-quote strong {
  font-size: 18px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 750;
}

.status-pill {
  background: var(--green-2);
  color: var(--green);
}

.tag.pending {
  background: #fff3d8;
  color: var(--amber);
}

.tag.redeemable {
  background: var(--blue-2);
  color: var(--blue);
}

.tag.tradable {
  background: var(--green-2);
  color: var(--green);
}

.bond-visual {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(21, 122, 90, 0.12), transparent 52%),
    linear-gradient(180deg, #ffffff, #eef4f1);
}

#bondCanvas {
  display: block;
  width: 100%;
  height: 220px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.detail-stats div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-stats span,
.detail-stats strong {
  display: block;
}

.detail-stats span {
  margin-bottom: 5px;
  font-size: 12px;
}

.trade-ticket {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.ticket-row,
.listing-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select {
  height: 40px;
  padding: 0 10px;
  color: var(--ink);
}

.orderbook,
.trade-feed,
.holdings,
.settlement-table {
  display: grid;
  gap: 8px;
}

.book-row,
.feed-row,
.holding-row,
.settlement-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}

.book-row.ask {
  background: linear-gradient(90deg, rgba(184, 74, 74, 0.1), white 52%);
}

.book-row.bid {
  background: linear-gradient(90deg, rgba(21, 122, 90, 0.1), white 52%);
}

.feed-row,
.holding-row,
.settlement-row {
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
}

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

.nft-card {
  min-height: 190px;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.nft-art {
  position: relative;
  min-height: 132px;
  background:
    radial-gradient(circle at 26% 32%, rgba(21, 122, 90, 0.26), transparent 28%),
    radial-gradient(circle at 72% 72%, rgba(41, 93, 143, 0.28), transparent 30%),
    linear-gradient(135deg, #f7fbf9, #dceae2);
}

.nft-art::before,
.nft-art::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(21, 32, 29, 0.18);
  border-radius: 999px;
}

.nft-art::before {
  inset: 25px 52px;
}

.nft-art::after {
  inset: 48px 28px 18px 96px;
}

.nft-body {
  padding: 12px;
}

.nft-body strong,
.nft-body span {
  display: block;
}

.nft-body span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.form-panel {
  max-width: 760px;
}

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

.listing-form .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .wallet {
    display: none;
  }

  .market-grid,
  .lower-grid,
  .portfolio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .metrics-row,
  .detail-stats,
  .ticket-row,
  .listing-form,
  .toolbar,
  .nft-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .book-row,
  .feed-row,
  .holding-row,
  .settlement-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Live-data states (real marketplace) */
.empty-state {
  padding: 18px;
  border: 1px dashed #c9d3cd;
  border-radius: 12px;
  color: #65726e;
  font-size: 14px;
  line-height: 1.5;
  background: #f7faf8;
}
.empty-state code {
  background: #e8efea;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.tag.open,
.tag.unopened,
.status-pill.open,
.status-pill.unopened {
  background: #eef2f0;
  color: #65726e;
}
