/* Layout: form column + sticky summary. Each section is one money-management decision,
   introduced by an MT5-style line label, with a live example under every control. */
:root {
  color-scheme: dark;
  --bg: #0a0e14; --bg-2: #0d121a; --surface: #121821; --surface-2: #19202b;
  --line: #222b38; --line-2: #2d3746;
  --fg: #e8edf4; --fg-2: #a6b1c1; --fg-3: #6f7b8e;
  --blue: #3a86f0; --blue-soft: #12233a; --tp: #2fbf7f; --sl: #ef5b5b; --gold: #e2b23c;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-num: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 12px;
}
html[lang="fa"] { --f-body: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; --f-num: "Vazirmatn", Tahoma, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); color: var(--fg); }
body { margin: 0; font: 400 16px/1.8 var(--f-body); -webkit-font-smoothing: antialiased; }
html[lang="fa"] body { line-height: 1.85; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
html[lang="fa"] .num { font-weight: 700; }
.wrap { max-width: 1160px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
h1, h2, h3 { margin: 0; font-weight: 700; text-wrap: balance; }
html[lang="fa"] h1, html[lang="fa"] h2, html[lang="fa"] h3 { font-weight: 800; }
p { margin: 0; }

.top { border-bottom: 1px solid var(--line); background: rgba(10, 14, 20, .92); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; backdrop-filter: blur(10px); }
.top .wrap { display: flex; align-items: center; gap: 14px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1.05rem/1 "IBM Plex Sans", sans-serif; direction: ltr; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; flex: none; display: block; }
.steps-mini { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--fg-3); }
.steps-mini .on { color: var(--blue); font-weight: 700; }
.steps-mini i { width: 18px; height: 2px; background: var(--line-2); display: inline-block; }
.lang { font: 500 .8rem/1 var(--f-body); color: var(--fg-2); background: none; border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; cursor: pointer; }
.lang:hover { color: var(--fg); border-color: var(--fg-3); }
html[lang="en"] .lang { font-family: "Vazirmatn", Tahoma, sans-serif; }
html[lang="fa"] .lang { font-family: "IBM Plex Sans", sans-serif; }
@media (max-width: 560px) { .steps-mini { display: none; } .lang { margin-inline-start: auto; } }

.intro { padding-block: clamp(28px, 5vw, 48px) 20px; display: grid; gap: 12px; max-width: 720px; }
.kicker { color: var(--blue); font-weight: 700; font-size: .95rem; }
.intro h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); line-height: 1.3; }
html[lang="fa"] .intro h1 { line-height: 1.45; }
.intro p { color: var(--fg-2); font-size: 1.05rem; }
.lock-note { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid rgba(226, 178, 60, .45); background: rgba(42, 33, 16, .5); color: #ffe08a; border-radius: 999px; font-size: .88rem; justify-self: start; }
.lock-note svg { width: 16px; height: 16px; flex: none; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; padding-bottom: 120px; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
form { display: grid; gap: 18px; min-width: 0; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(18px, 3vw, 26px); display: grid; gap: 18px; }
.sec-h { display: grid; gap: 4px; }
.eyebrow { display: flex; align-items: center; gap: 10px; font: 600 .74rem/1 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--c, var(--blue)); }
.eyebrow::after { content: ""; flex: 1; border-top: 1.5px dashed currentColor; opacity: .5; }
.eyebrow b { border: 1px solid currentColor; border-radius: 3px; padding: 5px 7px; font-weight: 600; direction: ltr; }
.sec h2 { font-size: 1.25rem; }
.sec-h p { color: var(--fg-3); font-size: .92rem; }

.field { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; padding-top: 0; }
.f-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.f-row > label, .f-row > .lbl { font-weight: 700; font-size: 1rem; }
.hint { color: var(--fg-2); font-size: .92rem; }
.ex { color: var(--fg-3); font-size: .88rem; }
.ex b, .ex .num { color: var(--fg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.txt { display: grid; gap: 6px; }
.txt label { font-weight: 700; font-size: .95rem; }
.txt input { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--fg); font: 500 1rem/1 var(--f-mono); direction: ltr; text-align: left; }
.txt input#bal { font-family: var(--f-num); }
.txt input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(58, 134, 240, .2); }
.txt input[aria-invalid="true"] { border-color: var(--sl); }
.txt small { color: var(--fg-3); font-size: .82rem; }
.txt small.err { color: #ff8a8a; }

.numbox { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 3px; direction: ltr; }
.numbox button { width: 34px; height: 34px; border: 0; border-radius: 7px; background: var(--surface-2); color: var(--fg); font: 600 1.1rem/1 var(--f-mono); cursor: pointer; }
.numbox button:hover { background: #222b38; }
.numbox input { width: 58px; height: 34px; border: 0; background: transparent; color: var(--fg); text-align: center; font: 700 1.15rem/1 var(--f-num); }
.numbox .unit { color: var(--fg-3); font: 500 .9rem/1 var(--f-num); padding-inline-end: 8px; }
.numbox .unit:empty { display: none; }
input[type="range"] { width: 100%; accent-color: var(--blue); height: 26px; }
.f-risk input[type="range"], .f-loss input[type="range"] { accent-color: var(--sl); }
.f-profit input[type="range"] { accent-color: var(--tp); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; min-width: 72px; min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg-2); font: 600 .95rem/1 var(--f-num); cursor: pointer; }
.seg input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: #cfe2ff; box-shadow: inset 0 0 0 1px var(--blue); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.sw { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; flex: none; }
.sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw i { width: 50px; height: 28px; border-radius: 999px; background: #2a323e; border: 1px solid var(--line-2); position: relative; transition: background .2s; }
.sw i::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #9aa6b8; transition: transform .2s, background .2s; }
.sw input:checked + i { background: var(--tp); border-color: var(--tp); }
.sw input:checked + i::after { transform: translateX(22px); background: #fff; }
html[dir="rtl"] .sw input:checked + i::after { transform: translateX(-22px); }
.sw input:focus-visible + i { outline: 2px solid var(--blue); outline-offset: 2px; }
.sw em { font-style: normal; font-size: .85rem; color: var(--fg-3); min-width: 42px; }
.sub { display: grid; gap: 8px; padding: 14px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--line-2); }
.badge-on { font-size: .8rem; font-weight: 700; color: var(--tp); border: 1px solid rgba(47, 191, 127, .5); border-radius: 999px; padding: 4px 10px; }
.news { margin-top: 4px; padding: 14px; border: 1px solid rgba(226, 178, 60, .4); border-radius: 10px; background: rgba(42, 33, 16, .45); }
.news .hint b { color: #ffe08a; }

.plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 700px) { .plans { grid-template-columns: repeat(2, 1fr); } }
.plan { position: relative; }
.plan input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.plan span { display: grid; gap: 2px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; }
.plan b { font-weight: 700; font-size: .95rem; }
.plan small { font: 700 1.05rem/1.3 var(--f-num); color: var(--fg-2); }
.plan input:checked + span { border-color: var(--gold); background: rgba(42, 33, 16, .6); box-shadow: inset 0 0 0 1px var(--gold); }
.plan input:checked + span small { color: var(--gold); }
.plan input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.plan input:disabled + span { opacity: .45; cursor: not-allowed; transform: none; }

aside { position: sticky; top: 74px; display: grid; gap: 14px; min-width: 0; }
@media (max-width: 980px) { aside { position: static; } }
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; }
.card h3 { font-size: 1.05rem; }
.sum { margin: 0; }
.sum div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.sum div:first-child { border-top: 0; }
.sum dt { color: var(--fg-3); }
.sum dd { margin: 0; font-weight: 700; text-align: end; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 10px 12px; border-radius: 9px; font-size: .88rem; line-height: 1.7; border: 1px solid; }
.checks li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; margin-top: .6em; }
.checks .e { border-color: rgba(239, 91, 91, .55); background: rgba(239, 91, 91, .1); color: #ffc4c4; } .checks .e::before { background: var(--sl); }
.checks .w { border-color: rgba(226, 178, 60, .45); background: rgba(42, 33, 16, .55); color: #ffe6a8; } .checks .w::before { background: var(--gold); }
.checks .i { border-color: rgba(58, 134, 240, .35); background: rgba(18, 35, 58, .55); color: #cfe2ff; } .checks .i::before { background: var(--blue); }
.checks .ok { border-color: rgba(47, 191, 127, .4); background: rgba(10, 40, 26, .5); color: #b5f0d1; } .checks .ok::before { background: var(--tp); }
.agree { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: .88rem; color: var(--fg-2); cursor: pointer; }
.agree input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--gold); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 20px; border-radius: 10px; border: 0; background: var(--blue); color: #fff; font: 700 1rem/1 var(--f-body); cursor: pointer; width: 100%; }
.btn:hover { background: #4a92f5; }
.btn:disabled { background: #273141; color: #6f7b8e; cursor: not-allowed; }
.fine { font-size: .8rem; color: var(--fg-3); }
.plans-state { min-height: 1.5em; color: var(--fg-3); font-size: .86rem; }
.plans-state.err, .submit-error, .server-error { color: #ff8a8a; }
.server-error:empty { display: none; }
.server-warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.server-warnings li { padding: 9px 11px; border-radius: 8px; border: 1px solid rgba(226, 178, 60, .45); background: rgba(42, 33, 16, .55); color: #ffe6a8; font-size: .86rem; }
.submit-error { margin: 0; padding: 10px 12px; border: 1px solid rgba(239, 91, 91, .55); background: rgba(239, 91, 91, .1); border-radius: 9px; font-size: .88rem; }
.renew-binding { display: grid; gap: 8px; padding: 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-2); }
.change-badge { margin: 0 0 12px; padding: 10px 12px; border-radius: 9px; font-size: .86rem; font-weight: 600; }
.change-badge.tighten { border: 1px solid rgba(47, 191, 127, .45); background: rgba(10, 40, 26, .5); color: #b5f0d1; }
.change-badge.loosen { border: 1px solid rgba(226, 178, 60, .45); background: rgba(42, 33, 16, .55); color: #ffe6a8; }
.renew-binding div { display: flex; justify-content: space-between; gap: 18px; }
.renew-binding span { color: var(--fg-3); }
.renew-binding b { direction: ltr; unicode-bidi: isolate; }
.server-invalid { border-color: rgba(239, 91, 91, .65); }
.done .success-meta { display: grid; gap: 5px; width: 100%; padding: 12px; border-radius: 9px; background: var(--bg-2); direction: ltr; font-family: var(--f-mono); }
.done { border-color: rgba(47, 191, 127, .5); }
.done p { color: var(--fg-2); font-size: .92rem; }

.site-footer { border-top: 1px solid var(--line); margin-top: 20px; padding-block: 24px 90px; display: flex; gap: 8px 18px; flex-wrap: wrap; justify-content: center; font-size: .86rem; color: var(--fg-3); }
.site-footer a { color: var(--fg-3); text-decoration: none; }
.site-footer a:hover { color: var(--fg); }

.bar { display: none; }
.bar[hidden] { display: none; }
@media (max-width: 980px) {
  .bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 12px; align-items: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: rgba(13, 18, 26, .96); border-top: 1px solid var(--line-2); backdrop-filter: blur(8px); }
  .bar span { flex: 1; font-size: .85rem; color: var(--fg-2); }
  .bar .btn { width: auto; min-height: 44px; }
}

/* ---------- livelier layer */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(40% 35% at 85% 0%, rgba(58, 134, 240, .18), transparent 70%),
              radial-gradient(35% 30% at 5% 40%, rgba(193, 140, 255, .10), transparent 70%),
              radial-gradient(40% 30% at 70% 100%, rgba(47, 191, 127, .10), transparent 70%); }
html, body { background-color: var(--bg); }
body { background: transparent; }
.intro h1 { background: linear-gradient(90deg, #fff, #cfe2ff 55%, #ffe08a); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[dir="rtl"] .intro h1 { background: linear-gradient(270deg, #fff, #cfe2ff 55%, #ffe08a); -webkit-background-clip: text; background-clip: text; }
.sec { position: relative; overflow: hidden; transition: border-color .25s; }
.sec::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, transparent, var(--c, var(--blue)), transparent); opacity: .8; }
.sec:focus-within { border-color: color-mix(in srgb, var(--c, var(--blue)) 45%, var(--line)); }
.sec-t { display: flex; align-items: center; gap: 12px; }
.ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--ic); background: color-mix(in srgb, var(--ic) 16%, transparent); border: 1px solid color-mix(in srgb, var(--ic) 40%, transparent); flex: none; }
.ic svg { width: 21px; height: 21px; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .presets { grid-template-columns: 1fr; } }
.preset { display: grid; gap: 6px; justify-items: start; text-align: start; padding: 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg); cursor: pointer; font: inherit; transition: transform .18s, border-color .2s, box-shadow .2s, background .2s; }
.preset:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--pc) 55%, var(--line-2)); }
.preset .pi { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--pc); background: color-mix(in srgb, var(--pc) 16%, transparent); }
.preset .pi svg { width: 22px; height: 22px; }
.preset b { font-size: 1.05rem; }
.preset small { color: var(--fg-3); font-size: .85rem; line-height: 1.6; }
.preset .pv { font-style: normal; font: 600 .8rem/1.4 var(--f-num); color: var(--fg-2); }
.preset.is-on { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 10%, var(--bg-2)); box-shadow: 0 10px 30px -14px var(--pc), inset 0 0 0 1px var(--pc); }
.preset.is-on .pi { background: var(--pc); color: #0b0f15; }
.plan span { transition: transform .18s, border-color .2s; }
.plan:hover span { transform: translateY(-2px); }
.numbox input.pop, .g-val b.pop { animation: pop .35s ease-out; }
@keyframes pop { 40% { transform: scale(1.18); color: #fff; } }
.checks li { animation: slidein .3s ease-out both; }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } }
.sw i::after { transition: transform .28s cubic-bezier(.3, 1.6, .5, 1), background .2s; }
.btn:not(:disabled) { background: linear-gradient(135deg, #3a86f0, #5b6cff); box-shadow: 0 10px 26px -12px #3a86f0; transition: transform .15s, box-shadow .2s; }
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 14px 30px -12px #5b6cff; }
.gauge-card { grid-template-columns: auto 1fr; align-items: center; gap: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--gc, var(--tp)) 12%, var(--surface)), var(--surface) 65%); border-color: color-mix(in srgb, var(--gc, var(--tp)) 40%, var(--line-2)); transition: background .4s, border-color .4s; }
.gauge { position: relative; width: 96px; height: 96px; }
.gauge svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.g-bg { fill: none; stroke: #222b38; stroke-width: 11; }
.g-fg { fill: none; stroke: var(--gc, var(--tp)); stroke-width: 11; stroke-linecap: round; stroke-dasharray: 314.16; stroke-dashoffset: 314.16; transition: stroke-dashoffset .6s cubic-bezier(.3, .8, .3, 1), stroke .4s; }
.g-val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.g-val b { font: 700 1.6rem/1 var(--f-num); color: var(--fg); display: inline-block; }
.g-val span { font-size: .7rem; color: var(--fg-3); }
.g-txt { display: grid; gap: 3px; min-width: 0; }
.g-k { font-size: .8rem; color: var(--fg-3); }
#g-label { font-size: 1.1rem; color: var(--gc, var(--tp)); }
#g-msg { font-size: .84rem; color: var(--fg-2); line-height: 1.6; }
.done { justify-items: center; text-align: center; animation: slidein .4s ease-out both; }
.done-ic { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--tp); color: #06160e; box-shadow: 0 0 0 8px rgba(47, 191, 127, .15); }
.done-ic svg { width: 30px; height: 30px; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s .15s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
