/* FxExplorer calculators (position size, compounding, leverage, margin call): white input deck + indigo readout. */
.fxe-calc-page { --fxe-ink: #1f2440; --fxe-muted: #5f6478; --fxe-line: #e7e8ee; --fxe-accent: #4a5fd9; --fxe-soft: #f3f4ff;
    display: flex; flex-direction: column; gap: 32px; color: var(--fxe-ink); }
.fxe-calc-head { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }

.fxe-calc { display: grid; gap: 20px; padding: 16px; border-radius: 20px; background: #fff url('../images/noise-tools.webp');
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, .08); }
@media (min-width: 768px) { .fxe-calc { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 24px; padding: 24px; } }

.fxe-calc__inputs { display: grid; gap: 16px; margin: 0; padding: 0; border: 0; min-width: 0; align-content: start; }
@media (min-width: 560px) { .fxe-calc__inputs { grid-template-columns: 1fr 1fr; } }
.fxe-calc__inputs legend { padding: 0; margin-bottom: 16px; font-size: 16px; font-weight: 600; }
.fxe-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fxe-field--wide, .fxe-calc__note { grid-column: 1 / -1; }
.fxe-field label { font-size: 13px; font-weight: 500; color: var(--fxe-muted); }
.fxe-field__box { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--fxe-line);
    border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.fxe-field__box:hover { border-color: #c9cdf2; }
.fxe-field__box:focus-within { border-color: var(--fxe-accent); box-shadow: 0 0 0 3px rgba(74, 95, 217, .14); }
.fxe-field__box input, .fxe-field__box select { flex: 1; min-width: 0; height: 42px; border: 0; outline: 0; background: transparent;
    font: inherit; font-size: 15px; color: var(--fxe-ink); font-variant-numeric: tabular-nums; }
.fxe-field__box select { cursor: pointer; }
.fxe-field__unit { font-size: 14px; font-weight: 600; color: var(--fxe-accent); }
.fxe-field__hint, .fxe-calc__note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--fxe-muted); }

.fxe-calc__readout { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 320px; padding: 24px;
    border-radius: 16px; color: #fff; background: linear-gradient(155deg, #26318a 0%, #4a5fd9 58%, #8b6cff 100%); }
.fxe-calc__readout::after { content: ''; position: absolute; inset: auto -60px -80px auto; width: 220px; height: 220px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .18); box-shadow: 0 0 0 28px rgba(255, 255, 255, .04); pointer-events: none; }
.fxe-calc__eyebrow { margin: 0 0 16px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.fxe-calc__result { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; }
.fxe-calc__label { margin: 0; font-size: 13px; opacity: .85; }
.fxe-calc__big { margin: -6px 0 0; font-size: clamp(32px, 6vw, 44px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere; }
.fxe-calc__big small { font-size: 16px; font-weight: 500; opacity: .8; }
.fxe-calc__empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
    font-size: 14px; line-height: 1.5; opacity: .9; }
.fxe-calc__empty[hidden], .fxe-calc__result[hidden] { display: none; }
.fxe-calc__empty svg { opacity: .7; }

.fxe-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 0; }
.fxe-stats div { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .12); }
.fxe-stats dt { font-size: 11px; line-height: 1.35; opacity: .8; }
.fxe-stats dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Position size: share of balance at risk, 0–10% scale. */
.fxe-meter { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.fxe-meter__fill { width: calc(var(--fx-risk, 0) * 100%); min-width: 4px; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a9f0cf, #fff);
    transition: width .3s ease; }
.fxe-meter__scale { display: flex; justify-content: space-between; gap: 8px; margin: -8px 0 0; font-size: 11px; opacity: .75; }

/* Compounding: growth curve + period ledger. */
.fxe-growth { margin: 0; }
.fxe-growth svg { display: block; width: 100%; height: 110px; }
.fxe-growth__area { fill: rgba(255, 255, 255, .16); }
.fxe-growth__line { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; }
[data-direction="down"] .fxe-growth__line { stroke: #ffc2c2; }
.fxe-growth figcaption { margin-top: 6px; font-size: 11px; opacity: .75; }
.fxe-ledger { grid-column: 1 / -1; border: 1px solid var(--fxe-line); border-radius: 14px; background: #fff; }
.fxe-ledger[hidden] { display: none; }
.fxe-ledger summary { padding: 14px 16px; font-weight: 600; cursor: pointer; }
.fxe-ledger__scroll { max-height: 360px; overflow: auto; border-top: 1px solid var(--fxe-line); }
.fxe-ledger table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.fxe-ledger th { position: sticky; top: 0; padding: 10px 16px; background: var(--fxe-soft); color: var(--fxe-muted); font-size: 12px; font-weight: 600; text-align: right; }
.fxe-ledger td { padding: 9px 16px; border-top: 1px solid var(--fxe-line); text-align: right; white-space: nowrap; }
.fxe-ledger th:first-child, .fxe-ledger td:first-child { text-align: left; }

/* Leverage: log ruler from 1:1 to 1:3000. */
.fxe-ruler { padding: 4px 0 2px; }
.fxe-ruler__track { position: relative; height: 6px; border-radius: 99px; background: linear-gradient(90deg, rgba(255,255,255,.25), rgba(255,255,255,.6)); }
.fxe-ruler__pin { position: absolute; top: 50%; left: calc(var(--fx-leverage, 0) * 100%); width: 18px; height: 18px; border: 3px solid #fff;
    border-radius: 50%; background: #26318a; transform: translate(-50%, -50%); transition: left .3s ease; }
.fxe-ruler__ticks { position: relative; height: 18px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 10px; opacity: .8; }
.fxe-ruler__ticks li { position: absolute; left: calc(var(--at) * 100%); transform: translateX(-50%); white-space: nowrap; }
.fxe-ruler__ticks li:first-child { transform: none; }
.fxe-ruler__ticks li:last-child { transform: translateX(-100%); }

/* Margin call: red (stop out) / amber (margin call) / green zones with the current level pinned. */
.fxe-state { margin: -4px 0 0; }
.fxe-state span { display: none; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
[data-state="safe"] .fxe-state [data-state-text="safe"] { display: inline-block; background: #c9f5df; color: #0d5c3a; }
[data-state="call"] .fxe-state [data-state-text="call"] { display: inline-block; background: #ffe6a8; color: #6b4600; }
[data-state="stopout"] .fxe-state [data-state-text="stopout"] { display: inline-block; background: #ffd0d0; color: #8a1414; }
.fxe-zones { position: relative; height: 12px; margin: 26px 0 4px; border-radius: 99px;
    background: linear-gradient(90deg, #ff8a8a 0 calc(var(--fx-stopout, 0) * 100%), #ffd36e 0 calc(var(--fx-call, 0) * 100%), #8ff0c0 0); }
.fxe-zones__mark { position: absolute; bottom: calc(100% + 4px); font-size: 10px; white-space: nowrap; transform: translateX(-50%); opacity: .9; }
.fxe-zones__mark::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 18px; background: rgba(255, 255, 255, .8); }
.fxe-zones__mark--stopout { left: calc(var(--fx-stopout, 0) * 100%); }
.fxe-zones__mark--call { left: calc(var(--fx-call, 0) * 100%); }
.fxe-zones__level { position: absolute; top: 50%; left: calc(var(--fx-level, 0) * 100%); width: 20px; height: 20px; border: 3px solid #26318a;
    border-radius: 50%; background: #fff; transform: translate(-50%, -50%); transition: left .3s ease; }

/* Risk of ruin: badge + two probability gauges on a 0–100% track. */
[data-state="low"] .fxe-state [data-state-text="low"] { display: inline-block; background: #c9f5df; color: #0d5c3a; }
[data-state="medium"] .fxe-state [data-state-text="medium"] { display: inline-block; background: #ffe6a8; color: #6b4600; }
[data-state="high"] .fxe-state [data-state-text="high"] { display: inline-block; background: #ffd0d0; color: #8a1414; }
.fxe-odds { display: grid; gap: 14px; }
.fxe-odds__row p { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px; font-size: 13px; }
.fxe-odds__row p b { font-variant-numeric: tabular-nums; }
.fxe-odds__track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.fxe-odds__track span { display: block; min-width: 3px; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd36e, #ff8a8a); transition: width .3s ease; }
.fxe-odds__row small { display: block; margin-top: 6px; font-size: 11px; line-height: 1.45; opacity: .8; }
.fxe-odds__row small b { font-weight: 600; }

.fxe-calc-formula { padding: 20px 24px; border-left: 3px solid var(--fxe-accent); border-radius: 0 14px 14px 0; background: var(--fxe-soft); }
.fxe-calc-formula pre { margin: 10px 0 0; font: 13px/1.8 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--fxe-ink); white-space: pre-wrap; }
.fxe-calc-notes { display: grid; gap: 24px; }
@media (min-width: 768px) { .fxe-calc-notes { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
.fxe-calc-notes section { display: flex; flex-direction: column; gap: 8px; }
.fxe-calc-more ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.fxe-calc-more a { display: inline-flex; min-height: 40px; align-items: center; padding: 0 14px; border: 1px solid var(--fxe-line); border-radius: 99px;
    font-size: 14px; color: var(--fxe-ink); transition: border-color .2s, color .2s; }
.fxe-calc-more a:hover, .fxe-calc-more a:focus-visible { border-color: var(--fxe-accent); color: var(--fxe-accent); }

@media (prefers-reduced-motion: reduce) { .fxe-calc-page * { transition: none !important; } }
