:root {
  color-scheme: dark;
  --bg: #090a0c;
  --surface: #111318;
  --surface-raised: #15181e;
  --surface-soft: #1a1d24;
  --text: #f2f3f5;
  --muted: #9299a5;
  --border: #252a33;
  --border-strong: #383f4b;
  --brand: #f04f55;
  --brand-strong: #ff7176;
  --positive: #ff7479;
  --positive-soft: #2a171a;
  --negative: #43d5a2;
  --negative-soft: #10251f;
  --warning: #f1bd63;
  --warning-soft: #2a2113;
  --info: #6aa8ff;
  --danger-border: #71353a;
  --danger-text: #ff9ca0;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

::selection {
  background: var(--brand);
  color: #ffffff;
}

* {
  scrollbar-color: var(--border-strong) var(--surface);
  scrollbar-width: thin;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

a {
  color: var(--brand-strong);
  text-underline-offset: 3px;
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  background: rgba(9, 10, 12, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.app-header::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--brand) 45%, var(--info) 55%, transparent 100%);
  background-size: 220% 100%;
  content: "";
  opacity: 0.55;
  animation: header-flow 7s linear infinite;
}

.header-inner,
.page-shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-lockup,
.header-actions,
.history-heading,
.table-footer {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(240, 79, 85, 0.28));
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 650;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

.header-actions {
  gap: 16px;
  margin-left: auto;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.live-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--negative);
  box-shadow: 0 0 0 3px var(--negative-soft);
  animation: live-pulse 2.4s ease-in-out infinite;
}

.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 113, 118, 0.14), 0 8px 22px rgba(240, 79, 85, 0.18);
}

.button-primary:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

.button-subtle {
  min-height: 30px;
  padding: 0 10px;
  background: transparent;
  font-size: 12px;
}

.button:disabled {
  cursor: default;
  opacity: 0.65;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 24px 0 40px;
}

.page-shell > section {
  min-width: 0;
}

.market-overview {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(360px, 1fr);
  align-items: stretch;
  gap: 18px;
}

.market-overview > section {
  min-width: 0;
  min-height: 380px;
}

.market-overview .workspace,
.market-overview .history-section {
  height: 100%;
}

.market-overview .workspace {
  display: flex;
  flex-direction: column;
}

.workspace,
.account-risk-section,
.income-section,
.calculator-section,
.history-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: ui-enter 520ms 180ms both;
}

.calculator-section {
  animation-delay: 260ms;
}

.account-risk-section {
  animation-delay: 220ms;
}

.income-section {
  animation-delay: 240ms;
}

.history-section {
  animation-delay: 340ms;
}

.load-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.query-panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.query-command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.query-command-actions,
.query-selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.query-command-actions {
  justify-content: flex-end;
}

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

.search-composer {
  position: relative;
  width: 100%;
}

.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.market-overview .search-field input[type="search"] {
  height: 36px;
}

input[type="search"],
.form-field input:not([type="radio"]):not([type="range"]),
select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

input[type="search"]:hover,
.form-field input:not([type="radio"]):not([type="range"]):hover,
select:hover {
  border-color: var(--border-strong);
}

input[type="search"]:focus,
.form-field input:not([type="radio"]):not([type="range"]):focus,
.form-field input[type="range"]:focus-visible,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(240, 79, 85, 0.28);
  outline-offset: 1px;
  border-color: var(--brand);
  background: var(--surface-raised);
}

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.48);
}

.token-option {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 0;
  border-bottom: 1px solid var(--border);
}

.token-option:last-of-type {
  border-bottom: 0;
}

.token-option:hover,
.token-option[aria-selected="true"] {
  background: var(--surface-soft);
}

.token-option-select {
  min-width: 0;
  min-height: 53px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 8px 12px;
  cursor: pointer;
}

.token-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  accent-color: var(--brand);
}

.token-option-copy {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.token-option-copy strong {
  font-size: 13px;
}

.token-option-copy small,
.option-status,
.search-empty,
.search-overflow,
.selection-empty {
  color: var(--muted);
  font-size: 11px;
}

.option-status {
  flex: 0 0 auto;
  color: var(--negative);
}

.option-status.is-closed {
  color: var(--muted);
}

.favorite-market {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.favorite-market:hover,
.favorite-market[aria-pressed="true"] {
  color: #f0b429;
}

.search-empty,
.search-overflow {
  padding: 13px 14px;
}

.search-overflow {
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.query-selection-row {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.selection-count-label {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.selection-count-label strong {
  color: var(--text);
}

.clear-selection {
  width: 30px;
  min-width: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.selected-token-list {
  min-width: 0;
  min-height: 30px;
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.selected-token {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.selected-token:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--positive-soft);
}

.error-banner {
  margin: 14px 20px 0;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  background: var(--positive-soft);
  color: var(--danger-text);
  font-size: 13px;
}

.table-shell {
  width: 100%;
  overflow-x: auto;
}

.market-overview .workspace .table-shell {
  flex: 1;
}

.market-overview .workspace table {
  min-width: 580px;
  table-layout: fixed;
}

.market-overview .workspace th,
.market-overview .workspace td {
  padding-right: 12px;
  padding-left: 12px;
}

.market-overview .workspace th:first-child {
  width: 40%;
}

.market-overview .workspace th:not(:first-child) {
  width: 20%;
}

.market-overview .workspace th {
  height: 36px;
}

.market-overview .workspace tbody td {
  height: 68px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  height: 42px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

th.numeric,
td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:hover:not(.empty-row) {
  background: var(--surface-raised);
}

tbody tr {
  transition: background-color 140ms ease;
}

tbody tr.is-chart-selected {
  background: var(--surface-raised);
}

.market-overview .workspace tbody tr.is-chart-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--brand);
}

.token-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.token-button {
  display: grid;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.token-button strong {
  font-size: 13px;
}

.token-button span,
.coverage,
.status-note {
  color: var(--muted);
  font-size: 11px;
}

.market-row-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.market-row-detail b {
  font-weight: 650;
}

.market-state {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--negative);
  vertical-align: 1px;
}

.market-state.closed {
  background: var(--border-strong);
}

.rate-value {
  font-weight: 650;
}

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

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

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

.pnl-positive {
  color: var(--negative);
}

.pnl-negative {
  color: var(--positive);
}

.loading-cell {
  color: var(--muted);
}

.loading-line {
  width: 76px;
  height: 9px;
  margin-left: auto;
  border-radius: 3px;
  background: var(--surface-soft);
  animation: pulse 1.4s ease-in-out infinite;
}

.retry-button {
  margin-left: 8px;
  padding: 3px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--brand-strong);
  font-size: 11px;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.empty-row td {
  height: 112px;
  color: var(--muted);
  text-align: left;
}

.table-footer {
  min-height: 50px;
  justify-content: space-between;
  padding: 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.calculator-section {
  margin-top: 0;
  padding: 16px;
}

.account-risk-section {
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.income-section {
  margin-top: 0;
  padding: 20px;
}

.account-income-mount {
  min-width: 0;
}

.account-income-mount > .income-section {
  margin: 0;
  padding: 16px;
  border: 0;
  border-radius: 0 0 5px 5px;
  background: transparent;
  box-shadow: none;
  animation: none;
}

.income-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.income-admin-toolbar {
  min-height: 34px;
}

.account-income-mount .income-admin-toolbar {
  width: 100%;
  display: grid;
  grid-template-columns: 132px auto;
  justify-content: end;
  gap: 8px;
}

.account-income-mount .income-admin-toolbar select {
  grid-column: auto;
  width: 132px;
}

.account-income-mount .income-admin-toolbar select,
.account-income-mount .income-admin-toolbar .button {
  min-height: 34px;
  height: 34px;
}

.income-heading-actions select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 10px;
}

.income-status {
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid rgba(42, 201, 145, 0.35);
  border-radius: 5px;
  background: rgba(42, 201, 145, 0.07);
  color: var(--negative);
  font-size: 10px;
}

.income-status.is-error {
  border-color: var(--danger-border);
  background: var(--positive-soft);
  color: var(--danger-text);
}

.income-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  margin-top: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.income-period-control {
  color: var(--muted);
  font-size: 10px;
}

.income-period-control .segmented-control {
  min-width: 122px;
}

.income-period-control .segmented-control span {
  min-height: 26px;
  font-size: 10px;
}

.income-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.income-metrics > div {
  min-width: 0;
  padding: 15px 13px;
}

.income-metrics > div + div {
  border-left: 1px solid var(--border);
}

.income-metrics span,
.income-metrics strong {
  display: block;
}

.income-metrics span {
  color: var(--muted);
  font-size: 9px;
}

.income-metrics strong {
  margin-top: 5px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.income-chart {
  min-width: 0;
  min-height: 270px;
  position: relative;
  padding-top: 10px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.income-chart svg {
  width: 100%;
  height: 270px;
  display: block;
}

.income-zero-line {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.income-bar-earnings {
  fill: var(--negative);
  opacity: 0.82;
}

.income-bar-fee {
  fill: var(--brand);
  opacity: 0.76;
}


.income-chart-label {
  fill: var(--muted);
  font-size: 9px;
}

.income-chart-legend {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 8px;
}

.income-chart-legend span::before {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 4px;
  border-radius: 2px;
  content: "";
}

.income-chart-legend .is-earnings::before { background: var(--negative); }
.income-chart-legend .is-fee::before { background: var(--brand); }

.income-table-shell {
  min-width: 0;
  overflow-x: auto;
}

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

.income-table th,
.income-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.income-table th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.012);
  font-size: 9px;
  font-weight: 600;
}

.income-table td {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.income-table th.numeric,
.income-table td.numeric {
  text-align: right;
}

.income-table td strong,
.income-table td small {
  display: block;
}

.income-table td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.account-connect-heading,
.account-row-heading,
.account-row-actions {
  display: flex;
  align-items: center;
}

.account-connect-heading,
.account-row-heading {
  justify-content: space-between;
}

.account-risk-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.account-connect-form {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 22px;
  border-right: 1px solid var(--border);
}

.account-connect-heading {
  align-items: baseline;
  gap: 10px;
  margin-bottom: 2px;
}

.account-connect-heading strong {
  font-size: 13px;
}

.account-connect-heading span,
.account-security-note {
  color: var(--muted);
  font-size: 11px;
}

.account-connect-form .button-primary {
  width: 100%;
  margin-top: 2px;
}

.account-auth-status {
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--negative);
  font-size: 11px;
}

.account-auth-status.is-error {
  border-color: var(--danger-border);
  background: var(--positive-soft);
  color: var(--danger-text);
}

.account-security-note {
  margin: 0;
}

.account-monitor {
  min-width: 0;
}

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

.account-empty {
  grid-column: 1 / -1;
  min-height: 230px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.account-row {
  min-width: 0;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-row + .account-row {
  border-top: 1px solid var(--border);
}

.account-row.is-expanded {
  grid-column: 1 / -1;
  min-height: 0;
}

.account-row-heading {
  gap: 18px;
}

.account-row-heading strong,
.account-row-heading span {
  display: block;
}

.account-row-heading strong {
  font-size: 13px;
}

.account-row-heading span,
.account-row-actions {
  color: var(--muted);
  font-size: 10px;
}

.account-row-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.account-row-actions button {
  padding: 3px 6px;
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  font-size: 11px;
}

.account-row-error {
  margin-top: 10px;
  color: var(--danger-text);
  font-size: 11px;
}

.account-risk-lineup {
  display: grid;
  grid-template-columns: minmax(74px, 0.35fr) minmax(170px, 1fr) minmax(170px, 0.75fr);
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.account-mmr-summary span,
.account-mmr-summary strong,
.account-mmr-summary small {
  display: block;
}

.account-mmr-summary span,
.account-mmr-summary small,
.account-values span {
  color: var(--muted);
  font-size: 10px;
}

.account-mmr-summary strong {
  margin: 3px 0 2px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.account-mmr-scale {
  position: relative;
  height: 12px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.account-mmr-scale span {
  position: absolute;
  top: 0;
}

.account-mmr-scale span:first-child {
  left: 0;
}

.account-mmr-scale span:nth-child(2) {
  left: 60%;
  transform: translateX(-50%);
}

.account-mmr-scale span:nth-child(3) {
  left: 80%;
  transform: translateX(-50%);
}

.account-mmr-scale span:last-child {
  right: 0;
}

.account-mmr-visual {
  min-width: 0;
  position: relative;
}

.account-mmr-track {
  position: relative;
  height: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-soft);
}

.account-mmr-watch,
.account-mmr-warning {
  position: absolute;
  top: 0;
  bottom: 0;
}

.account-mmr-watch {
  left: 60%;
  width: 20%;
  background: var(--warning-soft);
}

.account-mmr-warning {
  right: 0;
  width: 20%;
  border-radius: 0 4px 4px 0;
  background: var(--positive-soft);
}

.account-mmr-track i {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  transform: translate(-50%, -50%);
}

.account-values {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.account-values div {
  min-width: 0;
}

.account-values span,
.account-values strong {
  display: block;
}

.account-values strong {
  margin-top: 2px;
  color: var(--text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.account-health {
  min-width: 48px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 9px !important;
  font-weight: 650;
}

.account-data-warning {
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 169, 64, 0.3);
  border-radius: 5px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 10px;
}

.account-details {
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.account-details > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

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

.account-details > summary span {
  font-size: 11px;
  font-weight: 650;
}

.account-details > summary span::before {
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  content: "›";
  font-size: 15px;
  transform-origin: center;
}

.account-details[open] > summary span::before {
  transform: rotate(90deg);
}

.account-details > summary small {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.account-detail-content {
  padding: 0 0 6px;
}

.account-detail-tabs {
  display: flex;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px 5px 0 0;
  background: var(--surface-soft);
}

.account-detail-tabs button {
  flex: 1 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.account-detail-tabs button + button {
  border-left: 1px solid var(--border);
}

.account-detail-tabs button[aria-selected="true"] {
  border-bottom-color: var(--brand);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.account-detail-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 5px 5px;
}

.account-detail-block + .account-detail-block {
  border-top: 1px solid var(--border);
}

.account-risk-positions {
  border-top: 1px solid var(--border);
}

.account-risk-positions .account-detail-table,
.account-detail-panel > .account-table-shell .account-detail-table {
  min-width: 900px;
}

.account-detail-heading {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.account-detail-heading strong {
  font-size: 10px;
}

.account-detail-heading span {
  color: var(--muted);
  font-size: 9px;
}

.account-table-shell {
  min-width: 0;
  overflow-x: auto;
}

.account-detail-table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
}

.account-detail-table th,
.account-detail-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.account-detail-table th:first-child,
.account-detail-table td:first-child {
  text-align: left;
}

.account-detail-table th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.012);
  font-size: 9px;
  font-weight: 600;
}

.account-detail-table td {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.account-detail-table tr:last-child td {
  border-bottom: 0;
}

.account-detail-table td strong,
.account-detail-table td small {
  display: block;
}

.account-detail-table td small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.account-detail-loading {
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.account-settings-grid {
  display: grid;
  border-bottom: 1px solid var(--border);
}

.account-settings-grid > div {
  min-width: 0;
  padding: 12px;
}

.account-settings-grid > div + div {
  border-left: 1px solid var(--border);
}

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

.account-settings-grid span {
  color: var(--muted);
  font-size: 8px;
}

.account-settings-grid strong {
  margin-top: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.account-settings-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 0;
}

.account-income-history {
  border-top: 1px solid var(--border);
}

.account-income-history > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  list-style: none;
}

.account-income-history > summary::-webkit-details-marker {
  display: none;
}

.account-income-history > summary::before {
  margin-right: 8px;
  color: var(--brand-strong);
  content: "+";
  font-size: 14px;
}

.account-income-history[open] > summary {
  border-bottom: 1px solid var(--border);
}

.account-income-history[open] > summary::before {
  content: "−";
}

.account-history-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.account-settings-grid > div:nth-child(4n + 1) {
  border-left: 0;
}

.account-settings-grid > div:nth-child(n + 5) {
  border-top: 1px solid var(--border);
}

.setting-on {
  color: var(--negative);
}

.setting-off {
  color: var(--muted);
}

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

.account-calculator-output {
  min-width: 0;
}

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

.account-calculator-status {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
}

.account-calculator-status.is-error {
  color: var(--danger-text);
}

.account-calculator-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.account-calculator-results > div {
  min-width: 0;
  padding: 14px 16px;
}

.account-calculator-results > div + div {
  border-left: 1px solid var(--border);
}

.account-calculator-results span,
.account-calculator-results strong {
  display: block;
}

.account-calculator-results span {
  color: var(--muted);
  font-size: 10px;
}

.account-calculator-results strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.account-calculator-results .is-primary strong {
  font-size: 22px;
}

.account-calculator-breakdown-wrap {
  border-bottom: 1px solid var(--border);
}

.account-calculator-breakdown {
  min-width: 560px;
}

.calculator-heading,
.saved-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.calculator-heading .button-primary {
  min-width: 92px;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  align-items: start;
  gap: 18px;
  margin-top: 14px;
}

.calculator-form {
  margin-top: 0;
}

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

.calculator-section .form-field {
  gap: 4px;
  font-size: 11px;
}

.calculator-section .form-field legend {
  margin-bottom: 4px;
}

.calculator-section .strategy-options select,
.calculator-section .position-fields input:not([type="range"]) {
  height: 34px;
}

.calculator-section .segmented-control span {
  min-height: 26px;
  font-size: 11px;
}

.form-field {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

fieldset.form-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-field legend {
  margin-bottom: 6px;
  padding: 0;
}

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

.segmented-control {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}

.segmented-control label {
  min-width: 0;
  position: relative;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented-control span {
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.segmented-control input:checked + span {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(240, 79, 85, 0.28);
  outline-offset: 1px;
}

.live-market-data {
  min-width: 0;
  margin-top: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  box-shadow: 16px 0 0 var(--surface-raised), -16px 0 0 var(--surface-raised);
}

.live-data-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.live-data-heading strong {
  font-size: 13px;
  color: var(--text);
}

.live-data-heading span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.live-data-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 8px;
}

.live-data-grid div {
  min-width: 0;
}

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

.live-data-grid span {
  color: var(--muted);
  font-size: 10px;
}

.live-data-grid strong {
  margin-top: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  color: var(--text);
}

.live-data-grid .live-spread-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-data-grid .market-refresh-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.live-data-grid .market-refresh-indicator span {
  display: inline;
  color: inherit;
  font-size: inherit;
}

.market-refresh-indicator i {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--muted);
}

.market-refresh-indicator.is-loading {
  color: var(--info);
}

.market-refresh-indicator.is-loading i {
  background: var(--info);
  animation: market-refresh-pulse 1s ease-out infinite;
}

.market-refresh-indicator.is-live {
  color: var(--negative);
}

.market-refresh-indicator.is-live i {
  background: var(--negative);
  animation: market-refresh-pulse 1s ease-out infinite;
}

.market-refresh-indicator.is-delayed {
  color: var(--warning);
}

.market-refresh-indicator.is-delayed i {
  background: var(--warning);
}

.market-refresh-indicator.is-error {
  color: var(--brand-strong);
}

.market-refresh-indicator.is-error i {
  background: var(--brand-strong);
}

#calculator-live-spread.is-updated {
  animation: market-value-flash 600ms ease-out;
}

.position-panel {
  min-width: 0;
}

.position-panel h3 {
  margin-bottom: 14px;
  font-size: 14px;
}

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

.form-field input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quick-options button {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.quick-options button[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--positive-soft);
  color: var(--text);
  font-weight: 650;
}

.allocation-field > span:first-child,
.allocation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.allocation-field output {
  color: var(--text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.allocation-field input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.allocation-field[hidden] {
  display: none;
}

.allocation-meta {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.calculator-risk {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #6b5428;
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
}

.calculator-risk.is-error {
  border-color: var(--danger-border);
  background: var(--positive-soft);
  color: var(--danger-text);
}

.calculator-results {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.calculator-results::before {
  display: block;
  width: 24px;
  height: 2px;
  margin-bottom: 8px;
  background: var(--brand);
  content: "";
  box-shadow: 0 0 14px rgba(240, 79, 85, 0.5);
}

.primary-result span,
.primary-result small,
.result-grid span {
  color: var(--muted);
  font-size: 11px;
}

.primary-result strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px currentColor;
}

.primary-result small {
  display: block;
}

.primary-result small:empty,
.live-data-heading span:empty {
  display: none;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 10px;
}

.result-grid div {
  min-width: 0;
}

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

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

.result-grid strong {
  margin-top: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.breakdown-table-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.breakdown-table {
  width: 100%;
  min-width: 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  table-layout: fixed;
  font-size: 12px;
}

.breakdown-table th,
.breakdown-table td {
  height: 32px;
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-table th:first-child { width: 46%; }
.breakdown-table th:nth-child(2),
.breakdown-table th:nth-child(3) { width: 27%; }

.breakdown-table th:first-child,
.breakdown-table td:first-child {
  padding-left: 0;
}

.breakdown-table th:last-child,
.breakdown-table td:last-child {
  padding-right: 0;
}

.account-mmr-mount {
  min-width: 0;
}

.mmr-risk-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.account-mmr-mount > .mmr-risk-section {
  margin: 0;
  padding: 16px;
  border-top: 0;
}

.account-mmr-mount .mmr-chart {
  margin-top: 0;
}

.mmr-chart {
  position: relative;
  width: 100%;
  min-height: 230px;
  margin-top: 14px;
  cursor: crosshair;
  touch-action: pan-y;
}

.mmr-chart svg {
  display: block;
  width: 100%;
  height: 230px;
  overflow: visible;
}

.mmr-chart-placeholder {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mmr-danger-zone {
  fill: rgba(240, 79, 85, 0.07);
}

.mmr-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.mmr-threshold {
  stroke: var(--brand);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}

.mmr-risk-line {
  fill: none;
  stroke: var(--info);
  stroke-width: 2.25;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(106, 168, 255, 0.32));
}

.mmr-risk-line-after {
  opacity: 0.28;
  filter: none;
}

.mmr-current-marker,
.mmr-liquidation-marker {
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.mmr-current-marker {
  stroke: var(--border-strong);
}

.mmr-liquidation-marker {
  stroke: var(--brand);
}

.mmr-current-dot {
  fill: var(--surface);
  stroke: var(--info);
  stroke-width: 2;
}

.mmr-chart-label,
.mmr-marker-label {
  fill: var(--muted);
  font-size: 11px;
}

.mmr-marker-label {
  fill: var(--text);
}

.mmr-current-label {
  fill: var(--info);
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  font-size: 10px;
  font-weight: 600;
}

.mmr-hover-marker line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.mmr-hover-marker .mmr-hover-horizontal {
  opacity: 0.55;
}

.mmr-hover-marker[hidden] {
  display: none;
}

.mmr-hover-marker circle {
  fill: var(--surface);
  stroke: var(--info);
  stroke-width: 2;
}

.mmr-tooltip {
  position: absolute;
  z-index: 3;
  width: 172px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  color: var(--text);
  pointer-events: none;
  transform: translateX(-50%);
}

.mmr-tooltip strong,
.mmr-tooltip span {
  display: block;
  font-size: 11px;
}

.mmr-tooltip span {
  margin-top: 3px;
  color: var(--muted);
}

.risk-safe {
  color: var(--negative) !important;
}

.risk-warning {
  color: var(--warning) !important;
}

.risk-critical {
  color: var(--brand-strong) !important;
}

.history-section {
  margin-top: 0;
  padding: 20px;
}

.market-overview .history-section {
  display: flex;
  flex-direction: column;
}

.history-heading {
  justify-content: space-between;
  gap: 24px;
}

.history-market-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.range-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}

.range-control button {
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.range-control button[aria-pressed="true"] {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

.chart-meta {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.market-overview .history-section .chart {
  flex: 1;
  min-height: 260px;
}

.market-overview .history-section .chart svg {
  min-height: 260px;
  height: 100%;
}

.market-overview .history-section .chart-placeholder {
  min-height: 260px;
}

.chart {
  position: relative;
  width: 100%;
  min-height: 300px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 300px;
  overflow: visible;
}

.chart-placeholder {
  min-height: 270px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-zero {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.chart-area-positive {
  fill: rgba(255, 116, 121, 0.08);
}

.chart-area-negative {
  fill: rgba(67, 213, 162, 0.07);
}

.chart-line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(240, 79, 85, 0.35));
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--brand);
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-current {
  fill: var(--text);
  font-size: 11px;
  font-weight: 650;
}

@keyframes ui-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes header-flow {
  to {
    background-position: -220% 0;
  }
}

@keyframes live-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px var(--negative-soft), 0 0 0 0 rgba(67, 213, 162, 0.2);
  }
  50% {
    box-shadow: 0 0 0 3px var(--negative-soft), 0 0 0 8px rgba(67, 213, 162, 0);
  }
}

@keyframes market-refresh-pulse {
  0% {
    box-shadow: 0 0 0 0 currentColor;
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 5px transparent;
    opacity: 0.72;
  }
}

@keyframes market-value-flash {
  0% {
    background: rgba(240, 79, 85, 0.24);
  }
  100% {
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 1100px) {
  .market-overview {
    grid-template-columns: minmax(0, 1fr);
  }

  .market-overview > section {
    min-height: 0;
  }

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

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

  .account-risk-lineup {
    grid-template-columns: minmax(130px, 0.45fr) minmax(220px, 1fr);
  }

  .account-values {
    grid-column: 1 / -1;
  }

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

}

@media (max-width: 900px) {
  .income-heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

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

  .income-metrics > div:nth-child(odd) {
    border-left: 0;
  }

  .income-metrics > div:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .income-metrics > div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .calculator-layout {
    grid-template-columns: 1fr;
  }

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

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

  .account-risk-layout {
    grid-template-columns: 1fr;
  }

  .account-connect-form {
    padding-right: 0;
    padding-bottom: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .calculator-results {
    padding-top: 14px;
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .page-shell {
    width: min(100% - 24px, 1380px);
  }

  .header-inner {
    min-height: 92px;
    align-items: flex-start;
    padding: 14px 0;
  }

  .brand-lockup p,
  .live-indicator {
    display: none;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 16px;
  }

  .header-actions {
    align-self: center;
  }

  .button {
    min-height: 34px;
    padding: 0 11px;
    font-size: 12px;
  }

  .page-shell {
    padding-top: 14px;
  }

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

  .query-panel {
    padding: 14px 15px;
  }

  .search-results {
    max-height: 310px;
  }

  .table-footer {
    padding: 0 15px;
  }

  .history-section {
    padding: 16px 15px;
  }

  .calculator-section {
    padding: 16px 15px;
  }

  .account-risk-section {
    padding: 0;
  }

  .income-section {
    padding: 16px 15px;
  }

  .income-heading-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .income-heading-actions select {
    grid-column: auto;
    width: 100%;
  }

  .income-filters {
    grid-template-columns: 1fr;
  }

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

  .income-metrics > div:nth-child(odd) {
    border-left: 0;
  }

  .income-metrics > div:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .income-metrics > div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .income-chart,
  .income-chart svg,
  .income-chart .chart-placeholder {
    min-height: 230px;
    height: 230px;
  }

  .income-chart-legend {
    max-width: calc(100% - 12px);
    flex-wrap: wrap;
    justify-content: center;
  }

  .account-row-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-row-actions {
    width: 100%;
    justify-content: space-between;
  }

  .account-risk-lineup {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 14px;
  }

  .account-row {
    min-height: 0;
    padding: 16px;
    border-radius: 6px;
  }

  .account-details {
    margin-top: 12px;
  }

  .account-list {
    gap: 14px;
  }

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

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

  .account-settings-grid > div:nth-child(odd) {
    border-left: 0;
  }

  .account-settings-grid > div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .account-details > summary {
    min-height: 44px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 9px 4px;
  }

  .account-calculator {
    padding: 14px 0 0;
  }

  .account-calculator-controls {
    grid-template-columns: 1fr;
  }

  .account-details > summary small {
    padding-left: 23px;
    text-align: left;
  }

  .calculator-heading {
    align-items: flex-start;
  }

  .mmr-chart,
  .mmr-chart svg {
    min-height: 220px;
    height: 220px;
  }

  .strategy-options .form-field:first-child,
  .strategy-options .form-field:nth-child(2) {
    grid-column: 1 / -1;
  }

  .live-data-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .live-data-heading span {
    text-align: left;
  }

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

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

  .segmented-control span {
    padding: 0 5px;
  }

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

  .history-heading {
    gap: 14px;
  }

  .range-control {
    width: 100%;
  }

  .range-control button {
    flex: 1;
  }

  .chart,
  .chart svg {
    min-height: 250px;
    height: 250px;
  }

}

/* Authenticated shell */
[hidden] {
  display: none !important;
}

.header-link {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.session-user-menu {
  position: relative;
}

.session-user {
  min-width: 92px;
  min-height: 42px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: right;
}

.session-user:hover,
.session-user[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface);
}

.session-user span,
.session-user small {
  display: block;
}

.session-user-dropdown {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  width: 112px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.session-user-dropdown button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.session-user-dropdown button:hover,
.session-user-dropdown button:focus-visible {
  background: var(--surface-soft);
}

.session-user span {
  max-width: 150px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-user small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.account-risk-layout-full {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
}

.account-risk-layout-full .account-auth-status {
  margin: 0 0 10px;
}

/* Login */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: #090a0c;
}

.auth-shell {
  width: min(400px, 100%);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.38);
}

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

.auth-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(240, 79, 85, 0.26));
}

.auth-lockup h1 {
  font-size: 16px;
}

.auth-panel-heading h2 {
  font-size: 18px;
}

.auth-form {
  display: grid;
  gap: 15px;
  margin-top: 22px;
}

.auth-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
}

.auth-method-toggle {
  align-self: center;
  margin-top: 12px;
}

.auth-error,
.admin-message {
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  background: var(--positive-soft);
  color: var(--danger-text);
  font-size: 12px;
  line-height: 1.55;
}

/* Admin */
.admin-shell {
  width: min(1380px, calc(100% - 40px));
  min-height: calc(100vh - 104px);
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 16px;
  margin: 18px auto 32px;
}

.admin-nav {
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.admin-nav button {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.admin-nav button + button {
  border-top: 1px solid var(--border);
}

.admin-nav button[aria-pressed="true"] {
  border-left-color: var(--brand);
  background: var(--surface-soft);
}

.admin-nav span {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.admin-content,
.admin-view {
  min-width: 0;
}

.admin-view {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-message {
  margin-bottom: 10px;
  border-color: rgba(42, 201, 145, 0.35);
  background: rgba(42, 201, 145, 0.08);
  color: var(--negative);
}

.admin-message.is-error {
  border-color: var(--danger-border);
  background: var(--positive-soft);
  color: var(--danger-text);
}

.admin-action-bar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.admin-market-settings {
  display: grid;
  grid-template-columns: minmax(210px, 280px) auto minmax(240px, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.admin-market-settings > .button {
  min-height: 38px;
}

.admin-market-settings-panel {
  min-height: 78px;
  border-bottom: 0;
}

.admin-feature-shell {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
}

.admin-feature-nav {
  border-right: 1px solid var(--border);
  background: var(--surface-soft);
}

.admin-feature-nav button {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.admin-feature-nav button[aria-pressed="true"] {
  border-left-color: var(--brand);
  background: var(--surface);
}

.admin-feature-nav span {
  font-size: 12px;
  font-weight: 650;
}

.admin-feature-content {
  min-width: 0;
}

.admin-market-list {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
}

.admin-market-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
}

.admin-market-chip span:last-child,
.admin-market-empty {
  color: var(--muted);
}

.admin-split {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
}

.admin-editor {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.admin-editor[hidden] + .admin-table-shell {
  grid-column: 1 / -1;
}

.admin-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-editor-heading strong {
  font-size: 13px;
}

.text-action,
.table-actions button {
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  font-size: 11px;
}

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

.admin-editor-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.admin-editor-inline {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.4fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr) auto auto;
  align-items: end;
  gap: 12px;
  border-right: 0;
}

.admin-editor-inline .button {
  min-height: 38px;
}

.admin-check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text-muted);
  font-size: 12px;
}

.admin-check-field input,
.admin-account-access input {
  accent-color: var(--brand);
}

.admin-account-access {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
}

.admin-account-access legend {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.admin-account-access > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.admin-account-access label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

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

.notification-settings {
  display: grid;
}

.notification-settings-block {
  border-bottom: 1px solid var(--border);
}

.notification-settings-block > strong {
  display: block;
  padding: 14px 14px 0;
  font-size: 12px;
}

.notification-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  padding: 12px 14px 14px;
}

.notification-market-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px 14px 14px;
}

.notification-market-picker .admin-market-list {
  grid-column: 1 / -1;
}

.notification-status {
  margin: 12px 14px 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.notification-status.is-error {
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.notification-rule-grid > label:not(.form-field) {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.notification-rule-grid input[type="checkbox"] {
  accent-color: var(--brand);
}

.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.admin-passkey-manager {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.admin-passkey-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.admin-passkey-row,
.admin-passkey-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.admin-passkey-add {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-passkey-row input,
.admin-passkey-add input {
  min-width: 0;
  min-height: 36px;
}

.admin-passkey-row button {
  border: 0;
  background: transparent;
  color: var(--brand-strong);
}

.admin-table-shell {
  min-width: 0;
  overflow-x: auto;
}

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

.admin-table th,
.admin-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.015);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.admin-table td {
  font-size: 11px;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table td strong,
.admin-table td small {
  display: block;
}

.admin-table td small {
  max-width: 280px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 9px;
}

.status-badge.is-active {
  border-color: rgba(42, 201, 145, 0.35);
  background: rgba(42, 201, 145, 0.08);
  color: var(--negative);
}

.status-badge.is-disabled {
  color: var(--muted);
}

.status-badge.is-error,
.table-error,
.danger-action {
  color: var(--danger-text) !important;
}

@media (max-width: 980px) {
  .admin-shell {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-auto-rows: max-content;
    align-content: start;
  }

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

  .admin-nav button + button {
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .admin-nav button[aria-pressed="true"] {
    border-bottom: 3px solid var(--brand);
    border-left-color: var(--border);
  }

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

@media (max-width: 720px) {
  .auth-page {
    padding: 16px;
  }

  .auth-panel {
    padding: 26px 22px;
  }

  .auth-logo {
    width: 32px;
    height: 32px;
  }

  .admin-shell {
    width: min(100% - 24px, 1380px);
    gap: 12px;
    margin-top: 14px;
  }

  .admin-nav button {
    min-height: 42px;
    padding: 8px;
    text-align: center;
  }

  .admin-split {
    grid-template-columns: 1fr;
  }

  .admin-editor {
    grid-column: 1;
    padding: 16px;
    border-right: 0;
  }

  .admin-form-grid,
  .admin-editor-inline,
  .admin-settings-grid,
  .notification-rule-grid {
    grid-template-columns: 1fr;
  }

  .admin-market-settings {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px;
  }

  .admin-market-list {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .admin-feature-shell {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .admin-feature-nav {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .admin-feature-nav button {
    width: auto;
    min-width: 138px;
    min-height: 44px;
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .admin-feature-nav button[aria-pressed="true"] {
    border-bottom-color: var(--brand);
  }

  .admin-page .header-actions {
    gap: 7px;
  }

}

@media (max-width: 640px) {
  .app-header .header-actions {
    gap: 6px;
  }

  .app-header .header-link {
    padding: 0 8px;
  }

  body:not(.admin-page) #admin-link,
  .admin-page #admin-dashboard-link,
  body:not(.admin-page) .session-user,
  .admin-page .session-user {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  body:not(.admin-page) #admin-link,
  .admin-page #admin-dashboard-link {
    font-size: 0;
  }

  body:not(.admin-page) #admin-link::after {
    content: "管理";
    font-size: 10px;
  }

  .admin-page #admin-dashboard-link::after {
    content: "面板";
    font-size: 10px;
  }

  body:not(.admin-page) .session-user span,
  .admin-page .session-user span {
    max-width: 40px;
    text-align: center;
  }

  body:not(.admin-page) .session-user small,
  .admin-page .session-user small {
    display: none;
  }
}
