:root {
  color-scheme: dark;
  --heading-font: "Space Grotesk", "Segoe UI", "SF Pro Text", sans-serif;
  --body-font: "Manrope", "Segoe UI", "SF Pro Text", "Helvetica Neue", sans-serif;
  --bg: #09101f;
  --panel: rgba(15, 23, 42, 0.92);
  --panel-2: rgba(15, 23, 42, 0.78);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.32);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #14b8a6;
  --good: #22c55e;
  --bad: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 12px 30px rgba(2, 8, 23, 0.35);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.12), transparent 30%),
    linear-gradient(180deg, #0b1220 0%, #0a1324 46%, #07101f 100%);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 14px;
  line-height: 1.45;
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

#app {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 14px 12px 168px;
}

.topbar,
.status-strip,
.hero-panel,
.tabs,
.content,
.stack,
.stats-grid,
.form-grid,
.chain-meta,
.chain-layout {
  display: grid;
  gap: 12px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  min-width: 0;
}

.topbar h1,
.card-head h2,
.login-card h2 {
  margin: 0;
}

.topbar h1 {
  font-family: var(--heading-font);
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.card-head h2,
.login-card h2 {
  font-family: var(--heading-font);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.status-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.status-orbit {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  justify-items: stretch;
  gap: 8px;
}

.badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.orbit-badge {
  min-height: 34px;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orbit-badge.aws {
  grid-column: 1;
}

.orbit-badge.feed {
  grid-column: 2;
}

.orbit-badge.orders {
  grid-column: 4;
}

.orbit-badge.snapshot {
  grid-column: 5;
}

.refresh-center {
  grid-column: 3;
  min-width: 72px;
  min-height: 72px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.24), rgba(20, 184, 166, 0.24));
  border-color: rgba(56, 189, 248, 0.4);
  color: #dbeafe;
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.34);
}

.logout-stack-btn {
  display: grid;
  justify-items: center;
  gap: 3px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--text);
}

.logout-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.76);
  color: #fecaca;
  font-weight: 800;
}

.logout-label {
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
}

.badge.good {
  color: #bef264;
  border-color: rgba(34, 197, 94, 0.32);
}

.badge.bad {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.32);
}

.badge.warn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.32);
}

.hero-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.hero-card,
.card,
.chain-row,
.chain-table-shell,
.position-card,
.order-card,
.history-card,
.stat-card,
.settings-card,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 13px;
}

.hero-card .label {
  font-size: 11px;
  color: var(--muted);
}

.hero-card .value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
}

.hero-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hide-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  color: var(--muted);
  opacity: 0.7;
  line-height: 1;
}

.hide-toggle-btn:hover {
  opacity: 1;
}

.hide-toggle-btn.hidden-state {
  opacity: 0.35;
}

.hero-split-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.split-cell {
  min-width: 0;
}

.split-divider {
  width: 1px;
  height: 36px;
  background: var(--line);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 230;
}

.content {
  margin-top: 16px;
  touch-action: pan-y;
  position: relative;
  overflow: hidden;
}

#app:not(.dashboard-view) .topbar,
#app:not(.dashboard-view) .status-strip,
#app:not(.dashboard-view) .hero-panel {
  display: none;
}

#app:not(.dashboard-view) .content {
  margin-top: 8px;
}

.tab-panel {
  display: none;
  will-change: transform;
}

.tab-panel.active {
  display: block;
}

.tab-panel.slide-exit {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 0;
}

.tab-panel.slide-enter {
  display: block;
  z-index: 1;
}

.tab-panel.slide-exit.to-left {
  animation: slideOutLeft 220ms ease-out forwards;
}

.tab-panel.slide-exit.to-right {
  animation: slideOutRight 220ms ease-out forwards;
}

.tab-panel.slide-enter.from-right {
  animation: slideInFromRight 220ms ease-out forwards;
}

.tab-panel.slide-enter.from-left {
  animation: slideInFromLeft 220ms ease-out forwards;
}

@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

@keyframes slideOutRight {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

@keyframes slideInFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes slideInFromLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.card,
.login-card {
  padding: 14px;
}

.card + .card {
  margin-top: 14px;
}

.chain-layout {
  align-items: start;
}

.chain-top-metrics {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.chain-live-position-panel {
  display: none;
}

.chain-closed-orders-panel {
  display: none;
}

.chain-closed-orders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chain-closed-orders-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.chain-closed-orders-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.chain-live-position-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chain-live-position-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.chain-live-position-list {
  display: grid;
  gap: 8px;
}

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

.global-corner-widgets {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px;
  right: 12px;
  display: none;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 12px;
  z-index: 260;
  pointer-events: none;
}

.global-corner-widgets.visible {
  display: grid;
}

.corner-widget-slot {
  min-width: 0;
  display: flex;
  pointer-events: none;
}

.corner-widget-slot.left {
  justify-content: flex-start;
}

.corner-widget-slot.right {
  justify-content: flex-end;
}

.corner-widget {
  min-width: 108px;
  max-width: min(180px, calc(50vw - 24px));
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--widget-bg, rgba(15, 23, 42, 0.34));
  border: 1px solid var(--widget-border, rgba(148, 163, 184, 0.22));
  box-shadow: var(--widget-shadow, 0 12px 28px rgba(2, 8, 23, 0.2));
  backdrop-filter: blur(var(--widget-blur, 8px));
  -webkit-backdrop-filter: blur(var(--widget-blur, 8px));
  transform: scale(var(--widget-scale, 1));
  will-change: transform;
}

.corner-widget.left {
  transform-origin: top left;
  justify-self: start;
  text-align: left;
}

.corner-widget.right {
  transform-origin: top right;
  justify-self: end;
  text-align: right;
}

.corner-widget.preview {
  border-style: dashed;
}

.corner-widget-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.88);
}

.corner-widget-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.floating-index-chart {
  position: fixed;
  inset: 0;
  z-index: 255;
  pointer-events: none;
}

.floating-index-chart.visible {
  display: block;
}

.floating-index-chart-shell {
  width: var(--index-chart-width, 360px);
  height: var(--index-chart-height, 240px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-radius: 20px;
  background: var(--index-chart-bg, rgba(15, 23, 42, 0.26));
  border: 1px solid var(--index-chart-border, rgba(148, 163, 184, 0.24));
  box-shadow: var(--index-chart-shadow, 0 18px 36px rgba(2, 8, 23, 0.22));
  overflow: hidden;
  position: fixed;
  pointer-events: auto;
  overscroll-behavior: contain;
  touch-action: none;
}

.floating-index-chart-shell.compact {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 6px;
}

.floating-index-chart-shell.compact .floating-index-chart-title-wrap,
.floating-index-chart-shell.compact .floating-index-chart-picker,
.floating-index-chart-shell.compact .floating-index-chart-status,
.floating-index-chart-shell.compact .floating-index-chart-attribution,
.floating-index-chart-shell.compact #floatingIndexChartRefreshBtn {
  display: none;
}

.floating-index-chart-shell.compact .floating-index-chart-head {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  gap: 0;
  pointer-events: none;
}

.floating-index-chart-shell.compact .floating-index-chart-actions {
  pointer-events: auto;
}

.floating-index-chart-shell.compact .floating-index-chart-btn.close {
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
}

.floating-index-chart-shell.compact .floating-index-chart-viewport {
  border-radius: 12px;
}

.floating-index-chart-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.floating-index-chart-title-wrap {
  min-width: 0;
}

.floating-index-chart-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(125, 211, 252, 0.88);
}

.floating-index-chart-title {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-index-chart-picker {
  min-width: 118px;
  gap: 4px;
  font-size: 10px;
  color: rgba(226, 232, 240, 0.72);
  cursor: default;
  touch-action: auto;
  user-select: auto;
}

.floating-index-chart-picker span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.floating-index-chart-picker select {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  pointer-events: auto;
  touch-action: auto;
}

.floating-index-chart-actions,
.floating-index-chart-btn {
  cursor: default;
}

.floating-index-chart-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  touch-action: auto;
  user-select: auto;
}

.floating-index-chart-btn {
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.76);
  color: var(--text);
}

.floating-index-chart-btn.close {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.24);
}

.floating-index-chart-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.floating-index-chart-status {
  min-height: 16px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(226, 232, 240, 0.72);
}

.floating-index-chart-shell.error .floating-index-chart-status {
  color: #fca5a5;
}

.floating-index-chart-viewport {
  min-height: 0;
  position: relative;
  border-radius: 14px;
  background: rgba(2, 8, 23, 0.22);
  border: 1px solid rgba(148, 163, 184, 0.12);
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}

.floating-index-chart-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.floating-index-chart-canvas,
.floating-index-chart-canvas * {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.floating-index-chart-move-handle {
  position: absolute;
  top: 12px;
  right: 92px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.76));
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.28);
  cursor: move;
  touch-action: none;
  z-index: 4;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.floating-index-chart-move-handle:hover,
.floating-index-chart-move-handle:focus-visible {
  border-color: rgba(125, 211, 252, 0.4);
  background: linear-gradient(180deg, rgba(22, 32, 56, 0.96), rgba(15, 23, 42, 0.82));
  transform: translateY(-1px);
  outline: none;
}

.floating-index-chart-move-dots {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  gap: 4px 5px;
}

.floating-index-chart-move-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(186, 230, 253, 0.88);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.08);
}

.floating-index-chart-resize-handle {
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  border-radius: 8px 0 10px 0;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(125, 211, 252, 0.85) 46% 54%, transparent 55% 100%),
    linear-gradient(135deg, transparent 0 62%, rgba(125, 211, 252, 0.6) 63% 71%, transparent 72% 100%);
  opacity: 0.8;
  cursor: nwse-resize;
  touch-action: none;
}

.floating-index-chart-attribution {
  justify-self: start;
  font-size: 10px;
  color: rgba(226, 232, 240, 0.68);
  text-decoration: none;
}

.floating-index-chart-attribution:hover {
  color: rgba(226, 232, 240, 0.9);
}

.chain-metric-card {
  padding: 10px 11px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.8)),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.1), transparent 42%);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.28);
}

.chain-metric-label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chain-metric-value {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 800;
}

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.balance-toggle-btn {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11px;
}

.chain-controls-card {
  display: grid;
  gap: 7px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.86)),
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.08), transparent 38%);
}

.chain-actions-row {
  grid-template-columns: 0.92fr 1.08fr;
}

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

.section-label {
  margin-top: 2px;
  color: #7dd3fc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chain-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}

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

.dashboard-note-card .muted {
  margin: 0;
}

.dashboard-workspace {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

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

.dashboard-card-head {
  margin-bottom: 10px;
}

.dashboard-chip-row,
.dashboard-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-action-row {
  margin-top: 12px;
}

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

.dashboard-mini-card {
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.52);
}

.dashboard-mini-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dashboard-mini-value {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}

.dashboard-mini-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

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

.muted,
.micro,
.chain-meta,
.meta-row {
  color: var(--muted);
}

.micro {
  font-size: 12px;
}

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

.stat-card,
.settings-card {
  padding: 14px;
}

.stat-card .title,
.settings-card .title {
  font-size: 12px;
  color: var(--muted);
}

.stat-card .value,
.settings-card .value {
  margin-top: 8px;
  font-weight: 700;
}

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

.form-grid.compact label {
  gap: 6px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.76);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04243a;
  box-shadow: 0 8px 18px rgba(20, 184, 166, 0.2);
}

.ghost-btn,
.tab-btn {
  background: rgba(15, 23, 42, 0.76);
  color: var(--text);
  border: 1px solid var(--line);
}

.tab-btn {
  width: 100%;
  min-width: 0;
  padding: 10px 7px;
  border-radius: 10px;
  white-space: nowrap;
  font-size: 11px;
  text-align: center;
}

.danger-btn {
  background: rgba(127, 29, 29, 0.9);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.small-btn {
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.x-btn {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
}

.buy-btn {
  background: rgba(22, 163, 74, 0.18);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.32);
}

.sell-btn,
.danger-ghost {
  background: rgba(185, 28, 28, 0.18);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.24);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(20, 184, 166, 0.18));
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.18);
}

button:hover:not(.pos-sl-btn):not(.pos-exit-btn):not(.pos-sl-cancel-btn):not(.floating-exit-btn) {
  transform: translateY(-1px);
}

button:active:not(.pos-sl-btn):not(.pos-exit-btn):not(.pos-sl-cancel-btn):not(.floating-exit-btn) {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.52);
  outline-offset: 2px;
}

.chain-list,
.stack {
  display: grid;
  gap: 12px;
}

.chain-table-shell {
  overflow: auto;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(8, 15, 30, 0.92)),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 34%);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.28);
}

.chain-table {
  width: 100%;
  min-width: 0;
}

.chain-table-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chain-ribbon-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.68);
  color: #dbeafe;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chain-ribbon-pill.accent {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(14, 116, 144, 0.2);
  color: #7dd3fc;
}

.chain-ribbon-pill.subtle {
  color: var(--muted);
}

.chain-side-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 9px 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.chain-side-head .calls,
.chain-side-head .puts,
.chain-side-head .mid {
  font-size: 14px;
  font-weight: 800;
}

.chain-side-head .calls {
  color: #fbbf24;
  text-align: left;
}

.chain-side-head .mid {
  color: #e2e8f0;
  text-align: center;
}

.chain-side-head .puts {
  color: #c4b5fd;
  text-align: right;
}

.chain-table-head,
.chain-grid-row {
  display: grid;
  grid-template-columns: 0.88fr 0.96fr 0.98fr 0.96fr 0.88fr;
  align-items: center;
  gap: 5px;
}

.chain-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 6px;
  padding: 6px 6px 7px;
  border-radius: 12px;
  background: rgba(7, 12, 24, 0.92);
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chain-grid-row {
  min-height: 56px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.06);
}

.chain-grid-row + .chain-grid-row {
  margin-top: 4px;
}

.chain-grid-row.atm {
  background: linear-gradient(90deg, rgba(29, 78, 216, 0.24), rgba(30, 41, 59, 0.2));
  border-color: rgba(96, 165, 250, 0.3);
}

.chain-grid-row:hover {
  background: rgba(15, 23, 42, 0.58);
}

.chain-oi-cell,
.chain-ltp-cell,
.chain-strike-cell {
  min-height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.74);
}

.chain-buy-btn {
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.chain-buy-btn.ce {
  background: rgba(22, 163, 74, 0.16);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.26);
}

.chain-buy-btn.pe {
  background: rgba(220, 38, 38, 0.14);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.24);
}

.chain-oi-cell.empty,
.chain-ltp-cell.empty {
  opacity: 0.45;
}

.chain-oi-cell,
.chain-ltp-cell,
.chain-strike-cell {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 5px 5px;
  font-variant-numeric: tabular-nums;
}

.chain-oi-cell .metric-main,
.chain-ltp-cell .metric-main,
.chain-strike-cell .metric-main {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.05;
}

.chain-oi-cell .metric-sub,
.chain-ltp-cell .metric-sub,
.chain-strike-cell .metric-sub {
  margin-top: 1px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  text-align: center;
}

.chain-ltp-cell.ce {
  color: #86efac;
}

.chain-ltp-cell.pe {
  color: #fda4af;
}

.chain-oi-cell.ce {
  color: #bbf7d0;
}

.chain-oi-cell.pe {
  color: #ddd6fe;
}

.chain-strike-cell {
  background: rgba(30, 41, 59, 0.82);
  border-color: var(--line-strong);
  color: #e2e8f0;
}

.chain-grid-row.atm .chain-strike-cell {
  background: rgba(29, 78, 216, 0.36);
  color: #dbeafe;
  border-color: rgba(96, 165, 250, 0.34);
}

.chain-row,
.position-card,
.order-card,
.history-card {
  padding: 12px;
}

.chain-row {
  display: grid;
  gap: 12px;
}

.chain-row-head,
.position-head,
.order-head,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.leg-card {
  background: rgba(15, 23, 42, 0.54);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.leg-card .side {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.leg-card .symbol,
.symbol {
  font-weight: 700;
  font-size: 13px;
}

.leg-card .ltp,
.price {
  font-size: 18px;
  font-weight: 700;
}

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

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

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

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.compact-action-row {
  margin-top: 6px;
}

.compact-meta {
  gap: 6px 10px;
}

.compact-stack {
  gap: 6px;
}

.minimal-card {
  padding: 8px 10px;
  border-radius: 10px;
}

.minimal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.minimal-main {
  font-size: 13px;
  font-weight: 700;
}

.minimal-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.minimal-metrics {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 10px;
}

.pos-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* Position card action row */
.pos-card-wrap {
  position: relative;
}

.position-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.position-sl-control {
  flex: 1 1 108px;
  min-width: 96px;
}

.position-sl-input {
  width: 100%;
  min-width: 0;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text);
  text-align: center;
}

.position-sl-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.48);
}

.pos-sl-btn,
.pos-exit-btn {
  flex: 0 0 auto;
  width: 72px;
  min-width: 64px;
  min-height: 28px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  transition: none;
}

.pos-sl-cancel-btn {
  flex: 0 0 auto;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(248, 113, 113, 0.34);
  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: none;
}

.pos-sl-btn {
  background: rgba(37, 99, 235, 0.18);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.pos-sl-btn.pos-sl-btn-active {
  background: rgba(15, 23, 42, 0.68);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.26);
  cursor: default;
}

.pos-exit-btn {
  background: rgba(185, 28, 28, 0.22);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.pos-sl-btn:hover,
.pos-sl-btn:active,
.pos-sl-btn:focus-visible,
.pos-exit-btn:hover,
.pos-exit-btn:active,
.pos-exit-btn:focus-visible,
.pos-sl-cancel-btn:hover,
.pos-sl-cancel-btn:active,
.pos-sl-cancel-btn:focus-visible {
  transform: none !important;
}

.pos-sl-btn:active,
.pos-exit-btn:active,
.pos-sl-cancel-btn:active { opacity: 0.7; }

/* Order card: X tab pinned to right border center */
.order-card-wrap {
  position: relative;
  padding-right: 42px !important;
}

.order-cancel-tab {
  position: absolute;
  top: 0;
  right: 0;
  width: 38px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(185, 28, 28, 0.2);
  border: none;
  border-left: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 0 10px 10px 0;
  color: #fca5a5;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
}
.order-cancel-tab:active { opacity: 0.7; }

/* --- Global SL adjust panel --- */
.sl-adjust-panel {
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.sl-adjust-label {
  font-size: 10px;
  font-weight: 700;
  color: #fcd34d;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.sl-adjust-meta {
  margin-top: -2px;
  margin-bottom: 6px;
  font-size: 10px;
  color: #fde68a;
  font-weight: 600;
}
.sl-adjust-btns {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  align-items: stretch;
}
.sl-adjust-secondary-row {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 6px;
}
.sl-delta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 5px 4px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
  cursor: pointer;
  text-align: center;
}
.sl-delta-btn:active { opacity: 0.6; }
.sl-delta-btn.neg {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}
.sl-live-btn {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
}
.sl-live-btn span {
  display: inline-block;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sl-adjust-secondary-row .sl-live-btn {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: space-between;
  gap: 8px;
}
.sl-exit-all-btn {
  flex: 0 0 auto;
  min-width: 82px;
  border-color: rgba(248, 113, 113, 0.36);
  background: rgba(127, 29, 29, 0.24);
  color: #fecaca;
}
.sl-custom-row {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  align-items: center;
}
.sl-inline-step-btn {
  min-width: 32px;
  padding-inline: 0;
}
.sl-custom-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  text-align: center;
}
.sl-custom-input:focus { outline: none; border-color: rgba(245,158,11,0.5); }
.sl-apply-btn {
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid rgba(245,158,11,0.4);
  background: rgba(245,158,11,0.18);
  color: #fcd34d;
  cursor: pointer;
}
.sl-apply-btn:active { opacity: 0.6; }

.position-summary-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(34, 197, 94, 0.18);
  background:
    radial-gradient(circle at 80% 20%, rgba(34, 197, 94, 0.12), transparent 30%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.86));
}

.position-summary-label {
  color: var(--muted);
  font-size: 12px;
}

.position-summary-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
}

.position-summary-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.position-section + .position-section {
  margin-top: 14px;
}

.chain-live-position-list .sl-adjust-panel {
  margin-bottom: 0;
}

.orders-section + .orders-section {
  margin-top: 16px;
}

/* BUY / SELL side coloring */
.side-buy  { border-left: 3px solid rgba(34, 197, 94, 0.7) !important; }
.side-sell { border-left: 3px solid rgba(239, 68, 68, 0.7) !important; }
.side-label.side-buy  { color: #86efac; font-weight: 700; }
.side-label.side-sell { color: #fca5a5; font-weight: 700; }

/* Settings toggle rows */
.settings-section-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.confirm-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  gap: 8px;
}
.confirm-toggle-row:last-child { border-bottom: none; }
.confirm-toggle-label {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}
.confirm-toggle-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.confirm-toggle-state {
  font-size: 11px;
  color: var(--muted);
  min-width: 20px;
  text-align: right;
}
.confirm-toggle-input {
  width: 36px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
}

.settings-slider-shell {
  margin-top: 12px;
}

.settings-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-slider-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}

.settings-slider-value {
  font-size: 12px;
  color: var(--muted);
}

.settings-slider-input {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--accent);
}

.settings-slider-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.paper-engine-note {
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.paper-engine-toolbar,
.paper-engine-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.paper-engine-headline {
  margin-top: 12px;
}

.paper-engine-inline {
  font-size: 12px;
  color: var(--muted);
}

.paper-engine-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.65);
}

.paper-engine-pill.good {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(22, 163, 74, 0.16);
}

.paper-engine-pill.warn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.12);
}

.paper-engine-pill.bad {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(220, 38, 38, 0.14);
}

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

.paper-engine-metric {
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.46);
}

.paper-engine-form {
  margin-top: 12px;
}

.paper-engine-config-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
}

.paper-engine-groups-col,
.paper-engine-preview-col {
  display: grid;
  gap: 10px;
}

.paper-engine-group {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(8, 18, 38, 0.45);
  overflow: hidden;
}

.paper-engine-group > summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #dbeafe;
  list-style: none;
}

.paper-engine-group > summary::-webkit-details-marker {
  display: none;
}

.paper-engine-group[open] > summary {
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.paper-engine-group .paper-engine-form {
  margin-top: 0;
  padding: 10px;
}

.paper-field-hint {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
}

.paper-field-error {
  display: none;
  margin-top: 4px;
  font-size: 11px;
  color: #fecaca;
}

.paper-field-error.visible {
  display: block;
}

.paper-engine-form input.input-invalid,
.paper-engine-form select.input-invalid {
  border-color: rgba(248, 113, 113, 0.75) !important;
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.35);
}

.paper-engine-preview-card {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: rgba(8, 47, 73, 0.28);
}

.paper-engine-preview-item {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.paper-engine-validation-summary {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 12px;
}

.paper-engine-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
}

.paper-engine-diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.paper-engine-diff-table th,
.paper-engine-diff-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  text-align: left;
}

.paper-engine-diff-table th {
  color: #bae6fd;
}

.paper-engine-json-toolbar {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.paper-engine-preset-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.paper-engine-preset-row .small-btn {
  width: 100%;
  justify-content: center;
}

.paper-engine-json-toolbar .small-btn {
  width: 100%;
  justify-content: center;
}

.paper-engine-subsection {
  margin-top: 14px;
}

.paper-engine-trade-card,
.paper-engine-empty,
.paper-engine-log-row,
.paper-engine-error {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.46);
}

.paper-engine-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.24);
  background: rgba(127, 29, 29, 0.32);
}

.paper-engine-trade-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.paper-engine-trade-symbol {
  font-size: 14px;
  font-weight: 800;
}

.paper-engine-trade-side {
  font-size: 11px;
  color: var(--muted);
}

.paper-engine-log-row + .paper-engine-log-row {
  margin-top: 8px;
}

.paper-engine-log-main {
  font-size: 13px;
  font-weight: 700;
}

.paper-engine-log-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .paper-engine-config-layout {
    grid-template-columns: 1fr;
  }

  .paper-engine-preset-row,
  .paper-engine-json-toolbar {
    grid-template-columns: 1fr;
  }
}

.orders-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-heading {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.section-kicker {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.head-chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.orders-section-head h3 {
  margin: 0;
  font-size: 16px;
}

.position-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.position-section-head h3 {
  margin: 0;
  font-size: 16px;
}

.positions-shell,
.orders-shell {
  display: grid;
  gap: 12px;
}

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

.positions-scroll-shell,
.orders-scroll-shell {
  min-height: 0;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.44);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.positions-scroll-shell.empty,
.orders-scroll-shell.empty {
  overflow: visible;
}

.position-title-block,
.position-pnl-block {
  min-width: 0;
}

.position-pnl-block {
  text-align: right;
  flex-shrink: 0;
}

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

.position-metrics-grid span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.pnl-chip {
  border-color: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.position-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.side-chip,
.mode-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
}

.side-chip.buy {
  background: rgba(34, 197, 94, 0.18);
  color: #bbf7d0;
}

.side-chip.sell {
  background: rgba(248, 113, 113, 0.16);
  color: #fecaca;
}

.side-chip.flat {
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
}

.mode-chip {
  background: rgba(20, 184, 166, 0.12);
  color: #99f6e4;
  border: 1px solid rgba(20, 184, 166, 0.22);
}

.status-chip {
  background: rgba(15, 23, 42, 0.7);
  color: var(--muted);
  border: 1px solid var(--line);
}

.subtle-status {
  color: var(--muted);
}

.floating-exit-btn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 390;
  min-width: 112px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.96), rgba(127, 29, 29, 0.96));
  color: #fee2e2;
  border: 1px solid rgba(248, 113, 113, 0.25);
  box-shadow: 0 18px 36px rgba(2, 8, 23, 0.42);
  pointer-events: auto;
  will-change: transform;
}

.floating-exit-btn.disabled {
  opacity: 0.42;
}

.floating-exit-btn.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sl-editor {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.sl-editor input {
  flex: 1;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.95);
  backdrop-filter: blur(12px);
  z-index: 500;
}

.overlay.visible {
  display: grid;
}

.reconnect-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(10px);
  z-index: 340;
}

.reconnect-overlay.visible {
  display: flex;
}

.reconnect-overlay.danger .reconnect-card {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 22px 52px rgba(127, 29, 29, 0.28);
}

.reconnect-overlay.danger .reconnect-card p,
.reconnect-overlay.danger .reconnect-meta {
  color: #fecaca;
}

.reconnect-overlay.danger .reconnect-spinner {
  border-top-color: var(--bad);
}

.reconnect-card {
  width: min(100%, 380px);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px 20px;
  text-align: center;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 22px 52px rgba(2, 8, 23, 0.42);
}

.reconnect-card h2 {
  margin: 0;
  font-size: 20px;
}

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

.reconnect-meta {
  font-size: 12px;
  color: #cbd5e1;
}

.reconnect-action-btn {
  margin-top: 6px;
}

.reconnect-spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.18);
  border-top-color: var(--accent);
  animation: reconnect-spin 900ms linear infinite;
}

@keyframes reconnect-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

body.logged-out .tabs,
body.logged-out .floating-exit-btn,
body.logged-out .global-corner-widgets,
body.logged-out .floating-index-chart,
body.logged-out .topbar,
body.logged-out .status-strip,
body.logged-out .hero-panel,
body.logged-out .content {
  display: none !important;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
}

.login-copy,
.login-note {
  margin: 0;
  line-height: 1.5;
}

.login-copy {
  color: rgba(226, 232, 240, 0.92);
}

.login-note {
  color: var(--muted);
  font-size: 12px;
}

.login-loading {
  display: none;
  justify-items: center;
  gap: 10px;
  padding: 10px 0 2px;
  text-align: center;
}

.login-loading p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.5;
}

.login-card.loading .login-loading {
  display: grid;
}

.login-card.loading label,
.login-card.loading .login-copy,
.login-card.loading .login-note {
  opacity: 0.5;
}

.form-error {
  min-height: 18px;
  color: #fecaca;
  font-size: 12px;
}

.toast-container {
  position: fixed;
  right: 14px;
  bottom: calc(148px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  z-index: 260;
}

/* ---- In-app confirm modal ---- */
.confirm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 24px;
}
.confirm-modal-backdrop[hidden] { display: none; }
.confirm-modal-box {
  background: #0f1e35;
  border: 1px solid rgba(148,163,184,0.22);
  border-radius: 16px;
  padding: 24px 20px 18px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.confirm-modal-msg {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 20px;
  text-align: center;
}
.confirm-modal-btns {
  display: flex;
  gap: 10px;
}
.confirm-modal-btn {
  flex: 1;
  padding: 11px 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.confirm-cancel {
  background: rgba(148,163,184,0.12);
  color: var(--muted);
}
.confirm-cancel:active { opacity: 0.7; }
.confirm-ok {
  background: rgba(239,68,68,0.18);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.35);
}
.confirm-ok:active { opacity: 0.7; }

.toast {
  min-width: 240px;
  max-width: min(86vw, 360px);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.toast.good {
  border-color: rgba(34, 197, 94, 0.35);
}

.toast.bad {
  border-color: rgba(239, 68, 68, 0.35);
}

@media (max-width: 1099px) {
  .content {
    overflow-x: hidden;
    overflow-y: visible;
  }

  .positions-scroll-shell,
  .orders-scroll-shell {
    overflow: visible;
    overscroll-behavior: auto;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
  }

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

  .eyebrow {
    font-size: 11px;
    letter-spacing: 0.1em;
  }

  .status-orbit {
    gap: 6px;
  }

  .orbit-badge {
    min-height: 30px;
    font-size: 11px;
  }

  .refresh-center {
    min-width: 56px;
    min-height: 56px;
    font-size: 10px;
  }

  .logout-icon {
    width: 30px;
    height: 30px;
  }

  .tabs {
    left: 8px;
    right: 8px;
    gap: 5px;
    padding: 7px;
    border-radius: 18px;
    border-color: rgba(148, 163, 184, 0.28);
    box-shadow: 0 14px 32px rgba(2, 8, 23, 0.42);
  }

  .tab-btn {
    min-height: 42px;
    font-size: 11px;
    padding: 9px 6px;
    border-radius: 11px;
  }

  .status-strip,
  .hero-panel,
  .form-grid,
  .stats-grid,
  .chain-legs,
  .chain-top-grid {
    grid-template-columns: 1fr;
  }

  .hero-card .label,
  .section-kicker,
  .dashboard-mini-label {
    font-size: 11px;
  }

  .hero-card .value {
    font-size: 24px;
  }

  .position-summary-value {
    font-size: 30px;
  }

  .hero-split-card {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .split-divider {
    display: none;
  }

  #app {
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 182px;
  }

  .card,
  .hero-card,
  .login-card {
    border-radius: 16px;
  }

  .chain-table-shell {
    overflow-x: hidden;
    padding: 4px;
  }

  .chain-side-head {
    gap: 6px;
    margin-bottom: 8px;
    padding: 8px 10px;
  }

  .chain-side-head .calls,
  .chain-side-head .puts,
  .chain-side-head .mid {
    font-size: 13px;
  }

  .chain-table {
    width: 100%;
    min-width: 0;
  }

  .chain-table-head,
  .chain-grid-row {
    grid-template-columns: 0.8fr 0.92fr 0.92fr 0.92fr 0.8fr;
    gap: 4px;
  }

  .chain-table-head {
    padding: 0 2px 6px;
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  .chain-grid-row {
    min-height: 56px;
    padding: 4px;
    border-radius: 10px;
  }

  .chain-oi-cell,
  .chain-ltp-cell,
  .chain-strike-cell {
    min-height: 30px;
    border-radius: 8px;
    padding: 5px 4px;
  }

  .chain-oi-cell .metric-main,
  .chain-ltp-cell .metric-main,
  .chain-strike-cell .metric-main {
    font-size: 11px;
  }

  .chain-oi-cell .metric-sub,
  .chain-ltp-cell .metric-sub,
  .chain-strike-cell .metric-sub {
    font-size: 8px;
    margin-top: 1px;
  }

  .chain-buy-btn {
    min-height: 20px;
    padding: 0 6px;
    font-size: 9px;
  }

  .floating-exit-btn {
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(86px + env(safe-area-inset-bottom));
    min-width: 96px;
    padding: 10px 14px;
    font-size: 12px;
  }

  .toast-container {
    left: 10px;
    right: 10px;
    bottom: calc(140px + env(safe-area-inset-bottom));
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  .global-corner-widgets {
    top: calc(env(safe-area-inset-top) + 8px);
    left: 10px;
    right: 10px;
  }

  .corner-widget {
    min-width: 88px;
    max-width: calc(50vw - 18px);
    padding: 8px 10px;
    border-radius: 14px;
  }

  .corner-widget-label {
    font-size: 10px;
  }

  .corner-widget-value {
    font-size: 14px;
  }

  .floating-index-chart-shell {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 18px;
    padding: 10px;
  }

  .floating-index-chart-head {
    gap: 8px;
  }

  .floating-index-chart-title {
    font-size: 14px;
  }

  .floating-index-chart-status {
    font-size: 12px;
  }

  .floating-index-chart-move-handle {
    width: 38px;
    height: 38px;
    right: 96px;
  }

  .floating-index-chart-resize-handle {
    width: 24px;
    height: 24px;
  }

  .floating-index-chart-picker {
    min-width: 104px;
  }

  .floating-index-chart-picker select {
    padding: 6px 7px;
    font-size: 11px;
  }

  .floating-index-chart-btn {
    padding: 6px 8px;
    font-size: 10px;
  }
}

@media (max-width: 460px) {
  #app {
    padding-left: 8px;
    padding-right: 8px;
  }

  .status-strip {
    gap: 10px;
  }

  .tabs {
    left: 6px;
    right: 6px;
    gap: 4px;
    padding: 6px;
  }

  .tab-btn {
    min-height: 40px;
    font-size: 10px;
    letter-spacing: 0.01em;
  }
}

@media (min-width: 860px) {
  .chain-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
  }
}

@media (min-width: 1100px) {
  #app {
    width: min(1820px, 100%);
    padding: 14px 18px 28px;
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(420px, 0.88fr);
    grid-template-areas:
      "topbar status"
      "hero tabs"
      "content content";
    gap: 10px 16px;
  }

  .topbar {
    grid-area: topbar;
    gap: 12px;
    align-self: center;
  }

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

  .status-strip {
    grid-area: status;
    margin-top: 0;
  }

  .status-strip.status-orbit {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .orbit-badge {
    min-height: 40px;
    border-radius: 12px;
    font-size: 12px;
  }

  .refresh-center {
    min-width: 0;
    min-height: 40px;
    border-radius: 12px;
  }

  .hero-panel {
    grid-area: hero;
    margin-top: 0;
    grid-template-columns: 1.25fr 0.85fr 0.9fr;
    gap: 8px;
  }

  .hero-card {
    padding: 10px 12px;
  }

  .hero-card .value {
    margin-top: 4px;
    font-size: 20px;
  }

  .tabs {
    grid-area: tabs;
    position: sticky;
    left: auto;
    right: auto;
    bottom: auto;
    top: 14px;
    z-index: 180;
    width: 100%;
    margin-top: 0;
    margin-left: auto;
    margin-right: 0;
    padding: 4px;
    gap: 4px;
    backdrop-filter: blur(14px);
    align-self: start;
  }

  .tab-btn {
    padding: 9px 8px;
    font-size: 11px;
    border-radius: 11px;
  }

  .content {
    grid-area: content;
    margin-top: 4px;
    overflow: visible;
    min-height: 0;
  }

  #app:not(.dashboard-view) .topbar,
  #app:not(.dashboard-view) .status-strip,
  #app:not(.dashboard-view) .hero-panel {
    display: grid;
  }

  #app:not(.dashboard-view) .content {
    margin-top: 4px;
  }

  .tab-panel[data-panel="chain"],
  .tab-panel[data-panel="positions"],
  .tab-panel[data-panel="orders"] {
    min-height: calc(100vh - 220px);
  }

  .card,
  .login-card {
    padding: 12px 14px;
  }

  .dashboard-note-card {
    padding: 12px 14px;
  }

  .dashboard-note-card .card-head {
    margin-bottom: 8px;
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
    gap: 12px;
  }

  .dashboard-command-card {
    grid-column: 1 / -1;
  }

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

  .chain-layout {
    grid-template-columns: minmax(304px, 344px) minmax(0, 1fr) minmax(300px, 360px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "controls metrics closed"
      "controls table closed";
    min-height: calc(100vh - 220px);
    height: calc(100vh - 220px);
    gap: 10px 12px;
  }

  .chain-controls-card {
    grid-area: controls;
    align-self: start;
    position: sticky;
    top: 70px;
    gap: 6px;
    padding: 11px 12px;
  }

  .chain-top-metrics {
    grid-area: metrics;
    margin-bottom: 0;
    min-height: 0;
  }

  .chain-closed-orders-panel {
    grid-area: closed;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.78);
    box-shadow: var(--shadow);
    padding: 10px 12px;
    min-height: 0;
  }

  .chain-closed-orders-list {
    max-height: none;
    min-height: 0;
  }

  .chain-top-grid {
    grid-template-columns: 1.05fr 0.85fr 0.95fr;
    gap: 8px;
  }

  .chain-table-shell {
    grid-area: table;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 8px 9px;
    border-radius: 18px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .chain-side-head {
    margin-bottom: 6px;
    padding: 8px 12px;
  }

  .chain-table-head,
  .chain-grid-row {
    grid-template-columns: 0.92fr 1.08fr 1fr 1.08fr 0.92fr;
    gap: 6px;
  }

  .chain-table-head {
    padding: 6px 6px 7px;
    font-size: 9px;
  }

  .chain-grid-row {
    min-height: 54px;
    padding: 4px;
  }

  .chain-oi-cell,
  .chain-ltp-cell,
  .chain-strike-cell {
    min-height: 34px;
    padding: 5px 6px;
  }

  .chain-oi-cell .metric-main,
  .chain-ltp-cell .metric-main,
  .chain-strike-cell .metric-main {
    font-size: 11px;
  }

  .chain-buy-btn {
    min-height: 20px;
    padding: 0 7px;
    font-size: 9px;
  }

  .chain-ribbon-pill {
    min-height: 22px;
    padding: 0 9px;
    font-size: 9px;
  }

  .chain-status {
    font-size: 10px;
  }

  .section-label {
    font-size: 9px;
    letter-spacing: 0.14em;
  }

  .chain-controls-card .ghost-btn,
  .chain-controls-card input,
  .chain-controls-card select {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .chain-live-position-panel {
    display: grid;
    gap: 8px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .chain-live-position-list {
    max-height: calc(100vh - 520px);
    overflow: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
  }

  .chain-live-position-list .position-card {
    padding: 8px 9px;
  }

  .position-section .stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tab-panel[data-panel="positions"] > .card,
  .tab-panel[data-panel="orders"] > .card,
  .tab-panel[data-panel="settings"] > .card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .tab-panel[data-panel="positions"] > .card > .card-head,
  .tab-panel[data-panel="orders"] > .card > .card-head,
  .tab-panel[data-panel="settings"] > .card > .card-head {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.78);
    box-shadow: var(--shadow);
    position: sticky;
    top: 70px;
    z-index: 25;
  }

  .tab-panel[data-panel="positions"] > .card,
  .tab-panel[data-panel="orders"] > .card {
    min-height: calc(100vh - 220px);
    height: calc(100vh - 220px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  #positionsContainer,
  #ordersContainer {
    min-height: 0;
    align-items: start;
  }

  #positionsContainer.positions-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  #positionsContainer.positions-shell.has-closed {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }

  .position-section,
  .orders-section {
    min-height: 0;
    display: grid;
    gap: 8px;
    align-content: start;
  }

  .positions-scroll-shell,
  .orders-scroll-shell {
    max-height: calc(100vh - 320px);
  }

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

  .positions-grid.positions-grid-closed {
    grid-template-columns: minmax(0, 1fr);
  }

  .positions-grid .minimal-card,
  .orders-list .minimal-card {
    padding: 8px 9px;
  }

  .positions-grid .minimal-main,
  .orders-list .minimal-main {
    font-size: 12px;
  }

  .positions-grid .minimal-sub,
  .orders-list .minimal-sub,
  .positions-grid .minimal-metrics,
  .orders-list .minimal-metrics {
    font-size: 10px;
  }

  #ordersContainer {
    grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
  }

  .orders-section + .orders-section,
  .position-section + .position-section {
    margin-top: 0;
  }

  .orders-section .stack {
    gap: 8px;
  }

  #settingsContainer {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    align-items: start;
    gap: 10px;
  }

  .settings-card {
    height: 100%;
  }

  .orders-section,
  .position-section {
    align-self: start;
  }

  .floating-exit-btn {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 24px;
    min-width: 104px;
    padding: 10px 14px;
  }

  .toast-container {
    left: auto;
    right: 18px;
    bottom: 88px;
    width: min(380px, calc(100vw - 36px));
  }
}

@media (min-width: 1380px) {
  #app {
    width: min(1920px, 100%);
    gap: 10px 18px;
  }

  .chain-layout {
    grid-template-columns: minmax(320px, 364px) minmax(0, 1fr) minmax(320px, 390px);
    gap: 10px 14px;
  }

  .chain-table-shell {
    padding: 9px 10px;
  }

  .chain-side-head .calls,
  .chain-side-head .puts,
  .chain-side-head .mid {
    font-size: 13px;
  }

  .chain-table-head,
  .chain-grid-row {
    gap: 7px;
  }

  #settingsContainer {
    grid-template-columns: repeat(3, minmax(300px, 1fr));
  }

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

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(420px, 0.9fr);
  }

  .tabs {
    max-width: 900px;
  }
}
