/* Hummingbot Dashboard Styling
   Design tokens follow the original simulation report
   (tx_database/simulation/report_html.py, constant CSS): light + dark palette. */

:root {
    color-scheme: light;
    --bg: #f3f5f8; --ink: #17202a; --muted: #667085; --line: #dfe3ea;
    --panel: #fff; --head: #eef3fa; --stripe: #fafbfc;
    --accent: #225ea8; --accent-soft: #e3edf9;
    --negative: #b42318; --positive: #067647;
    --good: #067647; --good-bg: #dcfae6; --warn: #935f00; --warn-bg: #fef0c7;
    --bad: #b42318; --bad-bg: #fee4e2; --flag-bg: #fdecea;
    --shadow: 0 1px 3px #10182812;
    --topbar-h: 56px; --subnav-h: 0px; --page-max: 1320px;
    /* chart series (read by the SVG chart scripts through --pf-*) */
    --series-2: #168979; --series-3: #ba7200; --series-4: #7555b7;
    --grid: #dfe3ea; --grid-strong: #b9c1cf; --tip-bg: #fff;
    --warn-line: #a96800; --warn-band: rgba(186, 114, 0, .14); --bad-band: rgba(195, 60, 82, .12);
    /* legacy names kept for existing rules */
    --success-color: var(--good); --warning-color: #ffc107; --danger-color: var(--bad);
    --light-bg: var(--stripe);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0f1318; --ink: #e6e9ee; --muted: #98a2b3; --line: #2b323c;
        --panel: #171c23; --head: #1d2530; --stripe: #1a1f27;
        --accent: #6ea8fe; --accent-soft: #1c2a3d;
        --negative: #f97066; --positive: #47cd89;
        --good: #47cd89; --good-bg: #0b2e1c; --warn: #fdb022; --warn-bg: #3a2a06;
        --bad: #f97066; --bad-bg: #3d1512; --flag-bg: #3a1714;
        --shadow: none;
        --series-2: #3ccfb4; --series-3: #f0a43a; --series-4: #b69cf2;
        --grid: #2b323c; --grid-strong: #465061; --tip-bg: #1d2530;
        --warn-line: #fdb022; --warn-band: rgba(253, 176, 34, .16); --bad-band: rgba(249, 112, 102, .16);
        --warning-color: #fdb022;
    }
}

html { scroll-behavior: smooth; }
[id] { scroll-margin-top: calc(var(--topbar-h) + var(--subnav-h) + 16px); }

body {
    background-color: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.container-fluid {
    background: transparent;
    min-height: calc(100vh - var(--topbar-h));
}

/* Page container: reference width 1320px, 16px 20px 48px padding. */
.app-main {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 16px 20px 48px;
}

h1 {
    color: var(--ink);
    font-weight: 600;
    font-size: 26px;
    margin-bottom: 1rem;
}

/* Dashboard Info */
.dashboard-info {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.dashboard-info p {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Table Styling */
.table {
    background: var(--panel);
    color: var(--ink);
    border-color: var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
}

.table thead {
    background-color: var(--head);
    border-bottom: 2px solid var(--line);
}

.table thead th {
    font-weight: 600;
    color: var(--ink);
    background-color: var(--head);
    padding: 0.7rem 0.9rem;
    font-size: 13px;
}

.table tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--accent-soft);
}

.table tbody td {
    padding: 0.6rem 0.9rem;
    vertical-align: middle;
}

/* Status Row Classes */
.table tbody tr.status-success {
    border-left: 4px solid var(--success-color);
}

.table tbody tr.status-warning {
    border-left: 4px solid var(--warning-color);
}

.table tbody tr.status-danger {
    border-left: 4px solid var(--danger-color);
}

.table tbody tr.status-unknown {
    border-left: 4px solid var(--muted);
}

/* Status Indicators */
.status-indicator {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    display: inline-block;
}


/* Code Styling for NAV */
code {
    background-color: var(--head);
    color: var(--accent);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.95rem;
    font-family: 'Courier New', Courier, monospace;
}

/* Alert Styling */
.alert {
    border-radius: 0.5rem;
    border: none;
    box-shadow: var(--shadow);
}

.alert-info {
    background-color: var(--accent-soft);
    color: var(--ink);
    border-left: 4px solid var(--accent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container-fluid.app-main {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    h1 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }

    .dashboard-info {
        margin-top: 1.5rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .table thead th {
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .row {
        flex-direction: column;
    }

    .col-md-8,
    .col-md-4 {
        flex-basis: 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }

    .text-end {
        text-align: left !important;
    }

    h1 {
        font-size: 1.5rem;
    }

    .table {
        font-size: 0.9rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.5rem 0.25rem;
    }

    .status-indicator {
        font-size: 1rem;
        margin-right: 0.25rem;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.table {
    animation: fadeIn 0.3s ease-in;
}

/* Summary strip (dashboard) */
.summary-strip {
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
}

.summary-strip-sep {
    border-left: 1px solid var(--line);
    padding-left: 32px;
}

/* 30d trade sparkline (dashboard) */
.spark-chart {
    cursor: pointer;
    vertical-align: middle;
}

.spark-chart rect {
    fill: var(--accent);
    opacity: .75;
}

.spark-chart:hover rect {
    fill: var(--accent);
    opacity: 1;
}

.spark-modal-svg .spark-bar-success,
.spark-legend-success {
    fill: var(--positive);
    color: var(--positive);
}

.spark-modal-svg .spark-bar-fail,
.spark-legend-fail {
    fill: var(--negative);
    color: var(--negative);
}

.spark-axis-label {
    font-size: 11px;
    fill: var(--muted);
}

/* 30d daily PnL sparkline (dashboard) */
.spark-chart .spark-bar-pos,
.spark-modal-svg .spark-bar-pos {
    fill: var(--positive);
}

.spark-chart .spark-bar-neg,
.spark-modal-svg .spark-bar-neg {
    fill: var(--negative);
}

.spark-chart:hover .spark-bar-pos {
    fill: var(--positive);
    opacity: .8;
}

.spark-chart:hover .spark-bar-neg {
    fill: var(--negative);
    opacity: .8;
}

.spark-baseline,
.spark-modal-baseline {
    stroke: var(--grid-strong);
    stroke-width: 1;
}

/* One value label per bar, revealed on hover so 30 of them cannot overlap. */
.spark-value-label {
    font-size: 11px;
    fill: var(--ink);
    opacity: 0;
    pointer-events: none;
}

.spark-modal-bar:hover .spark-value-label {
    opacity: 1;
}

/* ------------------------------------------------------------------------
   Shared navigation (all pages): sticky top bar like .topbar of the report
   ------------------------------------------------------------------------ */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    column-gap: 6px;
    min-height: var(--topbar-h);
    padding: 0 max(20px, calc((100% - var(--page-max)) / 2 + 20px));
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    font-size: 14px;
    line-height: 1.5;
}

.app-nav-brand {
    display: flex;
    align-items: center;
    margin-right: 18px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--ink);
}

.app-nav-link {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
    color: var(--ink);
    background: var(--stripe);
}

.app-nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Signed-in user, password, logout (issue 32): pushed to the right edge. */
.app-nav-user {
    display: flex;
    align-items: stretch;
    margin-left: auto;
}
.app-nav-email {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}
.app-nav-role {
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 11px;
    color: var(--ink);
}
.app-nav-logout { display: flex; margin: 0; }
button.app-nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    cursor: pointer;
}

/* Login and password pages: one centred card, no navigation. */
.auth-card {
    max-width: 420px;
    margin: 8vh auto 0;
    padding: 28px 28px 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.auth-card .auth-brand { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-card .errorlist { color: var(--bad); padding-left: 0; list-style: none; font-size: 13px; margin: 4px 0 0; }
.auth-card .helptext, .auth-card .form-help { color: var(--muted); font-size: 12px; }
.auth-card .form-help ul { padding-left: 18px; margin: 4px 0 0; }

@media (max-width: 700px) {
    /* narrow: brand on its own line would waste height, so links scroll sideways */
    .app-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 12px;
        scrollbar-width: none;
    }
    .app-nav-brand { margin-right: 10px; font-size: 13px; }
    .app-nav-link { padding: 0 8px; font-size: 13px; }
    .app-nav-email { display: none; }
}
@media (max-width: 520px) {
    .app-nav-brand { display: none; }
    .app-nav-link { padding: 0 7px; font-size: 12.5px; }
}

/* ------------------------------------------------------------------------
   Portfolio overview (portfolio page)
   ------------------------------------------------------------------------ */
.page-portfolio {
    /* page-local names map onto the global design tokens */
    --pf-bg: var(--bg);
    --pf-panel: var(--panel);
    --pf-text: var(--ink);
    --pf-muted: var(--muted);
    --pf-border: var(--line);
    --pf-blue: var(--accent);
    --pf-green: var(--positive);
    --pf-red: var(--negative);
    --pf-usd: var(--accent);
    --pf-eur: var(--series-2);
    --pf-btc: var(--series-3);
    --pf-eth: var(--series-4);
    --pf-tx: var(--ink);
    background: var(--pf-bg);
    color: var(--pf-text);
    font-size: 14px;
    line-height: 1.5;
}

.page-portfolio .container-fluid.pf-main {
    background: transparent;
}

.pf-overview {
    margin-bottom: 28px;
}

.pf-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-portfolio h1.pf-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--pf-text);
}

.pf-sub {
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-period {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    padding: 4px;
    border-radius: 9px;
}

.pf-period button {
    font: inherit;
    color: var(--pf-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    padding: 7px 12px;
    cursor: pointer;
}

.pf-period button:hover {
    color: var(--pf-text);
}

.pf-period button[aria-pressed="true"] {
    background: var(--pf-blue);
    color: var(--panel);
}

.pf-period button:focus-visible,
.pf-checks input:focus-visible {
    outline: 2px solid var(--pf-blue);
    outline-offset: 2px;
}

.pf-values {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.pf-tile {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    padding: 18px;
    min-width: 0;
}

.pf-tile-label {
    color: var(--pf-muted);
    margin-bottom: 9px;
}

.pf-tile-value {
    font-size: 25px;
    font-weight: 600;
    letter-spacing: -0.7px;
    font-variant-numeric: tabular-nums;
}

/* The number never breaks; on a narrow tile the unit moves below it rather
   than the value being cut off or overflowing. */
.pf-tile-value .pf-num {
    white-space: nowrap;
}

.pf-change-up { color: var(--pf-green); }
.pf-change-down { color: var(--pf-red); }
.pf-change-flat,
.pf-change-na { color: var(--pf-muted); }

.pf-notice {
    margin-top: 12px;
    font-size: 12px;
    color: var(--pf-red);
}

/* TX-Stand (monitor.tx_valuation): the part of the value taken from TX. */
.pf-tx-part,
.pf-tx-note {
    margin-top: 8px;
}

.pf-chart {
    margin-top: 18px;
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    padding: 20px;
}

.pf-chart-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-portfolio .pf-chart-title {
    margin: 0 0 3px;
    font-size: 16px;
    font-weight: 600;
    color: var(--pf-text);
}

.pf-checks {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.pf-checks label {
    display: flex;
    gap: 5px;
    align-items: center;
    cursor: pointer;
    min-height: 32px;
}

.pf-checks input {
    accent-color: var(--pf-blue);
    width: 16px;
    height: 16px;
    margin: 0 2px 0 0;
}

.pf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.pf-color-usd { background: var(--pf-usd); }
.pf-color-eur { background: var(--pf-eur); }
.pf-color-btc { background: var(--pf-btc); }
.pf-color-eth { background: var(--pf-eth); }

.pf-plot-wrap {
    position: relative;
}

.pf-plot {
    width: 100%;
    height: 285px;
    display: block;
    margin-top: 14px;
    touch-action: pan-y;
}

.pf-plot text {
    fill: var(--pf-muted);
    font-size: 12px;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-variant-numeric: tabular-nums;
}

.pf-plot .pf-grid {
    stroke: var(--pf-border);
    stroke-width: 1;
}

.pf-plot .pf-grid-zero {
    stroke: var(--grid);
}

.pf-plot .pf-cursor {
    stroke: var(--grid-strong);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.pf-plot .pf-end {
    stroke: var(--pf-panel);
    stroke-width: 1.5;
}

.pf-tooltip {
    position: absolute;
    top: 18px;
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--pf-text);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px #10182820;
    font-variant-numeric: tabular-nums;
}

.pf-tooltip b {
    font-weight: 600;
}

.pf-tooltip-time {
    color: var(--pf-muted);
}

.pf-chart-status {
    margin-top: 6px;
    color: var(--pf-text);
}

.pf-chart-note {
    margin-top: 8px;
}

/* Issue 18: source legend of the history chart (TX solid, dashboard dotted). */
.pf-chart-legend {
    margin-top: 8px;
    display: grid;
    gap: 2px;
}

.pf-legend-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.pf-legend-line {
    flex: 0 0 22px;
    height: 0;
    border-top: 2.5px solid var(--pf-usd);
    transform: translateY(-3px);
}

.pf-legend-tx { border-top-color: var(--pf-tx); }
.pf-legend-dash { border-top-style: dotted; }
.pf-legend-inline { display: inline-block; width: 14px; margin-right: 4px; }

.pf-holdings-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Positions breakdown: Assets / Groups / Accounts tabs (issue 08). The tab
   choice lives on .pf-positions, outside the auto-refreshed #pfBreakdown, so a
   refresh never resets it. */
.pf-positions {
    margin-bottom: 28px;
}

.pf-panel {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    padding: 20px;
}

.pf-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--pf-border);
    margin-bottom: 14px;
}

.pf-tabs button {
    font: inherit;
    color: var(--pf-muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 8px 0 12px;
    cursor: pointer;
}

.pf-tabs button:hover {
    color: var(--pf-text);
}

.pf-tabs button[aria-pressed="true"] {
    color: var(--pf-blue);
    border-bottom-color: var(--pf-blue);
}

.pf-tabs button:focus-visible,
.pf-asset > summary:focus-visible,
.pf-account > summary:focus-visible,
.pf-assign select:focus-visible,
.pf-btn:focus-visible {
    outline: 2px solid var(--pf-blue);
    outline-offset: 2px;
}

.pf-view {
    display: none;
}

.pf-positions[data-view="assets"] .pf-view[data-view-panel="assets"],
.pf-positions[data-view="groups"] .pf-view[data-view-panel="groups"],
.pf-positions[data-view="accounts"] .pf-view[data-view-panel="accounts"] {
    display: block;
}

/* Allocation pie (issue 21) */
.pf-allocation {
    margin-top: 18px;
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    padding: 20px;
    min-width: 0;
}

.pf-alloc-switch {
    gap: 18px;
    margin-bottom: 0;
}

.pf-alloc-switch button {
    min-height: 44px;
}

.pf-alloc-view {
    display: none;
}

.pf-allocation[data-view="assets"] .pf-alloc-view[data-alloc-panel="assets"],
.pf-allocation[data-view="groups"] .pf-alloc-view[data-alloc-panel="groups"],
.pf-allocation[data-view="classes"] .pf-alloc-view[data-alloc-panel="classes"] {
    display: block;
}

/* Issue 41: pies left (long, short), a compact signed table right; the
   summary block on top. Shares in % of the NAV. */
.pf-alloc-body {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
    padding-top: 14px;
}

.pf-pies {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.pf-pie-fig {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pf-pie-svg {
    width: 200px;
    height: 200px;
    max-width: 100%;
    display: block;
}

.pf-pie-track { fill: var(--line); }
.pf-pie-lap { fill: none; stroke: var(--line); opacity: .7; }
.pf-pie-seg { stroke: var(--pf-panel, var(--panel)); stroke-width: 1; }
.pf-pie-short .pf-pie-seg { stroke: var(--pf-red, var(--negative)); stroke-width: 1.2; }
.pf-pie-hatch { pointer-events: none; }
.pf-pie-mark { stroke: var(--ink); stroke-width: 1.5; }
.pf-pie-total { font-size: 19px; font-weight: 650; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pf-pie-total.pf-change-down { fill: var(--pf-red, var(--negative)); }
.pf-pie-cap { font-size: 10px; fill: var(--muted); }

.pf-pie-fig figcaption,
.pf-pie-none {
    color: var(--pf-muted, var(--muted));
    font-size: .76rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pf-pie {
    width: 200px;
    height: 200px;
    max-width: 100%;
    flex-shrink: 0;
    border-radius: 50%;
}

.pf-pie-empty {
    background: transparent;
    border: 2px dashed var(--pf-border);
}

.pf-badge {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: 1px;
}
.pf-badge-warn { background: var(--warn-bg); color: var(--warn); }
.pf-badge-ok { background: var(--good-bg); color: var(--positive); }
.pf-badge-bad { background: var(--bad-bg); color: var(--negative); }

/* Iteration 4 (mix of 2.2 and 3): summary on top, a bar with the tabs and
   the Tabelle | Verlauf switch, then pies left and the table or the
   net-exposure plot right. */
.pf-alloc-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-top: 12px; border-bottom: 1px solid var(--pf-border); }
.pf-alloc-bar .pf-alloc-switch { border-bottom: 0; margin-bottom: -1px; }
.pf-alloc-panes { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.pf-alloc-panes button { font: inherit; font-size: .8rem; border: 0; background: transparent; color: var(--muted); padding: 3px 12px; border-radius: 6px; cursor: pointer; min-height: 30px; }
.pf-alloc-panes button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pf-alloc-panes button:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 1px; }
.pf-alloc-left .pf-alloc-view { display: none; }
.pf-allocation[data-view="assets"] .pf-pies[data-alloc-panel="assets"],
.pf-allocation[data-view="groups"] .pf-pies[data-alloc-panel="groups"],
.pf-allocation[data-view="classes"] .pf-pies[data-alloc-panel="classes"] { display: flex; }
.pf-allocation:not([data-pane="plot"]) .pf-alloc-pane[data-alloc-pane="plot"],
.pf-allocation[data-pane="plot"] .pf-alloc-pane[data-alloc-pane="table"] { display: none; }
.pf-alloc-right { min-width: 0; }
.pf-netplot { min-width: 0; }
.pf-netplot-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pf-netplot-title { font-size: .9rem; font-weight: 650; }
.pf-netplot-wins { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.pf-netplot-wins button { font: inherit; font-size: .74rem; border: 0; background: transparent; color: var(--muted); padding: 2px 8px; border-radius: 6px; cursor: pointer; }
.pf-netplot-wins button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pf-netplot-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.pf-chip { font: inherit; font-size: .74rem; padding: 1px 9px 1px 7px; border-radius: 999px; border: 1px solid var(--line);
           background: var(--panel); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pf-chip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.pf-chip[aria-pressed="true"] { color: var(--ink); border-color: var(--grid-strong); background: var(--stripe); font-weight: 600; }
.pf-np-svg { width: 100%; height: auto; display: block; }
.pf-np-grid { stroke: var(--line); stroke-width: 1; }
.pf-np-zero { stroke: var(--grid-strong); stroke-width: 1.5; }
.pf-np-ax { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.pf-np-band-l { fill: var(--positive); opacity: .10; }
.pf-np-band-s { fill: var(--negative); opacity: .10; }
.pf-np-edge-l { fill: none; stroke: var(--positive); stroke-width: 1; opacity: .45; }
.pf-np-edge-s { fill: none; stroke: var(--negative); stroke-width: 1; opacity: .45; }
.pf-np-line { fill: none; stroke-width: 2; }
.pf-np-net { stroke-width: 2.4; }
.pf-np-end { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pf-np-hit { fill: transparent; }
.pf-np-pt:hover .pf-np-hit { fill: var(--accent-soft); opacity: .5; }
.pf-netplot-legend { display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: .74rem; margin-top: 2px; }
.pf-netplot-legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pf-np-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.pf-np-key-l { background: var(--positive); opacity: .35; }
.pf-np-key-s { background: var(--negative); opacity: .35; }
.pf-netplot-status:empty { display: none; }

/* The table: deliberately light next to the pies. */
.pf-alloc-table-wrap { min-width: 0; overflow-x: auto; }

.pf-alloc-table,
.pf-alloc-summary {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
}

.pf-alloc-table th,
.pf-alloc-table td,
.pf-alloc-summary th,
.pf-alloc-summary td {
    padding: 3px 6px;
    border-bottom: 1px solid var(--pf-border, var(--line));
    text-align: left;
    vertical-align: top;
    font-weight: 400;
}

.pf-alloc-table thead th,
.pf-alloc-summary thead th {
    font-size: .7rem;
    font-weight: 600;
    color: var(--pf-muted, var(--muted));
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom-color: var(--grid-strong);
}

.pf-alloc-table .pf-num,
.pf-alloc-summary .pf-num { text-align: right; white-space: nowrap; }
.pf-alloc-table tbody th { font-weight: 500; }
.pf-alloc-table tbody th .pf-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: 0; }
.pf-alloc-members { display: block; font-size: .7rem; padding-left: 14px; }
.pf-alloc-table .pf-badge { margin-left: 4px; }

.pf-alloc-block th {
    padding-top: 9px !important;
    font-size: .7rem;
    font-weight: 600 !important;
    color: var(--pf-muted, var(--muted));
    text-transform: uppercase;
    letter-spacing: .03em;
}
.pf-alloc-stable th, .pf-alloc-stable td { color: var(--pf-muted, var(--muted)); }

.pf-alloc-origins { display: inline; }
.pf-alloc-origins summary { display: inline; cursor: pointer; list-style: none; }
.pf-alloc-origins summary::-webkit-details-marker { display: none; }
.pf-alloc-origins summary::after { content: " ▸"; color: var(--muted); font-size: .7rem; }
.pf-alloc-origins[open] summary::after { content: " ▾"; }
.pf-alloc-origins ul { margin: 2px 0 2px 14px; padding: 0; list-style: none; font-size: .72rem; color: var(--pf-muted, var(--muted)); }
.pf-alloc-origins li { display: flex; gap: 8px; justify-content: space-between; }
.pf-alloc-origins li b { font-weight: 400; white-space: nowrap; }

/* Signed meter: centre = 0, right = long, left = short, ends = ±100 % NAV. */
.pf-smeter {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 4px;
    margin-left: 6px;
    border-radius: 2px;
    background: var(--line);
    vertical-align: middle;
}
.pf-smeter::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--grid-strong); }
.pf-smeter i { position: absolute; top: 0; bottom: 0; border-radius: 2px; opacity: .75; }
.pf-smeter i.l { left: 50%; background: var(--positive); }
.pf-smeter i.s { right: 50%; background: var(--negative); }

/* Summary block on top. */
.pf-alloc-summary { max-width: 560px; margin: 4px 0 12px; font-size: .84rem; }
.pf-alloc-summary tbody th { font-weight: 600; }
.pf-alloc-summary tbody th .pf-sub { font-weight: 400; font-size: .72rem; margin-left: 4px; white-space: nowrap; }
.pf-alloc-sum-net th, .pf-alloc-sum-net td { background: var(--accent-soft); color: var(--accent); font-weight: 650 !important; }
.pf-alloc-sum-total th, .pf-alloc-sum-total td { border-top: 2px solid var(--grid-strong); font-weight: 650 !important; }
.pf-alloc-lev { margin: -6px 0 10px; }

.pf-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.pf-alloc-reason {
    color: var(--pf-red);
}

@media (max-width: 860px) {
    .pf-alloc-body { grid-template-columns: minmax(0, 1fr); }
    .pf-pies { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 600px) {
    .pf-pie-svg, .pf-pie { width: 150px; height: 150px; }
    .pf-alloc-usd, .pf-alloc-summary .pf-sub, .pf-smeter { display: none; }
    .pf-alloc-table th, .pf-alloc-table td { padding: 3px 4px; }
}

@media (max-width: 400px) {
    .pf-allocation {
        padding: 14px;
    }
}

.pf-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.5fr) minmax(150px, 2fr) minmax(120px, 1fr) minmax(80px, 0.7fr);
    gap: 16px;
    align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--pf-border);
}

.pf-row.pf-head {
    font-size: 12px;
    color: var(--pf-muted);
    padding: 5px 0 10px;
}

.pf-name {
    font-weight: 600;
    min-width: 0;
    overflow-wrap: anywhere;
}

.pf-name strong {
    font-weight: 600;
}

.pf-name .pf-sub {
    font-weight: 400;
}

.pf-detail {
    color: var(--pf-muted);
    min-width: 0;
    overflow-wrap: anywhere;
}

.pf-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pf-meter {
    display: block;
    height: 4px;
    background: var(--pf-border);
    border-radius: 3px;
    margin-top: 6px;
}

.pf-meter span {
    display: block;
    height: 100%;
    background: var(--pf-blue);
    border-radius: 3px;
}

.pf-asset > summary,
.pf-account > summary {
    cursor: pointer;
    list-style: none;
}

.pf-asset > summary::-webkit-details-marker,
.pf-account > summary::-webkit-details-marker {
    display: none;
}

.pf-asset > summary .pf-name::before,
.pf-account > summary .pf-name > strong::before {
    content: "▸ ";
    color: var(--pf-muted);
}

.pf-asset[open] > summary .pf-name::before,
.pf-account[open] > summary .pf-name > strong::before {
    content: "▾ ";
}

.pf-origin {
    background: var(--pf-bg);
    padding: 6px 14px 10px;
    border-bottom: 1px solid var(--pf-border);
}

.pf-source {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
}

/* Assets details (issue 26): account, coin / parent, portfolio group, ... */
.pf-source.pf-source-asset {
    grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr 1fr;
}

.pf-not-held {
    color: var(--pf-muted);
    font-style: italic;
}

.pf-source + .pf-source {
    border-top: 1px solid var(--pf-border);
}

.pf-source.pf-source-head {
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-gap .pf-name,
.pf-gap .pf-num {
    color: var(--pf-muted);
}

/* Issue 24: holdings without an asset class, marked in Groups and Klassen. */
.pf-unclassified .pf-name,
.pf-unclassified .pf-alloc-name {
    color: var(--danger-color);
}

.pf-unknown,
.pf-incomplete {
    color: var(--pf-red);
    font-size: 12px;
    font-weight: 400;
}

.pf-foot {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
    padding-top: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pf-note {
    color: var(--pf-muted);
    font-size: 12px;
    margin-top: 12px;
}

.pf-empty {
    color: var(--pf-muted);
    padding: 13px 0;
    border-bottom: 1px solid var(--pf-border);
}

.pf-account {
    border-bottom: 1px solid var(--pf-border);
}

.pf-account > summary.pf-row {
    border-bottom: 0;
}

.pf-account-body {
    padding-bottom: 12px;
}

.pf-assign {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-assign label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.pf-assign select {
    font: inherit;
    font-size: 13px;
    color: var(--pf-text);
    background: var(--pf-bg);
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    padding: 5px 7px;
    max-width: 100%;
}

.pf-assign select:disabled {
    opacity: 0.5;
}

.pf-btn {
    font: inherit;
    font-size: 13px;
    color: var(--pf-text);
    background: var(--pf-bg);
    border: 1px solid var(--pf-border);
    border-radius: 7px;
    padding: 5px 10px;
    cursor: pointer;
}

.pf-btn:hover {
    border-color: var(--pf-blue);
    color: var(--pf-blue);
}

/* Holdings of one account on the Accounts tab: manual positions can be
   deleted there, bot holdings are read-only (fifth column stays empty). */
.pf-holdings .pf-source {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(110px, auto) minmax(200px, auto) minmax(120px, auto) 34px;
    gap: 12px 20px;
    align-items: center;
}

.pf-avg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.pf-avg input {
    font: inherit;
    font-size: 13px;
    text-align: right;
    color: var(--pf-text);
    background: var(--pf-bg);
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    padding: 3px 6px;
    width: 96px;
    font-variant-numeric: tabular-nums;
}

.pf-avg input:focus-visible {
    outline: 2px solid var(--pf-blue);
    outline-offset: 2px;
}

.pf-btn-save {
    padding: 3px 7px;
    line-height: 1;
}

.pf-pnl {
    font-size: 11px;
    margin-top: 3px;
}

.pf-actions {
    text-align: right;
}

.pf-delete {
    margin: 0;
}

.pf-btn-danger {
    padding: 3px 7px;
    line-height: 1;
}

.pf-btn-danger:hover {
    border-color: var(--pf-red);
    color: var(--pf-red);
}

.pf-btn-primary {
    color: var(--panel);
    background: var(--pf-blue);
    border-color: var(--pf-blue);
}

.pf-btn-primary:hover {
    color: var(--panel);
    opacity: 0.9;
}

.pf-add {
    margin-top: 8px;
}

.pf-add input {
    font: inherit;
    font-size: 13px;
    color: var(--pf-text);
    background: var(--pf-bg);
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    padding: 5px 7px;
    width: 110px;
}

.pf-add input:focus-visible {
    outline: 2px solid var(--pf-blue);
    outline-offset: 2px;
}

.pf-account .pf-assign + .pf-assign {
    margin-top: 8px;
}

.pf-new-account {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 4px;
}

.pf-empty-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

@media (max-width: 640px) {
    .pf-panel {
        padding: 14px;
    }

    .pf-tabs {
        gap: 18px;
    }

    .pf-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        gap: 4px 10px;
    }

    .pf-row .pf-num:not(.pf-share) {
        grid-column: 2;
        grid-row: 1;
    }

    .pf-row .pf-detail {
        grid-column: 1 / -1;
        font-size: 12px;
    }

    .pf-row .pf-share,
    .pf-head .pf-detail {
        display: none;
    }

    .pf-source {
        grid-template-columns: 1fr 1fr;
    }

    .pf-source.pf-source-asset {
        grid-template-columns: 1fr 1fr;
    }

    .pf-holdings .pf-source {
        grid-template-columns: 1fr 1fr 34px;
    }

    .pf-holdings .pf-source > :nth-child(4),
    .pf-holdings .pf-source-head span:nth-child(4) {
        grid-column: 1 / -1;
        text-align: left;
    }

    .pf-holdings .pf-source > :nth-child(2),
    .pf-holdings .pf-source-head span:nth-child(2) {
        display: none;
    }

    .pf-source .pf-num {
        text-align: left;
    }
}

@media (max-width: 700px) {
    .page-portfolio .container-fluid.pf-main {
        padding: 12px 12px 36px;
    }

    .pf-values {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pf-tile-value {
        font-size: 22px;
    }

    .pf-period button {
        flex: 1 1 auto;
        padding: 7px 9px;
    }

    .pf-checks {
        gap: 4px 12px;
    }
}

@media (max-width: 400px) {
    .pf-tile {
        padding: 12px;
    }

    .pf-tile-value {
        font-size: 19px;
        letter-spacing: -0.4px;
    }

    .pf-chart {
        padding: 16px 12px;
    }
}
.page-strategy-monitoring {
    --pf-bg: var(--bg); --pf-panel: var(--panel); --pf-text: var(--ink);
    --pf-muted: var(--muted); --pf-border: var(--line); --pf-blue: var(--accent);
    --pf-green: var(--positive); --pf-red: var(--negative);
    --pf-usd: var(--accent); --pf-eur: var(--series-2); --pf-btc: var(--series-3); --pf-eth: var(--series-4);
    background: var(--pf-bg); color: var(--pf-text);
}
.sm-list { display: grid; gap: 1rem; }
.sm-row {
    display: grid; grid-template-columns: minmax(180px, .8fr) minmax(310px, 1.15fr) minmax(430px, 1.7fr);
    background: var(--pf-panel); border: 1px solid var(--pf-border); border-radius: 12px;
    box-shadow: var(--shadow); overflow: hidden;
}
.sm-block { padding: 1rem; min-width: 0; }
.sm-block + .sm-block { border-left: 1px solid var(--pf-border); }
.sm-heading { color: var(--pf-muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .75rem; }
.sm-heading small { font-weight: 400; letter-spacing: 0; text-transform: none; }
.sm-strategy-line { display: flex; align-items: center; gap: .45rem; font-size: 1.05rem; margin-bottom: .85rem; }
.sm-account-line { margin-top: -.6rem; margin-bottom: .85rem; }
.sm-account-line a { color: inherit; text-decoration: underline dotted; }
.sm-account-line a:hover, .sm-account-line a:focus-visible { color: var(--pf-text); text-decoration-style: solid; }
.sm-label { display: block; color: var(--pf-muted); font-size: .72rem; margin-bottom: .15rem; }
.sm-value code { color: inherit; font-size: 1rem; font-weight: 700; }
.sm-pnl-layout { display: grid; grid-template-columns: 1.2fr repeat(3, .7fr) 1.35fr; align-items: center; gap: .65rem; }
.sm-change { text-align: right; font-variant-numeric: tabular-nums; }
.sm-change > span { display: block; color: var(--pf-muted); font-size: .72rem; }
.sm-pnl-chart { text-align: right; }
.sm-line-chart { overflow: visible; }
.sm-line-chart polyline { fill: none; stroke: var(--pf-blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sm-line-chart circle { fill: var(--pf-blue); stroke: var(--pf-panel); stroke-width: 1; }
.sm-line-up polyline { stroke: var(--pf-green); }
.sm-line-up circle { fill: var(--pf-green); }
.sm-line-down polyline { stroke: var(--pf-red); }
.sm-line-down circle { fill: var(--pf-red); }
.sm-ops-grid { display: grid; grid-template-columns: repeat(3, minmax(80px, 1fr)); gap: .8rem 1rem; align-items: end; font-variant-numeric: tabular-nums; }
.sm-ops-grid > div:first-child { grid-column: 1 / -1; }
.sm-ops-grid code { color: inherit; white-space: nowrap; }
.sm-ops-grid small { color: var(--pf-muted); }
.sm-jump-warning { display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; padding: 0; border: 1px solid var(--warn-line); border-radius: 50%; color: var(--warn); background: var(--warn-bg); font-weight: 800; font-size: inherit; font-family: inherit; line-height: 1; cursor: default; }
.sm-jump-warning:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
@media (max-width: 1199px) {
    .sm-row { grid-template-columns: 1fr 2fr; }
    .sm-operations { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--pf-border); }
}
@media (max-width: 767px) {
    .sm-row { display: block; }
    .sm-block + .sm-block { border-left: 0; border-top: 1px solid var(--pf-border); }
    .sm-pnl-layout { grid-template-columns: repeat(3, 1fr); }
    .sm-pnl-layout .sm-value, .sm-pnl-chart { grid-column: span 3; text-align: left; }
    .sm-change { text-align: left; }
    .sm-ops-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compact one-row-per-strategy dashboard table (>= 1280px, issue 36). The account
   detail page keeps the card layout above (.sm-list / .sm-row / .sm-block). */
.sm-table {
    width: 100%; border-collapse: collapse; table-layout: auto;
    background: var(--pf-panel); border: 1px solid var(--pf-border); border-radius: 12px;
    box-shadow: var(--shadow);
}
/* The wrapper clips the rounded corners (the table itself must not be a
   scroll container, or the pinned strategy column would not stick). */
.sm-table-wrap { overflow-x: auto; border-radius: 12px; position: relative; }
.sm-table th, .sm-table td { padding: .5rem .35rem; vertical-align: middle; white-space: nowrap; font-size: .85rem; }
.sm-table td:first-child, .sm-table th:first-child { padding-left: .9rem; }
.sm-table td code { font-size: .8rem; padding: .1rem .25rem; }
.sm-table .sm-strategy-link, .sm-table .sm-strategy-cell strong { font-size: .9rem; }
.sm-table td small { font-size: .8rem; }
.sm-table thead tr:last-child th { white-space: normal; }
.sm-table thead th {
    color: var(--pf-muted); font-size: .68rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; text-align: left; border-bottom: 1px solid var(--pf-border);
    background: var(--head); position: sticky; top: 0; z-index: 1;
}
.sm-table thead tr:first-child th { font-size: .72rem; }
.sm-table thead th small { font-weight: 400; letter-spacing: 0; text-transform: none; }
.sm-table th.sm-num, .sm-table td.sm-num { text-align: right; }
.sm-table td, .sm-table th { font-variant-numeric: tabular-nums; }
.sm-table tbody tr { border-bottom: 1px solid var(--pf-border); }
.sm-table tbody tr:last-child { border-bottom: 0; }
.sm-table td code { color: inherit; font-weight: 700; }
/* Column-group shading + separators, matching the header groups: Strategy/NAV
   (cols 1-2), PnL (cols 3-7), Operations (cols 8-14). */
.sm-table .sm-group-nav { background: var(--pf-panel); }
.sm-table .sm-group-pnl { background: var(--stripe); }
.sm-table .sm-group-ops { background: var(--bg); }
.sm-table > * > tr > :nth-child(3),
.sm-table > * > tr > :nth-child(8) {
    border-left: 1px solid var(--pf-border);
}
.sm-strategy-cell { white-space: nowrap; }
.sm-strategy-cell .sm-jump-warning { margin-right: .4rem; vertical-align: middle; }
.sm-strategy-link { color: inherit; font-weight: 700; text-decoration: none; }
.sm-strategy-link:hover, .sm-strategy-link:focus-visible { text-decoration: underline; }
.sm-chart-cell { min-width: 0; }
.sm-table .sm-line-chart { width: 130px; height: 40px; }
.sm-table .status-indicator { margin-right: .3rem; }
.sm-curve-wrap { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }
.sm-curve-end { white-space: nowrap; }
.sm-curve-zero { stroke: var(--pf-border); stroke-width: 1; stroke-dasharray: 2 2; }
.sm-fee code { white-space: nowrap; }
.sm-table td[data-label]::before { content: none; }

/* Issue 36: no fixed row height (64px clipped two-line content). A cell
   height on a table cell is a minimum; the row grows with its content. */
.sm-table tr.sm-tr > td, .sm-table tr.sm-total-row > * { height: 52px; }
.sm-table tr[hidden] { display: none; }

/* Column priorities: strategy, status and the weekly chart keep their width;
   the less important status columns wrap in a controlled way. */
.sm-strategy-inner { display: flex; align-items: center; gap: .4rem; }
.sm-strategy-name { min-width: 0; }
.sm-table .sm-account-line { margin: .1rem 0 0; line-height: 1.3; }
.sm-strategy-head { white-space: nowrap; }
/* Sortable headers (strategies table) and the sort / reference form. */
.sm-sort-link { color: inherit; text-decoration: none; }
.sm-sort-link:hover, .sm-sort-link:focus-visible { color: var(--pf-text, inherit); text-decoration: underline; }
.sm-sort-mark { margin-left: .2rem; opacity: .35; font-size: .65rem; }
.sm-sorted .sm-sort-mark { opacity: 1; }
.sm-sorted .sm-sort-link { color: var(--pf-text, inherit); }
.sm-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; margin: 0 0 .75rem; }
.sm-toolbar label { display: flex; flex-direction: column; gap: .15rem; font-size: .75rem; color: var(--pf-muted); }
.sm-toolbar .form-select { min-width: 9rem; }
.sm-toolbar-help { align-self: center; max-width: 36rem; }
.sm-ref-badge { margin-left: .35rem; padding: .05rem .4rem; border-radius: 999px; border: 1px solid var(--pf-border); color: var(--pf-text); font-weight: 700 !important; }
.sm-reference-note { margin: .6rem 0 0; font-size: .78rem; color: var(--pf-muted); }
.sm-reference-note ul { padding-left: 1.1rem; }
.sm-toggle-space { display: inline-block; width: 1.6rem; flex: 0 0 1.6rem; }
.sm-strategy-head .sm-toggle-space { vertical-align: middle; margin-right: .4rem; }
.sm-table td.sm-fee { white-space: normal; min-width: 6.5rem; max-width: 10rem; font-size: .8rem; }
.sm-fee-main { white-space: nowrap; font-weight: 600; }
.sm-fee-usd { display: block; color: var(--pf-muted); }
.sm-fee-link { text-align: left; }
/* Strategy has priority: names up to the column minimum never wrap; only
   longer ones break at their "_" / "-" separators (soft_breaks filter). */
.sm-table .sm-strategy-cell { min-width: 17rem; }
.sm-table .sm-strategy-name { max-width: 18rem; }
.sm-table td.sm-age { white-space: normal; min-width: 4.8rem; }
.sm-table td.sm-age small { display: inline-block; }
.sm-table td.sm-rate { white-space: nowrap; }
.sm-rate-count { color: var(--pf-muted); font-weight: 400; }

/* Detail toggle (button, aria-expanded). */
.sm-detail-toggle {
    display: inline-grid; place-items: center; flex: 0 0 1.6rem; width: 1.6rem; height: 1.6rem; padding: 0;
    border: 1px solid var(--pf-border); border-radius: 6px; background: var(--pf-panel); color: var(--pf-muted); cursor: pointer;
}
.sm-detail-toggle:hover { color: var(--pf-text); border-color: var(--pf-muted); }
.sm-detail-toggle:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
.sm-chevron {
    width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(-45deg); transition: transform .15s ease;
}
.sm-detail-toggle[aria-expanded="true"] { color: var(--pf-blue); border-color: var(--pf-blue); }
.sm-detail-toggle[aria-expanded="true"] .sm-chevron { transform: rotate(45deg); margin-top: -.2rem; }
@media (prefers-reduced-motion: reduce) { .sm-chevron { transition: none; } }

/* Gesamt block: its own table above the strategies, same columns. */
.sm-total-block { margin-bottom: 1rem; }
/* Set by monitoring.js once both tables share measured column widths. */
.sm-table.sm-aligned { table-layout: fixed; }
/* All bots' positions can be a long list: scroll inside, header stays. */
.sm-total-table .sm-detail-scroll { max-height: 22rem; overflow-y: auto; }
.sm-total-table .sm-pos-table thead th { position: sticky; top: 0; z-index: 1; background: var(--head); }
.sm-table.sm-aligned > tbody > tr > td, .sm-table.sm-aligned > tbody > tr > th { overflow-wrap: anywhere; }
.sm-table tbody.sm-total-body tr.sm-total-row > * {
    background: var(--accent-soft); border-bottom: 2px solid var(--pf-blue); font-weight: 600;
}
.sm-total-label { font-size: .95rem; font-weight: 700; }
.sm-total-row th { text-align: left; }
.sm-coverage-count, .sm-coverage-note { display: block; color: var(--pf-muted); font-size: .7rem; font-weight: 400; }
.sm-table td.sm-total-coverage { white-space: normal; }
.sm-coverage summary { cursor: pointer; color: var(--warn); font-size: .8rem; font-weight: 600; }
.sm-coverage ul { margin: .25rem 0 0; padding-left: 1rem; font-size: .75rem; font-weight: 400; color: var(--pf-muted); }

/* Expanded detail row. */
.sm-table tbody.sm-open tr.sm-tr > td { border-bottom: 0; }
.sm-table tr.sm-detail-row > td { background: var(--pf-panel); padding: 0; white-space: normal; height: auto; }
.sm-detail {
    position: sticky; left: 0; max-width: min(100%, calc(100vw - 48px));
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem 1.5rem;
    padding: .9rem 1rem 1.1rem 2.9rem; border-top: 1px dashed var(--pf-border);
}
.sm-detail-title { margin: 0 0 2px; font-size: .9rem; font-weight: 600; color: var(--accent); }
.sm-detail-scroll { overflow-x: auto; margin-top: .5rem; }
.sm-detail-scroll:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
/* Compact positions table (user request): small font, tight rows. */
.sm-table .sm-pos-table, .sm-pos-table { width: 100%; border-collapse: collapse; font-size: .72rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sm-table .sm-pos-table th, .sm-table .sm-pos-table td { padding: .12rem .45rem; border-bottom: 1px solid var(--pf-border); white-space: nowrap; font-size: .72rem; height: auto; }
.sm-table .sm-pos-table thead th { color: var(--pf-muted); font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-align: left; position: static; }
.sm-pos-count {
    display: inline-block; min-width: 1.1rem; margin-left: .2rem; padding: 0 .25rem; border-radius: 999px;
    background: var(--head); color: var(--muted); font-size: .6rem; font-weight: 600; text-align: center;
}
.sm-table .sm-pos-table thead th.sm-num { text-align: right; }
.sm-pos-table .sm-num { text-align: right; }
.sm-pos-table tbody th { font-weight: 700; }
.sm-pos-table tfoot th, .sm-pos-table tfoot td { border-bottom: 0; font-weight: 600; }
.sm-pos-table tfoot td.pf-sub { font-weight: 400; }
.sm-pos-table .pf-incomplete { white-space: normal; }
.sm-detail .sm-exposure { margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
/* Issue 41: the allocation tables sit inside the strategies table: undo its cell rules. */
.sm-table .pf-alloc-table th, .sm-table .pf-alloc-table td,
.sm-table .pf-alloc-summary th, .sm-table .pf-alloc-summary td {
    padding: 2px 5px; height: auto; white-space: normal; vertical-align: top; font-size: inherit;
    border-bottom: 1px solid var(--pf-border);
}
.sm-table .pf-alloc-table thead tr th, .sm-table .pf-alloc-summary thead tr th {
    position: static; background: transparent; font-size: .62rem; font-weight: 700; color: var(--pf-muted);
    text-transform: uppercase; letter-spacing: .03em; border-bottom-color: var(--grid-strong);
}
.sm-table .pf-alloc-table .pf-num, .sm-table .pf-alloc-summary .pf-num { white-space: nowrap; text-align: right; }
.sm-table .pf-alloc-table tbody tr, .sm-table .pf-alloc-summary tbody tr { border-bottom: 0; }
.sm-exposure .pf-alloc-table { font-size: .72rem; }
.sm-exposure .pf-alloc-summary { font-size: .74rem; max-width: none; }
.sm-exposure .pf-alloc-summary tbody th .pf-sub { display: none; }
.sm-exposure .pf-alloc-table .pf-smeter { display: none; }
.sm-exposure .pf-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem 1rem; flex-wrap: wrap; margin: 0; }
.sm-exposure .pf-alloc-switch button { min-height: 32px; padding: 4px 0 6px; font-size: .8rem; }
.sm-exposure .pf-alloc-body { padding-top: .5rem; grid-template-columns: 150px minmax(0, 1fr); gap: 1rem; }
.sm-exposure .pf-pie-svg, .sm-exposure .pf-pie { width: 140px; height: 140px; }
.sm-exposure .pf-alloc-summary { font-size: .78rem; margin-top: .4rem; }
.sm-exposure .pf-note { margin-top: .5rem; font-size: .72rem; }
@media (max-width: 1099px) {
    .sm-detail { grid-template-columns: minmax(0, 1fr); padding-left: 1rem; }
}
@media (max-width: 600px) {
    .sm-exposure .pf-alloc-body { grid-template-columns: minmax(0, 1fr); }
}

/* Table view (>= 1280px; the page is at most 1600px wide, so this is every
   desktop width): compact variant. Tighter padding, chart value under the
   line, success-rate count and status age under their indicator. If it still
   does not fit (very long names, very large numbers), the table scrolls
   horizontally with the strategy column pinned; it never clips. */
@media (min-width: 1280px) {
    .sm-table th, .sm-table td { padding: .45rem .3rem; }
    .sm-table td code { font-size: .78rem; padding: .1rem .15rem; }
    .sm-table .sm-line-chart { width: 100px; height: 34px; }
    .sm-table .sm-curve-wrap { flex-direction: column; align-items: flex-end; gap: 0; }
    .sm-table .sm-curve-end { font-size: .78rem; line-height: 1.1; }
    .sm-table .status-indicator { font-size: .7rem; }
    .sm-table td.sm-rate .sm-rate-count { display: block; font-size: .72rem; }
    .sm-table td.sm-age .status-indicator { display: block; margin: 0; line-height: 1.2; }
    .sm-table td.sm-age { min-width: 4.2rem; }
    .sm-table td:first-child, .sm-table th:first-child { padding-left: .6rem; }
    .sm-table .spark-chart { width: 72px; }
    .sm-table .sm-strategy-cell { min-width: 15.5rem; }
    .sm-table td.sm-fee { min-width: 6rem; max-width: 7.5rem; }
    .sm-table .sm-fee-main { white-space: normal; }
    .sm-table .sm-strategy-name { max-width: 14rem; }
}
@media (min-width: 1440px) {
    /* Room for the fee balance on one line. */
    .sm-table td.sm-fee { max-width: 10rem; }
    .sm-table .sm-fee-main { white-space: nowrap; }
}
@media (min-width: 1280px) {
    .sm-table .sm-strategy-cell, .sm-table .sm-strategy-head { position: sticky; left: 0; z-index: 1; }
    .sm-table thead .sm-strategy-head { z-index: 2; }
    .sm-table tbody .sm-strategy-cell { box-shadow: 1px 0 0 var(--pf-border); }
}

/* Below 1280px: the existing card view (one card per strategy), earlier than
   before (1200px) because the 14 columns do not fit at 1200-1279px. */
@media (max-width: 1279px) {
    /* Child combinators only: the nested positions table keeps its layout. */
    .sm-table, .sm-table > thead, .sm-table > tbody, .sm-table > tbody > tr,
    .sm-table > tbody > tr > th, .sm-table > tbody > tr > td {
        display: block; width: auto;
    }
    .sm-table > colgroup, .sm-table > thead { display: none; }
    .sm-table > tbody > tr[hidden] { display: none; }
    .sm-table > tbody > tr.sm-tr, .sm-table > tbody > tr.sm-total-row {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .35rem 1rem;
        padding: .75rem 1rem; border-bottom: 1px solid var(--pf-border);
    }
    .sm-table tr.sm-tr > td, .sm-table tr.sm-total-row > * { height: auto; }
    .sm-table > tbody > tr > td, .sm-table > tbody > tr.sm-total-row > th {
        border-left: 0 !important; text-align: left !important; padding: .2rem 0;
        white-space: normal; max-width: none; min-width: 0;
    }
    .sm-table .sm-strategy-cell, .sm-table .sm-chart-cell, .sm-table .sm-total-coverage { grid-column: 1 / -1; }
    .sm-table .sm-empty-cell { display: none; }
    .sm-table .sm-group-nav, .sm-table .sm-group-pnl, .sm-table .sm-group-ops {
        background: transparent;
    }
    .sm-table tbody.sm-total-body tr.sm-total-row { background: var(--accent-soft); border-bottom: 2px solid var(--pf-blue); }
    .sm-table tbody.sm-total-body tr.sm-total-row > * { background: transparent; border-bottom: 0; }
    .sm-table > tbody > tr > td[data-label]:not(.sm-strategy-cell)::before {
        content: attr(data-label); display: block; color: var(--pf-muted); font-size: .72rem; font-weight: 400;
    }
    .sm-table-wrap { overflow-x: visible; }
    .sm-chart-cell { min-width: 0; }
    .sm-curve-wrap { justify-content: flex-start; }
    .sm-table .sm-strategy-name { max-width: none; }
    .sm-table .sm-strategy-cell { min-width: 0; }
    .sm-table td.sm-fee { max-width: none; }
    .sm-table > tbody > tr.sm-detail-row > td { padding: 0; }
    .sm-detail { position: static; max-width: none; }
}

/* Strategy monitoring: NAV tiles, styled like the portfolio overview. */
.sm-nav { margin-bottom: 1.25rem; }
.sm-nav-head { margin-bottom: .75rem; }
.page-strategy-monitoring .sm-nav-title { margin: 0 0 3px; font-size: 16px; font-weight: 600; color: var(--pf-text); }
.sm-nav .pf-sub { color: var(--pf-muted); font-size: 12px; }
.pf-tile-changes { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--pf-border); display: grid; gap: 4px; }
.pf-tile-change {
    display: grid; grid-template-columns: 4.5em auto 1fr; align-items: baseline; gap: 8px;
    font-size: 13px; font-variant-numeric: tabular-nums;
}
.pf-tile-change dt { color: var(--pf-muted); font-weight: 400; font-size: 12px; }
.pf-tile-change dd { margin: 0; white-space: nowrap; }
.pf-tile-pct { font-weight: 600; }
.pf-tile-amount { text-align: right; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.pf-tile-change.pf-change-na .pf-tile-amount { color: var(--pf-muted); }
/* Change lines are transfer-adjusted: a small label under them (scope in its
   tooltip) and an asterisk on a window that could only partly be adjusted. */
.pf-tile-adjusted { margin-top: 6px; font-size: 11px; color: var(--pf-muted); cursor: help; }
.pf-tile-partial { margin-left: 2px; color: var(--pf-muted); }
.pf-tile-change[title] { cursor: help; }
@media (max-width: 991px) { .sm-nav .pf-values { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 576px) { .sm-nav .pf-values { grid-template-columns: 1fr; } }

/* Tile head shared by portfolio and strategy monitoring: name and USD rate on
   the first line, the value beside a sparkline that opens the history pop-up. */
.pf-tile-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pf-tile-rate { font-size: 12px; color: var(--pf-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-tile-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-tile-spark { flex: none; cursor: pointer; border-radius: 6px; overflow: visible; }
.pf-tile-spark:hover, .pf-tile-spark:focus-visible { background: var(--pf-bg); outline: none; }
.pf-tile-spark:focus-visible { box-shadow: 0 0 0 2px var(--pf-blue); }
.pf-tile-spark-empty { display: none; }
.pf-tile-spark-line { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.pf-tile-spark-up { stroke: var(--pf-green); }
.pf-tile-spark-down { stroke: var(--pf-red); }
.pf-tile-spark-flat { stroke: var(--pf-muted); }

/* History pop-up of a tile (same frame as the 30-day trade chart). */
.nav-chart-modal .pf-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------------------
   issue 20: results + performance matrix
   ------------------------------------------------------------------------ */
.pf-results,
.pf-returns {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 18px;
    min-width: 0;
}

.pf-returns {
    margin-top: 18px;
    margin-bottom: 0;
}

.pf-results-sub {
    margin-bottom: 12px;
}

.pf-result-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 680px;
    align-items: start;
}

.pf-result-tile {
    border: 1px solid var(--pf-border);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 0;
}

.pf-result-tile .pf-tile-label {
    margin-bottom: 4px;
}

.pf-result-value {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-monthly {
    margin-top: 16px;
}

.pf-monthly-head b {
    font-weight: 600;
    font-size: 14px;
}

svg.pf-bars {
    display: block;
    width: 100%;
    height: 210px;
    margin-top: 6px;
}

.pf-bars-zero { stroke: var(--pf-muted); stroke-width: 1; }
.pf-bar-up { fill: var(--pf-green); }
.pf-bar-down { fill: var(--pf-red); }
.pf-bar-prov { fill-opacity: 0.4; stroke-dasharray: 3 2; stroke-width: 1; }
.pf-bar-up.pf-bar-prov { stroke: var(--pf-green); }
.pf-bar-down.pf-bar-prov { stroke: var(--pf-red); }
.pf-bar-label,
.pf-bar-note,
.pf-bar-na,
.pf-bar-value {
    text-anchor: middle;
    fill: var(--pf-muted);
    font-size: 11px;
}
.pf-bar-label-prov { font-weight: 700; fill: var(--pf-text); }
.pf-bar-note { font-size: 9px; }
.pf-bar-value { font-size: 10px; fill: var(--pf-text); }

/* Text fallback of the bars: visually hidden, read by screen readers. */
.pf-bars-list {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.pf-provisional {
    font-size: 11px;
    color: var(--pf-muted);
}

.pf-method {
    margin-top: 8px;
}

.pf-returns-scroll {
    overflow-x: auto;
    margin-top: 12px;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

table.pf-matrix {
    border-collapse: separate;
    border-spacing: 3px;
    width: 100%;
    min-width: 720px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

table.pf-matrix th {
    font-weight: 600;
    color: var(--pf-muted);
    padding: 6px 3px;
    text-align: center;
}

table.pf-matrix td {
    text-align: center;
    padding: 9px 3px;
    border-radius: 3px;
    white-space: nowrap;
    color: var(--pf-muted);
}

table.pf-matrix td.pf-pos { background: var(--good-bg); color: var(--pf-green); }
table.pf-matrix td.pf-neg { background: var(--bad-bg); color: var(--negative); }
table.pf-matrix td.pf-prov { outline: 1px dashed currentColor; outline-offset: -2px; }
table.pf-matrix .pf-matrix-total {
    font-weight: 700;
    border-left: 2px solid var(--pf-border);
}

@media (max-width: 600px) {
    .pf-results,
    .pf-returns {
        padding: 14px;
    }
    .pf-result-tiles {
        max-width: none;
    }
    .pf-result-value {
        font-size: 18px;
    }
    svg.pf-bars {
        height: 170px;
    }
}

/* --- Current Prices: class -> parent coin -> coins (issues 23, 26) -------- */
.xc > .xc-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .75rem;
    padding: .4rem 0;
    cursor: pointer;
    list-style: none;
    border-bottom: 2px solid var(--line);
    margin-bottom: .5rem;
}
.xc > .xc-summary::-webkit-details-marker { display: none; }
.xc > .xc-summary::before { content: "\25B8"; color: var(--muted); transition: transform .15s; }
.xc[open] > .xc-summary::before { transform: rotate(90deg); }
.xc-name { font-size: 1.1rem; font-weight: 600; }
.xc.xc-unassigned > .xc-summary { border-bottom-color: var(--danger-color); }
.xc-body { min-width: 0; }
.xg-suggestion-list { max-height: 12rem; overflow-y: auto; }
.xg-member-parent { background: var(--stripe); }
.xg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    justify-content: space-between;
}
.xg.xg-has-warning { border-left: 4px solid var(--warning-color); }
.xg.xg-unassigned { border-left: 4px solid var(--danger-color); }
.xg-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .75rem;
    padding: .6rem .9rem;
    cursor: pointer;
    list-style: none;
}
.xg-summary::-webkit-details-marker { display: none; }
.xg-summary::before {
    content: "\25B8";
    color: var(--muted);
    transition: transform .15s;
}
.xg[open] > .xg-summary::before { transform: rotate(90deg); }
.xg-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.xg-name { font-weight: 600; overflow-wrap: anywhere; }
.xg-badges { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.xg-ref { margin-left: auto; white-space: nowrap; }
.xg-body { padding: 0 .9rem .75rem; border-top: 1px solid var(--line); }
.xg-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .6rem 0;
}
.xg-controls form, .xg-member-actions form { min-width: 0; max-width: 100%; }
.xg-assign .form-select,
.xg-assign .form-control { width: auto; min-width: 0; max-width: 11rem; flex: 1 1 7rem; }
.xg-member {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .75rem;
    align-items: center;
    padding: .5rem .6rem;
    border-left: 4px solid transparent;
    border-top: 1px solid var(--line);
}
.xg-member.status-success { border-left-color: var(--success-color); }
.xg-member.status-warning { border-left-color: var(--warning-color); }
.xg-member.status-danger { border-left-color: var(--danger-color); }
.xg-member.status-unknown { border-left-color: var(--muted); }
.xg-member-warn { background: var(--warn-bg); }
.xg-member-main { overflow-wrap: anywhere; }
.xg-member-meta { display: flex; flex-wrap: wrap; gap: .1rem .9rem; grid-column: 1; }
.xg-member-meta .status-indicator { font-size: 1rem; margin-right: .25rem; }
.xg-member-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: flex-end;
    grid-column: 2;
    grid-row: 1 / span 2;
}
@media (max-width: 767px) {
    .xg-member { grid-template-columns: minmax(0, 1fr); }
    .xg-member-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
    .xg-ref { margin-left: 0; }
}

/* ------------------------------------------------------------------------
   Account detail: daily NAV according to TX, simulation slot (issue 27)
   ------------------------------------------------------------------------ */
.page-account-detail { --pf-tx: var(--ink); }
.tx-account { margin-top: 2rem; }
.tx-portfolio, .tx-simulation {
    background: var(--pf-panel); border: 1px solid var(--pf-border); border-radius: 12px;
    padding: 1rem; margin-top: 1rem; min-width: 0;
}
.tx-portfolio-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 .5rem; overflow-wrap: anywhere; }
.tx-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .25rem 1rem; margin: 0; }
.tx-meta dt { font-size: .75rem; color: var(--pf-muted); font-weight: 500; }
.tx-meta dd { margin: 0; overflow-wrap: anywhere; }
.tx-chart { margin-top: 1rem; }
.tx-table-wrap { margin-top: 1rem; }
.tx-table caption { caption-side: top; }
.tx-table td, .tx-table th { white-space: nowrap; }
.tx-row-missing td { background: var(--bad-bg); }
.tx-status { font-size: .75rem; border-radius: 999px; padding: 0 .45rem; border: 1px solid currentColor; }
.tx-status-complete { color: var(--pf-green); }
.tx-status-missing { color: var(--pf-red); }
.tx-price-marker {
    display: inline-block; margin-left: .25rem; font-size: .7rem; padding: 0 .4rem;
    border-radius: 4px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); cursor: help;
}
.tx-more { margin-top: .5rem; }
.tx-simulation-frame {
    display: block; width: 100%; height: 70vh; max-height: 900px; min-height: 320px;
    border: 1px solid var(--pf-border); border-radius: 8px; background: var(--panel); resize: vertical;
}
.sm-tx-marker {
    display: inline-block; font-size: .65rem; font-weight: 600; padding: 0 .3rem; margin-left: .25rem;
    border-radius: 4px; border: 1px solid var(--pf-muted); color: var(--pf-muted); vertical-align: middle;
}
@media (max-width: 600px) {
    .tx-table thead { display: none; }
    .tx-table, .tx-table tbody, .tx-table tr, .tx-table td { display: block; width: 100%; }
    .tx-table tr[hidden] { display: none; }
    .tx-table tr { border-bottom: 1px solid var(--pf-border); padding: .35rem 0; }
    .tx-table td { display: flex; justify-content: space-between; gap: .75rem; border: 0; padding: .1rem 0; white-space: normal; text-align: right; }
    .tx-table td::before { content: attr(data-label); color: var(--pf-muted); font-size: .8rem; text-align: left; }
    .tx-table caption { display: block; }
}

/* ------------------------------------------------------------------------
   Strategien: overview, Performance and Simulation pages (issue 28).
   Look of the simulation report (tx_database/simulation/report_html.py):
   calm grey page, white panels, blue accent headings, compact tables.
   ------------------------------------------------------------------------ */
.page-strategies {
    --pf-bg: var(--bg); --pf-panel: var(--panel); --pf-text: var(--ink); --pf-muted: var(--muted);
    --pf-border: var(--line); --pf-blue: var(--accent); --pf-green: var(--positive); --pf-red: var(--negative);
    --st-head: var(--head);
    --st-account: var(--accent); --st-bench-0: var(--series-3); --st-bench-1: var(--series-4);
    --pf-usd: var(--accent); --pf-btc: var(--series-3); --pf-eth: var(--series-4); --pf-tx: var(--ink);
    background: var(--pf-bg); color: var(--pf-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px; line-height: 1.5;
}
.page-strategies .container-fluid { background: transparent; }
.page-strategies h1 { color: var(--pf-text); }
.page-strategies code { background: transparent; color: inherit; padding: 0; font-size: .9em; }

/* Strategy head: back link, name, scope line, local Performance | Simulation switch. */
.st-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.st-head-main { min-width: 0; }
.st-back { font-size: 12px; }
.st-back a { color: var(--pf-muted); text-decoration: none; }
.st-back a:hover, .st-back a:focus-visible { color: var(--pf-blue); text-decoration: underline; }
.page-strategies h1.st-title { margin: 0 0 4px; font-size: 24px; font-weight: 500; letter-spacing: -.2px; overflow-wrap: anywhere; }
.st-scope { color: var(--pf-muted); font-size: 13px; }
.st-switch { display: flex; gap: 20px; border-bottom: 1px solid var(--pf-border); }
.st-switch-link { color: var(--pf-muted); text-decoration: none; padding: 6px 2px 8px; border-bottom: 2px solid transparent; font-weight: 500; }
.st-switch-link:hover, .st-switch-link:focus-visible { color: var(--pf-text); }
.st-switch-link.active, .st-switch-link[aria-current="page"] { color: var(--pf-blue); border-bottom-color: var(--pf-blue); }

/* Period selection YTD / All (links, so the choice is in the URL). */
.st-period-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.st-period { display: inline-flex; }
.st-period-link { font: inherit; color: var(--pf-muted); text-decoration: none; border-radius: 6px; padding: 6px 12px; }
.st-period-link:hover, .st-period-link:focus-visible { color: var(--pf-text); }
.st-period-link[aria-pressed="true"] { background: var(--pf-blue); color: var(--panel); }
.st-period-note { font-size: 12px; }
.st-warn { color: var(--warn); }

/* Panels. */
.st-panel {
    background: var(--pf-panel); border: 1px solid var(--pf-border); border-radius: 12px;
    padding: 14px 16px; min-width: 0; margin-bottom: 16px;
}
.st-panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-strategies .st-panel h2 { margin: 0; font-size: 16px; font-weight: 500; color: var(--pf-blue); }
.page-strategies .st-section-title { font-size: 16px; font-weight: 500; color: var(--pf-blue); margin: 24px 0 10px; }
.st-table-wrap { overflow-x: auto; }

/* Compact tables with a tinted header row. */
.st-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.st-table th, .st-table td { padding: 5px 8px; border-bottom: 1px solid var(--pf-border); text-align: left; font-weight: 400; vertical-align: top; }
.st-table thead th { background: var(--st-head); font-weight: 500; color: var(--pf-text); white-space: nowrap; }
.st-table th.sm-num, .st-table td.sm-num { text-align: right; white-space: nowrap; }
.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table .st-group td { color: var(--pf-muted); font-size: 12px; padding-top: 10px; border-bottom: 0; text-transform: uppercase; letter-spacing: .04em; }
.st-table .st-note { color: var(--pf-muted); font-size: 11px; margin-left: 4px; }
.st-measures-foot { margin-top: 10px; }
.st-metrics td:first-child { min-width: 180px; }
.st-entry-name { font-weight: 500; color: var(--pf-text); text-decoration: none; }
a.st-entry-name:hover, a.st-entry-name:focus-visible { color: var(--pf-blue); text-decoration: underline; }
.st-entry-unmapped td { color: var(--pf-muted); }
.st-views { white-space: nowrap; }
.st-sep { color: var(--pf-muted); margin: 0 4px; }
.st-gap { font-size: 13px; }

/* Charts: 2 columns, 1 column on narrow screens. */
.st-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.st-plot { margin-bottom: 0; }
.st-plot .pf-plot { height: 230px; margin-top: 6px; }
.st-plot .pf-plot-empty { font-size: 13px; }
.st-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.st-sw { display: inline-block; width: 16px; border-top: 2px solid var(--st-account); margin-right: 5px; vertical-align: middle; }
.st-sw-bench-0 { border-color: var(--st-bench-0); border-top-style: dashed; }
.st-sw-bench-1 { border-color: var(--st-bench-1); border-top-style: dotted; }
.st-dd-max { font-variant-numeric: tabular-nums; }
.st-sw-gap { width: 14px; height: 10px; border: 0; background: var(--warn-band); vertical-align: -1px; }
.pf-plot .st-gap-band { fill: var(--warn-band); }
.pf-plot .st-gap-band-broken { fill: var(--bad-band); }
.pf-plot .pf-axis-unit { font-weight: 500; }
.st-tooltip-gap { color: var(--warn); }
.st-charts-note { margin: 10px 0 20px; }
.page-strategies .tx-portfolio { margin-top: 0; }

@media (max-width: 650px) {
    .st-charts { grid-template-columns: 1fr; }
    .st-table th, .st-table td { padding: 5px 4px; }
    .st-metrics td:first-child { min-width: 0; }
    .st-switch { gap: 14px; }
    .st-views { white-space: normal; }
    .page-strategies h1.st-title { font-size: 20px; }
}

/* ------------------------------------------------------------------------
   Strategy simulation, structured results (issue 29). Own .sim-* classes;
   everything else is reused from the .st-* / .pf-* blocks above.
   ------------------------------------------------------------------------ */
.sim-root {
    --sim-c-profit: #225ea8; --sim-c-envelope: #17202a; --sim-c-missed: #c33c52; --sim-c-skip: #ba7200;
    --sim-c-target: #c33c52; --sim-c-band: rgba(19, 128, 75, .14);
    --sim-m-suggested: #13804b; --sim-m-knee: #7555b7; --sim-m-c90: #ba7200; --sim-m-c95: #8a5200;
}
.sim-meta { margin: 0 0 10px; }
.sim-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0; }
.sim-kpis-compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sim-kpi { background: var(--st-head); border-radius: 8px; padding: 8px 12px; min-width: 0; }
.sim-kpi-label { font-size: 12px; color: var(--pf-muted); }
.sim-kpi-value { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sim-kpis-compact .sim-kpi-value { font-size: 15px; }
.sim-kpi-sub { font-size: 12px; color: var(--pf-muted); overflow-wrap: anywhere; }
.sim-kpi-good .sim-kpi-value { color: var(--pf-green); }
.sim-kpi-bad .sim-kpi-value { color: var(--pf-red); }
.sim-kpi-warn .sim-kpi-value { color: #8a5200; }
.sim-badge { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--pf-border); }
.sim-badge-good { color: var(--pf-green); border-color: currentColor; }
.sim-badge-warn { color: #8a5200; border-color: currentColor; }
.sim-badge-bad { color: var(--pf-red); border-color: currentColor; }
.sim-flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin: 6px 0 10px; }
.sim-flow-item { display: flex; align-items: center; gap: 8px; }
.sim-flow-op { color: var(--pf-muted); font-size: 18px; }
.sim-flow-tile { background: var(--st-head); border-radius: 8px; padding: 6px 12px; }
.sim-flow-value { font-variant-numeric: tabular-nums; font-weight: 500; }
.sim-counts { margin: 4px 0 8px; }
.page-strategies .sim-h3 { font-size: 14px; font-weight: 500; margin: 12px 0 4px; color: var(--pf-text); }
.sim-verdict { margin: 4px 0 6px; }
.sim-charts { margin-top: 8px; }
.sim-chart { min-width: 0; }
.sim-plot { height: 320px; }
.sim-sw-band { background: var(--sim-c-band); border: 1px solid var(--sim-m-suggested); }
.sim-tooltip-markers { color: var(--sim-m-suggested); }
.pf-plot .sim-hline-label { font-size: 11px; }
.sim-details { margin-top: 10px; }
.sim-details > summary { cursor: pointer; color: var(--pf-blue); font-weight: 500; }
.st-panel.sim-details { padding: 10px 16px; }
.sim-pre { white-space: pre-wrap; font: inherit; font-size: 13px; margin: 8px 0 0; }
.sim-kv th { width: 30%; min-width: 140px; color: var(--pf-muted); }
.sim-kv td { overflow-wrap: anywhere; }
.sim-row-flag td { background: rgba(195, 60, 82, .07); }
.sim-row-suggested td { background: rgba(19, 128, 75, .1); font-weight: 500; }
.sim-bar-cell { background-image: linear-gradient(90deg, rgba(34, 94, 168, .18) var(--sim-bar), transparent var(--sim-bar)); }
.sim-bar-neg { background-image: linear-gradient(90deg, rgba(195, 60, 82, .22) var(--sim-bar), transparent var(--sim-bar)); }
.sim-diag { margin: 8px 0 0; padding-left: 18px; }
@media (max-width: 650px) {
    .sim-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sim-plot { height: 300px; }
}

/* ------------------------------------------------------------------------
   Issue 30: design alignment with the original simulation report.
   Later rules win over the page blocks above; tokens live in :root.
   ------------------------------------------------------------------------ */

/* Page-level surface: the body carries the page classes and the --bg token (set above). */
body.page-portfolio, body.page-strategies, body.page-strategy-monitoring { background: var(--bg); }

/* Sticky sub navigation (Performance | Simulation) directly under the top bar. */
.st-switch {
    position: sticky;
    top: var(--topbar-h);
    z-index: 1020;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 14px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.st-switch-link {
    padding: 4px 12px;
    border-radius: 6px;
    border-bottom: 0;
    color: var(--muted);
    font-weight: 500;
}
.st-switch-link:hover, .st-switch-link:focus-visible { color: var(--ink); background: var(--stripe); }
.st-switch-link.active, .st-switch-link[aria-current="page"] { color: var(--accent); background: var(--accent-soft); border-bottom: 0; }
.page-strategy-performance, .page-strategy-simulation { --subnav-h: 56px; }
.st-head { margin-bottom: 8px; }
.page-strategies h1.st-title { font-size: 26px; font-weight: 600; letter-spacing: 0; margin: 0 0 4px; }
.page-strategies h1.st-title, .page-strategies h1 { color: var(--ink); }
.st-scope { color: var(--muted); font-size: 12px; }
.st-back { font-size: 12px; }

/* Typography: titles, section headings, secondary text, numbers. */
.page-portfolio h1.pf-title, .page-strategy-monitoring h1, .page-prices h1 { font-size: 26px; font-weight: 600; }
.pf-chart-title, .page-portfolio .pf-chart-title,
.st-panel-head h2, .page-strategies .st-panel h2, .page-strategies .st-section-title,
.page-prices h2.h4 {
    font-size: 19px; font-weight: 600; color: var(--accent);
}
.page-strategies .st-section-title { margin: 22px 0 10px; }
.pf-sub, .st-period-note, .st-measures-foot, small, .small { font-size: 12px; }
.text-muted { color: var(--muted) !important; }
.pf-num, .pf-tile-value, .pf-result-value, .sm-num, .st-table, .sm-table, .tx-table,
.pf-row, table.pf-matrix, .xg-ref, .summary-strip { font-variant-numeric: tabular-nums; }

/* Panels: panel colour, 1px line, 12px radius, 18px/22px padding, 14px gaps. */
.st-panel, .pf-panel, .pf-chart, .tx-portfolio, .tx-simulation, .pf-allocation, .pf-returns {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.st-panel { padding: 18px 22px; margin-bottom: 14px; }
.pf-panel { padding: 18px 22px; }
.tx-portfolio, .tx-simulation { padding: 18px 22px; margin-top: 14px; }
.st-charts { gap: 14px; }
.tx-account { margin-top: 14px; }
.pf-tile { box-shadow: var(--shadow); }
.sm-list { gap: 14px; }
.sm-row { background: var(--panel); }
.pf-positions { margin-bottom: 14px; }

/* Tables: head tint + 2px rule, stripe, hover, right-aligned numbers. */
.st-table thead th, .sm-table thead th, .tx-table thead th, table.pf-matrix thead th {
    background: var(--head); color: var(--ink); border-bottom: 2px solid var(--line);
}
.st-table tbody tr:nth-child(even), .sm-table tbody tr:nth-child(even), .tx-table tbody tr:nth-child(even) { background: var(--stripe); }
.st-table tbody tr:hover, .sm-table tbody tr:hover, .tx-table tbody tr:hover { background: var(--accent-soft); }
.st-table th, .st-table td, .sm-table th, .sm-table td, .tx-table th, .tx-table td { border-bottom-color: var(--line); }
.table > :not(caption) > * > * { background-color: transparent; color: inherit; border-bottom-color: var(--line); }

/* Badges and status labels in the reference style (labels keep their text). */
.badge { border-radius: 999px; font-size: 12px; font-weight: 600; padding: 2px 9px; }
.badge.bg-light, .badge.bg-secondary { background-color: var(--head) !important; color: var(--muted) !important; border: 0 !important; }
.badge.bg-danger { background-color: var(--bad-bg) !important; color: var(--bad) !important; }
.badge.bg-success { background-color: var(--good-bg) !important; color: var(--good) !important; }
.badge.bg-warning { background-color: var(--warn-bg) !important; color: var(--warn) !important; }
.badge.bg-info { background-color: var(--accent-soft) !important; color: var(--accent) !important; }
.tx-status { font-weight: 600; }
.tx-status-complete { background: var(--good-bg); color: var(--good); border-color: transparent; }
.tx-status-missing { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* Charts: neutral text and grid from tokens (series colours come via --pf-*). */
.pf-plot text, .spark-axis-label { fill: var(--muted); }
.pf-grid { stroke: var(--grid); }
.pf-plot .pf-grid-zero, .pf-plot .pf-cursor { stroke: var(--grid-strong); }
.pf-tooltip { background: var(--tip-bg); z-index: 1040; }

/* Bootstrap components in the token palette (light and dark). */
.card, .modal-content, .dropdown-menu, .list-group-item { background-color: var(--panel); color: var(--ink); border-color: var(--line); }
.card { border-radius: 12px; box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--line); }
.form-control, .form-select { background-color: var(--panel); color: var(--ink); border-color: var(--line); }
.form-control:focus, .form-select:focus { background-color: var(--panel); color: var(--ink); border-color: var(--accent); }
.btn-outline-secondary { color: var(--muted); border-color: var(--line); }
.btn-outline-secondary:hover { background: var(--head); color: var(--ink); border-color: var(--line); }
.btn-secondary { background-color: var(--accent); border-color: var(--accent); color: var(--panel); }
.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-link, .alert-link { color: var(--accent); }
.border, .border-top, .border-bottom { border-color: var(--line) !important; }
.alert-warning { background-color: var(--warn-bg); color: var(--warn); }
.alert-danger { background-color: var(--bad-bg); color: var(--bad); }
.alert-success { background-color: var(--good-bg); color: var(--good); }
.text-danger { color: var(--bad) !important; }
.text-success { color: var(--good) !important; }
.text-warning { color: var(--warn) !important; }
.modal-backdrop { z-index: 1050; }
.modal { z-index: 1060; }
@media (prefers-color-scheme: dark) {
    .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
    .tx-simulation-frame { background: var(--panel); }
}

/* Narrow screens: tighter panels, sub navigation wraps naturally. */
@media (max-width: 650px) {
    .st-panel, .pf-panel, .tx-portfolio, .tx-simulation { padding: 14px 14px; }
    .st-switch { top: var(--topbar-h); }
    .page-strategies h1.st-title { font-size: 22px; }
}

/* Wide dense pages keep more room than the 1320px reading width. */
body.page-strategy-monitoring, body.page-prices { --page-max: 1600px; }
body.page-strategies { --page-max: 1320px; }
.alert .alert-link { color: var(--accent); }
.alert-warning .alert-link { color: var(--warn); }
.alert-danger .alert-link { color: var(--bad); }

/* ------------------------------------------------------------------------
   issue 31: Kennzahlen (collapsible, switchable) + Portfolio-Auswertung tabs
   ------------------------------------------------------------------------ */
.pf-metrics { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 22px; min-width: 0; }
.pf-metrics > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pf-metrics > summary::-webkit-details-marker { display: none; }
.pf-metrics > summary::before { content: "\25B8"; color: var(--muted); font-size: 12px; transition: transform .15s; }
.pf-metrics[open] > summary::before { transform: rotate(90deg); }
.pf-metrics > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.pf-metrics > summary h2 { margin: 0; }
.pf-metrics.st-panel { padding: 14px 22px; }
.pf-metrics-bar { display: flex; gap: 8px 28px; flex-wrap: wrap; align-items: flex-end; margin-top: 10px; }
.pf-metric-switch { margin-bottom: 8px; gap: 18px; }
.pf-metric-switch button { padding: 6px 0 8px; }
.pf-metric-caption { margin: 2px 0 6px; }
.pf-metric-notes { margin-top: 10px; display: grid; gap: 2px; }
.pf-metric-partial { color: var(--warn); }
.pf-metric-gap { margin-top: 8px; color: var(--muted); }
.pf-metric-gap-broken { color: var(--warn); }
/* period and group are plain attributes on the panel: pure CSS visibility */
.pf-metrics[data-period="ytd"] [data-metric-panel]:not([data-metric-panel="ytd"]),
.pf-metrics[data-period="all"] [data-metric-panel]:not([data-metric-panel="all"]) { display: none; }
.pf-metrics[data-group="period"] tbody[data-mgroup="risk"],
.pf-metrics[data-group="risk"] tbody[data-mgroup="period"] { display: none; }
.pf-metrics .st-table tbody:last-of-type tr:last-child td { border-bottom: 0; }

.pf-analysis { margin-top: 14px; padding: 18px 22px; min-width: 0; }
.pf-analysis { --st-account: var(--accent); --st-bench-0: var(--series-3); --st-bench-1: var(--series-4); }
.pa-tabs { display: flex; flex-wrap: wrap; gap: 4px 6px; border-bottom: 1px solid var(--line); margin: 10px 0 12px; }
.pa-tabs button { font: inherit; background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; padding: 8px 10px; cursor: pointer; }
.pa-tabs button:hover { color: var(--ink); }
.pa-tabs button[aria-selected="true"] { color: var(--accent); background: var(--head); border-bottom-color: var(--accent); }
.pa-tabs button:focus-visible, .pa-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pa-period { margin: 0 0 6px; align-items: baseline; flex-wrap: wrap; border-bottom: 0; }
.pa-period-hint { align-self: center; }
.pf-analysis:not([data-view="performance"]):not([data-view="drawdown"]):not([data-view="cash"]) .pa-period { visibility: hidden; }
.pa-panels { min-width: 0; }
.pa-panel { min-height: 420px; min-width: 0; }
.pa-panel[hidden] { display: none; }
.pa-view-title { margin: 0 0 3px; font-size: 16px; font-weight: 600; }
.pa-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pa-caption { margin-bottom: 6px; }
.pa-chart .pf-plot { height: 300px; margin-top: 6px; }
.pa-chart-note { margin-top: 10px; }
.pa-gap-note { margin-top: 8px; font-size: 12px; color: var(--muted); }
.pa-gap-note.pa-gap-broken { color: var(--warn); }
/* the former stand-alone blocks lose their own panel frame inside the tabs */
.pf-analysis .pf-results, .pf-analysis .pf-returns, .pf-analysis .pf-chart {
    background: none; border: 0; box-shadow: none; padding: 0; margin: 0; border-radius: 0;
}
.pf-analysis .pf-results { margin-bottom: 0; }
@media (max-width: 650px) {
    .pf-metrics, .pf-analysis { padding: 14px; }
    .pa-tabs button { padding: 7px 8px; }
    .pa-panel { min-height: 360px; }
}
@media (max-width: 650px) {
    .sim-flow { gap: 6px; }
    .sim-flow-item { flex: 1 1 130px; min-width: 0; gap: 4px; }
    .sim-flow-tile { flex: 1; min-width: 0; padding: 5px 8px; }
    .sim-flow-value { font-size: 13px; overflow-wrap: anywhere; }
}
.sim-root { min-width: 0; max-width: 100%; }
.sim-root .st-panel { max-width: 100%; box-sizing: border-box; }
.sim-root .st-table-wrap { max-width: 100%; overflow-x: auto; }

/* Fees earned breakdown: Budget and Erfolgsprovision in EUR and USD. */
.pf-fee-lines {
    margin: 8px 0 0;
    display: grid;
    gap: 4px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.pf-fee-lines > div {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 8px;
}

.pf-fee-lines dt {
    color: var(--pf-muted, inherit);
    white-space: nowrap;
}

.pf-fee-lines dd {
    margin: 0;
    text-align: right;
    min-width: 0;
}

.pf-fee-rate {
    margin-top: 6px;
}

@media (max-width: 600px) {
    .pf-result-tiles {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Success-rate cell and modal (Strategie-Monitoring) */
.sm-rate-link {
    background: none; border: 0; padding: 0; color: inherit; font: inherit;
    text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer;
}
.sm-rate-link:hover, .sm-rate-link:focus-visible { color: var(--accent); text-decoration-style: solid; }
.sr-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.sr-controls label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.sr-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.sr-tile { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.sr-tile-value { font-size: 1.4rem; font-weight: 700; }
.sr-chart { display: block; margin-bottom: 2px; }
.sr-chart .sr-grid { stroke: var(--grid); stroke-width: 1; }
.sr-chart .sr-hit { fill: transparent; cursor: pointer; }
.sr-chart .sr-day:hover .sr-hit { fill: var(--accent-soft); }
.sr-chart .sr-dot { fill: var(--muted); opacity: .7; }
.sr-chart .sr-rolling { fill: none; stroke: var(--accent); stroke-width: 2; }
.sr-chart .sr-split-line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 3; }
.sr-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-top: 16px; }
.sr-table { width: 100%; font-size: .85rem; }
.sr-table th, .sr-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.sr-table th[scope="row"] { font-weight: 500; white-space: nowrap; }
.sr-table td.sm-num { text-align: right; white-space: nowrap; }
.sr-table .sr-table-default { background: var(--accent-soft); }
.sr-bar { display: inline-block; width: 100%; min-width: 60px; height: 6px; background: var(--grid); border-radius: 3px; vertical-align: middle; }
.sr-bar > span { display: block; height: 100%; background: var(--positive); border-radius: 3px; }

/* Issue 36: current positions per source on the Accounts tab (manual / bot / CT). */
.pf-pos-block { padding: 8px 0 10px; }
.pf-pos-block + .pf-pos-block { border-top: 1px solid var(--pf-border); }
.pf-pos-source { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; color: var(--pf-muted); margin-bottom: 4px; }
.pf-pos-badge { font-weight: 600; color: var(--pf-text); border: 1px solid var(--pf-border); border-radius: 999px; padding: 0 8px; }
.pf-pos-badge-tx_ct { border-color: var(--pf-blue); color: var(--pf-blue); }
.pf-pos-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pf-pos-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.pf-pos-c-asset { width: 20%; }
.pf-pos-c-qty { width: 13%; }
.pf-pos-c-avg { width: 17%; }
.pf-pos-c-val, .pf-pos-c-cost { width: 15%; }
.pf-pos-c-pnl { width: 16%; }
.pf-pos-c-act { width: 44px; }
.pf-pos-table td, .pf-pos-table th { overflow-wrap: anywhere; }
.pf-pos-table th, .pf-pos-table td { padding: 6px 8px; border-top: 1px solid var(--pf-border); vertical-align: top; text-align: left; }
.pf-pos-table thead th { border-top: 0; font-size: 12px; font-weight: 400; color: var(--pf-muted); white-space: nowrap; }
.pf-pos-table tbody th { font-weight: 400; }
.pf-pos-table .pf-num { text-align: right; white-space: nowrap; }
.pf-pos-table tfoot th, .pf-pos-table tfoot td { font-weight: 600; }
.pf-pos-table .pf-reason { white-space: normal; max-width: 220px; margin-left: auto; }
.pf-pos-help { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.pf-pos-help:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
.pf-pos-gap { margin-top: 4px; }
.pf-pos-diag { margin-top: 4px; }
.pf-pos-diag ul { margin: 4px 0 0; padding-left: 18px; }
.pf-pos-extra { margin-top: 12px; }
/* Issue 37: source label, Stand and inline edit of account positions. */
.pf-pos-meta { margin-top: 2px; white-space: nowrap; }
.pf-src { display: inline-block; font-size: 11px; font-weight: 600; line-height: 1.4; border: 1px solid var(--pf-border); border-radius: 999px; padding: 0 6px; color: var(--pf-muted); }
.pf-src-ct { border-color: var(--pf-blue); color: var(--pf-blue); }
.pf-pos-input { font: inherit; font-size: 13px; text-align: right; color: var(--pf-text); background: var(--pf-bg); border: 1px solid var(--pf-border); border-radius: 6px; padding: 2px 6px; width: 100%; max-width: 130px; min-width: 0; font-variant-numeric: tabular-nums; }
.pf-pos-input-asset { text-align: left; max-width: 110px; font-weight: 600; text-transform: uppercase; }
.pf-pos-input:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
.pf-pos-table .pf-avg { display: inline-flex; width: 100%; justify-content: flex-end; }
.pf-pos-editable .pf-pos-c-act { width: 76px; }
.pf-pos-edit, .pf-pos-table .pf-delete { display: inline-block; margin: 0; }
@media (max-width: 700px) {
    .pf-pos-table { min-width: 720px; }
}
/* Issue 38: booking journal of manual accounts (Bewegungen). */
.pf-movements { margin-top: 6px; padding: 8px 0 10px; border-top: 1px solid var(--pf-border); }
.pf-movements > summary { cursor: pointer; }
.pf-mv-table { margin-top: 4px; }
.pf-mv-form { margin-top: 8px; }
.pf-mv-form select { font: inherit; font-size: 13px; color: var(--pf-text); background: var(--pf-bg); border: 1px solid var(--pf-border); border-radius: 6px; padding: 5px 7px; }
.pf-mv-form input[type="date"] { width: auto; }
.pf-mv-form input[type="checkbox"] { width: auto; }
.pf-mv-delete > summary { list-style: none; display: inline-block; cursor: pointer; }
.pf-mv-delete > summary::-webkit-details-marker { display: none; }
.pf-mv-delete form { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 4px; }
.pf-mv-note { margin-top: 6px; }

/* Hidden admin page /intern/: the rendered Markdown note. */
.intern-note { max-width: 860px; }
.intern-note table { border-collapse: collapse; margin: 8px 0 16px; }
.intern-note th, .intern-note td { border: 1px solid var(--line); padding: 4px 10px; }
.intern-note pre { background: var(--line); padding: 10px 12px; border-radius: 6px; overflow-x: auto; }
.intern-note blockquote { border-left: 4px solid var(--line); padding-left: 12px; color: var(--muted); }

/* Allocation history modal: legend rows of the portfolio Allocation card open it. */
.pf-alloc-hist { cursor: pointer; border-radius: 4px; }
.pf-alloc-hist:hover, .pf-alloc-hist:focus-visible { background: var(--accent-soft); outline: none; }
.pf-alloc-hist .pf-alloc-name { text-decoration: underline dotted; text-underline-offset: 3px; }
.ah-tiles { margin-top: 12px; }
.ah-chart { display: block; margin-bottom: 2px; overflow: visible; }
.ah-chart .ah-grid { stroke: var(--grid); stroke-width: 1; }
.ah-chart .ah-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.ah-chart .ah-area { opacity: .12; }
.ah-chart .ah-dot { stroke: var(--bg); stroke-width: 1; }
.ah-chart .ah-hit { fill: transparent; }
.ah-chart .ah-pt:hover .ah-hit { fill: var(--accent-soft); }
.ah-chart .ah-cursor { stroke: var(--grid-strong); stroke-width: 1; visibility: hidden; }
.ah-chart .ah-pt:hover .ah-cursor { visibility: visible; }
.ah-chart .ah-stack { opacity: .8; stroke: var(--bg); stroke-width: .5; }
.ah-chart .ah-stack-dim { opacity: .5; }
.ah-chart .ah-stack-focus { opacity: 1; }
.ah-chart .ah-grid-zero { stroke: var(--grid-strong); stroke-width: 1.5; }
.ah-chart .ah-stack-short { stroke: var(--negative); stroke-width: .8; }
.ah-chart .ah-net-line { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-dasharray: 5 3; }
.ah-legend-net th, .ah-legend-net td { font-weight: 650; border-top: 2px solid var(--grid-strong); }
.ah-legend { margin-top: 10px; }
.ah-legend .ah-legend-row { cursor: pointer; }
.ah-legend .ah-legend-row:hover { background: var(--accent-soft); }
.ah-legend .ah-legend-focus th { font-weight: 700; }
#allocHistoryModal .pf-chart-head { flex-wrap: wrap; gap: 8px; }
.ah-legend .pf-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Sub-navigation under the main nav: the Intern pages (/intern/...) and the
   portfolios of the portfolio page (shown only with more than one). */
.subnav-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.subnav-title { margin: 0; font-size: 24px; font-weight: 600; color: var(--ink); }
.subnav { display: flex; flex-wrap: wrap; gap: 4px; }
.subnav-link {
    padding: 6px 10px; color: var(--muted); font-weight: 500; font-size: 14px;
    text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.subnav-link:hover, .subnav-link:focus-visible { color: var(--ink); background: var(--stripe); }
.subnav-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.subnav-head + .pf-results .pa-view-title { font-size: 18px; }
