:root {
    --bg-green: #0DAB67;
    --bg-orange: #FF9342;
    --bg-red: #FF5543;
    --badge-bg: #E64F24;
    --bar-color: #69D5FF;
    --page-bg: #e5e7eb;
    --panel: #ffffff;
    --soft-gray: #f4f5f7;
    --line: #d9d9d9;
    --text: #202124;
    --muted: #8a8f98;
    --green-soft: #dff6ec;
    --orange-soft: #fff0e5;
    --red-soft: #ffe7e4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--page-bg);
    overflow-x: hidden;
}

button {
    font: inherit;
}

.page-shell {
    width: min(980px, 100vw);
    margin: 0 auto;
    padding: 12px;
    background: var(--panel);
    overflow-x: hidden;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    margin: 0 0 6px;
    padding: 4px 16px;
    border-radius: 999px;
    background: var(--badge-bg);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
}

h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.08;
    font-weight: 900;
}

.meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.meta-line span {
    padding-right: 8px;
    border-right: 1px solid var(--line);
}

.meta-line span:last-child {
    border-right: 0;
}

.summary-card {
    width: 238px;
    align-self: stretch;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    background: #fff;
}

.summary-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
    color: #4f5967;
    font-size: 12px;
    font-weight: 900;
}

.summary-title::after {
    content: "低估 → 高估";
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.summary-bar {
    display: flex;
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: var(--soft-gray);
}

.summary-bar-segment {
    min-width: 0;
    height: 100%;
}

.summary-bar-segment.cheap {
    background: var(--bg-green);
}

.summary-bar-segment.normal {
    background: var(--bg-orange);
}

.summary-bar-segment.expensive {
    background: var(--bg-red);
}

.summary-counts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.summary-cell {
    min-width: 0;
    border-radius: 8px;
    padding: 6px 7px;
}

.summary-cell span {
    display: block;
    font-size: 10px;
    color: #60656f;
}

.summary-cell strong {
    display: block;
    margin-top: 1px;
    font-size: 20px;
    line-height: 1;
    font-weight: 900;
}

.summary-cell.cheap {
    background: var(--green-soft);
}

.summary-cell.normal {
    background: var(--orange-soft);
}

.summary-cell.expensive {
    background: var(--red-soft);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
}

.segmented {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--soft-gray);
}

.segmented-button {
    min-width: 78px;
    border: 0;
    padding: 7px 12px;
    background: transparent;
    color: #555b63;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.segmented-button.active {
    background: var(--badge-bg);
    color: #fff;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
}

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

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 2px;
}

.dot.cheap {
    background: var(--bg-green);
}

.dot.normal {
    background: var(--bg-orange);
}

.dot.expensive {
    background: var(--bg-red);
}

.content {
    display: grid;
    gap: 10px;
}

.loading-panel,
.empty-panel {
    padding: 28px;
    border-radius: 12px;
    background: var(--soft-gray);
    text-align: center;
    color: var(--muted);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 8px;
    padding: 9px 12px;
    border: 1px solid #d5dbe5;
    border-left: 6px solid var(--badge-bg);
    border-radius: 8px;
    color: #202124;
    background: linear-gradient(90deg, #fff5ef 0%, #ffffff 78%);
    font-size: 17px;
    font-weight: 900;
    line-height: 1.15;
}

.section-title::after {
    content: "";
    height: 2px;
    flex: 1;
    border-radius: 999px;
    background: #d5dbe5;
}

.valuation-list {
    display: grid;
    gap: 7px;
}

.valuation-row {
    display: grid;
    grid-template-columns: minmax(152px, 190px) minmax(260px, 1fr) 196px;
    gap: 10px;
    align-items: center;
    min-height: 92px;
    padding: 8px 9px;
    border: 1px solid #eeeeee;
    border-left-width: 8px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.valuation-row.zone-cheap {
    border-left-color: var(--bg-green);
}

.valuation-row.zone-normal {
    border-left-color: var(--bg-orange);
}

.valuation-row.zone-expensive {
    border-left-color: var(--bg-red);
}

.identity,
.axis-panel,
.side-panel {
    min-width: 0;
}

.name-line {
    display: block;
    min-width: 0;
}

.index-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 16px;
    font-weight: 900;
    line-height: 1.18;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.subline {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.metric-note {
    color: #4f5967;
}

.status-compare {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    gap: 5px;
    align-items: center;
    margin-top: 6px;
    padding: 3px 8px;
    border: 1px solid #e8dfd6;
    border-radius: 7px;
    background: #fffaf5;
    color: #6f4f1e;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}

.status-compare span {
    flex: 0 0 auto;
}

.current-value {
    display: block;
    margin-top: 7px;
}

.current-value strong {
    font-size: 26px;
    line-height: 1;
    font-weight: 900;
    color: var(--text);
    transition: color 0.2s ease;
}

.current-value.zone-cheap strong {
    color: #078955;
}

.current-value.zone-normal strong {
    color: #d56f1d;
}

.current-value.zone-expensive strong {
    color: #cd362d;
}

.axis-labels {
    position: relative;
    height: 25px;
    margin: 0 1px 4px;
    font-size: 10px;
    color: #536071;
}

.axis-label {
    position: absolute;
    top: 0;
    width: 58px;
    transform: translateX(-50%);
    text-align: center;
    white-space: normal;
    line-height: 1.08;
}

.axis-label:first-child {
    transform: translateX(0);
    text-align: left;
}

.axis-label:last-child {
    transform: translateX(-100%);
    text-align: right;
}

.axis-label b {
    display: block;
    color: #222;
    font-size: 11px;
}

.axis-track {
    position: relative;
    height: 24px;
    overflow: visible;
    border-radius: 3px;
    background: var(--bg-orange);
    margin-inline: 1px;
}

.axis-segment {
    position: absolute;
    top: 0;
    bottom: 0;
}

.axis-segment.cheap {
    left: 0;
    border-radius: 3px 0 0 3px;
    background: var(--bg-green);
}

.axis-segment.normal {
    background: var(--bg-orange);
}

.axis-segment.expensive {
    right: 0;
    border-radius: 0 3px 3px 0;
    background: var(--bg-red);
}

.axis-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.62);
    z-index: 2;
    pointer-events: none;
}

.threshold-line {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.16);
    transform: translateX(-50%);
    z-index: 3;
}

.current-marker {
    position: absolute;
    top: 50%;
    z-index: 4;
    min-width: 35px;
    max-width: 60px;
    padding: 3px 7px 3px 8px;
    transform: translate(calc(-100% - 5px), -50%);
    border: 1px solid var(--marker-stroke);
    border-radius: 5px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 46%),
        var(--marker-fill);
    color: #ffffff;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.05;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.72),
        0 1px 2px rgba(15, 23, 42, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.12);
    white-space: nowrap;
}

.current-marker::before {
    content: "";
    position: absolute;
    right: -6px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid var(--marker-stroke);
    transform: translateY(-50%);
}

.current-marker::after {
    content: "";
    position: absolute;
    right: -4px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid var(--marker-fill);
    transform: translateY(-50%);
}

.current-marker.zone-cheap {
    --marker-fill: #078955;
    --marker-stroke: #066f47;
}

.current-marker.zone-normal {
    --marker-fill: #d56f1d;
    --marker-stroke: #ad5510;
}

.current-marker.zone-expensive {
    --marker-fill: #cd362d;
    --marker-stroke: #a62620;
}

.current-marker.edge-left {
    transform: translate(5px, -50%);
    padding: 3px 8px 3px 7px;
}

.current-marker.edge-right {
    transform: translate(calc(-100% - 5px), -50%);
}

.current-marker.edge-left::before {
    right: auto;
    left: -6px;
    border-left: 0;
    border-right: 6px solid var(--marker-stroke);
}

.current-marker.edge-left::after {
    right: auto;
    left: -4px;
    border-left: 0;
    border-right: 4px solid var(--marker-fill);
}

.side-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}

.distance-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}

.funds {
    display: contents;
}

.distance-card,
.fund-card {
    min-width: 0;
    padding: 4px 5px 4px 6px;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    background: #fafafa;
    overflow: hidden;
}

.distance-card {
    position: relative;
    border-left-width: 3px;
    border-left-style: solid;
}

.distance-card::after {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    pointer-events: none;
    z-index: 1;
}

.distance-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--fill, 0%);
    border-radius: 5px;
    opacity: 0.26;
    pointer-events: none;
    transition: width 240ms ease;
    z-index: 0;
}

.distance-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
}

.distance-card.tone-positive {
    border-left-color: #c04b4b;
    background: #fff6f5;
}

.distance-card.tone-negative {
    border-left-color: #0a9871;
    background: #f3fbf7;
}

.distance-card.tone-flat {
    border-left-color: #98a2ad;
    background: #f6f7f9;
}

.distance-card.tone-deep-green {
    border-left-color: #0a8f5f;
    background: #e8f8f0;
}

.distance-card.tone-normal-yellow {
    border-left-color: #d58a1d;
    background: #fff8ed;
}

.distance-card.tone-expensive-red {
    border-left-color: #d44030;
    background: #fff2f0;
}

.distance-card.tone-deep-red {
    border-left-color: #a82020;
    background: #fce8e8;
}

.distance-card.tone-positive .distance-fill {
    background: #c04b4b;
}

.distance-card.tone-negative .distance-fill {
    background: #0a9871;
}

.distance-card.tone-flat .distance-fill {
    background: #98a2ad;
}

.distance-card.tone-deep-green .distance-fill {
    background: #0a8f5f;
}

.distance-card.tone-normal-yellow .distance-fill {
    background: #d58a1d;
}

.distance-card.tone-expensive-red .distance-fill {
    background: #d44030;
}

.distance-card.tone-deep-red .distance-fill {
    background: #a82020;
}

.distance-card.is-full .distance-fill {
    border-radius: 5px;
}

.distance-card.is-missing .distance-fill {
    opacity: 0;
}

.distance-card.is-fill-inactive .distance-fill {
    opacity: 0;
}

.distance-card .distance-label,
.fund-card span {
    position: relative;
    z-index: 2;
    display: block;
    overflow: hidden;
    color: #757b84;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.distance-card .distance-value {
    position: relative;
    z-index: 2;
    display: block;
    overflow: hidden;
    margin-top: 1px;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.08;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.distance-card.tone-positive .distance-value {
    color: #c04b4b;
}

.distance-card.tone-negative .distance-value {
    color: #0a9871;
}

.distance-card.tone-flat .distance-value {
    color: #435166;
}

.distance-card.tone-deep-green .distance-value {
    color: #0a7a50;
}

.distance-card.tone-normal-yellow .distance-value {
    color: #b87010;
}

.distance-card.tone-expensive-red .distance-value {
    color: #c0392b;
}

.distance-card.tone-deep-red .distance-value {
    color: #8b1a1a;
}

.distance-card .distance-hint {
    position: relative;
    z-index: 2;
    display: block;
    overflow: hidden;
    margin-top: 1px;
    color: #6f7682;
    font-size: 9px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.distance-card .distance-copy {
    position: relative;
    z-index: 2;
    display: block;
    overflow: hidden;
    color: #757b84;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.distance-card .distance-pill {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    margin-top: 2px;
    padding: 1px 5px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
}

.distance-card .distance-pill-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--fill, 0%);
    border-radius: 10px;
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
}

.distance-card.tone-positive .distance-pill-fill {
    background: #c04b4b;
}

.distance-card.tone-negative .distance-pill-fill {
    background: #0a9871;
}

.distance-card.tone-flat .distance-pill-fill {
    background: #98a2ad;
}

.distance-card.tone-deep-green .distance-pill-fill {
    background: #0a8f5f;
}

.distance-card.tone-normal-yellow .distance-pill-fill {
    background: #d58a1d;
}

.distance-card.tone-expensive-red .distance-pill-fill {
    background: #d44030;
}

.distance-card.tone-deep-red .distance-pill-fill {
    background: #a82020;
}

.distance-card .distance-pill strong {
    position: relative;
    z-index: 1;
    font-weight: 700;
}

.distance-card.tone-positive .distance-pill strong {
    color: #c04b4b;
}

.distance-card.tone-negative .distance-pill strong {
    color: #0a9871;
}

.distance-card.tone-flat .distance-pill strong {
    color: #435166;
}

.distance-card.tone-deep-green .distance-pill strong {
    color: #0a7a50;
}

.distance-card.tone-normal-yellow .distance-pill strong {
    color: #b87010;
}

.distance-card.tone-expensive-red .distance-pill strong {
    color: #c0392b;
}

.distance-card.tone-deep-red .distance-pill strong {
    color: #8b1a1a;
}

.distance-card.is-plain .distance-copy {
    color: #9aa3ad;
}

.distance-card.is-focus-distance {
    box-shadow: 0 0 0 1.5px rgba(59, 91, 219, 0.25);
}

.fund-card strong {
    display: block;
    overflow: hidden;
    margin-top: 2px;
    font-size: 14px;
    line-height: 1.08;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 820px) {
    body {
        background: #f5f6f8;
    }

    .page-shell {
        width: 100%;
        padding: 10px;
        background: #f5f6f8;
    }

    .hero {
        grid-template-columns: 1fr;
        gap: 10px;
        align-items: start;
        padding-bottom: 8px;
        border-bottom: 0;
    }

    .eyebrow {
        margin-bottom: 5px;
        padding: 3px 12px;
        font-size: 11px;
    }

    h1 {
        font-size: 23px;
        line-height: 1.15;
    }

    .meta-line {
        gap: 6px;
        font-size: 12px;
    }

    .summary-card {
        width: 100%;
        border-radius: 10px;
    }

    .summary-title {
        font-size: 13px;
    }

    .summary-cell span {
        font-size: 11px;
    }

    .summary-cell strong {
        font-size: 22px;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .segmented {
        width: 100%;
    }

    .segmented-button {
        flex: 1;
        padding: 8px 10px;
        font-size: 13px;
    }

    .legend {
        width: 100%;
        justify-content: space-between;
        padding-inline: 2px;
        font-size: 12px;
    }

    .content {
        gap: 9px;
    }

    .section-title {
        margin: 10px 0 8px;
        padding: 8px 10px;
        border-left-width: 5px;
        font-size: 16px;
    }

    .valuation-list {
        gap: 9px;
    }

    .valuation-row {
        grid-template-columns: 1fr;
        gap: 10px;
        min-height: 0;
        padding: 10px;
        border-left-width: 6px;
        border-radius: 10px;
    }

    .identity {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 10px;
        align-items: center;
    }

    .name-line,
    .subline {
        grid-column: 1;
    }

    .index-name {
        font-size: 19px;
        line-height: 1.22;
    }

    .subline {
        margin-top: 2px;
        font-size: 12px;
    }

    .status-compare {
        grid-column: 1 / -1;
        margin-top: 2px;
        font-size: 11px;
    }

    .current-value {
        grid-column: 2;
        grid-row: 1 / span 2;
        margin: 0;
        text-align: right;
    }

    .current-value strong {
        font-size: 32px;
        letter-spacing: 0;
    }

    .axis-labels {
        height: 34px;
        margin-bottom: 6px;
        font-size: 11px;
    }

    .axis-label {
        width: 62px;
        line-height: 1.12;
    }

    .axis-label b {
        font-size: 12px;
    }

    .axis-track {
        height: 30px;
        border-radius: 4px;
    }

    .current-marker {
        min-width: 40px;
        max-width: 68px;
        padding: 3px 7px;
        font-size: 13px;
    }

    .side-panel {
        gap: 6px;
    }

    .distance-card,
    .fund-card {
        padding: 6px 7px;
        border-radius: 7px;
    }

    .distance-card .distance-label,
    .fund-card span {
        font-size: 11px;
    }

    .distance-card .distance-value {
        font-size: 15px;
    }

    .distance-card .distance-hint {
        font-size: 10px;
    }

    .fund-card strong {
        font-size: 17px;
    }
}

@media (max-width: 420px) {
    .page-shell {
        padding: 8px;
    }

    .meta-line span {
        padding-right: 6px;
    }

    h1 {
        font-size: 22px;
    }

    .index-name {
        font-size: 18px;
    }

    .axis-label {
        width: 55px;
        font-size: 10px;
    }

    .current-marker {
        min-width: 54px;
        max-width: 78px;
        font-size: 14px;
    }

    .distance-card,
    .fund-card {
        padding: 5px 6px;
    }

    .distance-card .distance-value {
        font-size: 14px;
    }

    .fund-card strong {
        font-size: 16px;
    }
}

/* ── Mobile export layout ── */
body.mobile-export {
    background: #ffffff;
}

body.mobile-export .page-shell {
    width: 100%;
    max-width: 100%;
}

/* ── Footer ── */
.page-footer {
    margin-top: 32px;
    padding: 16px 0 8px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.page-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.feedback-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 7px 18px;
    border-radius: 999px;
    background: #f4f5f7;
    color: #202124;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--line);
    transition: all 0.15s ease;
    cursor: pointer;
}

.feedback-btn:hover {
    background: #202124;
    color: #ffffff;
    border-color: #202124;
}
