body {
    font-family: Inter, sans-serif;
}

.portfolio-shell {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    padding: 6.5rem 1.5rem 3rem;
    background:
        linear-gradient(180deg, #ffffff 0%, #f7f7f7 42%, #ededed 100%);
}

.portfolio-shell::before {
    content: "";
    position: fixed;
    top: 7rem;
    right: -7rem;
    width: clamp(360px, 42vw, 620px);
    height: clamp(360px, 42vw, 620px);
    background-image: url("../../../logos/ravenstone-icon-192.png?v=20260427b");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: grayscale(1) blur(8px);
    opacity: 0.08;
    pointer-events: none;
    transform: rotate(-8deg);
}

.portfolio-workspace {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
}

.portfolio-toolbar,
.panel-header,
.toolbar-actions,
.portfolio-title-row,
.form-actions {
    display: flex;
    align-items: center;
}

.portfolio-toolbar {
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 30px 60px -48px rgba(0, 0, 0, 0.42);
    padding: 1rem;
    backdrop-filter: blur(12px);
}

.portfolio-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.portfolio-title-row {
    gap: 0.75rem;
    flex-wrap: wrap;
}

.portfolio-title-row h1 {
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1;
    font-weight: 800;
    color: #111827;
}

.toolbar-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.auth-banner,
.tool-panel,
.metric-card,
.modal-panel {
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 18px 44px -36px rgba(0, 0, 0, 0.34);
}

.auth-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.metric-card {
    position: relative;
    min-height: 7.25rem;
    overflow: hidden;
    border-radius: 1rem;
    padding: 1rem;
    display: grid;
    align-content: space-between;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, #111827, #9ca3af);
    opacity: 0.85;
}

.metric-card span,
.metric-card small,
.panel-note {
    color: #6b7280;
    font-size: 0.78rem;
}

.metric-card span {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.metric-card strong {
    margin-top: 0.5rem;
    font-size: 1.7rem;
    line-height: 1.1;
    color: #111827;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 1rem;
    align-items: start;
}

.workspace-main,
.workspace-side {
    display: grid;
    gap: 0.75rem;
}

.tool-panel {
    border-radius: 1rem;
    padding: 1.05rem;
    min-width: 0;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.panel-header {
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-header h2 {
    font-size: 1.02rem;
    font-weight: 800;
    color: #111827;
}

.status-pill {
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: #f9fafb;
    color: #374151;
    font-size: 0.75rem;
    font-weight: 800;
}

.control-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #ffffff;
    padding: 0.65rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
}

.control-input:focus {
    outline: 2px solid #111827;
    outline-offset: 1px;
}

.icon-button,
.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-radius: 0.5rem;
    font-size: 0.86rem;
    font-weight: 800;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-button {
    width: 2.55rem;
    height: 2.55rem;
    border: 1px solid #d1d5db;
    color: #111827;
    background: #ffffff;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled,
.control-input:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
}

.primary-button:disabled:hover {
    background: #111827;
}

.secondary-button:disabled:hover,
.icon-button:disabled:hover {
    background: #ffffff;
}

.icon-button:hover,
.secondary-button:hover {
    background: #f3f4f6;
}

.danger-button {
    color: #dc2626;
}

.danger-button:hover {
    border-color: #fecaca;
    background: #fff5f5;
}

.icon-button svg {
    width: 1rem;
    height: 1rem;
}

.primary-button {
    min-height: 2.5rem;
    padding: 0.65rem 1rem;
    background: #111827;
    color: #ffffff;
}

.primary-button:hover {
    background: #000000;
}

.secondary-button {
    min-height: 2.5rem;
    padding: 0.65rem 1rem;
    border: 1px solid #d1d5db;
    color: #111827;
    background: #ffffff;
}

.segmented-control {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    overflow: hidden;
}

.segmented-control button {
    min-width: 3.1rem;
    padding: 0.52rem 0.75rem;
    background: #ffffff;
    color: #4b5563;
    font-size: 0.78rem;
    font-weight: 800;
}

.segmented-control button.active {
    background: #111827;
    color: #ffffff;
}

.performance-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.compact-segment button {
    min-width: auto;
    padding-inline: 0.65rem;
}

.performance-insights-layout {
    display: block;
}

.performance-chart-area {
    min-width: 0;
}

.performance-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.85rem;
}

.portfolio-table {
    width: 100%;
    min-width: 1060px;
    border-collapse: collapse;
    background: #ffffff;
}

.portfolio-table.compact {
    min-width: 760px;
}

.portfolio-table th,
.portfolio-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eeeeee;
    text-align: right;
    font-size: 0.82rem;
    vertical-align: middle;
    white-space: nowrap;
}

.portfolio-table th:first-child,
.portfolio-table td:first-child,
.portfolio-table th:nth-child(2),
.portfolio-table td:nth-child(2),
.portfolio-table.compact th,
.portfolio-table.compact td {
    text-align: left;
}

.portfolio-table th {
    background: #f9fafb;
    color: #6b7280;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.portfolio-table tbody tr:hover {
    background: #f7f7f7;
}

.rvn-rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    min-width: 5.7rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 0.24rem 0.5rem;
    background: #f8fafc;
    color: #374151;
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1;
}

.rvn-rating-badge strong {
    color: #111827;
    font-size: 0.78rem;
}

.rvn-rating-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rvn-rating-badge.positive {
    border-color: rgba(4, 120, 87, 0.28);
    background: #ecfdf5;
    color: #047857;
}

.rvn-rating-badge.negative {
    border-color: rgba(220, 38, 38, 0.28);
    background: #fef2f2;
    color: #dc2626;
}

.rvn-rating-badge.hold {
    border-color: rgba(180, 83, 9, 0.3);
    background: #fffbeb;
    color: #b45309;
}

.rvn-rating-empty {
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 800;
}

.holding-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 13rem;
}

.holding-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.65rem;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #111827;
    font-size: 0.72rem;
    font-weight: 900;
    overflow: hidden;
}

.holding-logo img {
    width: 1.55rem;
    height: 1.55rem;
    object-fit: contain;
}

.holding-logo-text {
    display: none;
}

.holding-logo.logo-failed img {
    display: none;
}

.holding-logo.logo-failed .holding-logo-text {
    display: inline;
}

.holding-logo.logo-loaded .holding-logo-text {
    display: none;
}

.holding-name {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.holding-name strong {
    color: #111827;
    font-size: 0.88rem;
}

.holding-name span {
    color: #6b7280;
    font-size: 0.73rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 14rem;
}

.transaction-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
}

.transaction-form label,
.modal-panel label {
    display: grid;
    gap: 0.35rem;
    color: #374151;
    font-size: 0.78rem;
    font-weight: 800;
}

.transaction-form .form-actions {
    grid-column: span 2;
    justify-content: flex-end;
    gap: 0.5rem;
    align-self: end;
}

.form-status {
    min-height: 1.25rem;
    margin-top: 0.75rem;
    color: #4b5563;
    font-size: 0.82rem;
    font-weight: 700;
}

.form-status.error {
    color: #dc2626;
}

.form-status.success {
    color: #047857;
}

.csv-import-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.85rem;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
    margin-top: 0.75rem;
    padding: 0.85rem;
}

.csv-import-panel strong {
    color: #111827;
    font-size: 0.86rem;
    font-weight: 900;
}

.csv-import-panel p {
    color: #6b7280;
    font-size: 0.78rem;
    line-height: 1.45;
    margin-top: 0.2rem;
}

.csv-import-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.target-input {
    max-width: 4.8rem;
    text-align: right;
}

.tiny-action {
    color: #374151;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.35rem 0.45rem;
    border-radius: 0.35rem;
}

.tiny-action:hover {
    background: #f3f4f6;
}

.chart-legend,
.risk-list,
.rebalance-list,
.bar-list,
.insight-list,
.action-list {
    display: grid;
    gap: 0.65rem;
}

.bar-row {
    display: grid;
    gap: 0.35rem;
}

.bar-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.82rem;
}

.bar-row-top span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}

.bar-logo {
    display: inline-flex;
    flex: 0 0 auto;
}

.bar-logo .holding-logo {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 0.55rem;
}

.bar-logo .holding-logo img {
    width: 1.25rem;
    height: 1.25rem;
}

.bar-label-text {
    display: inline-block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-row-top strong {
    color: #111827;
    font-size: 0.78rem;
    white-space: nowrap;
}

.bar-track {
    height: 0.52rem;
    overflow: hidden;
    border-radius: 999px;
    background: #eeeeee;
}

.bar-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #111827, #2563eb);
}

.bar-track .negative-bar {
    background: linear-gradient(90deg, #dc2626, #f87171);
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

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

.mini-panel {
    border: 1px solid #e5e7eb;
    border-radius: 0.85rem;
    padding: 0.85rem;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
}

.mini-panel h3,
.action-list h3 {
    margin-bottom: 0.45rem;
    color: #111827;
    font-size: 0.82rem;
    font-weight: 900;
}

.mini-panel p,
.action-item {
    color: #4b5563;
    font-size: 0.8rem;
    line-height: 1.45;
}

.mini-panel p {
    overflow-wrap: anywhere;
}

.insight-split {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.1fr);
    gap: 1rem;
    align-items: start;
}

.dividend-insight-layout {
    display: grid;
    gap: 1rem;
}

.dividend-insight-layout #dividend-chart {
    min-height: 16rem;
}

.dividend-empty-state {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: center;
    min-height: 7.5rem;
    border: 1px dashed #cbd5e1;
    border-radius: 0.85rem;
    background: #f8fafc;
    padding: 1rem;
}

.dividend-empty-state strong {
    color: #111827;
    font-size: 0.9rem;
}

.dividend-empty-state p {
    margin-top: 0.25rem;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.5;
}

.dividend-empty-icon {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border-radius: 0.7rem;
    background: #e2e8f0;
    color: #334155;
}

.dividend-empty-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.dividend-metric-list {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.dividend-holdings-block {
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
}

.compact-header {
    margin-bottom: 0.7rem;
}

.compact-header h3,
.section-subtitle {
    color: #111827;
    font-size: 0.9rem;
    font-weight: 900;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-5 {
    margin-top: 1.25rem;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(4.3rem, 1fr));
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.compact-heatmap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
}

.heatmap-cell {
    min-height: 4.2rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.65rem;
    padding: 0.55rem;
    display: grid;
    align-content: space-between;
    background: #f7f7f7;
}

.compact-heatmap .heatmap-cell {
    min-height: 3.1rem;
    border-radius: 0.5rem;
    padding: 0.45rem;
}

.compact-heatmap .heatmap-cell span {
    font-size: 0.65rem;
}

.compact-heatmap .heatmap-cell strong {
    font-size: 0.76rem;
}

.heatmap-cell span {
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.heatmap-cell strong {
    color: #111827;
    font-size: 0.88rem;
    font-weight: 900;
    white-space: nowrap;
}

.heatmap-cell.positive-cell {
    border-color: rgba(4, 120, 87, 0.24);
    background: #f0fdf7;
}

.heatmap-cell.negative-cell {
    border-color: rgba(220, 38, 38, 0.24);
    background: #fff5f5;
}

.heatmap-cell.neutral-cell {
    background: #f7f7f7;
}

.heatmap-cell.estimated {
    border-style: dashed;
}

.heatmap-3 strong,
.heatmap-4 strong {
    font-size: 0.95rem;
}

.dividend-forecast-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.85rem;
}

.forecast-metric {
    min-width: 0;
}

.forecast-metric span {
    color: #6b7280;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.forecast-metric strong {
    display: block;
    margin-top: 0.25rem;
    color: #111827;
    font-size: 0.9rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.forecast-note {
    grid-column: 1 / -1;
    margin-top: 0.1rem;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.45;
}

.recommendation-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.recommendation-card {
    min-height: 8rem;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #111827;
    border-radius: 0.85rem;
    padding: 0.9rem;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
    display: grid;
    align-content: start;
    gap: 0.35rem;
}

.recommendation-card.warning {
    border-left-color: #b45309;
}

.recommendation-heading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.recommendation-heading > div {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.recommendation-card span {
    color: #6b7280;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.recommendation-card strong {
    color: #111827;
    font-size: 0.92rem;
    font-weight: 900;
}

.recommendation-card p {
    color: #4b5563;
    font-size: 0.8rem;
    line-height: 1.45;
}

.insight-item,
.action-item {
    border-left: 3px solid #6b7280;
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
    padding: 0.75rem;
}

.insight-item {
    display: grid;
    gap: 0.2rem;
}

.insight-item strong {
    color: #111827;
    font-size: 0.84rem;
}

.insight-item span {
    color: #4b5563;
    font-size: 0.8rem;
    line-height: 1.45;
}

.insight-item.positive {
    border-left-color: #111827;
}

.insight-item.warning {
    border-left-color: #737373;
}

.insight-item.critical {
    border-left-color: #000000;
}

.mt-4 {
    margin-top: 1rem;
}

.legend-row,
.risk-row,
.rebalance-row,
.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid #eeeeee;
    padding-bottom: 0.55rem;
    font-size: 0.83rem;
}

.interactive-legend {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.interactive-legend:hover,
.interactive-legend.active {
    background: #f8fafc;
}

.interactive-legend.active {
    box-shadow: inset 3px 0 0 #111827;
}

.legend-row:last-child,
.risk-row:last-child,
.rebalance-row:last-child,
.detail-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.legend-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

.row-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    color: #4b5563;
}

.row-value {
    color: #111827;
    font-weight: 800;
    text-align: right;
}

.chart-tooltip {
    position: fixed;
    z-index: 100;
    max-width: min(20rem, calc(100vw - 2rem));
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 0.5rem;
    background: rgba(17, 24, 39, 0.94);
    color: #ffffff;
    box-shadow: 0 18px 36px -24px rgba(0, 0, 0, 0.5);
    padding: 0.45rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 800;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.chart-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.positive {
    color: #047857 !important;
}

.negative {
    color: #dc2626 !important;
}

.muted {
    color: #6b7280;
}

.empty-state {
    border: 1px dashed #d1d5db;
    border-radius: 0.5rem;
    margin-top: 1rem;
    padding: 1.25rem;
    text-align: center;
    color: #6b7280;
}

.empty-state p {
    color: #111827;
    font-weight: 800;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.56);
    padding: 1rem;
}

.modal-panel {
    display: grid;
    gap: 1rem;
    width: min(460px, 100%);
    border-radius: 0.5rem;
    padding: 1rem;
}

canvas {
    width: 100%;
    max-width: 100%;
    border-radius: 0.85rem;
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
}

#performance-chart {
    min-height: 26rem;
    cursor: crosshair;
}

.hidden {
    display: none !important;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

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

    .insight-split,
    .recommendation-grid {
        grid-template-columns: 1fr;
    }

    .compact-heatmap {
        grid-template-columns: repeat(6, minmax(4.3rem, 1fr));
        overflow-x: auto;
    }
}

@media (max-width: 760px) {
    .portfolio-shell {
        padding: 5.75rem 1rem 2rem;
    }

    .portfolio-toolbar,
    .auth-banner,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions {
        justify-content: flex-start;
    }

    .performance-controls,
    .performance-controls .segmented-control {
        width: 100%;
    }

    .performance-controls .segmented-control button {
        flex: 1 1 auto;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .mini-grid {
        grid-template-columns: 1fr;
    }

    .compact-mini-grid {
        grid-template-columns: 1fr;
    }

    .heatmap-grid {
        grid-template-columns: repeat(6, minmax(4.3rem, 1fr));
    }

    #performance-chart {
        min-height: 20rem;
    }

    .transaction-form {
        grid-template-columns: 1fr;
    }

    .transaction-form .form-actions {
        grid-column: auto;
        justify-content: stretch;
    }

    .csv-import-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .csv-import-actions {
        justify-content: stretch;
    }

    .csv-import-actions > * {
        flex: 1;
    }

    .form-actions > * {
        flex: 1;
    }

    .dividend-empty-state {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .dividend-empty-state > button {
        grid-column: 1 / -1;
        width: 100%;
    }
}

.portfolio-access-gate {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 2rem;
    width: min(1120px, 100%);
    min-height: calc(100vh - 12rem);
    margin: 0 auto;
    align-items: center;
}

.gate-copy,
.gate-benefits,
.portfolio-onboarding {
    border: 1px solid #e5e7eb;
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 30px 70px -52px rgba(15, 23, 42, 0.5);
    padding: clamp(1.5rem, 4vw, 3rem);
}

.gate-copy h1 {
    margin-top: 0.75rem;
    max-width: 14ch;
    font-size: clamp(2.35rem, 6vw, 4.5rem);
    line-height: 1.02;
    font-weight: 800;
    color: #111827;
}

.gate-copy > p:not(.portfolio-eyebrow),
.portfolio-onboarding > p {
    margin-top: 1rem;
    color: #4b5563;
    line-height: 1.7;
}

.gate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.gate-benefits {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
}

/* Separate the shared marketing CTA from the final tracker panel. */
.portfolio-shell > #global-premium-cta {
    margin-top: 2rem;
}

.gate-benefits article {
    display: grid;
    gap: 0.3rem;
    border-radius: 0.85rem;
    background: #f9fafb;
    padding: 1rem;
}

.gate-benefits strong { color: #111827; }
.gate-benefits span { color: #4b5563; font-size: 0.9rem; line-height: 1.5; }

.portfolio-quality-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.75rem 1rem;
    color: #4b5563;
    font-size: 0.8rem;
}

.portfolio-view-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.85rem;
    background: #fff;
    padding: 0.35rem;
}

.portfolio-view-tabs :where(a, button) {
    min-height: 2.75rem;
    border-radius: 0.65rem;
    padding: 0.65rem 1rem;
    color: #4b5563;
    font-weight: 800;
    white-space: nowrap;
}

.portfolio-view-tabs [aria-current="page"] {
    background: #111827;
    color: #fff;
}

.portfolio-onboarding {
    margin-bottom: 1rem;
    padding: 1.5rem;
}

.portfolio-onboarding h2 {
    margin-top: 0.5rem;
    color: #111827;
    font-size: 1.5rem;
    font-weight: 800;
}

.transaction-modal-panel {
    width: min(820px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.positions-card-list { display: none; }

.holding-card { border: 1px solid #e5e7eb; border-radius: 1rem; padding: 1rem; background: #fff; }
.holding-card-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .75rem; align-items: center; }
.holding-card-header > div span { display: block; color: #64748b; font-size: .8rem; }
.holding-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.holding-card dl div { padding: .65rem; border-radius: .75rem; background: #f8fafc; }
.holding-card dt { color: #64748b; font-size: .75rem; }
.holding-card dd { margin: .15rem 0 0; font-weight: 650; }
.data-unavailable { color: #9a3412; font-weight: 650; }
.csv-preview { margin-top: 1rem; padding: 1rem; border: 1px solid #dbeafe; border-radius: 1rem; background: #f8fbff; }
.status-pill.duplicate { background: #fef3c7; color: #92400e; }
.status-pill.valid { background: #dcfce7; color: #166534; }
.status-pill.invalid { background: #fee2e2; color: #991b1b; }
.portfolio-undo { position: fixed; z-index: 80; right: 1rem; bottom: 1rem; display: flex; gap: 1rem; align-items: center; border-radius: .8rem; background: #111827; color: #fff; padding: .85rem 1rem; box-shadow: 0 18px 45px rgba(15, 23, 42, .3); }
.portfolio-undo.hidden { display: none; }
.portfolio-undo button { color: #fbbf24; font-weight: 800; text-decoration: underline; }
.column-chooser { position: relative; }
.column-chooser summary { cursor: pointer; border: 1px solid #d1d5db; border-radius: .65rem; padding: .55rem .75rem; font-size: .8rem; font-weight: 750; }
.column-chooser > div { position: absolute; z-index: 20; right: 0; top: calc(100% + .4rem); display: grid; gap: .45rem; min-width: 10rem; border: 1px solid #e5e7eb; border-radius: .75rem; background: #fff; padding: .75rem; box-shadow: 0 16px 35px rgba(15, 23, 42, .16); }
.column-chooser label { display: flex; gap: .45rem; align-items: center; font-size: .8rem; }
.portfolio-overflow { position: relative; }
.portfolio-overflow summary { cursor: pointer; border: 1px solid #d1d5db; border-radius: .7rem; padding: .7rem .9rem; font-size: .85rem; font-weight: 800; }
.portfolio-overflow > div { position: absolute; z-index: 30; right: 0; top: calc(100% + .4rem); display: grid; min-width: 14rem; border: 1px solid #e5e7eb; border-radius: .8rem; background: #fff; padding: .35rem; box-shadow: 0 18px 42px rgba(15, 23, 42, .18); }
.portfolio-overflow button { display: flex; gap: .6rem; align-items: center; width: 100%; border-radius: .6rem; padding: .7rem .75rem; text-align: left; font-size: .85rem; font-weight: 700; }
.portfolio-overflow button:hover { background: #f8fafc; }
#positions-table thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; }
#positions-table th button { font: inherit; color: inherit; }

:where(.portfolio-shell, .modal-backdrop) :where(a, button, select, input):focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .portfolio-shell *,
    .modal-backdrop * {
        scroll-behavior: auto !important;
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 760px) {
    .portfolio-access-gate { grid-template-columns: 1fr; min-height: auto; }
    .gate-copy h1 { font-size: clamp(2.25rem, 12vw, 3.25rem); }
    .portfolio-quality-bar { flex-direction: column; }
    .portfolio-view-tabs :where(a, button) { flex: 1 0 auto; }
    [data-portfolio-section="holdings"] .table-wrap { display: none; }
    .positions-card-list { display: grid; gap: 0.75rem; }
    .position-mobile-card {
        display: grid;
        gap: 0.8rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.85rem;
        background: #fff;
        padding: 1rem;
    }
    .position-mobile-card-header,
    .position-mobile-card-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }
    .position-mobile-card-header { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
    .position-mobile-card-grid span { display: grid; gap: 0.2rem; color: #6b7280; font-size: 0.72rem; }
    .position-mobile-card-grid strong { color: #111827; font-size: 0.9rem; }
}

.analytics-terminal {
    display: grid;
    gap: 1rem;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: clamp(0.85rem, 2vw, 1.35rem);
    box-shadow: 0 24px 55px -46px rgba(15, 23, 42, 0.55);
}

.analytics-terminal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.analytics-terminal-header h2 {
    margin-top: 0.25rem;
    color: #0f172a;
    font-size: clamp(1.35rem, 3vw, 2rem);
    font-weight: 850;
}

.analytics-terminal-header p:not(.portfolio-eyebrow),
.analytics-methodology,
.analytics-method-note {
    color: #475569;
    font-size: 0.82rem;
    line-height: 1.6;
}

.analytics-subnav {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    border: 1px solid #dbe3ee;
    border-radius: 0.8rem;
    background: #fff;
    padding: 0.3rem;
}

.analytics-subnav button {
    min-height: 2.65rem;
    flex: 1 0 auto;
    border-radius: 0.6rem;
    padding: 0.55rem 0.9rem;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 800;
}

.analytics-subnav button[aria-selected="true"] {
    background: #0f172a;
    color: #fff;
}

.analytics-data-status,
.analytics-methodology,
.analytics-method-note {
    border: 1px solid #dbe3ee;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.75rem 0.9rem;
}

.analytics-data-status[data-state="error"] { border-color: #fecaca; background: #fff7f7; color: #991b1b; }
.analytics-data-status[data-state="partial"] { border-color: #fde68a; background: #fffbeb; color: #92400e; }

.analytics-panel {
    display: grid;
    gap: 0.9rem;
    min-width: 0;
}

.scenario-controls {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(135px, 1fr)) auto;
    gap: 0.65rem;
    align-items: end;
}

.scenario-controls label { display: grid; gap: 0.35rem; color: #475569; font-size: 0.75rem; font-weight: 750; }
.scenario-controls button { min-height: 2.7rem; }

.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
}

.analytics-kpi {
    display: grid;
    gap: 0.3rem;
    min-height: 6.4rem;
    align-content: space-between;
    border: 1px solid #dbe3ee;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.85rem;
}

.analytics-kpi span { color: #64748b; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.analytics-kpi strong { color: #0f172a; font-size: 1.3rem; }
.analytics-kpi small { color: #64748b; font-size: 0.7rem; line-height: 1.4; }

.analytics-chart-card {
    display: grid;
    gap: 0.75rem;
    min-width: 0;
    border: 1px solid #dbe3ee;
    border-radius: 0.85rem;
    background: #fff;
    padding: 0.9rem;
}

.analytics-chart-card h3 { color: #0f172a; font-size: 0.96rem; font-weight: 850; }
.analytics-chart-card canvas { min-height: 18rem; }
.analytics-two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }

.analytics-legend { display: flex; flex-wrap: wrap; gap: 0.85rem; color: #475569; font-size: 0.75rem; font-weight: 700; }
.analytics-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-line { width: 1.6rem; height: 0.22rem; border-radius: 99px; background: #111827; }
.legend-line.replay { background: #7c3aed; border-top: 1px dashed #fff; }
.legend-line.benchmark { background: #2563eb; }

.chart-data-table summary {
    cursor: pointer;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 800;
}

.chart-data-table[open] summary { margin-bottom: 0.7rem; }
.analytics-methodology { background: #f1f5f9; }

.correlation-heatmap {
    display: grid;
    overflow-x: auto;
    font-size: 0.72rem;
}

.correlation-cell {
    display: grid;
    min-width: 3.6rem;
    min-height: 3rem;
    place-items: center;
    border: 1px solid rgba(255,255,255,.7);
    padding: 0.3rem;
    color: #0f172a;
    font-weight: 800;
}

.correlation-cell.header { position: sticky; left: 0; background: #f1f5f9; z-index: 1; }
.stress-snapshot .panel-header { margin-bottom: 0; }

@media (max-width: 980px) {
    .analytics-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scenario-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analytics-two-column { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .analytics-terminal-header { flex-direction: column; }
    .analytics-terminal-header > button { width: 100%; }
    .scenario-controls,
    .analytics-kpi-grid { grid-template-columns: 1fr; }
    .analytics-chart-card { padding: 0.7rem; }
    .analytics-chart-card canvas { min-height: 15rem; }
}

@media (forced-colors: active) {
    .legend-line,
    .correlation-cell { border: 1px solid CanvasText; }
}
