:root {
    --hi-green: var(--int-green);
    --hi-text: var(--int-text);
    --hi-muted: var(--int-muted);
    --hi-line: var(--int-line);
    --hi-line-strong: var(--int-line-strong);
    --hi-panel: var(--int-panel);
    --hi-panel-2: var(--int-panel-2);
}

body { background: var(--int-bg); color: var(--hi-text); }
.hi-workspace { padding: 1rem 0 2.5rem; }

.hi-stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid var(--hi-line-strong);
    background: var(--hi-panel);
}
.hi-stat-strip > div {
    display: grid;
    gap: .1rem;
    padding: .82rem 1rem;
    border-right: 1px solid var(--hi-line);
}
.hi-stat-strip > div:last-child { border-right: 0; }
.hi-stat-strip span { color: #75807a; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; }
.hi-stat-strip strong { color: #fff; font-size: 1.15rem; }
.hi-stat-strip small { color: var(--hi-muted); font-size: .66rem; }

.hi-research-controls {
    display: grid;
    grid-template-columns: 170px 130px minmax(260px, 1fr);
    gap: .65rem;
    align-items: end;
    margin-top: .75rem;
    padding: .72rem .8rem;
    border: 1px solid var(--hi-line-strong);
    background: var(--hi-panel);
}
.hi-research-controls.has-custom-range { grid-template-columns: 170px 110px 110px 130px minmax(260px, 1fr); }
.hi-custom-season[hidden] { display: none; }
.hi-research-controls label {
    display: block;
    margin-bottom: .28rem;
    color: #76807b;
    font-size: .62rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.hi-research-controls input,
.hi-research-controls select {
    width: 100%;
    min-height: 38px;
    padding: .48rem .62rem;
    border: 1px solid var(--hi-line-strong);
    border-radius: 3px;
    background: #0e1314;
    color: var(--hi-text);
    font: inherit;
    font-size: .79rem;
}

.hi-tabs {
    display: flex;
    overflow-x: auto;
    margin-top: .55rem;
    border: 1px solid var(--hi-line-strong);
    background: #0f1516;
    scrollbar-width: thin;
}
.hi-tabs button {
    flex: 0 0 auto;
    padding: .63rem .9rem .58rem;
    border: 0;
    border-right: 1px solid var(--hi-line);
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #9da7a2;
    font-size: .73rem;
    font-weight: 780;
    white-space: nowrap;
}
.hi-tabs button:hover { color: #fff; background: rgba(255,255,255,.025); }
.hi-tabs button.is-active {
    border-bottom-color: var(--hi-green);
    background: rgba(118,213,100,.055);
    color: #fff;
}

.hi-tab-panel {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 130ms ease, transform 130ms ease;
}
.hi-tab-panel.is-switching {
    opacity: 0;
    transform: translateY(3px);
}

.hi-highlight {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto minmax(220px, auto);
    gap: 1.1rem;
    align-items: center;
    min-height: 66px;
    margin-top: .55rem;
    padding: .72rem .9rem;
    border: 1px solid var(--hi-line-strong);
    background: linear-gradient(180deg, #141a1b, #101516);
}
.hi-highlight[hidden] { display: none; }
.hi-highlight__label { color: var(--hi-green); font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hi-highlight__identity { display: grid; gap: .1rem; }
.hi-highlight__identity strong { color: #fff; font-size: .92rem; }
.hi-highlight__identity span,
.hi-highlight__score small { color: var(--hi-muted); font-size: .67rem; }
.hi-highlight__score {
    display: grid;
    grid-template-columns: auto auto;
    gap: .1rem .6rem;
    align-items: baseline;
    padding-left: .9rem;
    border-left: 1px solid var(--hi-line);
}
.hi-highlight__score span { color: #7f8984; font-size: .62rem; text-transform: uppercase; }
.hi-highlight__score strong { color: #fff; font-size: 1.2rem; }
.hi-highlight__score small { grid-column: 1 / -1; }
.hi-highlight__tags { display: flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; }

.hi-view-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-top: .55rem;
    padding: .62rem .8rem;
    border: 1px solid var(--hi-line-strong);
    border-bottom: 0;
    background: #111718;
}
.hi-view-heading h2 { margin: 0; color: #fff; font-size: .86rem; font-weight: 800; }
.hi-view-heading p { margin: .16rem 0 0; color: var(--hi-muted); font-size: .69rem; }
.hi-view-heading > strong { color: var(--hi-green); font-size: .7rem; white-space: nowrap; }

.hi-table-frame { border: 1px solid var(--hi-line-strong); background: var(--hi-panel); }
.hi-table-scroll { overflow: auto; max-height: 68vh; }
.hi-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; color: var(--hi-text); font-size: .73rem; }
.hi-table th,
.hi-table td {
    min-width: 76px;
    padding: .56rem .58rem;
    border-right: 1px solid var(--hi-line);
    border-bottom: 1px solid var(--hi-line);
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
.hi-table th.is-left,
.hi-table td.is-left { text-align: left; }
.hi-table th:nth-child(2),
.hi-table td:nth-child(2) { min-width: 185px; }
.hi-table thead {
    position: sticky;
    top: 0;
    z-index: 7;
}
.hi-table thead th {
    position: relative;
    top: auto;
    z-index: 1;
    background: #151c1d;
    color: #dfe5e1;
}
.hi-column-row th { font-size: .65rem; }
.hi-column-row button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; }
.hi-table tbody tr:hover > td { background: #171e1f; }
.hi-rank { color: #a5aea9; font-weight: 650; }
.hi-player { color: #fff; font-weight: 650; }
.hi-score-button {
    min-width: 50px;
    padding: .2rem .36rem;
    border: 1px solid rgba(118,213,100,.28);
    border-radius: 3px;
    background: rgba(118,213,100,.07);
    color: #eaf8e7;
    font-weight: 650;
}
.hi-delta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .26rem;
    padding: .18rem .28rem;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    font-size: .71rem;
}
.hi-delta.is-positive { color: var(--int-positive); }
.hi-delta.is-negative { color: var(--int-danger); }
.hi-delta.is-neutral { color: #7f8984; }
.hi-tags-cell { min-width: 210px !important; }
.hi-tags { display: flex; min-width: 190px; flex-wrap: wrap; gap: .25rem; white-space: normal; }
.hi-tag {
    display: inline-flex;
    padding: .16rem .38rem;
    border: 1px solid #4b5651;
    border-radius: 999px;
    background: #202725;
    color: #eef3f0;
    font-size: .61rem;
    font-weight: 650;
}
.hi-tag--elite { border-color: #438f42; background: #173019; color: #d8f4d5; }
.hi-tag--rarity { border-color: #765ca6; background: #2a203d; color: #eadfff; }
.hi-tag--peak { border-color: #3e7698; background: #172c38; color: #d9f1ff; }
.hi-tag--bounce { border-color: #8c6c29; background: #332814; color: #f7dfa3; }
.hi-tag--decline { border-color: #98504a; background: #381d1b; color: #ffd8d4; }
.hi-loading,
.hi-error { min-width: min(900px, 90vw) !important; padding: 3rem !important; text-align: center !important; color: var(--hi-muted); }
.hi-empty { display: grid; gap: .3rem; place-items: center; padding: 3rem; border: 1px solid var(--hi-line-strong); background: var(--hi-panel); color: var(--hi-muted); }
.hi-empty strong { color: var(--hi-text); }
.hi-source-note { padding: .45rem .1rem 0; color: #6f7974; font-size: .62rem; text-align: right; }

.hi-popover {
    position: fixed;
    z-index: 2000;
    width: min(320px, calc(100vw - 24px));
    padding: .8rem;
    border: 1px solid var(--hi-line-strong);
    border-radius: 4px;
    background: #111817;
    color: #fff;
    box-shadow: 0 18px 45px rgba(0,0,0,.35);
    font-size: .74rem;
}
.hi-popover[hidden] { display: none; }
.hi-popover__title { display: block; margin-bottom: .55rem; color: #9be08f; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.hi-popover__row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-top: 1px solid rgba(255,255,255,.1); }
.hi-popover__row:first-of-type { border-top: 0; }
.hi-popover__row .up { color: #8ee07f; }
.hi-popover__row .down { color: #f08a83; }
.hi-popover__row .flat { color: #bdc7c2; }

@media (max-width: 900px) {
    .hi-stat-strip { grid-template-columns: repeat(2, 1fr); }
    .hi-stat-strip > div:nth-child(2) { border-right: 0; }
    .hi-stat-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--hi-line); }
    .hi-research-controls { grid-template-columns: 1fr 1fr; }
    .hi-search-field { grid-column: 1 / -1; }
    .hi-highlight { grid-template-columns: 1fr auto; }
    .hi-highlight__tags { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 575.98px) {
    .hi-stat-strip { grid-template-columns: 1fr; }
    .hi-stat-strip > div { border-right: 0; border-bottom: 1px solid var(--hi-line); }
    .hi-research-controls { grid-template-columns: 1fr 1fr; }
    .hi-highlight { display: flex; flex-direction: column; align-items: flex-start; }
    .hi-highlight__score { padding-left: 0; border-left: 0; }
    .hi-view-heading { align-items: flex-start; flex-direction: column; gap: .35rem; }
}

.hi-group-row th {
    top: 0;
    z-index: 4;
    height: 26px;
    padding: .34rem .58rem;
    border-bottom-color: var(--hi-line-strong);
    background: #101617;
    color: #77827c;
    font-size: .56rem;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.hi-column-row th { top: auto; }
.hi-header-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
}
.is-left .hi-header-cell { justify-content: flex-start; }
.hi-header-info {
    display: inline-grid;
    width: 15px;
    height: 15px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(118,213,100,.38) !important;
    border-radius: 50%;
    color: var(--hi-green) !important;
    font-size: .57rem !important;
    font-weight: 650 !important;
    line-height: 1;
}

/* Workspace refinements */

.hi-table-scroll {
    height: clamp(620px, 72vh, 860px);
    max-height: none;
}

.hi-header-info {
    display: inline-flex;
    width: auto;
    height: auto;
    align-items: center;
    padding: .12rem .32rem !important;
    border: 1px solid rgba(118,213,100,.35) !important;
    border-radius: 999px;
    background: rgba(118,213,100,.055) !important;
    color: var(--hi-green) !important;
    font-size: .54rem !important;
    font-weight: 650 !important;
    line-height: 1.15;
    white-space: nowrap;
}
.hi-header-info:hover,
.hi-header-info:focus-visible {
    border-color: var(--hi-green) !important;
    background: rgba(118,213,100,.12) !important;
    color: #b7f2ac !important;
    outline: none;
}

.hi-table th.hi-sticky,
.hi-table td.hi-sticky {
    position: sticky;
    left: var(--hi-sticky-left);
    z-index: 5;
    background: #121819;
}
.hi-table thead th.hi-sticky { position: sticky; z-index: 8; background: #151c1d; }
.hi-table tbody tr:hover > td.hi-sticky { background: #171e1f; }
.hi-table .hi-sticky--last::after {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    bottom: 0;
    width: 10px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(0,0,0,.28), transparent);
}

@media (max-width: 900px) {
    .hi-table-scroll { height: 68vh; }
}
