:root {
  color-scheme: dark;
  --bg: #0b0f12;
  --bg-elevated: #0f151a;
  --sidebar: #0c1116;
  --panel: #111820;
  --panel-2: #151d25;
  --panel-3: #19222b;
  --surface: #0e1419;
  --line: #26323d;
  --line-soft: rgba(188, 204, 220, 0.12);
  --muted: #8f9daa;
  --muted-2: #657482;
  --text: #f3f7fb;
  --soft: #d7e1eb;
  --green: #37d08f;
  --green-2: #a7f3c5;
  --red: #f16f72;
  --yellow: #f2bd5a;
  --blue: #6fa7ff;
  --cyan: #61d6d4;
  --ink: #07110d;
  --radius: 8px;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  --focus: 0 0 0 3px rgba(55, 208, 143, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(39, 54, 65, 0.42) 0, rgba(11, 15, 18, 0) 330px),
    linear-gradient(90deg, rgba(55, 208, 143, 0.04), rgba(111, 167, 255, 0.03) 42%, rgba(242, 189, 90, 0.035)),
    var(--bg);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, black 0, transparent 780px);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  min-width: 0;
  padding: 20px;
  border-right: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    var(--sidebar);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(215, 225, 235, 0.12);
  border-radius: var(--radius);
  background: #0a0f13;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 28px rgba(0, 0, 0, 0.25);
}

.brand-mark img {
  width: 46px;
  height: 46px;
  display: block;
}

.brand-lockup h1,
.topbar h2,
.panel h3,
.insight-box h4 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-stack {
  display: grid;
  gap: 7px;
}

.nav-item,
.ghost-button,
.primary-button,
.filter-chip,
.watch-button,
.segmented button {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--soft);
  background: transparent;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.nav-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 10px;
  text-align: left;
}

.nav-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(215, 225, 235, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active {
  border-color: rgba(55, 208, 143, 0.48);
  background: linear-gradient(90deg, rgba(55, 208, 143, 0.16), rgba(55, 208, 143, 0.055));
  color: var(--text);
  text-overflow: ellipsis;
}

.nav-item.active .nav-icon {
  border-color: rgba(55, 208, 143, 0.34);
  background: rgba(55, 208, 143, 0.12);
  color: var(--green-2);
}

.nav-item:hover {
  border-color: rgba(215, 225, 235, 0.22);
  background: rgba(255, 255, 255, 0.035);
}

.builder-panel,
.status-panel {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
}

.sidebar-details {
  display: block;
}

.sidebar-details summary {
  display: none;
}

.builder-panel {
  display: grid;
  gap: 9px;
}

.profile-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid rgba(188, 204, 220, 0.13);
  border-radius: var(--radius);
  outline: none;
  background: #0b1116;
  color: var(--text);
}

input::placeholder {
  color: #566574;
}

input:focus,
select:focus {
  border-color: rgba(55, 208, 143, 0.62);
}

.builder-panel p,
.market-detail p,
.insight-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  color: var(--muted);
  font-size: 13px;
}

.status-panel div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(55, 208, 143, 0.12);
}

.status-dot.warn {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(242, 189, 90, 0.14);
}

.status-dot.off {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(241, 111, 114, 0.14);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  margin-bottom: 16px;
  padding: 4px 0 2px;
}

.topbar > *,
.panel-head > *,
.detail-top > * {
  min-width: 0;
}

.topbar h2 {
  max-width: 760px;
  overflow-wrap: anywhere;
  color: #f6f9fc;
  font-size: clamp(23px, 2.25vw, 32px);
  line-height: 1.12;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.search-wrap {
  position: relative;
  min-width: min(380px, 100%);
  width: min(380px, 100%);
}

.search-wrap span {
  position: absolute;
  left: 12px;
  top: 11px;
  color: var(--muted-2);
  font-weight: 900;
}

.search-wrap input {
  padding-left: 30px;
}

.ghost-button,
.primary-button,
.watch-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 820;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.026);
}

.feed-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(242, 189, 90, 0.36);
  border-radius: var(--radius);
  background: rgba(242, 189, 90, 0.08);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.feed-pill.live {
  border-color: rgba(55, 208, 143, 0.46);
  background: rgba(55, 208, 143, 0.1);
  color: var(--green-2);
}

.feed-pill.error {
  border-color: rgba(241, 111, 114, 0.46);
  background: rgba(241, 111, 114, 0.1);
  color: var(--red);
}

.primary-button {
  border-color: rgba(55, 208, 143, 0.74);
  background: linear-gradient(180deg, #63e9aa, var(--green));
  color: var(--ink);
}

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

.primary-button:hover,
.ghost-button:hover,
.watch-button:hover,
.filter-chip:hover,
.segmented button:hover {
  border-color: rgba(215, 225, 235, 0.32);
  transform: translateY(-1px);
}

.primary-button:hover {
  border-color: rgba(167, 243, 197, 0.9);
}

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

.metrics-strip article,
.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)), var(--panel);
  box-shadow: var(--shadow);
}

.metrics-strip article {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 104px;
  min-width: 0;
  overflow: hidden;
  padding: 15px;
}

.metrics-strip article::after {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 52px;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--yellow));
  content: "";
  opacity: 0.78;
}

.metrics-strip span,
.price-band span,
.explain-grid span,
.ticket-preview span,
.ev-result span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 860;
  text-transform: uppercase;
}

.metrics-strip strong {
  font-size: 25px;
  line-height: 1.05;
}

.metrics-strip small {
  color: var(--green-2);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(390px, 1fr) minmax(310px, 0.82fr);
  gap: 12px;
  align-items: start;
}

.left-rail,
.right-rail,
.center-stage {
  display: grid;
  gap: 12px;
  min-width: 0;
}

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

.panel[data-panel] {
  display: none;
}

.panel[data-panel].active {
  display: block;
}

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

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-head h3 {
  font-size: 20px;
}

.panel-head.compact h3 {
  font-size: 17px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(188, 204, 220, 0.12);
  border-radius: var(--radius);
  background: rgba(6, 10, 13, 0.6);
}

.segmented button {
  min-height: 31px;
  padding: 0 10px;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.segmented button.active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.segmented.wide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

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

.filter-chip {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.filter-chip.active {
  border-color: rgba(111, 167, 255, 0.5);
  background: rgba(111, 167, 255, 0.12);
  color: var(--text);
}

.market-list,
.alert-list,
.signal-list,
#watchlistItems,
.wallet-activity,
.portfolio-table,
.settings-grid,
.preferences-grid {
  display: grid;
  gap: 10px;
}

.market-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)), var(--surface);
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.market-card:hover {
  border-color: rgba(215, 225, 235, 0.22);
  transform: translateY(-1px);
}

.market-card.active {
  border-color: rgba(55, 208, 143, 0.58);
  background:
    linear-gradient(90deg, rgba(55, 208, 143, 0.12), rgba(111, 167, 255, 0.045)),
    var(--surface);
}

.market-card button {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.market-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.market-title {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--soft);
  font-size: 15px;
  font-weight: 820;
  line-height: 1.35;
}

.market-price {
  color: var(--green-2);
  font-size: 24px;
  font-weight: 920;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.market-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(188, 204, 220, 0.13);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
}

.tag.green {
  border-color: rgba(55, 208, 143, 0.38);
  color: var(--green-2);
}

.tag.yellow {
  border-color: rgba(242, 189, 90, 0.4);
  color: var(--yellow);
}

.tag.red {
  border-color: rgba(241, 111, 114, 0.4);
  color: var(--red);
}

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

.detail-top h3 {
  overflow-wrap: anywhere;
  margin-bottom: 8px;
  font-size: clamp(22px, 2.4vw, 31px);
  line-height: 1.13;
}

.watch-button.active {
  border-color: rgba(55, 208, 143, 0.48);
  background: rgba(55, 208, 143, 0.12);
  color: var(--green-2);
}

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

.price-band div,
.explain-grid div,
.ticket-preview div,
.ev-result {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: rgba(6, 10, 13, 0.34);
}

.price-band strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.price-band div:first-child strong,
.ev-result strong {
  color: var(--green-2);
}

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

.explain-grid strong,
.ticket-preview strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.insight-box {
  padding: 13px;
  border: 1px solid rgba(242, 189, 90, 0.34);
  border-radius: var(--radius);
  background: rgba(242, 189, 90, 0.08);
}

.insight-box h4 {
  margin-bottom: 8px;
  color: var(--yellow);
  font-size: 14px;
}

.book-grid {
  display: grid;
  gap: 8px;
}

.book-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.book-bar {
  position: relative;
  height: 28px;
  overflow: hidden;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: #0b1116;
}

.book-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(55, 208, 143, 0.52), rgba(55, 208, 143, 0.2));
}

.book-row.asks .book-bar span {
  right: 0;
  left: auto;
  background: linear-gradient(90deg, rgba(241, 111, 114, 0.2), rgba(241, 111, 114, 0.52));
}

.ev-panel,
.trade-ticket,
.daily-watchlist {
  display: grid;
  gap: 12px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

#probabilityLabel {
  color: var(--text);
  font-size: 24px;
  font-weight: 920;
}

.ev-result strong {
  font-size: 28px;
}

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

.ticket-preview {
  display: grid;
  gap: 8px;
}

.ticket-preview strong {
  overflow-wrap: anywhere;
}

.order-draft-list,
.open-order-list {
  display: grid;
  gap: 10px;
}

.execution-status,
.account-status {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 820;
  line-height: 1.45;
}

.execution-status {
  border: 1px solid rgba(242, 189, 90, 0.4);
  background: rgba(242, 189, 90, 0.08);
  color: var(--yellow);
}

.execution-status.ready {
  border-color: rgba(55, 208, 143, 0.46);
  background: rgba(55, 208, 143, 0.1);
  color: var(--green-2);
}

.execution-status.blocked {
  border-color: rgba(241, 111, 114, 0.46);
  background: rgba(241, 111, 114, 0.1);
  color: var(--red);
}

.account-status {
  border: 1px solid rgba(111, 167, 255, 0.38);
  background: rgba(111, 167, 255, 0.08);
  color: #a8c7ff;
}

.account-status.ready {
  border-color: rgba(55, 208, 143, 0.46);
  background: rgba(55, 208, 143, 0.1);
  color: var(--green-2);
}

.account-status.blocked {
  border-color: rgba(241, 111, 114, 0.46);
  background: rgba(241, 111, 114, 0.1);
  color: var(--red);
}

.compact-actions {
  justify-content: stretch;
}

.compact-actions button {
  flex: 1 1 130px;
}

.order-draft,
.open-order,
.alert-item,
.notification-item,
.signal-item,
.watchlist-item,
.settings-card,
.preference-card,
.portfolio-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: rgba(6, 10, 13, 0.34);
}

.order-draft pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: #080d11;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.alert-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.7fr 0.8fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.portfolio-loader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.portfolio-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.portfolio-groups article {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid rgba(188, 204, 220, 0.11);
  border-radius: var(--radius);
  background: rgba(6, 10, 13, 0.34);
}

.portfolio-groups span,
.portfolio-groups small {
  color: var(--muted);
  font-size: 12px;
}

.portfolio-groups strong {
  font-size: 20px;
}

.panel-note {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.alert-item-top,
.notification-item-top,
.signal-item-top,
.portfolio-row-top,
.watchlist-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.alert-item strong,
.notification-item strong,
.signal-item strong,
.portfolio-row strong,
.settings-card strong,
.watchlist-item strong {
  overflow-wrap: anywhere;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.35;
}

.alert-item small,
.notification-item small,
.signal-item small,
.portfolio-row small,
.settings-card small,
.watchlist-item small {
  color: var(--muted);
}

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

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

.preference-card {
  min-height: 118px;
}

.preference-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 860;
  text-transform: uppercase;
}

.preference-card strong {
  font-size: 19px;
}

.settings-card {
  min-height: 116px;
}

.settings-card code {
  overflow-wrap: anywhere;
  color: var(--soft);
  font-size: 11px;
}

.settings-card ul {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
}

.wallet-activity {
  margin-top: 12px;
}

.wallet-activity h4 {
  margin-top: 4px;
  color: var(--soft);
  font-size: 13px;
  text-transform: uppercase;
}

.compact-row {
  gap: 6px;
  padding: 10px;
}

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

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.portfolio-grid div {
  display: grid;
  gap: 4px;
}

.portfolio-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

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

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  transform: translateY(18px);
  opacity: 0;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(55, 208, 143, 0.46);
  border-radius: var(--radius);
  background: #0d1c16;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: 160ms ease;
}

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

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

  .sidebar {
    position: static;
    height: auto;
  }

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

@media (min-width: 1241px) and (max-width: 1480px) {
  .content-grid {
    grid-template-columns: minmax(330px, 0.95fr) minmax(420px, 1.05fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell,
  .sidebar,
  .workspace,
  .topbar,
  .topbar > *,
  .topbar-actions,
  .panel,
  .builder-panel,
  .status-panel {
    max-width: 100%;
    overflow-x: hidden;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  .sidebar {
    width: 100vw;
    max-width: 100vw;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .brand-lockup {
    min-height: 46px;
  }

  .brand-mark,
  .brand-mark img {
    width: 42px;
    height: 42px;
  }

  .nav-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 6px;
    overflow-x: visible;
    padding-bottom: 2px;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 5px;
    min-height: 58px;
    min-width: 0;
    padding: 7px 6px;
    text-align: center;
    font-size: 10px;
    white-space: nowrap;
  }

  .nav-icon {
    width: 29px;
    height: 29px;
  }

  .nav-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(50%, 180px);
  }

  .sidebar-details {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  }

  .sidebar-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 0 12px;
    color: var(--soft);
    cursor: pointer;
    font-size: 13px;
    font-weight: 820;
    list-style: none;
  }

  .sidebar-details summary::-webkit-details-marker {
    display: none;
  }

  .sidebar-details summary::after {
    color: var(--muted);
    content: "+";
    font-size: 18px;
    font-weight: 700;
  }

  .sidebar-details[open] summary::after {
    content: "-";
  }

  .sidebar-details .builder-panel,
  .sidebar-details .status-panel {
    border: 0;
    border-top: 1px solid var(--line-soft);
    border-radius: 0 0 var(--radius) var(--radius);
    background: transparent;
  }

  .sidebar-details:not([open]) .builder-panel,
  .sidebar-details:not([open]) .status-panel {
    display: none;
  }

  .status-panel {
    margin-top: 0;
  }

  .topbar h2 {
    max-width: 24ch;
    font-size: 22px;
    line-height: 1.16;
  }

  .builder-panel input,
  .builder-panel select {
    max-width: 100%;
    font-size: 14px;
  }

  .topbar,
  .detail-top,
  .panel-head,
  .alert-item-top,
  .signal-item-top,
  .portfolio-row-top {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .search-wrap {
    min-width: 100%;
  }

  .metrics-strip,
  .price-band,
  .explain-grid,
  .portfolio-grid,
  .portfolio-groups,
  .settings-grid,
  .preferences-grid,
  .admin-token-row,
  .profile-actions,
  .portfolio-loader,
  .alert-form {
    grid-template-columns: 1fr;
  }

  .profile-actions .ghost-button,
  .admin-token-row .ghost-button,
  .portfolio-loader .primary-button {
    width: 100%;
  }

  .market-card-top {
    align-items: start;
    flex-direction: column;
  }
}
