/* Paper Trader — własny CSS (bez zewnętrznych zasobów). Autor: Brocode. */
:root {
  color-scheme: light;
  --bg: #f5f5f2; --surface: #ffffff; --surface-2: #f0efeb; --text: #1b1b1a; --muted: #5d5c57; --faint: #8b8a84;
  --border: #e2e1db; --border-strong: #cfcdc5; --accent: #2a6fd0; --accent-ink: #ffffff; --accent-soft: #e6effb;
  --pos: #0b7a3e; --neg: #c0272d; --warn: #9a6500; --pos-bg: #e3f4ea; --neg-bg: #fbe7e8; --warn-bg: #fdf1d6; --info-bg: #e6effb;
  --grid: #e8e7e1; --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 1px 8px rgba(20, 20, 18, .04);
  --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100; --s4: #e87ba4; --s5: #008300; --s6: #6250d6; --s7: #e34948;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --text: #efeee9; --muted: #aeada4; --faint: #85847c;
    --border: #2d2d2a; --border-strong: #42423e; --accent: #5b9bf0; --accent-ink: #0b1220; --accent-soft: #1b2a41;
    --pos: #46c28a; --neg: #ff7f7a; --warn: #e8b044; --pos-bg: #14301f; --neg-bg: #3a1c1d; --warn-bg: #33290f; --info-bg: #1b2a41;
    --grid: #2a2a27; --shadow: none;
    --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500; --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --text: #efeee9; --muted: #aeada4; --faint: #85847c;
  --border: #2d2d2a; --border-strong: #42423e; --accent: #5b9bf0; --accent-ink: #0b1220; --accent-soft: #1b2a41;
  --pos: #46c28a; --neg: #ff7f7a; --warn: #e8b044; --pos-bg: #14301f; --neg-bg: #3a1c1d; --warn-bg: #33290f; --info-bg: #1b2a41;
  --grid: #2a2a27; --shadow: none;
  --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500; --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .6rem .75rem; overflow: auto; margin: 0 0 .75rem; white-space: pre-wrap; word-break: break-word; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* układ */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; gap: 1rem; min-height: 52px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.brand small { font-weight: 500; color: var(--muted); }
.nav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: .35rem .6rem; border-radius: 6px; font-weight: 500; font-size: .93rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.nav-toggle { display: none; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: .3rem .5rem; cursor: pointer; font: inherit; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.footer { max-width: 1280px; margin: 0 auto; padding: 1rem 1rem 2rem; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* komponenty */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .6rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem 1rem; }
.kpi .l { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 1.25rem; font-weight: 650; line-height: 1.3; }
.kpi .v.big { font-size: 1.6rem; }
.kpi .s { font-size: .82rem; color: var(--muted); }
.pf-card h3 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pf-card .nav-line { display: flex; justify-content: space-between; align-items: flex-end; gap: .5rem; margin: .4rem 0 .6rem; }
.spark { width: 120px; height: 32px; }
.spark .ln { fill: none; stroke-width: 1.6; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge.ok, .badge.filled, .badge.active, .badge.BUY { background: var(--pos-bg); color: var(--pos); }
.badge.err, .badge.rejected, .badge.error, .badge.halted, .badge.killed, .badge.blocked, .badge.SELL { background: var(--neg-bg); color: var(--neg); }
.badge.warn, .badge.paused, .badge.skipped, .badge.cancelled, .badge.proposed, .badge.running, .badge.pending_password { background: var(--warn-bg); color: var(--warn); }
.badge.info, .badge.ai, .badge.strategy, .badge.user, .badge.admin, .badge.system, .badge.noop { background: var(--info-bg); color: var(--accent); }
.badge.archived { background: var(--surface-2); color: var(--faint); }

.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.sm { padding: .25rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--pos-bg); color: var(--pos); border-color: color-mix(in srgb, var(--pos) 30%, transparent); }
.flash.err { background: var(--neg-bg); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.alert { padding: .6rem .85rem; border-radius: 8px; border: 1px solid; margin-bottom: .6rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert.err { background: var(--neg-bg); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.info { background: var(--info-bg); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); padding: .55rem .85rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.disclaimer { color: var(--muted); font-size: .85rem; border-left: 3px solid var(--border-strong); padding: .2rem .75rem; margin: 0 0 1rem; }

/* tabele */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .45rem .6rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.data td { padding: .42rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.trunc { max-width: 38ch; overflow: hidden; text-overflow: ellipsis; }
table.data tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); }
th a { color: inherit; } th a:hover { color: var(--text); text-decoration: none; }
th .arrow { font-size: .7em; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* formularze */
label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: .45rem .6rem; min-height: 38px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: .85rem; } .field .hint { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; }
.check input { margin-top: .25rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; align-items: end; }
.filters .field { margin: 0; }
.narrow { max-width: 440px; margin: 2rem auto; }
.auth-card h1 { margin-bottom: .25rem; }
.reqs { color: var(--muted); font-size: .88rem; padding-left: 1.1rem; margin: .25rem 0 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem 1rem; }
.radio-card { display: block; border: 1px solid var(--border-strong); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .5rem; cursor: pointer; font-weight: 400; }
.radio-card strong { display: block; }
.radio-card input { margin-right: .4rem; }
.danger-zone { border-color: color-mix(in srgb, var(--neg) 45%, var(--border)); }
.action-block { padding: .85rem 0; border-top: 1px solid var(--border); }
.action-block:first-of-type { border-top: 0; padding-top: 0; }
.action-block h3 { margin-bottom: .2rem; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
.secret-box { background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 8px; padding: .8rem; margin-bottom: 1rem; }
.secret-box input { font-family: var(--mono); font-size: .85rem; }

/* zakładki, paginacja */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin: 0 0 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs a { padding: .55rem .85rem; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.pager { display: flex; gap: .4rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-top: .75rem; color: var(--muted); font-size: .88rem; }
.pager .pages { display: flex; gap: .3rem; align-items: center; }
.pager a, .pager span.cur { padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.pager span.cur { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pager a:hover { background: var(--surface-2); text-decoration: none; }

/* oś zdarzeń */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: .1rem 0 .9rem .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.38rem; top: .4rem; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); border: 2px solid var(--surface); }
.timeline li.t-rebalance::before, .timeline li.t-execution::before { background: var(--accent); }
.timeline li.t-halt::before, .timeline li.t-risk_reject::before, .timeline li.t-kill_switch::before { background: var(--neg); }
.timeline li.t-risk_clip::before, .timeline li.t-pause::before { background: var(--warn); }
.tl-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.tl-text { margin-top: .15rem; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 550; margin: .3rem 0; }

/* wykresy */
.chart { margin: 0; position: relative; }
svg.ch { width: 100%; height: auto; display: block; overflow: visible; }
svg.ch.ch-narrow { display: none; }
svg.ch text { font: 12px var(--sans); fill: var(--muted); }
svg.ch text.hmv { fill: var(--text); }
svg.ch .grid { stroke: var(--grid); stroke-width: 1; }
svg.ch .axis, svg.ch .tick { stroke: var(--border-strong); stroke-width: 1; }
svg.ch .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
svg.ch .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.ch .ln.dashed { stroke-dasharray: 6 4; }
svg.ch .area { stroke: var(--surface); stroke-width: 1; }
svg.ch .xhair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
svg.ch .dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.ln.s0 { stroke: var(--s0); } .ln.s1 { stroke: var(--s1); } .ln.s2 { stroke: var(--s2); } .ln.s3 { stroke: var(--s3); }
.ln.s4 { stroke: var(--s4); } .ln.s5 { stroke: var(--s5); } .ln.s6 { stroke: var(--s6); } .ln.s7 { stroke: var(--s7); }
.f0, .dot.s0 { fill: var(--s0); } .f1, .dot.s1 { fill: var(--s1); } .f2, .dot.s2 { fill: var(--s2); } .f3, .dot.s3 { fill: var(--s3); }
.f4, .dot.s4 { fill: var(--s4); } .f5, .dot.s5 { fill: var(--s5); } .f6, .dot.s6 { fill: var(--s6); } .f7, .dot.s7 { fill: var(--s7); }
svg.ch path.area:not(.stackarea) { fill-opacity: .16; stroke: none; }
svg.ch polygon.area { fill-opacity: .85; }
svg.ch .bar.up { fill: var(--pos); } svg.ch .bar.down { fill: var(--neg); }
svg.ch .hm-pos { fill: var(--pos); } svg.ch .hm-neg { fill: var(--neg); } svg.ch .hm-none { fill: var(--surface-2); }
svg.ch .hm-year { stroke: var(--border-strong); stroke-width: 1; }
.legend { list-style: none; display: flex; gap: .4rem 1rem; flex-wrap: wrap; padding: 0; margin: 0 0 .4rem; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .35rem; }
.sw { width: 18px; height: 0; border-top: 3px solid var(--s0); border-radius: 2px; display: inline-block; }
.sw.dashed { border-top-style: dashed; }
.sw.s0 { border-top-color: var(--s0); } .sw.s1 { border-top-color: var(--s1); } .sw.s2 { border-top-color: var(--s2); } .sw.s3 { border-top-color: var(--s3); }
.sw.s4 { border-top-color: var(--s4); } .sw.s5 { border-top-color: var(--s5); } .sw.s6 { border-top-color: var(--s6); } .sw.s7 { border-top-color: var(--s7); }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: .4rem .6rem; font-size: .8rem; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); z-index: 5; white-space: nowrap; }
.tip b { display: block; margin-bottom: .15rem; }
.tip .r { display: flex; gap: .5rem; justify-content: space-between; align-items: center; }
.tip .r i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: .3rem; }
.tip .r span:last-child { font-weight: 600; margin-left: .75rem; }

/* wskaźniki go/no-go */
.gate { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.gate:last-child { border-bottom: 0; }
.gate .dot-s { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.gate.pass .dot-s { background: var(--pos); } .gate.fail .dot-s { background: var(--neg); }
.gate .name { flex: 1; } .gate .val { font-weight: 650; }
.verdict { padding: .8rem 1rem; border-radius: 10px; font-weight: 650; font-size: 1.05rem; border: 1px solid; }
.verdict.nogo { background: var(--neg-bg); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.verdict.go { background: var(--pos-bg); color: var(--pos); border-color: color-mix(in srgb, var(--pos) 35%, transparent); }
.prose { max-width: 78ch; } .prose h2 { margin-top: 1.5rem; } .prose ul { padding-left: 1.2rem; }
.formula { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: .5rem .75rem; border-radius: 6px; margin: .5rem 0 .75rem; overflow-x: auto; }

@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .nav-toggle { display: inline-block; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; padding-bottom: .5rem; order: 5; }
  .nav.open { display: flex; }
  .topbar-in { gap: .5rem; }
  svg.ch.ch-wide { display: none; }
  svg.ch.ch-narrow { display: block; }
  svg.ch-narrow text { font-size: 11px; }
  .kpi .v.big { font-size: 1.4rem; }
  dl.kv { grid-template-columns: 1fr; gap: 0; } dl.kv dt { margin-top: .4rem; }
  .page-head { flex-direction: column; }
}
@media print { .topbar, .footer, .actions, .tabs { display: none; } body { background: #fff; } }
.tip[hidden] { display: none; }
.tip .r i.f0 { background: var(--s0); } .tip .r i.f1 { background: var(--s1); } .tip .r i.f2 { background: var(--s2); } .tip .r i.f3 { background: var(--s3); }
.tip .r i.f4 { background: var(--s4); } .tip .r i.f5 { background: var(--s5); } .tip .r i.f6 { background: var(--s6); } .tip .r i.f7 { background: var(--s7); }
.mt { margin-top: 1rem; } form.inline { display: inline; } .mb0 { margin-bottom: 0; }
.inline-form .field.grow { flex: 1; min-width: 200px; }
.alert.ok { background: var(--pos-bg); color: var(--pos); border-color: color-mix(in srgb, var(--pos) 30%, transparent); }
