/* ===================== Product Experience 4.0B — application shell (loaded last) =====================
   One sidebar (5 primary + 3 secondary), the market context in the top bar, route-driven contextual tabs, the phone bottom bar.
   Market colours identify the MARKET only (Spółki blue, Crypto amber, Forex teal) — never profit, loss, warnings or trading status. */
:root { --mk-spolki: var(--mk-stocks); --mk-wszystkie: #c9d4e3; --shell-line: var(--border-soft); --shell-text: #c9d4e3; }

/* ---- sidebar */
.app-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px 24px; }
.app-nav-group { display: flex; flex-direction: column; gap: 2px; }
.app-nav-sep { margin: 16px 12px 6px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #6f86a3; }
.app-nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--shell-text);
  text-decoration: none; font-weight: 500; font-size: .95rem; transition: background .15s ease, color .15s ease; }
.app-nav-link:hover { background: #142033; color: #fff; }
.app-nav-link.on { background: #1a2a40; color: #fff; box-shadow: inset 3px 0 0 #f5a524; }
.app-nav-link.secondary { font-size: .88rem; color: var(--text-dim); }
.app-nav-link .mud-icon-root { opacity: .85; }

/* ---- market context switcher (top bar) */
.mk-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); overflow-x: auto; max-width: 100%; }
.mk-opt { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 9px; color: var(--text-dim); text-decoration: none; font-size: .86rem;
  font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.mk-opt:hover { color: #fff; background: #142033; }
.mk-opt.on { background: var(--surface-2); color: #fff; }
.mk-opt.on.mk-spolki { box-shadow: inset 0 -2px 0 var(--mk-spolki); }
.mk-opt.on.mk-crypto { box-shadow: inset 0 -2px 0 var(--mk-crypto); }
.mk-opt.on.mk-forex { box-shadow: inset 0 -2px 0 var(--mk-forex); }
.mk-opt.on.mk-wszystkie { box-shadow: inset 0 -2px 0 var(--mk-wszystkie); }
.mk-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; margin-left: 10px;
  border: 1px solid currentColor; }
.mk-tag.mk-spolki, .mk-dot.mk-spolki { color: var(--mk-spolki); } .mk-tag.mk-crypto, .mk-dot.mk-crypto { color: var(--mk-crypto); }
.mk-tag.mk-forex, .mk-dot.mk-forex { color: var(--mk-forex); }
.mk-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: currentColor; margin-right: 10px; }

/* ---- contextual navigation */
.ctx-bar { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 16px; }
.ctx-title { display: flex; align-items: center; font-size: 1.3rem; font-weight: 700; color: var(--text); letter-spacing: .01em; }
.ctx-tabs, .ctx-sections { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ctx-tabs::-webkit-scrollbar, .ctx-sections::-webkit-scrollbar { display: none; }
.ctx-tabs { border-bottom: 1px solid var(--shell-line); }
.ctx-tab { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--text-dim); text-decoration: none; white-space: nowrap; font-weight: 600;
  font-size: .92rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ctx-tab:hover { color: #fff; }
.ctx-tab.on { color: #fff; border-bottom-color: #f5a524; }
.ctx-sec { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--border); color: var(--text-dim);
  text-decoration: none; white-space: nowrap; font-size: .84rem; }
.ctx-sec:hover { color: #fff; border-color: #34496a; }
.ctx-sec.on { color: #fff; background: var(--surface-2); border-color: #3b5478; }

/* ---- composed destinations */
.stack-block { margin-bottom: 26px; }
.stack-title { display: flex; align-items: center; font-size: 1.05rem; font-weight: 700; margin: 6px 0 10px; color: var(--text); }
.choose-market { padding: 20px; }
.choose-title { font-size: 1.1rem; margin: 0 0 6px; }
.choose-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.mk-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--border); color: var(--text);
  text-decoration: none; font-weight: 600; background: var(--surface-2); }
.mk-btn.mk-spolki { border-left: 4px solid var(--mk-spolki); } .mk-btn.mk-crypto { border-left: 4px solid var(--mk-crypto); } .mk-btn.mk-forex { border-left: 4px solid var(--mk-forex); }
.mk-btn:hover { background: var(--surface-2); }

/* ---- phone bottom bar (same five destinations in every market) */
.app-bottom { display: none; }
@media (max-width: 959.98px) {
  .app-bottom { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
    background: var(--bg); border-top: 1px solid var(--shell-line); padding-bottom: env(safe-area-inset-bottom); }
  .ab-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: #8ea2bb; text-decoration: none;
    font-size: .66rem; background: none; border: 0; cursor: pointer; padding: 0 2px; }
  .ab-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ab-item.on { color: #fff; box-shadow: inset 0 2px 0 #f5a524; }
  .app-main { padding-bottom: 76px; }
  .ctx-title { font-size: 1.15rem; }
}
@media (max-width: 640px) {
  .app-topbar .mk-switch { position: absolute; left: 0; right: 0; top: 56px; border-radius: 0; border-left: 0; border-right: 0; justify-content: space-between; padding: 4px 8px; }
  .app-topbar .mk-opt { flex: 1 1 auto; justify-content: center; padding: 0 6px; min-height: 36px; font-size: .8rem; }
  .app-main { padding-top: 46px; }
}

/* ===================== PX 4.0C — Strategie (Odkrywaj, Biblioteka, szczegóły, porównanie) and the Bot Center ===================== */
.disc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.disc-count { color: var(--text-dim); font-size: .88rem; }
.disc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.disc-actions input[type=search] { min-height: 40px; min-width: 200px; }
.disc-search { margin-bottom: 14px; }
.disc-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.disc-filters input, .disc-filters select, .disc-actions input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 9px; min-height: 40px; padding: 0 10px; }
.disc-filters input[type=search] { flex: 1 1 220px; }
.disc-adv summary { min-height: 40px; display: inline-flex; align-items: center; cursor: pointer; color: var(--text-dim); }
.disc-adv-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.disc-adv-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--text-dim); }
.srow-list { display: flex; flex-direction: column; gap: 8px; }
.srow-list.grouped { border-left: 2px solid var(--border); padding-left: 10px; margin-bottom: 10px; }
.lib-group { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); margin: 12px 0 6px; }
.srow, .bc-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) auto; gap: 8px 18px; align-items: center; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.srow.sel { border-color: #f5a524; }
.bc-row.attn { border-color: rgba(245, 165, 36, .55); }
.srow-title { display: flex; align-items: center; font-weight: 700; font-size: .98rem; min-width: 0; }
.srow-title a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.srow-title a:hover { text-decoration: underline; }
.srow-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; color: var(--text-dim); margin-top: 4px; align-items: center; }
.srow-ev { padding: 1px 8px; border-radius: 6px; border: 1px solid #34496a; font-size: .74rem; }
.srow-ev.ev-validated { color: #7ee2a8; border-color: rgba(46, 160, 67, .5); }
.srow-ev.ev-rejected { color: #f2b8a2; border-color: rgba(229, 83, 75, .4); }
.srow-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); gap: 4px 16px; margin: 0; }
.srow-kpi div { display: flex; flex-direction: column; min-width: 0; }
.srow-kpi dt { font-size: .7rem; color: var(--text-dim); }
.srow-kpi dd { margin: 0; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.srow-kpi .wide dd { font-weight: 500; font-size: .8rem; white-space: normal; }
.srow-kpi dd.up { color: var(--up); } .srow-kpi dd.down { color: var(--down); }
.srow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.srow-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.srow-actions .sc-btn { min-height: 38px; }
.srow-actions .sc-btn.on { border-color: #f5a524; color: #fff; }
.srow-bots { font-size: .8rem; color: #7ee2a8; text-decoration: none; }
.mode-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; }
.mode-chip.paper { background: #16283f; color: #9cc3ff; } .mode-chip.demo { background: #2a2210; color: #f5c26b; }
.bc-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.bc-filters button { background: none; cursor: pointer; }
.ctx-sec.disabled { opacity: .45; cursor: not-allowed; }
.bc-demo { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .84rem; color: #c9d4e3; padding: 8px 10px;
  border-radius: 9px; background: #18160f; border: 1px dashed rgba(245, 165, 36, .35); }
.bc-demo a { color: #f5c26b; }
.bc-main { min-width: 0; }
.det-head, .bot-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.det-title { display: flex; align-items: center; font-size: 1.25rem; margin: 0 0 4px; }
.det-tabs { margin: 4px 0 14px; }
.det-kv { margin: 8px 0 12px; }
.det-pgroup { margin: 10px 0; }
.det-overview p { max-width: 80ch; }
.bot-top { background: #101a28; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.bot-top-main { flex: 1 1 420px; min-width: 0; }
.bot-top-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-width: 520px; }
.bot-scope { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.bot-steps { display: flex; flex-wrap: wrap; gap: 4px 6px; list-style: none; padding: 0; margin: 8px 0; }
.bot-steps li { font-size: .74rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); color: #6f86a3; }
.bot-steps li.done { color: #c9f2d6; border-color: rgba(46, 160, 67, .45); }
.cmp-wrap { overflow-x: auto; }
.cmp-table { border-collapse: collapse; min-width: 560px; width: 100%; font-size: .88rem; }
.cmp-table th, .cmp-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.cmp-table thead th { font-size: .9rem; }
.cmp-table tbody th { color: var(--text-dim); font-weight: 500; white-space: nowrap; }
.param-group { margin: 12px 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 8px; }
@media (max-width: 959.98px) {
  .srow, .bc-row { grid-template-columns: 1fr; }
  .srow-side, .srow-actions { align-items: flex-start; justify-content: flex-start; }
  .srow-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bot-top-actions { align-items: flex-start; max-width: none; }
  .disc-actions input[type=search] { min-width: 0; flex: 1 1 160px; }
}

/* ===================== PX 4.0D — Terminal, Portfel, DEMO account, Editor ===================== */
.trade-desk.with-rail .td-grid { grid-template-columns: 180px minmax(0, 1fr) 360px; }
.trade-desk.side-closed .td-grid { grid-template-columns: minmax(0, 1fr) 150px; }
.trade-desk.with-rail.side-closed .td-grid { grid-template-columns: 180px minmax(0, 1fr) 150px; }
.td-rail { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.td-rail-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 8px 10px; min-height: 44px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.td-rail-item small { color: var(--text-dim); font-size: .72rem; }
.td-rail-item.on { border-color: #2dd4bf; background: #10231f; }
.td-side-toggle { align-self: flex-end; background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; min-height: 36px; padding: 0 10px; cursor: pointer; font-size: .8rem; }
.exec-modes, .pf-ctx { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.exec-mode { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim);
  font-size: .82rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.exec-mode.on { color: #fff; background: var(--surface-2); border-color: #3b5478; }
.exec-mode.off { opacity: .45; cursor: not-allowed; }
.pf-table td, .pf-table th { white-space: nowrap; }
.pf-table tr.stale td { opacity: .6; }
.pf-table .up { color: var(--up); } .pf-table .down { color: var(--down); }
.d-block { display: block; }
.demo-acct-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.demo-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 8px 0 10px; }
.demo-kpis > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.demo-kpis span { font-size: .72rem; color: var(--text-dim); } .demo-kpis b { font-size: 1.02rem; } .demo-kpis small { font-size: .72rem; color: var(--text-dim); }
.mk-session { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; font-size: .84rem; }
.fwd-block { border-top: 1px solid var(--border); padding: 8px 0; }
.fwd-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: .85rem; padding: 3px 0; }
.fwd-row .up { color: var(--up); } .fwd-row .down { color: var(--down); }
.studio-bar-main { position: sticky; top: 64px; z-index: 20; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.st-tabs { margin-top: 10px; }
.st-tabs button { background: none; cursor: pointer; }
@media (max-width: 1100px) {
  .trade-desk.with-rail .td-grid, .trade-desk.side-closed .td-grid, .trade-desk.with-rail.side-closed .td-grid { grid-template-columns: minmax(0, 1fr); }
  .td-rail { flex-direction: row; overflow-x: auto; max-height: none; order: -1; }
  .td-rail-item { min-width: 120px; }
  .td-side-toggle { align-self: stretch; }
}
@media (max-width: 640px) { .studio-bar-main { top: 102px; } }
