:root {
  --bg: #090c12;
  --surface: rgba(22, 28, 38, .78);
  --surface-solid: #161c26;
  --surface-2: rgba(36, 45, 60, .7);
  --border: rgba(120, 140, 170, .18);
  --text: #e8eef6;
  --muted: #8c99ab;
  --up: #26d0b2;
  --down: #ff5c70;
  --accent: #4c8dff;
  --accent-2: #8b5cf6;
  --warn: #f5b638;
  --equity: #4c8dff;
  --bench: #b08cff;
  --radius: 14px;
  --sidebar: 288px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef2f8; --surface: rgba(255, 255, 255, .85); --surface-solid: #ffffff; --surface-2: rgba(232, 238, 247, .8);
    --border: rgba(60, 80, 110, .16); --text: #172033; --muted: #5b6a80; --up: #0f9e87; --down: #d93a4f;
    --accent: #2f6fe0; --accent-2: #7a4be0; --warn: #b7791f; --equity: #2f6fe0; --bench: #8a5cf6;
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); }
body { font-family: var(--font); font-size: 14px; line-height: 1.55; font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; letter-spacing: -.005em; }
h3 { margin-top: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono, .num { font-variant-numeric: tabular-nums; }
.pos { color: var(--up); }
.neg { color: var(--down); }

/* ================= animated background ================= */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; width: 55vmax; height: 55vmax; border-radius: 50%; filter: blur(90px); opacity: .22; will-change: transform; }
.aurora i:nth-child(1) { background: var(--accent); left: -15vmax; top: -20vmax; animation: drift1 26s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { background: var(--accent-2); right: -18vmax; top: 10vmax; animation: drift2 32s ease-in-out infinite alternate; opacity: .16; }
.aurora i:nth-child(3) { background: var(--up); left: 20vmax; bottom: -30vmax; animation: drift3 38s ease-in-out infinite alternate; opacity: .12; }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vmax, 18vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(14vmax, -14vmax) scale(1.2); } }
@media (prefers-color-scheme: light) { .aurora i { opacity: .14 !important; } }

/* ================= layout (sidebar on the right) ================= */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; padding: 0 22px 40px; }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); backdrop-filter: blur(16px);
           border-left: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
           animation: slideInRight .6s var(--ease) both; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.side-brand strong { flex: 1; font-size: 15px; letter-spacing: -.01em; }
.brand-mark, .logo-mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.brand-mark span, .logo-mark span { width: 5px; border-radius: 2px; background: linear-gradient(var(--up), var(--accent)); transform-origin: bottom; animation: bars 2.4s var(--ease) infinite; }
.brand-mark span:nth-child(1), .logo-mark span:nth-child(1) { height: 9px; animation-delay: 0s; }
.brand-mark span:nth-child(2), .logo-mark span:nth-child(2) { height: 18px; animation-delay: .25s; }
.brand-mark span:nth-child(3), .logo-mark span:nth-child(3) { height: 13px; animation-delay: .5s; }
.brand-mark span:nth-child(4), .logo-mark span:nth-child(4) { height: 22px; animation-delay: .75s; }
@keyframes bars { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
.side-nav { padding: 12px 10px; flex: 1; position: relative; }
.nav-item, .nav-strat { position: relative; display: block; padding: 9px 12px; border-radius: 10px; margin-bottom: 3px; border: 1px solid transparent;
                        transition: background .25s, transform .25s var(--ease), border-color .25s; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms + 150ms); }
.nav-item:hover, .nav-strat:hover { background: var(--surface-2); transform: translateX(-3px); }
.nav-item.active, .nav-strat.active { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent); border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); }
.nav-item.active::after, .nav-strat.active::after { content: ""; position: absolute; right: -11px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent-2)); animation: grow .4s var(--ease) both; }
@keyframes grow { from { transform: scaleY(0); } }
.nav-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 16px 12px 6px; }
.nav-strat .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 550; }
.nav-strat .row2 { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 1px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.sdot.open { background: var(--up); animation: pulse 1.8s ease-out infinite; }
.sdot.paused { background: var(--warn); }
.side-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; justify-content: space-between; align-items: center; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 18px 0 14px; }
.topbar h1 { animation: fadeUp .5s var(--ease) both; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-block: 0; right: 0; z-index: 20; transform: translateX(105%); transition: transform .35s var(--ease); animation: none; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .6); }
  .menu-btn { display: inline-block; }
  .content { padding: 0 14px 40px; }
}

/* ================= pills, badges, buttons ================= */
.badge { font-size: 11px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.badge.paper { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, transparent); }
.badge.pass { color: var(--up); border-color: color-mix(in srgb, var(--up) 60%, transparent); }
.badge.fail { color: var(--down); border-color: color-mix(in srgb, var(--down) 60%, transparent); }
.status { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 4px 12px; border-radius: 999px; background: var(--surface); backdrop-filter: blur(10px); border: 1px solid var(--border); transition: border-color .3s, color .3s; }
.pill.ok { border-color: color-mix(in srgb, var(--up) 55%, transparent); color: var(--up); }
.pill.bad { border-color: color-mix(in srgb, var(--down) 55%, transparent); color: var(--down); }
.pill.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--warn); }
.pill.price { font-weight: 600; font-variant-numeric: tabular-nums; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; position: relative; }
.pill.ok .live-dot { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.sdot.open { color: var(--up); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.btn { position: relative; overflow: hidden; font: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
       border-radius: 10px; padding: 7px 14px; cursor: pointer; transition: transform .2s var(--ease), border-color .2s, box-shadow .25s, background .2s; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 18px -8px var(--accent); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--border)); }
.btn.danger:hover { border-color: var(--down); box-shadow: 0 6px 18px -8px var(--down); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .35); transform: scale(0); animation: ripple .6s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
.shine::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-120%); animation: shine 3.5s ease-in-out infinite; }
@keyframes shine { 55%, 100% { transform: translateX(120%); } }
.small-btn { padding: 3px 11px; font-size: 12px; }

.alert { background: color-mix(in srgb, var(--down) 14%, var(--surface-solid)); border: 1px solid var(--down); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; animation: fadeUp .4s var(--ease) both; }
.alert.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface-solid)); border-color: var(--warn); }

/* ================= views & entrance animations ================= */
.view { display: flex; flex-direction: column; gap: 14px; animation: viewIn .55s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(18px) scale(.995); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi, .card { position: relative; background: var(--surface); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: var(--radius);
              animation: fadeUp .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); transition: border-color .3s, transform .3s var(--ease), box-shadow .3s; }
.kpi { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.card { padding: 14px 16px; min-width: 0; }
/* cursor spotlight */
.kpi::before, .card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s;
                              background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%); }
.kpi:hover::before, .card:hover::before { opacity: 1; }
.kpi:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 14px 34px -18px var(--accent); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value.text { font-size: 16px; padding: 3px 0; }
.kpi .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flash-up { animation: flashUp .9s ease-out; }
.flash-down { animation: flashDown .9s ease-out; }
@keyframes flashUp { 0% { text-shadow: 0 0 18px var(--up); transform: scale(1.06); } 100% { text-shadow: none; transform: none; } }
@keyframes flashDown { 0% { text-shadow: 0 0 18px var(--down); transform: scale(1.06); } 100% { text-shadow: none; transform: none; } }

.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
        grid-template-areas: "chart feed" "equity feed" "positions feed" "stats trades"; }
.feed { grid-area: feed; } .chart { grid-area: chart; } .equity { grid-area: equity; } .positions { grid-area: positions; }
.stats { grid-area: stats; } .trades { grid-area: trades; }
.grid > :nth-child(1) { --i: 4; } .grid > :nth-child(2) { --i: 5; } .grid > :nth-child(3) { --i: 6; }
.grid > :nth-child(4) { --i: 7; } .grid > :nth-child(5) { --i: 8; } .grid > :nth-child(6) { --i: 9; }
@media (max-width: 1250px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "feed" "equity" "positions" "stats" "trades"; }
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; position: relative; }
.strat-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.strat-head > div:first-child { flex: 1; min-width: 260px; }
.strat-title { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.strat-title h2 { font-size: 20px; letter-spacing: -.02em; }
.strat-head p { margin: 6px 0 0; }
.chart-box { height: 420px; width: 100%; position: relative; animation: chartIn .9s var(--ease) both .2s; }
.chart-box.short { height: 240px; }
@keyframes chartIn { from { opacity: 0; transform: scale(.985); filter: blur(4px); } }
.legend { margin-top: 8px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px 0 2px; vertical-align: middle; }
.dot.eq { background: var(--equity); } .dot.bh { background: var(--bench); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; position: relative; }
.seg button { font: inherit; font-size: 12px; background: transparent; color: var(--muted); border: 0; padding: 5px 14px; cursor: pointer; transition: background .25s, color .25s; }
.seg button.active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }

/* ================= decision feed ================= */
.decisions { list-style: none; margin: 0; padding: 0; max-height: 1060px; overflow-y: auto; }
.decisions li { position: relative; border-bottom: 1px solid var(--border); padding: 11px 4px 11px 14px; animation: slideIn .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
.decisions li::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--border); }
.decisions li.open::before { background: var(--up); } .decisions li.close::before, .decisions li.partial_close::before { background: var(--down); }
.decisions li.pause::before, .decisions li.reset::before { background: var(--warn); }
.decisions li.fresh { animation: slideIn .55s var(--ease) both, highlight 2.4s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-22px); } }
@keyframes highlight { 0% { background: color-mix(in srgb, var(--accent) 24%, transparent); } 100% { background: transparent; } }
.decisions li:last-child { border-bottom: 0; }
.d-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.act { font-size: 11px; padding: 1px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; font-weight: 600; }
.act.open { color: var(--up); border-color: var(--up); }
.act.close, .act.partial_close { color: var(--down); border-color: var(--down); }
.act.pause, .act.reset { color: var(--warn); border-color: var(--warn); }
.d-sum { margin: 0; }
details { margin-top: 5px; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; transition: color .2s; }
details summary:hover { color: var(--text); }
details[open] > :not(summary) { animation: fadeUp .35s var(--ease) both; }
details ul { margin: 4px 0; padding-left: 18px; }
details .kv { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ================= tables ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; }
td.num { font-variant-numeric: tabular-nums; }
tbody tr { animation: rowIn .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); transition: background .2s; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-14px); } }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.empty { color: var(--muted); padding: 14px 0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); transition: transform .25s var(--ease); }
.stat:hover { transform: translateY(-2px); }
.stat .label { font-size: 12px; color: var(--muted); display: block; }
.stat .value { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .bt { font-size: 11px; color: var(--muted); display: block; }

.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.score-big { font-size: 34px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 56px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; }
.bar-track .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; transform: scaleX(0); animation: barGrow .9s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 60ms + 200ms); }
@keyframes barGrow { to { transform: scaleX(1); } }

/* ================= dialog, inputs ================= */
dialog { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); max-width: 440px; padding: 22px; }
dialog[open] { animation: pop .35s var(--ease); }
dialog::backdrop { background: rgba(4, 8, 14, .6); backdrop-filter: blur(5px); animation: fade .3s; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
input { font: inherit; width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); transition: border-color .25s, box-shadow .25s; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
code { background: var(--surface-2); padding: 1px 7px; border-radius: 5px; }

/* ================= skeleton ================= */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--accent) 12%, var(--surface-2)) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ================= login ================= */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; position: relative; overflow: hidden; }
.login-chart { position: fixed; left: 0; right: 0; bottom: 6vh; width: 100%; height: 40vh; z-index: -1; opacity: .5; }
.login-chart .draw { stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: drawLine 3.6s var(--ease) .3s forwards, glowLine 5s ease-in-out 4s infinite alternate; filter: drop-shadow(0 0 8px var(--accent)); }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes glowLine { to { filter: drop-shadow(0 0 16px var(--up)); } }
.login-card { width: 100%; max-width: 380px; background: var(--surface); backdrop-filter: blur(22px); border: 1px solid var(--border); border-radius: 20px; padding: 30px 28px;
              display: flex; flex-direction: column; gap: 8px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7); animation: cardRise .9s var(--ease) both; }
.login-card.leaving { animation: cardLeave .4s var(--ease) forwards; }
@keyframes cardRise { from { opacity: 0; transform: translateY(36px) scale(.96); } }
@keyframes cardLeave { to { opacity: 0; transform: translateY(-20px) scale(.97); filter: blur(6px); } }
.login-card.shake { animation: shake .5s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.login-card > * { animation: fadeUp .6s var(--ease) both; }
.login-card > :nth-child(1) { animation-delay: .2s; } .login-card > :nth-child(2) { animation-delay: .28s; } .login-card > :nth-child(3) { animation-delay: .36s; }
.login-card > :nth-child(4) { animation-delay: .44s; } .login-card > :nth-child(5) { animation-delay: .52s; } .login-card > :nth-child(6) { animation-delay: .6s; }
.login-card > :nth-child(7) { animation-delay: .68s; } .login-card > :nth-child(8) { animation-delay: .76s; }
.logo-mark { height: 30px; margin-bottom: 6px; }
.logo-mark span { width: 7px; }
.login-card h1 { font-size: 24px; letter-spacing: -.03em; background: linear-gradient(90deg, var(--text), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-card .btn { margin-top: 14px; padding: 11px; font-size: 14px; }
.login-card .badge { align-self: center; margin-top: 10px; }
.login-error { color: var(--down); margin: 4px 0 0; font-size: 13px; }

/* ================= accessibility ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .login-chart .draw { stroke-dashoffset: 0; }
}
