/* =====================================================================
   UX 3.0 — responsive foundation (loaded last). Root causes fixed here, once, for every page:
   1. grid / flex children kept their min-content width (min-width:auto) — long names, URLs and options widened the whole document;
   2. desktop rules declared AFTER the phone media queries silently overrode them (e.g. the 4-column strategy rows);
   3. form controls sized to their longest option / value;
   4. wide tables were not contained in their own scroll area.
   Scroll areas that are meant to scroll (tables, charts, strips) scroll inside their own box; nothing is hidden with overflow:hidden.
   Breakpoints: phone ≤ 700, tablet ≤ 959 (drawer becomes an overlay), desktop.
   ===================================================================== */

/* ---------- readability: secondary text had ~3:1 contrast on the dark surfaces ---------- */
:root { --text-faint: #7D879A; }

/* ---------- 1. intrinsic widths ---------- */
.app-main, .mud-main-content { min-width: 0; }
.grid > *, .studio-grid > *, .ov-row > *, .ws-title-row > *, .trade-bar > *, .studio-bar > *, .card-head > *, .kv > *, .sc > * { min-width: 0; }
select, input, textarea { max-width: 100%; min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
.mud-main-content p, .mud-main-content li, .mud-main-content dd, .card, .alert, .kpi-sub, .page-lead, .sec-title small { overflow-wrap: break-word; }
code, kbd, samp, .url, .break-anywhere { overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
/* ellipsised select text instead of a select as wide as its longest option */
select { text-overflow: ellipsis; }

/* ---------- 4. tables never widen the page: they scroll inside themselves ---------- */
.table-scroll { max-width: 100%; overscroll-behavior-x: contain; }
@media (max-width: 1100px) {
    table.dt:not(.dt-cards), table.compare-table, table.data-table {
        display: block; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    }
    .table-scroll > table.dt:not(.dt-cards), .table-scroll > table.compare-table { display: table; overflow: visible; }
}

/* ---------- top bar: brand · workspace switcher · account ---------- */
.app-topbar .mud-toolbar { gap: 6px; min-width: 0; }
.app-topbar .brand { margin-left: 4px; min-width: 0; }
.ws-switch { margin-left: 18px; flex: 0 1 auto; min-width: 0; }
.ws-switch-item { min-height: 34px; white-space: nowrap; text-decoration: none; transition: background .15s, color .15s; }
.ws-switch--forex.on { color: var(--fx); background: var(--fx-dim); box-shadow: 0 0 0 1px var(--fx-line) inset; }
.user-menu .user-link { white-space: nowrap; }
.user-icon-link { display: none; }
@media (max-width: 700px) {
    .app-topbar .mud-toolbar { padding-left: 6px !important; padding-right: 8px !important; }
    .topbar-menu { margin-left: 0 !important; margin-right: 0 !important; }
    .brand-name { display: none; }
    .ws-switch { display: flex; margin-left: 6px; gap: 2px; padding: 2px; flex: 1 1 auto; justify-content: space-between; max-width: 290px; }
    .ws-switch-item { flex: 1 1 0; justify-content: center; gap: 4px; padding: 6px 4px; font-size: 12.5px; min-height: 38px; }
    .ws-switch-item .mud-icon-root { font-size: 16px; }
    .user-menu .user-link, .user-menu .user-logout-form { display: none; }
    .user-icon-link { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--text-dim); }
    .user-icon-link:hover { color: var(--text); background: var(--surface-hover); }
}
@media (max-width: 359px) { .ws-switch-item .mud-icon-root { display: none; } }

/* ---------- drawer: overlay below 960 px (MudBlazor animates it), backdrop blocks the page ---------- */
.mud-drawer.app-sidebar { transition: transform .22s ease, width .22s ease, left .22s ease !important; }
@media (max-width: 959.98px) {
    .mud-overlay.mud-overlay-drawer { background: rgba(5, 7, 11, .55); backdrop-filter: blur(2px); }
    .app-sidebar .side-link, .app-sidebar .ws-nav-child, .app-sidebar .ws-nav-link { min-height: 40px; }
}

/* ---------- navigation strips: own scroll area each, touch swipe, no reset ---------- */
.ws-toolbar, .ws-subtabs { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; scroll-padding-inline: 16px; }
.ws-toolbar { max-width: 100%; }
.wt-items { flex: 0 0 auto; }
.wt-item, .ws-subtab { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 959.98px) {
    .ws-subtabs { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
    .ws-subtabs::-webkit-scrollbar { display: none; }
}
@media (max-width: 700px) {
    /* the workspace is shown by the switcher in the top bar — the strip spends its width on destinations */
    .ws-toolbar { padding: 4px; gap: 2px; border-radius: 12px; margin-bottom: 8px; -webkit-mask-image: none; mask-image: none; }
    .ws-toolbar .wt-brand, .ws-toolbar .wt-sep { display: none; }
    .wt-item { padding: 9px 12px; min-height: 40px; }
    .ws-subtabs { margin: 0 0 10px; padding-bottom: 2px; gap: 6px; }
    .ws-subtabs-label { display: none; }
    .ws-subtab { min-height: 38px; }
}

/* ---------- page heads ---------- */
.ws-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ws-title-row .page-h1 { overflow-wrap: anywhere; }
.crypto-safety, .stock-safety { flex-wrap: wrap; }
@media (max-width: 700px) {
    .mode-strip { flex-wrap: wrap; }
    .crypto-safety .ex, .stock-safety .ex { display: none; }
}

/* ---------- section rows with a title and an action ---------- */
.sec-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 14px 0 8px; }
.sec-row .sec-title { margin: 0; }

/* ---------- shared strategy card (StrategyCard.razor) ---------- */
.sc-list { display: grid; gap: 8px; container-type: inline-size; }
.sc { display: grid; gap: 6px 16px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
      grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head actions" "meta actions" "metrics actions" "activity activity" "details details"; }
.sc-head { grid-area: head; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sc-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.sc .sc-title a, .sc .sc-title a:visited { color: var(--text); text-decoration: none; }
.sc-title a:hover { color: var(--accent); }
.sc-badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sc-ev { font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 4px; white-space: nowrap; border: 1px solid transparent; }
.sc-ev--hist { color: var(--text-dim); background: var(--gray-dim); border-color: #333B4A; }
.sc-ev--exp { color: var(--warn); background: var(--warn-dim); border-color: #6b4c17; }
.sc-ev--shadow { color: #C3B5FF; background: #241d45; border-color: #4C3D86; }
.sc-ev--paper { color: #9DC8FF; background: var(--info-dim); border-color: #1f4a7a; }
.sc-ev--qual { color: var(--up); background: var(--up-dim); border-color: #1f5a37; }
.sc-ev--research { color: var(--accent); background: var(--accent-dim); border-color: #1D5A52; }
.sc-meta { grid-area: meta; font-size: 12.5px; color: var(--text-dim); overflow-wrap: anywhere; }
.sc-metrics { grid-area: metrics; display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 2px 0 0; }
.sc-metric { min-width: 0; }
.sc-metric dt { font-size: 11px; color: var(--text-faint); margin: 0; white-space: nowrap; }
.sc-metric dd { margin: 0; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sc-metric dd small { display: block; font-size: 11px; font-weight: 400; color: var(--text-faint); }
.sc-activity { grid-area: activity; font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.sc-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; align-self: center; max-width: 340px; }
.sc-details { grid-area: details; font-size: 12px; color: var(--text-dim); }
.sc-details > summary { cursor: pointer; color: var(--text-faint); font-size: 12px; padding: 2px 0; width: fit-content; }
.sc-details-body { display: grid; gap: 4px; padding: 6px 0 2px; overflow-wrap: anywhere; }
@container (max-width: 640px) {
    .sc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "meta" "metrics" "activity" "actions" "details"; padding: 12px; }
    .sc-head { flex-direction: column; align-items: flex-start; }
    .sc-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px 12px; }
    .sc-metric dd { font-size: 13.5px; }
    .sc-actions { justify-content: flex-start; max-width: none; padding-top: 4px; border-top: 1px solid var(--border); }
}

/* ---------- compact action buttons (touch targets ≥ 36 px) ---------- */
.sc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 9px;
          border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600;
          text-decoration: none; cursor: pointer; white-space: nowrap; }
.sc-btn:hover { background: var(--surface-hover); }
.sc-btn.primary { border-color: #1D5A52; background: var(--accent-dim); color: var(--accent); }
.sc-btn.danger { color: var(--down); border-color: #5A1E22; }
.sc-btn.danger:hover { background: var(--down-dim); }
.sc-btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- older row lists (ov-row) become stacked on narrow containers instead of word-by-word columns ---------- */
.ov-list { container-type: inline-size; }
@container (max-width: 640px) {
    .ov-row, .ov-row.my-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .ov-row > .n, .ov-row > .my-actions { grid-column: 1 / -1; }
    .ov-row .my-actions { white-space: normal; }
}

/* ---------- Studio ---------- */
.studio-bar .grow { min-width: min(220px, 100%); }
.studio-bar label { min-width: 0; max-width: 100%; }
.studio-bar select { max-width: 100%; }
.studio-side { min-width: 0; }
@media (max-width: 700px) {
    .studio-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
    .studio-bar > .grow, .studio-bar > .studio-wide, .studio-bar > .tb-menu { grid-column: 1 / -1; }
    .studio-bar input, .studio-bar select { width: 100%; height: 38px; }
    .studio-bar input[type=number] { width: 100% !important; }
    .studio-bar .mud-button-root { min-height: 38px; }
    .studio-status { flex-wrap: wrap; }
    .chart-toolbar { gap: 4px; }
    .chart-toolbar .ct-select { max-width: 46vw; }
    .tb-menu-panel { max-width: calc(100vw - 24px); }
}

/* ---------- charts are as wide as their container ---------- */
.chart-shell, .chart-card, .chart-host { max-width: 100%; min-width: 0; }

/* ---------- integration cards: long URLs / redirect addresses wrap ---------- */
.cred-form code, .cred-form .mono, .integration-url, .mono { overflow-wrap: anywhere; word-break: break-all; }

/* ---------- bottom navigation includes Forex accents ---------- */
@media (max-width: 700px) {
    .bottom-nav--forex .bn-item.on { color: var(--fx); background: rgba(46,211,160,.12); }
    .bottom-nav--forex { box-shadow: inset 0 2px 0 rgba(46,211,160,.35); }
    .bn-sheet-title.fx { color: var(--fx); }
    .bn-tile.fx.on { border-color: var(--fx-line); color: var(--fx); }
    .bn-item { min-height: 50px; }
}

/* ---------- Studio: collapsible parameters; phone order chart → result → parameters → equity → trades ---------- */
.studio-params > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.studio-params > summary::-webkit-details-marker { display: none; }
.studio-params > summary h3 { margin-bottom: 8px; }
.studio-params > summary .dim { font-size: 11.5px; }
.studio-bar input[type=checkbox], .studio-bar input[type=radio] { width: auto !important; height: auto !important; }
.ct-check { align-self: center; }
@media (max-width: 1100px) {
    .studio-grid { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
    .studio-grid .card { min-width: 0; max-width: 100%; }
    .studio-main, .studio-side { display: contents; }
    .studio-grid .st-chart { order: 1; }
    .studio-grid .marker-detail { order: 2; }
    .studio-grid .st-result { order: 3; }
    .studio-grid .studio-params { order: 4; }
    .studio-grid .st-equity { order: 5; }
    .studio-grid .st-trades { order: 6; }
    .studio-grid .st-notes { order: 7; }
    .studio-grid > * > *, .studio-grid .card { margin-top: 0 !important; }
    .studio-stale > * { opacity: .55; }
}
@media (max-width: 700px) {
    .studio-bar > .ct-check { grid-column: 1 / -1; flex-direction: row; }
    .studio-bar .mud-button-root { width: 100%; }
    .chart-card .chart-host, .chart-card .ct-host { min-height: 340px; }
}

/* ---------- trading desk (TradingDesk.razor) — Spółki, Crypto, Forex → Handel ---------- */
.trade-desk { display: flex; flex-direction: column; gap: 10px; }
.td-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.td-field { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-dim); min-width: 0; }
.td-field.td-wide { flex: 0 1 320px; }
.td-select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; height: 38px; padding: 0 8px; font: inherit; font-size: 13.5px; width: 100%; }
.td-tf { margin: 0; }
.td-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; }
.td-main, .td-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.td-main > .card, .td-side > .card { margin: 0 !important; }
.td-panel h3 { margin-bottom: 8px; }
.td-panel-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.td-panel-head h3 { margin: 0; }
.td-panel-head .td-select { flex: 1 1 180px; width: auto; height: 34px; font-size: 12.5px; }
.td-quote { display: flex; flex-direction: column; gap: 6px; }
.td-quote-main { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 22px; }
.td-inst { display: flex; flex-direction: column; margin-right: auto; min-width: 0; }
.td-inst b { font-size: 17px; }
.td-inst small { color: var(--text-faint); font-size: 11.5px; }
.td-px { display: flex; flex-direction: column; }
.td-px span { font-size: 11px; color: var(--text-faint); }
.td-px b { font-size: 19px; font-variant-numeric: tabular-nums; }
.td-quote-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; }
.td-chart .crypto-chart { min-height: 420px; }
.td-acct-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.td-acct-kpis > div { display: flex; flex-direction: column; min-width: 0; }
.td-acct-kpis span { font-size: 11px; color: var(--text-faint); }
.td-acct-kpis b { font-size: 14.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.td-acct-kpis small { font-size: 11px; color: var(--text-dim); }
.td-acct-status { font-size: 12px; margin: 6px 0; overflow-wrap: anywhere; }
.td-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.td-tab { flex: 0 0 auto; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-dim); font: inherit; font-size: 12.5px; padding: 8px 10px; min-height: 38px; cursor: pointer; }
.td-tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.td-tabpanel { max-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
.td-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.td-row small { display: block; color: var(--text-faint); font-size: 11px; overflow-wrap: anywhere; }
.td-row .right { text-align: right; }
@media (max-width: 1100px) { .td-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
    .td-field.td-wide { flex: 1 1 100%; }
    .td-tf { width: 100%; }
    .td-chart .crypto-chart { min-height: 360px; }
    .td-quote-main { gap: 6px 16px; }
    .td-inst { flex: 1 1 100%; }
    .td-px b { font-size: 17px; }
}

/* ---------- quote tiles (Forex → Rynek) ---------- */
.quote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.quote-tile { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; padding: 12px 14px; }
.quote-tile:hover { border-color: var(--fx-line); }
.quote-tile .qt-name { font-size: 13px; color: var(--text-dim); }
.quote-tile .qt-px { font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.quote-tile small { color: var(--text-faint); font-size: 11.5px; }

/* ---------- Panel główny ---------- */
.dash-h2 { font-size: 16px; font-weight: 700; margin: 0; }
.dash-h2 small { font-weight: 400; font-size: 12px; margin-left: 6px; }
.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 14px; align-items: start; }
.dash-paper .sec-row { margin-top: 0; }
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.dash-kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: inherit; text-decoration: none; min-width: 0; }
.dash-kpi:hover { border-color: var(--accent); }
.dash-kpi span { font-size: 11.5px; color: var(--text-dim); }
.dash-kpi b { font-size: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.dash-kpi small { font-size: 11.5px; color: var(--text-faint); }
.dash-paper-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
.dash-attn { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 6px 0; color: var(--warn); text-decoration: none; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.dash-attn.neutral { color: var(--text); }
.dash-attn:hover { text-decoration: underline; }
.dash-rs-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.dash-rs-main small, .dash-rs-num small { display: block; font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; }
.dash-rs-num { text-align: right; }
.dash-split.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ws-panel--forex { border-color: var(--fx-line); }
.ws-panel--forex::before { background: radial-gradient(120% 100% at 100% 0%, rgba(46,211,160,.14), transparent 60%); }
.ws-panel--forex .ws-panel-icon { background: linear-gradient(135deg, var(--fx), var(--fx-2)); color: #03201A; }
.ws-panel--forex .ws-panel-title b { color: var(--fx); }
.ws-panel--forex .ws-panel-open:hover { color: var(--fx); border-color: var(--fx-line); }
@media (max-width: 1500px) { .dash-split.triple { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1180px) { .dash-top { grid-template-columns: minmax(0, 1fr); } .dash-split.triple { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-paper-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .dash-kpi b { font-size: 17px; } .dash-hero-stats { width: 100%; } .dash-hero-stats .hero-stat { flex: 1 1 calc(50% - 8px); } }
.dash-find { display: block; font-size: 12.5px; padding: 6px 0; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.dash-find:hover { color: var(--accent); }
.dash-find-ws { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .05em; color: var(--text-dim); margin-right: 6px; text-transform: uppercase; }

/* ---------- ADR-058: broker DEMO / LIVE modes, readiness, health ---------- */
.sc-ev--demo { color: #FFD08A; background: #3a2a10; border-color: #8a5a12; }
.sc-ev--live { color: #fff; background: #7a1d22; border-color: #b3262e; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 8px 16px; margin: 4px 0; }
.kv-grid > div { min-width: 0; }
.kv-grid dt { font-size: 11px; color: var(--text-faint); }
.kv-grid dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.flag { font-size: 12.5px; padding: 6px 10px; border-left: 3px solid var(--border); margin: 4px 0; background: var(--surface-2); border-radius: 0 8px 8px 0; overflow-wrap: anywhere; }
.flag-bad { border-left-color: var(--down); }
.flag-warn { border-left-color: var(--warn); }
.health-panel .dash-attn b { color: var(--text); }
.term-bad { border-color: #5A1E22; }
.term-warn { border-color: #5A431A; }
.empty-line { font-size: 12.5px; color: var(--text-dim); padding: 6px 2px; border-bottom: 1px dashed var(--border); margin-bottom: 6px; }
.dash-research-d { margin-top: 12px; }
.dash-research-d > summary { cursor: pointer; }

/* Hotfix ADR-058 — visible failures: page-level error boundary and the session-failure bar. */
.app-error { border: 1px solid var(--bad, #e5534b); background: rgba(229, 83, 75, .08); }
.app-error h3 { margin: 0 0 .35rem; }
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 3000; padding: .75rem 2.5rem .75rem 1rem;
  background: #5a1d1d; color: #fff; font-size: .9rem; box-shadow: 0 -2px 8px rgba(0,0,0,.4); }
#blazor-error-ui .reload { color: #ffd479; font-weight: 600; margin-left: .5rem; }
#blazor-error-ui .dismiss { position: absolute; right: .9rem; top: .6rem; cursor: pointer; color: #fff; }
.sc-btn[disabled] { opacity: .55; cursor: not-allowed; }
.alert.ok { border: 1px solid rgba(46, 160, 67, .55); background: rgba(46, 160, 67, .1); }

/* ===================== PX 4.0A — "Uruchom strategię" dialog (compact on desktop, full screen on phones) ===================== */
.launch-overlay { position: fixed; inset: 0; background: rgba(3, 7, 15, .62); backdrop-filter: blur(2px); z-index: 1400; }
.launch-dialog { position: fixed; z-index: 1401; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: #0f1724; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55); color: var(--text); }
.launch-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--border-soft); }
.launch-head h2 { margin: 2px 0 6px; font-size: 1.2rem; line-height: 1.3; }
.launch-kicker { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.launch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.launch-x { background: none; border: 0; color: var(--text-dim); font-size: 1.1rem; min-width: 44px; min-height: 44px; cursor: pointer; border-radius: 8px; }
.launch-x:hover { background: var(--surface-2); }
.launch-body { overflow-y: auto; padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.launch-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.launch-status { margin-right: auto; font-size: .85rem; color: var(--text-dim); }
.launch-status.bad { color: #f2b8a2; }
.launch-go { min-height: 44px; padding: 0 22px; font-weight: 600; }
.launch-label { margin-top: 10px; font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.launch-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.launch-sum > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.launch-sum span { font-size: .72rem; color: var(--text-dim); } .launch-sum b { font-size: 1.05rem; } .launch-sum b.small { font-size: .82rem; }
.launch-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.launch-mode-opt { text-align: left; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 10px 12px; min-height: 56px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; }
.launch-mode-opt small { color: var(--text-dim); font-size: .74rem; }
.launch-mode-opt.on { border-color: #f5a524; box-shadow: inset 0 0 0 1px #f5a524; background: #1c1a12; }
.launch-mode-opt[disabled] { opacity: .45; cursor: not-allowed; }
.launch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.launch-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: #b9c7d8; }
.launch-grid input, .launch-grid select { min-height: 40px; }
.launch-risk { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.launch-risk > div { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; border-bottom: 1px dashed var(--border); padding: 4px 0; }
.launch-risk span { color: var(--text-dim); }
.launch-check { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; padding: 7px 10px; border-radius: 8px; background: #121b29; }
.launch-check.block { background: rgba(229, 83, 75, .12); border: 1px solid rgba(229, 83, 75, .35); }
.launch-check.warn { background: rgba(245, 165, 36, .1); border: 1px solid rgba(245, 165, 36, .3); }
.launch-check.ok { background: rgba(46, 160, 67, .1); border: 1px solid rgba(46, 160, 67, .35); }
.launch-check.block .launch-ico { color: var(--down); } .launch-check.warn .launch-ico { color: #f5a524; } .launch-check.info .launch-ico { color: #7fb2ff; } .launch-check.ok .launch-ico { color: var(--up); }
.launch-steps { margin: 4px 0 0; padding-left: 20px; font-size: .86rem; display: flex; flex-direction: column; gap: 3px; }
.launch-running, .launch-account, .launch-note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .86rem; display: flex; flex-direction: column; gap: 6px; }
.launch-bot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); padding-top: 6px; }
.launch-bot small { display: block; }
.launch-auth { border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.launch-size { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }
.launch-id { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .76rem; }
.launch-done { background: rgba(46, 160, 67, .08); border: 1px solid rgba(46, 160, 67, .35); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.launch-done-title { font-weight: 700; color: var(--up); }
.launch-mode { font-size: .88rem; }
.warn-t { color: #f5c26b; }
@media (max-width: 640px) {
  .launch-dialog { inset: 0; top: 0; left: 0; transform: none; width: 100vw; max-height: none; height: 100dvh; border-radius: 0; border: 0; }
  .launch-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .launch-modes, .launch-grid, .launch-risk { grid-template-columns: 1fr; }
  .launch-foot { position: sticky; bottom: 0; background: #0f1724; }
  .launch-foot .sc-btn { flex: 1 1 auto; min-height: 44px; }
  .launch-status { flex-basis: 100%; }
}
.demo-sum { display: flex; flex-direction: column; gap: 6px; }
.demo-sum-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: inherit; text-decoration: none; min-height: 44px; }
.demo-sum-row:hover { border-color: #f5a524; }
.launch-dialog input[type=number], .launch-dialog input[type=text], .launch-dialog select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font-size: .95rem; width: 100%; box-sizing: border-box; }
.launch-dialog input[type=number]:focus, .launch-dialog select:focus { outline: 2px solid #f5a524; outline-offset: 1px; }
.launch-dialog .paper-markets .chip { gap: 6px; min-height: 36px; padding: 0 10px; }
.launch-dialog .ct-check { display: flex; gap: 8px; align-items: center; min-height: 36px; }

/* AT-01 — final PX4 corrections (operator review of PX4_FINAL_SCREENSHOTS), phones only, presentation only:
   chart higher on the Terminal and in the Editor (no introductory lead; the Editor's secondary status meta folds to one line); the Terminal shows ONE
   instrument selector (the dropdown) — the duplicate instrument-card rail stays on tablets / desktop. Chart tools and strategy controls are unchanged. */
@media (max-width: 700px) {
    .mud-main-content:has(.trade-desk) .page-lead.in-shell,
    .mud-main-content:has(.studio-side) .page-lead.in-shell { display: none; }
    .trade-desk.with-rail .td-bar ~ .td-grid > .td-rail { display: none; }
    .studio-status > span.dim { display: none; }
    .studio-status > span.dim:last-child { display: inline; }
}

/* AT-02 — DEMO sizing choice (two options), sizing diagnostics, Bot Center sizing line */
.launch-sizing-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
.launch-sizing-diag { margin-top: 6px; }
.sizing-diag dd { font-variant-numeric: tabular-nums; }
.bc-sizing { grid-column: 1 / -1; font-size: .8rem; padding: 2px 10px 0; min-width: 0; }
.bc-sizing details summary { cursor: pointer; color: var(--text-dim); }
@media (max-width: 700px) { .launch-sizing-modes { grid-template-columns: 1fr; } }

/* AT-02 — Discovery personal archive: bulk bar, inline server-preview confirmation, row pick */
.disc-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; margin: 8px 0; font-size: .86rem; }
.disc-confirm { padding: 12px; margin: 8px 0; border-color: #f5a524; }
.disc-pick { font-size: .78rem; color: var(--text-dim); white-space: nowrap; }

/* hotfix — inherited launch settings */
.launch-inherit { margin: 6px 0 4px; }
.launch-inherit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: .84rem; padding: 3px 0;
  border-bottom: 1px dashed var(--border); }
@media (max-width: 700px) { .launch-inherit-row { grid-template-columns: minmax(0, 1fr) auto; } .launch-inherit-row .chip { grid-column: 1 / -1; justify-self: start; } }

/* AT-03: trade direction is its own field (never hidden in the closing reason); a row selects its chart markers */
.dir-chip { display:inline-block; padding:0 6px; border-radius:6px; font-size:.72rem; font-weight:700; letter-spacing:.03em; border:1px solid currentColor; }
.dir-chip.dir-long { color:#26a69a; }
.dir-chip.dir-short { color:#c77dff; }
.st-trades .trade-row { cursor:pointer; }
.st-trades .trade-row.sel > td { background:rgba(45,212,191,.08); }
.st-trades .trade-detail > td { background:rgba(45,212,191,.04); white-space:normal; }
.ei-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px; }
.ei-funnel { display:flex; flex-wrap:wrap; gap:4px; align-items:center; font-size:.82rem; }
.ei-funnel b { font-variant-numeric:tabular-nums; }
.ei-funnel .arr { opacity:.5; }
.ei-grid .kv { display:flex; flex-direction:column; gap:2px; padding:8px 10px; border:1px solid var(--border, rgba(255,255,255,.08)); border-radius:10px; min-width:0; }
.ei-grid .kv b { font-size:.95rem; }
.ei-grid .kv small { opacity:.75; }

/* AT-04: execution-policy comparison, research agenda, strategy knowledge */
.ep-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ep-controls select, .ep-lots { min-height: 32px; }
.ep-lots { width: 5.5rem; }
.ep-why td { padding-top: 0; border-top: 0; }
.ra-next { padding: .5rem .75rem; border-left: 3px solid var(--accent, #4f8cff); background: var(--surface-2, rgba(127,127,127,.06)); border-radius: 6px; }
.sk-kind { margin-top: .5rem; }
.sk-card .fwd-row, .ra-card .fwd-row { flex-wrap: wrap; }
.ep-card td:first-child { white-space: normal; min-width: 12rem; max-width: 22rem; }
.ep-card td:first-child small { overflow-wrap: anywhere; }
