/* Yield backtest detail modal */
body.yield-detail-modal-open {
    overflow: hidden;
}

#yield-backtest-table tbody tr.yield-detail-trigger {
    cursor: zoom-in;
}

#yield-backtest-table tbody tr.yield-detail-trigger:hover td {
    background-color: rgba(18, 96, 161, 0.045);
}

#yield-backtest-table tbody tr.yield-detail-trigger:focus-visible {
    outline: 2px solid #1768b8;
    outline-offset: -2px;
}

.yield-detail-instruction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    color: #2f6e9e;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.yield-detail-instruction::before {
    content: "↗";
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border: 1px solid #b7d5ed;
    border-radius: 50%;
    color: #1768b8;
    font-size: 10px;
}

.yield-detail-modal[hidden] {
    display: none;
}

.yield-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 38px);
    box-sizing: border-box;
}

.yield-detail-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 29, 45, 0.38);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.yield-detail-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(980px, 100%);
    max-height: min(850px, calc(100dvh - 24px));
    overflow: hidden;
    border: 1px solid #d6e1ea;
    border-radius: 16px;
    background: #f7f9fb;
    color: #1d2d3e;
    box-shadow: 0 24px 70px rgba(8, 26, 45, 0.26);
}

.yield-detail-dialog:focus-visible {
    outline: 3px solid rgba(31, 108, 176, 0.46);
    outline-offset: 3px;
}

.yield-detail-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 19px 21px 17px;
    border-bottom: 1px solid #dbe5ed;
    background: linear-gradient(105deg, #1c4e49 0%, #236c65 58%, #2a8276 100%);
    color: #ffffff;
}

.yield-detail-eyebrow {
    display: block;
    margin: 0 0 4px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.92px;
}

.yield-detail-dialog-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: clamp(18px, 2vw, 23px);
    font-weight: 750;
    letter-spacing: -0.45px;
    line-height: 1.25;
}

.yield-detail-dialog-header p {
    margin: 7px 0 0;
    color: rgba(255, 255, 255, 0.83);
    font-size: 12px;
    font-weight: 500;
}

.yield-detail-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding-top: 2px;
}

.yield-detail-header-actions .yield-status {
    font-size: 11px;
    white-space: nowrap;
}

.yield-detail-close {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.11);
    color: #ffffff;
    font-family: inherit;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.yield-detail-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.yield-detail-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.yield-detail-modal-body {
    overflow: auto;
    padding: 18px 20px 22px;
    scrollbar-gutter: stable;
}

.yield-detail-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid #dbe5ed;
    border-radius: 11px;
    background: #ffffff;
}

.yield-detail-metric {
    min-width: 0;
    padding: 13px 14px;
    border-right: 1px solid #e5ebf0;
}

.yield-detail-metric:last-child {
    border-right: 0;
}

.yield-detail-metric span,
.yield-detail-section p,
.yield-detail-step-label,
.yield-detail-formula-results span,
.yield-detail-comparison span,
.yield-detail-reference-grid span {
    display: block;
    color: #697887;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.35;
}

.yield-detail-metric strong {
    display: block;
    overflow: hidden;
    margin-top: 5px;
    color: #203143;
    font-size: clamp(15px, 1.8vw, 19px);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yield-detail-metric.actual strong {
    color: #9a2b34;
}

.yield-detail-metric.calculated strong {
    color: #16635c;
}

.yield-detail-metric.difference strong,
.yield-detail-metric.anomaly strong {
    color: #b4232d;
}

.yield-detail-metric.fit strong {
    color: #146c43;
}

.yield-detail-metric.good strong {
    color: #0b5cad;
}

.yield-detail-metric.warning strong {
    color: #895c00;
}

.yield-detail-metric.unknown strong {
    color: #5f6875;
}

.yield-detail-section {
    margin-top: 12px;
    padding: 16px;
    border: 1px solid #dbe5ed;
    border-radius: 11px;
    background: #ffffff;
}

.yield-detail-section-heading {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.yield-detail-section-number {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 25px;
    height: 25px;
    border-radius: 7px;
    background: #e4f1ef;
    color: #17675e;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.45px;
}

.yield-detail-section-heading h3 {
    margin: 0 0 3px;
    color: #253849;
    font-size: 14px;
    font-weight: 750;
    letter-spacing: -0.2px;
    line-height: 1.3;
}

.yield-detail-section-heading p {
    margin: 0;
}

.yield-detail-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.yield-detail-step {
    position: relative;
    display: flex;
    min-width: 0;
    gap: 8px;
    padding: 10px;
    border: 1px solid #e3ebf1;
    border-radius: 8px;
    background: #fbfcfd;
}

.yield-detail-step-index {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: #eaf3f8;
    color: #23658b;
    font-size: 10px;
    font-weight: 800;
}

.yield-detail-step > div {
    min-width: 0;
}

.yield-detail-step strong {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: #263849;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yield-detail-step small {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: #8a98a5;
    font-size: 10px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yield-detail-formula {
    overflow: hidden;
    border: 1px solid #dce9e8;
    border-radius: 9px;
    background: linear-gradient(110deg, #f5fbfa 0%, #fbfdfd 100%);
}

.yield-detail-formula-expression {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 15px;
    border-bottom: 1px solid #dce9e8;
    color: #245851;
    font-size: 13px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.yield-detail-formula-expression span {
    padding: 5px 8px;
    border: 1px solid #cce0dd;
    border-radius: 6px;
    background: #ffffff;
}

.yield-detail-formula-expression b {
    color: #4f756f;
    font-size: 14px;
}

.yield-detail-formula-results {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.yield-detail-formula-results > div {
    min-width: 0;
    padding: 12px 15px;
    border-right: 1px solid #dce9e8;
}

.yield-detail-formula-results > div:last-child {
    border-right: 0;
    background: rgba(39, 121, 111, 0.07);
}

.yield-detail-formula-results strong,
.yield-detail-comparison strong,
.yield-detail-reference-grid strong {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: #263849;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yield-detail-formula-results > div:last-child strong {
    color: #16635c;
    font-size: 16px;
}

.yield-detail-comparison {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.yield-detail-comparison > div,
.yield-detail-reference-grid > div {
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #e1e9ef;
    border-radius: 8px;
    background: #fbfcfd;
}

.yield-detail-comparison strong {
    color: #a22f37;
}

.yield-detail-comparison > div:nth-child(4) strong {
    color: #2d526d;
}

.yield-detail-status-copy {
    font-size: 13px !important;
}

.yield-detail-note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    font-size: 11px;
    line-height: 1.45;
}

.yield-detail-note strong {
    flex: 0 0 auto;
}

.yield-detail-note.is-comparable {
    border: 1px solid #c9e0dc;
    background: #f1faf8;
    color: #24675f;
}

.yield-detail-note.is-excluded {
    border: 1px solid #e8d4a4;
    background: #fffaf0;
    color: #73551b;
}

.yield-detail-reference-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.yield-detail-reference-grid small {
    display: block;
    margin-top: 2px;
    color: #7f8d99;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.yield-detail-footnote {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 15px;
    margin-top: 10px;
    color: #7a8895;
    font-size: 10.5px;
    line-height: 1.45;
}

.yield-detail-loading,
.yield-detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    min-height: 280px;
    padding: 28px;
    box-sizing: border-box;
    color: #5c6d7d;
    text-align: center;
}

.yield-detail-loading > div,
.yield-detail-empty {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.yield-detail-loading strong,
.yield-detail-empty strong {
    color: #294257;
    font-size: 14px;
}

.yield-detail-loading span,
.yield-detail-empty span {
    font-size: 12px;
}

.yield-detail-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #c9dce7;
    border-top-color: #20706a;
    border-radius: 50%;
    animation: yield-detail-spin 0.75s linear infinite;
}

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

.yield-detail-dialog-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid #dbe5ed;
    background: #ffffff;
}

.yield-detail-dialog-footer button {
    min-width: 76px;
    min-height: 31px;
    padding: 6px 13px;
    border: 1px solid #b7cfdf;
    border-radius: 6px;
    background: #ffffff;
    color: #285875;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.yield-detail-dialog-footer button:hover {
    border-color: #689fbd;
    background: #f2f8fb;
}

@media (max-width: 820px) {
    .yield-detail-overview,
    .yield-detail-comparison,
    .yield-detail-reference-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .yield-detail-metric:nth-child(2) {
        border-right: 0;
    }

    .yield-detail-metric:nth-child(-n+2) {
        border-bottom: 1px solid #e5ebf0;
    }

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

@media (max-width: 560px) {
    .yield-detail-modal {
        padding: 8px;
    }

    .yield-detail-dialog {
        max-height: calc(100dvh - 16px);
        border-radius: 12px;
    }

    .yield-detail-dialog-header,
    .yield-detail-modal-body {
        padding-left: 14px;
        padding-right: 14px;
    }

    .yield-detail-dialog-header {
        gap: 10px;
        padding-top: 15px;
        padding-bottom: 14px;
    }

    .yield-detail-header-actions .yield-status {
        display: none;
    }

    .yield-detail-section {
        padding: 13px;
    }

    .yield-detail-steps,
    .yield-detail-formula-results {
        grid-template-columns: 1fr;
    }

    .yield-detail-formula-results > div {
        border-right: 0;
        border-bottom: 1px solid #dce9e8;
    }

    .yield-detail-formula-results > div:last-child {
        border-bottom: 0;
    }

    .yield-detail-overview,
    .yield-detail-comparison,
    .yield-detail-reference-grid {
        grid-template-columns: 1fr;
    }

    .yield-detail-metric,
    .yield-detail-metric:nth-child(2) {
        border-right: 0;
        border-bottom: 1px solid #e5ebf0;
    }

    .yield-detail-metric:last-child {
        border-bottom: 0;
    }

    .yield-detail-instruction {
        display: none;
    }
}

/* Bond coupon and amortization components in the yield review table */
#yield-backtest-table {
    min-width: 2360px;
}

#yield-backtest-table th:nth-child(7) { width: 125px; }
#yield-backtest-table th:nth-child(8) { width: 110px; }
#yield-backtest-table th:nth-child(9),
#yield-backtest-table th:nth-child(10),
#yield-backtest-table th:nth-child(11),
#yield-backtest-table th:nth-child(12),
#yield-backtest-table th:nth-child(15) { width: 125px; }
#yield-backtest-table th:nth-child(13) { width: 108px; }
#yield-backtest-table th:nth-child(14) { width: 96px; }
#yield-backtest-table th:nth-child(16) { width: 76px; }
#yield-backtest-table th:nth-child(17) { width: 92px; }

#yield-backtest-table .yield-coupon {
    color: #17675e;
    font-weight: 700;
}

#yield-backtest-table .yield-amortization {
    font-weight: 700;
}

#yield-backtest-table .yield-amortization.is-positive {
    color: #156b43;
}

#yield-backtest-table .yield-amortization.is-negative {
    color: #a64525;
}

#yield-backtest-table .yield-row-anomaly .yield-coupon {
    color: #17675e;
    font-weight: 700;
}

#yield-backtest-table .yield-row-anomaly .yield-amortization.is-positive {
    color: #156b43;
}

#yield-backtest-table .yield-row-anomaly .yield-amortization.is-negative {
    color: #a64525;
}

#yield-backtest-table .yield-row-unknown .yield-coupon,
#yield-backtest-table .yield-row-unknown .yield-amortization {
    color: #7a828c;
    font-weight: 500;
}

/* Coupon and effective-interest breakdown inside the detail dialog */
.yield-detail-formula-caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px 0;
    color: #53716e;
    font-size: 10.5px;
    font-weight: 650;
    line-height: 1.35;
}

.yield-detail-formula-caption strong {
    color: #195c55;
    font-size: 12px;
    font-weight: 800;
}

.yield-detail-formula-caption span {
    text-align: right;
}

.yield-detail-bond-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.yield-detail-bond-meta span {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #dce8e5;
    border-radius: 8px;
    background: #f8fbfa;
    color: #50706c;
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

.yield-detail-bond-meta b {
    display: block;
    margin-bottom: 3px;
    color: #23665f;
    font-size: 10px;
    font-weight: 800;
}

.yield-detail-coupon-formula {
    background: linear-gradient(110deg, #f3faf8 0%, #fbfdfd 100%);
}

.yield-detail-coupon-formula .yield-detail-formula-results > div:last-child strong {
    color: #17675e;
}

.yield-detail-effective-formula {
    margin-top: 11px;
    background: linear-gradient(110deg, #f5f8fc 0%, #fbfdff 100%);
    border-color: #dbe5ef;
}

.yield-detail-effective-formula .yield-detail-formula-caption {
    color: #58708a;
}

.yield-detail-effective-formula .yield-detail-formula-caption strong {
    color: #275d89;
}

.yield-detail-effective-formula .yield-detail-formula-expression {
    border-color: #dbe5ef;
}

.yield-detail-effective-formula .yield-detail-formula-expression span {
    border-color: #d4e1ec;
}

.yield-detail-effective-formula .yield-detail-formula-results {
    border-color: #dbe5ef;
}

.yield-detail-effective-formula .yield-detail-formula-results > div {
    border-color: #dbe5ef;
}

.yield-detail-effective-formula .yield-detail-formula-results > div:last-child {
    background: rgba(48, 105, 155, 0.07);
}

.yield-detail-effective-formula .yield-detail-formula-results > div:last-child strong {
    color: #1f5d94;
}

.yield-detail-amortization-bridge {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin: 11px 0 0;
    padding: 11px;
    border: 1px solid #e5e2d7;
    border-radius: 9px;
    background: #fcfbf8;
}

.yield-detail-amortization-bridge > div {
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid #e7e4da;
    border-radius: 7px;
    background: #ffffff;
}

.yield-detail-amortization-bridge span {
    display: block;
    color: #7a786d;
    font-size: 10.5px;
    font-weight: 650;
}

.yield-detail-amortization-bridge strong {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: #31485b;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yield-detail-amortization-bridge > b {
    color: #8f8a7b;
    font-size: 17px;
    font-weight: 700;
}

.yield-detail-amortization-bridge .yield-detail-amortization-result {
    border-color: #e4d8c8;
    background: #fffdf9;
}

.yield-detail-amortization-bridge .yield-detail-amortization-result strong {
    color: #a04a2a;
}

@media (max-width: 820px) {
    .yield-detail-bond-meta {
        grid-template-columns: 1fr;
    }

    .yield-detail-amortization-bridge {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .yield-detail-amortization-bridge > b {
        display: none;
    }
}

@media (max-width: 560px) {
    .yield-detail-formula-caption {
        display: block;
    }

    .yield-detail-formula-caption span {
        display: block;
        margin-top: 3px;
        text-align: left;
    }
}


/* SAC fallback validation route column */
#yield-backtest-table th:nth-child(17) { width: 136px; }
#yield-backtest-table th:nth-child(18) { width: 92px; }

#yield-backtest-table .yield-validation-method {
    color: #315d76;
    font-size: 10.5px;
    font-weight: 700;
}

#yield-backtest-table .yield-row-unknown .yield-validation-method {
    color: #697481;
    font-weight: 600;
}

/* Compact hover help for the yield-validation ledger */
.yield-table-title {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-width: 0;
    gap: 6px;
}

.yield-table-title h3 {
    min-width: 0;
}

.yield-info-tooltip {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    z-index: 30;
}

.yield-info-tooltip-trigger {
    appearance: none;
    display: inline-grid;
    place-items: center;
    width: 19px;
    height: 19px;
    margin: 0;
    padding: 0;
    border: 1px solid #9fcfc5;
    border-radius: 50%;
    background: #f0faf7;
    color: #176f63;
    font: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: help;
}

.yield-info-tooltip-trigger:hover,
.yield-info-tooltip-trigger:focus-visible {
    border-color: #277f72;
    background: #e0f3ed;
    color: #0f5b50;
}

.yield-info-tooltip-trigger:focus-visible {
    outline: 2px solid rgba(31, 122, 108, 0.32);
    outline-offset: 2px;
}

.yield-info-tooltip-content {
    position: absolute;
    top: calc(100% + 8px);
    left: -7px;
    z-index: 40;
    box-sizing: border-box;
    width: min(540px, calc(100vw - 48px));
    padding: 10px 12px;
    border: 1px solid #b9ddd5;
    border-radius: 8px;
    background: #f8fcfb;
    box-shadow: 0 8px 20px rgba(18, 65, 59, 0.16);
    color: #46625e;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.55;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
    visibility: hidden;
}

.yield-info-tooltip-content > span {
    display: block;
}

.yield-info-tooltip-hint {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid #d7ebe6;
    color: #216b61;
    font-weight: 700;
}

.yield-info-tooltip:hover .yield-info-tooltip-content,
.yield-info-tooltip:focus-within .yield-info-tooltip-content {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}
