/* =====================================================================
   Workspaces — responsive layer (2026-10-18, ADR-026). Loaded after workspaces.css.
   Breakpoints checked at 390 / 430 px (phones) and 820 px (tablet portrait).
   Phones get: bottom navigation, cards instead of wide tables, collapsible chart
   controls, a bottom sheet for details. SPÓŁKI = blue, CRYPTO = orange.
   ===================================================================== */

/* ---------- shared presentation primitives ---------- */
.family-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px;
    color: var(--cr); background: var(--cr-dim); box-shadow: inset 0 0 0 1px var(--cr-line); vertical-align: middle; white-space: nowrap; }
.family-badge.family-eq { color: var(--eq); background: var(--eq-dim); box-shadow: inset 0 0 0 1px var(--eq-line); }
.chip-scroll { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .pill-tab { flex: 0 0 auto; }
.section-head { display: flex; align-items: center; gap: 10px; }
.section-head h2 { font-size: 16px; margin: 0; }
.ml-auto { margin-left: auto; }
.link-like { color: var(--text-dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }

/* market-breadth regime labels */
.rg { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px; border-radius: 5px; }
.rg-bull { background: var(--up-dim); color: var(--up); }
.rg-recovery { background: #12313a; color: #4dd0e1; }
.rg-side { background: var(--gray-dim, #232a38); color: var(--text-dim); }
.rg-weak { background: var(--warn-dim); color: var(--warn); }
.rg-bear { background: var(--down-dim); color: var(--down); }
.rg-panic { background: #4a0f14; color: var(--down); box-shadow: inset 0 0 0 1px #8c1d26; }
.rg-none { background: var(--surface-2); color: var(--text-faint); }

.breadth-card { display: block; text-decoration: none; color: inherit; border-top: 2px solid var(--cr) !important; }
.breadth-card:hover { background: var(--surface-hover); }
.breadth-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.breadth-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 10px; }
.breadth-level b { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; }
.breadth-level small { display: block; font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }
.breadth-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.breadth-bar span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--down), var(--warn) 45%, var(--up)); }
.breadth-trend { font-size: 11.5px; font-weight: 700; text-align: right; white-space: nowrap; }
.breadth-trend small { display: block; font-weight: 500; color: var(--text-faint); }
.breadth-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.breadth-stats div { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px; }
.breadth-stats span { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.breadth-stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.regime-strip { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 1px; margin: 4px 0 6px; }
.regime-strip span { display: block; min-width: 2px; padding: 0; border-radius: 0; }
.spells { display: flex; flex-direction: column; gap: 4px; }
.spell summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0; font-size: 12.5px; }

/* crypto overview */
.quote-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.bot-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.bot-card.paused { opacity: .75; }
.bot-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.bot-card-head a { color: var(--text); text-decoration: none; }
.bot-card-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin-bottom: 8px; }
.bot-card-kpis span { display: block; font-size: 10.5px; color: var(--text-dim); }
.bot-card-kpis b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bot-signals { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.sig-chip { font-size: 11.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 2px 6px; }
.pos-row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto auto; gap: 8px; font-size: 12px; padding: 4px 0; border-top: 1px solid var(--border); align-items: center; }

/* stock workspace */
.ws-page-head--equities .page-h1 { color: var(--text); }
.stock-safety { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; border-left: 2px solid var(--eq-line); padding: 2px 0 2px 10px; margin: -4px 0 16px; font-size: 11.5px; color: var(--text-dim); }
.stock-safety-icon { color: var(--eq); font-size: 15px !important; }
.trade-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.stock-select { background: var(--surface); color: var(--text); border: 1px solid var(--eq-line); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13.5px; min-width: 260px; max-width: 100%; }
.stock-select.small { min-width: 160px; padding: 6px 8px; font-size: 12.5px; }
.trade-quote { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trade-quote b { font-size: 18px; font-variant-numeric: tabular-nums; }
.tf-tabs .pill-tab[disabled] { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.sig-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--border); align-items: center; }
.sig-row:first-of-type { border-top: 0; }
.sig-row .kpi-sub { grid-column: 1 / -1; margin-top: 0; }
.paper-form { display: grid; gap: 8px; margin-top: 10px; }
.paper-form label { display: grid; gap: 3px; font-size: 11.5px; color: var(--text-dim); }
.paper-form input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
.strategy-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.strategy-card .reasons { margin-top: 6px; }
.data-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.cal-list { display: flex; flex-direction: column; }
.cal-day { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.cal-day:first-child { border-top: 0; }
.cal-items { display: flex; flex-direction: column; gap: 4px; }
.cal-item { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.cal-item a { color: var(--text); }

/* phone-only toggles: hidden on larger screens */
.m-toggle { display: none; }
.bottom-nav, .bn-sheet, .bn-backdrop { display: none; }

/* ---------- tablet portrait (≤ 900 px, e.g. 820 px) ---------- */
@media (max-width: 900px) {
    .breadth-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stock-select { min-width: 0; flex: 1 1 260px; }
    .data-cards { grid-template-columns: 1fr; }
}

/* ---------- phones (≤ 700 px, e.g. 390 / 430 px) ---------- */
@media (max-width: 700px) {
    .mud-main-content { padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important; }
    .mud-container { padding-left: 10px !important; padding-right: 10px !important; }
    .ws-toolbar { position: static; margin-bottom: 10px; }
    .card { padding: 12px 12px; }
    h1.page-h1 { font-size: 21px; }
    p.page-lead { font-size: 12.5px; margin-bottom: 12px; }
    .hide-xs { display: none; }

    /* bottom navigation */
    .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
        background: rgba(14,17,24,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
    .bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 9px; color: var(--text-dim);
        text-decoration: none; font-size: 10.5px; background: none; border: 0; font-family: inherit; cursor: pointer; min-height: 48px; justify-content: center; }
    .bn-item .mud-icon-root { font-size: 21px; }
    .bottom-nav--equities .bn-item.on { color: var(--eq); background: rgba(79,163,255,.12); }
    .bottom-nav--crypto .bn-item.on { color: var(--cr); background: rgba(247,147,26,.12); }
    .bottom-nav--home .bn-item.on { color: var(--accent); background: var(--accent-dim); }
    .bottom-nav--equities { box-shadow: inset 0 2px 0 rgba(79,163,255,.35); }
    .bottom-nav--crypto { box-shadow: inset 0 2px 0 rgba(247,147,26,.4); }
    .bn-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1301; }
    .bn-sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1302; max-height: 78vh; overflow-y: auto;
        background: var(--surface); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); }
    .bn-sheet-grab { width: 42px; height: 4px; border-radius: 2px; background: var(--border); margin: 2px auto 10px; }
    .bn-sheet-title { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--eq); margin: 8px 2px 6px; }
    .bn-sheet-title.cr { color: var(--cr); }
    .bn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .bn-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 11px; border: 1px solid var(--border);
        background: var(--bg); color: var(--text); text-decoration: none; font-size: 11.5px; text-align: center; min-height: 58px; justify-content: center; }
    .bn-tile.eq.on { border-color: var(--eq-line); color: var(--eq); }
    .bn-tile.cr.on { border-color: var(--cr-line); color: var(--cr); }

    /* wide tables become cards: each cell shows its column name (data-label) */
    table.dt-cards thead { display: none; }
    table.dt-cards, table.dt-cards tbody, table.dt-cards tr, table.dt-cards td { display: block; width: 100%; }
    table.dt-cards tr { border: 1px solid var(--border); border-radius: 11px; padding: 8px 10px; margin-bottom: 8px; background: var(--bg); }
    table.dt-cards tbody tr:hover { background: var(--bg); }
    table.dt-cards td { border: 0 !important; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right !important; font-size: 12.5px; }
    table.dt-cards td::before { content: attr(data-label); color: var(--text-faint); font-size: 11px; text-align: left; flex: 0 0 auto; padding-right: 8px; }
    table.dt-cards td:first-child { font-size: 13.5px; text-align: left !important; justify-content: flex-start; padding-bottom: 6px !important; border-bottom: 1px solid var(--border) !important; margin-bottom: 4px; }
    table.dt-cards td:first-child::before { display: none; }
    table.dt-cards td[data-label=""]::before { display: none; }
    .m-cards .table-scroll, .m-cards { overflow: visible; }

    /* chart controls collapse; price chart stays primary */
    .m-toggle { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
        border-radius: 9px; padding: 7px 11px; font: inherit; font-size: 12.5px; margin-bottom: 8px; cursor: pointer; }
    .m-collapsible:not(.open) { display: none; }
    .chart-card { padding: 4px !important; margin-left: -4px; margin-right: -4px; }
    .chart-card .kpi-sub { padding: 0 6px 4px; font-size: 10.5px; }
    .trade-bar { gap: 8px; }
    .trade-bar .pill-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .coin-tabs, .tf-tabs { width: 100%; }
    .indicator-toggles { gap: 6px !important; }
    .ind-toggle { font-size: 12px; padding: 5px 8px; }

    /* details as a bottom sheet */
    .m-sheet { position: fixed !important; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 1250; margin: 0 !important;
        max-height: 62vh; overflow-y: auto; border-radius: 16px 16px 0 0 !important; box-shadow: 0 -12px 30px rgba(0,0,0,.6); }

    .breadth-main { grid-template-columns: auto minmax(0, 1fr); }
    .breadth-trend { grid-column: 1 / -1; text-align: left; }
    .breadth-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quote-strip { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; margin-left: -2px; }
    .quote-strip::-webkit-scrollbar { display: none; }
    .quote-strip .quote-card { flex: 0 0 132px; padding: 10px; }
    .quote-strip .kpi-value { font-size: 17px; }
    .bot-cards { grid-template-columns: 1fr; }
    .pos-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
    .pos-row > :last-child { display: none; }
    .strategy-cards, .data-cards { grid-template-columns: 1fr; }
    .ws-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ws-kpi b { font-size: 17px; }
    .stock-safety .dot-sep { display: none; }
    .stock-safety > span { width: 100%; }
    .grid.g-3, .grid.g-2-even { gap: 10px; }
    .kv { flex-wrap: wrap; }
}


/* mobile-only summary cell of card tables; long notes wrap on desktop */
.m-only { display: none; }
td.cell-note { white-space: normal; min-width: 220px; }
@media (max-width: 700px) {
    table.dt-cards td.m-only { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-start; }
    table.dt-cards tr:has(td.m-only) td.m-only + td { border-bottom: 0 !important; margin-bottom: 0; padding-bottom: 3px !important; font-size: 12.5px; justify-content: space-between; text-align: right !important; }
    table.dt-cards tr:has(td.m-only) td.m-only + td::before { display: inline; }
    td.cell-note { min-width: 0; }
    .table-scroll table.dt-cards td:first-child { position: static; background: transparent; }
}


/* Panel główny: quick entry into every workspace section (the 50/50 split stays) */
.ws-quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -2px 0 12px; }
.ws-quick::-webkit-scrollbar { display: none; }
.ws-quick a { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 5px 9px; border-radius: 8px;
    border: 1px solid var(--border); color: var(--text-dim); text-decoration: none; background: var(--bg); }
.ws-quick a .mud-icon-root { font-size: 15px; }
.ws-panel--equities .ws-quick a:hover { color: var(--eq); border-color: var(--eq-line); }
.ws-panel--crypto .ws-quick a:hover { color: var(--cr); border-color: var(--cr-line); }


/* Comparison on phones: one strategy column at a time, chosen with the chips above the table */
.m-only-flex { display: none !important; }
@media (max-width: 700px) {
    .m-only-flex { display: flex !important; }
    table.m-one-col th:not(:first-child):not(.col-sel), table.m-one-col td:not(:first-child):not(.col-sel):not([colspan]) { display: none; }
    table.m-one-col td:first-child { white-space: normal; }
}

/* Crypto strategy families (ADR-027): three cards + a collapsed archive. */
.family-card { display: block; color: inherit; text-decoration: none; }
.family-card:hover { box-shadow: inset 0 0 0 1px var(--cr-line); }
.family-title { color: var(--cr); }
.family-card .family-title { font-weight: 800; letter-spacing: .04em; font-size: 15px; margin-bottom: 4px; }
details.archive > summary { cursor: pointer; list-style: revert; }
details.archive[open] > summary { margin-bottom: 6px; }

/* Crypto Handel (ADR-028): one compact bar — coin · timeframe · strategy · indicator menu. */
.trade-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.trade-bar .pill-tabs { margin-bottom: 0; }
.strategy-tabs .pill-tab { font-weight: 600; }
.ind-menu { position: relative; }
.ind-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
    padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); user-select: none; }
.ind-menu > summary::-webkit-details-marker { display: none; }
.ind-menu[open] > summary { border-color: var(--cr-line); }
.ind-menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 300px; max-width: calc(100vw - 32px);
    background: var(--surface, #141a24); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
    display: flex; flex-wrap: wrap; gap: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.ind-group-title { width: 100%; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }
@media (max-width: 640px) {
    .ind-menu { width: 100%; }
    .ind-menu-panel { position: static; width: 100%; max-width: none; margin-top: 6px; box-shadow: none; }
}

/* Strategy ON/OFF rows (ADR-028): name + status left, switch right — one row per strategy. */
.switch-list { display: flex; flex-direction: column; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row .switch-main { flex: 1 1 auto; min-width: 0; }
.switch-row .switch-main .kpi-sub { white-space: normal; }
.switch-row .mud-switch { margin: 0; flex: 0 0 auto; }

/* ADR-029 navigation: on desktop the docked sidebar holds the Crypto section list; the Crypto toolbar then shows only its
   brand chip (no duplicate list). With the sidebar closed, or below the docking breakpoint (960 px), the toolbar list returns. */
@media (min-width: 960px) {
    .drawer-open .ws-toolbar--crypto { display: none; }
}

/* Bot page: one card per strategy. */
.bot-families { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1280px) { .bot-families { grid-template-columns: minmax(0, 1fr); } }
.bot-family.running { box-shadow: inset 0 0 0 1px var(--cr-line); }
.bot-family-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.bot-family-status { display: flex; gap: 6px; flex-wrap: wrap; }
.bot-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.bot-controls .mud-switch { margin: 0; }
.bot-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bot-kpis > div { display: flex; flex-direction: column; font-size: 12px; color: var(--text-dim); }
.bot-kpis b { font-size: 14px; color: var(--text); }
.signal-line > summary { cursor: pointer; display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.dt.compact td, .dt.compact th { padding: 5px 8px; font-size: 12px; }

/* Backtest form. */
.lab-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.lab-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.lab-form select, .lab-form input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-width: 130px; }
.lab-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) { .lab-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .lab-kpis { gap: 8px; } .lab-form label { flex: 1 1 140px; } }
@media (max-width: 360px) { .lab-kpis { grid-template-columns: minmax(0, 1fr); } }

/* Cards never let their content spill out: grid/flex children may shrink, long values and tags wrap. */
.card, .kpi-card, .strategy-card { min-width: 0; }
.kpi-card .kpi-value { overflow-wrap: anywhere; line-height: 1.15; }
.kpi-card .kpi-sub, .strategy-card .kpi-sub { overflow-wrap: anywhere; }
.family-badge, .status, .mode { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.card-head > b, .card-head > h3 { min-width: 0; overflow-wrap: anywhere; }

/* Admin users. */
.user-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.user-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.user-form input, .user-form select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-width: 160px; }

table.dt select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
table.dt td.wrap-cell { white-space: normal; min-width: 180px; }

/* 2026-11-25 (phone check at 390/360 px): a long sector / industry name in the company header widened the whole page (horizontal scroll).
   Header chips may wrap; elsewhere chips keep their single-line look. */
.company-head .meta-line { flex-wrap: wrap; max-width: 100%; }
.company-head .meta-line .chip { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
