/* The 0DTE backtest app: the manual's palette and shell (top bar, a sticky left pane with the controls, the results on the
   right); system sans for the UI, no framework, no external fonts (the site's CSP is default-src 'self'). */
:root { --ink: #1c1f24; --muted: #5f6670; --rule: #d9dde3; --paper: #fbfaf7; --panel: #f1f3f6; --white: #ffffff; --navy: #1f3a5f; --orange: #d9711c; --pos: #2e7d5b; --neg: #b23a3a; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--paper); line-height: 1.45; font-size: 16px; font-variant-numeric: lining-nums tabular-nums; }

.top { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--rule); font-size: .85rem; }
.top .in { max-width: 1420px; margin: 0 auto; padding: .55rem 1.2rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.top .book { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--navy); }
.lang { display: flex; gap: 6px; }
.flag { padding: 3px; border: 2px solid transparent; border-radius: 6px; background: transparent; line-height: 0; cursor: pointer; opacity: .55; }
.flag.active { border-color: var(--navy); opacity: 1; }
.flag:hover { opacity: 1; }

.layout { max-width: 1420px; margin: 0 auto; padding: 0 16px 40px; }
.side { padding: 18px 0 10px; border-bottom: 1px solid var(--rule); }
main { min-width: 0; }
header h1 { font-size: 26px; margin: 22px 0 6px; color: var(--navy); }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
@media (min-width: 1024px) {
  .layout { display: grid; grid-template-columns: 19rem minmax(0, 1080px); gap: 0 1.8rem; justify-content: center; padding: 0 1.2rem 40px; }
  .side { position: sticky; top: 2.65rem; align-self: start; max-height: calc(100vh - 2.65rem); overflow-y: auto; scrollbar-width: thin; padding: 1.2rem 1rem 2rem 0; border-right: 1px solid var(--rule); border-bottom: none; }
}

/* the controls */
.field { margin-bottom: 15px; }
.field .name { font-size: .78rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); margin-bottom: 5px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { flex: 1 1 auto; padding: 6px 8px; font-size: .86rem; border: 1px solid var(--rule); border-radius: 5px; background: var(--white); color: var(--ink); cursor: pointer; }
.seg button:hover { border-color: var(--navy); }
.seg button[aria-checked="true"] { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
input[type="range"] { display: block; width: 100%; margin: 8px 0 0; accent-color: var(--navy); cursor: pointer; }
.ticks { display: flex; justify-content: space-between; margin: 0 -4px; }
.ticks button { background: none; border: none; padding: 2px 4px; font-size: .78rem; color: var(--muted); cursor: pointer; }
.ticks button:hover { color: var(--navy); }
.ticks button.on { color: var(--navy); font-weight: 700; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
button { font: inherit; border-radius: 6px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--rule); background: var(--white); color: var(--ink); }
button.primary { background: var(--orange); color: #fff; border-color: var(--orange); font-weight: 700; }
button.primary[disabled] { opacity: .6; cursor: default; }
button.secondary:hover { background: var(--panel); }
.progress { margin-top: 16px; }
.bar { height: 8px; background: var(--panel); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--navy); transition: width .25s linear; }
.stage { font-size: 14px; color: var(--muted); margin-top: 6px; min-height: 1.4em; }
.error { color: var(--neg); margin: 12px 0 0; }

/* the results */
#results { margin-top: 10px; }
#results h2 { font-size: 22px; margin: 0 0 4px; }
#results h3 { font-size: 16px; margin: 22px 0 8px; }
.settings { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--white); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 20px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.card .v.pos { color: var(--pos); }
.card .v.neg { color: var(--neg); }
.chart { background: var(--white); border: 1px solid var(--rule); border-radius: 10px; padding: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .readout { font-size: 13px; color: var(--muted); padding: 4px 6px 0; min-height: 1.4em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .two { grid-template-columns: 1fr; } }
table { border-collapse: collapse; width: 100%; background: var(--white); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; font-size: 14px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { background: var(--panel); font-weight: 600; color: var(--muted); font-size: 12px; }
td.pos { color: var(--pos); } td.neg { color: var(--neg); }
.heat-wrap { overflow-x: auto; }
.heat td, .heat th { text-align: center; padding: 5px 4px; font-size: 12px; min-width: 52px; }
.heat td.cell { color: var(--ink); }
.heat td.p1 { background: rgba(46, 125, 91, .14); } .heat td.p2 { background: rgba(46, 125, 91, .28); } .heat td.p3 { background: rgba(46, 125, 91, .42); } .heat td.p4 { background: rgba(46, 125, 91, .56); } .heat td.p5 { background: rgba(46, 125, 91, .70); color: #fff; }
.heat td.n1 { background: rgba(178, 58, 58, .14); } .heat td.n2 { background: rgba(178, 58, 58, .28); } .heat td.n3 { background: rgba(178, 58, 58, .42); } .heat td.n4 { background: rgba(178, 58, 58, .56); } .heat td.n5 { background: rgba(178, 58, 58, .70); color: #fff; }
.share { margin-top: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.copied { color: var(--pos); font-size: 14px; }
.course { margin-top: 14px; }
a { color: var(--navy); }
footer { margin-top: 36px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--rule); padding-top: 12px; }
footer .small { font-size: 12px; }
