:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #050c16;
  --surface: #0c1929;
  --surface-raised: #102033;
  --surface-soft: #0a1625;
  --border: #203147;
  --border-soft: #182a3e;
  --text: #edf3f8;
  --text-soft: #9cafc2;
  --text-muted: #71869b;
  --accent: #ee9c75;
  --accent-strong: #ffad85;
  --accent-ink: #2c130b;
  --positive: #61c7a4;
  --positive-soft: rgba(97, 199, 164, 0.1);
  --negative: #f07f86;
  --negative-soft: rgba(240, 127, 134, 0.1);
  --warning: #f3be62;
  --warning-soft: rgba(243, 190, 98, 0.1);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 12% 3%, rgba(238, 156, 117, 0.07), transparent 25rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="radio"] + label {
  cursor: pointer;
}

.page-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 0 28px;
  transition: filter 180ms ease, opacity 180ms ease, transform 180ms ease;
}

body.modal-open .page-shell {
  filter: blur(10px) saturate(0.72);
  opacity: 0.62;
  pointer-events: none;
  transform: scale(0.992);
}

.site-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(156, 175, 194, 0.12);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 8px 18px rgba(139, 92, 246, 0.22));
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.intro {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 58px 0 42px;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

h1 span {
  color: var(--text-soft);
}

.workspace {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.panel {
  overflow: hidden;
  background: rgba(12, 25, 41, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 75px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 32, 51, 0.52);
  border-bottom: 1px solid var(--border-soft);
}

.panel-heading > div {
  display: flex;
  gap: 12px;
  align-items: center;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

form {
  padding: 25px 24px 24px;
}

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

.field {
  min-width: 0;
}

.field-full {
  grid-column: 1 / -1;
}

.section-break {
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.field label,
.field legend {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.field > label {
  display: inline-block;
  margin-bottom: 7px;
}

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

.label-row span {
  color: var(--text-muted);
  font-size: 10px;
}

.choice-field {
  padding: 0;
  margin: 0;
  border: 0;
}

.choice-field legend {
  padding: 0;
  margin-bottom: 7px;
}

.input-wrap,
.select-wrap {
  min-height: 44px;
  display: flex;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-wrap:focus-within,
.select-wrap:focus-within {
  background: #0d1b2c;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238, 156, 117, 0.11);
}

input,
select {
  min-width: 0;
  width: 100%;
  height: 42px;
  padding: 0 13px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: inherit;
  outline: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

input::placeholder {
  color: #52677c;
  opacity: 1;
}

select {
  appearance: none;
  padding-right: 37px;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-soft);
  border-bottom: 1.5px solid var(--text-soft);
  pointer-events: none;
  transform: translateY(-2px) rotate(45deg);
}

.has-prefix input,
.text-prefix input {
  padding-left: 8px;
}

.has-suffix input {
  padding-right: 4px;
}

.currency-affix,
.text-prefix > span,
.input-affix {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.currency-affix,
.text-prefix > span {
  padding-left: 13px;
}

.input-affix {
  padding: 0 13px 0 7px;
}

.segmented {
  display: grid;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.segmented.direction-control,
.segmented.risk-control {
  grid-template-columns: 1fr 1fr;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  min-height: 34px;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  transition: all 150ms ease;
}

.segmented input:checked + label {
  color: var(--text);
  background: var(--surface-raised);
  border-color: var(--border);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.18);
}

.direction-control input[value="LONG"]:checked + label {
  color: var(--positive);
}

.direction-control input[value="SHORT"]:checked + label {
  color: var(--negative);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-error {
  min-height: 0;
  display: block;
  margin-top: 5px;
  color: var(--negative);
  font-size: 10px;
  line-height: 1.35;
}

.field-error:not(:empty) {
  min-height: 14px;
}

.field.has-error .input-wrap,
.field.has-error .select-wrap {
  border-color: rgba(240, 127, 134, 0.75);
}

.validation-summary {
  margin: 20px 24px 0;
  padding: 13px 15px;
  color: #ffc4c7;
  background: var(--negative-soft);
  border: 1px solid rgba(240, 127, 134, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.validation-summary strong {
  font-size: 11px;
}

.validation-summary ul {
  margin: 6px 0 0;
  padding-left: 17px;
}

.form-actions {
  display: flex;
  gap: 9px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

/* Calculate button adapted from Uiverse.io by shivam_7937 */
.calculate-cta {
  position: relative;
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.calculate-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #6366f1, #ec4899, #facc15);
  border-radius: 12px;
  filter: blur(15px);
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 1s ease;
}

.calculate-cta:hover .calculate-glow,
.calculate-cta:focus-within .calculate-glow {
  opacity: 1;
  transition-duration: 0.2s;
}

.calculate-button {
  position: relative;
  min-height: 46px;
  width: 100%;
  display: inline-flex;
  padding: 0 32px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.calculate-button:hover {
  background: #1f2937;
  box-shadow: 0 12px 24px rgba(75, 85, 99, 0.3);
  transform: translateY(-2px);
}

.calculate-button:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 4px;
}

.calculate-button svg {
  margin-left: 9px;
  margin-right: -4px;
  stroke: #fff;
  stroke-width: 2;
  overflow: visible;
}

.calculate-button .arrow-line {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.calculate-button .arrow-head {
  transition: transform 0.2s ease;
}

.calculate-button:hover .arrow-line,
.calculate-button:focus-visible .arrow-line {
  opacity: 1;
}

.calculate-button:hover .arrow-head,
.calculate-button:focus-visible .arrow-head {
  transform: translateX(3px);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.015em;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.button-primary {
  flex: 1;
  color: var(--accent-ink);
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: var(--border);
}

.button-ghost:hover {
  color: var(--text);
  background: var(--surface-raised);
}

dialog.result-dialog,
dialog.result-dialog:modal {
  width: min(1120px, calc(100vw - 48px)) !important;
  max-width: calc(100vw - 48px) !important;
  max-height: calc(100dvh - 32px);
  padding: 0;
  margin: auto;
  color: var(--text);
  overflow: auto;
  background: linear-gradient(180deg, rgba(15, 31, 49, 0.99), rgba(8, 20, 34, 0.99));
  border-top: 2px solid rgba(238, 156, 117, 0.72);
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(113, 134, 155, 0.12),
    0 0 70px rgba(238, 156, 117, 0.07);
}

.result-dialog::backdrop {
  background: rgba(2, 8, 15, 0.68);
  -webkit-backdrop-filter: blur(16px) saturate(0.72);
  backdrop-filter: blur(16px) saturate(0.72);
}

.result-dialog[open] {
  animation: dialog-in 180ms ease-out;
}

.result-heading-actions {
  gap: 9px !important;
}

.result-heading h2 {
  font-size: 22px;
}

.dialog-close {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.dialog-close:hover {
  color: var(--text);
  background: var(--surface-raised);
  border-color: #38506a;
}

.dialog-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dialog-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.capital-warning {
  display: flex;
  gap: 12px;
  margin: 18px 22px 0;
  padding: 13px 14px;
  align-items: flex-start;
  color: #f8d99d;
  background: var(--warning-soft);
  border: 1px solid rgba(243, 190, 98, 0.25);
  border-radius: var(--radius-sm);
}

.capital-warning[hidden] {
  display: none;
}

.capital-warning svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--warning);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.capital-warning strong,
.capital-warning span {
  display: block;
}

.capital-warning strong {
  margin-bottom: 2px;
  font-size: 11px;
}

.capital-warning span {
  color: #c7ad7d;
  font-size: 10px;
  line-height: 1.5;
}

.result-groups {
  display: block;
}

.result-group {
  min-width: 0;
  padding: 30px 38px 24px;
}

.position-summary {
  padding-bottom: 34px;
}

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

.position-meta {
  display: flex;
  min-height: 50px;
  margin-bottom: 12px;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--border-soft);
}

.position-meta > span {
  padding: 7px 11px;
  color: var(--text);
  background: rgba(113, 134, 155, 0.08);
  border: 1px solid rgba(113, 134, 155, 0.16);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.direction-badge.long {
  color: var(--positive);
}

.direction-badge.short {
  color: var(--negative);
}

.metrics-list {
  margin: 0;
}

.metrics-list > div {
  display: flex;
  min-height: 52px;
  padding: 13px 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(32, 49, 71, 0.55);
}

.metrics-list > div:last-child {
  border-bottom: 0;
}

.metrics-list dt {
  min-width: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.metrics-list dd {
  overflow: hidden;
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics-list .emphasis-row dd {
  color: var(--text);
  font-size: 16px;
}

.metrics-list .take-profit-row dd {
  color: var(--positive);
}

.metrics-list .stop-loss-row dd {
  color: var(--negative);
}

.summary-actions {
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 20px 24px 18px;
  align-items: center;
  justify-content: center;
  background: rgba(7, 17, 31, 0.28);
  border-top: 1px solid var(--border-soft);
}

#download-status {
  color: var(--positive);
  font-size: 11px;
}

/* Download button adapted from Uiverse.io by vinodjangid07 */
.Btn {
  width: 50px;
  height: 50px;
  display: flex;
  position: relative;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  background-color: rgb(27, 27, 27);
  border: none;
  border-radius: 50%;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.11);
  transition-duration: 0.3s;
}

.svgIcon {
  width: 17px;
  fill: rgb(214, 178, 255);
}

.icon2 {
  width: 18px;
  height: 5px;
  border-right: 2px solid rgb(182, 143, 255);
  border-bottom: 2px solid rgb(182, 143, 255);
  border-left: 2px solid rgb(182, 143, 255);
}

.tooltip {
  position: absolute;
  right: -105px;
  display: flex;
  padding: 5px 10px;
  align-items: center;
  justify-content: center;
  color: white;
  background-color: rgb(12, 12, 12);
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  letter-spacing: 0.5px;
  transition-duration: 0.2s;
}

.tooltip::before {
  position: absolute;
  left: -5px;
  width: 10px;
  height: 10px;
  content: "";
  background-color: rgb(12, 12, 12);
  transform: rotate(45deg);
}

.Btn:hover:not(:disabled) .tooltip,
.Btn:focus-visible .tooltip {
  opacity: 1;
}

.Btn:hover:not(:disabled) {
  background-color: rgb(150, 94, 255);
}

.Btn:hover:not(:disabled) .icon2 {
  border-color: rgb(235, 235, 235);
}

.Btn:hover:not(:disabled) .svgIcon {
  fill: rgb(255, 255, 255);
  animation: slide-in-top 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.Btn:focus-visible {
  outline: 2px solid rgb(182, 143, 255);
  outline-offset: 4px;
}

.Btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

@keyframes slide-in-top {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .intro {
    width: min(1120px, 100%);
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 0 16px;
  }

  .site-header {
    min-height: 76px;
  }

  .intro {
    padding: 38px 0 30px;
  }

  dialog.result-dialog,
  dialog.result-dialog:modal {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px);
  }

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

  .field-full {
    grid-column: auto;
  }

  .section-break {
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding: 0 10px;
  }

  h1 {
    font-size: 37px;
  }

  .panel-heading,
  form,
  .result-group,
  .summary-actions {
    padding-right: 16px;
    padding-left: 16px;
  }

  .panel-heading > p {
    display: none;
  }

  .field-full {
    grid-column: auto;
  }

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

  .capital-warning {
    margin-right: 16px;
    margin-left: 16px;
  }

  .form-actions {
    flex-direction: column;
  }

  .calculate-cta {
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .summary-actions {
    align-items: center;
  }

  #download-status {
    min-height: 14px;
    text-align: center;
  }

}

@media (prefers-reduced-motion: reduce) {
  .result-dialog[open] {
    animation: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
