:root {
  --ink: #061B31;
  --navy: #0a2540;
  --slate: #425466;
  --muted: #6B7C93;
  --violet: #635bff;
  --violet2: #5851EA;
  --line: #E3E8EF;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --soft: #F6F9FC;
  --g: linear-gradient(90deg, #635BFF, #A960EE 55%, #FF6BA3);
  --shadow: 0 10px 30px rgba(22, 45, 82, .055);
}
* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--tb, 78px) + var(--sn, 76px) + 24px);
  overflow-x: clip;
}
body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg);
  font: 14px Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  padding-bottom: 78px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* Topbar */
.topbar {
  height: 78px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 0 clamp(22px, 3.5vw, 54px);
  background: rgba(245, 245, 247, .94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(16, 40, 68, .025);
}
.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3em;
  color: var(--ink);
  white-space: nowrap;
  margin-right: 14px;
  text-decoration: none;
}
.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.nav a {
  padding: 12px 16px;
  border-radius: 11px;
  text-decoration: none;
  color: var(--slate);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  transition: all .2s;
}
.nav a:hover, .nav a.active {
  color: var(--violet);
  background: #f0efff;
}
.right {
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
}
.market {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
}
.market strong { color: var(--ink); font-weight: 650; }
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2BD9A2;
}
.dot.off { background: #A3B1C6; }
.iconbtn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f5f5f7;
  color: #506987;
  display: grid;
  place-items: center;
}
.iconbtn svg { width: 18px; height: 18px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  background: linear-gradient(135deg, #635bff, #a960ee);
}
.user { font-weight: 600; font-size: 13px; }
.logout {
  border: 1px solid var(--violet);
  background: #f5f5f7;
  color: var(--violet);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all .2s;
}
.logout:hover { background: #f0efff; }

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--g);
  z-index: 60;
}

/* Layout */
main {
  max-width: 1540px;
  margin: auto;
  padding: 32px clamp(20px, 3.5vw, 50px) 48px;
}
.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 28px;
  position: relative;
}
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 12px;
}
.intro h1 {
  margin: 0;
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1.1;
  color: var(--ink);
}
.intro h1 span {
  background: var(--g);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.intro p {
  color: #3E6286;
  font-size: 16px;
  line-height: 1.6;
  margin: 12px 0 0;
}
.hero-art {
  position: absolute;
  z-index: -1;
  right: -1%;
  top: -10px;
  width: 57%;
  height: 205px;
  pointer-events: none;
  overflow: hidden;
  opacity: .72;
  mask-image: linear-gradient(90deg, transparent 0%, #000 12%, #000 100%);
}
.hero-art svg { width: 100%; height: 100%; }
.status-pill {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 18px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(22, 45, 82, .04);
}
.status-pill strong { color: var(--ink); font-size: 16px; margin-left: 8px; }

/* Subnavigation */
.strategy-subnav {
  position: sticky;
  top: calc(var(--tb, 78px) + 10px);
  z-index: 25;
  display: flex;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  padding: 7px;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f5f5f7;
  box-shadow: 0 10px 24px -12px rgba(50, 50, 93, .28);
}
.strategy-subnav:before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -10px;
  bottom: -10px;
  left: -50vw;
  width: 200vw;
  background: #f5f5f7;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 18px -14px rgba(50, 50, 93, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.strategy-subnav.stuck:before {
  opacity: 1;
}
.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--slate);
  transition: .2s;
}
.tab:hover { background: #ffffff; border-color: #e6e2ff; }
.tab.active { background: #ffffff; border-color: #dedaff; color: var(--violet); box-shadow: 0 4px 12px rgba(99, 91, 255, .1); }
.tab-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #eae8ff, #fceeff);
  font-size: 16px;
  color: var(--violet);
  flex: none;
}
.tab strong { display: block; font-size: 13px; color: var(--navy); }
.tab small { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Two-column Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 380px;
  gap: 24px;
  align-items: start;
}
.main-column { min-width: 0; }
.panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.panel-head p { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--violet);
  background: #f0efff;
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* Sections & Form Fields */
.section {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}
.section:last-child { border-bottom: 0; }
.section-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.step {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f0efff;
  color: var(--violet);
  font-weight: 700;
  font-size: 11px;
  flex: none;
}
.section-title h3 { font-size: 14px; font-weight: 650; margin: 0; color: var(--navy); }
.section-title p { font-size: 11px; color: var(--muted); margin: 3px 0 0; }
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field.full { grid-column: span 2; }
.field label { font-size: 12px; font-weight: 600; color: var(--slate); }
.field input, .field select, .field textarea {
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  background: #f5f5f7;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: all .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--violet);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 91, 255, .12);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  border: 1px solid #D6DEEB;
  border-radius: 99px;
  padding: 6px 14px;
  background: #f5f5f7;
  font-size: 12px;
  color: var(--slate);
  cursor: pointer;
  transition: all .2s;
}
.chip.active, .chip:hover {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  background: #fafafc;
  border-top: 1px solid var(--line);
}
.primary-btn {
  background: var(--violet);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 11px 22px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(99, 91, 255, .3);
  transition: all .2s;
}
.primary-btn:hover {
  background: var(--violet2);
  transform: translateY(-1px);
}
.secondary-btn {
  background: #ffffff;
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13px;
  color: var(--slate);
  transition: all .2s;
}
.secondary-btn:hover { background: #f5f5f7; border-color: #B9C7DD; }

/* Option Legs Dynamic Builder */
.legs-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.leg-card {
  border: 1px solid #D5D9FB;
  border-radius: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #F1F2FF 0%, #FAF0F8 100%);
  box-shadow: 0 4px 16px rgba(50, 50, 93, .04);
  transition: border-color .2s, box-shadow .2s;
}
.leg-card:hover {
  border-color: #8F88FF;
  box-shadow: 0 8px 24px rgba(99, 91, 255, .10);
}
.leg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(213, 217, 251, .6);
}
.leg-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.leg-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.leg-side-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.leg-side-pill.buy {
  background: #e6f9f2;
  color: #00b981;
  border: 1px solid #a7f3d0;
}
.leg-side-pill.sell {
  background: #fee2e2;
  color: #ef4444;
  border: 1px solid #fecaca;
}
.leg-actions-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.leg-action-btn {
  border: 1px solid #D5D9FB;
  border-radius: 7px;
  background: #ffffff;
  color: var(--slate);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
  transition: all .18s ease;
}
.leg-action-btn:hover {
  border-color: var(--violet);
  background: #f0efff;
  color: var(--violet);
}
.leg-action-btn.danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fff;
}
.leg-action-btn.danger:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}
.leg-grid-primary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.leg-grid-advanced {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(213, 217, 251, .7);
}
@media (max-width: 900px) {
  .leg-grid-primary, .leg-grid-advanced {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 550px) {
  .leg-grid-primary, .leg-grid-advanced {
    grid-template-columns: 1fr;
  }
}
.leg-grid-advanced .leg-field-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.leg-grid-advanced .leg-field-item > div:last-child {
  margin-top: auto;
}
.leg-field-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.leg-field-item label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
  white-space: nowrap;
}
.leg-field-item input,
.leg-field-item select {
  width: 100%;
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  box-sizing: border-box;
}
.leg-field-item input:focus,
.leg-field-item select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px rgba(99, 91, 255, .15);
}
.leg-trail-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 33px;
  padding: 0 4px;
}
.leg-trail-toggle-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--violet);
  cursor: pointer;
}

/* Fixed Right AI Strategy Builder */
.ai-builder {
  position: sticky;
  top: 96px;
  align-self: start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 36px rgba(22, 45, 82, .07);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  overflow: hidden;
}
.ai-builder .panel-head {
  padding: 18px 22px 16px;
}
.ai-card {
  padding: 20px;
  overflow-y: auto;
}
.ai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.ai-head h3 {
  margin: 0;
  font-size: 14px;
  color: var(--navy);
  font-weight: 700;
}
.ai-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.ai-orb {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #635BFF, #A960EE);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 6px 14px rgba(99, 91, 255, .25);
  flex: none;
}
.ai-callout {
  border: 1px solid #e5e1ff;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7f6ff, #fff9fd);
  padding: 14px;
  margin-bottom: 15px;
}
.ai-callout strong {
  font-size: 12px;
  color: var(--navy);
}
.ai-callout p {
  font-size: 11px;
  line-height: 1.6;
  color: #667085;
  margin: 7px 0 0;
}
.prompt-list {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
}
.prompt {
  border: 1px solid #D5D9FB;
  border-radius: 10px;
  padding: 11px 12px;
  background: linear-gradient(135deg, #F1F2FF 0%, #FAF0F8 100%);
  text-align: left;
  font-size: 11px;
  color: #475467;
  line-height: 1.45;
  transition: all .2s;
  cursor: pointer;
}
.prompt:hover {
  border-color: #8F88FF;
  background: linear-gradient(135deg, #E3E6FF 0%, #F9E1F2 100%);
  color: var(--violet);
  transform: translateX(2px);
}
.ai-mini-input {
  display: flex;
  gap: 8px;
}
.ai-mini-input input {
  min-width: 0;
  flex: 1;
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f5f5f7;
  color: var(--ink);
  font-size: 12px;
  outline: none;
  transition: border-color .18s;
}
.ai-mini-input input:focus {
  outline: 2px solid rgba(99, 91, 255, .45);
  outline-offset: 1px;
  border-color: #D6DEEB;
}
.ai-mini-input button {
  border: 0;
  border-radius: 8px;
  width: 42px;
  background: var(--violet);
  color: #ffffff;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: background .2s;
  cursor: pointer;
}
.ai-mini-input button:hover {
  background: var(--violet2);
}
.ai-note {
  margin-top: 14px;
  font-size: 11px;
  line-height: 1.5;
  color: #8a94a6;
}

/* Floating AI Combinations Generator Dock */
.combo-dock {
  position: fixed;
  z-index: 45;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  border: 1px solid rgba(220, 216, 255, .9);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgba(245, 245, 247, .92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 -10px 34px rgba(40, 35, 90, .10);
  overflow: hidden;
  transition: height .25s ease, box-shadow .25s ease, background .25s ease;
  max-height: 72vh;
}
.combo-dock[hidden] {
  display: none !important;
}
.combo-dock:not(.expanded) {
  height: 76px;
}
.combo-dock.expanded {
  height: min(560px, 80vh);
  box-shadow: 0 -18px 60px rgba(40, 35, 90, .17);
  background: rgba(245, 245, 247, .97);
}
.combo-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px clamp(16px, 4vw, 56px);
  background: linear-gradient(100deg, #f3f1ff, #fff7fd);
  cursor: pointer;
  user-select: none;
}
.combo-top .ai-orb {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 18px;
}
.combo-title {
  flex: 1;
  min-width: 0;
}
.combo-title strong {
  display: block;
  font-size: 13px;
  color: var(--navy);
}
.combo-title small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.dock-chevron {
  border: 1px solid #D5D9FB;
  border-radius: 8px;
  background: #ffffff;
  color: var(--violet);
  min-width: 64px;
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.dock-chevron:hover {
  background: #efedff;
  border-color: var(--violet);
}
.combo-body {
  display: none;
  padding: 12px clamp(16px, 4vw, 56px) 16px;
  height: calc(100% - 76px);
  flex-direction: column;
}
.combo-dock.expanded .combo-body {
  display: flex;
}
.chat-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 10px;
}
.bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #475467;
  background: #E9EBFF;
}
.bubble.ai {
  background: #E9EBFF;
  color: #3f38b9;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.bubble.user {
  background: var(--violet);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.combo-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.combo-dock:not(.expanded) .combo-suggestions {
  display: none;
}
.combo-suggestions button {
  border: 1px solid #D5D9FB;
  border-radius: 99px;
  background: #ffffff;
  color: var(--violet);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: all .15s;
}
.combo-suggestions button:hover {
  background: #efedff;
  border-color: var(--violet);
}
.chat-input {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.chat-input input {
  min-width: 0;
  flex: 1;
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  padding: 10px 14px;
  background: #ffffff;
  font-size: 12px;
  outline: none;
  transition: border-color .18s;
}
.chat-input input:focus {
  outline: 2px solid rgba(99, 91, 255, .45);
  outline-offset: 1px;
  border-color: #D6DEEB;
}
.chat-input button {
  border: 0;
  border-radius: 8px;
  background: var(--violet);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s;
}
.chat-input button:hover {
  background: var(--violet2);
}

/* My Strategies View */
.view-pane { display: none; }
.view-pane.active { display: block; }
.strategy-list {
  display: grid;
  gap: 12px;
  padding: 20px 24px;
}
.strategy-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  transition: all .2s;
}
.strategy-card:hover {
  border-color: #dedaff;
  box-shadow: 0 6px 18px rgba(99, 91, 255, .08);
  transform: translateY(-1px);
}
.strategy-info h4 { margin: 0 0 5px; font-size: 14px; font-weight: 650; color: var(--navy); }
.strategy-info p { margin: 0; font-size: 12px; color: var(--muted); }
.strategy-tags { display: flex; gap: 8px; margin-top: 8px; }
.tag { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: #f0efff; color: var(--violet); }
.tag-green { background: #e6f9f2; color: #00b981; }
.tag-amber { background: #fef3c7; color: #d97706; }
.tag-muted { background: #f1f5f9; color: #64748b; }
.portfolio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr);
  gap: 20px;
}
@media(max-width: 950px) {
  .portfolio-grid { grid-template-columns: 1fr; }
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99,91,255,.2);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.app-footer {
  max-width: 1540px;
  margin: 40px auto 0;
  padding: 26px clamp(20px, 3.5vw, 50px) 44px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.app-footer a { color: var(--violet); text-decoration: none; }
.app-footer .wm { letter-spacing: .3em; color: var(--ink); font-weight: 700; }
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #0a2540;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(10, 37, 64, .3);
  transition: all .25s;
  z-index: 100;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Right-side Toast Notifications (Old Frontend Reference) */
#notificationContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-notification {
  background: #2c3e50;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  min-width: 300px;
  max-width: 450px;
  animation: toastSlideIn 0.3s ease-out;
  border-left: 4px solid #1a237e;
  pointer-events: auto;
}

.toast-notification.success {
  border-left-color: #00c853;
}

.toast-notification.error {
  border-left-color: #ff1744;
}

.toast-notification.warning {
  border-left-color: #ffc107;
}

.toast-notification.info {
  border-left-color: #2196f3;
}

.toast-notification .toast-icon {
  margin-right: 12px;
  font-size: 1.2rem;
  line-height: 1;
}

.toast-notification .toast-content {
  flex-grow: 1;
}

.toast-notification .toast-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.toast-notification .toast-message {
  font-size: 0.8rem;
  opacity: 0.9;
  word-break: break-word;
}

@keyframes toastSlideIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(110%); opacity: 0; }
}

@media(max-width: 1050px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .ai-builder { position: static; max-height: none; }
}

/* Modals & Dialogs */
.modal-backdrop.show { display: flex; }
.dep-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f7;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 28px 90px rgba(16, 24, 40, .35);
  overflow: hidden;
  animation: rise .18s ease-out;
}
.dep-modal:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--g);
  z-index: 2;
}
@keyframes rise { from { transform: translateY(8px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.02em;
}
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.modal-head .close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f7;
  color: #667085;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .2s;
}
.modal-head .close:hover { background: #efedff; color: var(--violet); }
.modal-body {
  padding: 18px 26px 20px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}
.modal-foot {
  padding: 14px 26px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f5f5f7;
}
.foot-left { font-size: 12px; color: var(--muted); }
.foot-actions { display: flex; gap: 8px; }

/* Segmented button toggle */
.segmented {
  display: inline-flex;
  background: #eceef3;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--slate);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--violet);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99, 91, 255, .25);
}
.segmented.fit { width: 100%; display: flex; }
.segmented.fit button { flex: 1; text-align: center; }

/* Notice & Unit inputs */
.notice {
  background: #FFF9E9;
  border: 1px solid #F2D9A0;
  color: #815B08;
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 12px;
  line-height: 1.5;
  margin: 14px 0 6px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.notice:before {
  content: "ℹ";
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #F2B01E;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 18px;
}
.unit {
  display: flex;
  align-items: stretch;
}
.unit input {
  flex: 1;
  min-width: 0;
}
.unit span {
  display: grid;
  place-items: center;
  padding: 0 12px;
  border: 1px solid #D6DEEB;
  background: #f7f6ff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Portfolio strategy picker list */
.portfolio-picker {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
}
.portfolio-strat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background .15s;
}
.portfolio-strat-row:hover {
  background: #f8f7ff;
}
.portfolio-strat-row:last-child { margin-bottom: 0; }
.strat-check-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.strat-check-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--violet);
  cursor: pointer;
}
.strat-check-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 13px;
}
.strat-mult-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.strat-mult-wrap input {
  width: 58px;
  padding: 5px 8px;
  border: 1px solid #D6DEEB;
  border-radius: 6px;
  background: #f5f5f7;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* Custom Elements for Strategy Builder */
.sub-card {
  background: #fafafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 18px;
  background: #D6DEEB;
  border-radius: 99px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background .2s;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
}
.toggle-switch input[type="checkbox"]:checked {
  background: var(--violet);
}
.toggle-switch input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-switch input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}
.custom-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  list-style: none;
  margin: 4px 0 0;
  padding: 6px 0;
}
.custom-dropdown-menu li {
  margin: 0;
  padding: 0;
}
.custom-dropdown-menu .dropdown-item {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--navy);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.custom-dropdown-menu .dropdown-item:hover {
  background: #f0efff;
  color: var(--violet);
}
.leg-card.connection {
  border-color: #a7f3d0;
  background: linear-gradient(135deg, #f0fdf4 0%, #f7fee7 100%);
}
.leg-card.connection:hover {
  border-color: #34d399;
  box-shadow: 0 8px 24px rgba(16, 185, 129, .12);
}
.leg-card.connection .leg-num {
  color: #065f46;
}
.leg-reentry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(213, 217, 251, .7);
}
.leg-reentry-grid select,
.leg-reentry-grid input[type="number"] {
  border: 1px solid #D6DEEB;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  box-sizing: border-box;
}
.leg-reentry-grid select:focus,
.leg-reentry-grid input[type="number"]:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px rgba(99, 91, 255, .15);
}
@media (max-width: 768px) {
  .leg-reentry-grid {
    grid-template-columns: 1fr;
  }
}
