:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-1: rgba(255, 255, 255, 0.94);
  --surface-2: rgba(255, 255, 255, 0.75);
  --surface-3: rgba(255, 255, 255, 0.72);
  --surface-soft: #fafaf9;
  --surface-soft-1: rgba(250, 250, 249, 0.95);
  --surface-soft-2: rgba(250, 250, 249, 0.9);
  --surface-soft-3: rgba(250, 250, 249, 0.7);
  --surface-cool: rgba(248, 250, 252, 0.75);
  --surface-cool-1: rgba(248, 250, 252, 0.9);
  --surface-warm: rgba(245, 245, 244, 0.95);
  --surface-warm-1: rgba(245, 245, 244, 0.9);
  --surface-hover: rgba(245, 245, 244, 0.65);
  --surface-active: rgba(37, 99, 235, 0.04);
  --surface-active-1: rgba(37, 99, 235, 0.06);
  --row-active: rgba(219, 234, 254, 0.5);
  --row-active-1: rgba(219, 234, 254, 0.45);
  --row-active-2: rgba(219, 234, 254, 0.42);
  --row-active-3: rgba(219, 234, 254, 0.55);
  --muted: #667085;
  --text: #101828;
  --border: #d9dee7;
  --border-soft: rgba(214, 211, 209, 0.7);
  --border-soft-1: rgba(214, 211, 209, 0.9);
  --border-cool: rgba(217, 222, 231, 0.95);
  --border-cool-1: rgba(217, 222, 231, 0.86);
  --border-cool-2: rgba(217, 222, 231, 0.8);
  --border-cool-3: rgba(217, 222, 231, 0.72);
  --border-row: rgba(231, 229, 228, 0.9);
  --border-row-1: rgba(231, 229, 228, 0.6);
  --soft: #f8fafc;
  --accent: #111827;
  --accent-on: #ffffff;
  --green: #15803d;
  --green-bg: rgba(220, 252, 231, 0.7);
  --green-bg-1: rgba(220, 252, 231, 0.65);
  --green-tint: rgba(21, 128, 61, 0.12);
  --red: #b91c1c;
  --red-bg: rgba(254, 226, 226, 0.75);
  --red-bg-1: rgba(254, 226, 226, 0.82);
  --red-bg-2: rgba(254, 226, 226, 0.7);
  --red-tint: rgba(185, 28, 28, 0.12);
  --amber: #b45309;
  --amber-bg: rgba(254, 243, 199, 0.8);
  --amber-bg-1: rgba(254, 243, 199, 0.72);
  --amber-tint: rgba(180, 83, 9, 0.1);
  --blue: #2563eb;
  --blue-bg: rgba(219, 234, 254, 0.8);
  --blue-bg-1: rgba(219, 234, 254, 0.75);
  --blue-bg-2: rgba(219, 234, 254, 0.72);
  --blue-bg-3: rgba(219, 234, 254, 0.42);
  --blue-bg-4: rgba(219, 234, 254, 0.55);
  --blue-tint: rgba(37, 99, 235, 0.1);
  --teal: #0f766e;
  --teal-tint: rgba(15, 118, 110, 0.1);
  --purple: #7c3aed;
  --chart-bg: #ffffff;
  --chart-bg-2: #fafaf9;
  --chart-grid: rgba(214, 211, 209, 0.4);
  --chart-grid-soft: rgba(214, 211, 209, 0.3);
  --chart-grid-strong: rgba(214, 211, 209, 0.7);
  --chart-text: #57534e;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.16);
  --shadow-xl: 0 28px 70px rgba(15, 23, 42, 0.24);
  --shadow-blue: 0 8px 18px rgba(15, 23, 42, 0.07);
  --shadow-tab: 0 7px 16px rgba(37, 99, 235, 0.26);
  --shadow-shell: 0 14px 32px rgba(15, 23, 42, 0.08);
  --shadow-button: 0 10px 18px rgba(15, 23, 42, 0.12);
  --backdrop: rgba(15, 23, 42, 0.18);
  --live-dot: #16a34a;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e16;
  --card: #121826;
  --surface: #161d2c;
  --surface-1: rgba(22, 29, 44, 0.94);
  --surface-2: rgba(22, 29, 44, 0.72);
  --surface-3: rgba(22, 29, 44, 0.68);
  --surface-soft: #0e1320;
  --surface-soft-1: rgba(14, 19, 32, 0.95);
  --surface-soft-2: rgba(14, 19, 32, 0.88);
  --surface-soft-3: rgba(14, 19, 32, 0.65);
  --surface-cool: rgba(18, 24, 40, 0.78);
  --surface-cool-1: rgba(18, 24, 40, 0.92);
  --surface-warm: rgba(20, 26, 42, 0.96);
  --surface-warm-1: rgba(20, 26, 42, 0.9);
  --surface-hover: rgba(255, 255, 255, 0.04);
  --surface-active: rgba(96, 165, 250, 0.06);
  --surface-active-1: rgba(96, 165, 250, 0.09);
  --row-active: rgba(96, 165, 250, 0.16);
  --row-active-1: rgba(96, 165, 250, 0.14);
  --row-active-2: rgba(96, 165, 250, 0.12);
  --row-active-3: rgba(96, 165, 250, 0.2);
  --muted: #8b95a7;
  --text: #e6edf3;
  --border: rgba(148, 163, 184, 0.16);
  --border-soft: rgba(148, 163, 184, 0.14);
  --border-soft-1: rgba(148, 163, 184, 0.22);
  --border-cool: rgba(148, 163, 184, 0.2);
  --border-cool-1: rgba(148, 163, 184, 0.18);
  --border-cool-2: rgba(148, 163, 184, 0.16);
  --border-cool-3: rgba(148, 163, 184, 0.14);
  --border-row: rgba(148, 163, 184, 0.12);
  --border-row-1: rgba(148, 163, 184, 0.08);
  --soft: #0e1320;
  --accent: #e6edf3;
  --accent-on: #0a0e16;
  --green: #4ade80;
  --green-bg: rgba(34, 197, 94, 0.16);
  --green-bg-1: rgba(34, 197, 94, 0.18);
  --green-tint: rgba(74, 222, 128, 0.14);
  --red: #f87171;
  --red-bg: rgba(239, 68, 68, 0.16);
  --red-bg-1: rgba(239, 68, 68, 0.2);
  --red-bg-2: rgba(239, 68, 68, 0.14);
  --red-tint: rgba(248, 113, 113, 0.16);
  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.16);
  --amber-bg-1: rgba(245, 158, 11, 0.18);
  --amber-tint: rgba(251, 191, 36, 0.16);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.18);
  --blue-bg-1: rgba(96, 165, 250, 0.2);
  --blue-bg-2: rgba(96, 165, 250, 0.16);
  --blue-bg-3: rgba(96, 165, 250, 0.12);
  --blue-bg-4: rgba(96, 165, 250, 0.22);
  --blue-tint: rgba(96, 165, 250, 0.18);
  --teal: #2dd4bf;
  --teal-tint: rgba(45, 212, 191, 0.16);
  --purple: #a78bfa;
  --chart-bg: #0e1320;
  --chart-bg-2: #0a0e16;
  --chart-grid: rgba(148, 163, 184, 0.08);
  --chart-grid-soft: rgba(148, 163, 184, 0.06);
  --chart-grid-strong: rgba(148, 163, 184, 0.18);
  --chart-text: #8b95a7;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 28px 70px rgba(0, 0, 0, 0.6);
  --shadow-blue: 0 8px 18px rgba(0, 0, 0, 0.4);
  --shadow-tab: 0 7px 16px rgba(37, 99, 235, 0.35);
  --shadow-shell: 0 14px 32px rgba(0, 0, 0, 0.45);
  --shadow-button: 0 10px 18px rgba(0, 0, 0, 0.4);
  --backdrop: rgba(0, 0, 0, 0.6);
  --live-dot: #4ade80;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #0a0e16;
    --card: #121826;
    --surface: #161d2c;
    --surface-1: rgba(22, 29, 44, 0.94);
    --surface-2: rgba(22, 29, 44, 0.72);
    --surface-3: rgba(22, 29, 44, 0.68);
    --surface-soft: #0e1320;
    --surface-soft-1: rgba(14, 19, 32, 0.95);
    --surface-soft-2: rgba(14, 19, 32, 0.88);
    --surface-soft-3: rgba(14, 19, 32, 0.65);
    --surface-cool: rgba(18, 24, 40, 0.78);
    --surface-cool-1: rgba(18, 24, 40, 0.92);
    --surface-warm: rgba(20, 26, 42, 0.96);
    --surface-warm-1: rgba(20, 26, 42, 0.9);
    --surface-hover: rgba(255, 255, 255, 0.04);
    --surface-active: rgba(96, 165, 250, 0.06);
    --surface-active-1: rgba(96, 165, 250, 0.09);
    --row-active: rgba(96, 165, 250, 0.16);
    --row-active-1: rgba(96, 165, 250, 0.14);
    --row-active-2: rgba(96, 165, 250, 0.12);
    --row-active-3: rgba(96, 165, 250, 0.2);
    --muted: #8b95a7;
    --text: #e6edf3;
    --border: rgba(148, 163, 184, 0.16);
    --border-soft: rgba(148, 163, 184, 0.14);
    --border-soft-1: rgba(148, 163, 184, 0.22);
    --border-cool: rgba(148, 163, 184, 0.2);
    --border-cool-1: rgba(148, 163, 184, 0.18);
    --border-cool-2: rgba(148, 163, 184, 0.16);
    --border-cool-3: rgba(148, 163, 184, 0.14);
    --border-row: rgba(148, 163, 184, 0.12);
    --border-row-1: rgba(148, 163, 184, 0.08);
    --soft: #0e1320;
    --accent: #e6edf3;
    --accent-on: #0a0e16;
    --green: #4ade80;
    --green-bg: rgba(34, 197, 94, 0.16);
    --green-bg-1: rgba(34, 197, 94, 0.18);
    --green-tint: rgba(74, 222, 128, 0.14);
    --red: #f87171;
    --red-bg: rgba(239, 68, 68, 0.16);
    --red-bg-1: rgba(239, 68, 68, 0.2);
    --red-bg-2: rgba(239, 68, 68, 0.14);
    --red-tint: rgba(248, 113, 113, 0.16);
    --amber: #fbbf24;
    --amber-bg: rgba(245, 158, 11, 0.16);
    --amber-bg-1: rgba(245, 158, 11, 0.18);
    --amber-tint: rgba(251, 191, 36, 0.16);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.18);
    --blue-bg-1: rgba(96, 165, 250, 0.2);
    --blue-bg-2: rgba(96, 165, 250, 0.16);
    --blue-bg-3: rgba(96, 165, 250, 0.12);
    --blue-bg-4: rgba(96, 165, 250, 0.22);
    --blue-tint: rgba(96, 165, 250, 0.18);
    --teal: #2dd4bf;
    --teal-tint: rgba(45, 212, 191, 0.16);
    --purple: #a78bfa;
    --chart-bg: #0e1320;
    --chart-bg-2: #0a0e16;
    --chart-grid: rgba(148, 163, 184, 0.08);
    --chart-grid-soft: rgba(148, 163, 184, 0.06);
    --chart-grid-strong: rgba(148, 163, 184, 0.18);
    --chart-text: #8b95a7;
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 28px 70px rgba(0, 0, 0, 0.6);
    --shadow-blue: 0 8px 18px rgba(0, 0, 0, 0.4);
    --shadow-tab: 0 7px 16px rgba(37, 99, 235, 0.35);
    --shadow-shell: 0 14px 32px rgba(0, 0, 0, 0.45);
    --shadow-button: 0 10px 18px rgba(0, 0, 0, 0.4);
    --backdrop: rgba(0, 0, 0, 0.6);
    --live-dot: #4ade80;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

html {
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: clip;
}

a {
  color: inherit;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  width: min(540px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-1);
  box-shadow: var(--shadow);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.page {
  max-width: 1920px;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  display: grid;
  gap: 18px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 18px;
  position: relative;
  z-index: 0;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 20px;
}

.hero-primary {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

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

.title-row h1,
.title-row h2,
.title-row h3,
.title-row p {
  margin: 0;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.chip-row,
.control-row,
.mini-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chip.good {
  color: var(--green);
  border-color: rgba(21, 128, 61, 0.2);
  background: var(--green-bg);
}

.chip.bad {
  color: var(--red);
  border-color: rgba(185, 28, 28, 0.2);
  background: var(--red-bg);
}

.chip.warn {
  color: var(--amber);
  border-color: rgba(180, 83, 9, 0.2);
  background: var(--amber-bg);
}

.chip.info {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.2);
  background: var(--blue-bg);
}

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

.hero-chart-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  display: grid;
  gap: 12px;
  flex: 1;
  min-height: 420px;
}

.chart-control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.chart-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chart-feed-field {
  min-width: 0;
}

.chart-control-actions {
  display: flex;
  justify-content: flex-end;
}

.hero-tradingview-anchor {
  display: block;
  width: 100%;
}

.hero-tradingview-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--chart-bg) 0%, var(--chart-bg-2) 100%);
  position: relative;
  z-index: 0;
  width: 100%;
  height: clamp(360px, 58vh, 520px);
  min-height: 360px;
  touch-action: pan-y;
}

.tradingview-widget-container {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
  min-height: 0;
}

.tradingview-widget-container__widget {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.tradingview-caption {
  padding: 10px 12px 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft-2);
}

/* ── Past Trade Detail ─────────────────────────── */

.trade-row {
  cursor: pointer;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .trade-row:hover {
    background: var(--surface-active);
  }
}

.trade-row.row-active {
  background: var(--surface-active-1);
}

.trade-closed-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}

.trade-expand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft-1);
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1;
}

.trade-detail-row td {
  padding: 0 !important;
  background: var(--surface-soft-1);
  border-bottom: 2px solid var(--border);
}

.trade-detail {
  padding: 16px 20px 20px;
  display: grid;
  gap: 14px;
}

.trade-detail-section {
  display: grid;
  gap: 8px;
}

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

.trade-detail-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.trade-detail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.trade-detail-time {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.trade-detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.trade-detail-stats > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-warm);
}

.trade-detail-stats > span > strong {
  color: var(--text);
}

.trade-detail-reasons {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.trade-detail-reasons div + div {
  margin-top: 3px;
}

.trade-reason-label {
  font-weight: 600;
  color: var(--text);
}

.trade-detail-timeframe {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.trade-tf-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.trade-tf-btn {
  padding: 4px 10px !important;
  font-size: 11px !important;
  min-height: 0 !important;
}

.trade-detail-chart {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.trade-detail-chart .chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.trade-detail-chart .legend {
  padding: 8px 14px 4px;
  background: var(--surface-soft-1);
}

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

.paper-settings-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

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

.field {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--soft);
  color: var(--text);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.field input:disabled,
.field select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.checkbox-field {
  align-content: center;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.metric {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--soft);
  padding: 14px 15px;
  min-width: 0;
}

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

.metric-value {
  margin-top: 8px;
  font-size: clamp(22px, 1.55vw, 28px);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: break-word;
}

.metric-detail {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.tone-good {
  color: var(--green);
}

.tone-bad {
  color: var(--red);
}

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

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--surface-soft-3);
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  position: relative;
  z-index: 2;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
}

.tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-blue);
}

.tab-panel {
  display: none;
  gap: 18px;
}

.tab-panel.active {
  display: grid;
  position: relative;
  z-index: 2;
}

.status-banner {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: var(--blue-bg-1);
  color: var(--blue);
}

.runtime-command-shell {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 0;
  border: 1px solid var(--border-cool);
  border-radius: 14px;
  background: var(--surface-1);
  box-shadow: var(--shadow-shell);
  backdrop-filter: blur(18px);
  overflow: visible;
}

.runtime-command-main {
  display: grid;
  grid-template-columns: auto auto auto minmax(240px, auto) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  min-width: 0;
}

.runtime-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.runtime-segment {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--soft);
}

.runtime-scope-button,
.section-nav-button,
.feed-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
}

.runtime-scope-button {
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 14px;
}

.runtime-scope-button.active {
  color: var(--accent-on);
  background: var(--blue);
  box-shadow: var(--shadow-tab);
}

.command-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

.bucket-command {
  position: relative;
  min-width: 0;
}

.bucket-command-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  white-space: nowrap;
}

.bucket-command-button span:first-child {
  font-weight: 700;
}

.bucket-command-button strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.runtime-status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.command-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.command-chip.good {
  color: var(--green);
  border-color: rgba(21, 128, 61, 0.18);
  background: var(--green-bg-1);
}

.command-chip.warn {
  color: var(--amber);
  border-color: rgba(180, 83, 9, 0.18);
  background: var(--amber-bg-1);
}

.command-chip.info {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.18);
  background: var(--blue-bg-2);
}

.command-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.command-action {
  border-radius: 8px;
  min-height: 40px;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  font-weight: 900;
}

.section-nav {
  display: flex;
  gap: 22px;
  padding: 0 16px;
  border-top: 1px solid var(--border-cool-2);
}

.section-nav-button {
  position: relative;
  padding: 14px 2px 13px;
  font-size: 14px;
}

.section-nav-button.active {
  color: var(--blue);
}

.section-nav-button.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 999px;
  background: var(--blue);
}

.runtime-command-meta {
  position: absolute;
  right: 16px;
  bottom: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--live-dot);
}

.bucket-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 12px);
  width: min(440px, calc(100vw - 48px));
  max-height: min(660px, calc(100vh - 160px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 12px;
}

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

.bucket-search-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bucket-search-shell input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  min-width: 0;
}

.bucket-popover-list,
.activation-bucket-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.bucket-selector-item,
.activation-bucket {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
}

.bucket-selector-item.active,
.activation-bucket.active {
  border-color: rgba(37, 99, 235, 0.5);
  background: var(--blue-bg-3);
}

.bucket-selector-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bucket-selector-title em {
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  text-transform: uppercase;
}

.bucket-selector-meta,
.bucket-selector-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.bucket-selector-foot {
  align-items: center;
  justify-content: space-between;
}

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

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

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

.grid-market {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 18px;
}

.workspace-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace-sidebar,
.workspace-main {
  min-width: 0;
}

.sidebar-stack {
  display: grid;
  gap: 18px;
}

.sidebar-sticky-block {
  position: sticky;
  top: 24px;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: var(--surface-2);
}

.mini-tab {
  border: 0;
  background: var(--surface-warm);
  color: var(--muted);
  padding: 9px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
}

.mini-tab.active {
  background: var(--accent);
  color: var(--accent-on);
}

.stack {
  display: grid;
  gap: 18px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.table-wrap.limited {
  max-height: 430px;
}

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

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-row);
  font-size: 13px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

@media (hover: hover) and (pointer: fine) {
  tbody tr:hover {
    background: var(--surface-hover);
  }
}

.row-active {
  background: var(--row-active);
}

.cell-symbol {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.position-opened-cell {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 128px;
  font-variant-numeric: tabular-nums;
}

.position-opened-cell small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.position-side {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.position-side.chip-long {
  background: var(--green-tint);
  color: var(--green);
  border-color: rgba(21, 128, 61, 0.24);
}

.position-side.chip-short {
  background: var(--red-tint);
  color: var(--red);
  border-color: rgba(185, 28, 28, 0.28);
}

.position-side.chip-neutral {
  background: rgba(120, 113, 108, 0.12);
  color: var(--muted);
  border-color: rgba(120, 113, 108, 0.24);
}

.leverage-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-tint);
  color: var(--blue);
  border: 1px solid rgba(37, 99, 235, 0.22);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.leverage-chip.lev-low {
  background: var(--teal-tint);
  color: var(--teal);
  border-color: rgba(15, 118, 110, 0.22);
}

.leverage-chip.lev-mid {
  background: var(--amber-tint);
  color: var(--amber);
  border-color: rgba(180, 83, 9, 0.26);
}

.leverage-chip.lev-high {
  background: var(--red-tint);
  color: var(--red);
  border-color: rgba(185, 28, 28, 0.26);
}

.pnl-cell {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.pnl-cell .pnl-abs {
  font-weight: 700;
  font-size: 13px;
}

.pnl-cell .pnl-pct {
  font-size: 11px;
  color: inherit;
  opacity: 0.85;
}

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

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

.pnl-neutral {
  color: var(--muted);
}

.bucket-overview-card {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-soft-2));
}

.bucket-overview-card .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pnl-curve-card {
  grid-column: 1 / -1;
  margin-top: 0;
}

.pnl-curve-stats {
  margin-top: 14px;
  margin-bottom: 12px;
}

.pnl-curve-host {
  width: 100%;
  height: 340px;
  min-height: 280px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}

.pnl-curve-empty {
  margin-top: 14px;
}

.today-pnl-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin: 14px 0 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--soft);
}

.today-pnl-card.pnl-positive {
  border-color: rgba(21, 128, 61, 0.35);
  background: linear-gradient(
    180deg,
    rgba(21, 128, 61, 0.09),
    rgba(21, 128, 61, 0.03)
  );
}

.today-pnl-card.pnl-negative {
  border-color: rgba(185, 28, 28, 0.35);
  background: linear-gradient(
    180deg,
    rgba(185, 28, 28, 0.09),
    rgba(185, 28, 28, 0.03)
  );
}

.today-pnl-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.today-pnl-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.today-pnl-sub {
  font-size: 12px;
  color: var(--muted);
}

.today-pnl-values {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.today-pnl-usd {
  font-size: 22px;
  font-weight: 700;
}

.today-pnl-pct {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.today-pnl-card.pnl-positive .today-pnl-usd,
.today-pnl-card.pnl-positive .today-pnl-pct {
  color: var(--green);
}

.today-pnl-card.pnl-negative .today-pnl-usd,
.today-pnl-card.pnl-negative .today-pnl-pct {
  color: var(--red);
}

.trade-journal-card {
  grid-column: 1 / -1;
  overflow: hidden;
}

.trade-filter-bar {
  display: grid;
  grid-template-columns: minmax(280px, auto) 1fr auto;
  align-items: end;
  gap: 14px;
  padding: 14px;
  margin: 16px 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-3);
}

.trade-date-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.trade-date-field {
  display: grid;
  gap: 7px;
  min-width: 160px;
}

.trade-date-field span,
.journal-stat-label,
.period-pnl-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trade-date-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trade-date-field input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
  border-color: rgba(37, 99, 235, 0.45);
}

.trade-preset-group {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.trade-preset-button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.trade-preset-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-button);
}

.trade-range-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.period-pnl-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  margin: 0 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-cool-1), var(--surface-1));
}

.period-pnl-card.pnl-positive {
  border-color: rgba(21, 128, 61, 0.3);
  background: linear-gradient(180deg, rgba(21, 128, 61, 0.08), rgba(21, 128, 61, 0.025));
}

.period-pnl-card.pnl-negative {
  border-color: rgba(185, 28, 28, 0.28);
  background: linear-gradient(180deg, rgba(185, 28, 28, 0.08), rgba(185, 28, 28, 0.025));
}

.period-pnl-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.period-pnl-values {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  min-width: 220px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.period-pnl-usd {
  font-size: 30px;
  font-weight: 900;
}

.period-pnl-pct {
  font-size: 16px;
  font-weight: 800;
}

.journal-stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.journal-stat {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 70px;
  min-width: 126px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.journal-stat-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.journal-stat-value small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.trade-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 14px;
}

.trade-stat {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--soft);
  min-width: 92px;
}

.trade-stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trade-stat-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trade-stat-value small {
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

td .pill-button,
td .table-actions {
  font-variant-numeric: tabular-nums;
}

.clickable {
  cursor: pointer;
}

.chart-box {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--chart-bg) 0%, var(--chart-bg-2) 100%);
  padding: 12px;
}

.chart-title {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

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

.chart-svg.compact {
  height: 210px;
}

.legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.pill-button {
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.pill-button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pill-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.pill-button:active,
.tab:active,
.mini-tab:active,
.bucket-item:active,
.symbol-card:active,
.trade-row:active {
  transform: scale(0.98);
  transition: transform 0.08s ease-out;
}

.split-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.split-header > * {
  min-width: 0;
  max-width: 100%;
}

.action-strip {
  margin-top: 14px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 28px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: var(--surface-soft-3);
}

.snapshot-list {
  display: grid;
  gap: 12px;
}

.snapshot-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: var(--soft);
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.snapshot-notes {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}

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

.reason-cell {
  min-width: 220px;
  max-width: 320px;
  white-space: normal;
  line-height: 1.4;
}

.weights {
  display: grid;
  gap: 8px;
}

.weight-row {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 0.7fr 0.7fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 12px;
}

.error-banner {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(185, 28, 28, 0.2);
  background: var(--red-bg-1);
  color: var(--red);
}

.bucket-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.bucket-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--soft);
  padding: 14px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.bucket-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--row-active-1);
}

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

.bucket-title {
  font-size: 15px;
  font-weight: 800;
}

.bucket-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.compact-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.compact-actions > *,
.table-actions > * {
  min-width: 0;
}

.chart-card {
  min-width: 0;
}

.chart-card-header {
  align-items: start;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.chart-symbol-switcher {
  justify-content: flex-end;
  max-width: min(620px, 100%);
  gap: 8px;
}

.chart-symbol-button {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  gap: 5px;
  min-width: 112px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.chart-symbol-button:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.chart-symbol-button.active {
  border-color: rgba(37, 99, 235, 0.5);
  background: var(--blue-bg-4);
}

.chart-symbol-button:disabled {
  cursor: progress;
}

.chart-symbol-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.chart-symbol-main strong {
  font-size: 13px;
  letter-spacing: 0.02em;
}

.chart-symbol-main span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-symbol-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chart-symbol-session {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.chart-symbol-session.active {
  color: var(--green);
}

.chart-symbol-session.waiting {
  color: var(--amber);
}

.chart-symbol-session.blocked {
  color: var(--red);
}

.chart-symbol-meta.live {
  color: var(--green);
}

.chart-symbol-meta.stale {
  color: var(--amber);
}

.chart-symbol-meta.auth {
  color: var(--red);
}

.chart-symbol-meta.pending {
  color: var(--blue);
}

.chart-switcher-empty {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 11px 12px;
}

.chart-select {
  display: grid;
  gap: 8px;
  min-width: 180px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.chart-select select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--soft);
  color: var(--text);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.chart-timeframes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chart-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chart-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-badge strong {
  color: var(--text);
}

.chart-badge.good,
.symbol-status.live,
.status-metric.good {
  color: var(--green);
}

.chart-badge.warn,
.symbol-status.stale,
.status-metric.warn {
  color: var(--amber);
}

.chart-badge.bad,
.symbol-status.auth,
.status-metric.bad {
  color: var(--red);
}

.chart-badge.info,
.symbol-status.pending,
.status-metric.info {
  color: var(--blue);
}

.chart-stage {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--chart-bg) 0%, var(--chart-bg-2) 100%);
  overflow: hidden;
}

.chart-host {
  position: relative;
  width: 100%;
  height: 560px;
  touch-action: pan-y;
}

.chart-empty {
  margin: 0;
  border: 0;
  border-radius: 0;
  min-height: 260px;
  height: 100%;
  display: grid;
  place-items: center;
}

.chart-empty.chart-error {
  color: var(--red);
  font-weight: 600;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 16px;
  align-content: center;
  background: linear-gradient(180deg, var(--chart-bg) 0%, var(--chart-bg-2) 100%);
  color: var(--text);
  text-align: center;
}

.chart-loading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chart-loading-bars {
  display: flex;
  align-items: end;
  gap: 5px;
  height: 46px;
}

.chart-loading-bars span {
  display: block;
  width: 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.42);
  animation: chartPulse 900ms ease-in-out infinite;
}

.chart-loading-bars span:nth-child(1) {
  height: 18px;
}

.chart-loading-bars span:nth-child(2) {
  height: 34px;
  animation-delay: 90ms;
}

.chart-loading-bars span:nth-child(3) {
  height: 25px;
  animation-delay: 180ms;
}

.chart-loading-bars span:nth-child(4) {
  height: 42px;
  animation-delay: 270ms;
}

.chart-loading-bars span:nth-child(5) {
  height: 28px;
  animation-delay: 360ms;
}

@keyframes chartPulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scaleY(0.65);
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chart-symbol-button {
    transition: none;
  }

  .chart-symbol-button:hover:not(:disabled) {
    transform: none;
  }

  .chart-loading-bars span {
    animation: none;
    opacity: 0.75;
  }
}

.chart-summary-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

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

.symbol-board {
  display: grid;
  gap: 10px;
}

.symbol-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--soft);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.symbol-card.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--row-active-1);
}

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

.symbol-card-head strong {
  font-size: 15px;
}

.symbol-card-symbol {
  display: grid;
  gap: 3px;
}

.symbol-card-symbol em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.symbol-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.symbol-status {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.saxo-cockpit {
  display: grid;
  gap: 16px;
}

.saxo-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.status-metric {
  border-left: 3px solid currentColor;
}

.saxo-reauth {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 18px;
  background: var(--red-bg-2);
  padding: 16px;
  color: var(--text);
  min-width: 0;
}

.saxo-reauth > * {
  min-width: 0;
}

.saxo-reauth h3,
.saxo-reauth p {
  margin: 0;
}

.saxo-reauth p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.reauth-error {
  color: var(--red) !important;
  font-weight: 700;
  word-break: break-word;
}

.reauth-steps {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.reauth-steps code {
  color: var(--text);
  word-break: break-all;
}

.setup-note {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-warm-1);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.setup-grid {
  margin-top: 14px;
  align-items: stretch;
}

.setup-source-metric {
  min-height: 100%;
}

.cockpit-stack {
  display: grid;
  gap: 14px;
}

.cockpit-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(360px, 0.82fr);
  gap: 14px;
  align-items: start;
}

.cockpit-chart-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.cockpit-kpi-ribbon {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.cockpit-side-card {
  display: grid;
  gap: 14px;
  align-self: start;
  align-content: start;
}

.side-panel-section,
.activation-check-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-cool);
  padding: 12px;
  min-width: 0;
}

.side-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.side-panel-heading h3 {
  margin: 0;
  font-size: 15px;
}

.side-panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-blotter {
  display: grid;
  border: 1px solid var(--border-cool-1);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.mini-blotter-row {
  display: grid;
  grid-template-columns: 1fr 0.72fr 0.72fr 0.9fr 0.9fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 10px 11px;
  border-bottom: 1px solid var(--border-cool-3);
  font-size: 12px;
}

.mini-position-row {
  grid-template-columns: minmax(66px, 1fr) auto minmax(48px, 0.72fr) minmax(50px, 0.74fr);
}

.mini-position-row.mini-blotter-head > span:nth-child(5) {
  display: none;
}

.mini-blotter-row:last-child {
  border-bottom: 0;
}

.mini-blotter-row > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-blotter-row > .mini-pnl-action {
  overflow: visible;
}

.mini-pnl-action {
  display: inline-flex;
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  max-width: 100%;
  padding-top: 3px;
}

.mini-action-button {
  max-width: 100%;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1;
}

.mini-action-button.danger {
  color: var(--red);
  border-color: var(--red-tint);
  background: var(--red-bg-2);
}

.mini-blotter-head {
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.activation-check-list {
  display: grid;
  border: 1px solid var(--border-cool-1);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.activation-check {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  border-bottom: 1px solid var(--border-cool-3);
  font-size: 12px;
}

.activation-check:last-child {
  border-bottom: 0;
}

.activation-check em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.check-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: var(--accent-on);
  font-size: 11px;
  font-weight: 900;
}

.activation-check.pass .check-dot {
  background: var(--green);
}

.activation-check.warn .check-dot {
  background: var(--amber);
}

.compact-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  margin: 0;
  border-radius: 9px;
}

.cockpit-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: 14px;
}

.cockpit-feed-card {
  display: grid;
  gap: 0;
}

.feed-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--border);
  margin: -2px -4px 0;
  padding: 0 4px;
}

.feed-tab {
  position: relative;
  padding: 12px 0;
  font-size: 14px;
}

.feed-tab.active {
  color: var(--blue);
}

.feed-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 999px;
  background: var(--blue);
}

.activation-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: var(--backdrop);
}

.activation-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: min(560px, calc(100vw - 36px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  padding: 18px;
}

.activation-drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.activation-drawer-head h2,
.activation-picker h3 {
  margin: 0;
}

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

.activation-picker {
  min-height: 0;
  overflow: auto;
}

.activation-bucket span {
  color: var(--muted);
  font-size: 12px;
}

.activation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 1320px) {
  .workspace-shell,
  .hero,
  .grid-market,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

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

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

  .saxo-status-grid,
  .saxo-reauth {
    grid-template-columns: 1fr;
  }

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

  .chart-control-grid {
    grid-template-columns: 1fr;
  }

  .chart-control-actions {
    justify-content: flex-start;
  }

  .sidebar-sticky-block {
    position: static;
  }

  /* .bucket-overview-card .kpi-grid has higher specificity than .kpi-grid;
     needs its own tablet override so the 4-col layout doesn't leak into tablets */
  .bucket-overview-card .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .runtime-command-main,
  .cockpit-main-grid,
  .cockpit-lower-grid {
    grid-template-columns: 1fr;
  }

  .trade-filter-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .trade-preset-group {
    justify-content: flex-start;
  }

  .trade-range-count {
    text-align: left;
  }

  .command-divider {
    display: none;
  }

  .command-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page {
    padding:
      max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .kpi-grid,
  .mini-grid,
  .snapshot-grid,
  .cockpit-kpi-ribbon,
  .activation-compare,
  .activation-actions {
    grid-template-columns: 1fr;
  }

  .runtime-command-shell {
    position: static;
  }

  .runtime-command-main {
    gap: 10px;
    padding: 12px;
  }

  .runtime-segment {
    grid-template-columns: 1fr;
  }

  .runtime-status-strip,
  .section-nav {
    gap: 12px;
  }

  .trade-date-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .trade-date-field {
    min-width: 0;
  }

  .trade-preset-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-preset-button {
    width: 100%;
    padding: 0 12px;
  }

  .period-pnl-card,
  .period-pnl-values {
    align-items: flex-start;
    flex-direction: column;
    min-width: 0;
    text-align: left;
  }

  .period-pnl-usd {
    font-size: 24px;
  }

  .journal-stat {
    width: 100%;
  }

  .runtime-command-meta {
    position: static;
    padding: 0 12px 12px;
  }

  .bucket-command-button {
    width: 100%;
    justify-content: flex-start;
  }

  .bucket-popover {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 120px;
    width: auto;
  }

  .mini-blotter-row {
    grid-template-columns: 1fr 0.68fr 0.68fr;
  }

  .mini-position-row {
    grid-template-columns: minmax(72px, 1fr) auto;
  }

  .mini-blotter-row > span:nth-child(4),
  .mini-blotter-row > span:nth-child(5) {
    display: none;
  }

  .mini-position-row > span:nth-child(3),
  .mini-position-row > span:nth-child(4) {
    display: none;
  }

  .mini-position-row > span:nth-child(5) {
    display: inline-flex;
  }

  .mini-position-row.mini-blotter-head > span:nth-child(5) {
    display: none;
  }

  .metric-value {
    font-size: 22px;
  }

  .chart-summary-grid,
  .kpi-grid-compact,
  .saxo-status-grid {
    grid-template-columns: 1fr;
  }

  .chart-toolbar {
    width: 100%;
  }

  .chart-symbol-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    max-width: 100%;
  }

  .chart-symbol-button {
    min-width: 0;
  }

  .chart-symbol-session {
    white-space: normal;
  }

  .chart-select {
    min-width: 0;
    width: 100%;
  }

  .chart-host {
    height: 320px;
  }

  .hero-chart-section,
  .hero-tradingview-anchor,
  .hero-tradingview-stage,
  .tradingview-widget-container,
  .tradingview-widget-container__widget {
    min-height: 0;
  }

  .hero-tradingview-stage {
    height: 320px;
  }

  table {
    min-width: 0;
  }

  .field input,
  .field select,
  .chart-select select {
    font-size: 16px;
  }

  .split-header {
    flex-direction: column;
  }

  .compact-actions,
  .table-actions {
    width: 100%;
  }

  .compact-actions .pill-button,
  .table-actions .pill-button,
  .saxo-reauth .pill-button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .pill-button {
    padding: 12px 16px;
    min-height: 44px;
    white-space: normal;
  }
  .mini-action-button {
    min-height: 36px;
    padding: 8px 10px;
    white-space: nowrap;
  }
  .tab {
    padding: 13px 16px;
  }
  .mini-tab {
    padding: 11px 14px;
  }

  .pnl-curve-host {
    height: 260px;
    min-height: 220px;
  }

  /* Prevent cards and scrollable wraps from expanding beyond their grid track.
     Without these, a wide table or KPI inside a card forces the card (and the
     whole stack) wider than the viewport, causing the content to be clipped
     by our body overflow-x: clip. */
  .card,
  .table-wrap {
    min-width: 0;
  }

  /* Bound the single-column grid tracks so they respect the parent width
     instead of sizing to content. */
  .stack,
  .sidebar-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  /* .bucket-overview-card .kpi-grid has higher specificity than the generic
      .kpi-grid mobile rule, so re-declare it here to collapse to a single column. */
  .bucket-overview-card .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Theme Toggle ─────────────────────────────── */

.theme-toggle {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
  user-select: none;
  -webkit-user-select: none;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle-icon {
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.theme-toggle[data-theme="dark"] .theme-toggle-icon {
  color: var(--amber);
}

.theme-toggle[data-theme="light"] .theme-toggle-icon,
.theme-toggle:not([data-theme="dark"]) .theme-toggle-icon {
  color: var(--blue);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
  .theme-toggle:hover {
    transform: none;
  }
}

@media (max-width: 720px) {
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
  .theme-toggle-icon {
    font-size: 16px;
  }
}
