/* Font declarations */
@font-face {
    font-family: 'PP Neue Montreal';
    src: url('../fonts/PPNeueMontreal-Book.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PP Neue Montreal Mono';
    src: url('../fonts/PPNeueMontrealMono-Variable.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Items';
    src: url('../fonts/Items-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --font-neue-montreal: "PP Neue Montreal", "PP Neue Montreal Fallback", system-ui, arial, sans-serif;
    --font-items: "Items", "Items Fallback", Times New Roman, Times, serif;
    --default-font-family: var(--font-neue-montreal);
    --radius: .625rem;

    /* Color scheme — refined to match Leverage Dashboard feel */
    --background: #ffffff;
    --page-background: #f3f5f4;
    --foreground: #6c6b71;
    --foreground-strong: #283235;
    --card: #ffffff;
    --card-foreground: #6c6b71;
    --primary: #006472;
    --primary-foreground: #ffffff;
    --secondary: #f5f5f5;
    --secondary-foreground: #6c6b71;
    --muted: #f5f5f5;
    --muted-foreground: #8a8990;
    --accent: #f5f5f5;
    --accent-foreground: #6c6b71;
    --destructive: #c62828;
    --border: #e5e5e5;
    --input: #e5e5e5;
    --ring: #62a0ad;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236c6b71' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    --surface-subtle: #f6f8f7;
    --surface-quiet: #fdfdfc;
    --surface-inset: #f2f5f4;
    --border-soft: #e1e7e4;
    --border-strong: #d9dfdd;
    --focus-ring: rgba(0, 100, 114, 0.10);

    /* Bitwise brand */
    --bitwise-green: #45b979;
    --bitwise-light-green: #a7d8b5;
    --bitwise-dark-teal: #006472;
    --bitwise-light-teal: #62a0ad;
    --bitwise-dark-grey: #6c6b71;
    --bitwise-light-grey: #8a8990;

    /* Stable categorical map palette: brand anchors plus restrained research hues. */
    --ae-map-color-1: var(--bitwise-dark-teal);
    --ae-map-color-2: var(--bitwise-green);
    --ae-map-color-3: #d8903d;
    --ae-map-color-4: #5273a3;
    --ae-map-color-5: #a55f78;
    --ae-map-color-6: #758c45;
    --ae-map-color-7: #b8584f;
    --ae-map-color-8: #4c91a8;
    --ae-map-color-9: #8d6d43;
    --ae-map-color-10: #7966a3;
    --ae-map-color-11: #338b76;
    --ae-map-color-12: #7a8087;

    /* Legacy mappings */
    --primary-bg: var(--background);
    --secondary-bg: var(--page-background);
    --text-primary: var(--foreground);
    --text-secondary: var(--muted-foreground);
    --accent-color: var(--bitwise-green);
    --border-color: var(--border);
    --table-header-bg: var(--secondary);
    --table-row-hover: var(--accent);
    --positive-color: #2e7d32;
    --negative-color: var(--destructive);

    /* Gradient bar — from Leverage Dashboard */
    --gradient-bar: linear-gradient(to right,
        rgba(46, 125, 50, 0.40) 0%,
        rgba(245, 127, 23, 0.38) 50%,
        rgba(183, 28, 28, 0.45) 100%
    );

    /* Layout */
    --nav-height: 54px;
    --subnav-height: 0px;
    --sidebar-width: 268px;
    --canvas-max-width: 1220px;
    --transition-speed: 0.2s;
    --card-padding: 1.25rem;
    --card-border-radius: var(--radius);
    --font-headers: var(--font-items);
    --font-body: var(--font-neue-montreal);
    --control-height: 2rem;
    --control-height-sm: 2rem;
    --control-radius: 6px;
    --panel-radius: 8px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --text-xs: 0.68rem;
    --text-sm: 0.75rem;
    --text-md: 0.82rem;
    --shadow-hairline: 0 1px 2px rgba(20, 36, 32, 0.045);
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--default-font-family);
    background-color: var(--page-background);
    color: var(--foreground);
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    font-feature-settings: "liga" on;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-items);
    font-weight: normal;
    letter-spacing: 0.1px;
    margin-bottom: 0.5rem;
    color: var(--bitwise-dark-grey);
}

/* ===== APP SHELL ===== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== TOP NAV ===== */
.app-nav {
    display: flex;
    align-items: center;
    height: var(--nav-height);
    padding: 0 1.5rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 20;
    gap: 0;
}

.app-nav-brand {
    border: 0;
    padding: 0;
    background: transparent;
    font-size: 1.15rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
    letter-spacing: 0.2px;
    flex-shrink: 0;
    font-family: var(--font-items);
    cursor: pointer;
    line-height: 1;
}

.app-nav-brand:hover,
.app-nav-brand:focus-visible {
    color: var(--bitwise-dark-teal);
}

.app-nav-brand:focus-visible {
    outline: 2px solid rgba(0, 100, 114, 0.25);
    outline-offset: 4px;
    border-radius: 4px;
}

.app-nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 1.25rem;
    flex-shrink: 0;
}

.app-nav-modes {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
    align-items: stretch;
    height: 100%;
}

.app-nav-setup {
    display: flex;
    align-items: center;
    gap: 1.35rem;
    height: 100%;
    min-width: 0;
}

.app-subnav {
    display: none;
    align-items: center;
    min-height: var(--subnav-height);
    padding: 0 2.5rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 15;
}

.app--configure {
    --subnav-height: 40px;
}

.app--configure .app-subnav {
    display: flex;
}

.app-subnav .app-nav-setup {
    width: min(var(--canvas-max-width), 100%);
    margin: 0 auto;
    padding: 0 2.5rem;
}

.nav-setup-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    min-height: 100%;
    padding: 0 0.45rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--bitwise-light-grey);
}

.nav-setup-field:focus-within {
    box-shadow: inset 0 -1px 0 rgba(0, 100, 114, 0.36);
    color: var(--bitwise-dark-teal);
}

.nav-setup-label {
    color: currentColor;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.2px;
    text-transform: none;
    white-space: nowrap;
}

.nav-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.nav-input-wrap--money {
    width: 92px;
}

.nav-prefix {
    color: currentColor;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1;
}

.nav-input,
.nav-date-inputs input[type="date"] {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    outline: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

.nav-input:focus,
.nav-date-inputs input[type="date"]:focus {
    color: var(--bitwise-dark-teal);
}

.nav-date-inputs {
    display: grid;
    grid-template-columns: 7.8rem auto 7.8rem;
    align-items: center;
    gap: 0.35rem;
}

.nav-date-inputs input[type="date"] {
    cursor: pointer;
}

.nav-date-inputs input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.32;
    cursor: pointer;
}

.nav-date-arrow {
    color: currentColor;
    font-size: 0.8rem;
    line-height: 1;
}

.nav-report-fields {
    display: inline-flex;
    align-items: center;
    gap: 0.62rem;
    min-width: 0;
    margin-left: auto;
    padding-left: 0.9rem;
    border-left: 1px solid var(--border);
}

.nav-report-field {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    min-width: 0;
}

.nav-report-input {
    width: 10.4rem;
    min-width: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.2;
    outline: none;
    padding: 0.12rem 0;
}

.nav-report-input--wide {
    width: 13.5rem;
}

.nav-report-input::placeholder {
    color: color-mix(in srgb, var(--muted-foreground) 78%, transparent);
}

.nav-report-input:focus {
    border-bottom-color: rgba(0, 100, 114, 0.36);
    color: var(--bitwise-dark-teal);
}

.app-nav-setup .input-status {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
}

.app-nav-setup .nav-error-message {
    position: absolute;
    z-index: 40;
    top: calc(100% + 0.35rem);
    left: 0;
    max-width: min(280px, 80vw);
    margin: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(198, 40, 40, 0.2);
    border-radius: 6px;
    background: #fffafa;
    box-shadow: 0 8px 20px rgba(40, 50, 53, 0.08);
    line-height: 1.25;
    white-space: nowrap;
}

.app-nav-setup .nav-error-message--end {
    right: 0;
    left: auto;
}

/* Saved-library button — top-right corner, visually separate from the
   three workflow mode tabs. Folder icon + optional count badge. */
.app-nav-library {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-left: 0.75rem;
    padding: 0.4rem 0.75rem;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--bitwise-dark-grey);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.app-nav-library svg { flex-shrink: 0; }
.app-nav-library:hover {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.04);
}
.app-nav-library[data-active="true"] {
    background: var(--bitwise-dark-teal);
    border-color: var(--bitwise-dark-teal);
    color: #fff;
}
.app-nav-library[data-active="true"]:hover {
    background: #005562;
    border-color: #005562;
}
.app-nav-library-label {
    font-size: 0.78rem;
}
.app-nav-library-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.1rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.app-nav-library[data-active="true"] .app-nav-library-count {
    background: #fff;
    color: var(--bitwise-dark-teal);
}
.app-nav-agent {
    margin-left: 0.45rem;
}
.app-nav-agent .material-icons {
    font-size: 1.05rem;
}
/* Hide the word on narrow screens — keep icon + count */
@media (max-width: 900px) {
    .app-nav-library-label { display: none; }
}

.mode-tab {
    font-family: var(--font-neue-montreal);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--bitwise-light-grey);
    background: none;
    border: none;
    padding: 0 0.75rem;
    cursor: pointer;
    border-radius: 0;
    transition: color 0.2s ease;
    letter-spacing: 0.2px;
    white-space: nowrap;
    position: relative;
    display: flex;
    align-items: center;
}

.mode-tab::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    border-radius: 2px 2px 0 0;
    transition: background 0.2s ease;
}

.mode-tab:hover {
    color: var(--foreground);
}

.mode-tab--disabled,
.mode-tab--disabled:hover,
.mode-tab:disabled {
    color: #b7b6b9;
    cursor: not-allowed;
    opacity: 0.55;
}

.mode-tab.active {
    color: var(--bitwise-dark-teal);
    font-weight: 600;
}

.mode-tab.active::after {
    background: var(--bitwise-dark-teal);
}

/* ===== APP BODY ===== */
.app-body {
    flex: 1;
    display: grid;
    overflow: hidden;
    transition: grid-template-columns 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth fade for mode panels */
.app-body > * {
    animation: fadeInPanel 0.25s ease;
}

@keyframes fadeInPanel {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* CONFIGURE STATE */
.app--configure .app-body {
    grid-template-columns: 1fr;
}
.app--configure .results-panel {
    display: none;
}
.app--configure .config-sidebar {
    display: none;
}
.app--configure .config-canvas {
    display: block;
}

/* RESULTS STATE */
.app--results .app-body {
    grid-template-columns: var(--sidebar-width) 1fr;
}
.app--results .config-sidebar {
    display: flex;
}
.app--results .config-canvas {
    display: none;
}
.app--results .results-panel {
    display: block;
}

/* SAVED SCENARIOS LIBRARY STATE */
.app--saved .app-body {
    grid-template-columns: 1fr;
    min-height: 0;
}
.app--saved .config-panel,
.app--saved .results-panel,
.app--saved .ae-layout,
.app--saved .ib-layout {
    display: none !important;
}
.app--saved .saved-layout {
    display: flex;
}
.saved-layout {
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem 2.5rem 3rem;
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
}
.saved-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
}
.saved-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    letter-spacing: 0;
    margin: 0 0 0.2rem 0;
}
.saved-subtitle {
    font-size: 0.82rem;
    color: var(--muted-foreground);
    margin: 0;
}
.saved-sort { min-width: 200px; }
.saved-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1rem;
}
.saved-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--muted-foreground);
}
.saved-empty h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    margin-bottom: 0.5rem;
    font-family: var(--font-neue-montreal);
}
.saved-empty p { font-size: 0.85rem; }

/* Saved card */
.saved-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.15rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.saved-card:hover {
    border-color: rgba(0, 100, 114, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.saved-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}
.saved-card-heading {
    min-width: 0;
    flex: 1;
}
.saved-card-topline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.28rem;
}
.saved-card-source {
    display: inline-flex;
    align-items: center;
    min-height: 1.25rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: rgba(0, 100, 114, 0.08);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--bitwise-dark-teal);
}
.saved-card-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.25rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--rule-soft, #eef0f2);
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.saved-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    padding: 0;
    font-family: var(--font-neue-montreal);
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
}
.saved-card-name:hover, .saved-card-name:focus {
    border-bottom-color: var(--border);
}
.saved-card-name[readonly] {
    cursor: default;
    color: var(--foreground);
}
.saved-card-name[readonly]:hover,
.saved-card-name[readonly]:focus {
    border-bottom-color: transparent;
}
.saved-card-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0 0.3rem;
    border-radius: 4px;
}
.saved-card-delete:hover {
    color: var(--destructive, #c0392b);
    background: rgba(192, 57, 43, 0.06);
}
.saved-card-builder {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted-foreground);
    font-size: 0.72rem;
    line-height: 1.35;
}
.saved-card-builder strong {
    color: var(--foreground);
    font-weight: 600;
}
.saved-builder-avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.saved-card-savedat {
    margin-left: auto;
    color: var(--muted-foreground);
    font-style: italic;
    white-space: nowrap;
}
.saved-card-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.68rem;
    color: var(--muted-foreground);
    line-height: 1.35;
}
.saved-card-meta-row span {
    display: inline-flex;
    align-items: center;
    min-height: 1.45rem;
    padding: 0 0.45rem;
    border-radius: 5px;
    background: #f8f9f9;
    border: 1px solid var(--rule-soft, #eef0f2);
}
.saved-card-composition {
    display: grid;
    gap: 0.45rem;
}
.saved-asset-chip-row,
.saved-scenario-preview > div,
.saved-card-differences > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.32rem;
}
.saved-asset-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.22rem;
    min-height: 1.45rem;
    padding: 0 0.48rem;
    border-radius: 5px;
    background: #f7faf9;
    border: 1px solid rgba(0, 100, 114, 0.11);
    color: var(--foreground);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.saved-asset-chip strong {
    color: var(--bitwise-dark-teal);
    font-size: 0.66rem;
}
.saved-asset-chip--more {
    color: var(--muted-foreground);
    background: #fff;
    border-color: var(--rule-soft, #eef0f2);
}
.saved-scenario-preview {
    display: grid;
    gap: 0.28rem;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--rule-soft, #eef0f2);
    border-radius: 7px;
    background: #fbfcfc;
}
.saved-scenario-preview > span {
    color: var(--muted-foreground);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.55px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.saved-card-more-scenarios {
    color: var(--muted-foreground);
    font-size: 0.68rem;
}
.saved-card-differences {
    display: grid;
    gap: 0.28rem;
    padding-top: 0.1rem;
}
.saved-card-differences > span {
    color: var(--bitwise-dark-teal);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.65px;
    text-transform: uppercase;
}
.saved-diff-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.35rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: rgba(212, 169, 106, 0.15);
    border: 1px solid rgba(212, 169, 106, 0.35);
    color: #6f5833;
    font-size: 0.64rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.saved-card-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.55rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--rule-soft, #eef0f2);
    border-bottom: 1px solid var(--rule-soft, #eef0f2);
}
.saved-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.saved-stat-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted-foreground);
    white-space: nowrap;
}
.saved-stat-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--foreground);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.saved-stat-value.positive { color: var(--positive, #0e7a3a); }
.saved-stat-value.negative { color: var(--negative, #c0392b); }
.saved-card-actions {
    display: flex;
    gap: 0.5rem;
}
.saved-action-btn {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    transition: all 0.15s;
}
.saved-action-btn:hover {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
}
.saved-action-btn--primary {
    background: var(--bitwise-dark-teal);
    color: #fff;
    border-color: var(--bitwise-dark-teal);
}
.saved-action-btn--primary:hover {
    background: #005562;
    border-color: #005562;
    color: #fff;
}

.saved-hub-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.saved-hub-tab {
    appearance: none;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.65rem 0.85rem;
}
.saved-hub-tab:hover {
    color: var(--foreground);
}
.saved-hub-tab.active {
    color: var(--bitwise-dark-teal);
    border-bottom-color: var(--bitwise-dark-teal);
}
.saved-hub-panel {
    display: none;
}
.saved-hub-panel.active {
    display: block;
}
.saved-library-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.saved-library-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--control-radius);
    background: var(--surface-quiet);
}
.saved-library-tab {
    border: 0;
    border-radius: calc(var(--control-radius) - 2px);
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: var(--text-sm);
    font-weight: 700;
    min-height: 30px;
    padding: 0 0.72rem;
}
.saved-library-tab.active {
    background: var(--background);
    color: var(--bitwise-dark-teal);
    box-shadow: var(--shadow-hairline);
}
.saved-hub-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.saved-hub-copy h2,
.wishlist-section-heading h2 {
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}
.saved-hub-copy p {
    color: var(--muted-foreground);
    font-size: 0.78rem;
    margin: 0;
}
.saved-hub-eyebrow {
    color: var(--muted-foreground);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.9px;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
}
.leaderboard-status-open { color: #9a6a00; }
.leaderboard-status-live { color: var(--bitwise-dark-teal); }
.leaderboard-status-final { color: var(--foreground); }
.leaderboard-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.leaderboard-table {
    border-collapse: collapse;
    min-width: 980px;
    width: 100%;
}
.leaderboard-table th {
    background: var(--muted, #f7f8f9);
    color: var(--muted-foreground);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.55px;
    padding: 0.7rem 0.75rem;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}
.leaderboard-table td {
    border-top: 1px solid var(--border);
    color: var(--foreground);
    font-size: 0.78rem;
    padding: 0.75rem;
    vertical-align: top;
}
.leaderboard-rank {
    color: var(--bitwise-dark-teal);
    font-weight: 700;
    white-space: nowrap;
}
.leaderboard-primary {
    color: var(--foreground);
    font-weight: 700;
}
.leaderboard-secondary,
.leaderboard-assets {
    color: var(--muted-foreground);
    font-size: 0.7rem;
    line-height: 1.35;
    margin-top: 0.1rem;
}
.leaderboard-row-delete {
    font-size: 1rem;
}
.saved-inline-loading,
.saved-inline-error,
.saved-inline-empty {
    color: var(--muted-foreground);
    font-size: 0.82rem;
    padding: 1.25rem;
    text-align: center;
}
.saved-inline-error {
    color: var(--negative, #c0392b);
}
.wishlist-layout {
    display: grid;
    gap: 1.25rem;
}
.wishlist-form {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}
.wishlist-form-grid {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 0.85rem;
}
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.canvas-textarea {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.82rem;
    line-height: 1.4;
    min-height: 5.25rem;
    padding: 0.65rem 0.75rem;
    resize: vertical;
    width: 100%;
}
.canvas-textarea:focus {
    border-color: var(--bitwise-dark-teal);
    outline: none;
}
.wishlist-form-actions {
    display: flex;
    gap: 0.55rem;
    margin-top: 0.85rem;
}
.wishlist-columns {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.wishlist-list-section {
    min-width: 0;
}
.wishlist-section-heading {
    align-items: baseline;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.65rem;
    padding-bottom: 0.45rem;
}
.wishlist-section-heading span {
    color: var(--muted-foreground);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}
.wishlist-list {
    display: grid;
    gap: 0.65rem;
}
.wishlist-item {
    align-items: flex-start;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.85rem;
}
.wishlist-item-title {
    color: var(--foreground);
    font-size: 0.88rem;
    font-weight: 700;
}
.wishlist-item-meta,
.wishlist-item-notes,
.wishlist-item-side {
    color: var(--muted-foreground);
    font-size: 0.72rem;
    line-height: 1.35;
}
.wishlist-item-notes {
    margin-top: 0.3rem;
}
.wishlist-item-side {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 6rem;
    text-align: right;
}
.leaderboard-modal-backdrop {
    align-items: center;
    background: rgba(27, 37, 42, 0.35);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1.5rem;
    position: fixed;
    z-index: 1000;
}
.leaderboard-modal-backdrop[hidden] {
    display: none;
}
.leaderboard-modal {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.18);
    display: grid;
    gap: 0.85rem;
    max-width: 520px;
    padding: 1.25rem;
    width: min(100%, 520px);
}
.leaderboard-modal-header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.leaderboard-modal-header h2 {
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}
.leaderboard-entry-summary {
    color: var(--muted-foreground);
    font-size: 0.78rem;
    line-height: 1.45;
    margin: 0;
}
.leaderboard-modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .saved-header,
    .saved-hub-toolbar,
    .wishlist-form-actions {
        align-items: stretch;
        flex-direction: column;
    }
    .wishlist-form-grid,
    .wishlist-columns {
        grid-template-columns: 1fr;
    }
    .saved-sort {
        min-width: 0;
        width: 100%;
    }
    .saved-grid {
        grid-template-columns: 1fr;
    }
    .saved-card-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== RESULTS PAGE: top-level section heading ===== */
.results-section { margin-bottom: 2.25rem; }
.results-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding-bottom: 0.65rem;
    margin-bottom: 1.05rem;
    border-bottom: 1px solid var(--border);
}
.results-section-heading h2 {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--foreground-strong);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 0;
    font-family: var(--font-neue-montreal);
}
.results-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    min-width: 0;
}
.risk-free-chip {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.45px;
    color: var(--bitwise-dark-teal);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 0.24rem 0.5rem;
    cursor: help;
}
.results-section-sub {
    font-size: 0.78rem;
    color: var(--muted-foreground);
    margin-top: 0.3rem;
    line-height: 1.5;
    font-style: italic;
}
.results-section-heading .table-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ===== PORTFOLIO CONSTRUCTION: rolling contribution ===== */
.rolling-contribution-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 180px)) minmax(240px, 1fr);
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 0.75rem;
}
.rolling-contribution-section .results-action-btn {
    border-radius: 0;
}
.rolling-control {
    display: grid;
    gap: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.55px;
    color: var(--muted-foreground);
    text-transform: uppercase;
}
.rolling-control input,
.rolling-control select {
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--background);
    color: var(--foreground-strong);
    padding: 0 0.6rem;
    font-family: var(--font-neue-montreal);
    font-size: 0.8rem;
}
.rolling-contribution-method {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1.45;
    padding-bottom: 0.25rem;
}
.rolling-contribution-status {
    min-height: 1.2rem;
    color: var(--muted-foreground);
    font-size: 0.76rem;
    margin: 0.15rem 0 0.8rem;
}
.rolling-contribution-status.is-error { color: var(--destructive); }
.rolling-contribution-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}
.rolling-stat {
    border: 1px solid var(--border);
    background: var(--background);
    border-radius: 0;
    padding: 0.78rem 0.85rem;
    min-width: 0;
}
.rolling-stat span {
    display: block;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    line-height: 1.2;
    margin-bottom: 0.35rem;
}
.rolling-stat strong {
    display: block;
    color: var(--foreground-strong);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.15;
}
.rolling-stat strong.positive { color: var(--positive-color); }
.rolling-stat strong.negative { color: var(--destructive); }
.rolling-contribution-chart {
    height: 430px;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--background);
    overflow: hidden;
}
@media (max-width: 920px) {
    .rolling-contribution-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .rolling-contribution-method { grid-column: 1 / -1; }
    .rolling-contribution-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== "BY THE NUMBERS" — TABS ===== */
.numbers-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-bottom: 0;
    background: #f7f9f8;
}
.numbers-tab {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    padding: 0.62rem 0.95rem;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.58px;
    text-transform: uppercase;
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    border-bottom: 2px solid transparent;
    margin-bottom: 0;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.numbers-tab:last-child { border-right: 0; }
.numbers-tab:hover {
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.035);
}
.numbers-tab.active {
    color: var(--bitwise-dark-teal);
    border-bottom-color: var(--bitwise-dark-teal);
    background: var(--background);
    font-weight: 600;
}
.numbers-tab-panels {
    border: 1px solid var(--border);
    background: var(--background);
    position: relative;
    z-index: 2;
    overflow: hidden;
}
.numbers-tab-panel.active { display: block; }
.numbers-tab-panel[hidden] { display: none; }

.numbers-section .results-section-heading {
    align-items: flex-start;
    border-bottom: 0;
    margin-bottom: 0.8rem;
    padding-bottom: 0;
}

.numbers-section .table-header-actions {
    margin-bottom: 0;
}

.numbers-section .performance-table-wrapper {
    border: 0;
    margin: 0;
}

.numbers-section .metric-tooltip .tooltip-text {
    top: calc(100% + 8px);
    bottom: auto;
    left: auto;
    right: 0;
    transform: none;
}

.numbers-section .performance-table th {
    background: #f7f9f8;
    border-bottom: 1px solid var(--border);
}

.numbers-section .performance-table th:hover {
    background: #f1f5f4;
}

.numbers-section .performance-table td {
    border-bottom-color: var(--border-soft);
}

/* ===== DATA AUDIT ===== */
.data-audit-heading {
    align-items: flex-start;
}

.data-audit-status {
    display: inline-flex;
    align-items: center;
    min-height: 1.35rem;
    padding: 0.18rem 0.45rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--muted-foreground);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.45px;
    line-height: 1;
    text-transform: uppercase;
}

.data-audit-status.is-ready {
    border-color: rgba(46, 125, 50, 0.3);
    background: rgba(46, 125, 50, 0.06);
    color: var(--positive-color);
}

.data-audit-status.needs-review {
    border-color: rgba(198, 40, 40, 0.3);
    background: rgba(198, 40, 40, 0.05);
    color: var(--destructive);
}

.data-audit-kpis {
    display: grid;
    grid-template-columns: minmax(280px, 1.55fr) repeat(3, minmax(150px, 1fr));
    border: 1px solid var(--border);
    background: var(--background);
}

.data-audit-kpi {
    min-width: 0;
    min-height: 5.5rem;
    padding: 0.8rem 0.9rem;
    border-right: 1px solid var(--border);
}

.data-audit-kpi:last-child { border-right: 0; }

.data-audit-kpi span,
.data-audit-kpi small {
    display: block;
    color: var(--muted-foreground);
    font-size: 0.64rem;
    line-height: 1.35;
}

.data-audit-kpi span {
    font-weight: 700;
    letter-spacing: 0.38px;
    text-transform: uppercase;
}

.data-audit-kpi strong {
    display: block;
    margin: 0.36rem 0 0.3rem;
    color: var(--foreground-strong);
    font-size: 0.93rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.24;
    overflow-wrap: anywhere;
}

.data-audit-kpi--primary strong {
    color: var(--bitwise-dark-teal);
}

.data-audit-issue-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-top: 0;
    background: #f8faf9;
}

.data-audit-issue-grid > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.58rem 0.75rem;
    border-right: 1px solid var(--border);
}

.data-audit-issue-grid > div:last-child { border-right: 0; }
.data-audit-issue-grid span { color: var(--muted-foreground); font-size: 0.67rem; }
.data-audit-issue-grid strong { color: var(--foreground-strong); font-size: 0.77rem; font-variant-numeric: tabular-nums; }
.data-audit-has-issues { color: var(--destructive) !important; font-weight: 700; }

.data-audit-tieout {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-top: 0.75rem;
    padding: 0.72rem 0.8rem;
    border: 1px solid rgba(181, 115, 20, 0.38);
    background: rgba(181, 115, 20, 0.07);
    color: #77500e;
}

.data-audit-tieout.is-verified {
    border-color: rgba(46, 125, 50, 0.3);
    background: rgba(46, 125, 50, 0.06);
    color: var(--positive-color);
}

.data-audit-tieout > .material-icons { flex: 0 0 auto; font-size: 1rem; }
.data-audit-tieout strong { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.35px; }
.data-audit-tieout p { margin: 0.23rem 0 0; color: inherit; font-size: 0.72rem; line-height: 1.45; }
.data-audit-fingerprint { overflow-wrap: anywhere; font-family: var(--font-neue-montreal-mono, monospace); }

.data-audit-entry-list {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.75rem;
}

.data-audit-entry {
    border: 1px solid var(--border);
    background: var(--background);
}

.data-audit-entry > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.8rem;
    color: var(--foreground-strong);
    cursor: pointer;
    list-style-position: inside;
    font-size: 0.74rem;
    font-weight: 600;
}

.data-audit-entry > summary small {
    margin-left: auto;
    color: var(--muted-foreground);
    font-size: 0.65rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.data-audit-entry[open] > summary { border-bottom: 1px solid var(--border); }

.data-audit-table-wrap { overflow-x: auto; }
.data-audit-table { width: 100%; border-collapse: collapse; font-size: 0.69rem; }
.data-audit-table th {
    padding: 0.52rem 0.58rem;
    border-bottom: 1px solid var(--border);
    background: #f7f9f8;
    color: var(--muted-foreground);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.28px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}
.data-audit-table td { padding: 0.55rem 0.58rem; border-bottom: 1px solid var(--border-soft); color: var(--foreground); }
.data-audit-table td small { display: block; margin-top: 0.12rem; color: var(--muted-foreground); font-size: 0.58rem; line-height: 1.25; }
.data-audit-table tbody tr:last-child td { border-bottom: 0; }
.data-audit-table .data-audit-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-audit-empty { margin: 0; padding: 0.8rem; color: var(--muted-foreground); font-size: 0.7rem; }

.data-audit-transformations,
.data-audit-issues {
    padding: 0.7rem 0.8rem;
    border-top: 1px solid var(--border);
    color: var(--foreground);
    font-size: 0.69rem;
}

.data-audit-transformations > strong,
.data-audit-issues > strong {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--foreground-strong);
    font-size: 0.63rem;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

.data-audit-transformations > span { color: var(--muted-foreground); }
.data-audit-transformations ul,
.data-audit-issues ul { display: grid; gap: 0.32rem; margin: 0; padding: 0; list-style: none; }
.data-audit-transformations li { display: flex; gap: 0.5rem; align-items: baseline; }
.data-audit-transformations li > span {
    flex: 0 0 auto;
    min-width: 3.8rem;
    color: var(--bitwise-dark-teal);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.data-audit-issues li {
    display: grid;
    grid-template-columns: auto minmax(110px, auto) 1fr;
    gap: 0.45rem;
    align-items: baseline;
}
.data-audit-issues li strong { font-size: 0.66rem; font-weight: 600; text-transform: capitalize; }
.data-audit-issues li p { margin: 0; color: var(--muted-foreground); line-height: 1.4; }
.data-audit-severity { padding: 0.1rem 0.3rem; background: var(--muted); color: var(--muted-foreground); font-size: 0.55rem; font-weight: 700; text-transform: uppercase; }
.data-audit-severity.is-warning { background: rgba(181, 115, 20, 0.09); color: #77500e; }
.data-audit-severity.is-error { background: rgba(198, 40, 40, 0.07); color: var(--destructive); }
.data-audit-issues-more { margin: 0.45rem 0 0; color: var(--muted-foreground); font-size: 0.65rem; }

@media (max-width: 960px) {
    .data-audit-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .data-audit-kpi:nth-child(2) { border-right: 0; }
    .data-audit-kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .data-audit-issue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .data-audit-issue-grid > div:nth-child(2n) { border-right: 0; }
    .data-audit-issue-grid > div { border-bottom: 1px solid var(--border); }
    .data-audit-issue-grid > div:last-child { border-bottom: 0; }
}

@media (max-width: 620px) {
    .data-audit-kpis { grid-template-columns: 1fr; }
    .data-audit-kpi { border-right: 0; border-bottom: 1px solid var(--border); }
    .data-audit-kpi:last-child { border-bottom: 0; }
    .data-audit-entry > summary { align-items: flex-start; flex-direction: column; gap: 0.25rem; }
    .data-audit-entry > summary small { margin-left: 0; }
    .data-audit-issues li { grid-template-columns: auto 1fr; }
    .data-audit-issues li p { grid-column: 1 / -1; }
}

/* "vs. Benchmarks" — stacked (scenarios on top, benchmarks below).
   Each column spans full width so the metric columns line up vertically,
   making "did my scenario beat S&P?" a straight eye-trace down the page. */
.numbers-vs-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.numbers-vs-col-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
}

/* ===== SCENARIO MATCHUPS ===== */
.matchup-heading {
    align-items: flex-end;
}
.matchup-controls {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
}
.matchup-pair-control {
    display: grid;
    gap: 0.28rem;
    min-width: min(320px, 100%);
}
.matchup-pair-control > span {
    color: var(--muted-foreground);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.42px;
    text-transform: uppercase;
}
.matchup-pair-control select {
    height: 2rem;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--background);
    color: var(--foreground-strong);
    padding: 0 2rem 0 0.6rem;
    font-family: var(--font-neue-montreal);
    font-size: 0.76rem;
}
.matchup-grain-control {
    display: inline-flex;
    height: 2rem;
    border: 1px solid var(--border);
    background: var(--background);
}
.matchup-grain-control button {
    min-width: 3.15rem;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--muted-foreground);
    padding: 0 0.62rem;
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.38px;
    text-transform: uppercase;
}
.matchup-grain-control button:last-child { border-right: 0; }
.matchup-grain-control button:hover {
    background: rgba(0, 100, 114, 0.04);
    color: var(--bitwise-dark-teal);
}
.matchup-grain-control button.active {
    background: var(--bitwise-dark-teal);
    color: #fff;
}
.matchup-stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border: 1px solid var(--border);
    background: var(--background);
}
.matchup-stat {
    min-width: 0;
    min-height: 5.4rem;
    padding: 0.72rem 0.78rem;
    border-right: 1px solid var(--border);
}
.matchup-stat:last-child { border-right: 0; }
.matchup-stat span,
.matchup-stat small {
    display: block;
    overflow-wrap: anywhere;
}
.matchup-stat span {
    min-height: 1.75rem;
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.34px;
    line-height: 1.35;
    text-transform: uppercase;
}
.matchup-stat strong {
    display: block;
    margin: 0.24rem 0 0.14rem;
    color: var(--foreground-strong);
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.matchup-stat small {
    color: var(--muted-foreground);
    font-size: 0.62rem;
    line-height: 1.3;
}
.matchup-overlap-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.2rem;
    padding: 0.62rem 0.75rem;
    border: 1px solid var(--border);
    border-top: 0;
    background: #f8faf9;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    line-height: 1.45;
}
.matchup-overlap-line strong {
    color: var(--foreground-strong);
    font-weight: 600;
}
.matchup-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
    gap: 1rem;
    margin-top: 1rem;
}
.matchup-behavior,
.matchup-downside {
    min-width: 0;
}
.matchup-block-heading,
.matchup-chart-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}
.matchup-block-heading h3,
.matchup-chart-heading h3 {
    margin: 0;
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.48px;
    text-transform: uppercase;
}
.matchup-block-heading span,
.matchup-chart-heading span {
    color: var(--muted-foreground);
    font-size: 0.65rem;
}
.matchup-behavior-map {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--border);
    background: var(--background);
}
.matchup-quadrant {
    display: grid;
    align-content: center;
    min-width: 0;
    min-height: 7.4rem;
    border: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 0.8rem;
    text-align: left;
    cursor: pointer;
    color: var(--foreground);
}
.matchup-quadrant:nth-child(2n) { border-right: 0; }
.matchup-quadrant:nth-child(n+3) { border-bottom: 0; }
.matchup-quadrant span,
.matchup-quadrant small {
    display: block;
    overflow-wrap: anywhere;
}
.matchup-quadrant span {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.28px;
    text-transform: uppercase;
}
.matchup-quadrant strong {
    display: block;
    margin: 0.32rem 0 0.18rem;
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.matchup-quadrant small {
    color: var(--muted-foreground);
    font-size: 0.65rem;
    line-height: 1.3;
}
.matchup-quadrant.diversifies-left { background: rgba(0, 100, 114, 0.065); }
.matchup-quadrant.diversifies-right { background: rgba(212, 169, 106, 0.1); }
.matchup-quadrant.together-up { background: rgba(46, 125, 50, 0.055); }
.matchup-quadrant.together-down { background: rgba(198, 40, 40, 0.05); }
.matchup-quadrant:hover { filter: saturate(1.25); }
.matchup-quadrant.active {
    box-shadow: inset 0 0 0 2px var(--bitwise-dark-teal);
}
.matchup-defense-row {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) repeat(3, minmax(4.3rem, 0.7fr));
    min-height: 6rem;
    border: 1px solid var(--border);
    border-bottom: 0;
    background: var(--background);
}
.matchup-defense-row > div {
    display: grid;
    align-content: center;
    gap: 0.24rem;
    min-width: 0;
    padding: 0.72rem;
    border-right: 1px solid var(--border);
}
.matchup-defense-row > div:last-child { border-right: 0; }
.matchup-defense-row span {
    color: var(--muted-foreground);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.28px;
    line-height: 1.35;
    text-transform: uppercase;
}
.matchup-defense-row strong {
    overflow-wrap: anywhere;
    color: var(--foreground-strong);
    font-size: 0.82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.matchup-defense-row strong.positive { color: var(--positive-color); }
.matchup-defense-row strong.negative { color: var(--negative-color); }
.matchup-beta-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.45rem 1rem;
    padding: 0.67rem 0.72rem;
    border: 1px solid var(--border);
    background: #f8faf9;
    color: var(--muted-foreground);
    font-size: 0.66rem;
    line-height: 1.4;
}
.matchup-beta-line strong {
    margin-left: 0.25rem;
    color: var(--foreground-strong);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.matchup-chart-heading {
    align-items: center;
    margin-top: 1.1rem;
}
.matchup-chart-heading > div {
    display: grid;
    gap: 0.22rem;
}
.matchup-clear-filter[hidden] { display: none; }
.matchup-return-chart {
    width: 100%;
    min-height: 390px;
    border: 1px solid var(--border);
    background: var(--background);
    overflow: hidden;
}
.matchup-chart-empty {
    display: grid;
    min-height: 390px;
    place-items: center;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}
.matchup-audit {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    background: var(--background);
}
.matchup-audit > summary {
    padding: 0.62rem 0.72rem;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.4;
}
.matchup-audit[open] > summary { border-bottom: 1px solid var(--border); }
.matchup-audit-body {
    display: grid;
    gap: 0.38rem;
    padding: 0.68rem 0.72rem;
}
.matchup-audit-body p {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 0.65rem;
    line-height: 1.45;
}
.matchup-audit-body strong { color: var(--foreground-strong); }
.matchup-audit-body code {
    overflow-wrap: anywhere;
    color: var(--foreground);
    font-family: var(--font-neue-montreal-mono, monospace);
    font-size: 0.62rem;
}
@media (max-width: 1080px) {
    .matchup-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .matchup-stat:nth-child(3n) { border-right: 0; }
    .matchup-stat:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
    .matchup-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .matchup-controls {
        align-items: stretch;
        justify-content: flex-start;
        width: 100%;
    }
    .matchup-pair-control { flex: 1 1 100%; }
    .matchup-pair-control select { width: 100%; }
    .matchup-grain-control {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        width: 100%;
    }
    .matchup-grain-control button { min-width: 0; }
    .matchup-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .matchup-stat:nth-child(3n) { border-right: 1px solid var(--border); }
    .matchup-stat:nth-child(2n) { border-right: 0; }
    .matchup-stat:nth-child(-n+4) { border-bottom: 1px solid var(--border); }
    .matchup-defense-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .matchup-defense-row > div:first-child {
        grid-column: 1 / -1;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .matchup-chart-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}
@media (max-width: 480px) {
    .matchup-stat-grid { grid-template-columns: 1fr; }
    .matchup-stat,
    .matchup-stat:nth-child(2n),
    .matchup-stat:nth-child(3n) {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .matchup-stat:last-child { border-bottom: 0; }
    .matchup-behavior-map { grid-template-columns: 1fr; }
    .matchup-quadrant,
    .matchup-quadrant:nth-child(2n),
    .matchup-quadrant:nth-child(n+3) {
        min-height: 5.8rem;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .matchup-quadrant:last-child { border-bottom: 0; }
}

/* ===== WHAT DROVE RETURNS — per-scenario card ===== */
.wdr-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.wdr-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem 1.15rem 1.15rem;
}
.wdr-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.8rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border);
}
.wdr-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
    font-family: var(--font-neue-montreal);
}
.wdr-card-total {
    font-size: 0.78rem;
    color: var(--muted-foreground);
}
.wdr-card-total strong { color: var(--foreground); }

.wdr-hero-row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 1rem;
}
.wdr-hero-stat {
    min-width: 0;
    background: #fafbfc;
    border: 1px solid var(--rule-soft, #eef0f2);
    border-radius: 0;
    padding: 0.55rem 0.65rem;
}
.wdr-hero-stat span {
    display: block;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted-foreground);
    line-height: 1.2;
}
.wdr-hero-stat strong {
    display: block;
    margin-top: 0.15rem;
    color: var(--foreground);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.wdr-hero-stat strong.positive,
.wdr-hero-delta.positive { color: var(--positive, #0e7a3a); }
.wdr-hero-stat strong.negative,
.wdr-hero-delta.negative { color: var(--negative, #c0392b); }
.wdr-hero-delta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.2;
}
.wdr-hero-delta.muted {
    color: var(--muted-foreground);
}

.wdr-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 1180px) {
    .wdr-hero-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
    .wdr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .wdr-hero-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.wdr-subtitle {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--muted-foreground);
    margin-bottom: 0.6rem;
}
.wdr-chart-note {
    margin-top: -0.25rem;
    margin-bottom: 0.45rem;
    color: var(--muted-foreground);
    font-size: 0.7rem;
    line-height: 1.35;
}

/* Contribution row — 5 columns:
     [ Asset | Own return | Return bar | Contribution pp | PnL $ ]  */
.wdr-contrib-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.wdr-contrib-row {
    display: grid;
    grid-template-columns: 86px 62px minmax(120px, 1fr) 64px 72px;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}
.wdr-contrib-row--head {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--muted-foreground);
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--rule-soft, #eef0f2);
    margin-bottom: 0.15rem;
}
.wdr-contrib-row--head .wdr-contrib-bar-wrap {
    background: transparent;
    height: auto;
}
.wdr-contrib-row--head .wdr-contrib-bar-wrap::before { display: none; }
.wdr-contrib-bar-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}
.wdr-contrib-row--agg .wdr-contrib-sym {
    font-style: italic;
    color: var(--muted-foreground);
    font-weight: 500;
}
.wdr-contrib-row--total {
    padding-top: 0.5rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--rule-soft, #eef0f2);
    font-weight: 600;
}
.wdr-contrib-row--total .wdr-contrib-sym {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.wdr-contrib-sym {
    font-weight: 600;
    color: var(--foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wdr-contrib-ret {
    text-align: right;
    font-weight: 500;
}
.wdr-contrib-bar-wrap {
    position: relative;
    height: 14px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}
.wdr-contrib-bar-wrap::before {
    /* Center line — positive bars extend right, negative extend left. */
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(0,0,0,0.12);
}
.wdr-contrib-bar {
    position: absolute;
    top: 1px;
    bottom: 1px;
    border-radius: 2px;
}
.wdr-bar-pos { background: linear-gradient(90deg, #3aaa9e, #006472); }
.wdr-bar-neg { background: linear-gradient(90deg, #c0392b, #a02717); }

.wdr-contrib-share {
    text-align: right;
    font-weight: 500;
}
.wdr-contrib-dollars {
    text-align: right;
    font-weight: 600;
}
.wdr-contrib-ret.positive,
.wdr-contrib-share.positive,
.wdr-contrib-dollars.positive { color: var(--positive, #0e7a3a); }
.wdr-contrib-ret.negative,
.wdr-contrib-share.negative,
.wdr-contrib-dollars.negative { color: var(--negative, #c0392b); }
.wdr-contrib-ret.muted,
.wdr-contrib-share.muted { color: var(--muted-foreground); }

.wdr-breakeven-note {
    margin-top: 0.6rem;
    font-size: 0.72rem;
    color: var(--muted-foreground);
    font-style: italic;
}

/* High-water mark context charts + drawdown/run-up meta */
.wdr-chart-pair {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-bottom: 0.55rem;
}
.wdr-side-chart-block {
    min-width: 0;
}
.wdr-chart-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--muted-foreground);
}
.wdr-chart-label::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--negative, #c0392b);
}
.wdr-chart-label--positive::before {
    background: var(--positive, #0e7a3a);
}
.wdr-underwater,
.wdr-runup {
    width: 100%;
    height: 104px;
    border: 1px solid var(--rule-soft, #eef0f2);
    box-sizing: border-box;
}
.wdr-dd-meta {
    font-size: 0.75rem;
    color: var(--foreground);
    line-height: 1.5;
    margin-bottom: 0.85rem;
}
.wdr-dd-meta strong { font-weight: 600; }
.wdr-dd-meta .negative { color: var(--negative, #c0392b); }
.wdr-dd-meta .positive { color: var(--positive, #0e7a3a); }

/* Mini cards: best/worst day + win rate */
.wdr-mini-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.wdr-mini {
    background: #fafbfc;
    border: 1px solid var(--rule-soft, #eef0f2);
    border-radius: 0;
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.wdr-mini-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
}
.wdr-mini-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--foreground);
    font-variant-numeric: tabular-nums;
}
.wdr-mini-value.positive { color: var(--positive, #0e7a3a); }
.wdr-mini-value.negative { color: var(--negative, #c0392b); }
.wdr-mini-sub {
    font-size: 0.65rem;
    color: var(--muted-foreground);
}

/* ===== SCENARIO COMPARISON MATRIX ===== */
.scenario-strips-section {
    display: block;
    margin-bottom: 2rem;
    overflow: hidden;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0;
}
.scenario-strip-table-head,
.scenario-strip {
    display: grid;
    grid-template-columns: 4.65rem minmax(220px, 1.45fr) minmax(360px, 1.7fr) minmax(220px, 0.95fr);
    gap: 1.15rem;
    align-items: center;
}
.scenario-strip-table-head {
    min-height: 2.45rem;
    padding: 0 1.15rem;
    background: #f7f9f8;
    border-bottom: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
}
.scenario-strip {
    position: relative;
    min-height: 4.85rem;
    padding: 0.82rem 1.15rem;
    border: 0;
    border-radius: 0;
    background: var(--background);
    transition: background-color 0.15s;
}
.scenario-strip + .scenario-strip {
    border-top: 1px solid var(--border);
}
.scenario-strip:hover {
    background: #fbfcfb;
}
.strip-control-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.42rem;
    min-width: 0;
}
.strip-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.strip-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.05rem;
    height: 1.35rem;
    padding: 0 0.4rem;
    border: 1px solid rgba(0, 100, 114, 0.16);
    border-radius: 999px;
    background: rgba(0, 100, 114, 0.055);
    color: var(--bitwise-dark-teal);
    font-size: 0.61rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.strip-scenario-cell {
    min-width: 0;
}
.strip-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    letter-spacing: 0;
}
.strip-source {
    flex-shrink: 0;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.72px;
    text-transform: uppercase;
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.07);
    padding: 0.11rem 0.42rem;
    border-radius: 999px;
    white-space: nowrap;
}
.strip-metrics {
    display: grid;
    grid-template-columns: minmax(5.35rem, 1.15fr) repeat(4, minmax(4.35rem, 1fr));
    gap: 0.28rem;
    align-items: center;
    min-width: 0;
}
.strip-metric {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
    font-size: 0.74rem;
    line-height: 1.1;
}
.strip-metric-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.62px;
    text-transform: uppercase;
    color: var(--muted-foreground);
}
.strip-metric-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--foreground);
    font-variant-numeric: tabular-nums;
}
.strip-metric--primary {
    padding: 0;
    border-radius: 0;
    background: transparent;
}
.strip-metric--primary .strip-metric-label {
    color: var(--muted-foreground);
}
.strip-metric--primary .strip-metric-value {
    color: var(--positive, #0e7a3a);
    font-size: 0.82rem;
}
.strip-metric-value.positive { color: var(--positive, #0e7a3a); }
.strip-metric-value.negative { color: var(--negative, #c0392b); }
.strip-allocation-cell {
    display: grid;
    gap: 0.38rem;
    min-width: 0;
}
.strip-bar {
    display: flex;
    width: min(100%, 280px);
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef0f2;
}
.strip-bar-seg {
    height: 100%;
    display: block;
    transition: filter 0.15s;
}
.strip-bar-seg:hover { filter: brightness(0.92); }
.strip-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.58rem;
    min-width: 0;
    color: var(--foreground);
    font-size: 0.64rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.strip-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-width: 0;
    white-space: nowrap;
}
.strip-chip-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    flex-shrink: 0;
}
.strip-proxy-note {
    grid-column: 2 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.1rem;
    padding: 0.45rem 0.6rem;
    background: #fef9ed;
    border: 1px solid #e3c989;
    border-radius: 6px;
    font-size: 0.72rem;
    color: #704f0f;
    line-height: 1.45;
}
.strip-proxy-note strong { color: #4a3509; font-weight: 700; }
.strip-proxy-note .muted { color: #8a6c2a; }
.strip-deferred-note {
    background: #eef8f7;
    border-color: #8ec7c1;
    color: #285b5a;
}
.strip-proxy-badge {
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    background: #d4a017;
    color: #fff;
    padding: 0.12rem 0.45rem;
    border-radius: 3px;
}
.strip-deferred-badge {
    background: #006472;
}
.scenario-strip .save-scenario-btn {
    position: static;
    justify-self: start;
    align-self: center;
}

@media (max-width: 1160px) {
    .scenario-strip-table-head,
    .scenario-strip {
        grid-template-columns: 4.65rem minmax(180px, 1.15fr) minmax(320px, 1.5fr);
    }

    .scenario-strip-table-head span:last-child,
    .strip-allocation-cell {
        grid-column: 2 / -1;
    }

    .scenario-strip-table-head span:last-child {
        display: none;
    }
}

@media (max-width: 760px) {
    .scenario-strip-table-head {
        display: none;
    }

    .scenario-strip {
        grid-template-columns: 4.65rem 1fr;
        gap: 0.7rem;
        padding: 0.9rem;
    }

    .strip-control-cell {
        justify-content: flex-start;
    }

    .strip-scenario-cell,
    .strip-metrics,
    .strip-allocation-cell,
    .strip-proxy-note {
        grid-column: 2 / -1;
    }

    .strip-name {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        line-height: 1.25;
    }

    .strip-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem 0.8rem;
    }

    .strip-bar {
        width: 100%;
    }
}

/* Chart header row — houses the Hide Benchmarks toggle next to the title. */
.chart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 1rem;
}
.chart-header-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.chart-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--muted-foreground);
    cursor: pointer;
    user-select: none;
}
.chart-toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--bitwise-dark-teal);
}

/* Save button on result scenario rows */
.save-scenario-btn {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    background: transparent;
    border: 1px solid transparent;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    color: var(--bitwise-light-grey, #9ca0ab);
    border-radius: 999px;
    transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.1s;
    z-index: 2;
}
.save-scenario-btn .material-icons {
    font-size: 1rem;
    line-height: 1;
}
.save-scenario-btn:hover {
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.06);
    border-color: rgba(0, 100, 114, 0.14);
}
.save-scenario-btn.saved {
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.09);
    border-color: rgba(0, 100, 114, 0.18);
}
.save-scenario-btn.saved:hover {
    color: #005562;
    background: rgba(0, 100, 114, 0.12);
}
.save-scenario-btn:active { transform: scale(0.92); }

/* Restored-snapshot banner inside config canvas */
.saved-restored-banner {
    background: linear-gradient(135deg, #f8fbf5 0%, #edf1de 100%);
    border: 1px solid #d6dfc1;
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
}
.saved-restored-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.8rem;
}
.saved-restored-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--bitwise-dark-teal);
    margin-bottom: 0.2rem;
}
.saved-restored-meta {
    font-size: 0.85rem;
    color: var(--foreground);
}
.saved-restored-meta strong { color: var(--bitwise-dark-teal); font-weight: 700; }
.saved-restored-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}
.saved-restored-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(0, 100, 114, 0.15);
}

/* ===== CONFIG PANEL ===== */
.config-panel {
    background: var(--background);
    border-right: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-height) - var(--subnav-height));
}

.app--configure .config-panel {
    border-right: none;
    background: transparent;
    overflow-y: auto;
}

/* ===== CONFIG CANVAS (configure mode) ===== */
.config-canvas {
    padding: 1rem 2.5rem 2.25rem;
    max-width: var(--canvas-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Settings row: value + date range */
.canvas-settings {
    display: grid;
    grid-template-columns: minmax(190px, 220px) minmax(360px, 520px);
    gap: 0.75rem;
    align-items: stretch;
    max-width: 760px;
    margin-bottom: 1.55rem;
}

/* Canvas field card */
.canvas-field-card {
    background: var(--background);
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    padding: 0.78rem;
    transition: border-color 0.2s;
    box-shadow: var(--shadow-hairline);
}

.canvas-field-card:focus-within {
    border-color: rgba(0, 100, 114, 0.28);
    box-shadow: 0 0 0 3px rgba(0, 100, 114, 0.06);
}

.canvas-field-card--value,
.canvas-field-card--date-range {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 86px;
    gap: 0.48rem;
}

.canvas-label {
    display: block;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--muted-foreground);
    margin-bottom: 0;
    font-weight: 700;
    line-height: 1;
}

.canvas-input {
    width: 100%;
    font-size: 1.12rem;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--foreground-strong);
    outline: none;
    font-family: var(--font-neue-montreal);
    min-width: 0;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.canvas-input::placeholder {
    color: var(--muted-foreground);
    font-weight: 400;
}

.canvas-select {
    width: 100%;
    font-size: var(--text-md);
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--foreground);
    outline: none;
    font-family: var(--font-neue-montreal);
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0 center;
    background-size: 13px 13px;
    padding-right: 1.1rem;
}

.canvas-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.55rem;
    padding: 0 0.62rem;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: var(--surface-quiet);
}

.canvas-prefix {
    color: var(--bitwise-dark-teal);
    font-size: 0.86rem;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

.canvas-field-card--value .canvas-input {
    font-size: 0.86rem;
    font-weight: 700;
}

.canvas-date-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
}

.canvas-date-field {
    display: grid;
    gap: 0.22rem;
    min-width: 0;
    padding: 0.42rem 0.55rem;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: var(--surface-quiet);
}

.canvas-date-label {
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.canvas-date-inputs input[type="date"] {
    width: 100%;
    font-size: 0.86rem;
    font-weight: 700;
    background: transparent;
    border: none;
    color: var(--foreground-strong);
    outline: none;
    font-family: var(--font-neue-montreal);
    min-width: 0;
    cursor: pointer;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.canvas-date-inputs input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.4;
    cursor: pointer;
}

.canvas-date-arrow {
    color: var(--muted-foreground);
    font-size: 0.85rem;
    flex-shrink: 0;
    line-height: 1;
}

/* Canvas section header — phase label (Setup, Scenarios, …) */
.canvas-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.config-canvas > .canvas-section-header:not(:first-child) {
    margin-top: 2.25rem;
}

#canvas-scenarios-section > .canvas-section-header {
    margin-top: 0;
}

#canvas-scenarios-section,
#scenarios-container {
    width: 100%;
    max-width: 100%;
}

.canvas-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0;
    margin: 0;
    font-family: var(--font-neue-montreal);
}

.scenario-builder {
    background: var(--background);
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow-hairline);
    padding: 1rem;
    width: 100%;
    margin-bottom: 1.25rem;
}

.scenario-builder-mode {
    display: inline-flex;
    border: 1px solid var(--border-soft);
    border-radius: var(--control-radius);
    overflow: hidden;
    background: var(--surface-quiet);
}

.scenario-builder-mode-btn {
    min-height: 2rem;
    border: 0;
    border-right: 1px solid var(--border-soft);
    background: transparent;
    color: var(--muted-foreground);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 0 0.75rem;
    cursor: pointer;
}

.scenario-builder-mode-btn:last-child { border-right: 0; }

.scenario-builder-mode-btn.active {
    background: var(--bitwise-dark-teal);
    color: #fff;
}

.scenario-builder-panel {
    display: none;
}

.scenario-builder-panel.active {
    display: block;
}

.scenario-builder-preview {
    margin-top: 0.75rem;
    padding: 0.72rem 0.8rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--panel-radius);
    color: var(--foreground);
    font-size: var(--text-sm);
    line-height: 1.45;
    background: var(--surface-quiet);
}

.scenario-builder-preview:empty {
    display: none;
}

.scenario-builder-preview.is-error {
    border-color: rgba(198, 40, 40, 0.36);
    color: #8f2424;
    background: #fff8f6;
}

.overlay-size-control {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.overlay-size-suffix {
    color: var(--text-secondary);
    font-size: var(--text-md);
    font-weight: 700;
}

.overlay-size-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.overlay-size-presets button {
    min-width: 2.15rem;
    min-height: 1.35rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--control-radius);
    background: var(--surface-quiet);
    color: var(--muted-foreground);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-xs);
    font-weight: 700;
    cursor: pointer;
}

.overlay-size-presets button:hover,
.overlay-size-presets button:focus-visible {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.overlay-blend-panel {
    width: 100%;
    margin: -0.2rem 0 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
}

.overlay-blend-panel[hidden] {
    display: none;
}

.overlay-blend-header,
.overlay-blend-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.overlay-blend-header {
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.overlay-blend-rows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: var(--space-2);
}

.overlay-blend-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto var(--control-height);
    align-items: center;
    gap: var(--space-2);
}

.overlay-blend-quick-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.overlay-blend-quick {
    min-height: var(--control-height);
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    padding: 0 0.72rem;
    background: var(--surface-quiet);
    color: var(--foreground-strong);
    font-size: var(--text-sm);
    font-weight: 650;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.overlay-blend-quick:hover,
.overlay-blend-quick:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.overlay-blend-asset-picker {
    min-width: 0;
}

.overlay-blend-weight-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.overlay-blend-weight {
    width: 4.1rem;
    min-height: var(--control-height);
    padding: 0 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-sm);
    text-align: center;
}

.overlay-blend-weight:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.overlay-blend-remove {
    width: var(--control-height);
    height: var(--control-height);
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.overlay-blend-remove .material-icons {
    font-size: 15px;
}

.overlay-blend-remove:hover {
    background: rgba(198, 40, 40, 0.06);
    border-color: rgba(198, 40, 40, 0.14);
    color: var(--destructive);
}

.overlay-blend-total {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 700;
}

.overlay-blend-total.valid { color: var(--bitwise-green); }
.overlay-blend-total.invalid { color: var(--destructive); }

.custom-file-card {
    overflow: visible;
}

.custom-file-display {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--foreground);
    font-size: var(--text-md);
    line-height: 1.25;
    cursor: pointer;
    position: relative;
}

.custom-file-display .material-icons {
    color: var(--bitwise-dark-teal);
    font-size: 1rem;
    flex-shrink: 0;
}

.custom-file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    right: 0.5rem;
    bottom: 0.5rem;
    opacity: 0;
    pointer-events: none;
}

.scenario-client-btn.active {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.08);
}

.report-editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: var(--background);
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.report-editor {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    background: var(--background);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.report-editor-header,
.report-editor-actions,
.report-editor-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.report-editor-header {
    margin-bottom: 1rem;
    flex: 0 0 auto;
}

.report-editor-header h2 {
    margin: 0.15rem 0 0;
    font-size: 1rem;
}

.report-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.report-editor-count,
.report-editor-preview-state {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 0.55rem;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    background: var(--surface-quiet);
    white-space: nowrap;
}

.report-editor-count.is-empty,
.report-editor-preview-state.is-error {
    color: #9a3412;
    border-color: rgba(154, 52, 18, 0.22);
    background: rgba(154, 52, 18, 0.06);
}

.report-editor-preview-state.is-dirty {
    color: var(--bitwise-green);
    border-color: rgba(69, 185, 121, 0.28);
    background: rgba(69, 185, 121, 0.08);
}

.report-editor-options {
    display: grid;
    grid-template-columns: minmax(220px, 1.15fr) minmax(210px, 1fr) minmax(220px, 1.1fr) minmax(170px, 0.8fr);
    align-items: start;
    justify-content: stretch;
    gap: 0.75rem 1rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 0.6rem;
    font-size: var(--text-sm);
    color: var(--foreground);
    flex: 0 0 auto;
}

.report-editor-option-group {
    display: grid;
    gap: 0.38rem;
    align-content: start;
    min-width: 0;
}

.report-editor-option-group-title {
    display: block;
    margin-bottom: 0.08rem;
    color: var(--muted-foreground);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.report-editor-options label,
.report-editor-option-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.report-editor-option-row {
    color: var(--foreground-strong);
    line-height: 1.25;
}

.report-editor-option-row input {
    flex: 0 0 auto;
    margin: 0;
}

.report-editor-select-option {
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: var(--text-xs);
}

.report-editor-select-option span {
    min-width: 0;
}

.report-editor-select-option select {
    height: 1.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--background);
    color: var(--foreground-strong);
    font: inherit;
    font-size: var(--text-xs);
    padding: 0 1.45rem 0 0.45rem;
}

@media (max-width: 1180px) {
    .report-editor-options {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 760px) {
    .report-editor-options {
        grid-template-columns: minmax(0, 1fr);
    }
}

.report-editor-limit {
    color: var(--muted-foreground);
    font-size: var(--text-xs);
    margin-bottom: 0.75rem;
    flex: 0 0 auto;
}

.report-editor-workspace {
    display: grid;
    grid-template-columns: minmax(420px, 0.8fr) minmax(560px, 1.2fr);
    gap: 1rem;
    min-height: 0;
    flex: 1 1 auto;
}

.report-editor-draft,
.report-editor-preview {
    min-width: 0;
    min-height: 0;
}

.report-editor-draft {
    overflow: auto;
    padding-right: 0.25rem;
}

.report-editor-block-header,
.report-editor-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.report-title-field {
    display: grid;
    gap: 0.4rem;
    margin: 0 0 0.75rem;
}

.report-scenario-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0.45rem 0 1rem;
}

.report-scenario-option {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--control-radius);
    background: var(--surface-quiet);
    color: var(--foreground);
    min-height: 64px;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.report-scenario-option.is-selected {
    border-color: rgba(0, 100, 114, 0.42);
    background: rgba(0, 100, 114, 0.045);
    box-shadow: inset 0 0 0 1px rgba(0, 100, 114, 0.08);
}

.report-scenario-option:has(input:disabled) {
    opacity: 0.55;
}

.report-scenario-option strong,
.report-scenario-option small {
    display: block;
    line-height: 1.25;
}

.report-scenario-option strong {
    font-size: var(--text-sm);
    color: var(--foreground-strong);
}

.report-scenario-option small,
.report-editor-empty {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.report-recommendation-picker {
    display: grid;
    gap: 0.4rem;
    margin: 0 0 1rem;
}

.report-editor-textarea {
    width: 100%;
    min-height: 9rem;
    resize: vertical;
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    padding: 0.75rem;
    margin: 0.5rem 0 1rem;
    font-family: var(--font-neue-montreal);
    font-size: var(--text-md);
    line-height: 1.45;
    color: var(--foreground);
    background: var(--surface-quiet);
}

.report-editor-textarea--summary {
    min-height: 7.25rem;
}

.report-editor-textarea--narrative {
    min-height: 18rem;
}

.report-narrative-blocks {
    display: grid;
    gap: 0.7rem;
    margin: 0.5rem 0 1rem;
}

.report-narrative-block {
    display: grid;
    gap: 0.35rem;
}

.report-narrative-block > span {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--muted-foreground);
    font-weight: 700;
}

.report-editor-textarea--narrative-block {
    min-height: 8rem;
    margin: 0;
}

.report-editor-advanced {
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    background: var(--surface-quiet);
    margin: 0.25rem 0 1rem;
    overflow: hidden;
}

.report-editor-advanced summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.72rem 0.85rem;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--foreground-strong);
}

.report-editor-advanced summary small {
    color: var(--muted-foreground);
    font-size: var(--text-xs);
    font-weight: 500;
}

.report-copy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    padding: 0 0.85rem 0.85rem;
}

.report-copy-field {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.report-copy-field span {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--muted-foreground);
    font-weight: 700;
}

.report-copy-input {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--border-soft);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-sm);
    line-height: 1.35;
    padding: 0.55rem 0.62rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.report-copy-input--textarea {
    min-height: 74px;
    resize: vertical;
}

.report-copy-input:focus,
.report-copy-input.is-linked,
.report-editor-textarea.is-linked {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
    background: #fff;
}

.report-editor-preview {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.report-editor-preview-canvas {
    --report-preview-scale: 0.72;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    background: #f6f6f3;
    overflow: hidden;
}

.report-editor-preview iframe {
    width: calc(100% / var(--report-preview-scale));
    height: calc(100% / var(--report-preview-scale));
    border: 0;
    background: #f6f6f3;
    display: block;
    transform: scale(var(--report-preview-scale));
    transform-origin: top left;
}

.report-editor-actions {
    justify-content: flex-end;
    flex: 0 0 auto;
    margin-top: 0.9rem;
}

@media (max-width: 980px) {
    .report-editor {
        height: calc(100vh - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .report-editor-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .report-editor-header-actions {
        order: 3;
        width: 100%;
        margin-left: 0;
    }

    .report-editor-workspace {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .report-editor-draft {
        overflow: visible;
        padding-right: 0;
    }

    .report-editor-preview {
        min-height: 560px;
    }

    .report-copy-grid {
        grid-template-columns: 1fr;
    }

    .report-scenario-list {
        grid-template-columns: 1fr;
    }
}

/* Sub-header used to group scenario generators under the Scenarios phase */
.canvas-subheader {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted-foreground);
    font-family: var(--font-neue-montreal);
    margin: 1.75rem 0 0.7rem 0;
    letter-spacing: 0;
}

.canvas-section-actions {
    display: flex;
    gap: var(--space-2);
}

.canvas-action-row {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    flex-wrap: wrap;
}

/* Canvas action buttons (small) */
.canvas-action-btn {
    min-height: var(--control-height-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1;
    padding: 0 0.7rem;
    border-radius: var(--control-radius);
    border: 1px solid var(--border-strong);
    background: var(--background);
    color: var(--foreground-strong);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.canvas-action-btn .material-icons {
    font-size: 14px;
    line-height: 1;
}

.canvas-action-btn:hover {
    background: var(--surface-subtle);
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
}

.canvas-action-btn:focus-visible {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.canvas-action-btn--teal {
    background: var(--bitwise-dark-teal);
    color: white;
    border-color: var(--bitwise-dark-teal);
}

.canvas-action-btn--teal:hover {
    background: #005562;
    border-color: #005562;
    color: white;
}

/* Scenarios grid */
.canvas-scenarios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
    gap: var(--space-4);
    align-items: start;
    margin-bottom: var(--space-5);
}

/* Scenario cards in canvas */
.config-canvas .scenario-config {
    background: var(--background);
    border: 1px solid var(--border-strong);
    border-radius: var(--panel-radius);
    overflow: hidden;
    margin-bottom: 0;
    width: 100%;
    min-width: 0;
    box-shadow: 0 1px 2px rgba(20, 36, 32, 0.05);
}

.config-canvas .scenario-header {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) auto;
    align-items: center;
    min-height: 2.65rem;
    padding: 0.5rem var(--space-4);
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-strong);
    gap: 0.65rem;
}

.config-canvas .scenario-name-input {
    width: 100%;
    font-size: var(--text-md);
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    outline: none;
    min-width: 0;
    padding: 0;
    min-height: 1.25rem;
}

.config-canvas .scenario-body {
    padding: 0.85rem var(--space-4) var(--space-4);
}

.config-canvas .scenario-collapse-summary {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.45rem;
    padding: 0.55rem var(--space-4);
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-quiet);
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-sm);
    line-height: 1.35;
    overflow: hidden;
}

.config-canvas .scenario-collapse-summary[hidden] {
    display: none;
}

.scenario-summary-meta {
    flex: 0 0 auto;
    color: var(--bitwise-dark-teal);
    font-weight: 700;
}

.scenario-summary-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.scenario-summary-sleeve {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scenario-summary-sleeve strong {
    color: var(--foreground-strong);
    font-weight: 700;
}

.scenario-summary-divider {
    color: var(--text-muted);
    flex: 0 0 auto;
}

/* Side-by-side rebalancing + fee */
.scenario-settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.scenario-settings-row .form-group {
    margin-bottom: 0;
}

.scenario-cost-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 0.45rem;
    padding: 0.48rem 0.55rem;
    border: 1px solid var(--border-soft);
    background: var(--surface-quiet);
}

.scenario-cost-field label {
    font-size: 0.58rem;
    letter-spacing: 0.42px;
}

.scenario-cost-field input {
    height: 1.65rem;
    min-height: 1.65rem;
    padding: 0 0.45rem;
    font-size: 0.72rem;
}

.scenario-balance-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    width: 100%;
    grid-column: 1 / -1;
}

.scenario-opening-cost-control {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.65rem;
    color: var(--text-secondary);
    font-size: 0.66rem;
    white-space: nowrap;
}

.scenario-opening-cost-control input {
    width: 0.82rem;
    height: 0.82rem;
    margin: 0;
}

.scenario-execution-note {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.35;
}

.scenario-balance-actions .canvas-action-btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
}

.scenario-groups-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.scenario-group,
.optimizer-group {
    border: 1px solid var(--border-strong);
    border-radius: var(--panel-radius);
    background: var(--surface-quiet);
    padding: var(--space-3);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.scenario-group-header,
.optimizer-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

.scenario-group-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
}

.scenario-group-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.scenario-group-name,
.optimizer-group-name {
    flex: 1 1 9rem;
    min-width: 0;
    min-height: var(--control-height-sm);
    border: none;
    background: transparent;
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: var(--text-md);
    font-weight: 700;
    outline: none;
    padding: 0 var(--space-1);
}

.scenario-group-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--control-height) calc(3.65rem + 1rem) var(--control-height) var(--control-height-sm);
    grid-template-areas: "balance optimize target lock spacer";
    align-items: end;
    gap: var(--space-2);
    width: 100%;
}

.scenario-group-number,
.optimizer-group-max {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted-foreground);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.scenario-group-number {
    grid-area: target;
    align-items: stretch;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.scenario-group-target-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.scenario-group-percent,
.scenario-group-control-label {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1;
}

.scenario-group-lock-cell {
    grid-area: lock;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.scenario-group-remove-spacer {
    grid-area: spacer;
    width: var(--control-height-sm);
    height: var(--control-height-sm);
}

.scenario-group-controls .scenario-balance-btn {
    grid-area: balance;
    width: 100%;
}

.scenario-group-controls .scenario-optimize-btn {
    grid-area: optimize;
    width: var(--control-height);
    min-width: var(--control-height);
    padding: 0;
}

.scenario-group-controls .scenario-optimize-btn .material-icons {
    font-size: 18px;
}

.scenario-group-number input,
.optimizer-group-max input {
    width: 3.65rem;
    min-height: var(--control-height-sm);
    padding: 0 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    background: var(--background);
    color: var(--foreground-strong);
    text-align: center;
}

.optimizer-group-max input {
    width: 4.35rem;
}

.optimizer-context-note {
    margin: 0 0 var(--space-2);
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(0, 100, 114, 0.16);
    border-radius: var(--control-radius);
    background: rgba(0, 100, 114, 0.055);
    color: var(--foreground);
    font-size: var(--text-sm);
    line-height: 1.35;
}

.scenario-group-assets,
.optimizer-group-assets {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.scenario-group-assets .asset-row,
.optimizer-group-assets .asset-row {
    margin-bottom: 0;
}

.scenario-group-total {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
}

.scenario-group-total.valid { color: var(--bitwise-green); }
.scenario-group-total.invalid { color: var(--destructive); }

.add-asset-btn--group {
    margin-top: var(--space-2);
}

.weight-lock-btn {
    width: var(--control-height);
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--muted-foreground);
    cursor: pointer;
    flex-shrink: 0;
}

.weight-lock-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.weight-lock-btn.locked {
    border-color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.08);
    color: var(--bitwise-dark-teal);
}

.weight-lock-btn:hover,
.weight-lock-btn:focus-visible,
.scenario-group-number input:focus,
.optimizer-group-max input:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.scenario-group-remove-btn,
.optimizer-group-header .remove-asset-btn {
    width: var(--control-height-sm);
    height: var(--control-height-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.scenario-group-remove-btn .material-icons,
.optimizer-group-header .remove-asset-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.scenario-group-remove-btn:hover,
.optimizer-group-header .remove-asset-btn:hover {
    background: rgba(198, 40, 40, 0.06);
    border-color: rgba(198, 40, 40, 0.14);
    color: var(--destructive);
}

/* Canvas collapsible sections */
.canvas-collapsible {
    border: 1px solid var(--border-soft);
    border-radius: var(--panel-radius);
    margin-bottom: var(--space-4);
    overflow: hidden;
    background: var(--background);
    box-shadow: var(--shadow-hairline);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.canvas-collapsible:hover {
    border-color: rgba(0, 100, 114, 0.18);
}

.canvas-collapsible--nested {
    margin: var(--space-4) 0 0;
    background: var(--surface-subtle);
    border-color: var(--border-soft);
}

.canvas-collapsible--nested .canvas-collapsible-toggle {
    background: transparent;
    padding: 0 var(--space-4);
    min-height: 2.55rem;
    font-size: var(--text-md);
}

.canvas-collapsible--nested .canvas-collapsible-body {
    background: var(--background);
    padding: var(--space-4);
}

.canvas-collapsible-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.95rem;
    padding: 0 var(--space-5);
    background: var(--surface-quiet);
    border: none;
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--foreground-strong);
    text-transform: none;
    letter-spacing: 0;
    transition: background 0.2s;
}

.canvas-collapsible-toggle:hover {
    background: var(--surface-subtle);
}

.canvas-toggle-icon {
    font-size: 0.85rem;
    color: var(--bitwise-light-grey);
    font-weight: 400;
    line-height: 1;
    transition: transform 0.2s ease;
}

.canvas-collapsible-body {
    padding: var(--space-5);
    border-top: 1px solid var(--border-soft);
    background: var(--surface-subtle);
}

.canvas-hint {
    font-size: 0.78rem;
    color: var(--muted-foreground);
    margin-bottom: 0.9rem;
    line-height: 1.5;
}

/* ===== SCENARIO SEARCH — sidebar chip axes ===== */
.ss-axis-stack {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.25rem;
}
.ss-axis {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.ss-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.ss-chip {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    transition: all 0.15s ease;
    letter-spacing: 0.1px;
}
.ss-chip:hover {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
}
.ss-chip.active {
    background: var(--bitwise-dark-teal);
    color: #fff;
    border-color: var(--bitwise-dark-teal);
}
.ss-chip.active:hover {
    background: #005562;
    border-color: #005562;
}
.ss-sleeve-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}
.ss-sleeve-row .asset-dropdown-wrap { flex: 1; }
.ss-sleeve-weight-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}
.ss-sleeve-weight-wrap .weight-label {
    width: 3.65rem;
    max-width: 3.65rem;
    white-space: normal;
    line-height: 1.05;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.ss-add-sleeve-btn {
    margin: var(--space-2) 0 var(--space-3);
}

/* ===== SCENARIO SEARCH — main results panel ===== */
.ss-main-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.8rem;
}
.ss-main-header h3 {
    margin: 0;
    font-family: var(--font-neue-montreal);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted-foreground);
}
.ss-main-header .ss-meta {
    font-size: 0.78rem;
    color: var(--muted-foreground);
}
/* Distribution banner (anti-overfit signal) */
.ss-dist-banner {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.9rem;
}
.ss-dist-banner--warn {
    background: #fef9ed;
    border-color: #e3c989;
}
.ss-dist-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}
.ss-dist-cell { display: flex; flex-direction: column; gap: 0.15rem; }
.ss-dist-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted-foreground);
}
.ss-dist-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--foreground);
}
.ss-dist-warning {
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px dashed #e3c989;
    font-size: 0.78rem;
    color: #8a6314;
    line-height: 1.45;
}

/* "Why" bullet inside the top-pick card */
.ss-why {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    margin: 0.2rem 0 0.85rem;
    padding: 0.55rem 0.7rem;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(0, 100, 114, 0.15);
    border-radius: 6px;
}
.ss-why-badge {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: var(--bitwise-dark-teal);
    color: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    margin-top: 1px;
}
.ss-why-text {
    font-size: 0.78rem;
    color: var(--foreground);
    line-height: 1.5;
}
.ss-why-text strong { color: var(--bitwise-dark-teal); }

/* Clipped-window annotation */
.ss-window-clip {
    color: var(--muted-foreground);
    font-style: italic;
    font-size: 0.75rem;
}

.ss-top-card {
    background: linear-gradient(135deg, #f8fbf5 0%, #edf1de 100%);
    border: 1px solid #d6dfc1;
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}
.ss-top-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted-foreground);
    margin-bottom: 0.4rem;
}
.ss-top-card-headline {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bitwise-dark-teal);
    margin-bottom: 0.25rem;
    font-family: var(--font-neue-montreal);
}
.ss-top-card-axes {
    font-size: 0.82rem;
    color: var(--foreground);
    margin-bottom: 0.7rem;
}
.ss-top-card-axes strong { font-weight: 600; color: var(--bitwise-dark-teal); }
.ss-top-card-metrics {
    display: flex;
    gap: 1.4rem;
    flex-wrap: wrap;
}
.ss-top-metric { display: flex; flex-direction: column; gap: 0.15rem; }
.ss-top-metric-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted-foreground);
}
.ss-top-metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--foreground);
}
.ss-grid-wrap { margin-top: 0.5rem; }
.ss-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.ss-grid-table thead th {
    background: var(--secondary);
    color: var(--foreground);
    font-weight: 600;
    padding: 0.55rem 0.7rem;
    text-align: right;
    font-size: 0.68rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.ss-grid-table thead th.ss-col-lookback,
.ss-grid-table thead th.ss-col-rebal { text-align: left; }
.ss-grid-table thead th:hover { color: var(--bitwise-dark-teal); }
.ss-grid-table thead th.sort-asc::after  { content: ' \25B2'; font-size: 0.6rem; }
.ss-grid-table thead th.sort-desc::after { content: ' \25BC'; font-size: 0.6rem; }
.ss-grid-table tbody td {
    padding: 0.45rem 0.7rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.ss-grid-table tbody td.ss-col-lookback,
.ss-grid-table tbody td.ss-col-rebal {
    text-align: left;
    color: var(--foreground);
}
.ss-grid-table tbody td.ss-col-weight { font-weight: 600; }
.ss-grid-table tbody tr:hover td { background: rgba(0,100,114,0.04); }
.ss-grid-table tbody tr.ss-best-row td { background: #edf1de; font-weight: 600; }
.ss-use-btn,
.ss-grid-table .ss-use-btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--bitwise-dark-teal);
    background: transparent;
    color: var(--bitwise-dark-teal);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-weight: 600;
    transition: all 0.15s;
}
.ss-use-btn:hover,
.ss-grid-table .ss-use-btn:hover {
    background: var(--bitwise-dark-teal);
    color: #fff;
}

/* Index builder grid */
.canvas-index-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.canvas-index-grid--row2 {
    margin-bottom: 1.75rem;
}
.canvas-field-card--empty {
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

/* Pinned index card in Portfolio Backtest canvas */
.pinned-index-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--secondary);
    border: 1.5px solid #006472;
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}
.pinned-index-info {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    flex-wrap: wrap;
    min-width: 0;
}
.pinned-index-badge {
    background: #006472;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.pinned-index-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-index-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pinned-index-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.pinned-index-remove:hover { color: #c0392b; }

/* Optimizer settings grid inside canvas collapsible */
.canvas-opt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: var(--space-3);
    margin: var(--space-3) 0 var(--space-4);
}

.canvas-opt-grid--scenario-builder {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.canvas-opt-grid--overlay {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0.75rem 0 0;
}

.canvas-opt-grid--stacked {
    margin-top: var(--space-3);
}

.canvas-field-card--sm {
    padding: var(--space-3) var(--space-4);
}

.canvas-field-card--span-2 {
    grid-column: span 2;
}

.canvas-field-card--centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-field-card--stacked {
    margin-bottom: var(--space-3);
}

.canvas-field-card--sm .canvas-label {
    font-size: var(--text-xs);
    margin-bottom: 0.35rem;
}

.canvas-label--stacked {
    margin-bottom: var(--space-2);
}

.canvas-muted-estimate {
    font-size: var(--text-md);
    color: var(--muted-foreground);
}

.canvas-run-row,
.canvas-progress-row {
    margin-top: var(--space-3);
}

.canvas-results-pointer {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    text-align: center;
}

.canvas-field-card--sm select,
.canvas-field-card--sm .canvas-number-input {
    width: 100%;
    font-size: var(--text-md);
    background-color: transparent;
    border: none;
    color: var(--foreground);
    outline: none;
    font-family: var(--font-neue-montreal);
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.05rem center;
    background-size: 13px 13px;
    padding-right: 1.2rem;
}

.canvas-field-card--sm .canvas-number-input {
    background-image: none;
    padding-right: 0;
    font-variant-numeric: tabular-nums;
}

#scenario-builder .canvas-field-card--sm select.canvas-select {
    min-height: var(--control-height);
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    padding: 0 1.9rem 0 0.65rem;
    background-color: var(--background);
    background-position: right 0.65rem center;
    color: var(--foreground-strong);
    font-family: var(--font-body);
    font-size: var(--text-sm);
}

#scenario-builder .canvas-field-card--sm select.canvas-select:hover {
    border-color: rgba(0, 100, 114, 0.3);
}

#scenario-builder .canvas-field-card--sm select.canvas-select:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.optimizer-actions-row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin: var(--space-3) 0 var(--space-4);
}

.optimizer-group {
    margin-bottom: var(--space-3);
}

.optimizer-group-header {
    align-items: center;
}

.optimizer-group-max {
    flex-shrink: 0;
}

.opt-groups-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: -0.35rem 0 0.8rem;
}

.opt-best-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* CTA buttons */
.canvas-cta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.canvas-save-btn {
    min-height: var(--control-height);
}

.run-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bitwise-dark-teal);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.65rem 1.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-neue-montreal);
    letter-spacing: 0.2px;
    flex-shrink: 0;
}

.run-btn:hover {
    background: #005562;
    box-shadow: 0 2px 12px rgba(0, 100, 114, 0.2);
}

.run-btn:active {
    box-shadow: none;
    background: #004a55;
}

.run-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.run-btn--sm {
    padding: 0.5rem 1.1rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

.reset-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 1.1rem;
    font-size: 0.82rem;
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    transition: all 0.2s ease;
}

.reset-btn:hover {
    color: var(--foreground);
    border-color: var(--foreground);
    background: var(--secondary);
}

/* Canvas error */
.canvas-error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 87, 72, 0.08);
    border: 1px solid rgba(245, 87, 72, 0.3);
    border-radius: 8px;
    color: var(--destructive);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ===== CONFIG SIDEBAR (results mode) ===== */
.config-sidebar {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    height: 100%;
    overflow-y: auto;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-mode-eyebrow {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted-foreground);
    font-weight: 600;
}

.sidebar-mode-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--foreground);
}

.edit-config-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.5rem 0.9rem;
    font-size: 0.78rem;
    color: var(--foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-weight: 500;
    width: 100%;
    transition: all 0.15s ease;
}

.edit-config-btn:hover {
    background: var(--secondary);
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
}

.sidebar-run-status {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid rgba(0, 100, 114, 0.16);
    border-radius: 8px;
    background: rgba(0, 100, 114, 0.045);
    color: var(--bitwise-dark-teal);
    font-size: 0.72rem;
    font-weight: 700;
}

.sidebar-run-status[hidden] {
    display: none;
}

.sidebar-run-status-dot {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 50%;
    background: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 0 rgba(0, 100, 114, 0.24);
    animation: sidebarStatusPulse 1.35s ease-out infinite;
    flex-shrink: 0;
}

@keyframes sidebarStatusPulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 100, 114, 0.24); }
    70%  { box-shadow: 0 0 0 7px rgba(0, 100, 114, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 100, 114, 0); }
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
}

.sidebar-params {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.sidebar-summary-section {
    display: grid;
    gap: 0.5rem;
}

.sidebar-section-heading {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted-foreground);
    font-weight: 700;
}

.sidebar-date-range {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 0.42rem;
}

.sidebar-date-tile,
.sidebar-value-tile {
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface-quiet);
}

.sidebar-date-tile {
    padding: 0.48rem 0.52rem;
}

.sidebar-date-tile span,
.sidebar-value-tile span {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.55px;
    line-height: 1;
    text-transform: uppercase;
}

.sidebar-date-tile strong,
.sidebar-value-tile strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--foreground-strong);
    font-size: 0.73rem;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-date-connector {
    align-self: center;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

.sidebar-value-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.62rem;
}

.sidebar-value-tile span {
    margin: 0;
}

.sidebar-value-tile strong {
    color: var(--bitwise-dark-teal);
    font-size: 0.84rem;
    text-align: right;
}

.sidebar-param {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.sidebar-param-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
    font-weight: 600;
    flex-shrink: 0;
    padding-top: 1px;
}

.sidebar-param-value {
    font-size: 0.78rem;
    color: var(--foreground);
    text-align: right;
    font-weight: 500;
    line-height: 1.4;
}

.sidebar-param--accent .sidebar-param-value {
    color: var(--bitwise-dark-teal);
    font-weight: 700;
}

.sidebar-scenario-card {
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--background);
    box-shadow: var(--shadow-hairline);
}

.sidebar-scenario-card--index {
    border-color: rgba(0, 100, 114, 0.20);
    background: rgba(0, 100, 114, 0.035);
}

.sidebar-scenario-head {
    display: grid;
    gap: 0.25rem;
    padding: 0.62rem 0.68rem 0.58rem;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-scenario-title {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 0.35rem;
    overflow: hidden;
    color: var(--foreground-strong);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-scenario-meta {
    overflow: hidden;
    color: var(--muted-foreground);
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-index-badge {
    flex-shrink: 0;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.sidebar-asset-list {
    display: grid;
}

.sidebar-asset-list--loose {
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--background);
}

.sidebar-asset-group-label {
    padding: 0.45rem 0.68rem 0.26rem;
    color: var(--muted-foreground);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.55px;
    line-height: 1;
    text-transform: uppercase;
}

.sidebar-asset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    gap: 0.65rem;
    padding: 0.4rem 0.68rem;
    border-top: 1px solid var(--border-soft);
}

.sidebar-asset-list > .sidebar-asset-row:first-child {
    border-top: 0;
}

.sidebar-asset-group-label + .sidebar-asset-row {
    border-top: 0;
}

.sidebar-asset-symbol {
    min-width: 0;
    overflow: hidden;
    color: var(--foreground-strong);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-asset-weight {
    flex-shrink: 0;
    color: var(--foreground);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    line-height: 1.15;
}

.sidebar-empty-note,
.sidebar-more-assets {
    padding: 0.5rem 0.68rem;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    font-weight: 600;
}

.sidebar-more-assets {
    border-top: 1px solid var(--border-soft);
    color: var(--bitwise-dark-teal);
}

.sidebar-scenario-name {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    padding-left: 0.2rem;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.report-export-fields {
    display: grid;
    gap: 0.4rem;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.64);
}

.report-export-heading {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--bitwise-dark-teal);
    font-weight: 700;
    margin-bottom: 0.05rem;
}

.report-export-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
    font-weight: 600;
}

.report-export-input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.76rem;
    line-height: 1.2;
    padding: 0.48rem 0.55rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-export-input::placeholder {
    color: var(--muted-foreground);
}

.report-export-input:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 3px rgba(0, 100, 114, 0.08);
}

.sidebar-action-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.5rem 0.875rem;
    font-size: 0.78rem;
    color: var(--foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-action-btn:hover {
    background: var(--secondary);
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
}

.sidebar-action-btn--primary {
    background: var(--bitwise-dark-teal);
    color: white;
    border-color: var(--bitwise-dark-teal);
}

.sidebar-action-btn--primary:hover {
    background: #005562;
    border-color: #005562;
    color: white;
}

/* ===== RESULTS PANEL ===== */
.results-panel {
    overflow-y: auto;
    height: calc(100vh - var(--nav-height));
    padding: 1.75rem 2rem;
    background: var(--page-background);
}

.results-panel h2 {
    margin: 0;
    font-family: var(--font-neue-montreal);
    color: var(--foreground-strong);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding-bottom: 0;
    border-bottom: 0;
}

#results-container,
#scenarios-results-container,
#optimizer-results-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* ===== FORM GROUPS (inside scenario cards / optimizer panel) ===== */
.form-group {
    margin-bottom: var(--space-3);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0;
}

.form-group input,
.form-group select {
    width: 100%;
    min-height: var(--control-height);
    padding: 0 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-md);
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground-strong);
    transition: all var(--transition-speed);
}

.form-group select,
.asset-row select,
.mc-select,
.ae-category-select,
.ae-scenario-picker,
.ib-select,
.rt-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 13px 13px;
    padding-right: 1.9rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.error-message {
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--destructive);
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* ===== ASSET ROW ===== */
.asset-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}

.asset-row:last-child {
    margin-bottom: 0;
}

.asset-row select {
    flex: 1;
    min-width: 0;
    min-height: var(--control-height);
    padding: 0 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground-strong);
    transition: all var(--transition-speed);
}

.asset-row select:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

/* Asset dropdown */
.asset-dropdown-container {
    flex: 1;
    min-width: 0;
    position: relative;
}

.asset-dropdown-button {
    width: 100%;
    min-height: var(--control-height);
    padding: 0 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground-strong);
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-speed);
}

.asset-dropdown-button::after {
    content: '▾';
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.35rem;
    flex-shrink: 0;
}

.asset-dropdown-button:hover {
    border-color: rgba(0, 100, 114, 0.3);
}
.asset-dropdown-button:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.asset-row--synthetic .asset-dropdown-button,
.asset-row--synthetic .asset-dropdown-button:disabled {
    cursor: default;
    background: rgba(0, 100, 114, 0.06);
    border-color: rgba(0, 100, 114, 0.18);
    color: var(--foreground);
    opacity: 1;
}

.asset-row--synthetic .asset-dropdown-button::after {
    content: '';
    margin-left: 0;
}

.asset-dropdown-menu {
    position: fixed;   /* fixed so it escapes all overflow:hidden ancestors */
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    z-index: 9999;
    max-height: 320px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    /* top / left / width set by JS when opened */
}

.asset-dropdown-menu.open { display: flex; }

.asset-search-input {
    padding: 0.5rem 0.6rem;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    font-size: 0.75rem;
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground);
    outline: none;
}

.asset-search-input:focus { border-bottom-color: var(--bitwise-dark-teal); }

.asset-options-list {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding-bottom: 0.5rem;
}

.asset-market-filters {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.55rem;
    overflow-x: auto;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.asset-market-pill {
    flex: 0 0 auto;
    padding: 0.18rem 0.48rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    color: var(--muted-foreground);
    font: 600 0.6rem var(--font-body);
    cursor: pointer;
}

.asset-market-pill:hover,
.asset-market-pill.active {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.08);
}

.asset-option-group { margin-bottom: 0; }

.asset-option-group-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.6rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
    background: var(--secondary);
    z-index: 1;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s;
}
.asset-option-group-header:hover { background: var(--muted); }
.asset-option-group-header .group-toggle {
    font-size: 0.55rem;
    transition: transform 0.15s;
    flex-shrink: 0;
    margin-left: 0.4rem;
    color: var(--muted-foreground);
}
.asset-option-group.collapsed .group-toggle { transform: rotate(-90deg); }

.asset-option-group-body { }
.asset-option-group.collapsed .asset-option-group-body { display: none; }

.asset-option-group-count {
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    background: var(--border);
    color: var(--muted-foreground);
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: auto;
    margin-right: 0.3rem;
}

.asset-option {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    color: var(--foreground);
    transition: background-color 0.1s ease;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}
.asset-option-symbol {
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.asset-option-name {
    font-size: 0.68rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.asset-option-meta {
    margin-left: auto;
    max-width: 42%;
    color: var(--bitwise-light-grey);
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.asset-option:hover { background-color: var(--muted); }

.asset-option.selected {
    background-color: rgba(69, 185, 121, 0.1);
}
.asset-option.selected .asset-option-symbol { color: var(--bitwise-green); }

.asset-option.hidden { display: none; }

.asset-row .weight-input {
    width: 3.65rem;
    min-height: var(--control-height);
    padding: 0 0.35rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground-strong);
    text-align: center;
    transition: all var(--transition-speed);
}

.asset-row .weight-input:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.asset-row .weight-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.asset-row .remove-asset-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    width: var(--control-height-sm);
    height: var(--control-height-sm);
    border-radius: var(--control-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed);
    flex-shrink: 0;
}

.asset-row .remove-asset-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.asset-row .remove-asset-btn:hover {
    background: rgba(198, 40, 40, 0.06);
    border-color: rgba(198, 40, 40, 0.14);
    color: var(--destructive);
}

.asset-row .remove-asset-btn:focus-visible {
    outline: none;
    border-color: var(--destructive);
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.10);
}

.add-asset-btn {
    background-color: transparent;
    color: var(--bitwise-dark-teal);
    border: 1px dashed var(--border-strong);
    min-height: var(--control-height);
    padding: 0 0.875rem;
    border-radius: var(--control-radius);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-body);
    transition: all var(--transition-speed);
    margin-top: var(--space-2);
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.add-asset-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.add-asset-btn:hover {
    background-color: var(--bitwise-dark-teal);
    color: white;
    border-color: var(--bitwise-dark-teal);
    border-style: solid;
}

/* ===== SCENARIO CONFIG CARDS ===== */
.scenario-config {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.scenario-config:last-child { margin-bottom: 0; }

.scenario-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background-color: var(--secondary);
    border-bottom: 1px solid var(--border);
}

.scenario-name-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-neue-montreal);
    color: var(--foreground);
    letter-spacing: 0.1px;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    transition: background-color var(--transition-speed);
}

.scenario-name-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.5);
}

.scenario-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: 0;
    min-width: 0;
}

.scenario-save-config-btn.saved {
    border-color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.08);
    color: var(--bitwise-dark-teal);
}

.scenario-save-config-btn .material-icons {
    font-size: 14px;
}

.collapse-btn,
.remove-scenario-btn {
    width: var(--control-height);
    height: var(--control-height);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed), background-color var(--transition-speed), border-color var(--transition-speed);
    border-radius: var(--control-radius);
}

.collapse-btn .material-icons,
.remove-scenario-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.collapse-btn:hover {
    color: var(--bitwise-dark-teal);
    border-color: rgba(0, 100, 114, 0.12);
    background-color: rgba(0, 100, 114, 0.05);
}

.remove-scenario-btn:hover {
    color: var(--destructive);
    border-color: rgba(198, 40, 40, 0.14);
    background-color: rgba(198, 40, 40, 0.06);
}

.collapse-btn:focus-visible,
.remove-scenario-btn:focus-visible {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.scenario-body { padding: 1rem; }

.assets-container { margin-bottom: var(--space-3); }

/* Weight total indicator */
.weight-total {
    margin-top: var(--space-4);
    font-weight: 600;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    padding: 0.45rem 0.65rem;
    background-color: var(--surface-subtle);
    border-radius: var(--control-radius);
    text-align: center;
}

.weight-total.valid {
    color: var(--bitwise-green);
    background-color: rgba(69, 185, 121, 0.1);
}

.weight-total.invalid {
    color: var(--destructive);
    background-color: rgba(245, 87, 72, 0.1);
}

/* Overlay section */
.overlay-asset-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
}

.overlay-asset-row .form-group {
    flex: 1;
    margin-bottom: var(--space-2);
}

.overlay-asset-row .remove-asset-btn {
    align-self: flex-end;
    margin-bottom: var(--space-2);
    width: var(--control-height);
    height: var(--control-height);
    flex: 0 0 var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-speed), background-color var(--transition-speed), border-color var(--transition-speed);
}

.overlay-asset-row .remove-asset-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.overlay-asset-row .remove-asset-btn:hover {
    color: var(--destructive);
    background: rgba(245, 87, 72, 0.06);
    border-color: rgba(245, 87, 72, 0.16);
}

.ss-basket-weight-input {
    width: 3.65rem;
    min-height: var(--control-height);
    padding: 0 0.35rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground-strong);
    text-align: center;
    transition: all var(--transition-speed);
}
.ss-basket-weight-input:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

/* Old .btn classes (used by modal buttons, optimizer) */
.btn {
    background-color: var(--bitwise-green);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    font-weight: 500;
    font-family: var(--font-body);
    transition: all var(--transition-speed);
    margin-top: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.btn:hover { background-color: #3a9d65; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { background-color: var(--muted); cursor: not-allowed; color: var(--muted-foreground); transform: none; }

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

.btn-secondary:hover { background-color: var(--secondary); color: var(--foreground); }

.btn-small {
    background-color: var(--bitwise-green);
    color: white;
    border: none;
    padding: 0.45rem 0.7rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-small:hover { background-color: #3a9d65; transform: translateY(-1px); }
.btn-small-secondary {
    background-color: transparent;
    color: var(--bitwise-dark-teal);
    border: 1px solid rgba(0, 100, 114, 0.28);
}
.btn-small-secondary:hover {
    background-color: rgba(0, 100, 114, 0.08);
    color: var(--bitwise-dark-teal);
}
.btn-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.results-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.32rem;
    min-height: 1.9rem;
    padding: 0.36rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.15px;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.results-action-btn:hover {
    border-color: rgba(0, 100, 114, 0.35);
    background: rgba(0, 100, 114, 0.04);
    color: var(--bitwise-dark-teal);
}

.results-action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.12);
}

.results-action-btn--primary {
    border-color: var(--bitwise-dark-teal);
    background: var(--bitwise-dark-teal);
    color: #fff;
}

.results-action-btn--primary:hover {
    border-color: #005562;
    background: #005562;
    color: #fff;
}

.results-action-btn .btn-icon {
    font-size: 0.9rem;
}

/* ===== PERFORMANCE TABLES ===== */
.performance-table-wrapper {
    overflow-x: auto;
    margin-top: 0;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.table-header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.performance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    background-color: var(--background);
}

.performance-table th {
    background-color: transparent;
    color: var(--bitwise-light-grey);
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-family: var(--font-neue-montreal);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 0.65rem;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
    position: relative;
}

.performance-table th:hover { background-color: var(--muted); }
.performance-table th:first-child { padding-left: 0.875rem; }
.performance-table th:last-child { padding-right: 0.875rem; text-align: right; }

.sort-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--bitwise-green);
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.performance-table th:hover .sort-indicator,
.sort-indicator.active { opacity: 1; }

.performance-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--bitwise-dark-grey);
    font-family: var(--font-body);
}

.performance-table td:first-child { padding-left: 0.875rem; font-weight: 500; }
.performance-table td:last-child { padding-right: 0.875rem; text-align: right; }

.performance-table tbody tr { transition: background-color 0.15s ease; }
.performance-table tbody tr:hover { background-color: var(--table-row-hover); }
.performance-table tbody tr:last-child td { border-bottom: none; }

.scenario-comparison-row { cursor: pointer; }
.scenario-comparison-row:hover { background-color: var(--table-row-hover) !important; }

.performance-value { font-variant-numeric: tabular-nums; }
.performance-value.positive { color: var(--positive-color); }
.performance-value.negative { color: var(--negative-color); }
.performance-value.null { color: var(--text-secondary); font-style: italic; }

/* ===== CHART CONTAINERS ===== */
.scenario-section {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.scenario-section:last-child { margin-bottom: 0; }

.scenario-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--bitwise-light-grey);
    margin-bottom: 0.75rem;
    font-family: var(--font-neue-montreal);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: none;
    padding-bottom: 0;
}

.scenario-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.scenario-header-actions .scenario-title { margin-bottom: 0; flex: 1; }

.chart-container {
    margin-top: 0;
    background: var(--background);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid rgba(0, 0, 0, 0.04);
    width: 100%;
    box-sizing: border-box;
    box-shadow: none;
}

.chart-container h3 {
    margin-bottom: 0.75rem;
    font-size: 0.7rem;
    font-family: var(--font-neue-montreal);
    color: var(--bitwise-light-grey);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
}

.chart-container > div { width: 100% !important; min-width: 0; }

.combined-performance-chart {
    min-height: 360px;
}

:root[data-results-theme="dark"] .performance-table-wrapper {
    border: 1px solid #2d343a;
    border-radius: 0;
    background: var(--background);
}

:root[data-results-theme="dark"] .performance-table th {
    background: #f6f8f8;
    color: var(--foreground-strong);
    border-bottom-color: #2d343a;
}

:root[data-results-theme="dark"] .performance-table td {
    border-bottom-color: #d8dee1;
}

:root[data-results-theme="dark"] .performance-table tbody tr:last-child td {
    border-bottom: none;
}

:root[data-results-theme="dark"] .chart-container {
    border: 1px solid #2d343a;
    border-radius: 0;
    padding: 1rem;
}

:root[data-results-theme="dark"] .chart-container h3 {
    color: var(--foreground-strong);
}

:root[data-results-theme="dark"] .rolling-stat,
:root[data-results-theme="dark"] .rolling-contribution-chart,
:root[data-results-theme="dark"] .mc-fan-chart-container,
:root[data-results-theme="dark"] .mc-stat-card,
:root[data-results-theme="dark"] .mc-note,
:root[data-results-theme="dark"] .rolling-control input,
:root[data-results-theme="dark"] .rolling-control select {
    border-color: #2d343a;
    background: var(--background);
}

:root[data-results-theme="dark"] .numbers-tabs,
:root[data-results-theme="dark"] .numbers-tab-panels,
:root[data-results-theme="dark"] .wdr-card,
:root[data-results-theme="dark"] .scenario-strip {
    border-color: #2d343a;
    border-radius: 0;
}

:root[data-results-theme="dark"] .numbers-tabs,
:root[data-results-theme="dark"] .numbers-section .performance-table th {
    background: #f6f8f8;
}

:root[data-results-theme="dark"] .numbers-section .performance-table-wrapper {
    border: 0;
}

:root[data-results-theme="dark"] .numbers-section .performance-table td {
    border-bottom-color: #d8dee1;
}

:root[data-results-theme="dark"] .wdr-card-header,
:root[data-results-theme="dark"] .wdr-contrib-row--head,
:root[data-results-theme="dark"] .wdr-contrib-row--total {
    border-color: #2d343a;
}

:root[data-results-theme="dark"] .scenario-strips-section .scenario-strip + .scenario-strip {
    border-top-color: var(--border-soft);
}

:root[data-results-theme="dark"] .wdr-underwater,
:root[data-results-theme="dark"] .wdr-runup,
:root[data-results-theme="dark"] #correlation-beta-content .performance-table {
    border: 1px solid #2d343a;
    border-radius: 0;
}

.corr-beta-meta {
    color: var(--muted-foreground);
    font-weight: 500;
    text-transform: none;
}

.corr-pivot-table td strong {
    display: block;
    color: var(--foreground-strong);
    font-weight: 700;
}

.corr-pivot-table td span {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted-foreground);
    font-size: 0.68rem;
}

.corr-holding-table td strong {
    display: block;
    color: var(--foreground-strong);
    font-weight: 700;
}

.corr-holding-table td span {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted-foreground);
    font-size: 0.68rem;
}

.chart-export-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-export-btn:hover {
    background-color: var(--background);
    color: var(--foreground);
    border-color: var(--bitwise-dark-teal);
}

.results-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-section-header h3 {
    font-size: 0.7rem;
    font-family: var(--font-neue-montreal);
    color: var(--bitwise-light-grey);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
}

/* Benchmark status */
.benchmark-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--secondary);
    font-size: 0.72rem;
    color: var(--muted-foreground);
}

.benchmark-status strong { color: var(--foreground); font-weight: 600; }
.benchmark-status.warning { border-color: var(--destructive); }
.benchmark-status-missing { color: var(--destructive); font-weight: 600; }
.benchmark-status-list { width: 100%; margin: 0.2rem 0 0; padding-left: 1.1rem; color: var(--foreground); }
.benchmark-status-list li { margin: 0.2rem 0; line-height: 1.35; font-size: 0.71rem; }

.benchmark-control-section {
    padding: 0.7rem 0.85rem;
    transition: padding 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.benchmark-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.benchmark-control-body {
    margin-top: 0.75rem;
}

.benchmark-control-section.collapsed {
    padding: 0.55rem 0.75rem;
}

.benchmark-control-section.collapsed .benchmark-control-body {
    display: none;
}

.benchmark-control-header h3 {
    margin: 0;
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--bitwise-light-grey);
}

.benchmark-control-status {
    margin-top: 0.25rem;
    font-size: 0.74rem;
    color: var(--muted-foreground);
}

.benchmark-toggle-btn {
    min-width: 76px;
}

.benchmark-control-actions,
.benchmark-picker-row,
.benchmark-chip-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.benchmark-preset-actions {
    margin-bottom: 0.6rem;
}

.benchmark-picker-row {
    margin-bottom: 0.75rem;
}

.benchmark-search {
    flex: 1 1 240px;
    min-width: 220px;
    max-width: 420px;
    height: 34px;
    padding: 0 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.78rem;
    outline: none;
}

.benchmark-search:focus {
    border-color: var(--bitwise-dark-teal);
}

.benchmark-chip,
.benchmark-empty-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 28px;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font-size: 0.74rem;
    font-weight: 600;
}

.benchmark-empty-chip {
    color: var(--muted-foreground);
    font-weight: 500;
}

.benchmark-chip button {
    border: none;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.benchmark-chip button:hover {
    color: var(--destructive);
}

/* ===== LOADING ===== */
.loading {
    padding: 5rem 2rem;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-direction: column;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--border);
    border-top-color: var(--bitwise-dark-teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text { text-align: center; }

.loading-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.loading-subtitle { font-size: 0.8rem; color: var(--text-secondary); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== ERROR MESSAGES ===== */
.error-container-msg {
    background-color: rgba(245, 87, 72, 0.08);
    color: var(--destructive);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 3px solid var(--destructive);
    font-size: 0.85rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.error-icon { font-size: 1.25rem; flex-shrink: 0; }
.error-content { flex: 1; }
.error-title { font-weight: 600; margin-bottom: 0.2rem; font-size: 0.875rem; }
.error-text { font-size: 0.8rem; line-height: 1.4; }
.btn-error-retry { margin-top: 0.75rem; background-color: var(--destructive); color: white; }

.coverage-preflight {
    background: #fff8ed;
    border: 1px solid #e0b76a;
    border-left: 3px solid #c9861b;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    color: var(--foreground);
}

.coverage-preflight-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.coverage-preflight-copy {
    color: var(--muted-foreground);
    font-size: 0.8rem;
    line-height: 1.4;
}

.coverage-preflight-list {
    margin: 0.75rem 0;
    padding-left: 1.1rem;
    font-size: 0.78rem;
    line-height: 1.45;
}

.coverage-preflight-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.btn-error-retry:hover { background-color: #d63031; }

/* Input validation status */
.input-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    pointer-events: none;
    opacity: 0;
}

.input-status.success { opacity: 1; }
.input-status.success::after { content: '✓'; color: var(--bitwise-green); font-size: 12px; font-weight: bold; }
.input-status.error { opacity: 1; }
.input-status.error::after { content: '✕'; color: var(--destructive); font-size: 12px; font-weight: bold; }

/* Empty state */
#empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

#empty-state h2 { color: var(--bitwise-dark-grey); margin-bottom: 0.5rem; font-size: 1rem; font-family: var(--font-neue-montreal); font-weight: 600; }
#empty-state p { font-size: 0.875rem; }

/* ===== OPTIMIZER ===== */
.optimizer-combo-estimate {
    display: none;
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin-top: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: var(--background);
    border-radius: 4px;
    border: 1px solid var(--border);
}

.progress-bar-container {
    width: 100%;
    height: 5px;
    background: var(--secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--bitwise-green);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text { font-size: 0.7rem; color: var(--muted-foreground); margin-top: 0.25rem; }

#optimizer-results-main { padding: 0; }

.opt-main-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; }
.opt-best-card { background: var(--secondary); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.opt-best-title { font-weight: 700; font-size: 0.7rem; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-neue-montreal); color: var(--bitwise-light-grey); text-transform: uppercase; letter-spacing: 0.6px; }
.opt-metric-badge { font-size: 0.7rem; font-weight: 500; padding: 0.2rem 0.5rem; border-radius: 4px; background: var(--bitwise-green); color: white; }
.opt-weights-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.opt-weight-chip { font-size: 0.8rem; padding: 0.3rem 0.6rem; border-radius: 4px; background: var(--card); border: 1px solid var(--border); }
.opt-metrics-row { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.opt-metric { display: flex; flex-direction: column; gap: 0.15rem; }
.opt-metric-label { font-size: 0.7rem; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.3px; }
.opt-metric-value { font-size: 1rem; font-weight: 600; }
.opt-top-table-wrap { margin-top: 0; overflow-x: auto; }
.opt-top-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.opt-top-table th, .opt-top-table td { padding: 0.5rem 0.75rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.opt-sortable { cursor: pointer; }
.opt-sortable:hover { color: var(--bitwise-green); }
.opt-top-table th { font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; font-size: 0.7rem; color: var(--muted-foreground); }
.opt-top-table th:first-child, .opt-top-table td:first-child { text-align: center; width: 2.5rem; }
.opt-top-table th:nth-child(2), .opt-top-table td:nth-child(2) { text-align: left; }
.opt-weights-cell { font-size: 0.75rem; }
.opt-top-table tbody tr:first-child { background: rgba(69, 185, 121, 0.08); }
.opt-row-clickable { cursor: pointer; }
.opt-use-btn {
    min-height: 1.55rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.68rem;
}
.opt-best-use-btn {
    margin-top: 0.75rem;
}
.opt-top-table tbody tr:hover { background: rgba(0,0,0,0.02); }

/* ===== METRIC TOOLTIPS ===== */
.metric-tooltip { position: relative; cursor: help; }

.metric-tooltip .tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1px solid var(--muted-foreground);
    font-size: 0.55rem;
    font-style: italic;
    font-weight: 600;
    color: var(--muted-foreground);
    margin-left: 3px;
    vertical-align: middle;
    opacity: 0.55;
    transition: opacity 0.15s;
}

.metric-tooltip:hover .tooltip-icon { opacity: 1; }

.metric-tooltip .tooltip-text {
    visibility: visible;
    opacity: 0;
    position: absolute;
    z-index: 200;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--foreground);
    color: var(--background);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    width: max-content;
    max-width: 280px;
    text-align: left;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    transition: opacity 0.15s;
    text-transform: none;
    letter-spacing: normal;
}

.metric-tooltip .tooltip-text .tooltip-formula {
    display: block;
    margin-top: 4px;
    font-size: 0.65rem;
    opacity: 0.7;
}

.metric-tooltip:hover .tooltip-text { opacity: 1; }

.numbers-section .metric-tooltip:hover .tooltip-text,
.numbers-section .metric-tooltip:focus-within .tooltip-text {
    opacity: 1;
}

/* ===== MONTE CARLO ===== */
.mc-section {
    margin-top: 1.5rem;
    width: 100%;
    min-width: 0;
}

.mc-title {
    margin: 0;
    font-family: var(--font-neue-montreal);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--bitwise-light-grey);
}

.mc-fan-chart-container {
    position: relative;
    margin-bottom: 0.85rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0;
    overflow: hidden;
}

.mc-fan-chart {
    width: 100%;
    height: 460px;
    min-height: 430px;
}

.mc-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.mc-stat-card {
    border: 1px solid var(--border);
    background: var(--background);
    border-radius: 0;
    padding: 0.78rem 0.85rem;
    min-width: 0;
    min-height: 4.85rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.22rem;
}

.mc-stat-label {
    color: var(--muted-foreground);
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mc-stat-value {
    color: var(--foreground-strong);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.mc-stat-value.positive { color: var(--bitwise-green); }
.mc-stat-value.negative { color: #e74c3c; }

.mc-note {
    font-size: 0.78rem;
    color: var(--muted-foreground);
    line-height: 1.5;
    padding: 0.75rem 0.85rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0;
    margin-top: 0;
}

.mc-note strong {
    color: var(--foreground-strong);
    font-weight: 600;
}

.mc-warning {
    font-size: 0.78rem;
    line-height: 1.45;
    color: #8a5a00;
    background: rgba(212, 169, 106, 0.12);
    border: 1px solid rgba(212, 169, 106, 0.34);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    margin: -0.35rem 0 0.9rem;
}

.mc-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

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

.mc-select {
    min-height: 2rem;
    padding: 0.36rem 1.9rem 0.36rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0;
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.mc-select:hover {
    border-color: rgba(0, 100, 114, 0.28);
    background-color: rgba(0, 100, 114, 0.03);
}

.mc-select:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.mc-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: var(--font-neue-montreal);
}

.mc-btn:hover { background: var(--secondary); border-color: var(--bitwise-dark-teal); }
.mc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mc-btn .mc-btn-icon { font-size: 0.95rem; line-height: 1; }

.mc-loading { display: flex; align-items: center; gap: 0.5rem; padding: 1rem; font-size: 0.8rem; color: var(--muted-foreground); }

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    overflow: auto;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--background);
    margin: 2% auto;
    padding: 0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { margin: 0; font-size: 1.15rem; font-family: var(--font-items); font-weight: normal; color: var(--bitwise-dark-grey); }
.modal-header h3 { margin: 0; font-size: 1.05rem; font-family: var(--font-items); font-weight: normal; color: var(--bitwise-dark-grey); }

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed);
    line-height: 1;
}

.modal-close:hover { color: var(--foreground); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }

.agent-access-modal-content {
    max-width: 760px;
}
.agent-access-subtitle {
    margin: 0.25rem 0 0;
    max-width: 600px;
    color: var(--muted-foreground);
    font-size: 0.78rem;
    line-height: 1.45;
}
.agent-access-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.agent-access-security {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(0, 100, 114, 0.22);
    border-radius: 8px;
    background: rgba(0, 100, 114, 0.045);
    color: var(--bitwise-dark-grey);
    font-size: 0.8rem;
    line-height: 1.45;
}
.agent-access-security .material-icons {
    color: var(--bitwise-dark-teal);
    font-size: 1.25rem;
}
.agent-access-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px auto;
    gap: 0.75rem;
    align-items: end;
}
.agent-access-create label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    color: var(--muted-foreground);
    font-size: 0.72rem;
    font-weight: 600;
}
.agent-access-create input,
.agent-access-create select {
    width: 100%;
    min-height: 38px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font: inherit;
    font-size: 0.8rem;
}
.agent-key-secret {
    padding: 1rem;
    border: 1px solid rgba(69, 185, 121, 0.5);
    border-radius: 8px;
    background: rgba(69, 185, 121, 0.08);
}
.agent-key-secret-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
    font-size: 0.78rem;
}
.agent-key-secret-heading > div { display: flex; flex-direction: column; gap: 0.12rem; }
.agent-key-secret-heading span { color: var(--muted-foreground); }
.agent-key-secret-value {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.agent-key-secret-value code {
    min-width: 0;
    flex: 1;
    padding: 0.7rem;
    overflow-wrap: anywhere;
    border: 1px solid rgba(69, 185, 121, 0.28);
    border-radius: 6px;
    background: var(--background);
    font-size: 0.74rem;
}
.agent-key-secret-value .btn {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
}
.agent-key-secret > p { margin: 0.65rem 0 0; color: var(--muted-foreground); font-size: 0.66rem; line-height: 1.4; }
.agent-key-secret > p code { color: var(--bitwise-dark-teal); font-size: inherit; }
.agent-access-step {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.agent-access-step-heading {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}
.agent-access-step-heading > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 1.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
}
.agent-access-step-heading h3 { margin: 0; font-size: 0.9rem; }
.agent-access-step-heading p { margin: 0.18rem 0 0; color: var(--muted-foreground); font-size: 0.7rem; line-height: 1.4; }
.agent-one-shot-prompt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 100, 114, 0.035);
}
.agent-one-shot-prompt strong { display: block; font-size: 0.75rem; }
.agent-one-shot-prompt span { display: block; margin-top: 0.18rem; color: var(--muted-foreground); font-size: 0.66rem; line-height: 1.35; }
.agent-one-shot-prompt .btn { width: auto; flex: 0 0 auto; margin: 0; }
.agent-access-list-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
}
.agent-access-list-header > div { flex: 1; min-width: 0; }
.agent-access-list-header .btn { width: auto; flex: 0 0 auto; }
.agent-access-list-header h3 { margin: 0; font-size: 0.95rem; }
.agent-access-list-header p { margin: 0.2rem 0 0; color: var(--muted-foreground); font-size: 0.72rem; }
.agent-key-list { display: flex; flex-direction: column; gap: 0.65rem; }
.agent-key-row {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
}
.agent-key-row--revoked,
.agent-key-row--expired { opacity: 0.62; }
.agent-key-row-main { flex: 1; min-width: 0; }
.agent-key-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.82rem; }
.agent-key-row-title strong { overflow-wrap: anywhere; }
.agent-key-status {
    flex: 0 0 auto;
    padding: 0.14rem 0.4rem;
    border-radius: 999px;
    background: rgba(69, 185, 121, 0.14);
    color: #247548;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
}
.agent-key-row--revoked .agent-key-status,
.agent-key-row--expired .agent-key-status { background: var(--secondary); color: var(--muted-foreground); }
.agent-key-row-main > code { display: block; overflow-wrap: anywhere; color: var(--bitwise-dark-teal); font-size: 0.72rem; }
.agent-key-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.85rem;
}
.agent-key-meta > span { display: flex; min-width: 0; flex-direction: column; gap: 0.15rem; }
.agent-key-meta small { color: var(--muted-foreground); font-size: 0.58rem; font-weight: 600; letter-spacing: 0.045em; text-transform: uppercase; }
.agent-key-meta strong,
.agent-key-meta code { overflow-wrap: anywhere; color: var(--bitwise-dark-grey); font-size: 0.66rem; font-weight: 500; line-height: 1.35; }
.agent-key-fingerprint code { color: var(--muted-foreground); }
.agent-key-row > .agent-key-revoke {
    width: auto;
    flex: 0 0 auto;
    align-self: center;
    margin: 0;
    padding: 0.48rem 0.75rem;
    border: 1px solid rgba(165, 42, 42, 0.3);
    background: transparent;
    color: #a52a2a;
}
.agent-key-row > .agent-key-revoke:hover {
    border-color: rgba(165, 42, 42, 0.5);
    background: rgba(165, 42, 42, 0.07);
    color: #8f2525;
}
.agent-key-revoke-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.4rem; max-width: 230px; color: #8f2525; font-size: 0.66rem; }
.agent-key-revoke-confirm .btn { width: auto; padding: 0.35rem 0.55rem; }
.agent-key-empty { padding: 1.5rem; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted-foreground); text-align: center; font-size: 0.78rem; }
.agent-key-empty--error { color: #a52a2a; border-color: rgba(165, 42, 42, 0.35); }
@media (max-width: 820px) {
    .agent-key-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .agent-access-create { grid-template-columns: 1fr; }
    .agent-key-secret-heading, .agent-key-secret-value, .agent-key-row { align-items: stretch; flex-direction: column; }
    .agent-key-row > .agent-key-revoke { align-self: flex-start; }
    .agent-one-shot-prompt { align-items: stretch; flex-direction: column; }
    .agent-one-shot-prompt .btn { align-self: flex-start; }
}
@media (max-width: 460px) {
    .agent-key-meta { grid-template-columns: 1fr; }
}

.saved-repair-modal-content {
    max-width: 680px;
}

.saved-repair-subtitle {
    margin: 0.2rem 0 0;
    color: var(--muted-foreground);
    font-size: 0.76rem;
}

.saved-repair-intro {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(0, 100, 114, 0.22);
    border-radius: 8px;
    background: rgba(0, 100, 114, 0.06);
    color: var(--bitwise-dark-grey);
    font-size: 0.78rem;
    line-height: 1.45;
}

.saved-repair-intro .material-icons {
    color: var(--bitwise-dark-teal);
    font-size: 1.2rem;
}

.saved-repair-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.saved-repair-item {
    display: grid;
    grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 1.2fr);
    gap: 0.45rem 1rem;
    align-items: end;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
}

.saved-repair-item-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    grid-row: 1 / span 2;
    align-self: center;
}

.saved-repair-item-copy strong {
    color: var(--bitwise-dark-grey);
    font-size: 0.9rem;
}

.saved-repair-item-copy span,
.saved-repair-item label {
    color: var(--muted-foreground);
    font-size: 0.68rem;
}

.saved-repair-select {
    width: 100%;
}

.saved-repair-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--border);
}

.saved-repair-actions .btn {
    width: auto;
    min-width: 130px;
    margin-top: 0;
}

@media (max-width: 640px) {
    .saved-repair-item { grid-template-columns: 1fr; }
    .saved-repair-item-copy { grid-row: auto; }
    .saved-repair-actions { flex-direction: column-reverse; }
    .saved-repair-actions .btn { width: 100%; }
}

/* ===== METHODOLOGY MODAL ===== */
.methodology-modal-content {
    max-width: 1040px;
}

.methodology-modal-subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.76rem;
    color: var(--muted-foreground);
    font-family: var(--font-neue-montreal);
}

.methodology-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: #fafafa;
}

.methodology-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid rgba(0, 100, 114, 0.18);
    border-radius: 8px;
    background: #ffffff;
}

.methodology-kicker {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--bitwise-dark-teal);
}

.methodology-hero h3,
.methodology-section h3 {
    margin: 0;
    color: var(--bitwise-dark-grey);
    font-family: var(--font-items);
    font-weight: normal;
}

.methodology-hero h3 {
    font-size: 1rem;
}

.methodology-hero p {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
}

.methodology-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 0.28rem 0.65rem;
    background: rgba(69, 185, 121, 0.12);
    color: var(--bitwise-dark-teal);
    border: 1px solid rgba(69, 185, 121, 0.24);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.methodology-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.methodology-section h3 {
    font-size: 0.95rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.methodology-card-grid,
.methodology-glossary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.75rem;
}

.methodology-card-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.methodology-card,
.methodology-glossary article {
    min-width: 0;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.methodology-card h4,
.methodology-glossary h4 {
    margin: 0 0 0.45rem;
    color: var(--foreground);
    font-size: 0.78rem;
    font-weight: 700;
    font-family: var(--font-neue-montreal);
}

.methodology-card p,
.methodology-glossary p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.55;
}

.methodology-card code,
.methodology-glossary code {
    display: block;
    margin-top: 0.65rem;
    padding: 0.5rem 0.55rem;
    border-radius: 6px;
    background: #f3f5f6;
    color: var(--bitwise-dark-teal);
    font-size: 0.68rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .methodology-hero {
        flex-direction: column;
    }
    .methodology-card-grid,
    .methodology-glossary,
    .methodology-card-grid--compact {
        grid-template-columns: 1fr;
    }
}

/* ===== REBALANCING MODAL ===== */
.scenario-report-section { margin-bottom: 2rem; overflow-x: auto; }
.scenario-report-section:last-child { margin-bottom: 0; }
.scenario-report-section h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--bitwise-dark-teal);
    text-transform: none;
    letter-spacing: 0.2px;
    border-bottom: 2px solid var(--bitwise-light-teal);
    padding-bottom: 0.4rem;
    font-family: var(--font-items);
    font-weight: normal;
}

.rebalancing-deferred-note {
    margin: -0.35rem 0 0.85rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #8ec7c1;
    background: #eef8f7;
    color: #285b5a;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.45;
}
.rebalancing-deferred-note strong {
    color: #123f3f;
}

.rebalancing-log-table { width: 100%; min-width: 1100px; border-collapse: collapse; font-size: 0.8rem; }

.rebalancing-log-table th {
    background-color: var(--table-header-bg);
    color: var(--foreground);
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.68rem;
    white-space: nowrap;
}

.rebalancing-log-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    vertical-align: top;
}

.rebalancing-log-table tbody tr:hover { background-color: var(--table-row-hover); }
.rebalancing-log-table tbody tr:last-child td { border-bottom: none; }

.rebalance-type {
    display: inline-block;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.rebalance-type.initial { background-color: rgba(69, 185, 121, 0.1); color: var(--bitwise-green); }
.rebalance-type.rebalance { background-color: rgba(0, 100, 114, 0.1); color: var(--bitwise-dark-teal); }

/* Benchmarks table clickable rows */
#benchmarks-table tbody tr { cursor: pointer; }
#benchmarks-table tbody tr:hover { background-color: rgba(69, 185, 121, 0.08) !important; }

/* ===== LOGIN ===== */
.login-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-modal {
    background: var(--card);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
}

.login-modal h2 { margin: 0 0 1.5rem; font-size: 1.5rem; font-family: var(--font-items); font-weight: normal; color: var(--bitwise-dark-grey); }
.login-error { color: var(--destructive); font-size: 0.8rem; margin-bottom: 1rem; }

.login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.app-blurred { filter: blur(4px); pointer-events: none; user-select: none; }

/* ===== INDEX EVOLUTION TRACKER ===== */
.rt-root {
    font-size: 0.82rem;
    color: var(--foreground);
}

.rt-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.rt-subtitle {
    font-size: 0.78rem;
    color: var(--muted-foreground);
    margin-top: 0.35rem;
    max-width: 62ch;
    line-height: 1.45;
}

.rt-jumpto {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
}

.rt-jumpto label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted-foreground);
    font-weight: 600;
}

.rt-jumpto select {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background, #fff);
    color: var(--foreground);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

/* --- Stats row --- */
.rt-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.rt-stat {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
}

.rt-stat-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.rt-stat-val {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-items);
    color: var(--bitwise-dark-teal);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.rt-stat-val.rt-stat-add { color: #1a7a4a; }
.rt-stat-val.rt-stat-rm  { color: #b91c1c; }

.rt-stat-sub {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin-top: 0.2rem;
}

/* --- Timeline row --- */
.rt-timeline-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.rt-timeline {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.rt-timeline::-webkit-scrollbar { height: 8px; }
.rt-timeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.rt-card {
    flex: 0 0 auto;
    width: 168px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background, #fff);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    scroll-snap-align: start;
    overflow: hidden;
}

.rt-card:hover {
    border-color: var(--bitwise-light-teal);
}

.rt-card-changed {
    background: rgba(69, 185, 121, 0.03);
}

.rt-card-active {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 1px 0 0 var(--bitwise-dark-teal) inset, 0 0 0 2px rgba(0,100,114,0.12);
    transform: translateY(-1px);
}

.rt-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--secondary);
}

.rt-card-date {
    font-weight: 700;
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    color: var(--foreground);
}

.rt-card-badge {
    font-size: 0.6rem;
    background: rgba(245, 158, 11, 0.18);
    color: #a45c00;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.rt-card-mix {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 5px 10px 0;
    font-size: 0.7rem;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.rt-mix-eq { color: var(--bitwise-dark-teal); font-weight: 600; }
.rt-mix-cr { color: #a45c00; font-weight: 600; background: rgba(245, 158, 11, 0.14); padding: 0 5px; border-radius: 3px; }
.rt-mix-total { margin-left: auto; color: var(--muted-foreground); }

.rt-card-body {
    padding: 6px 10px 10px;
    min-height: 72px;
    font-size: 0.72rem;
}

.rt-card-section { margin-top: 4px; }

.rt-card-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.rt-label-add { color: #1a7a4a; }
.rt-label-rm  { color: #b91c1c; }

.rt-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.rt-card-nochange {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted-foreground);
    font-size: 0.7rem;
    font-style: italic;
    padding-top: 1rem;
}

/* --- Chips --- */
.rt-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.2px;
    line-height: 1.5;
}

.rt-chip-add { background: rgba(69, 185, 121, 0.15); color: #1a7a4a; }
.rt-chip-rm  { background: rgba(220, 53, 69, 0.12);  color: #b91c1c; text-decoration: line-through; }
.rt-chip.rt-type-crypto { outline: 1px solid rgba(245, 158, 11, 0.45); }

.rt-chip-more {
    display: inline-block;
    font-size: 0.66rem;
    color: var(--muted-foreground);
    padding: 1px 4px;
    font-weight: 600;
}

/* --- Detail panel --- */
.rt-detail {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background, #fff);
    padding: 1rem 1.1rem;
}

.rt-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.9rem;
}

.rt-detail-title {
    font-family: var(--font-items);
    font-size: 1rem;
    font-weight: 600;
    color: var(--bitwise-dark-teal);
    font-variant-numeric: tabular-nums;
}

.rt-detail-sub {
    font-size: 0.74rem;
    color: var(--muted-foreground);
    margin-top: 0.2rem;
}

.rt-detail-legend {
    display: flex;
    gap: 0.85rem;
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.rt-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.rt-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.rt-detail-section {
    margin-bottom: 1rem;
}

.rt-detail-section-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted-foreground);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.rt-holdings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
    gap: 0.4rem;
}

.rt-hold {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.35rem;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--secondary);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.rt-hold-rank {
    font-size: 0.62rem;
    color: var(--muted-foreground);
    font-weight: 600;
}

.rt-hold-sym {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    color: var(--foreground);
}

.rt-hold-wt {
    color: var(--muted-foreground);
    font-size: 0.68rem;
}

/* Asset-type color theming — applies to both holding cards AND chips/swatches */
.rt-type-equity,
.rt-swatch.rt-type-equity { background: rgba(0, 100, 114, 0.08); }
.rt-type-equity .rt-hold-sym { color: var(--bitwise-dark-teal); }
.rt-swatch.rt-type-equity { background: var(--bitwise-dark-teal); opacity: 0.5; }

.rt-type-crypto,
.rt-swatch.rt-type-crypto { background: rgba(245, 158, 11, 0.14); }
.rt-type-crypto .rt-hold-sym { color: #a45c00; }
.rt-type-crypto.rt-hold { border-color: rgba(245, 158, 11, 0.35); }
.rt-swatch.rt-type-crypto { background: #f59e0b; opacity: 0.7; }

.rt-hold-new {
    border-color: var(--bitwise-green) !important;
    box-shadow: 0 0 0 1px var(--bitwise-green) inset;
}
.rt-swatch.rt-hold-new { background: var(--bitwise-green); }

.rt-detail-changes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
}

.rt-changes-col { font-size: 0.75rem; }

.rt-changes-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.rt-changes-col > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.recon-th-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 3px;
}

.recon-th-entry { background: rgba(69,185,121,0.15); color: #1a7a4a; }
.recon-th-exit  { background: rgba(220,53,69,0.12);  color: #b91c1c; }

/* ===== LEVERAGE-STYLE GRADIENT ACCENTS ===== */

/* Gradient accent bar — use on section dividers or KPI strips */
.gradient-accent-bar {
    height: 4px;
    border-radius: 999px;
    background: var(--gradient-bar);
    margin: 0.75rem 0;
}

/* Scenario section divider — subtle top border */
.scenario-section {
    position: relative;
}

.scenario-section::before {
    content: '';
    display: block;
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin-bottom: 1.25rem;
}

.scenario-section:first-child::before { display: none; }

/* Refined card hover for chart containers */
.chart-container:hover {
    border-color: rgba(0, 0, 0, 0.10);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Refined optimizer best card */
.opt-best-card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Monte Carlo stat cards — subtle scan affordance */
.mc-stat-card:hover {
    background: #fbfcfb;
}

/* Market context pill style (inspired by Leverage Dashboard header pills) */
.benchmark-status {
    border: 1px solid rgba(98, 160, 173, 0.35);
    background: rgba(98, 160, 173, 0.06);
    border-radius: 8px;
}

.benchmark-status strong {
    color: var(--bitwise-dark-teal);
}

/* Scenario name inputs */
.scenario-name-input {
    font-family: var(--font-neue-montreal) !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    color: var(--bitwise-dark-grey) !important;
}

/* Sidebar mode name — Items font */
.sidebar-mode-name {
    font-family: var(--font-items);
    font-weight: normal;
    color: var(--bitwise-dark-grey);
}

/* Canvas labels — refined */
.canvas-label {
    color: var(--bitwise-light-grey);
}

/* Progress bar gradient */
.progress-bar-fill {
    background: linear-gradient(to right, var(--bitwise-dark-teal), var(--bitwise-green));
}

/* Loading spinner — teal instead of green */
.loading-spinner {
    border-top-color: var(--bitwise-dark-teal);
}

/* ===== ASSET EXPLORER ===== */

/* Explorer mode — hide normal config/results, show explorer */
.app--explorer .config-panel { display: none; }
.app--explorer .results-panel { display: none; }
.app--explorer .ae-layout { display: grid; }
.app--explorer .app-body { grid-template-columns: 1fr; overflow: hidden; }

.ae-layout {
    display: none;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 1fr auto;
    height: calc(100vh - var(--nav-height));
    overflow: hidden;
}

/* ── Left: Table Panel ── */
.ae-table-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--page-background);
    position: relative;
}

/* Filter Bar */
.ae-filters {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.25rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Stale row in the AE table: muted text + subtle warning tint */
.ae-row-stale td {
    color: var(--muted-foreground);
}
.ae-row-stale .ae-symbol {
    color: var(--muted-foreground);
    text-decoration: line-through;
    text-decoration-color: rgba(192, 57, 43, 0.45);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

/* Stale badge inline with the symbol */
.ae-stale-badge {
    display: inline-block;
    margin-left: 0.45rem;
    padding: 0.08rem 0.4rem;
    border-radius: 3px;
    background: rgba(192, 57, 43, 0.08);
    color: #a84238;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    vertical-align: middle;
    white-space: nowrap;
}

/* Stale entry inside the asset picker dropdowns */
.asset-option--stale .asset-option-symbol,
.asset-option--stale .asset-option-name { color: var(--muted-foreground); }
.asset-option-stale {
    margin-left: auto;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    background: rgba(192, 57, 43, 0.1);
    color: #a84238;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.ae-filter-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.ae-filter-btn {
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border: none;
    background: var(--background);
    color: var(--bitwise-light-grey);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.ae-filter-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.ae-filter-btn:hover {
    color: var(--bitwise-dark-grey);
    background: var(--secondary);
}

.ae-filter-btn.active {
    color: var(--background);
    background: var(--bitwise-dark-teal);
}

.ae-search {
    flex: 1;
    min-width: 160px;
    max-width: 300px;
    padding: 0.38rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: var(--font-neue-montreal);
    background: var(--background);
    color: var(--foreground);
    outline: none;
    transition: border-color 0.15s;
}

.ae-search:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.ae-search::placeholder { color: var(--bitwise-light-grey); }

.ae-category-select {
    min-width: 150px;
    max-width: 210px;
    padding: 0.38rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.72rem;
    font-family: var(--font-neue-montreal);
    background: var(--background);
    color: var(--foreground);
    outline: none;
}

.ae-category-select:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.ae-market-select {
    min-width: 120px;
    max-width: 155px;
}

.ae-market-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.32rem;
    padding: 0.08rem 0.34rem;
    border: 1px solid rgba(0, 100, 114, 0.24);
    border-radius: 999px;
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.06);
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Smart Select Buttons */
/* ── Top N secondary filter row ── */
.ae-topn-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
}

.ae-topn-label {
    font-family: var(--font-neue-montreal);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--bitwise-light-grey);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-right: 0.15rem;
}

.ae-topn-btn {
    font-family: var(--font-neue-montreal);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.28rem 0.55rem;
    border: 1px solid rgba(98, 160, 173, 0.25);
    border-radius: 999px;
    background: transparent;
    color: var(--bitwise-dark-teal);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.ae-topn-btn:hover {
    background: rgba(98, 160, 173, 0.1);
    border-color: var(--bitwise-dark-teal);
}

.ae-topn-btn.active {
    background: var(--bitwise-dark-teal);
    color: #fff;
    border-color: var(--bitwise-dark-teal);
}

.ae-topn-custom {
    margin-left: 0.15rem;
}

.ae-topn-input {
    font-family: var(--font-neue-montreal);
    font-size: 0.65rem;
    font-weight: 600;
    width: 3.2rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid rgba(98, 160, 173, 0.25);
    border-radius: 999px;
    background: transparent;
    color: var(--bitwise-dark-teal);
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.ae-topn-input:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(98, 160, 173, 0.15);
}

.ae-topn-input::placeholder {
    color: var(--bitwise-light-grey);
}

/* Hide spinner for number input */
.ae-topn-input::-webkit-outer-spin-button,
.ae-topn-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ae-topn-input[type=number] { -moz-appearance: textfield; }

.ae-clear-btn {
    font-family: var(--font-neue-montreal);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(0,0,0,0.03);
    color: var(--bitwise-light-grey);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 0.35rem;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.ae-clear-btn:hover {
    background: rgba(0,0,0,0.06);
    border-color: var(--bitwise-light-grey);
    color: var(--bitwise-dark-grey);
}

.ae-count {
    font-size: 0.7rem;
    color: var(--bitwise-light-grey);
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ae-refresh-btn {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 0.55rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--surface-inset);
    color: var(--bitwise-dark-teal);
    font-family: var(--font-neue-montreal);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ae-refresh-btn .material-icons {
    font-size: 14px;
}

.ae-refresh-btn:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--bitwise-dark-teal);
}

.ae-refresh-btn:disabled {
    cursor: wait;
    opacity: 0.65;
}

.ae-refresh-btn.is-loading .material-icons {
    animation: ae-refresh-spin 0.9s linear infinite;
}

.ae-refresh-status {
    min-width: 5.8rem;
    color: var(--bitwise-light-grey);
    font-size: 0.62rem;
    white-space: nowrap;
}

.ae-refresh-status--loading { color: var(--bitwise-dark-teal); }
.ae-refresh-status--success { color: #347c58; }
.ae-refresh-status--error { color: #a84238; }

@keyframes ae-refresh-spin {
    to { transform: rotate(360deg); }
}

.ae-view-switch {
    display: inline-flex;
    align-items: stretch;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--surface-inset);
}

.ae-view-btn {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 0.55rem;
    border: 0;
    border-right: 1px solid var(--border-strong);
    background: transparent;
    color: var(--bitwise-light-grey);
    font-family: var(--font-neue-montreal);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
}

.ae-view-btn:last-child {
    border-right: 0;
}

.ae-view-btn .material-icons {
    font-size: 14px;
}

.ae-view-btn:hover {
    color: var(--foreground-strong);
    background: var(--background);
}

.ae-view-btn.active {
    background: var(--bitwise-dark-teal);
    color: var(--background);
}

.ae-view-btn:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--bitwise-light-teal);
    outline-offset: -2px;
}

/* Add to Scenario action */
.ae-add-to-scenario-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.ae-add-to-scenario-btn {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border: none;
    border-radius: 6px;
    background: var(--bitwise-dark-teal);
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.ae-add-to-scenario-btn:hover:not(:disabled) {
    background: #005560;
}
.ae-add-to-scenario-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ae-scenario-picker {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    outline: none;
    max-width: 130px;
}
.ae-scenario-picker:focus {
    border-color: var(--bitwise-dark-teal);
}

/* Table */
.ae-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

/* Asset map */
.ae-map-wrap {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--background);
}

.ae-map-wrap[hidden] {
    display: none;
}

.ae-map-toolbar {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.45rem 0.8rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-quiet);
    flex: 0 0 auto;
}

.ae-map-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--bitwise-light-grey);
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
}

.ae-map-control select {
    min-height: 1.8rem;
    max-width: 190px;
    padding: 0 1.7rem 0 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background-color: var(--background);
    background-image: var(--select-chevron);
    background-position: right 0.35rem center;
    background-repeat: no-repeat;
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: 0.66rem;
    appearance: none;
}

.ae-map-control select:focus-visible {
    border-color: var(--bitwise-dark-teal);
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

.ae-map-count {
    color: var(--bitwise-dark-grey);
    font-size: 0.65rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ae-map-link-key {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    margin-left: auto;
    color: var(--bitwise-light-grey);
    font-size: 0.61rem;
    white-space: nowrap;
}

.ae-map-link-key-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ae-map-link-key-item > i {
    width: 1.35rem;
    height: 0;
    border-top: 1px solid #7c858a;
}

.ae-map-link-key-item--company > i {
    border-top-style: dashed;
}

.ae-map-reset {
    width: var(--control-height);
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--bitwise-dark-grey);
    cursor: pointer;
}

.ae-map-reset .material-icons {
    font-size: 16px;
}

.ae-map-reset:hover,
.ae-map-reset:focus-visible {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    outline: none;
}

.ae-map-canvas {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 300px;
    overflow: hidden;
    background: #f7f9f8;
    isolation: isolate;
}

.ae-map-svg {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}

.ae-map-svg:active {
    cursor: grabbing;
}

.ae-map-link {
    stroke: #788488;
    stroke-width: 1;
    stroke-opacity: 0.42;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.ae-map-link--company {
    stroke-dasharray: 3 3;
    stroke-opacity: 0.3;
}

.ae-map-cluster-label {
    fill: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    paint-order: stroke;
    stroke: #f7f9f8;
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
}

.ae-map-node {
    cursor: pointer;
    outline: none;
}

.ae-map-node-halo {
    fill: rgba(255, 255, 255, 0.92);
    stroke: transparent;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
    transition: fill 0.15s, stroke 0.15s;
}

.ae-map-node-dot {
    stroke: rgba(255, 255, 255, 0.94);
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
    transition: stroke-width 0.15s, filter 0.15s;
}

.ae-map-node:hover .ae-map-node-halo,
.ae-map-node:focus-visible .ae-map-node-halo {
    fill: rgba(98, 160, 173, 0.13);
    stroke: var(--bitwise-light-teal);
}

.ae-map-node.is-in-scenario .ae-map-node-halo {
    stroke: var(--bitwise-dark-teal);
    stroke-dasharray: 2.5 2;
}

.ae-map-node.is-selected .ae-map-node-halo {
    fill: rgba(69, 185, 121, 0.18);
    stroke: var(--bitwise-dark-teal);
    stroke-dasharray: none;
    stroke-width: 2.5px;
}

.ae-map-node.is-selected .ae-map-node-dot {
    stroke: var(--background);
    stroke-width: 2.5px;
    filter: drop-shadow(0 1px 2px rgba(0, 100, 114, 0.22));
}

.ae-map-node.is-inspecting .ae-map-node-halo {
    stroke: var(--foreground-strong);
    stroke-width: 3px;
}

.ae-map-node-symbol {
    fill: #ffffff;
    font-family: var(--font-neue-montreal);
    font-size: 6.5px;
    font-weight: 700;
    letter-spacing: 0;
    pointer-events: none;
    user-select: none;
}

.ae-map-tooltip {
    position: absolute;
    z-index: 5;
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    padding: 0.48rem 0.58rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 5px 16px rgba(27, 37, 42, 0.12);
    color: var(--foreground-strong);
    pointer-events: none;
}

.ae-map-tooltip[hidden] {
    display: none;
}

.ae-map-tooltip strong {
    font-size: 0.71rem;
}

.ae-map-tooltip span {
    overflow: hidden;
    color: var(--bitwise-dark-grey);
    font-size: 0.64rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ae-map-tooltip small {
    color: var(--bitwise-light-grey);
    font-size: 0.59rem;
}

.ae-map-empty {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    background: #f7f9f8;
    color: var(--bitwise-light-grey);
    font-size: 0.82rem;
}

.ae-map-empty[hidden] {
    display: none;
}

.ae-map-legend {
    position: absolute;
    right: 0.6rem;
    bottom: 0.55rem;
    left: 0.6rem;
    z-index: 2;
    min-height: 1.7rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(217, 223, 221, 0.92);
    border-radius: var(--control-radius);
    background: rgba(255, 255, 255, 0.92);
    color: var(--bitwise-dark-grey);
    scrollbar-width: thin;
}

.ae-map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    font-size: 0.57rem;
    white-space: nowrap;
}

.ae-map-legend-item i {
    width: 0.5rem;
    height: 0.5rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--ae-group-color);
}

.ae-map-legend-more {
    flex: 0 0 auto;
    color: var(--bitwise-light-grey);
    font-size: 0.57rem;
    white-space: nowrap;
}

.ae-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    table-layout: auto;
}

.ae-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.ae-table th {
    background: var(--background);
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--bitwise-light-grey);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    text-align: left;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-neue-montreal);
    white-space: nowrap;
}

.ae-table th:hover { color: var(--bitwise-dark-teal); }
.ae-table th.ae-th-select { width: 36px; text-align: center; cursor: default; }
.ae-table th.ae-th-symbol { width: 90px; white-space: nowrap; }
.ae-table th.ae-th-name   { width: 28%; min-width: 180px; }
.ae-table th.ae-th-sector { width: 120px; white-space: nowrap; }
.ae-table th.ae-th-group  { width: 150px; white-space: nowrap; }
.ae-table th.ae-th-labels { width: 180px; min-width: 150px; cursor: default; }
.ae-table th.ae-th-type   { width: 96px; white-space: nowrap; }
.ae-table th.ae-th-mcap   { width: 110px; text-align: right; white-space: nowrap; }
.ae-table th.ae-th-details { width: 38px; padding-left: 0.25rem; padding-right: 0.25rem; cursor: default; }
.ae-table th.ae-th-drag   { width: 28px; }
.ae-table th.ae-th-labels:hover,
.ae-table th.ae-th-details:hover { color: var(--bitwise-light-grey); }

.ae-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--bitwise-dark-grey);
    font-family: var(--font-neue-montreal);
    vertical-align: middle;
}

.ae-table tbody tr {
    transition: background 0.1s;
    cursor: grab;
}

.ae-table tbody tr:hover {
    background: rgba(98, 160, 173, 0.04);
}

.ae-table tbody tr:focus-visible {
    outline: 2px solid rgba(0, 100, 114, 0.36);
    outline-offset: -2px;
}

.ae-table tbody tr.ae-selected {
    background: rgba(0, 100, 114, 0.06);
}

.ae-table tbody tr.ae-inspecting {
    box-shadow: inset 3px 0 0 var(--bitwise-dark-teal);
    background: rgba(98, 160, 173, 0.08);
}

.ae-table tbody tr.ae-selected .ae-check {
    background: var(--bitwise-dark-teal);
    border-color: var(--bitwise-dark-teal);
    color: white;
}

.ae-table tbody tr.ae-dragging { opacity: 0.4; }

/* Check circle */
.ae-check {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.6rem;
    color: transparent;
    background: var(--background);
    padding: 0;
    line-height: 1;
    font-family: var(--font-neue-montreal);
}

.ae-check:hover {
    border-color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.04);
}

.ae-symbol {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--bitwise-dark-grey);
}

.ae-name-text {
    color: var(--bitwise-light-grey);
    font-size: 0.73rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 280px;
}

.ae-sector-text,
.ae-group-text {
    color: var(--bitwise-dark-grey);
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 150px;
}

.ae-group-text {
    color: var(--bitwise-light-grey);
}

.ae-cell-select,
.ae-cell-details,
.ae-cell-drag {
    text-align: center;
}

.ae-cell-labels {
    max-width: 190px;
}

.ae-row-labels {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    max-width: 190px;
    overflow: hidden;
}

.ae-label-chip {
    display: inline-block;
    min-width: 0;
    max-width: 82px;
    overflow: hidden;
    padding: 0.13rem 0.38rem;
    border: 1px solid rgba(0, 100, 114, 0.15);
    border-radius: 4px;
    background: #eef4f2;
    color: #3c6568;
    font-size: 0.59rem;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.ae-row-labels .ae-label-chip:nth-child(2) {
    border-color: rgba(74, 96, 128, 0.14);
    background: #f1f3f6;
    color: #59687a;
}

.ae-label-overflow {
    flex: 0 0 auto;
    color: var(--bitwise-light-grey);
    font-size: 0.6rem;
    font-variant-numeric: tabular-nums;
}

.ae-labels-empty {
    color: var(--muted-foreground);
    font-size: 0.64rem;
    font-style: italic;
}

.ae-type-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    line-height: 1.3;
}

.ae-type-crypto   { background: rgba(245,166,35,0.10); color: #c68a1a; border: 1px solid rgba(245,166,35,0.25); }
.ae-type-equity   { background: rgba(0,100,114,0.08);  color: var(--bitwise-dark-teal); border: 1px solid rgba(0,100,114,0.20); }
.ae-type-index    { background: rgba(69,185,121,0.10); color: #2d8659; border: 1px solid rgba(69,185,121,0.25); }
.ae-type-currency { background: rgba(108,107,113,0.10); color: var(--bitwise-dark-grey); border: 1px solid rgba(108,107,113,0.20); }

.ae-mcap {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.73rem;
    color: var(--bitwise-dark-grey);
}

.ae-info-btn {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--bitwise-light-grey);
    cursor: pointer;
    padding: 0;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.ae-info-btn .material-icons {
    font-size: 16px;
    line-height: 1;
}

.ae-info-btn:hover,
.ae-info-btn:focus-visible {
    border-color: rgba(0, 100, 114, 0.16);
    background: rgba(0, 100, 114, 0.06);
    color: var(--bitwise-dark-teal);
    outline: none;
}

.ae-drag-handle {
    color: var(--bitwise-light-grey);
    font-size: 0.8rem;
    cursor: grab;
    opacity: 0.25;
    transition: opacity 0.15s;
    text-align: center;
}

.ae-table tbody tr:hover .ae-drag-handle { opacity: 0.7; }

.ae-table-empty {
    padding: 3rem;
    text-align: center;
    color: var(--bitwise-light-grey);
    font-size: 0.85rem;
}

/* Asset intelligence detail panel. It is scoped to the table panel so the
   Selection Summary remains independently usable in the grid row below. */
.ae-asset-detail {
    position: absolute;
    z-index: 12;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(430px, 100%);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-strong);
    background: var(--background);
    box-shadow: -14px 0 32px rgba(27, 37, 42, 0.12);
}

.ae-asset-detail[hidden] {
    display: none;
}

.ae-asset-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-quiet);
    flex: 0 0 auto;
}

.ae-asset-detail-heading {
    min-width: 0;
}

.ae-asset-detail-kicker {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--bitwise-dark-teal);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.ae-asset-detail-title {
    margin: 0;
    color: var(--foreground-strong);
    font-family: var(--font-items);
    font-size: 1.15rem;
    line-height: 1.2;
}

.ae-asset-detail-subtitle {
    margin: 0.18rem 0 0;
    color: var(--bitwise-light-grey);
    font-size: 0.72rem;
    line-height: 1.35;
}

.ae-asset-detail-close {
    width: var(--control-height);
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--bitwise-light-grey);
    cursor: pointer;
}

.ae-asset-detail-close .material-icons {
    font-size: 18px;
}

.ae-asset-detail-close:hover,
.ae-asset-detail-close:focus-visible {
    border-color: rgba(0, 100, 114, 0.18);
    background: rgba(0, 100, 114, 0.06);
    color: var(--bitwise-dark-teal);
    outline: none;
}

.ae-asset-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ae-detail-selection-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-inset);
}

.ae-detail-selection-action > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.ae-detail-selection-action strong {
    color: var(--foreground-strong);
    font-size: 0.69rem;
}

.ae-detail-selection-action > div > span {
    color: var(--bitwise-light-grey);
    font-size: 0.61rem;
    line-height: 1.35;
}

.ae-detail-select-btn {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    padding: 0 0.6rem;
    border: 1px solid var(--bitwise-dark-teal);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--bitwise-dark-teal);
    font-family: var(--font-neue-montreal);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
}

.ae-detail-select-btn .material-icons {
    font-size: 15px;
}

.ae-detail-select-btn:hover,
.ae-detail-select-btn:focus-visible,
.ae-detail-select-btn.is-selected {
    background: var(--bitwise-dark-teal);
    color: var(--background);
    outline: none;
}

.ae-detail-section {
    margin: 0;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
}

.ae-detail-section:last-child {
    border-bottom: 0;
}

.ae-detail-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.ae-detail-section-title {
    margin: 0 0 0.55rem;
    color: var(--foreground-strong);
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.ae-detail-section-heading .ae-detail-section-title {
    margin-bottom: 0;
}

.ae-detail-count {
    min-width: 1.25rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: var(--surface-inset);
    color: var(--bitwise-light-grey);
    font-size: 0.59rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ae-detail-facts {
    margin: 0;
}

.ae-detail-fact {
    display: grid;
    grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.035);
}

.ae-detail-fact:last-child {
    border-bottom: 0;
}

.ae-detail-fact dt {
    color: var(--bitwise-light-grey);
    font-size: 0.65rem;
}

.ae-detail-fact dd {
    min-width: 0;
    margin: 0;
    color: var(--bitwise-dark-grey);
    font-size: 0.69rem;
    overflow-wrap: anywhere;
}

.ae-detail-label-groups,
.ae-detail-relationships {
    margin-top: 0.55rem;
}

.ae-detail-label-group + .ae-detail-label-group {
    margin-top: 0.8rem;
}

.ae-detail-label-group h4 {
    margin: 0 0 0.25rem;
    color: var(--bitwise-light-grey);
    font-family: var(--font-neue-montreal);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

.ae-detail-label-item,
.ae-detail-relationship {
    padding: 0.42rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.045);
}

.ae-detail-label-item:last-child,
.ae-detail-relationship:last-child {
    border-bottom: 0;
}

.ae-detail-label-main {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.ae-label-chip--detail {
    max-width: 230px;
    font-size: 0.63rem;
}

.ae-detail-label-key {
    min-width: 0;
    overflow: hidden;
    color: var(--bitwise-light-grey);
    font-size: 0.61rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ae-detail-label-meta,
.ae-detail-relationship-meta {
    margin-top: 0.22rem;
    color: var(--muted-foreground);
    font-size: 0.59rem;
    line-height: 1.35;
}

.ae-detail-relationship-main {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
}

.ae-detail-relationship-type {
    flex: 0 0 auto;
    color: var(--bitwise-dark-teal);
    font-size: 0.62rem;
    font-weight: 700;
}

.ae-detail-relationship-target {
    min-width: 0;
    color: var(--foreground-strong);
    font-size: 0.69rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ae-detail-relationship p {
    margin: 0.2rem 0 0;
    color: var(--bitwise-dark-grey);
    font-size: 0.64rem;
    line-height: 1.4;
}

.ae-detail-empty {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 0.67rem;
    line-height: 1.4;
}

/* ── Right: Scenario Buckets Panel ── */
.ae-buckets-panel {
    display: flex;
    flex-direction: column;
    background: var(--background);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    grid-row: 1 / 3;
}

.ae-buckets-header {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ae-buckets-title {
    font-family: var(--font-items);
    font-size: 0.92rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
}

.ae-add-scenario-btn {
    font-family: var(--font-neue-montreal);
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1;
    padding: 0 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--control-radius);
    background: var(--background);
    color: var(--bitwise-dark-teal);
    cursor: pointer;
    transition: all 0.15s;
}

.ae-add-scenario-btn .material-icons {
    font-size: 14px;
    line-height: 1;
}

.ae-add-scenario-btn:hover {
    background: var(--secondary);
    border-color: var(--bitwise-dark-teal);
}

.ae-buckets-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Scenario Bucket */
.ae-bucket {
    border: 1px dashed var(--border-strong);
    border-radius: var(--panel-radius);
    padding: 0;
    transition: all 0.2s;
    background: var(--background);
    overflow: hidden;
}

.ae-bucket.ae-bucket-active {
    border-color: var(--bitwise-dark-teal);
    border-style: solid;
}

.ae-bucket.ae-drag-over {
    border-color: var(--bitwise-dark-teal);
    background: rgba(69, 185, 121, 0.04);
    box-shadow: 0 0 0 3px rgba(69, 185, 121, 0.08);
}

.ae-bucket-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0.65rem;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-soft);
}

.ae-bucket-name {
    font-family: var(--font-items);
    font-size: 0.8rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    min-width: 0;
    flex: 1;
    cursor: text;
}

.ae-bucket-count {
    font-size: 0.6rem;
    font-weight: 600;
    background: var(--bitwise-dark-teal);
    color: white;
    padding: 1px 5px;
    border-radius: 999px;
    margin-left: 0.4rem;
    flex-shrink: 0;
}

.ae-bucket-count.ae-empty {
    background: var(--border);
    color: var(--bitwise-light-grey);
}

.ae-bucket-remove-btn {
    width: var(--control-height);
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    color: var(--bitwise-light-grey);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin-left: 0.25rem;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.ae-bucket-remove-btn .material-icons {
    font-size: 15px;
    line-height: 1;
}

.ae-bucket-remove-btn:hover {
    color: #c62828;
    background: rgba(198, 40, 40, 0.06);
    border-color: rgba(198, 40, 40, 0.14);
}

.ae-bucket-body {
    padding: 0.4rem 0.5rem;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ae-bucket-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    color: var(--bitwise-light-grey);
    font-size: 0.7rem;
    font-style: italic;
}

/* Asset chip in bucket */
.ae-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.45rem;
    background: var(--secondary);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 5px;
    font-size: 0.7rem;
    font-family: var(--font-neue-montreal);
    transition: background 0.1s;
}

.ae-chip:hover { background: rgba(0, 0, 0, 0.04); }

.ae-chip-symbol {
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    min-width: 36px;
}

.ae-chip-name {
    color: var(--bitwise-light-grey);
    font-size: 0.65rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ae-chip-name small,
.ae-drawer-name small {
    display: block;
    color: var(--muted-foreground);
    font-size: 0.58rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ae-chip-remove {
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--bitwise-light-grey);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.ae-chip-remove .material-icons {
    font-size: 13px;
    line-height: 1;
}

.ae-chip-remove:hover {
    color: #c62828;
    background: rgba(198, 40, 40, 0.06);
    border-color: rgba(198, 40, 40, 0.14);
}

/* ── Bottom: Summary Drawer ── */
.ae-drawer {
    grid-column: 2 / 3;
    background: var(--background);
    border-top: 2px solid var(--border);
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.ae-drawer.ae-drawer-collapsed { max-height: 40px; }
.ae-drawer.ae-drawer-expanded { max-height: 260px; }

.ae-drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    user-select: none;
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font-neue-montreal);
}

.ae-drawer-toggle:hover { background: var(--secondary); }

.ae-drawer-title {
    font-family: var(--font-items);
    font-size: 0.82rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
}

.ae-drawer-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--bitwise-dark-teal);
    color: white;
    margin-left: 0.4rem;
}

.ae-drawer-arrow {
    font-size: 0.65rem;
    color: var(--bitwise-light-grey);
    transition: transform 0.2s;
}

.ae-drawer-expanded .ae-drawer-arrow { transform: rotate(180deg); }

.ae-drawer-body {
    padding: 0 1.25rem 0.75rem;
    overflow-y: auto;
    max-height: 200px;
}

.ae-drawer-scenarios {
    display: flex;
    gap: 1.25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.35rem;
}

.ae-drawer-scenario {
    min-width: 220px;
    max-width: 300px;
    flex-shrink: 0;
}

.ae-drawer-scenario-title {
    font-family: var(--font-items);
    font-size: 0.8rem;
    color: var(--bitwise-dark-teal);
    margin-bottom: 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid var(--bitwise-light-teal);
}

.ae-drawer-asset-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.73rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.ae-drawer-asset-row:last-child { border-bottom: none; }

.ae-drawer-symbol {
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    min-width: 45px;
}

.ae-drawer-name {
    color: var(--bitwise-light-grey);
    flex: 1;
    font-size: 0.68rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ae-drawer-weight {
    width: 50px;
    text-align: center;
    padding: 0.18rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-neue-montreal);
    color: var(--bitwise-dark-grey);
    background: var(--background);
    outline: none;
    font-variant-numeric: tabular-nums;
}

.ae-drawer-weight:focus { border-color: var(--bitwise-dark-teal); }

.ae-drawer-pct {
    font-size: 0.65rem;
    color: var(--bitwise-light-grey);
}

.ae-weight-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.ae-weight-total.valid { color: var(--bitwise-green); }
.ae-weight-total.invalid { color: #c62828; }

/* Bucket settings panel */
.ae-bucket-settings {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.ae-transfer-btn {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ===== PRODUCT WEIGHTS EXPLORER ===== */
.app--productweights .config-panel,
.app--productweights .results-panel,
.app--productweights .ae-layout,
.app--productweights .ib-layout,
.app--productweights .saved-layout { display: none !important; }
.app--productweights .pw-layout { display: grid; }
.app--productweights .app-body { grid-template-columns: 1fr; overflow: hidden; }

.pw-layout {
    display: none;
    grid-template-columns: 286px minmax(0, 1fr);
    height: calc(100vh - var(--nav-height));
    min-height: 0;
    overflow: hidden;
    background: #f5f6f4;
}

.pw-catalog-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fbfbfa;
    border-right: 1px solid var(--border);
}
.pw-catalog-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.15rem 0.8rem;
}
.pw-eyebrow,
.pw-section-kicker {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--bitwise-dark-teal);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.pw-catalog-header h2,
.pw-query-heading h2,
.pw-snapshot-toolbar h2,
.pw-replay-header h2 {
    margin: 0;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 1rem;
    font-weight: 700;
}
.pw-catalog-count {
    color: var(--muted-foreground);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
}
.pw-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    margin: 0 1.15rem 0.7rem;
    padding: 0.45rem 0.58rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.pw-search-wrap:focus-within {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}
.pw-search-wrap .material-icons { color: var(--muted-foreground); font-size: 1rem; }
.pw-search-wrap input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.77rem;
}
.pw-kind-filter {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 1.15rem 0.8rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.pw-kind-btn,
.pw-query-mode button {
    border: 0;
    background: #fff;
    color: var(--muted-foreground);
    cursor: pointer;
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.38rem 0.55rem;
}
.pw-kind-btn + .pw-kind-btn,
.pw-query-mode button + button { border-left: 1px solid var(--border); }
.pw-kind-btn.active,
.pw-query-mode button.active { background: var(--bitwise-dark-teal); color: #fff; }
.pw-catalog-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0.7rem 0.8rem;
}
.pw-product-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.6rem;
    width: 100%;
    margin-bottom: 0.35rem;
    padding: 0.72rem 0.75rem;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.pw-product-card:hover { background: #fff; border-color: var(--border); transform: translateY(-1px); }
.pw-product-card.active {
    background: #fff;
    border-color: rgba(0, 100, 114, 0.28);
    box-shadow: 0 4px 14px rgba(27, 37, 42, 0.05);
}
.pw-product-card-symbol { font-size: 0.83rem; font-weight: 700; letter-spacing: 0.01em; }
.pw-product-card-kind {
    align-self: start;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: rgba(0, 100, 114, 0.07);
    color: var(--bitwise-dark-teal);
    font-size: 0.57rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.pw-product-card-id,
.pw-product-card-coverage { color: var(--muted-foreground); font-size: 0.63rem; }
.pw-product-card-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pw-product-card-coverage { grid-column: 1 / -1; }
.pw-loading-card,
.pw-empty-list {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 8rem;
    padding: 1rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    text-align: center;
}
.pw-spinner {
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid rgba(0, 100, 114, 0.18);
    border-top-color: var(--bitwise-dark-teal);
    border-radius: 50%;
    animation: pwSpin 0.7s linear infinite;
}
@keyframes pwSpin { to { transform: rotate(360deg); } }
.pw-source-note {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    margin: 0;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 100, 114, 0.025);
    color: var(--muted-foreground);
    font-size: 0.64rem;
    line-height: 1.4;
}
.pw-source-note .material-icons { color: var(--bitwise-dark-teal); font-size: 0.95rem; }

.pw-main { min-width: 0; min-height: 0; overflow-y: auto; }
.pw-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 3rem;
    text-align: center;
}
.pw-empty-mark {
    display: grid;
    place-items: center;
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 1.15rem;
    border-radius: 18px;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(0, 100, 114, 0.18);
}
.pw-empty h1,
.pw-hero h1 {
    margin: 0;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 1.6rem;
    font-weight: 700;
}
.pw-empty p { max-width: 34rem; margin-top: 0.45rem; color: var(--muted-foreground); font-size: 0.82rem; }
.pw-workspace { width: min(1180px, 100%); margin: 0 auto; padding: 1.65rem 2rem 3rem; }
.pw-hero,
.pw-query-heading,
.pw-snapshot-toolbar,
.pw-replay-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.pw-hero { align-items: flex-end; margin-bottom: 1.15rem; }
.pw-identity-line { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.35rem; }
.pw-kind-badge,
.pw-engine-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.35rem;
    padding: 0.18rem 0.48rem;
    border-radius: 999px;
    background: rgba(0, 100, 114, 0.08);
    color: var(--bitwise-dark-teal);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.pw-identity-line code { color: var(--muted-foreground); font-size: 0.68rem; }
.pw-hero-copy p { margin-top: 0.35rem; color: var(--muted-foreground); font-size: 0.74rem; }
.pw-hero-actions { display: flex; gap: 0.45rem; }
.pw-secondary-btn,
.pw-primary-btn,
.pw-fingerprint-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.05rem;
    padding: 0.42rem 0.68rem;
    border-radius: 6px;
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.pw-secondary-btn { border: 1px solid var(--border); background: #fff; color: var(--foreground); }
.pw-secondary-btn:hover { border-color: rgba(0, 100, 114, 0.35); color: var(--bitwise-dark-teal); }
.pw-secondary-btn:disabled { cursor: not-allowed; opacity: 0.45; }
.pw-secondary-btn .material-icons { font-size: 0.9rem; }
.pw-primary-btn { border: 1px solid var(--bitwise-dark-teal); background: var(--bitwise-dark-teal); color: #fff; }
.pw-primary-btn:hover { background: #005562; }
.pw-primary-btn:disabled { cursor: wait; opacity: 0.62; }

.pw-query-card,
.pw-replay-card,
.pw-table-card {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    box-shadow: var(--shadow-hairline);
}
.pw-query-card { padding: 1rem 1.1rem; margin-bottom: 1rem; }
.pw-query-mode { display: flex; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.pw-query-controls,
.pw-replay-controls {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    margin-top: 0.85rem;
    flex-wrap: wrap;
}
.pw-range-fields { display: flex; align-items: flex-end; gap: 0.55rem; }
.pw-range-fields[hidden] { display: none; }
.pw-field { display: grid; gap: 0.25rem; min-width: 8.2rem; }
.pw-field > span,
.pw-snapshot-picker > span {
    color: var(--muted-foreground);
    font-size: 0.61rem;
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}
.pw-field input,
.pw-field select,
.pw-snapshot-picker select,
.pw-money-input {
    height: 2.05rem;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--foreground);
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    padding: 0.36rem 0.52rem;
}
.pw-field input:focus,
.pw-field select:focus,
.pw-snapshot-picker select:focus { outline: none; border-color: var(--bitwise-dark-teal); box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08); }
.pw-date-arrow { padding-bottom: 0.45rem; color: var(--muted-foreground); }
.pw-inline-status { min-width: 6rem; padding-bottom: 0.42rem; color: var(--muted-foreground); font-size: 0.68rem; }
.pw-error-banner {
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(183, 28, 28, 0.2);
    border-radius: 7px;
    background: rgba(183, 28, 28, 0.045);
    color: #9f2722;
    font-size: 0.74rem;
    line-height: 1.45;
}
.pw-snapshot-section { display: grid; gap: 0.8rem; }
.pw-snapshot-toolbar { align-items: flex-end; margin-top: 1.25rem; }
.pw-snapshot-picker { display: grid; gap: 0.25rem; }
.pw-snapshot-picker select { min-width: 9.5rem; }
.pw-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.65rem; }
.pw-stat-card {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.75);
}
.pw-stat-card span { color: var(--muted-foreground); font-size: 0.62rem; font-weight: 650; text-transform: uppercase; }
.pw-stat-card strong { color: var(--foreground); font-size: 1rem; font-variant-numeric: tabular-nums; }
.pw-status-pass { color: #24704c !important; }
.pw-status-pass-with-exceptions { color: #9a6500 !important; }
.pw-status-fail { color: #a52a24 !important; }
.pw-audit-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.72rem 0.85rem;
    border: 1px solid rgba(36, 112, 76, 0.18);
    border-radius: 8px;
    background: rgba(36, 112, 76, 0.045);
}
.pw-audit-strip[data-status="fail"] { border-color: rgba(165, 42, 36, 0.2); background: rgba(165, 42, 36, 0.045); }
.pw-audit-strip[data-status="pass_with_exceptions"] { border-color: rgba(154, 101, 0, 0.22); background: rgba(154, 101, 0, 0.05); }
.pw-audit-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #24704c; }
.pw-audit-strip[data-status="fail"] .pw-audit-dot { background: #a52a24; }
.pw-audit-strip[data-status="pass_with_exceptions"] .pw-audit-dot { background: #9a6500; }
.pw-audit-strip strong { display: block; color: var(--foreground); font-size: 0.72rem; }
.pw-audit-strip p { margin: 0.1rem 0 0; color: var(--muted-foreground); font-size: 0.65rem; line-height: 1.35; }
.pw-fingerprint-btn { min-height: 1.8rem; border: 1px solid var(--border); background: #fff; color: var(--muted-foreground); }
.pw-table-card { overflow: hidden; }
.pw-table-caption { display: flex; justify-content: space-between; gap: 1rem; padding: 0.58rem 0.8rem; color: var(--muted-foreground); font-size: 0.63rem; }
.pw-table-wrap { overflow: auto; max-height: 470px; border-top: 1px solid var(--border); }
.pw-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.pw-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.58rem 0.7rem;
    border-bottom: 1px solid var(--border);
    background: #f5f6f4;
    color: var(--muted-foreground);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}
.pw-table td { padding: 0.62rem 0.7rem; border-bottom: 1px solid rgba(225, 226, 222, 0.72); color: var(--foreground); font-size: 0.7rem; vertical-align: middle; }
.pw-table tr:last-child td { border-bottom: 0; }
.pw-table tbody tr:hover { background: rgba(0, 100, 114, 0.025); }
.pw-table tr.pw-row-negative { background: rgba(165, 42, 36, 0.045); }
.pw-table tr.pw-row-unweighted { background: rgba(154, 101, 0, 0.045); color: var(--muted-foreground); }
.pw-number { text-align: right !important; font-variant-numeric: tabular-nums; }
.pw-holding-primary { display: block; font-weight: 700; }
.pw-holding-secondary { display: block; margin-top: 0.08rem; color: var(--muted-foreground); font-size: 0.61rem; }
.pw-type-chip { padding: 0.14rem 0.38rem; border-radius: 999px; background: rgba(0, 100, 114, 0.06); color: var(--bitwise-dark-teal); font-size: 0.58rem; font-weight: 650; }
.pw-weight-negative { color: #a52a24; font-weight: 700; }
.pw-weight-missing { color: #9a6500; font-style: italic; }

.pw-replay-card { margin-top: 1.15rem; padding: 1rem 1.1rem 1.15rem; }
.pw-replay-header p { margin-top: 0.25rem; color: var(--muted-foreground); font-size: 0.7rem; }
.pw-replay-controls .pw-field { flex: 1 1 8rem; }
.pw-money-input { display: flex; align-items: center; gap: 0.2rem; padding: 0 0.5rem; }
.pw-money-input span { color: var(--muted-foreground); font-size: 0.72rem; }
.pw-money-input input { width: 100%; height: 1.8rem; padding: 0; border: 0; outline: 0; }
.pw-run-btn { flex: 0 0 auto; min-width: 7rem; }
.pw-replay-status { min-height: 1rem; margin-top: 0.65rem; color: var(--muted-foreground); font-size: 0.68rem; }
.pw-replay-status.is-error { color: #a52a24; }
.pw-replay-results { display: grid; gap: 0.8rem; margin-top: 0.35rem; }
.pw-metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.55rem; }
.pw-metric {
    display: grid;
    gap: 0.2rem;
    padding: 0.72rem 0.78rem;
    border-radius: 7px;
    background: #f5f6f4;
}
.pw-metric span { color: var(--muted-foreground); font-size: 0.59rem; font-weight: 700; text-transform: uppercase; }
.pw-metric strong { color: var(--foreground); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pw-replication-note { padding: 0.65rem 0.75rem; border-left: 3px solid var(--bitwise-dark-teal); background: rgba(0, 100, 114, 0.035); color: var(--muted-foreground); font-size: 0.67rem; line-height: 1.45; }
.pw-chart { width: 100%; height: 330px; }

@media (max-width: 1080px) {
    .pw-layout { grid-template-columns: 240px minmax(0, 1fr); }
    .pw-workspace { padding-left: 1.25rem; padding-right: 1.25rem; }
    .pw-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pw-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .app.app--productweights { height: 100dvh; overflow: hidden; }
    .app--productweights .app-body { height: calc(100dvh - var(--nav-height)); min-height: 0; overflow: hidden; }
    .pw-layout { grid-template-columns: 1fr; grid-template-rows: minmax(150px, 28vh) minmax(0, 1fr); height: 100%; }
    .pw-catalog-panel { border-right: 0; border-bottom: 1px solid var(--border); }
    .pw-catalog-header { padding-top: 0.75rem; }
    .pw-catalog-list { display: flex; gap: 0.4rem; overflow-x: auto; overflow-y: hidden; padding-bottom: 0.55rem; }
    .pw-product-card { min-width: 205px; margin-bottom: 0; }
    .pw-source-note { display: none; }
    .pw-workspace { padding: 1rem 0.8rem 2rem; }
    .pw-hero { align-items: flex-start; }
    .pw-query-heading,
    .pw-replay-header { flex-direction: column; }
    .pw-range-fields { width: 100%; flex-wrap: wrap; }
    .pw-range-fields .pw-field { flex: 1; }
    .pw-query-controls > .pw-field { flex: 1; }
    .pw-audit-strip { grid-template-columns: auto minmax(0, 1fr); }
    .pw-fingerprint-btn { grid-column: 2; justify-self: start; }
    .pw-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .pw-hero { flex-direction: column; }
    .pw-stat-grid { grid-template-columns: 1fr 1fr; }
    .pw-snapshot-toolbar { align-items: flex-start; flex-direction: column; }
    .pw-snapshot-picker { width: 100%; }
    .pw-snapshot-picker select { width: 100%; }
}

/* ===== INDEX BUILDER ===== */

/* Index builder mode — hide normal panels, show builder */
.app--indexbuilder .config-panel { display: none; }
.app--indexbuilder .results-panel { display: none; }
.app--indexbuilder .ae-layout { display: none; }
.app--indexbuilder .ib-layout { display: grid; }
.app--indexbuilder .app-body { grid-template-columns: 1fr; overflow: hidden; }

.ib-layout {
    display: none;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - var(--nav-height));
    overflow: hidden;
}

/* ── Left: Rule Pipeline ── */
.ib-pipeline {
    display: flex;
    flex-direction: column;
    background: var(--background);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
}

.ib-pipeline-header {
    padding: 1.5rem 1.25rem 1rem;
}

.ib-pipeline-title {
    font-family: var(--font-items);
    font-size: 1.05rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
    display: block;
    letter-spacing: 0.1px;
}

.ib-pipeline-sub {
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    color: var(--bitwise-light-grey);
    margin-top: 0.25rem;
    display: block;
}

.ib-rules-list {
    flex: 0 0 auto;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

/* Connected flow line between rule cards */
.ib-rules-list::before {
    content: '';
    position: absolute;
    top: 1.25rem;
    bottom: 1.25rem;
    left: calc(1.25rem + 0.7rem);
    width: 1.5px;
    background: linear-gradient(to bottom, var(--bitwise-dark-teal), rgba(0, 100, 114, 0.15));
    z-index: 0;
    border-radius: 1px;
}

/* ── Rule Card ── */
.ib-rule {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
    padding: 0.6rem 0 0.6rem 0;
}

.ib-rule-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0 0.5rem 0;
    border-bottom: none;
    background: transparent;
}

.ib-rule-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--bitwise-dark-teal);
    color: #fff;
    font-family: var(--font-neue-montreal);
    font-size: 0.6rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px var(--background);
    position: relative;
    z-index: 2;
}

.ib-rule-label {
    font-family: var(--font-neue-montreal);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    letter-spacing: 0.2px;
}

.ib-rule-desc {
    font-family: var(--font-neue-montreal);
    font-size: 0.62rem;
    color: var(--bitwise-light-grey);
    margin-left: auto;
}

.ib-rule-body {
    padding: 0 0 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--page-background);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ib-rule-body:hover {
    border-color: rgba(0, 100, 114, 0.2);
    box-shadow: 0 2px 8px rgba(0, 100, 114, 0.04);
}

/* ── Universe chips ── */
.ib-universe-chips {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.ib-sector-chips {
    max-height: 92px;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.ib-chip {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--bitwise-light-grey);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}

.ib-chip:hover {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.03);
}

.ib-chip.active {
    background: rgba(0, 100, 114, 0.08);
    color: var(--bitwise-dark-teal);
    border-color: rgba(0, 100, 114, 0.3);
    font-weight: 700;
}

.ib-chip--sector {
    font-size: 0.64rem;
}

/* Index universe chips — slightly different accent */
.ib-chip--index.active {
    background: rgba(26, 54, 93, 0.08);
    border-color: rgba(26, 54, 93, 0.3);
    color: #1a365d;
}

.ib-chip--index:hover {
    border-color: #1a365d;
    color: #1a365d;
    background: rgba(26, 54, 93, 0.03);
}

/* Universe group labels and divider */
.ib-universe-group-label {
    font-family: var(--font-neue-montreal);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--bitwise-light-grey);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ib-universe-divider {
    height: 1px;
    background: var(--border);
    margin: 0.4rem 0;
}

/* PIT badge */
.ib-pit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: rgba(26, 54, 93, 0.1);
    color: #1a365d;
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    cursor: help;
    border: 1px solid rgba(26, 54, 93, 0.2);
}

/* PIT hint */
.ib-pit-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    background: rgba(26, 54, 93, 0.04);
    border: 1px solid rgba(26, 54, 93, 0.1);
    font-family: var(--font-neue-montreal);
    font-size: 0.62rem;
    color: #4a5568;
    line-height: 1.45;
}

.ib-pit-hint-icon {
    font-size: 0.75rem;
    color: #1a365d;
    flex-shrink: 0;
    margin-top: -0.05rem;
}

/* Summary chip for PIT filters */
.ib-summary-chip--pit {
    border-color: #1a365d;
}

.ib-summary-chip--pit .ib-summary-label {
    color: #1a365d;
}

.ib-summary-chip--pit .ib-summary-val {
    color: #1a365d;
    font-weight: 700;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Secondary button in pipeline actions */
.ib-secondary-btn {
    font-size: 0.72rem;
    padding: 0.55rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--bitwise-light-grey);
    border-radius: 8px;
    width: 100%;
    text-align: center;
    transition: all 0.2s ease;
}

.ib-secondary-btn:hover {
    border-color: var(--bitwise-dark-teal);
    color: var(--bitwise-dark-teal);
    background: rgba(0, 100, 114, 0.03);
}

/* ── Form fields ── */
.ib-rank-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.ib-rank-row > .ib-select,
.ib-rank-row > .ib-date-input {
    flex: 1 1 auto;
    min-width: 0;
}

.ib-field-label {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--bitwise-light-grey);
    min-width: 4.25rem;
    flex-shrink: 0;
    letter-spacing: 0.2px;
}

.ib-field-suffix {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    color: var(--bitwise-light-grey);
}

.ib-select {
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ib-select:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.ib-number-input {
    font-family: var(--font-neue-montreal);
    font-size: 0.75rem;
    font-weight: 600;
    width: 4rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--bitwise-dark-teal);
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ib-number-input:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.ib-number-input::-webkit-outer-spin-button,
.ib-number-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ib-number-input[type=number] { -moz-appearance: textfield; }

.ib-date-input {
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ib-date-input:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

.ib-text-input {
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    font-weight: 500;
    width: 5.5rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ib-text-input:focus {
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

/* ── Conditionals ── */
.ib-conditionals-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ib-add-condition-btn {
    font-family: var(--font-neue-montreal);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(98, 160, 173, 0.35);
    border-radius: 999px;
    background: rgba(98, 160, 173, 0.06);
    color: var(--bitwise-dark-teal);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}

.ib-add-condition-btn:hover {
    background: rgba(98, 160, 173, 0.15);
    border-color: var(--bitwise-dark-teal);
}

.ib-conditions-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ib-condition-card {
    background: var(--page-background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
}

.ib-condition-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.ib-cond-type {
    flex: 1;
    min-width: 8rem;
    font-size: 0.68rem;
}

.ib-cond-asset-type {
    font-size: 0.68rem;
}

.ib-cond-value {
    width: 3.2rem;
    font-size: 0.68rem;
}

.ib-cond-asset {
    width: 4.5rem;
    font-size: 0.68rem;
}

.ib-cond-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
    color: var(--bitwise-light-grey);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.ib-cond-remove:hover {
    background: rgba(198, 40, 40, 0.1);
    color: #c62828;
}

/* ── Pipeline Actions ── */
.ib-pipeline-actions {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--background);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ib-apply-btn {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    border-radius: 8px;
}

/* ── Right: Preview Panel ── */
.ib-preview {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--page-background);
}

.ib-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ib-preview-title {
    font-family: var(--font-items);
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--bitwise-dark-grey);
    letter-spacing: 0.1px;
}

.ib-preview-count {
    font-family: var(--font-neue-montreal);
    font-size: 0.68rem;
    color: var(--bitwise-light-grey);
    background: var(--secondary);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Summary chips ── */
.ib-preview-summary {
    display: flex;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
    background: var(--background);
}

.ib-summary-chip {
    display: flex;
    flex-direction: column;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--page-background);
    min-width: 5.5rem;
    transition: border-color 0.15s;
}

.ib-summary-chip:hover {
    border-color: rgba(0, 100, 114, 0.2);
}

.ib-summary-chip.ib-flag-warn {
    border-color: #e65100;
    background: rgba(230, 81, 0, 0.03);
}

.ib-summary-label {
    font-family: var(--font-neue-montreal);
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--bitwise-light-grey);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ib-summary-val {
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
    color: var(--bitwise-dark-grey);
    margin-top: 0.15rem;
    font-weight: 600;
}

.ib-flag-warn .ib-summary-val {
    color: #e65100;
    font-weight: 600;
}

/* ── Preview Table ── */
.ib-preview-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
}

.ib-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-neue-montreal);
    font-size: 0.72rem;
}

.ib-preview-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.ib-preview-table th {
    padding: 0.55rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.6rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--bitwise-light-grey);
    background: var(--background);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.ib-preview-table td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    white-space: nowrap;
    color: var(--bitwise-dark-grey);
    font-size: 0.73rem;
}

.ib-preview-table tr:hover td {
    background: rgba(0, 100, 114, 0.02);
}

.ib-td-rank {
    width: 2.5rem;
    color: var(--bitwise-light-grey);
    font-weight: 500;
    font-size: 0.65rem;
    font-variant-numeric: tabular-nums;
}

.ib-td-symbol {
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    letter-spacing: 0.3px;
}

.ib-td-name {
    color: var(--bitwise-light-grey);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.7rem;
}

.ib-td-sector,
.ib-td-group {
    color: var(--bitwise-dark-grey);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.68rem;
}

.ib-td-group {
    color: var(--bitwise-light-grey);
    max-width: 150px;
}

.ib-td-mcap {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-size: 0.7rem;
}

.ib-td-weight {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--bitwise-dark-teal);
    font-size: 0.72rem;
}

.ib-th-mcap, .ib-th-weight { text-align: right; }
.ib-th-rank { width: 2.5rem; }

/* ── Type badges ── */
.ib-type-badge {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.ib-type-crypto {
    background: rgba(245, 166, 35, 0.08);
    color: #c68a1a;
    border-color: rgba(245, 166, 35, 0.2);
}

.ib-type-usequity {
    background: rgba(0, 100, 114, 0.06);
    color: var(--bitwise-dark-teal);
    border-color: rgba(0, 100, 114, 0.15);
}

.ib-type-index {
    background: rgba(69, 185, 121, 0.08);
    color: #2d8659;
    border-color: rgba(69, 185, 121, 0.2);
}

.ib-type-curncy {
    background: rgba(108, 107, 113, 0.06);
    color: var(--bitwise-dark-grey);
    border-color: rgba(108, 107, 113, 0.15);
}

/* ── Exclude button on preview table rows ── */
.ib-th-actions { width: 2rem; }

.ib-td-exclude {
    width: 2rem;
    text-align: center;
    padding: 0.3rem 0.4rem !important;
}

.ib-exclude-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--bitwise-light-grey);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0;
}

.ib-preview-table tr:hover .ib-exclude-btn {
    opacity: 0.5;
}

.ib-exclude-btn:hover {
    opacity: 1 !important;
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
}

/* ── Excluded assets summary chip ── */
.ib-summary-chip--excluded {
    border-color: rgba(198, 40, 40, 0.2);
    background: rgba(198, 40, 40, 0.03);
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s;
}

.ib-summary-chip--excluded:hover {
    border-color: rgba(198, 40, 40, 0.35);
}

.ib-summary-chip--excluded .ib-summary-label {
    color: #c62828;
}

.ib-summary-chip--excluded .ib-summary-val {
    color: #c62828;
    font-weight: 500;
    font-size: 0.65rem;
}

/* ── Excluded dropdown ── */
.ib-excluded-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 0.4rem;
    z-index: 50;
    flex-direction: column;
    gap: 0.15rem;
}

.ib-excluded-dropdown--open {
    display: flex;
}

.ib-excluded-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    transition: background 0.1s;
}

.ib-excluded-item:hover {
    background: var(--page-background);
}

.ib-excluded-sym {
    font-family: var(--font-neue-montreal);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--bitwise-dark-grey);
    letter-spacing: 0.2px;
}

.ib-excluded-restore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--bitwise-dark-teal);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.ib-excluded-restore:hover {
    background: rgba(0, 100, 114, 0.08);
}

.ib-excluded-clear {
    font-family: var(--font-neue-montreal);
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--bitwise-dark-teal);
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.5rem 0.2rem;
    margin-top: 0.15rem;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s;
}

.ib-excluded-clear:hover {
    color: #005562;
}

.ae-bucket-settings-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.ae-bucket-settings-row:last-child { margin-bottom: 0; }

.ae-bucket-settings-field {
    flex: 1;
}

.ae-bucket-settings-field label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--bitwise-light-grey);
    margin-bottom: 0.2rem;
    font-weight: 600;
}

.ae-bucket-settings-field input,
.ae-bucket-settings-field select {
    width: 100%;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.28rem 0.4rem;
    background: var(--background);
    color: var(--bitwise-dark-grey);
    font-family: var(--font-neue-montreal);
    outline: none;
}

.ae-bucket-settings-field input:focus,
.ae-bucket-settings-field select:focus {
    border-color: var(--bitwise-dark-teal);
}

/* ===== CONTROL CONSISTENCY OVERRIDES ===== */
.canvas-select,
.form-group select,
.asset-row select,
.mc-select,
.ae-category-select,
.ae-scenario-picker,
.ae-bucket-settings-field select,
.ib-select,
.rt-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 13px 13px;
    padding-right: 1.9rem;
}

.canvas-select {
    background-position: right 0.05rem center;
    padding-right: 1.2rem;
}

.ae-category-select,
.ae-scenario-picker,
.ae-bucket-settings-field select,
.ib-select,
.rt-select {
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.ae-category-select:hover,
.ae-scenario-picker:hover,
.ae-bucket-settings-field select:hover,
.ib-select:hover,
.rt-select:hover,
.form-group select:hover,
.asset-row select:hover {
    border-color: rgba(0, 100, 114, 0.28);
    background-color: rgba(0, 100, 114, 0.03);
}

.ae-category-select:focus,
.ae-scenario-picker:focus,
.ae-bucket-settings-field select:focus,
.ib-select:focus,
.rt-select:focus {
    outline: none;
    border-color: var(--bitwise-dark-teal);
    box-shadow: 0 0 0 2px rgba(0, 100, 114, 0.08);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1240px) {
    .app-nav {
        padding: 0 1rem;
    }
    .app-subnav {
        padding: 0 1rem;
    }
    .app-nav-divider {
        margin: 0 0.8rem;
    }
    .app-nav-setup {
        gap: 1rem;
    }
    .nav-report-fields {
        gap: 0.45rem;
        padding-left: 0.65rem;
    }
    .nav-report-input {
        width: 7.4rem;
    }
    .nav-report-input--wide {
        width: 9.25rem;
    }
    .nav-input-wrap--money {
        width: 86px;
    }
    .nav-date-inputs {
        grid-template-columns: 7.15rem auto 7.15rem;
    }
    .ae-table .ae-th-group,
    .ae-table .ae-cell-group {
        display: none;
    }
}

@media (max-width: 1100px) {
    .canvas-index-grid { grid-template-columns: 1fr 1fr; }
    .canvas-opt-grid { grid-template-columns: 1fr 1fr; }
    .nav-report-fields {
        overflow-x: auto;
    }
    .nav-report-field {
        flex: 0 0 auto;
    }
    .nav-date-inputs {
        grid-template-columns: minmax(0, 7.8rem) auto minmax(0, 7.8rem);
    }
}

@media (max-width: 900px) {
    .canvas-settings { grid-template-columns: 1fr; }
    .canvas-scenarios { grid-template-columns: 1fr; }
    :root { --sidebar-width: 240px; }
    .app--configure { --subnav-height: 46px; }
    .ae-layout { grid-template-columns: 220px minmax(0, 1fr); }
    .ae-table .ae-th-sector,
    .ae-table .ae-cell-sector {
        display: none;
    }
}

@media (max-width: 768px) {
    body { overflow: auto; }
    .app { height: auto; }
    .app-body { height: auto; overflow: visible; }
    .config-panel { height: auto; }
    .results-panel { height: auto; }
    .app--results .app-body { grid-template-columns: 1fr; grid-template-rows: auto auto; }
    .app-nav-modes { gap: 0; overflow-x: auto; }
    .mode-tab { font-size: 0.72rem; padding: 0.35rem 0.5rem; }
    .app-subnav {
        padding: 0 1.25rem;
    }
    .app-subnav .app-nav-setup {
        padding: 0;
    }
    .app--configure .app-nav-setup {
        display: grid;
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
        justify-content: stretch;
        align-items: center;
        gap: 0.6rem;
    }
    .nav-report-fields {
        grid-column: 1 / -1;
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
    }
    .nav-setup-field {
        min-width: 0;
    }
    .nav-date-inputs {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }
    .canvas-index-grid { grid-template-columns: 1fr 1fr; }
    .config-canvas .scenario-header {
        grid-template-columns: 1fr;
        align-items: stretch;
        padding-top: var(--space-2);
        padding-bottom: var(--space-2);
    }
    .scenario-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .scenario-settings-row { grid-template-columns: 1fr; }
    .scenario-cost-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .scenario-balance-actions { grid-column: auto; }
    .results-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    .results-title-row {
        align-items: flex-start;
    }
    .risk-free-chip {
        white-space: normal;
    }
    .results-section-heading .table-header-actions {
        justify-content: flex-start;
        width: 100%;
    }
    .numbers-tab {
        flex: 1 0 auto;
        min-width: max-content;
        text-align: center;
    }
    .mc-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .mc-controls {
        justify-content: flex-start;
        width: 100%;
    }
    .mc-select {
        flex: 1 1 10rem;
        min-width: 0;
    }
    .mc-fan-chart {
        height: 430px;
    }
    .mc-summary-grid { grid-template-columns: 1fr 1fr; }
    .performance-table { min-width: 600px; }
    .results-panel { padding: 1.25rem; }
    .config-canvas { padding: 1.25rem; }
    .app.app--explorer {
        height: 100dvh;
        overflow: hidden;
    }
    .app--explorer .app-body {
        height: calc(100dvh - var(--nav-height));
        min-height: 0;
        overflow: hidden;
    }
    .ae-layout {
        height: 100%;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(150px, 26vh) minmax(0, 1fr) auto;
    }
    .ae-buckets-panel {
        grid-column: 1;
        grid-row: 1;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .ae-buckets-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .ae-bucket {
        min-width: 215px;
    }
    .ae-table-panel {
        grid-column: 1;
        grid-row: 2;
        min-height: 0;
    }
    .ae-drawer {
        grid-column: 1;
        grid-row: 3;
    }
    .ae-filters {
        padding: 0.6rem 0.75rem;
    }
    .ae-map-toolbar {
        flex-wrap: wrap;
        gap: 0.45rem 0.7rem;
    }
    .ae-map-link-key {
        display: none;
    }
    .ae-map-count {
        margin-left: auto;
    }
    .ae-map-canvas {
        min-height: 260px;
    }
    .ae-asset-detail {
        width: min(430px, 100%);
    }
}

@media (max-width: 480px) {
    .app--configure { --subnav-height: 82px; }
    .app-subnav {
        align-items: stretch;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
    .app--configure .app-nav-divider {
        display: none;
    }
    .app--configure .app-nav-library {
        margin-left: 0.35rem;
    }
    .app--configure .app-nav-setup {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
    .nav-report-fields {
        gap: 0.5rem;
    }
    .nav-report-input,
    .nav-report-input--wide {
        width: 8.4rem;
    }
    .nav-setup-label {
        display: inline;
        min-width: 5.5rem;
    }
    .nav-setup-field {
        min-height: 2rem;
        padding: 0;
    }
    .canvas-index-grid { grid-template-columns: 1fr; }
    .canvas-opt-grid { grid-template-columns: 1fr; }
    .form-group input, .form-group select { font-size: 16px; }
    .ae-view-switch {
        order: 1;
    }
    .ae-map-toolbar {
        align-items: stretch;
        padding: 0.45rem 0.6rem;
    }
    .ae-map-control {
        flex: 1 1 calc(50% - 0.35rem);
        align-items: stretch;
        flex-direction: column;
        gap: 0.2rem;
    }
    .ae-map-control select {
        width: 100%;
        max-width: none;
        font-size: 0.72rem;
    }
    .ae-map-count {
        margin-left: 0;
        align-self: center;
    }
    .ae-map-reset {
        margin-left: auto;
    }
    .ae-detail-selection-action {
        align-items: stretch;
        flex-direction: column;
    }
    .ae-detail-select-btn {
        align-self: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ae-map-node-halo,
    .ae-map-node-dot {
        transition: none;
    }
}
