:root {
  --bg: #0E131B;
  --panel: #151C27;
  --panel2: #1A2330;
  --line: #273242;
  --text: #E6EAF0;
  --muted: #8E99AA;
  --accent: #F0B340;
  --gain: #38CF8A;
  --loss: #F0616D;
  --put: #6AA6F8;
  --call: #F0B340;
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
.num, td.r, .stat .v, input[type=number] { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.accent { color: var(--accent); }
.put { color: var(--put); }
.call { color: var(--call); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* --- układ --- */
.layout { display: flex; min-height: 100%; }
.side {
  width: 216px; flex: 0 0 216px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { padding: 20px 18px 18px; font-weight: 700; letter-spacing: 0.08em; }
.logo b { color: var(--accent); }
.logo span { display: block; font-weight: 400; letter-spacing: 0; color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 2px; }
.nav a {
  color: var(--muted); padding: 8px 10px; border-radius: 6px; display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.on { background: #1F2A3A; color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav .stage { margin-left: auto; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.side-foot { margin-top: auto; padding: 16px 18px 20px; border-top: 1px solid var(--line); font-size: 12px; }
.side-foot .v { font-size: 16px; font-weight: 600; color: var(--text); }
.bar { height: 6px; background: #0B1017; border-radius: 3px; overflow: hidden; margin-top: 6px; position: relative; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar > b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--loss); }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top .grow { flex: 1; }

/* --- komponenty --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.stat { background: var(--panel); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 7px 12px; border-radius: 6px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3A475B; background: #202B3A; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1A1305; font-weight: 600; }
.btn.primary:hover { background: #F5C060; }
.btn.danger { color: var(--loss); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea {
  background: #0F151F; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--text); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label.f { flex: 1 1 120px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 7px 7px; border-bottom: 1px solid #1D2634; vertical-align: middle; }
.t th.r, .t td.r { text-align: right; }
.t td.r, .t td.num, .t td.nw { white-space: nowrap; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #192231; }
.t tr.month td { background: #111822; color: var(--muted); font-size: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.t tr.month b { color: var(--text); font-weight: 600; margin-right: 10px; }
.tablewrap { overflow-x: auto; }
.legs { font-size: 12.5px; display: inline-block; min-width: 180px; max-width: 210px; }
.legs > span { white-space: nowrap; }
.legs .sep { color: var(--muted); margin: 0 1px; }
.tk { font-weight: 650; }
.roll { color: var(--accent); margin-right: 4px; }

.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #1E2836; color: var(--muted); margin: 1px 3px 1px 0; white-space: nowrap; }
.chip.warn { background: rgba(240, 97, 109, 0.12); color: var(--loss); }
.st { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; border: 1px solid transparent; }
.st-otwarta { color: var(--accent); border-color: rgba(240, 179, 64, 0.35); }
.st-zamknieta { color: var(--muted); border-color: var(--line); }
.st-rolowana { color: var(--put); border-color: rgba(106, 166, 248, 0.35); }
.st-przydzial, .st-wykonanie { color: #C79BF2; border-color: rgba(199, 155, 242, 0.35); }
.st-wygasla { color: var(--gain); border-color: rgba(56, 207, 138, 0.3); }
.st-stop_loss { color: var(--loss); border-color: rgba(240, 97, 109, 0.35); }
.badge { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { padding: 6px 8px; font-size: 13px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* --- panel wysuwany --- */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 12, 0.6); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(1180px, 100vw); background: var(--bg); border-left: 1px solid var(--line);
  z-index: 50; display: flex; flex-direction: column; animation: slide 0.18s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.drawer-body { flex: 1; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.drawer-body > .l { padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.drawer-body > .rp { padding: 18px 18px; border-left: 1px solid var(--line); background: #111822; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 22px; border-top: 1px solid var(--line); background: var(--panel); }
.sec { display: flex; flex-direction: column; gap: 10px; }
.legtable input, .legtable select { padding: 5px 6px; font-size: 13px; width: 100%; }
.legtable td { padding: 4px 4px; border-bottom: none; }
.legtable th { padding: 4px 4px; }
.legtable .tot { text-align: right; white-space: nowrap; padding-right: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.kv > span:nth-child(odd) { color: var(--muted); }
.kv > span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 4px 0; }
.check .auto { margin-left: auto; }
.check.bad span.txt { color: var(--loss); }

/* --- modal --- */
.modal { position: fixed; left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, calc(100vw - 32px)); max-height: 84vh; overflow: auto; z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal .mh { padding: 16px 20px 0; }
.modal .mb { padding: 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.overlay.m { z-index: 55; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222D3D; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 80; }
.toast.err { border-color: var(--loss); color: #FFC9CE; }

/* --- szczegóły --- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--muted); }
.timeline li.otwarcie::after { border-color: var(--accent); }
.timeline li.rolowanie::after { border-color: var(--put); }
.timeline li.zamkniecie::after, .timeline li.wygasniecie::after { border-color: var(--gain); }
.timeline li.przydzial::after, .timeline li.wykonanie::after { border-color: #C79BF2; }
.timeline .d { color: var(--muted); font-size: 12px; }
.chainbox { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.chainbox a { padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 12.5px; }
.chainbox a.cur { border-color: var(--accent); }
.chainbox .arr { color: var(--muted); }
svg text { fill: var(--muted); font-size: 11px; font-family: inherit; }

/* --- strategie --- */
.split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.slist a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.slist a:hover { background: var(--panel2); }
.slist a.on { background: #1F2A3A; box-shadow: inset 2px 0 0 var(--accent); }
.slist .grp { margin: 14px 10px 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.md h1, .md h2, .md h3 { color: var(--text); text-transform: none; letter-spacing: 0; }
.md h2 { font-size: 17px; }
.md p { margin: 0 0 10px; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md code { background: #0F151F; padding: 1px 5px; border-radius: 4px; }
pre.wz { white-space: pre-wrap; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0; color: var(--text); }

/* --- logowanie --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login .logo { padding: 0 0 6px; font-size: 18px; }

@media (max-width: 1100px) {
  .drawer-body { grid-template-columns: 1fr; }
  .drawer-body > .rp { border-left: none; border-top: 1px solid var(--line); }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .side { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .logo { padding: 12px 16px; }
  .logo span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; padding: 0 8px 8px; }
  .nav a { white-space: nowrap; }
  .nav .stage { display: none; }
  .side-foot { display: none; }
  .main { padding: 16px 16px 60px; }
  .g2, .g3, .split { grid-template-columns: 1fr; }
}

.tip { position: fixed; z-index: 90; pointer-events: none; background: #0B1017; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 12px; display: none; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
/* horyzont wygaśnięć */
.hz { position: relative; margin-top: 4px; }
.hz-axis { position: relative; height: 22px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.hz-axis span { position: absolute; bottom: 4px; transform: translateX(-50%); white-space: nowrap; }
.hz-axis span.today { color: var(--accent); }
.hz-lane { position: relative; }
.hz-pill { position: absolute; transform: translateX(-50%); font-size: 11.5px; padding: 2px 7px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; cursor: pointer; color: var(--text); }
.hz-pill:hover { border-color: var(--accent); }
.hz-pill.credit { border-color: rgba(56,207,138,.45); }
.hz-pill.debit { border-color: rgba(240,97,109,.45); }
.hz-pill b { font-weight: 600; }
.hz-earn { position: absolute; transform: translateX(-50%); font-size: 10.5px; color: var(--loss); white-space: nowrap; }
.hz-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: #1C2532; }
.hz-cap { display: flex; margin-top: 8px; gap: 2px; }
.hz-cap div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.hz-cap div b { display: block; color: var(--text); font-weight: 600; font-size: 12.5px; }
.todo { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.todo li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--panel2); border-radius: 6px; border-left: 3px solid var(--line); cursor: pointer; }
.todo li:hover { background: #202B3A; }
.todo li.pilne { border-left-color: var(--loss); }
.todo li.zysk { border-left-color: var(--gain); }
.todo li.info { border-left-color: var(--accent); }
.todo .ic { width: 18px; text-align: center; flex: none; }
.todo .tx { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.nav .grp { margin: 12px 10px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search { margin: 0 12px 8px; }
.search input { width: 100%; padding: 6px 9px; font-size: 13px; }
@media (max-width: 820px) { #pgrid { grid-template-columns: 1fr !important; } }
.hz-wrap { overflow-x: auto; }
.hz { min-width: 680px; }
.wheel { display: inline-flex; gap: 3px; vertical-align: middle; }
.wheel i { width: 14px; height: 6px; border-radius: 3px; background: #273242; }
.wheel i.on { background: var(--accent); }
@media (max-width: 1000px) { #kgrid { grid-template-columns: 1fr !important; } }
/* analityka — wykresy */
.wyk-siatka { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wyk.pelny { grid-column: 1 / -1; }
.wniosek { margin-top: 10px; font-size: 13px; color: var(--text); border-left: 3px solid var(--accent); padding: 4px 0 4px 10px; background: rgba(240,179,64,.05); }
.wniosek:empty { display: none; }
@media (max-width: 900px) { .wyk-siatka { grid-template-columns: 1fr; } }
