:root {
    color-scheme: dark;
    --bg: #0b1220;
    --sidebar: #101a2b;
    --panel: #142136;
    --deep: #111d2f;
    --line: #26364d;
    --line-soft: #223148;
    --text: #f1f5fb;
    --muted: #a0b1ca;
    --muted-strong: #becbe0;
    --blue: #78a7ff;
    --button: #3266d9;
    --green: #69dbac;
    --red: #ff969f;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
a:hover { color: #b8d0ff; }
button, input, select { font: inherit; }
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    border: 1px solid transparent; border-radius: 8px; padding: .7rem 1.05rem; cursor: pointer;
    background: var(--button); color: #fff; font-weight: 650; min-height: 40px;
}
button:hover, .button:hover { background: #477be9; color: #fff; }
button:disabled { opacity: .52; cursor: wait; }
.secondary { border-color: #344a69; background: #1b2b44; color: #dce8ff; }
.secondary:hover { background: #283e61; }
.danger { background: #3d2637; border-color: #6b394a; color: #ffc0c7; }
.danger:hover { background: #633144; }
.text-button { background: transparent; color: var(--muted-strong); padding: .35rem .45rem; min-height: 34px; }
.text-button:hover { background: #21304a; }
:focus-visible { outline: 2px solid #8fb5ff; outline-offset: 3px; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: clamp(2rem, 3vw, 2.6rem); letter-spacing: -.043em; line-height: 1.12; font-weight: 720; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; font-weight: 680; }
h3 { font-size: 1rem; }
p { color: var(--muted); line-height: 1.55; margin: .6rem 0; }
small, .micro { color: var(--muted); font-size: .79rem; }
.muted { color: var(--muted); }
.positive { color: var(--green); }
.break { overflow-wrap: anywhere; }
.skip { position: fixed; z-index: 20; top: 8px; left: 12px; transform: translateY(-180%); padding: .6rem; background: var(--bg); }
.skip:focus { transform: none; }
.eyebrow { margin: 0 0 .55rem; color: var(--blue); text-transform: uppercase; font-size: .72rem; letter-spacing: .15em; font-weight: 750; }
.shell { display: grid; grid-template-columns: 235px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: var(--sidebar); border-right: 1px solid var(--line-soft); position: sticky; top: 0;
    height: 100dvh; display: flex; flex-direction: column; padding: 1.35rem .85rem .85rem;
}
.sidebar nav { overflow-y: auto; min-height: 0; padding: 0 .18rem .5rem; scrollbar-width: thin; }
.brand-link { display: block; margin: 0 .45rem 1.25rem; color: var(--text); }
.brand {
    display: flex; align-items: center; gap: .7rem; font-weight: 740;
    font-size: 1.13rem; letter-spacing: -.035em; line-height: 1.12; overflow-wrap: anywhere;
}
.brand small { display: block; color: var(--muted); margin-top: .35rem; font-size: .57rem; letter-spacing: .16em; font-weight: 760; }
.brand img, .brand-mark { width: 39px; height: 39px; flex: 0 0 39px; object-fit: contain; }
.brand-mark {
    background: linear-gradient(145deg, #244778, #17304f);
    border: 1px solid #35598a; display: flex; align-items: flex-end; justify-content: center; gap: 3px;
    padding: 9px 8px; border-radius: 11px; transform: none;
}
.brand-mark i { display: block; background: #83b0ff; width: 4px; height: 41%; border-radius: 1px; }
.brand-mark i:nth-child(2) { height: 69%; }
.brand-mark i:nth-child(3) { height: 100%; background: #63dcb0; }
.nav-section { color: #94a7c0; font-size: .66rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 730; margin: 1rem .65rem .42rem; }
.nav-item {
    display: flex; gap: .55rem; align-items: center; padding: .49rem .6rem;
    white-space: nowrap; border: 1px solid transparent; border-radius: 7px; color: #acbed6; font-size: .83rem;
}
.nav-item:hover { background: #192840; }
.nav-item.active { border-color: #33517e; background: #1c3457; color: #dceaff; font-weight: 650; }
.nav-item > span { flex: 0 0 16px; text-align: center; color: #7da2d6; font-size: 1.13rem; line-height: 1; }
.nav-item small { margin-left: auto; padding: .1rem .32rem; border: 1px solid #34435a; border-radius: 4px; font-size: .6rem; }
.sidebar-footer { margin-top: auto; padding: .9rem .6rem .15rem; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: .76rem; display: flex; gap: .6rem; align-items: center; }
.dot { display: inline-block; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.topbar { min-height: 62px; display: flex; justify-content: space-between; align-items: center; gap: .7rem; border-bottom: 1px solid var(--line-soft); padding: .55rem clamp(1rem, 3vw, 2.65rem); }
.crumbs, .top-controls { display: flex; gap: .75rem; align-items: center; white-space: nowrap; }
.crumbs { color: var(--muted); font-size: .84rem; }
.crumbs strong { color: var(--muted-strong); font-weight: 630; }
.top-controls .text-button { font-size: .79rem; }
.workspace-switch { display: inline-flex; align-items: center; padding: 3px; gap: 2px; border: 1px solid var(--line); background: var(--deep); border-radius: 8px; }
.workspace-option { min-width: 39px; min-height: 26px; display: grid; place-items: center; padding: .15rem .5rem; color: var(--muted); font-size: .76rem; font-weight: 650; border-radius: 5px; }
.workspace-option.current { color: #dceaff; background: #24436f; }
.workspace-option.real-funds { color: #ffd1d6; background: #653448; }
a.workspace-option:hover { color: var(--text); background: #263b59; }
.workspace-option.unavailable { color: var(--muted); opacity: .63; }
.avatar { border-radius: 50%; color: #bdd5ff; background: #223954; width: 31px; height: 31px; display: grid; place-items: center; font-weight: 760; }
.icon-button { display: none; background: #1c2d46; padding: .3rem .6rem; min-height: 33px; }
.content { max-width: 1660px; margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 2.65rem) 3rem; display: grid; gap: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .32rem; }
.page-head p:last-child { margin-bottom: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; min-width: 0; }
.compact { padding: 1.18rem 1.24rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.metric { padding: .93rem 1.08rem 1.1rem; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: .35rem; font-size: .84rem; color: var(--muted-strong); }
.metric-icon { display: grid; place-items: center; width: 27px; height: 27px; flex-shrink: 0; border-radius: 7px; background: #1e3454; color: #8eb7ff; font-size: 1rem; }
.metric > strong { display: block; margin: .44rem 0 .36rem; font-size: clamp(1.38rem, 2.15vw, 2rem); letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.metric small { display: block; line-height: 1.36; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 2.03fr) minmax(278px, 1fr); gap: 1rem; align-items: start; }
.side-stack { display: grid; gap: 1rem; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.12rem 1.2rem .75rem; }
.instrument { display: flex; gap: .72rem; align-items: center; }
.instrument h2 { font-size: 1.3rem; letter-spacing: -.042em; }
.instrument p { margin: .05rem 0 0; font-size: .77rem; }
.pair-icon { display: flex; align-items: center; color: #dce7ff; }
.pair-icon i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-style: normal; font-weight: 750; background: #23518e; border: 2px solid #182946; }
.pair-icon i + i { background: #1c534c; color: #acf3cd; margin-left: -6px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); background: var(--deep); border-radius: 8px; }
.segmented button { min-height: 29px; padding: .22rem .6rem; background: transparent; border-radius: 5px; font-size: .75rem; color: var(--muted); }
.segmented button[aria-pressed="true"] { color: #dceaff; background: #24436f; }
.chart-summary { display: flex; align-items: center; gap: 1.4rem; padding: .35rem 1.2rem .95rem; }
.chart-summary > div:not(.help-label) { display: grid; gap: .25rem; }
.chart-summary > div > .help-label > span { color: var(--muted); font-size: .72rem; }
.chart-summary > div > strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.chart-summary > .help-label:last-child { margin-left: auto; }
.chart-area { position: relative; overflow: hidden; height: 296px; background: var(--deep); border-block: 1px solid var(--line-soft); }
.wide-chart .chart-area { height: clamp(325px, 60vh, 620px); }
.chart-canvas { width: 100%; height: 100%; visibility: hidden; }
.chart-area.has-data .chart-canvas { visibility: visible; }
.chart-empty {
    position: absolute; inset: 0; display: grid; gap: .55rem; place-content: center; justify-items: center; text-align: center;
    padding: 1rem; background-image: linear-gradient(#20304a65 1px, transparent 1px), linear-gradient(90deg, #20304a65 1px, transparent 1px);
    background-size: 100% 48px, 64px 100%;
}
.chart-area.has-data .chart-empty { display: none; }
.empty-icon, .small-empty > span { background: #1b2e49; color: #8bb4ff; border: 1px solid #2b4469; border-radius: 11px; display: grid; place-items: center; }
.empty-icon { font-size: 1.5rem; width: 41px; height: 41px; margin-bottom: .12rem; }
.chart-empty strong, .small-empty strong { font-size: .95rem; }
.chart-footer { padding: .7rem 1.1rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; color: var(--muted); font-size: .7rem; }
.chart-footer .dot { margin-right: .25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: .8rem; }
.badge {
    display: inline-flex; align-items: center; gap: .4rem; border: 1px solid #344764; background: #1c2b43; color: #b9c9df;
    border-radius: 6px; padding: .2rem .48rem; font-size: .69rem; line-height: 1.22; font-weight: 650; white-space: nowrap;
}
.badge.good { color: #86e6bd; background: #193b38; border-color: #2b6053; }
.badge.bad { color: var(--red); background: #3c2538; border-color: #684258; }
.badge.blue, .badge.environment { color: #a9c6ff; background: #192e4d; border-color: #345686; }
.badge.environment .dot, .sidebar-footer .dot { color: var(--green); }
.status-grid, .details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 0 .65rem; margin: .38rem 0 .9rem; }
.status-grid dt, .status-grid dd, .details dt, .details dd { border-bottom: 1px solid var(--line-soft); margin: 0; padding: .53rem 0; font-size: .8rem; }
.status-grid dt, .details dt { color: var(--muted); }
.status-grid dd, .details dd { text-align: right; overflow-wrap: anywhere; max-width: min(32ch, 100%); }
.subtle-link { font-weight: 640; font-size: .8rem; }
.lower-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.settings-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.lower-grid.inset { gap: 2rem; }
.small-empty { display: flex; gap: .75rem; align-items: center; color: var(--muted); margin: .65rem 0 1rem; min-height: 54px; }
.small-empty > span { flex: 0 0 33px; height: 33px; font-size: 1.06rem; }
.small-empty p { font-size: .83rem; margin: .22rem 0; }
.table-scroll { overflow: auto; max-height: 520px; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { padding: .63rem .55rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
th { font-size: .71rem; color: var(--muted); font-weight: 620; white-space: nowrap; background: var(--deep); position: sticky; top: 0; }
td small { display: block; margin-top: .25rem; min-width: 10ch; }
.lower-grid td:first-child { white-space: nowrap; }
td details { min-width: 100px; }
summary { color: var(--blue); cursor: pointer; user-select: none; }
details ul { color: var(--muted-strong); padding-left: 1.15rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; padding: .35rem; border: 1px solid var(--line); border-radius: 10px; background: var(--deep); }
.tabs a { border-radius: 7px; padding: .47rem .68rem; color: var(--muted-strong); font-size: .84rem; }
.tabs a:hover { background: #1d304d; }
.tabs a.active { color: #d5e4ff; background: #233e66; }
.field { display: grid; gap: .35rem; margin: .5rem 0 .92rem; min-width: 0; }
.field-caption { position: relative; display: flex; align-items: center; justify-content: space-between; gap: .45rem; }
.field-caption > label { font-size: .79rem; color: var(--muted-strong); font-weight: 610; }
.section-help { position: relative; }
.help-label { position: relative; display: flex; align-items: center; gap: .28rem; }
.help-popup { flex: none; }
.help-popup > summary { display: grid; place-items: center; list-style: none; width: 28px; height: 28px; color: var(--blue); border-radius: 6px; }
.help-popup > summary::-webkit-details-marker { display: none; }
.help-popup > summary:hover, .help-popup[open] > summary { background: #263c5a; }
.help-popup > summary > span { display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%; font-size: .71rem; font-weight: 700; line-height: 1; }
.help-panel {
    position: absolute; z-index: 12; inset-inline-end: 0; top: calc(100% + 6px);
    width: min(340px, calc(100vw - 24px)); max-height: min(70vh, 460px); overflow: auto;
    padding: .9rem; color: var(--muted-strong); background: #17263b; border: 1px solid #45638a;
    box-shadow: 0 12px 28px #050a13cc; border-radius: 9px; font-size: .82rem; line-height: 1.45;
}
.help-panel.positioned { position: fixed; inset: auto; z-index: 18; white-space: normal; }
.help-panel strong { color: var(--text); font-size: .9rem; }
.help-panel ol, .help-panel ul { padding-inline-start: 1.1rem; margin: .55rem 0 0; }
.help-panel li + li { margin-top: .35rem; }
.help-panel p { margin: .55rem 0 0; color: var(--muted-strong); }
.help-panel a { text-decoration: underline; text-underline-offset: 2px; }
input:not([type=checkbox]), select { width: 100%; min-height: 39px; background: #0e1a2c; border: 1px solid #38506e; border-radius: 7px; padding: .48rem .62rem; color: var(--text); }
input[readonly] { color: var(--muted); }
input[type=file] { font-size: .74rem; }
input::file-selector-button { color: var(--text); background: #263b59; border: 0; padding: .22rem .42rem; border-radius: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .85rem; }
.check, .button-row { display: flex; align-items: center; gap: .6rem; }
.check { color: var(--muted-strong); font-size: .86rem; padding: .25rem 0; }
.check input { width: 16px; height: 16px; accent-color: #5688f2; }
.check-group { margin: .25rem 0 1rem; }
.button-row { flex-wrap: wrap; }
.secondary-form { margin-top: .75rem; }
.notice { border: 1px solid #355984; background: #1c3556; color: #d9e8ff; padding: .7rem .9rem; border-radius: 8px; margin: 0; }
.notice.error { border-color: #85485d; background: #43293b; color: #ffd0d7; }
.notice.success { border-color: #346857; background: #193d37; color: #baf6da; }
.login-panel .notice, .setup-panel .notice { margin: .7rem 0; }
.code-block { display: block; border: 1px solid var(--line); border-radius: 6px; background: var(--deep); color: #d6e5ff; padding: .65rem; overflow-wrap: anywhere; }
.commentary { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .78rem; }
.commentary p { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.run-grid { grid-template-columns: minmax(200px, .35fr) minmax(0, 1fr); }
.run-list { display: grid; gap: .35rem; max-height: 520px; overflow: auto; }
.run-list a { display: grid; padding: .55rem .64rem; border-radius: 6px; gap: .23rem; font-size: .85rem; color: var(--muted-strong); }
.run-list a.selected, .run-list a:hover { background: #233e66; color: #d7e5ff; }
.run-list span { font-size: .74rem; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: .55rem; margin: .8rem 0; }
.result-grid > div { background: var(--deep); border: 1px solid var(--line-soft); border-radius: 7px; padding: .54rem; display: grid; gap: .3rem; }
.result-grid .help-label > span { color: var(--muted); font-size: .75rem; }
.result-grid > div > strong { font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.learning-start ol, .learning-start ul { padding-inline-start: 1.25rem; color: var(--muted-strong); }
.learning-start li + li { margin-top: .6rem; }
.learning-start a { text-decoration: underline; text-underline-offset: .2em; }
.learning-glossary > h2 { margin-bottom: .75rem; }
.learning-glossary details { border-top: 1px solid var(--line-soft); padding: .6rem 0; }
.learning-glossary details:last-child { padding-bottom: 0; }
.run-details { margin: .65rem 0; }
.equity-area { height: 235px; border: 1px solid var(--line); border-radius: 8px; }
.public-page { min-height: 100vh; background: radial-gradient(ellipse at 50% 4%, #1b3051 0%, #0c1525 45%, #0b1220 78%); padding: clamp(1.2rem, 7vw, 5rem) 1rem 3rem; }
.setup-frame { max-width: 870px; margin: 0 auto; }
.setup-frame > .brand { margin: 0 0 1.55rem; }
.setup-grid { display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: 1rem; }
.setup-steps { display: grid; align-content: start; gap: .4rem; }
.setup-steps div { padding: .55rem; display: flex; align-items: center; color: var(--muted); gap: .58rem; border: 1px solid transparent; border-radius: 8px; font-size: .85rem; }
.setup-steps div.current { border-color: #3b5985; background: #1e375a; color: #e0ebff; }
.setup-steps span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 6px; background: #243856; color: #acceff; font-size: .72rem; font-weight: 750; }
.setup-panel, .login-panel { padding: clamp(1rem, 3vw, 2.15rem); }
.setup-panel h1, .login-panel h1 { font-size: clamp(1.65rem, 4vw, 2.35rem); }
.checklist { margin: 1rem 0; }
.checklist > div { display: flex; gap: .5rem; justify-content: space-between; align-items: center; padding: .44rem 0; border-bottom: 1px solid var(--line-soft); }
.login-frame { max-width: 425px; margin: 0 auto; }
.login-brand { display: flex; justify-content: center; margin-bottom: 1.45rem; }
.login-panel form { margin-top: 1.08rem; }
.login-panel button { width: 100%; }
.login-mode { text-align: center; margin-top: 1rem; font-size: .8rem; }
.login-mode .dot { color: var(--green); }
.login-workspaces { display: flex; justify-content: center; margin-bottom: 1rem; }
@media (max-width: 1120px) {
    .shell { grid-template-columns: 205px minmax(0, 1fr); }
    .overview-grid { grid-template-columns: minmax(0, 1.65fr) minmax(245px, 1fr); }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
    .shell { display: block; }
    .sidebar { display: none; position: fixed; z-index: 9; top: 61px; left: 0; width: 254px; height: calc(100dvh - 61px); box-shadow: 14px 0 36px #070c1680; }
    .sidebar.opened { display: flex; }
    .icon-button { display: inline-flex; }
}
@media (max-width: 680px) {
    .overview-grid, .lower-grid, .settings-grid, .run-grid { grid-template-columns: minmax(0, 1fr); }
    .content { padding-top: 1.25rem; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .top-controls { gap: .25rem; }
    .top-controls .avatar, .top-controls .broker-environment, .crumbs > span { display: none; }
    .topbar { min-height: 61px; }
    .chart-summary { gap: .55rem; padding-inline: .8rem; flex-wrap: wrap; }
    .chart-summary .badge { padding-inline: .3rem; }
    .chart-area { height: 260px; }
    .setup-grid { grid-template-columns: minmax(0, 1fr); }
    .setup-steps { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .setup-steps div { display: block; text-align: center; padding: .28rem; font-size: .62rem; }
    .setup-steps span { margin: 0 auto .22rem; }
}
@media (max-width: 390px) {
    .crumbs { min-width: 0; gap: .4rem; }
    .crumbs strong { overflow: hidden; text-overflow: ellipsis; }
    .field, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .metric-head { font-size: .72rem; }
    .metric { padding-inline: .63rem; }
    .badge { font-size: .64rem; }
}

.market-picker { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; }
.market-picker .button-row { align-items: end; }
.market-picker .field { margin-bottom: 0; }
.market-picker select { max-width: min(280px, 75vw); }
