:root {
    color-scheme: light;
    --page: #f6f8fc;
    --surface: #ffffff;
    --surface-soft: #fbfcff;
    --line: #e0e8f2;
    --line-strong: #d3dce8;
    --text: #14243a;
    --muted: #62728a;
    --purple: #7057e8;
    --control-brand: #6266e5;
    --purple-dark: #5845c8;
    --purple-soft: #f3f1ff;
    --purple-line: #d4c9ff;
    --row-select-line: rgba(112, 87, 232, 0.24);
    --row-select-bg: rgba(112, 87, 232, 0.03);
    --green: #07945f;
    --red: #e34c49;
    --shadow: 0 16px 34px rgba(20, 36, 58, 0.065);
    --radius-lg: 22px;
    --radius-md: 16px;
    --overview-rate: 14%;
    --overview-price: 18%;
    --overview-flow: 18%;
    --overview-ratio: 14%;
    --table-cell-right-gap: 16px;
    --table-cell-right-gap-mobile: 10px;
    --table-last-cell-safe-gap: 22px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
    background: var(--page);
}

body {
    margin: 0;
    min-width: 0;
    background:
            radial-gradient(circle at 15% -10%, rgba(124, 45, 255, 0.08), transparent 34%),
            linear-gradient(180deg, #f8faff 0%, var(--page) 42%, #f6f8fc 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: 0;
}

[hidden] {
    display: none !important;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
a,
.pill {
    transition: border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease;
}

.shell {
    width: min(100%, 1260px);
    margin: 0 auto;
    padding: 36px 28px 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}

.identity {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.coin-badge {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    border: 1.5px solid var(--purple-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--purple-dark);
    font-size: 26px;
    font-weight: 700;
    box-shadow: 0 10px 26px rgba(124, 45, 255, 0.08);
}

.identity-copy {
    min-width: 0;
}

h1 {
    margin: 0;
    color: var(--text);
    font-size: 34px;
    font-weight: 720;
    line-height: 1.12;
    white-space: nowrap;
}

.subline {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 0;
}

.coin-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--purple-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 12px 26px rgba(124, 45, 255, 0.10);
}

.coin-switch-label {
    margin: 0 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.coin-option {
    appearance: none;
    min-width: 58px;
    padding: 10px 14px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #263850;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
    text-align: center;
}

.coin-option:hover,
.tab-button:hover,
.pill:hover {
    border-color: var(--purple-line);
    box-shadow: 0 10px 24px rgba(124, 45, 255, 0.12);
}

.coin-option.active {
    color: var(--purple-dark);
    background: #f5f2ff;
    box-shadow: inset 0 0 0 1px rgba(112, 87, 232, 0.26), 0 8px 16px rgba(112, 87, 232, 0.12);
}

body.is-refreshing .coin-switch {
    cursor: progress;
}

body.is-refreshing .summary,
body.is-refreshing .tab-panel.active {
    opacity: 0.86;
}

.status-strip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.86);
    color: #263850;
    font-size: 14px;
    white-space: nowrap;
}

.status-label {
    margin-right: 8px;
    color: var(--muted);
}

#jsonLink {
    color: var(--purple-dark);
    font-weight: 650;
}

.warning,
.error-state,
.empty-state {
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.warning {
    color: #8a5a00;
}

.error-state {
    color: #b42318;
}

.summary {
    margin-bottom: 30px;
}

.market-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(470px, 1.08fr);
    gap: 24px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.market-main,
.market-side {
    min-width: 0;
}

.market-side {
    padding-left: 24px;
    border-left: 1px solid var(--line);
}

.label,
.side-metric span,
.range-item span,
.summary-label {
    color: var(--muted);
    font-size: 17px;
    font-weight: 500;
}

.price {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-top: 16px;
}

.price strong {
    color: var(--text);
    font-size: 64px;
    font-weight: 720;
    line-height: 0.95;
    letter-spacing: 0;
}

.price span {
    color: var(--muted);
    font-size: 16px;
    font-weight: 600;
}

.range {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 24px;
}

.range-item {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    min-width: 0;
}

.range-item b {
    font-size: 18px;
    font-weight: 560;
}

.balance-labels {
    display: grid;
    gap: 16px;
}

.summary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    font-size: 21px;
}

.summary-row b {
    font-size: 30px;
    font-weight: 680;
    line-height: 1;
}

.summary-label {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    font-size: 20px;
}

.summary-dot {
    width: 10px;
    height: 10px;
    margin-right: 12px;
    border-radius: 999px;
    background: currentColor;
}

.summary-row.support-text .summary-dot {
    background: var(--red);
}

.summary-row.pressure-text .summary-dot {
    background: var(--green);
}

.support-text {
    color: var(--red);
}

.pressure-text {
    color: var(--green);
}

.range-low {
    color: var(--red);
}

.range-high {
    color: var(--green);
}

.Green {
    color: var(--green);
}

.Red {
    color: var(--red);
}

.Black {
    color: var(--text);
}

.balance-track {
    display: flex;
    height: 8px;
    margin: 20px 0;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f7;
}

.balance-support {
    background: var(--red);
}

.balance-pressure {
    background: var(--green);
}

.side-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.side-metric {
    min-width: 0;
    padding: 13px 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.side-metric span,
.side-metric b {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-metric b {
    margin-top: 6px;
    color: inherit;
    font-size: 20px;
    font-weight: 680;
}

.side-metric b.support-text {
    color: var(--red);
}

.side-metric b.pressure-text {
    color: var(--green);
}

.side-metric b.Green {
    color: var(--green);
}

.side-metric b.Red {
    color: var(--red);
}

.side-metric b.Black {
    color: var(--text);
}

.tabs {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    gap: 6px;
    margin: 0 0 12px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 14px 30px rgba(8, 29, 61, 0.07);
}

.tab-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #1d2d44;
    cursor: pointer;
    font: inherit;
    font-size: 16px;
    font-weight: 650;
    white-space: nowrap;
}

.tab-button::before {
    content: "";
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--purple);
    box-shadow: 0 0 0 3px rgba(124, 45, 255, 0.12);
}

.tab-button.active {
    color: var(--purple-dark);
    border-color: var(--purple-line);
    background: var(--purple-soft);
    box-shadow: inset 0 0 0 1px rgba(124, 45, 255, 0.08);
}

.tab-button[data-tab="supports"]::before {
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(255, 45, 45, 0.11);
}

.tab-button[data-tab="supports"].active {
    color: var(--red);
    border-color: rgba(255, 45, 45, 0.24);
    background: rgba(255, 45, 45, 0.08);
}

.tab-button[data-tab="pressure"]::before {
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.11);
}

.tab-button[data-tab="pressure"].active {
    color: var(--green);
    border-color: rgba(0, 166, 81, 0.24);
    background: rgba(0, 166, 81, 0.08);
}

.tab-button.active::after {
    content: none;
}

.tab-button:focus-visible {
    outline: 2px solid rgba(124, 45, 255, 0.26);
    outline-offset: 2px;
}

.coin-option:focus-visible {
    outline: 2px solid rgba(124, 45, 255, 0.26);
    outline-offset: 2px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 18px 36px rgba(8, 29, 61, 0.07);
}

.table-wrap {
    width: 100%;
    overflow: hidden;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

.table-wrap:focus {
    outline: none;
}

.table-wrap:focus-visible {
    outline: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: var(--surface);
    table-layout: fixed;
}

table[data-table-key="overview"] .overview-col-rate {
    width: var(--overview-rate);
}

table[data-table-key="overview"] .overview-col-price-low,
table[data-table-key="overview"] .overview-col-price-high {
    width: var(--overview-price);
}

table[data-table-key="overview"] .overview-col-short,
table[data-table-key="overview"] .overview-col-long {
    width: var(--overview-flow);
}

table[data-table-key="overview"] .overview-col-ratio {
    width: var(--overview-ratio);
}

table[data-table-key="overview"] th,
table[data-table-key="overview"] td {
    text-align: right;
}

table[data-table-key="overview"] td:first-child {
    text-align: right;
}

th,
td {
    min-width: 0;
    padding: 18px var(--table-cell-right-gap) 18px 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    font-size: 17px;
    font-weight: 430;
    font-variant-numeric: tabular-nums;
    line-height: 1.42;
    text-align: right;
    white-space: nowrap;
}

th {
    color: var(--text);
    font-weight: 620;
    background: #fbfdff;
}

th:first-child,
td:first-child {
    text-align: right;
}

th:last-child,
td:last-child {
    border-right: 0;
    padding-right: var(--table-last-cell-safe-gap);
}

tr:last-child td {
    border-bottom: 0;
}

.matrix-detail-row td,
.matrix-detail-cell {
    padding: 0;
    border-right: 0;
    background: #f7faff;
    white-space: normal;
}

.level-matrix-card {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fbfdff 0%, #f7faff 100%);
}

.child-matrix-table {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}

.child-matrix-table th,
.child-matrix-table td {
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 13px;
}

.child-matrix-table th {
    color: #66758d;
    font-weight: 500;
    background: #fbfcff;
}

tbody tr:hover td {
    background: #fcfbff;
}

tbody tr {
    cursor: pointer;
}

tbody tr.empty-row {
    cursor: default;
}

tbody tr:focus {
    outline: none;
}

tbody tr.is-row-selected td {
    background: var(--row-select-bg);
    border-top: 1px solid var(--row-select-line);
    border-bottom: 1px solid var(--row-select-line);
}

tbody tr.is-row-selected td:first-child {
    border-left: 1px solid var(--row-select-line);
}

tbody tr.is-row-selected td:last-child {
    border-right: 1px solid var(--row-select-line);
}

.ratio-cell {
    display: table-cell;
}

.ratio-cell [data-ratio-value] {
    display: inline-block;
    min-width: 3.6em;
    text-align: right;
}

.ratio-track {
    display: inline-flex;
    width: min(82px, 42%);
    height: 7px;
    margin-left: 10px;
    overflow: hidden;
    vertical-align: middle;
    border-radius: 999px;
    background: #eef2f7;
}

.ratio-short {
    background: var(--green);
}

.ratio-long {
    background: var(--red);
}

@media (max-width: 980px) {
    .shell {
        padding: 26px 16px 30px;
    }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 14px;
    }

    .header-controls {
        display: contents;
    }

    .coin-switch {
        grid-column: 2;
        justify-self: end;
    }

    .status-strip {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
    }

    .pill {
        min-width: 0;
        min-height: 40px;
    }

    #updatedAtPill {
        justify-content: flex-start;
        overflow: hidden;
    }

    #updatedAtText {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .market-panel {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
    }

    .market-side {
        padding: 20px 0 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .side-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    body {
        font-size: 14px;
    }

    .shell {
        padding: 28px 14px 26px;
    }

    .topbar {
        margin-bottom: 24px;
    }

    .identity {
        gap: 10px;
    }

    .coin-badge {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 17px;
        font-weight: 650;
    }

    h1 {
        font-size: 22px;
        font-weight: 680;
    }

    .subline,
    .coin-switch-label {
        display: none;
    }

    .coin-option {
        min-width: 46px;
        padding: 7px 10px;
        border-radius: 10px;
        font-size: 13px;
    }

    .status-strip {
        gap: 8px;
    }

    .pill {
        padding: 0 10px;
        border-radius: 11px;
        font-size: 12px;
    }

    .status-label {
        margin-right: 7px;
    }

    .summary {
        margin-bottom: 30px;
    }

    .market-panel {
        grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
        gap: 14px;
        padding: 20px 16px;
        border-radius: 18px;
    }

    .market-side {
        padding: 0 0 0 16px;
        border-top: 0;
        border-left: 1px solid var(--line);
    }

    .label,
    .range-item span,
    .summary-label {
        font-size: 14px;
    }

    .price {
        gap: 8px;
        margin-top: 12px;
    }

    .price strong {
        font-size: 40px;
        font-weight: 680;
    }

    .price span {
        font-size: 12px;
    }

    .range {
        gap: 12px;
        margin-top: 18px;
    }

    .range-item {
        gap: 6px;
    }

    .range-item b {
        font-size: 13px;
        font-weight: 520;
    }

    .balance-labels {
        gap: 12px;
    }

    .summary-row {
        gap: 8px;
    }

    .summary-row b {
        font-size: 19px;
        font-weight: 640;
    }

    .summary-label {
        font-size: 15px;
    }

    .summary-dot {
        width: 8px;
        height: 8px;
        margin-right: 8px;
    }

    .balance-track {
        height: 6px;
        margin: 14px 0;
    }

    .side-grid {
        display: none;
    }

    .tabs {
        display: flex;
        width: max-content;
        max-width: 100%;
        margin-bottom: 10px;
        padding: 5px;
        border-radius: 999px;
    }

    .tab-button {
        min-height: 36px;
        padding: 0 12px;
        font-size: 13px;
        font-weight: 620;
    }

    .panel {
        border-radius: 16px;
    }

    .table-wrap {
        overflow: hidden;
    }

    th,
    td {
        padding: 14px var(--table-cell-right-gap-mobile) 14px 0;
        font-size: 12.2px;
        font-weight: 400;
        line-height: 1.4;
    }

    th:first-child,
    td:first-child {
        padding-left: 0;
        padding-right: var(--table-cell-right-gap-mobile);
    }

    th:last-child,
    td:last-child {
        padding-right: calc(var(--table-cell-right-gap-mobile) + 4px);
    }

    table[data-table-key="overview"] th,
    table[data-table-key="overview"] td {
        padding-right: var(--table-cell-right-gap-mobile);
        padding-left: 0;
    }

    table[data-table-key="overview"] th:first-child,
    table[data-table-key="overview"] td:first-child {
        padding-right: var(--table-cell-right-gap-mobile);
        padding-left: 0;
    }

    table[data-table-key="overview"] th:last-child,
    table[data-table-key="overview"] td:last-child {
        padding-right: calc(var(--table-cell-right-gap-mobile) + 4px);
        padding-left: 0;
    }

    .ratio-cell [data-ratio-value] {
        min-width: 0;
    }

    .ratio-track {
        display: none;
    }
}

@media (max-width: 430px) {
    .shell {
        padding-right: 12px;
        padding-left: 12px;
    }

    .market-panel {
        padding: 18px 14px;
        gap: 12px;
    }

    .price strong {
        font-size: 38px;
    }

    .range {
        display: none;
    }

    th,
    td {
        padding-top: 13px;
        padding-bottom: 13px;
        font-size: 11.8px;
    }

    table[data-table-key="overview"] th,
    table[data-table-key="overview"] td {
        padding-right: calc(var(--table-cell-right-gap-mobile) - 1px);
        padding-left: 0;
        font-size: 11.6px;
    }
}

@media (max-width: 390px) {
    .shell {
        padding-right: 10px;
        padding-left: 10px;
    }

    h1 {
        font-size: 20px;
    }

    .coin-option {
        min-width: 42px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .market-panel {
        padding: 16px 12px;
    }

    .price strong {
        font-size: 34px;
    }

    .summary-row b {
        font-size: 17px;
    }

    th,
    td {
        padding-right: 8px;
        padding-left: 0;
        font-size: 11.2px;
    }

    th:last-child,
    td:last-child {
        padding-right: 12px;
    }

    table[data-table-key="overview"] th,
    table[data-table-key="overview"] td {
        padding-right: 8px;
        padding-left: 0;
        font-size: 11px;
    }

    table[data-table-key="overview"] th:last-child,
    table[data-table-key="overview"] td:last-child {
        padding-right: 12px;
    }
}

/* Visual comfort pass: keep market semantics, reduce glare and heavy type. */
body {
    background:
            radial-gradient(circle at 15% -10%, rgba(112, 87, 232, 0.045), transparent 34%),
            linear-gradient(180deg, #fbfcff 0%, var(--page) 44%, #f7f9fc 100%);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.coin-badge,
.coin-switch,
.pill,
.market-panel,
.tabs,
.panel {
    box-shadow: var(--shadow);
}

h1 {
    color: #14243a;
    font-weight: 660;
}

.coin-badge {
    background: rgba(255, 255, 255, 0.82);
    color: var(--purple-dark);
    font-weight: 650;
}

.coin-option,
.tab-button,
#jsonLink {
    font-weight: 620;
}

.coin-option.active {
    color: #5845c8;
    background: #f5f2ff;
    box-shadow: inset 0 0 0 1px rgba(112, 87, 232, 0.24), 0 8px 16px rgba(112, 87, 232, 0.10);
}

.price strong {
    color: #14243a;
    font-weight: 660;
}

.price span,
.label,
.side-metric span,
.range-item span,
.summary-label,
.subline,
.coin-switch-label,
.status-label {
    color: var(--muted);
    font-weight: 460;
}

.summary-row b,
.side-metric b {
    font-weight: 640;
}

th {
    color: #24344c;
    font-weight: 580;
    background: #fbfcfe;
}

td {
    color: #203049;
    font-weight: 400;
}

.support-text,
.range-low,
.Red {
    color: var(--red);
}

.pressure-text,
.range-high,
.Green {
    color: var(--green);
}

.tab-button[data-tab="supports"].active {
    color: #cf403d;
    border-color: rgba(227, 76, 73, 0.22);
    background: rgba(227, 76, 73, 0.065);
}

.tab-button[data-tab="pressure"].active {
    color: #087f55;
    border-color: rgba(7, 148, 95, 0.22);
    background: rgba(7, 148, 95, 0.065);
}

.balance-track,
.ratio-track {
    background: #eef3f8;
}

tbody tr:hover td {
    background: #fbfcff;
}
