:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e6e9ef;
  --text: #1c2333;
  --muted: #6b7382;
  --primary: #1e5eff;
  --primary-soft: #eaf0ff;
  --green: #12a36a;
  --green-soft: #e6f7ef;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #d98b00;
  --amber-soft: #fff5e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --font: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 32px; }
.brand { font-weight: 700; font-size: 20px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .logo { flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.brand-sub { font-size: 12.5px; font-weight: 700; color: var(--text); opacity: 0.78; text-transform: uppercase; letter-spacing: 0.14em; margin-top: 2px; white-space: nowrap; }

.menu { position: relative; }
.menu-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; min-height: 38px; }
.menu-btn:hover { background: var(--bg); }
.menu-user { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.off { background: #b8bfcc; box-shadow: 0 0 0 3px var(--bg); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14); padding: 6px; z-index: 40; max-height: calc(100vh - 90px); overflow-y: auto; }
.menu-head { padding: 10px 12px 8px; }
.menu-title { font-weight: 600; }
.menu-sub { font-size: 12px; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text); font-size: 13px; font-weight: 500; min-height: 42px; }
.menu-item:not(.static):hover { background: var(--bg); }
.menu-item.active { background: var(--primary-soft); color: var(--primary); }
.menu-item .grow { flex: 1; display: flex; flex-direction: column; }
.menu-item small { color: var(--muted); font-size: 11px; font-weight: 400; }
.menu-ico { width: 18px; text-align: center; color: var(--muted); display: inline-flex; justify-content: center; }
.menu-item.active .menu-ico { color: var(--primary); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-nav { display: block; }
.menu-primary { display: none; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); font-weight: 500; padding: 8px 12px; border-radius: 8px; white-space: nowrap; transition: background 0.12s, color 0.12s; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.neutral { background: var(--bg); color: var(--muted); border-color: var(--border); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.tabbar { display: none; }

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.main { grid-template-columns: 2fr 1fr; align-items: start; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.pos { color: var(--green); }
.neg { color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: rgba(30, 94, 255, 0.025); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag.buy { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tag.sell { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag.open { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tag.closed { background: var(--bg); color: var(--muted); }
.tag.failed, .tag.error { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag.info, .tag.trade { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit; min-height: 36px; transition: background 0.12s; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: #174ad6; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; min-height: 30px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select.btn { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b7382' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; text-align: left; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.chart { width: 100%; height: 220px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart.tall { height: 340px; position: relative; }
.chart.payoff { height: 260px; }
.chart-tip { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 11.5px; pointer-events: none; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); white-space: nowrap; }

.strategy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.scard { display: flex; flex-direction: column; gap: 12px; }
.scard .title { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.scard .desc { color: var(--muted); font-size: 13px; min-height: 58px; }
.scard .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.scard .metrics .label { font-size: 11px; color: var(--muted); }
.scard .metrics .value { font-weight: 600; }
.scard .under { display: flex; flex-wrap: wrap; gap: 4px; }

.form { display: grid; gap: 12px; }
.form label { font-size: 12px; color: var(--muted); font-weight: 500; display: block; margin-bottom: 4px; }
.form input, .form select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); min-height: 42px; }
.form input:focus, .form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card .brand-name { font-size: 26px; }
.login-card .brand-sub { font-size: 15px; }
.login-card p.lead { text-align: center; color: var(--muted); margin: 0 0 24px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; overflow-wrap: anywhere; }
.alert.error { background: var(--red-soft); color: var(--red); }
.alert.warn { background: var(--amber-soft); color: var(--amber); }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.info { background: var(--primary-soft); color: var(--primary); }

.legs { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.legs li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; }
.filters a.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
pre.detail { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 8px 10px; border-radius: 6px; font-size: 11px; margin: 6px 0 0; max-height: 160px; overflow: auto; }
.steps { counter-reset: step; display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 12px; }
.steps li::before { counter-increment: step; content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 12px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all 0.2s; pointer-events: none; z-index: 60; max-width: calc(100vw - 40px); }
.toast.show { opacity: 1; transform: none; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; overflow-wrap: anywhere; }

.chain-table td, .chain-table th { padding: 5px 8px; font-size: 12px; }
.chain-table .strike { font-weight: 700; background: var(--bg); text-align: center; }
.chain-table tr.atm .strike { background: var(--primary-soft); color: var(--primary); }
.chain-table td.itm { background: rgba(245, 159, 0, 0.06); }
.chain-table td.oi-max { box-shadow: inset 3px 0 0 var(--primary); }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.check small { color: var(--muted); margin-left: auto; text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); font-family: inherit; }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

@media (max-width: 1080px) {
  .grid.cols-4, .grid.cols-3, .grid.main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strategy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-inner { gap: 16px; }
  .nav { display: none; }
  .menu-primary { display: block; }
  .tabbar { display: flex; align-items: stretch; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--border); padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .tabbar a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 2px; color: var(--muted); font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; line-height: 1.2; -webkit-tap-highlight-color: transparent; user-select: none; }
  .tabbar a svg { display: block; }
  .tabbar .tab-ico { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 999px; transition: background 0.15s, transform 0.1s; }
  .tabbar .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  .tabbar a.active .tab-ico { background: var(--primary-soft); }
  .tabbar a.active .tab-ico svg { stroke-width: 2.1; }
  .tabbar a:active .tab-ico { transform: scale(0.92); background: var(--bg); }
  .tabbar a.active:active .tab-ico { background: var(--primary-soft); }
  .page { padding-bottom: calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }
  .footer { padding-bottom: calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); left: 20px; right: 20px; text-align: center; }
}

@media (max-width: 820px) {
  .chain-table .col-ba { display: none; }
  .topbar-inner { padding: 0 16px; height: 56px; }
  .brand-name { font-size: 17px; }
  .brand .logo { width: 30px; height: 30px; }
  .page { padding-left: 16px; padding-right: 16px; padding-top: 20px; }
  h1 { font-size: 20px; }
  .card { padding: 16px; }
  .stat .value { font-size: 22px; }
  .menu-panel { position: fixed; top: 62px; right: 12px; left: auto; width: min(320px, calc(100vw - 24px)); }
  .kv { grid-template-columns: 120px 1fr; }
  .chart.tall { height: 280px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; padding: 6px 12px; }
  .form input, .form select { font-size: 16px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; min-width: 0; }
  .page-head .actions select.btn { flex: 1; min-width: 0; }
}

@media (max-width: 640px) {
  .grid.cols-2, .grid.main { grid-template-columns: 1fr; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid { gap: 12px; }
  .strategy-grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 19px; }
  .stat .sub { font-size: 11px; }
  .card-head .small { font-size: 11px; }
  .page-head p { font-size: 13px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .menu-user { display: none; }
  .menu-btn { padding: 8px 10px; }
  .brand-sub { display: none; }
}

/* ---- v3.9 performance analytics ---------------------------------------------------------------------- */
:root { --chart-profit: #0f9d7a; --chart-loss: #e5484d; --cell-p1: #5fc0a5; --cell-p2: #0f9d7a; --cell-n1: #f19a9e; --cell-n2: #e5484d; --cell-z: #e6e9ef; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.kpi .sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; overflow-wrap: anywhere; }
.kpi .meter { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.kpi .meter span { display: block; height: 100%; background: var(--chart-profit); border-radius: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.p { background: var(--chart-profit); } .dot.n { background: var(--chart-loss); }
.chart.cum { height: 240px; position: relative; }
.chart.bars { height: 240px; position: relative; }
details.tbl { margin-top: 6px; } details.tbl summary { cursor: pointer; } details.tbl table { margin-top: 6px; width: 100%; }
.chart .hit { cursor: crosshair; }
.chart .bar:hover, .chart .bar:focus { opacity: 0.8; outline: none; }
/* P&L calendar */
.cal-nav { display: flex; align-items: center; gap: 10px; } .cal-nav h2 { min-width: 150px; text-align: center; }
.btn.sm.disabled { opacity: 0.4; pointer-events: none; }
.cal-sum { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12.5px; }
.cal { display: grid; gap: 4px; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.1fr); gap: 4px; }
.cal-head span { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 6px; }
.cal-cell { position: relative; min-height: 64px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 6px 8px; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 0; }
.cal-cell .dom { position: absolute; top: 5px; left: 8px; font-size: 11px; color: var(--muted); font-weight: 500; }
.cal-cell .amt { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.cal-cell .cnt { font-size: 10.5px; color: var(--muted); }
.cal-cell.off { background: var(--bg); } .cal-cell.out { opacity: 0.35; background: var(--bg); } .cal-cell.future { background: repeating-linear-gradient(135deg, var(--surface) 0 6px, var(--bg) 6px 8px); }
.cal-cell.z { background: var(--cell-z); }
.cal-cell.p1 { background: var(--cell-p1); border-color: var(--cell-p1); color: #0b2f26; } .cal-cell.p1 .dom, .cal-cell.p1 .cnt { color: #0b2f26; }
.cal-cell.p2 { background: var(--cell-p2); border-color: var(--cell-p2); color: #fff; } .cal-cell.p2 .dom, .cal-cell.p2 .cnt { color: rgba(255,255,255,0.85); }
.cal-cell.n1 { background: var(--cell-n1); border-color: var(--cell-n1); color: #3d0f11; } .cal-cell.n1 .dom, .cal-cell.n1 .cnt { color: #3d0f11; }
.cal-cell.n2 { background: var(--cell-n2); border-color: var(--cell-n2); color: #fff; } .cal-cell.n2 .dom, .cal-cell.n2 .cnt { color: rgba(255,255,255,0.85); }
.cal-cell[tabindex]:hover, .cal-cell[tabindex]:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.cal-cell.cal-wk { background: var(--bg); border-style: dashed; justify-content: center; }
.cal-cell.cal-wk.wp .amt { color: var(--chart-profit); } .cal-cell.cal-wk.wn .amt { color: var(--chart-loss); }
.cal-legend { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.sw.p1 { background: var(--cell-p1); } .sw.p2 { background: var(--cell-p2); } .sw.n1 { background: var(--cell-n1); } .sw.n2 { background: var(--cell-n2); } .sw.z { background: var(--cell-z); }
.cal-tip { position: fixed; z-index: 50; background: var(--text); color: #fff; font-size: 11.5px; padding: 8px 10px; border-radius: 8px; white-space: pre-line; max-width: 320px; pointer-events: none; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2); }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cal-cell { min-height: 56px; padding: 4px 6px; } .cal-cell .amt { font-size: 11.5px; } .cal-cell .cnt { display: none; } .cal-row { grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.2fr); gap: 3px; } }
@media (max-width: 520px) { .cal-cell .dom { font-size: 10px; top: 3px; left: 5px; } .cal-cell .amt { font-size: 10px; } .cal-head span { font-size: 9.5px; padding: 0 2px; } }
#performance .grid > div { min-width: 0; }
details.tbl { overflow-x: auto; }
.chart svg { max-width: 100%; }
.kpi .value.dual { font-size: 19px; } .kpi .value span { white-space: nowrap; }
.cal-cell .amt { white-space: nowrap; } .cal-cell .amt .short { display: none; }
@media (max-width: 640px) { .cal-cell .amt .full { display: none; } .cal-cell .amt .short { display: inline; } .cal-cell .amt { font-size: 11.5px; } .cal-sum { font-size: 12px; gap: 8px; } }
/* v4.0 backtest */
.checks { display: grid; gap: 8px; }
.checks.row { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; margin: 0; font-size: 13px; color: var(--text); font-weight: 500; }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check.off { opacity: 0.55; cursor: not-allowed; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); min-height: 0; flex: none; }
.check-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.check-title { font-weight: 600; }
.check-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.checks.years .check { padding: 6px 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg-item { margin: 0; cursor: pointer; }
.seg-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-item span { display: block; padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--muted); border-right: 1px solid var(--border); }
.seg-item:last-child span { border-right: 0; }
.seg-item:has(input:checked) span { background: var(--text); color: #fff; }
.seg.small .seg-item span { padding: 5px 10px; font-size: 12px; }
details.adv summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.meter.big { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.meter.big span { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s; }
.chart.equity { height: 280px; position: relative; }
.chart.dd { height: 90px; position: relative; margin-top: 4px; }
table.heat th, table.heat td { padding: 6px 6px; font-size: 12px; }
table.heat td.heat-cell { text-align: right; font-variant-numeric: tabular-nums; border-radius: 4px; }
table.heat td.heat-cell.p1 { background: var(--cell-p1); color: #0b2f26; }
table.heat td.heat-cell.p2 { background: var(--cell-p2); color: #fff; }
table.heat td.heat-cell.n1 { background: var(--cell-n1); color: #3d0f11; }
table.heat td.heat-cell.n2 { background: var(--cell-n2); color: #fff; }
table.heat td.heat-cell.z { background: var(--cell-z); }
.note-block { margin-bottom: 10px; }
.note { display: inline-block; margin: 3px 8px 0 0; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; }
.note b { color: var(--text); font-weight: 600; }
.assumptions { margin: 10px 0 0; padding-left: 18px; }
.assumptions li { margin-bottom: 4px; }
#bt-kpis .kpi .value { font-size: 20px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } .seg-item span { padding: 8px 10px; } #bt-kpis .kpi .value { font-size: 18px; } }
[hidden] { display: none !important; }
.form .check { display: flex; margin: 0; font-size: 13px; color: var(--text); font-weight: 500; }
.form .seg-item { margin: 0; font-size: 13px; }
#bt-strategies { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { #bt-strategies { grid-template-columns: 1fr; } }
td.legs { white-space: nowrap; font-size: 11.5px; }
.leg { display: inline-block; margin: 1px 6px 1px 0; padding: 1px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.leg.sell { border-color: var(--cell-n1); } .leg.buy { border-color: var(--cell-p1); }
#bt-trades td { padding: 7px 8px; }
.checks.row .check-body { flex: 0 0 auto; }
td.legs { white-space: normal; min-width: 260px; max-width: 420px; }
.leg { white-space: nowrap; }
#bt-trades td.mono { white-space: nowrap; }
/* v5.0 portfolio desk */
:root { --sl-options: #2a78d6; --sl-swing: #eb6834; --sl-momentum: #1baf7a; --sl-futures: #eda100; --sl-portfolio: #1c2333; }
.dot.sl-options { background: var(--sl-options); } .dot.sl-swing { background: var(--sl-swing); } .dot.sl-momentum { background: var(--sl-momentum); } .dot.sl-futures { background: var(--sl-futures); }
.tag.sl-options, .tag.sl-swing, .tag.sl-momentum, .tag.sl-futures { background: var(--bg); color: var(--text); border-color: var(--border); }
.tag.sl-options::before, .tag.sl-swing::before, .tag.sl-momentum::before, .tag.sl-futures::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.tag.sl-options::before { background: var(--sl-options); } .tag.sl-swing::before { background: var(--sl-swing); } .tag.sl-momentum::before { background: var(--sl-momentum); } .tag.sl-futures::before { background: var(--sl-futures); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); margin-top: 8px; }
.legend .sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.form-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .form-row.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .form-row.four, .form-row.three { grid-template-columns: 1fr; } }
.sleeve-card h2 .dot { width: 10px; height: 10px; margin-right: 8px; }
.sleeve-card .adv summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.kpi.sub .value { font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chips a { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none; }
.chips a.on { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.alloc-bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; min-width: 90px; }
.alloc-bar > span { display: block; height: 100%; border-radius: 3px; }
/* v5.1 */
.card .scard { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface); }
.chips.tabs { margin: 0 0 16px; }
.chips.tabs a { padding: 6px 14px; font-size: 13px; }
.chips a .dot { width: 7px; height: 7px; margin-right: 6px; }
.page-head h1 .dot { margin-right: 8px; vertical-align: 2px; }
.btn .dot { width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; }
.kpi .value.dual { font-size: 18px; }
@media (max-width: 1200px) { .nav a { padding: 8px 9px; font-size: 13px; } }
/* v5.1 backtest configuration */
.bt-setup .form { gap: 0; }
.bt-row { display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.bt-row:last-of-type { border-bottom: 0; }
.bt-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-top: 8px; }
.bt-hint { grid-column: 2; color: var(--muted); font-size: 12.5px; }
.bt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bt-inline { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bt-inline input[type=date], .bt-inline input[type=month], .bt-inline input[type=number], .bt-inline input[type=text] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; margin: 0; color: var(--text); }
.chip input[type=checkbox], .chip input[type=radio] { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip.off { opacity: 0.5; cursor: not-allowed; }
.chip small { color: var(--muted); font-size: 11px; }
.chip input[type=text] { border: 0; background: transparent; font: inherit; outline: none; }
.seg.lg button { padding: 9px 16px; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg.lg button .dot { width: 8px; height: 8px; margin: 0; }
.input-prefix { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.input-prefix span { padding: 0 8px 0 10px; color: var(--muted); font-size: 13px; }
.input-prefix input { border: 0 !important; border-radius: 0 !important; width: 140px; }
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.lbl input { width: 120px; }
.bt-actions { display: flex; align-items: center; gap: 14px; padding-top: 16px; flex-wrap: wrap; }
.bt-setup details.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.bt-setup details.adv { display: block; }
@media (max-width: 720px) { .bt-row { grid-template-columns: 1fr; gap: 8px; } .bt-hint, .bt-inline { grid-column: 1; } .seg.lg { flex-wrap: wrap; } }
.form .chip, .chips .chip { display: inline-flex; width: auto; margin: 0; }
.form .chip input { width: 14px; }
.form .bt-inline input[type=date], .form .bt-inline input[type=month] { width: auto; }
.form .bt-inline input[type=number] { width: 140px; }
.form .lbl input { width: 120px; }
.form .bt-label, .form .lbl { font-weight: 600; }
.bt-setup .form label.lbl { display: flex; }
@media (max-width: 640px) { .kv { grid-template-columns: 110px 1fr; } .kv dd { min-width: 0; } }

/* sleeve set-up tables: give the reason column room so notes don't wrap word-per-line */
.setup-cell{min-width:220px}
@media(max-width:720px){.setup-cell{min-width:160px}}
