/* Valuation tab. Loaded only on REIT pages that include it. Scoped to .valuation-shell. */

.valuation-shell {
    width: 100%;
    padding: 0 16px;
    color: var(--ink-strong);
    box-sizing: border-box;
}

.valuation-shell h2.valuation-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-strong);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-soft);
}

/* ----- NAV strip, NAV bridge, K-REIT P/NAV comparison (2026-11-15) -----
   Same register as the 재무정보 tab: the strip reuses .financial-summary-grid /
   .financial-summary-card (reit-common.css), the bridge reuses .key-metrics-group /
   .key-metrics-table (style.css, the 개요 tab's 시장 지표). Flat sections, square
   hairlines, no card shell, no shadow. Only the comparison plot is drawn here. */
.valuation-shell .nav-strip {
    margin-bottom: 24px;
}

.valuation-shell .nav-strip-sub {
    color: var(--ink-muted);
}

.nav-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 40px;
    margin-bottom: 24px;
}

@media (max-width: 991px) {
    .nav-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

.nav-detail-grid > [hidden] {
    display: none;
}

.nav-bridge .key-metrics-table td {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.nav-bridge .nav-bridge-total th,
.nav-bridge .nav-bridge-total td {
    color: var(--ink-strong);
    font-weight: 700;
}

.nav-note {
    margin: 8px 12px 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink-muted);
    word-break: keep-all;
}

.nav-peer-plot {
    position: relative;
    margin: 16px 12px 0;
}

.nav-peer-field {
    position: relative;
    border-bottom: 1px solid var(--border-soft);
}

/* Lines sit in the plot, not the field: each runs past the axis and the axis
   numbers and stops at the top of its own name in .nav-peer-refs (18px tall). */
.nav-peer-line {
    position: absolute;
    bottom: 17px;
    width: 0;
}

.nav-peer-line--median {
    border-left: 1px solid var(--ink-muted);
}

.nav-peer-line--nav {
    border-left: 1px dashed var(--ink-muted);
}

.nav-peer-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    /* Context, so translucent (2026-11-15): this REIT's own dot in brand
       is the one to find, and where two neighbours overlap the overlap darkens. */
    background: var(--ink-muted);
    opacity: 0.4;
    /* Centred on its point; layoutSwarm (valuation_charts.js) sets `top`. */
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Laid out at the peer size like every other dot, so it can overlap a neighbour
   by a pixel or two; the ring keeps it reading as on top. */
.nav-peer-dot--self {
    width: 11px;
    height: 11px;
    background: var(--brand);
    box-shadow: 0 0 0 1.5px var(--card-surface);
    opacity: 1;
    z-index: 1;
}

.nav-peer-self-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-deep);
    white-space: nowrap;
}

.nav-peer-self-label--start { transform: none; }
.nav-peer-self-label--end   { transform: translateX(-100%); }

.nav-peer-axis {
    position: relative;
    height: 22px;
}

.nav-peer-tick {
    position: absolute;
    top: 6px;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.nav-peer-tick--start { transform: none; }
.nav-peer-tick--end   { transform: translateX(-100%); }

/* Names of the median and NAV lines, under the axis numbers, where each line ends. */
.nav-peer-refs {
    position: relative;
    height: 18px;
}

.nav-peer-ref {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-muted);
    white-space: nowrap;
}

.nav-peer-ref--start { transform: none; }
.nav-peer-ref--end   { transform: translateX(-100%); }

/* ----- Sub-tab pills ----- */
.sub-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 18px;
    overflow-x: auto;
}

.sub-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.12s, border-bottom-color 0.12s;
}

.sub-tab-btn:hover {
    color: var(--ink-strong);
}

.sub-tab-btn.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.sub-tab-panel[hidden] {
    display: none !important;
}

/* Summary/Income section temporarily hidden below the value bar while its
   replacement is decided (2026-08-30). Remove this rule to restore. */
#valuationSection .sub-tabs,
#valuationSection .sub-tab-panel {
    display: none;
}

/* ----- KPI tiles ----- */
/* Single dense strip divided by hairlines, not individual cards — terminal-
   density register (see DESIGN.md "Tool Pages: Terminal-Density
   Exception"). The 1px `gap` + `background: var(--border-soft)` combo lets
   the container color show through as thin dividers between tiles, both
   horizontally and (if tiles wrap to a second row) vertically. */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    margin-bottom: 18px;
    background: var(--border-soft);
    border: 1px solid var(--border-soft);
}

/* Book-equity REITs render no tiles at all (renderKpiTiles returns early), and an
   empty .kpi-grid is not invisible: it still paints its own 1px border-soft frame
   and reserves the 18px margin, leaving a stray hairline where the row used to be. */
.kpi-grid:empty {
    display: none;
}

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

.kpi-tile {
    background: var(--surface-strong);
    border: none;
    border-radius: 0;
    padding: 14px 16px;
}

.kpi-tile-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
    margin: 0 0 6px;
}

.kpi-tile-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink-strong);
    margin: 0;
    line-height: 1.1;
}

.kpi-tile-sub {
    font-size: 11px;
    color: var(--ink-muted);
    margin: 4px 0 0;
}

.kpi-tile-sub-pos { color: var(--brand-deep); }
.kpi-tile-sub-neg { color: var(--market-up); }

/* .kpi-tile--note REMOVED 2026-08-02 along with its only consumer. Book-equity
   REITs now render an empty KPI row rather than a placeholder tile explaining
   the absence -- the NAV above it is already complete on its own. */

/* ----- Plotly chart cards ----- */
.val-chart-card {
    background: var(--surface-strong);
    border: 1px solid var(--border-soft);
    border-radius: 24px;
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.val-chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-strong);
    margin: 0 0 4px;
}

.val-chart-sub {
    font-size: 12px;
    color: var(--ink-muted);
    margin: 0 0 12px;
}

.val-chart-target {
    width: 100%;
    max-width: 100%;
    min-height: 240px;
    overflow: hidden;
}

.val-chart-target-bar {
    min-height: 160px;
}

.ncf-asset-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 10px;
}

.ncf-asset-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) 56px 112px;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--ink-strong);
}

.ncf-asset-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.ncf-asset-name-wrap {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.ncf-asset-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ncf-asset-preferred {
    font-size: 10px;
    color: var(--brand-deep);
    background: var(--brand-soft);
    border: 1px solid var(--border-soft);
    padding: 1px 6px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: help;
}

.ncf-asset-pct,
.ncf-asset-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ncf-asset-pct {
    color: var(--ink-muted);
}

@media (max-width: 640px) {
    .ncf-asset-row {
        grid-template-columns: 10px minmax(0, 1fr) 48px;
    }

    .ncf-asset-value {
        grid-column: 2 / -1;
        text-align: left;
        color: var(--ink-muted);
    }
}

.ncf-chart-tooltip {
    position: fixed;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translate(14px, -50%);
    padding: 8px 12px;
    background: var(--ink-strong);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
    font-size: 12px;
    color: var(--surface-strong);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    white-space: nowrap;
}

.ncf-chart-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

.ncf-chart-tooltip-swatch {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.ncf-chart-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ncf-chart-tooltip-name {
    font-weight: 600;
    color: var(--surface-strong);
}

.ncf-chart-tooltip-value {
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
}

.ncf-chart-tooltip-value em {
    margin-left: 6px;
    font-style: normal;
    color: var(--brand-bright);
}

.val-chart-target-tall {
    min-height: 360px;
}

.val-empty-state {
    display: flex;
    min-height: 240px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: 1px dashed var(--text-tertiary);
    border-radius: 24px;
    background: var(--surface-tint);
    color: var(--ink-muted);
    font-size: 13px;
    text-align: center;
}

.val-chart-target .js-plotly-plot,
.val-chart-target .plot-container,
.val-chart-target .svg-container {
    width: 100% !important;
    max-width: 100% !important;
}

.val-chart-card {
    min-width: 0;  /* allow grid item to shrink below content size */
    overflow: hidden;
}

/* ----- Legacy card fade — keep hidden inside subtabs for fallback ----- */
.valuation-legacy-hidden { display: none !important; }

/* Re-style the (legacy) Stabilized Pro Forma card when it lives inside the proforma sub-tab */
.sub-tab-panel .card {
    border: 1px solid var(--border-soft) !important;
    box-shadow: none !important;
}

.sub-tab-panel .card-body { padding: 16px 18px; }
.sub-tab-panel .card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ----- Pro Forma income table ----- */
.proforma-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.proforma-table thead th {
    background: var(--table-header-bg);
    height: var(--table-header-height);
    vertical-align: middle;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
    padding: 0 6px;
    border-bottom: 2px solid var(--border-soft);
    white-space: nowrap;
    font-weight: 600;
}

.proforma-table thead th:first-child { text-align: left; }

.proforma-table tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-soft);
    font-variant-numeric: tabular-nums;
}

.proforma-table tbody tr:nth-child(odd) { background: var(--surface-tint); }
.proforma-table tbody tr:hover { background: var(--highlight-soft); }

.proforma-total-row td {
    border-top: 2px solid var(--border-soft) !important;
    font-weight: 700;
    background: var(--surface-tint) !important;
}

/* ----- Vertical (per-asset stacked) Pro Forma ----- */
/* Each asset becomes its own mini income statement; blocks stack vertically.
   Detail rows are always visible so the table reads like a compact financial model. */
.proforma-asset-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.proforma-asset-block {
    border: 1px solid var(--border-soft);
    border-radius: 24px;
    padding: 12px 14px 14px;
    background: var(--surface-strong);
}

.proforma-asset-block-total {
    background: var(--surface-tint);
    border-color: var(--border-soft);
}

.proforma-asset-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
}

.proforma-asset-name {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-strong);
}

.proforma-asset-caprate {
    font-size: 11px;
    color: var(--ink-muted);
    background: var(--surface-tint);
    border: 1px solid var(--border-soft);
    padding: 2px 8px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.proforma-caprate-interpretable {
    cursor: pointer;
    border-style: dashed;
    transition: background 0.15s, color 0.15s;
}
.proforma-caprate-interpretable:hover {
    background: var(--highlight-soft);
    color: var(--brand-deep);
    border-color: var(--brand-deep);
}
.proforma-caprate-interpretable::after {
    content: ' ↗';
    font-size: 10px;
    opacity: 0.7;
}

/* SHAP modal */
.shap-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.shap-modal-box {
    background: var(--surface-strong);
    border-radius: 24px;
    width: min(600px, 94vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
}
.shap-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.shap-modal-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--ink-strong);
}
.shap-modal-asset {
    font-size: 12px;
    color: var(--ink-muted);
    flex: 1;
}
.shap-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--ink-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.shap-modal-close:hover { color: var(--ink-strong); }
.shap-modal-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--surface-tint);
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    flex-shrink: 0;
}
.shap-arrow { color: var(--text-tertiary); }
.shap-model-badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--border-soft);
    color: var(--ink-muted);
    padding: 2px 8px;
    border-radius: 999px;
}
.shap-interaction-note {
    padding: 6px 18px;
    font-size: 11px;
    color: var(--ink-muted);
    background: var(--surface-tint);
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.shap-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.shap-table-wrap {
    overflow-y: auto;
    flex: 1;
    padding: 8px 18px;
}
.shap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.shap-table thead th {
    position: sticky;
    top: 0;
    /* Opaque (sticky header scrolls over rows) and on the standard header
       fill token instead of plain white. */
    background: var(--table-header-bg);
    height: var(--table-header-height);
    vertical-align: middle;
    font-size: 11px;
    color: var(--ink-muted);
    font-weight: 600;
    padding: 0 4px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
}
.shap-table thead th:last-child { text-align: right; }
.shap-row td { padding: 5px 4px; vertical-align: middle; border-bottom: 1px solid var(--border-soft); }
.shap-interaction td { background: var(--surface-tint); }
.shap-feat-label {
    width: 38%;
    color: var(--ink-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.shap-bar-cell { width: 47%; padding: 5px 8px; }
.shap-bar-wrap {
    position: relative;
    height: 12px;
    background: var(--surface-tint);
    border-radius: 3px;
    overflow: hidden;
}
.shap-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}
.shap-bar-mid {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--text-tertiary);
}
.shap-val {
    width: 15%;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.shap-pos { color: var(--market-up); }
.shap-neg { color: var(--market-down); }
.shap-footnote {
    font-size: 10px;
    color: var(--text-tertiary);
    padding: 8px 18px 12px;
    margin: 0;
    flex-shrink: 0;
    border-top: 1px solid var(--border-soft);
}

.proforma-asset-block-table {
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.proforma-table.proforma-vertical tbody tr:nth-child(odd) { background: transparent; }
.proforma-table.proforma-vertical tbody tr:hover td { background: var(--surface-tint); }

.proforma-table.proforma-vertical .proforma-line-label {
    text-align: left;
    white-space: nowrap;
    color: var(--ink-strong);
}

.proforma-table.proforma-vertical tbody td {
    height: 36px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border-soft);
}

.proforma-table.proforma-vertical tbody td.text-end {
    text-align: right;
    font-weight: 500;
    color: var(--ink-strong);
    font-variant-numeric: tabular-nums;
}

.proforma-table.proforma-vertical .proforma-subtotal-row td {
    border-top: 1px solid var(--text-tertiary);
    border-bottom: 1px solid var(--border-soft);
    font-weight: 700;
    background: var(--border-soft);
}

.proforma-table.proforma-vertical .proforma-subtotal-row td.text-end {
    font-weight: 800;
}

.proforma-table.proforma-vertical .proforma-deduct-row .proforma-line-label {
    color: var(--market-up);
}

.proforma-table.proforma-vertical .proforma-deduct-row td {
    color: var(--market-up);
    background: var(--surface-strong);
}

.proforma-table.proforma-vertical .proforma-deduct-level-1 .proforma-line-label {
    padding-left: 26px;
}

.proforma-table.proforma-vertical .proforma-deduct-level-2 .proforma-line-label {
    padding-left: 48px;
    color: var(--market-up);
    font-size: 12px;
}

.proforma-table.proforma-vertical .proforma-deduct-level-2 td {
    color: var(--market-up);
}

.proforma-table.proforma-vertical .proforma-derived-row td {
    border-top: 2px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    font-weight: 800;
    background: var(--highlight-soft);
}

.proforma-table.proforma-vertical .proforma-derived-row td.text-end {
    font-weight: 900;
}
