.metric-grid {
    align-items: stretch;
}

.metric-grid-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
    position: relative;
    min-height: 14.5rem;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 0.75rem;
    overflow: hidden;
    border: 1px solid #d7e0ee;
    border-radius: 1.55rem;
    padding: 1.15rem 1.15rem 1.25rem;
    background: #fff;
    box-shadow: 0 0.45rem 1.2rem rgba(16, 33, 60, 0.05);
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 0.34rem;
    background: #c7d7ef;
}

.metric-card > span {
    position: relative;
    z-index: 1;
    width: fit-content;
    padding: 0.32rem 0.55rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(199, 215, 239, 0.95);
    color: #29456d;
    font-size: 0.72rem;
}

.metric-card > strong {
    position: relative;
    z-index: 1;
    align-self: end;
    margin: 0;
    font-size: clamp(2.75rem, 6vw, 4.6rem);
    letter-spacing: -0.08em;
    line-height: 0.92;
}

.metric-source {
    position: relative;
    z-index: 1;
    width: fit-content;
    margin: 0;
    padding: 0.22rem 0.48rem;
    border-radius: 999px;
    background: #f8fbff;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 850;
}

.metric-change {
    position: relative;
    z-index: 1;
    width: fit-content;
    margin: 0;
    padding: 0.46rem 0.62rem 0.46rem 0.46rem;
    border: 0;
    box-shadow: 0 0.45rem 1.1rem rgba(16, 33, 60, 0.08);
}

.metric-change .metric-change-arrow {
    width: 1.65rem;
    height: 1.65rem;
    background: rgba(255, 255, 255, 0.82);
    font-size: 1.05rem;
}

.metric-change-label {
    color: inherit;
    opacity: 0.82;
}

.metric-card-up::after {
    background: #16a34a;
}

.metric-card-up {
    background: linear-gradient(180deg, #ffffff 0%, #f6fdf8 100%);
    border-color: rgba(22, 163, 74, 0.26);
}

.metric-card-up > strong {
    color: #166534;
}

.metric-card-down::after {
    background: #dc2626;
}

.metric-card-down {
    background: linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
    border-color: rgba(220, 38, 38, 0.24);
}

.metric-card-down > strong {
    color: #b42318;
}

.metric-card-flat::after {
    background: #94a3b8;
}

.metric-card-flat {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-color: rgba(148, 163, 184, 0.28);
}

.metric-card-flat > strong {
    color: #24324b;
}

.metric-change-up {
    background: #ecfdf3;
}

.history-chart-card {
    display: grid;
    gap: 1.25rem;
    padding: 1.35rem;
}

.history-chart-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.history-chart-header p,
.history-chart-note {
    color: var(--muted);
    margin: 0;
}

.history-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.history-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 0.86rem;
    font-weight: 800;
}

.history-chart-legend i {
    display: inline-block;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 999px;
}

.history-chart-scroll {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.history-chart-svg {
    display: block;
    min-width: 760px;
    width: 100%;
    height: auto;
}

.history-insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.history-insight-card {
    background: linear-gradient(150deg, #fff 0%, #f7fbff 100%);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: 0 0.45rem 1.35rem rgba(16, 33, 60, 0.06);
}

.history-insight-card span {
    color: var(--blue);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.76rem;
}

.history-insight-card strong {
    display: block;
    margin: 0.45rem 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.history-insight-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.history-insight-card dl div {
    padding: 0.75rem;
    border-radius: 0.9rem;
    background: #fff;
    border: 1px solid rgba(215, 224, 238, 0.8);
}

.history-insight-card dt {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.history-insight-card dd {
    margin: 0.1rem 0 0;
    font-weight: 900;
}

.history-insight-note {
    color: var(--muted);
    margin-bottom: 0;
}

.history-table-wrap {
    overflow-x: auto;
}

.history-comparison-table th,
.history-comparison-table td {
    white-space: nowrap;
}

.history-comment-pill {
    display: inline-flex;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--sand);
    border: 1px solid var(--line);
    color: var(--blue-dark);
    font-size: 0.82rem;
    font-weight: 850;
}

.interactive-data-table {
    display: grid;
    gap: 1rem;
}

.table-control-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-filter-button,
.table-sort-control select,
.table-row-button {
    font: inherit;
}

.table-filter-button {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.48rem 0.78rem;
    background: #fff;
    color: var(--blue-dark);
    font-weight: 850;
    cursor: pointer;
}

.table-filter-button:hover,
.table-filter-button.is-active {
    border-color: rgba(29, 95, 209, 0.4);
    background: var(--cyan);
    color: var(--blue);
}

.table-sort-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-weight: 850;
}

.table-sort-control select {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.48rem 0.7rem;
    background: #fff;
    color: var(--blue-dark);
    font-weight: 850;
}

.table-explainer {
    border: 1px solid rgba(29, 95, 209, 0.18);
    border-radius: 1.25rem;
    padding: 1.15rem;
    background: linear-gradient(150deg, #ffffff 0%, #f4f8ff 100%);
    box-shadow: 0 0.45rem 1.35rem rgba(16, 33, 60, 0.06);
}

.table-explainer span {
    display: block;
    color: var(--blue);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.table-explainer strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.35rem;
}

.table-explainer p {
    margin: 0.45rem 0 0;
    color: #334155;
}

.table-row-button {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--blue);
    font-weight: 900;
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.16em;
    cursor: pointer;
}

.interactive-table-row.is-selected td {
    background: #f4f8ff;
}

.hub-link-row,
.table-filter-button,
.table-row-button,
.table-sort-control select {
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.hub-link-row:hover,
.hub-link-row:focus-visible {
    border-color: rgba(29, 95, 209, 0.34);
    box-shadow: 0 0.9rem 2.1rem rgba(16, 33, 60, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.hub-link-row:focus-visible,
.table-filter-button:focus-visible,
.table-row-button:focus-visible,
.table-sort-control select:focus-visible {
    outline: 3px solid rgba(29, 95, 209, 0.24);
    outline-offset: 3px;
}

.interactive-table-row:hover td {
    background: #f8fbff;
}

.history-table-wrap {
    border: 1px solid rgba(215, 224, 238, 0.78);
    border-radius: 1.1rem;
    background: #fff;
}

.history-table-wrap .table-like {
    margin: 0;
}

@media (max-width: 1100px) {
    .metric-grid-four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .metric-card {
        min-height: 12.5rem;
    }

    .metric-grid-four,
    .history-chart-header,
    .history-insight-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .history-chart-legend {
        justify-content: flex-start;
    }

    .table-control-bar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-filter-button,
    .table-sort-control,
    .table-sort-control select {
        width: 100%;
    }

    .table-filter-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 560px) {
    .table-filter-group {
        grid-template-columns: 1fr;
    }

    .metric-card > strong {
        font-size: clamp(2.3rem, 18vw, 3.45rem);
    }

    .history-chart-svg {
        min-width: 640px;
    }
}
