:root {
    --bg: #f6f7f3;
    --panel: #ffffff;
    --ink: #17201b;
    --muted: #667069;
    --line: #dfe4dc;
    --buy: #147d64;
    --buy-soft: #dceee8;
    --sell: #b5413a;
    --sell-soft: #f3dfdd;
    --accent: #2c5f8d;
    --accent-soft: #dbe8f2;
    --shadow: 0 12px 30px rgba(23, 32, 27, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

h1,
h2 {
    margin: 0;
    font-weight: 760;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 4.2rem);
    line-height: 0.96;
}

h2 {
    font-size: 1.05rem;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.date-card,
.summary-grid article,
.mover-list,
.notice {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.date-card {
    min-width: 190px;
    padding: 14px 16px;
    text-align: right;
}

.date-card span,
.summary-grid span,
.filters span,
.muted {
    color: var(--muted);
    font-size: 0.78rem;
}

.date-card strong {
    display: block;
    margin-top: 4px;
    font-size: 1.12rem;
}

.date-card small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.3;
}

.control-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    padding: 12px;
    background: #e9eee8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.segmented {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 4px;
    padding: 4px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.segmented a,
.filters button,
.text-link {
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
}

.segmented a.active {
    background: var(--accent);
    color: #ffffff;
}

.filters {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
}

.filters label {
    display: grid;
    gap: 4px;
}

.filters input,
.filters select,
.filters button {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
}

.filters input,
.filters select {
    padding: 0 10px;
}

.filters button {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.summary-grid article {
    min-height: 116px;
    padding: 18px;
}

.summary-grid strong {
    display: block;
    margin-top: 10px;
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1;
}

.summary-grid small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
    align-items: start;
    margin-bottom: 26px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 24px 0 10px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--panel);
}

.table-wrap {
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.flow-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
}


.category-table {
    min-width: 720px;
    font-size: 0.88rem;
}

.flow-table.category-table th,
.flow-table.category-table td {
    padding: 9px 10px;
}

.flow-table.category-table th {
    font-size: 0.7rem;
}

.category-table .category-link {
    max-width: 220px;
}

.flow-table th,
.flow-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}

.flow-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f2f5f0;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.sort-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.sort-link:hover {
    color: var(--accent);
}

.flow-table th:first-child,
.flow-table td:first-child,
.detail-table th:nth-child(2),
.detail-table td:nth-child(2),
.detail-table th:nth-child(3),
.detail-table td:nth-child(3) {
    text-align: left;
}

.flow-table tr:last-child td {
    border-bottom: 0;
}

.flow-table tr.selected td {
    background: var(--accent-soft);
}

.category-link {
    position: relative;
    z-index: 1;
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    font-weight: 750;
    text-decoration: none;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.bar {
    display: block;
    width: var(--bar-width);
    min-width: 3px;
    height: 7px;
    margin-top: 7px;
    border-radius: 999px;
}

.bar.buy {
    background: var(--buy);
}

.bar.sell {
    background: var(--sell);
}

.positive {
    color: var(--buy);
}

.negative {
    color: var(--sell);
}

.movers {
    display: grid;
    gap: 14px;
}

.mover-list {
    padding: 12px;
}

.mover-list h2 {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.mover-list a {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 7px 0;
    border-top: 1px solid var(--line);
    text-decoration: none;
}

.mover-list a:first-of-type {
    border-top: 0;
}

.mover-list strong {
    font-size: 0.86rem;
}

.mover-list span {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mover-list em {
    font-size: 0.82rem;
    font-style: normal;
    font-weight: 760;
}

.detail-table {
    min-width: 860px;
    font-size: 0.88rem;
}

.detail-table th,
.detail-table td {
    padding: 9px 10px;
}

.detail-table th {
    font-size: 0.7rem;
}


.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td,
.clickable-row:focus td {
    background: #f7faf5;
}

.row-primary-link {
    color: inherit;
    text-decoration: none;
}

.etf-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, 0.8fr);
    gap: 18px;
    align-items: stretch;
    margin: 24px 0 18px;
}

.etf-hero > div:first-child,
.detail-stats article,
.chart-wrap,
.legend-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.etf-hero > div:first-child {
    padding: 20px;
}

.etf-hero h2 {
    font-size: clamp(1.35rem, 2vw, 2rem);
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.detail-stats article {
    padding: 16px;
}

.detail-stats span,
.detail-stats small {
    color: var(--muted);
    font-size: 0.76rem;
}

.detail-stats strong {
    display: block;
    margin-top: 8px;
    font-size: 1.28rem;
}

.detail-stats small {
    display: block;
    margin-top: 6px;
}

.chart-wrap {
    overflow: auto;
    padding: 14px;
}

.flow-return-chart {
    display: block;
    width: 100%;
    min-width: 720px;
    height: auto;
}

.chart-axis {
    stroke: var(--line);
    stroke-width: 1;
}

.chart-buy {
    fill: var(--buy);
    opacity: 0.72;
}

.chart-sell {
    fill: var(--sell);
    opacity: 0.72;
}


.chart-hit-area {
    fill: transparent;
    pointer-events: all;
}


.chart-tooltip {
    position: fixed;
    z-index: 20;
    min-width: 190px;
    padding: 10px 12px;
    border: 1px solid #abc7ba;
    border-radius: 6px;
    background: #f7fff9;
    color: var(--ink);
    box-shadow: 0 10px 28px rgba(23, 32, 27, 0.18);
    font-size: 0.9rem;
    line-height: 1.3;
    pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
    display: block;
}

.chart-tooltip strong {
    color: var(--buy);
    font-size: 1rem;
}

.chart-tooltip span {
    margin-top: 4px;
    color: var(--muted);
}

.chart-return {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-label,
.chart-date {
    fill: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.return-label {
    fill: var(--accent);
}

.empty-chart {
    padding: 22px;
    color: var(--muted);
}

.legend-row {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 12px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 0.84rem;
}

.legend-box {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    vertical-align: -1px;
}

.legend-box.buy {
    background: var(--buy);
}

.legend-box.sell {
    background: var(--sell);
}

.legend-line {
    display: inline-block;
    width: 22px;
    height: 3px;
    margin-right: 6px;
    background: var(--accent);
    vertical-align: 3px;
}


.detail-table td:nth-child(2) {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-table td:nth-child(3) {
    max-width: 270px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notice {
    padding: 18px;
}

.notice p {
    margin: 8px 0 0;
}

.notice.error {
    border-color: #e3b7b3;
    background: #fff6f5;
}

@media (max-width: 1080px) {
    .etf-hero {
        grid-template-columns: 1fr;
    }

    .detail-stats {
        grid-template-columns: 1fr;
    }

    .control-band,
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .date-card {
        text-align: left;
    }

    .filters {
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-left: 0;
    }

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

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

@media (max-width: 620px) {
    .shell {
        width: min(100% - 20px, 1480px);
        padding-top: 18px;
    }

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

    .filters,
    .filters label,
    .filters input,
    .filters select,
    .filters button,
    .segmented {
        width: 100%;
    }

    .segmented a {
        flex: 1 1 0;
        text-align: center;
    }
}
