:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --color-background: #0f172a;
  --color-background-alt: #1e293b;
  --color-surface: rgba(15, 23, 42, 0.7);
  --color-surface-muted: rgba(148, 163, 184, 0.08);
  --color-surface-strong: rgba(148, 163, 184, 0.12);
  --color-text-primary: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-strong: #f8fafc;
  --color-negative-text: #f87171;
  --color-warning-text: #fbbf24;
  --color-positive-strong: #22c55e;
  --color-positive-text: #86efac;
  --color-border-subtle: rgba(148, 163, 184, 0.25);
  --color-accent-start: #38bdf8;
  --color-accent-end: #0ea5e9;
  --color-success: #22c55e;
  --color-warning: #fbbf24;
  --color-danger: #f87171;
  --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.45);
}

:root[data-theme='light'] {
  color-scheme: light;
  --color-background: #f1f5f9;
  --color-background-alt: #e2e8f0;
  --color-surface: rgba(255, 255, 255, 0.86);
  --color-surface-muted: rgba(203, 213, 225, 0.35);
  --color-surface-strong: rgba(203, 213, 225, 0.55);
  --color-text-primary: #0f172a;
  --color-text-muted: #475569;
  --color-text-strong: #0b1120;
  --color-negative-text: #dc2626;
  --color-warning-text: #d97706;
  --color-positive-strong: #16a34a;
  --color-positive-text: #15803d;
  --color-border-subtle: rgba(51, 65, 85, 0.25);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, var(--color-background-alt) 0%, var(--color-background) 60%);
  color: var(--color-text-primary);
  display: flex;
  justify-content: center;
}
body.auth-locked {
  overflow: hidden;
}
body.auth-locked .page {
  display: none;
}
.page {
  width: min(1200px, 100%);
  padding: 0.4rem clamp(1.5rem, 5vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
}
h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}
p {
  margin: 0;
  line-height: 1.5;
}
.header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.header__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}
.header__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.header__title {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.header__install {
  white-space: nowrap;
  padding: 0.45rem 0.9rem;
}
.header__user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.header__user-email {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.header__user button {
  padding: 0.45rem 0.9rem;
}
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.status-chips:empty {
  display: none;
}
.status-chips:not(:empty) {
  margin-top: 0.3rem;
}
.status-chip {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5f5;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.status-chip.ok {
  background: rgba(34, 197, 94, 0.2);
  color: var(--color-success);
}
.status-chip.error {
  background: rgba(248, 113, 113, 0.2);
  color: var(--color-danger);
}
.status-chip.info {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}
button {
  background: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  border: none;
  color: #052c4c;
  padding: 0.6rem 1.15rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
  box-shadow: 0 12px 25px rgba(14, 165, 233, 0.35);
}
button.secondary {
  background: rgba(148, 163, 184, 0.2);
  color: var(--color-text-primary);
  box-shadow: none;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
button:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
button:focus-visible,
select:focus-visible,
input[type='number']:focus-visible,
.tab:focus-visible,
button.venue-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
input, button {
  font-family: inherit;
}
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
input[type='number']:focus,
textarea:focus {
  border-color: rgba(56, 189, 248, 0.65);
  outline: none;
}
textarea {
  resize: vertical;
  min-height: 3.2rem;
}
label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.venue-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

button.venue-button {
  background: rgba(15, 23, 42, 0.85);
  color: var(--color-text-primary);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: none;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-start;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: normal;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

button.venue-button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.6);
}

.venue-button__logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 0.4rem;
  background: rgba(15, 23, 42, 0.8);
}

.venue-button__label {
  font-weight: 600;
  font-size: 0.95em;
  letter-spacing: 0.02em;
  line-height: 1.15;
  flex: 1;
  word-break: break-word;
}

button.venue-button.selected {
  background: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  color: #052c4c;
  border-color: rgba(56, 189, 248, 0.9);
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.45);
}

button.venue-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  filter: none;
}
.layout {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  align-items: start;
}
.panel {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: 1.1rem;
  box-shadow: 0 28px 60px rgba(8, 15, 34, 0.45);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.08);
  backdrop-filter: blur(12px);
}
.panel h2 {
  font-size: 1.1rem;
  color: var(--color-text-strong);
}
.control-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.1rem;
  border-radius: 0.9rem;
  background: var(--color-surface-muted);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.control-feedback {
  min-height: 1rem;
}
.feedback {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #cbd5f5;
  font-size: 0.85rem;
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.feedback--success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
}
.feedback--error {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}
.feedback__message {
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.feedback ul {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.feedback li {
  list-style: disc;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.control-card h3 {
  font-size: 1rem;
  color: var(--color-text-strong);
}
.control-card p {
  font-size: 0.9rem;
  color: #a5b4fc;
}
.control-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Leverage Slider */
.leverage-slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.25);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}
input[type="range"]:focus {
  outline: none;
}
input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: var(--focus-ring), 0 2px 8px rgba(14, 165, 233, 0.4);
}
.leverage-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-strong);
  min-width: 2.5rem;
  text-align: right;
}
.notional-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: rgba(148, 163, 184, 0.1);
  margin-top: 0.25rem;
}
.preview-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.preview-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-positive-text);
}
.preview-value.error {
  color: var(--color-danger);
}
.preview-value.loading {
  color: var(--color-text-muted);
}

/* Collateral Slider */
.collateral-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.collateral-mode-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 0.5rem;
  align-self: flex-start;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 0.4rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  box-shadow: none;
}
.mode-btn:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--color-text-primary);
  transform: none;
}
.mode-btn.active {
  background: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  color: #052c4c;
}
.collateral-slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.collateral-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-strong);
  min-width: 4rem;
  text-align: right;
}
.collateral-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  background: rgba(148, 163, 184, 0.08);
  font-size: 0.8rem;
}
.collateral-info .info-label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
}
.collateral-info .info-value {
  color: var(--color-text-primary);
  font-weight: 500;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.panel-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1100;
}
.auth-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 23, 0.78);
  backdrop-filter: blur(6px);
}
.auth-overlay__dialog {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
  gap: 1.5rem;
  padding: 2rem;
  width: min(90vw, 720px);
  background: rgba(15, 23, 42, 0.9);
  border-radius: 1.1rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.45);
}
.auth-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-panel--disabled {
  opacity: 0.5;
}
.auth-panel[hidden] {
  display: none;
}
.auth-panel h2 {
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.auth-panel button[type='submit'] {
  align-self: flex-start;
}
.auth-switch {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-accent-start);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  align-self: flex-start;
}
.auth-switch:focus-visible {
  outline: none;
  box-shadow: none;
  text-decoration: none;
}
.auth-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.auth-message--error {
  color: var(--color-danger);
}
.auth-message--success {
  color: var(--color-success);
}

.profile-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1090;
}
.profile-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.profile-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}
.profile-modal__dialog {
  position: relative;
  width: min(640px, 95vw);
  max-height: min(85vh, 720px);
  background: rgba(15, 23, 42, 0.96);
  border-radius: 1rem;
  padding: 1.8rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
}
.profile-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.profile-modal__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}
.profile-modal__body {
  overflow-y: auto;
  padding-right: 0.4rem;
}
.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.profile-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
}
.profile-section__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-strong);
}
.profile-section__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.profile-section__link {
  font-size: 0.85rem;
  color: var(--color-accent-start);
  text-decoration: underline;
}
.profile-section__link:focus-visible,
.profile-section__link:hover {
  text-decoration: none;
}
.profile-section__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.profile-section__save {
  align-self: flex-end;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.profile-field__optional {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  text-transform: none;
  color: var(--color-text-muted);
}
.profile-field__hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.profile-modal__actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.profile-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.profile-message--error {
  color: var(--color-danger);
}
.profile-message--success {
  color: var(--color-success);
}
.profile-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.summary-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.1rem;
  border-radius: 0.9rem;
  background: var(--color-surface);
  border-left: 4px solid rgba(148, 163, 184, 0.2);
  border-right: 1px solid rgba(148, 163, 184, 0.08);
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}
.summary-card.positive {
  border-left-color: var(--color-success);
}
.summary-card.warning {
  border-left-color: var(--color-warning);
}
.summary-card.negative {
  border-left-color: var(--color-danger);
}
.summary-card.muted {
  border-left-color: rgba(148, 163, 184, 0.25);
}
.summary-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.summary-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text-strong);
}
.summary-meta {
  font-size: 0.86rem;
  color: #a5add1;
}
.tab-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  align-self: flex-start;
}
.tab {
  background: transparent;
  border: none;
  color: #cbd5f5;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.tab.active {
  background: rgba(148, 163, 184, 0.35);
  color: #0b1120;
}
.tab-panel {
  display: none;
  gap: 1.25rem;
  animation: fadeIn 0.25s ease;
}
.tab-panel.active {
  display: grid;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.split-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
.sub-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  border-radius: 0.9rem;
  background: var(--color-surface-muted);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.combined-slot {
  min-height: 1.5rem;
}
.combined-metric {
  font-size: 1rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  padding: 0.65rem 0.85rem;
  border-radius: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.combined-metric.positive {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-positive-strong);
}
.combined-metric.negative {
  background: rgba(248, 113, 113, 0.12);
  color: var(--color-negative-text);
}
.combined-metric.muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-muted);
}
.strategy-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.strategy-metrics:empty {
  display: none;
}
.empty-state {
  color: #94a3b8;
  font-size: 0.9rem;
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  margin-top: 0.5rem;
}
.table-scroll:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.table-scroll table {
  width: 100%;
  border-spacing: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table--positions {
  table-layout: fixed;
  word-break: break-word;
}
.data-table--positions .liq-cell {
  color: var(--color-text-muted);
  font-size: 0.85em;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.55rem 0.35rem;
}
.data-table thead {
  color: #94a3b8;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.data-table tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.5);
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill.long {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
}
.pill.short {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}
.pill.neutral {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5f5;
}
.strategies {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.strategy-card {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.strategy-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.strategy-card__heading {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.strategy-card .meta {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}
.strategy-card__actions {
  display: flex;
  gap: 0.4rem;
}
.strategy-close-btn {
  white-space: nowrap;
}
.strategy-card .legs {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.leg-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
}
.kv-grid {
  display: grid;
  gap: 0.55rem;
  font-size: 0.85rem;
}
.kv-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  background: rgba(15, 23, 42, 0.6);
}
.kv-item .label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
}
.kv-item .value {
  color: var(--color-text-primary);
  font-weight: 500;
}
.stat-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border-radius: 0.7rem;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.stat-card span {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.stat-card strong {
  font-size: 1rem;
  color: var(--color-text-strong);
}
.list-simple {
  display: grid;
  gap: 0.45rem;
  font-size: 0.85rem;
}
.list-simple span.label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  margin-right: 0.35rem;
}
.totals-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.totals-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}
.totals-card li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 0.65rem;
  font-size: 0.9rem;
}
.log-stream {
  display: grid;
  gap: 0.9rem;
}
.log-entry {
  border-radius: 0.9rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.log-entry.success {
  border-color: rgba(34, 197, 94, 0.35);
}
.log-entry.error {
  border-color: rgba(248, 113, 113, 0.35);
}
.log-header {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 0.85rem;
}
.log-header span.time {
  color: var(--color-text-muted);
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Courier New', monospace;
}
.log-header span.action {
  font-weight: 600;
  color: var(--color-text-strong);
  text-transform: capitalize;
}
.log-header span.status {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.log-body {
  font-size: 0.85rem;
  color: #cbd5f5;
  display: grid;
  gap: 0.35rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.control-card--fundings {
  gap: 0.75rem;
}
.control-card__hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.fundings-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}
.fundings-modal.is-open {
  display: flex;
}
.fundings-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}
.fundings-modal__dialog {
  position: relative;
  width: min(880px, calc(100vw - 2.5rem));
  max-height: calc(100vh - 4rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.85));
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.45);
}
.fundings-modal__header,
.fundings-modal__footer {
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.fundings-modal__footer {
  flex-wrap: wrap;
}
.fundings-modal__footer-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.fundings-modal__header h2 {
  margin: 0;
  font-size: 1.3rem;
}
.fundings-modal__body {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}
.fundings-modal__intro {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.fundings-modal__overview {
  display: grid;
  gap: 0.5rem;
}
.fundings-modal__content {
  display: grid;
  gap: 1rem;
  align-content: start;
  align-items: stretch;
}
@media (min-width: 960px) {
  .fundings-modal__content {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  }
}
.fundings-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.7);
  box-shadow: inset 0 0 20px rgba(15, 23, 42, 0.25);
  min-height: 0;
}
.fundings-panel--markets {
  background: rgba(37, 99, 235, 0.12);
}
.fundings-panel--strategies {
  background: rgba(22, 163, 74, 0.12);
}
.fundings-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.fundings-panel__header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text-primary);
}
.fundings-panel__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.fundings-panel__placeholder {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: rgba(148, 163, 184, 0.08);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
}
.fundings-panel--markets .fundings-results {
  flex: 1 1 auto;
  overflow: auto;
  padding-right: 0.25rem;
}
.fundings-panel--strategies .fundings-launch {
  flex: 1 1 auto;
}
@media (min-width: 960px) {
  .fundings-panel--markets .fundings-results {
    max-height: 360px;
  }
}
.fundings-modal__close {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.5rem;
}
.fundings-modal__close:hover,
.fundings-modal__close:focus {
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-primary);
}
.fundings-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.fundings-panel--markets .fundings-results::-webkit-scrollbar {
  width: 0.35rem;
}
.fundings-panel--markets .fundings-results::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}
.fundings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.fundings-table thead {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.fundings-table th,
.fundings-table td {
  text-align: left;
  padding: 0.6rem 0.4rem;
}
.fundings-table tbody tr {
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.fundings-table tbody tr:first-child {
  border-top: none;
}
.fundings-table tbody tr:nth-child(odd) {
  background: rgba(148, 163, 184, 0.04);
}
.fundings-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.12);
}
.fundings-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.fundings-message.success {
  color: var(--color-positive-strong);
}
.fundings-message.error {
  color: var(--color-negative-text);
}
.fundings-errors {
  color: var(--color-negative-text);
  font-size: 0.8rem;
  display: grid;
  gap: 0.3rem;
}
.fundings-errors ul {
  margin: 0;
  padding-left: 1.2rem;
}
.fundings-launch {
  display: grid;
  gap: 1rem;
  width: 100%;
}
.fundings-launch__controls {
  display: grid;
  gap: 0.5rem;
}
.fundings-launch__controls label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.fundings-launch__hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
}
.fundings-recommendations {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .fundings-recommendations {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .fundings-recommendations {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.fundings-recommendation-card {
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-subtle);
  background: rgba(34, 197, 94, 0.08);
  display: grid;
  gap: 0.5rem;
  height: 100%;
}
.fundings-recommendation-card--primary {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.12);
}
.fundings-recommendation-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.fundings-recommendation-card__rank {
  font-weight: 600;
  color: var(--color-text-primary);
}
.fundings-recommendation-card__legs {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.fundings-recommendation-card__legs span {
  display: block;
  color: var(--color-text-primary);
}
.fundings-recommendation-card__legs small {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}
.fundings-recommendation-card__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.fundings-recommendation-card__feedback {
  font-size: 0.8rem;
}
.fundings-recommendation-card__feedback--info {
  color: var(--color-text-muted);
}
.fundings-recommendation-card__feedback--success {
  color: var(--color-positive-strong);
}
.fundings-recommendation-card__feedback--error {
  color: var(--color-negative-text);
}
.fundings-recommendation-card__feedback--warning {
  color: var(--color-warning-text);
}
.fundings-recommendation-card__spread {
  font-size: 0.85rem;
  color: var(--color-positive-text);
}
.fundings-recommendation-card__spread--negative {
  color: var(--color-negative-text);
}
body.modal-open {
  overflow: hidden;
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .page {
    padding: 0.4rem clamp(1rem, 4vw, 2rem) 1.5rem;
    gap: 1.75rem;
  }
  .layout {
    gap: 1.5rem;
  }
  .panel {
    padding: 1.3rem;
  }
  .panel-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }
  .control-card {
    padding: 1rem;
  }
  .sub-card {
    padding: 0.95rem 1.05rem;
  }
  .summary-card {
    padding: 0.9rem 1rem;
  }
}
@media (max-width: 640px) {
  body {
    justify-content: flex-start;
  }
  .page {
    gap: 1.5rem;
    padding: 0.4rem clamp(0.75rem, 5vw, 1.5rem) 1.25rem;
  }
  .header__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }
  .header__actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.45rem;
  }
  .header__user {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .status-chips {
    width: 100%;
  }
  .layout {
    gap: 1.2rem;
  }
  .panel {
    padding: 1rem;
    gap: 1rem;
  }
  .panel--overview {
    order: 1;
  }
  .panel--control {
    order: 2;
  }
  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .summary-card[data-summary='monitoring'] {
    display: none;
  }
  .tab-group {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }
  .tab-group::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex: 0 0 auto;
    padding: 0.45rem 0.85rem;
  }
  .split-grid {
    gap: 0.75rem;
  }
  .venue-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  button,
  input[type='number'] {
    width: 100%;
  }
  .control-actions {
    flex-direction: column;
  }
  .fundings-modal__dialog {
    width: calc(100vw - 1.5rem);
    padding: 1.25rem;
  }
  .fundings-launch {
    grid-template-columns: 1fr;
  }
  .table-scroll {
    margin: 0.5rem -0.75rem 0;
    padding: 0 0.75rem;
    overflow-x: visible;
  }
  .data-table--positions {
    border: 0;
  }
  .data-table--positions thead {
    display: none;
  }
  .data-table--positions tbody {
    display: grid;
    gap: 0.75rem;
  }
  .data-table--positions tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.75rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.15);
    background: rgba(15, 23, 42, 0.55);
  }
  .data-table--positions tbody td {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.95rem;
  }
  .data-table--positions tbody td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }
  .data-table--positions tbody td .pill {
    margin-right: auto;
  }
  .strategy-card {
    padding: 0.95rem 1rem;
    gap: 0.8rem;
    border-radius: 1rem;
  }
  .strategy-card header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }
  .strategy-card__heading strong {
    font-size: 1rem;
  }
  .strategy-card__actions {
    width: 100%;
    justify-content: flex-end;
  }
  .strategy-card__actions button {
    width: auto;
  }
  .strategy-card .meta {
    font-size: 0.8rem;
  }
  .strategy-metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }
  .strategy-metrics .combined-metric {
    display: flex;
    width: 100%;
    justify-content: space-between;
    font-size: 0.95rem;
  }
  .strategy-card .legs {
    gap: 0.65rem;
  }
  .leg-row {
    grid-template-columns: auto 1fr;
    gap: 0.45rem 0.8rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.85rem;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.12);
  }
  .leg-row span:nth-child(1) {
    align-self: start;
  }
  .leg-row span:nth-child(2) {
    font-weight: 600;
  }
  .leg-row span:nth-child(3) {
    grid-column: 1 / 2;
    font-size: 0.85rem;
    color: var(--color-text-muted);
  }
  .leg-row span:nth-child(4) {
    grid-column: 2 / 3;
    justify-self: flex-end;
    text-align: right;
    font-weight: 600;
  }
}

/* Exchange Limits Section */
.limits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.limits-header h3 {
  margin: 0;
}
.limits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}
.limit-card {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 0.85rem;
  padding: 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  transition: border-color 0.2s ease;
}
.limit-card:hover {
  border-color: rgba(148, 163, 184, 0.3);
}
.limit-card--unavailable {
  opacity: 0.55;
}
.limit-card__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.limit-card__logo {
  width: 22px;
  height: 22px;
  border-radius: 0.4rem;
  object-fit: contain;
  background: rgba(15, 23, 42, 0.8);
}
.limit-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-strong);
}
.limit-card__metrics {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.limit-card__metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.limit-card__metric-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.limit-card__metric-value {
  color: var(--color-text-primary);
  font-weight: 500;
}
.limit-card__metric-value.positive {
  color: var(--color-positive-text);
}
.limit-card__metric-value.highlight {
  color: var(--color-accent-start);
  font-weight: 600;
}
.limit-card__error {
  font-size: 0.8rem;
  color: var(--color-danger);
  line-height: 1.4;
}
@media (max-width: 640px) {
  .limits-grid {
    grid-template-columns: 1fr;
  }
  .limits-header {
    flex-wrap: wrap;
  }
}
