:root {
  --bg: #020617;
  --surface: #07111f;
  --surface-2: #0b1424;
  --surface-3: #101b2f;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.32);
  --green: #39ff14;
  --green-2: #a3ff5c;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --red: #fb7185;
  --text: #f8fafc;
  --muted: #a7b7c8;
  --muted-2: #718096;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, #020617 0%, #07111f 52%, #020617 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.38;
  overscroll-behavior-y: contain;
}

body:has(.auth-gate) {
  overflow: hidden;
}

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

button {
  border: 0;
}

a {
  color: inherit;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(circle at 50% 8%, rgba(57, 255, 20, 0.14), transparent 34%),
    rgba(2, 6, 23, 0.96);
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100dvh - 28px);
  margin: auto 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px;
  border: 1px solid rgba(57, 255, 20, 0.26);
  border-radius: 18px;
  background: rgba(7, 17, 31, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.52), 0 0 54px rgba(57, 255, 20, 0.10);
}

.auth-card img {
  display: block;
  width: min(230px, 72%);
  height: auto;
  margin: 0 auto 10px;
}

.auth-card h2 {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
  text-align: center;
}

.auth-card p,
.auth-card small {
  display: block;
  margin: 0 0 10px;
  color: #b9cbbb;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 10px;
  padding: 4px;
  border: 1px solid rgba(57, 255, 20, 0.20);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.72);
}

.auth-switch button {
  min-height: 34px;
  margin: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.auth-switch button[aria-selected="true"] {
  color: #04110a;
  background: linear-gradient(135deg, var(--green), var(--green-2));
}

.auth-card label {
  display: grid;
  gap: 5px;
  margin: 9px 0;
  color: #d8f5dd;
  font-size: 13px;
  font-weight: 800;
}

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

.auth-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 10px;
  font-weight: 700;
  line-height: 1.35;
}

.auth-check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

.auth-card[data-mode="login"] .auth-register-field {
  display: none;
}

.auth-card input {
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(57, 255, 20, 0.22);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
}

.account-coverage {
  margin: 0 0 14px;
}

.auth-card button {
  width: 100%;
  min-height: 38px;
  margin: 10px 0 8px;
  border-radius: 8px;
  color: #04110a;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  font-weight: 900;
  cursor: pointer;
}

.auth-card .auth-exit-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.72);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.auth-card .auth-exit-button:hover,
.auth-card .auth-exit-button:focus-visible {
  color: var(--text);
  border-color: rgba(57, 255, 20, 0.44);
  background: rgba(16, 27, 47, 0.94);
}

.auth-card .auth-link-button {
  display: block;
  width: auto;
  min-height: 0;
  margin: 2px auto 8px;
  padding: 4px 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.2;
}

.auth-card .auth-link-button:hover,
.auth-card .auth-link-button:focus-visible {
  color: var(--green-2);
  background: rgba(57, 255, 20, 0.08);
}

@media (max-width: 520px) {
  .auth-gate {
    padding: 14px;
  }

  .auth-card {
    max-height: calc(100dvh - 28px);
    margin: 0;
    padding: 20px;
  }

  .auth-name-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

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

.app-shell main {
  transform: translateY(var(--pull-distance));
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.app-shell.pulling-refresh main {
  transition: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.96);
  overflow-y: auto;
}

.brand-lockup {
  display: block;
  padding: 8px;
  border: 1px solid rgba(57, 255, 20, 0.2);
  border-radius: 8px;
  background: var(--surface);
}

.brand-lockup img {
  display: block;
  width: 100%;
  border-radius: 6px;
}

.session-box,
.sidebar-status {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.session-box span,
.sidebar-status b {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-box strong {
  font-size: 15px;
}

.session-box small,
.sidebar-status span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.primary-nav a,
.bottom-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.primary-nav a {
  justify-content: flex-start;
}

.concise-nav,
.concise-bottom-nav {
  scrollbar-width: thin;
}

.concise-bottom-nav {
  scrollbar-width: none;
}

.concise-bottom-nav::-webkit-scrollbar {
  display: none;
}

.primary-nav a:hover,
.primary-nav a.active,
.bottom-nav a.active {
  color: var(--text);
  border-color: rgba(57, 255, 20, 0.34);
  background: rgba(57, 255, 20, 0.08);
}

main {
  min-width: 0;
  padding: clamp(14px, 2.4vw, 28px);
}

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

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

.realtime-summary {
  display: grid;
  justify-items: end;
  gap: 4px;
  max-width: 280px;
}

.realtime-summary small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  text-align: right;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(26px, 3.1vw, 42px);
  line-height: 1;
}

.topbar p {
  max-width: 840px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.pull-refresh-indicator {
  position: sticky;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 32;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: min(420px, 100%);
  margin: -6px auto 10px;
  padding: 7px 12px 7px 9px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(7, 17, 31, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-18px + (22px * var(--pull-progress, 0)))) scale(calc(0.96 + (0.04 * var(--pull-progress, 0))));
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease, color 140ms ease;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.32);
}

.pull-refresh-indicator::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(148, 163, 184, 0.38);
  border-top-color: var(--green);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(57, 255, 20, 0.06), 0 0 18px rgba(57, 255, 20, 0.18);
  transform: rotate(calc(180deg * var(--pull-progress, 0)));
}

.pull-refresh-indicator.visible,
.pull-refresh-indicator.refreshing {
  opacity: 1;
}

.pull-refresh-indicator.armed,
.pull-refresh-indicator.refreshing {
  border-color: rgba(57, 255, 20, 0.42);
  color: var(--green-2);
}

.pull-refresh-indicator.refreshing {
  transform: translateY(8px) scale(1);
}

.pull-refresh-indicator.refreshing::before {
  animation: refreshSpin 720ms linear infinite;
}

.app-shell.refresh-bounce main {
  animation: refreshSnap 760ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-shell.refresh-bounce-failed main {
  animation: refreshSnapFailed 520ms ease;
}

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

@keyframes refreshSnap {
  0% { transform: translateY(0); }
  24% { transform: translateY(12px); }
  54% { transform: translateY(-4px); }
  78% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

@keyframes refreshSnapFailed {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(7px); }
  62% { transform: translateY(-3px); }
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sync-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(57, 255, 20, 0.28);
  border-radius: 999px;
  color: var(--green);
  background: rgba(57, 255, 20, 0.08);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-chip.warning {
  color: #ffd68a;
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.1);
}

.sync-pill.warning,
.sync-pill.stale {
  color: #ffd68a;
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.1);
}

.sync-pill.stale {
  color: #ff9aa8;
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.1);
}

.sync-pill.neutral {
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.08);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.site-footer {
  width: min(900px, 100%);
  margin: 28px auto 0;
  padding: 14px 0 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.section-heading {
  display: grid;
  gap: 8px;
  max-width: 940px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(21px, 2.6vw, 32px);
  line-height: 1.08;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-grid,
.content-grid,
.sleeve-grid,
.recommendation-grid,
.gauge-grid {
  display: grid;
  gap: 14px;
}

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

.two-columns {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.trade-layout {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
}

.trade-history-layout {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.15fr);
}

.sage-layout {
  grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.25fr);
}

.stock-picks-layout {
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 0.58fr);
}

.content-grid,
.sleeve-grid,
.recommendation-grid,
.gauge-grid {
  margin-top: 14px;
}

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

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

.metric-card,
.panel-card,
.account-card,
.recommendation-card,
.sleeve-card,
.gauge-card,
.preview-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.84), rgba(2, 6, 23, 0.86));
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 96px;
  padding: 10px;
}

.metric-card.primary-metric {
  grid-column: span 2;
}

.metric-card span,
.card-head span,
.recommendation-card span,
.sleeve-card span,
.gauge-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card strong {
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1;
}

.metric-card p,
.account-card p,
.sleeve-card p,
.recommendation-card p,
.gauge-card p,
.preview-box p,
.stack-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

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

.card-head h2 {
  margin: 2px 0 0;
  font-size: 18px;
}

.text-button,
.danger-button,
button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.text-button {
  border: 1px solid rgba(57, 255, 20, 0.28);
  color: var(--green);
  background: rgba(57, 255, 20, 0.07);
}

.text-button.subtle {
  border-color: rgba(148, 163, 184, 0.22);
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
}

.operator-strip {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(57, 255, 20, 0.22);
  border-radius: 8px;
  background: rgba(7, 17, 31, 0.78);
}

.operator-strip[hidden] {
  display: none;
}

.operator-strip label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button.primary {
  color: #04110a;
  background: linear-gradient(135deg, var(--green), var(--green-2));
}

button.primary:disabled {
  cursor: not-allowed;
  color: rgba(248, 250, 252, 0.46);
  background: rgba(148, 163, 184, 0.10);
  box-shadow: none;
}

.danger-button {
  border: 1px solid rgba(251, 113, 133, 0.46);
  color: #ffd5dc;
  background: rgba(251, 113, 133, 0.1);
}

.danger-button.small {
  min-height: 34px;
  font-size: 12px;
}

.stack-list,
.account-grid,
.mode-list {
  display: grid;
  gap: 10px;
}

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

.account-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.stack-item,
.account-card,
.mode-row {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.compact-account-detail .card-head {
  margin-bottom: 2px;
}

.stack-item.compact-stack {
  min-height: 46px;
  padding: 6px 7px;
}

.stack-item.compact-stack .stack-item-head {
  display: grid;
  gap: 3px;
}

.stack-item.compact-stack .stack-item-head b,
.stack-item.compact-stack .stack-item-head span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-item.compact-stack .stack-item-head span {
  color: var(--text);
  font-size: 12px;
  line-height: 1.12;
}

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

.stack-item.compact-stack:hover .assistive-copy,
.stack-item.compact-stack:focus-within .assistive-copy {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  white-space: normal;
}

.compact-ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(112px, 0.72fr);
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 5px 7px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.58);
}

.compact-ledger-row span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.compact-ledger-row span:last-child {
  text-align: right;
}

.compact-ledger-row b {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-ledger-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-position-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

.account-position-strip span {
  overflow: hidden;
  min-height: 21px;
  padding: 3px 5px;
  border: 1px solid rgba(34, 211, 238, 0.13);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.24);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-position-strip b {
  color: var(--text);
  font-size: 10px;
}

.account-source-strip {
  display: grid;
  grid-template-columns: minmax(86px, 0.72fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}

.account-source-strip span {
  overflow: hidden;
  min-height: 22px;
  padding: 4px 6px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.22);
  font-size: 9.5px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-source-strip .source-chip {
  color: var(--text);
  background: rgba(148, 163, 184, 0.10);
}

.account-source-strip .positive-chip {
  color: var(--green);
  border-color: rgba(57, 255, 20, 0.22);
  background: rgba(57, 255, 20, 0.08);
}

.account-source-strip .warning-chip {
  color: #ffd68a;
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.10);
}

.account-source-strip .derived-chip,
.account-source-strip .fallback-chip {
  color: #8be9fd;
  border-color: rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.09);
}

.account-source-strip .fallback-chip {
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.08);
}

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

.freshness-chip {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.28);
}

.freshness-chip i,
.freshness-chip b,
.freshness-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.freshness-chip i {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.freshness-chip b {
  color: var(--text);
  font-size: 10px;
}

.freshness-chip small {
  color: var(--muted-2);
  font-size: 8px;
}

.freshness-live {
  border-color: rgba(57, 255, 20, 0.25);
  background: rgba(57, 255, 20, 0.07);
}

.freshness-live b {
  color: var(--green);
}

.freshness-delayed {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.09);
}

.freshness-delayed b,
.freshness-stale b {
  color: #ffd68a;
}

.freshness-stale {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.09);
}

.freshness-stale b {
  color: #ff9aa8;
}

.freshness-fallback b {
  color: var(--muted);
}

.interactive-card {
  cursor: pointer;
}

.interactive-card:hover,
.interactive-card:focus {
  border-color: rgba(57, 255, 20, 0.4);
  background: rgba(57, 255, 20, 0.08);
  outline: none;
}

.icon-text-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.icon-text-button:hover,
.icon-text-button:focus {
  border-color: rgba(57, 255, 20, 0.42);
  color: var(--green);
  outline: none;
}

.wide-card {
  grid-column: 1 / -1;
}

.compact-metrics {
  margin-bottom: 14px;
}

.stack-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.stack-item-head b,
.account-card b,
.mode-row b {
  font-size: 14px;
}

.stack-item-head span,
.account-card span,
.mode-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(112px, 0.72fr);
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 5px 7px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.58);
}

.compact-ledger-row span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.compact-ledger-row span:last-child {
  text-align: right;
}

.compact-ledger-row b {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-ledger-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-position-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

.account-position-strip span {
  overflow: hidden;
  min-height: 21px;
  padding: 3px 5px;
  border: 1px solid rgba(34, 211, 238, 0.13);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.24);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-position-strip b {
  color: var(--text);
  font-size: 10px;
}

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

.mini-metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 46px;
  padding: 6px 7px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.28);
}

.mini-metric i {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.mini-metric b {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
}

.progress-bar i {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.holdings-ledger-table {
  min-width: 1320px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.ticker-lockup,
.feature-badges {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ticker-lockup > span {
  min-width: 0;
}

.mini-logo {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid rgba(57, 255, 20, 0.28);
  border-radius: 6px;
  object-fit: cover;
  background: #000;
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.14);
}

.sage-mini-logo {
  border-color: rgba(57, 255, 20, 0.38);
}

.feature-mini-logo {
  padding: 2px;
}

.user-mini-logo {
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.10), 0 0 14px rgba(57, 255, 20, 0.08);
}

.trade-row .feature-badges,
.trade-detail-title .feature-badges,
.stack-item-head .feature-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 8px;
  vertical-align: middle;
}

.stack-item-head .feature-badges .mini-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.72);
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(57, 255, 20, 0.52);
}

.wide {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
}

.check-row label {
  display: block;
  color: #ffd68a;
  font-size: 12px;
  line-height: 1.45;
}

.preview-box {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.trade-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.62);
  text-align: left;
  cursor: pointer;
}

.trade-row.active,
.trade-row:hover {
  border-color: rgba(57, 255, 20, 0.38);
  background: rgba(57, 255, 20, 0.08);
}

.trade-row span {
  display: grid;
  gap: 4px;
}

.trade-row b {
  font-size: 13px;
}

.trade-row small,
.trade-row i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.trade-row i {
  max-width: 42%;
  text-align: right;
}

.trade-detail-panel {
  display: grid;
  gap: 12px;
}

.trade-detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.trade-detail-title h3 {
  margin: 0;
  font-size: 19px;
}

.trade-detail-title span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.detail-item,
.trade-rationale {
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.56);
}

.detail-item {
  display: grid;
  gap: 5px;
}

.detail-item span,
.trade-rationale b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-item b {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.trade-rationale p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.trade-gauge-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
}

.brand-explainer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.brand-explainer-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.48);
}

.brand-explainer-item img {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(57, 255, 20, 0.26);
  border-radius: 8px;
  object-fit: cover;
  background: #000;
}

.brand-explainer-item b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
}

.brand-explainer-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.preview-row span {
  color: var(--muted);
}

.preview-row b {
  text-align: right;
}

.intent-json {
  min-height: 320px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  color: #d7ffe1;
  background: rgba(2, 6, 23, 0.72);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.compat-ok,
.compat-warn,
.compat-error {
  border-color: rgba(148, 163, 184, 0.18);
}

.compat-ok {
  background: rgba(57, 255, 20, 0.07);
}

.compat-warn {
  background: rgba(245, 158, 11, 0.08);
}

.compat-error {
  background: rgba(251, 113, 133, 0.08);
}

.recommendation-card,
.sleeve-card,
.gauge-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.stock-pick-sleeves {
  display: grid;
  gap: 10px;
}

.stock-pick-sleeve {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.stock-pick-sleeve:hover,
.stock-pick-sleeve:focus-visible,
.stock-pick-sleeve.active {
  border-color: rgba(57, 255, 20, 0.54);
  background: rgba(57, 255, 20, 0.08);
  outline: none;
}

.stock-pick-sleeve span,
.stock-pick-sleeve small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stock-pick-sleeve b {
  font-size: 14px;
}

.stock-pick-description {
  grid-column: 1 / -1;
}

.stock-pick-description p {
  max-width: 100%;
  white-space: normal;
}

.symbol-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symbol-chip-row span {
  min-width: 46px;
  padding: 5px 8px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 6px;
  color: #dffcf6;
  background: rgba(34, 211, 238, 0.08);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.stock-pick-hedges {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.recommendation-card h3,
.sleeve-card h3,
.gauge-card h3 {
  margin: 0;
  font-size: 16px;
}

.recommendation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.sage-heading {
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: center;
}

.sage-heading img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid rgba(57, 255, 20, 0.3);
  border-radius: 8px;
  background: #000;
}

.mode-row {
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  cursor: pointer;
}

.mode-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.gauge-value {
  position: relative;
  height: 110px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(251, 113, 133, 0.32), rgba(245, 158, 11, 0.26), rgba(57, 255, 20, 0.24));
  overflow: hidden;
}

.gauge-value::after {
  content: "";
  position: absolute;
  left: var(--needle, 50%);
  bottom: 0;
  width: 3px;
  height: 82%;
  transform: translateX(-50%);
  background: var(--text);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.5);
}

.gauge-value b {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-size: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 50;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(57, 255, 20, 0.3);
  border-radius: 8px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bottom-nav {
  display: none;
}

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

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

.neutral {
  color: var(--text);
}

.needs-sync {
  color: #ffd68a;
}

.warning-text {
  color: #ffd68a;
}

.chart-grid {
  display: grid;
  gap: 12px;
}

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

.chart-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.chart-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-detail-chart-card {
  gap: 8px;
}

.account-detail-summary {
  gap: 10px;
}

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

.detail-metric {
  display: grid;
  min-width: 0;
  gap: 4px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.detail-metric.warning {
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(245, 158, 11, 0.09);
}

.detail-metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.detail-metric b {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.18;
  text-overflow: ellipsis;
}

.account-detail-chart-card .line-chart {
  min-height: 210px;
}

.time-tabs {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 2px 0 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.time-tab {
  min-width: 0;
  min-height: 30px;
  flex: 1;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.time-tab.active {
  color: var(--green);
  background: rgba(57, 255, 20, 0.10);
}

.chart-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.chart-readout {
  display: grid;
  gap: 2px;
  min-height: 44px;
}

.chart-readout b {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.chart-readout span {
  font-size: 11px;
  font-weight: 900;
}

.coverage-subhead {
  padding: 7px 2px 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stack-item.muted-stack {
  opacity: 0.72;
}

.line-chart {
  display: block;
  width: 100%;
  min-height: 170px;
  overflow: visible;
}

.robinhood-line-chart {
  touch-action: none;
  user-select: none;
}

.chart-axis {
  stroke: rgba(248, 250, 252, 0.18);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-grid-line {
  stroke: rgba(248, 250, 252, 0.09);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-sample-dot {
  fill: currentColor;
  opacity: 0.62;
}

.chart-touch-target {
  fill: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.chart-scrub-line {
  stroke: rgba(248, 250, 252, 0.46);
  stroke-width: 1.2;
  stroke-dasharray: 2 4;
  vector-effect: non-scaling-stroke;
}

.chart-scrub-dot {
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.chart-label,
.chart-tick {
  fill: rgba(248, 250, 252, 0.92);
  font-size: 11px;
  font-weight: 800;
}

.chart-tick {
  fill: rgba(226, 232, 240, 0.86);
  font-size: 10px;
}

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

  .metric-card.primary-metric {
    grid-column: span 1;
  }

  .sleeve-grid,
  .recommendation-grid,
  .gauge-grid,
  .brand-explainer,
  .detail-grid-wide,
  .two-columns,
  .trade-layout,
  .trade-history-layout,
  .sage-layout,
  .stock-picks-layout {
    grid-template-columns: 1fr;
  }

}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-lockup {
    display: none;
  }

  .primary-nav {
    display: none;
  }

  .session-box,
  .sidebar-status {
    margin-top: 0;
  }

  main {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    display: grid;
  }

  .sync-pill {
    justify-self: start;
  }

  .realtime-summary {
    justify-items: start;
  }

  .realtime-summary small {
    text-align: left;
  }

  .dashboard-grid,
  .account-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .metric-card {
    min-height: 92px;
  }

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

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

  .card-head {
    align-items: stretch;
  }

  .trade-form {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 0;
  }

  .holdings-ledger-table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    display: grid;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.13);
  }

  td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  td small {
    text-align: right;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    gap: 8px;
    min-height: calc(70px + env(safe-area-inset-bottom, 0px));
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    touch-action: pan-x;
    user-select: none;
    border-top: 1px solid var(--line);
    background: rgba(2, 6, 23, 0.96);
    backdrop-filter: blur(14px);
    box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.34);
    cursor: grab;
    mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  }

  .bottom-nav a {
    flex: 0 0 auto;
    min-width: 96px;
    min-height: 44px;
    padding: 6px 9px;
    font-size: 11px;
    white-space: nowrap;
    scroll-snap-align: center;
    -webkit-user-drag: none;
  }

  .bottom-nav.dragging {
    cursor: grabbing;
    scroll-snap-type: none;
  }
}

@media (max-width: 520px) {
  .operator-strip {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .account-grid,
  .holding-chart-grid,
  .detail-grid-wide {
    grid-template-columns: 1fr;
  }

  .account-source-strip {
    grid-template-columns: 1fr;
  }

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

  .compact-stack-list {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .card-head,
  .stack-item-head,
  .trade-detail-title,
  .preview-row {
    display: grid;
  }

  .preview-row b {
    text-align: left;
  }

  .detail-grid,
  .trade-gauge-grid {
    grid-template-columns: 1fr;
  }

  .trade-row {
    display: grid;
  }

  .trade-row i {
    max-width: none;
    text-align: left;
  }

  .sage-heading {
    grid-template-columns: 1fr;
  }
}
