:root {
  color-scheme: dark;
  --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: "Segoe UI", "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 14px;
}

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

#app {
  max-width: 960px;
  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-size: 24px;
  line-height: 1.1;
}

.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);
  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-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tab-floating-metrics {
  position: sticky;
  top: 10px;
  z-index: 12;
  margin-bottom: 10px;
  display: none;
  pointer-events: none;
}

.tab-floating-metrics.visible {
  display: block;
}

.floating-summary-grid {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.floating-summary-chip {
  min-width: 88px;
  max-width: calc(50% - 6px);
  padding: 8px 11px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.36);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.floating-summary-chip.right {
  margin-left: auto;
  text-align: right;
}

.floating-summary-value {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.chain-metric-card {
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.chain-metric-value {
  margin-top: 6px;
  font-size: 18px;
  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: 8px;
}

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

.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: 12px;
}

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

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

.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;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04243a;
}

.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: 8px 6px;
  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);
}

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

.chain-table-shell {
  overflow: auto;
  padding: 8px;
}

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

.chain-side-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid var(--line);
}

.chain-side-head .calls,
.chain-side-head .puts,
.chain-side-head .mid {
  font-size: 15px;
  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: 6px;
}

.chain-table-head {
  padding: 0 6px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chain-grid-row {
  min-height: 62px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid transparent;
}

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

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

.chain-oi-cell,
.chain-ltp-cell,
.chain-strike-cell {
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.6);
}

.chain-buy-btn {
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  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: 6px 6px;
  font-variant-numeric: tabular-nums;
}

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

.chain-oi-cell .metric-sub,
.chain-ltp-cell .metric-sub,
.chain-strike-cell .metric-sub {
  margin-top: 2px;
  font-size: 10px;
  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: relative container, Exit pinned to bottom-right */
.pos-card-wrap {
  position: relative;
  padding-bottom: 28px !important;
}

.pos-exit-btn {
  position: absolute;
  bottom: 6px;
  right: 8px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 5px;
  background: rgba(185, 28, 28, 0.22);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.3);
  cursor: pointer;
  line-height: 1.4;
}
.pos-exit-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-btns {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.sl-delta-btn {
  flex: 0 0 auto;
  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-custom-row {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  align-items: center;
}
.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;
}

.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);
}

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

.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;
}

.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: 220;
  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;
}

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

.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 .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;
}

.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: 680px) {
  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .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: 4px;
    padding: 5px;
  }

  .tab-btn {
    font-size: 10px;
    padding: 8px 4px;
  }

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

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

  .split-divider {
    display: none;
  }

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

  .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%;
  }
}

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