:root,
:root[data-theme='dark'] {
    --star50-rotation: #62d5d0;
    --star50-risk: #ffb65c;
    --star50-dividend: #6f8cff;
    --star50-ma: #aeb8c2;
    --star50-upper: #3dca86;
    --star50-lower: #e06b78;
    --star50-chart-grid: rgba(120, 168, 148, 0.11);
}

:root[data-theme='light'],
:root[data-theme='clear'] {
    --star50-rotation: #087b77;
    --star50-risk: #b96b0a;
    --star50-dividend: #425fc4;
    --star50-ma: #64706a;
    --star50-upper: #0c8a4b;
    --star50-lower: #c0392b;
    --star50-chart-grid: rgba(15, 30, 22, 0.08);
}

html[data-page='star50-dividend-strategy'] body {
    background: var(--bg-body);
}

.star50-shell {
    width: min(1840px, calc(100vw - 32px));
}

html[data-page='star50-dividend-strategy'] .strategy-header .brand-group {
    flex: 0 0 auto;
}

html[data-page='star50-dividend-strategy'] .strategy-header .strategy-view-nav {
    flex: 1 1 auto;
    max-width: none;
    margin-left: 0;
}

.star50-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.star50-command {
    border-top: 2px solid color-mix(in srgb, var(--star50-rotation) 82%, transparent);
}

.star50-position-command {
    min-width: 0;
}

.star50-position-command .allocation-command-head > div {
    min-width: 0;
}

.star50-position-command .allocation-command-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.star50-position-track {
    height: 14px;
}

.position-risk,
.position-defensive {
    display: block;
    height: 100%;
    transition: width 240ms var(--ease-out);
}

.position-risk {
    width: 0;
    background: var(--star50-risk);
}

.position-defensive {
    width: 100%;
    background: var(--star50-dividend);
}

.dot-star50 {
    background: var(--star50-risk);
}

.dot-dividend {
    background: var(--star50-dividend);
}

.star50-command-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 18px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.fixed-parameter-panel,
.star50-performance-panel,
.yearly-panel,
.trades-panel,
.star50-method-panel {
    padding: 16px 18px;
}

.source-link {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card);
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: 700;
}

.fixed-parameter-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.fixed-parameter-grid > div {
    min-width: 0;
    padding: 11px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card) 54%, transparent);
}

.fixed-parameter-grid span,
.method-grid span {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
}

.fixed-parameter-grid strong,
.method-grid strong {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.45;
    text-overflow: ellipsis;
}

.star50-equity-chart {
    width: 100%;
    height: clamp(340px, 42vh, 500px);
}

.star50-drawdown-chart {
    width: 100%;
    height: clamp(180px, 22vh, 250px);
}

.star50-signal-chart {
    width: 100%;
    height: clamp(460px, 55vh, 680px);
    border-top: 1px solid var(--border);
    background: var(--chart-bg);
}

.star50-allocation-chart {
    width: 100%;
    height: 72px;
    border-bottom: 1px solid var(--border);
    background: var(--chart-bg);
}

.chart-legend strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 10px;
}

.line-rotation {
    height: 3px;
    background: var(--star50-rotation);
}

.line-star50 {
    background: var(--star50-risk);
}

.line-dividend {
    background: var(--star50-dividend);
}

.line-ma {
    background: var(--star50-ma);
}

.line-upper {
    background: var(--star50-upper);
}

.line-lower {
    background: var(--star50-lower);
}

.signal-snapshot {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 8px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.signal-snapshot > div {
    min-width: 0;
    padding: 10px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card) 54%, transparent);
}

.signal-snapshot span {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
}

.signal-snapshot strong {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.star50-signal-legend {
    gap: 18px;
    min-height: 30px;
    margin-bottom: 4px;
}

.star50-signal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.allocation-heading {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 8px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
}

.allocation-heading > span:last-child {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.allocation-key {
    display: inline-block;
    width: 7px;
    height: 7px;
}

.risk-key {
    background: var(--star50-risk);
}

.dividend-key {
    background: var(--star50-dividend);
}

.star50-table-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 12px;
}

.star50-table-scroll {
    max-height: 460px;
}

.star50-method-panel .section-head {
    margin-bottom: 12px;
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.method-grid > div {
    min-width: 0;
    min-height: 82px;
    padding: 13px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.method-grid > div.method-wide {
    grid-column: span 2;
}

.method-grid strong {
    white-space: normal;
}

@media (max-width: 1320px) {
    .fixed-parameter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .signal-snapshot {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .star50-table-grid {
        grid-template-columns: minmax(0, 1fr);
    }

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

@media (max-width: 720px) {
    .star50-shell {
        width: min(100%, calc(100vw - 16px));
        padding-top: 8px;
    }

    .star50-main {
        gap: 8px;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
        align-items: center;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header .brand-group {
        min-width: 0;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header .brand-subtitle {
        display: none;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header .strategy-view-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        max-width: 100%;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header .header-actions {
        grid-column: 2;
        grid-row: 1;
    }

    html[data-page='star50-dividend-strategy'] .strategy-header .status-chip {
        display: none;
    }

    .composite-command,
    .composite-chart-panel,
    .fixed-parameter-panel,
    .star50-performance-panel,
    .yearly-panel,
    .trades-panel,
    .star50-method-panel {
        padding: 14px 12px;
    }

    .fixed-parameter-grid,
    .signal-snapshot,
    .method-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .method-grid > div.method-wide {
        grid-column: span 2;
    }

    .star50-equity-chart {
        height: 300px;
    }

    .star50-drawdown-chart {
        height: 180px;
    }

    .star50-signal-chart {
        height: 360px;
    }

    .star50-allocation-chart {
        height: 58px;
    }

    .source-link {
        margin-top: 8px;
    }
}

@media (max-width: 460px) {
    .fixed-parameter-grid,
    .signal-snapshot {
        grid-template-columns: minmax(0, 1fr);
    }

    .method-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .method-grid > div.method-wide {
        grid-column: auto;
    }
}
