.market-terminal-section {
    position: relative;
    left: 50%;
    width: min(1320px, calc(100vw - 44px));
    margin: 42px 0 14px;
    transform: translateX(-50%);
}

.market-terminal {
    --terminal-amber: #f6b940;
    --terminal-amber-soft: rgba(246,185,64,.16);
    --terminal-green: #39d7a0;
    --terminal-green-soft: rgba(57,215,160,.12);
    --terminal-red: #ff6577;
    --terminal-red-soft: rgba(255,101,119,.12);
    --terminal-panel: rgba(8,16,29,.94);
    overflow: hidden;
    border: 1px solid rgba(246,185,64,.24);
    border-radius: 20px;
    background:
        radial-gradient(circle at 18% -18%, rgba(246,185,64,.12), transparent 28rem),
        linear-gradient(155deg, rgba(14,27,47,.98), rgba(6,13,24,.98) 68%);
    box-shadow: 0 28px 80px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.025);
}

.market-terminal::before {
    content: "";
    display: block;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(246,185,64,.78) 28%, rgba(130,168,255,.38) 72%, transparent);
}

.terminal-head {
    min-height: 94px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(148,172,214,.10);
}

.terminal-identity,
.terminal-market-title,
.terminal-live-status,
.terminal-price-row,
.terminal-control-row,
.terminal-depth-labels,
.terminal-footer {
    display: flex;
    align-items: center;
}

.terminal-identity { gap: 13px; min-width: 0; }
.terminal-btc-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(246,185,64,.30);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(246,185,64,.19), rgba(246,185,64,.04));
    box-shadow: 0 0 28px rgba(246,185,64,.09);
}
.terminal-btc-icon img { display: block; width: 30px; height: 30px; }
.terminal-heading-copy { display: grid; gap: 5px; min-width: 0; }
.terminal-market-title { gap: 8px; }
.terminal-market-title h2 { margin: 0; font-size: clamp(1.25rem,2.1vw,1.72rem); letter-spacing: -.04em; }
.terminal-market-title span { color: #8f9eb5; font-size: .92em; font-weight: 650; }
.terminal-market-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.terminal-market-tags span {
    padding: 3px 7px;
    border: 1px solid rgba(148,172,214,.13);
    border-radius: 999px;
    color: #8493aa;
    background: rgba(13,24,41,.56);
    font-size: 8px;
    font-weight: 820;
    letter-spacing: .11em;
}
.terminal-market-tags span:last-child { border-color: rgba(246,185,64,.18); color: #dbb768; }

.terminal-price-block { min-width: 230px; display: grid; justify-items: end; gap: 6px; }
.terminal-price-row { justify-content: flex-end; gap: 10px; }
.terminal-price {
    color: #f7f9fd;
    font-size: clamp(1.45rem,2.5vw,2rem);
    font-weight: 780;
    letter-spacing: -.045em;
    font-variant-numeric: tabular-nums;
    transition: color .18s ease, text-shadow .18s ease;
}
.terminal-price.is-price-up { color: #83ecc7; text-shadow: 0 0 20px rgba(57,215,160,.23); }
.terminal-price.is-price-down { color: #ff9aa5; text-shadow: 0 0 20px rgba(255,101,119,.18); }
.terminal-change {
    min-width: 62px;
    padding: 4px 7px;
    border-radius: 7px;
    color: #a8b4c7;
    background: rgba(148,172,214,.06);
    font-size: 10px;
    font-weight: 760;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.terminal-change.is-positive { color: #73e5bd; background: rgba(57,215,160,.08); }
.terminal-change.is-negative { color: #ff8d9b; background: rgba(255,101,119,.08); }
.terminal-live-status {
    gap: 7px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #7e8da4;
    font: inherit;
    font-size: 9px;
    font-weight: 820;
    letter-spacing: .11em;
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.terminal-live-status:hover { border-color: rgba(148,172,214,.13); background: rgba(148,172,214,.045); }
.terminal-live-status:focus-visible { outline: 2px solid rgba(246,185,64,.52); outline-offset: 2px; }
.terminal-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #6d788a; box-shadow: 0 0 0 3px rgba(109,120,138,.08); }
.terminal-live-status[data-state="live"] { color: #68ddb4; }
.terminal-live-status[data-state="live"] .terminal-live-dot { background: var(--terminal-green); box-shadow: 0 0 0 4px rgba(57,215,160,.10), 0 0 15px rgba(57,215,160,.28); }
.terminal-live-status[data-state="reconnecting"] { color: #e6bd6e; }
.terminal-live-status[data-state="reconnecting"] .terminal-live-dot,
.terminal-live-status[data-state="delayed"] .terminal-live-dot { background: var(--terminal-amber); box-shadow: 0 0 0 4px rgba(246,185,64,.09); }
.terminal-live-status[data-state="offline"] { color: #ff8f9b; }
.terminal-live-status[data-state="offline"] .terminal-live-dot { background: var(--terminal-red); box-shadow: 0 0 0 4px rgba(255,101,119,.09); }
.terminal-live-status[data-state="paused"] { color: #8c98aa; border-color: rgba(148,172,214,.10); background: rgba(148,172,214,.035); }
.terminal-live-status[data-state="paused"] .terminal-live-dot { background: #6d788a; box-shadow: none; }
.market-terminal.is-live-paused .terminal-price,
.market-terminal.is-live-paused .terminal-depth-track,
.market-terminal.is-live-paused .order-book-list { opacity: .86; }

.terminal-controls {
    min-height: 50px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(148,172,214,.08);
    background: rgba(5,12,22,.38);
}
.terminal-control-row { gap: 4px; overflow-x: auto; scrollbar-width: none; }
.terminal-control-row::-webkit-scrollbar { display: none; }
.terminal-control-label { flex: 0 0 auto; margin-right: 6px; color: #68778f; font-size: 8px; font-weight: 820; letter-spacing: .11em; text-transform: uppercase; }
.terminal-chip {
    min-width: 41px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #8e9bb0;
    font-size: 9px;
    font-weight: 780;
}
.terminal-chip:hover { color: #e8eef9; background: rgba(130,168,255,.06); }
.terminal-chip.is-active {
    border-color: rgba(246,185,64,.23);
    color: #f6cc76;
    background: rgba(246,185,64,.09);
    box-shadow: inset 0 0 0 1px rgba(246,185,64,.04);
}

.terminal-stage { display: grid; grid-template-columns: minmax(0,2.85fr) minmax(292px,1fr); min-height: 590px; }
.terminal-chart-column { position: relative; min-width: 0; padding: 14px 14px 10px; border-right: 1px solid rgba(148,172,214,.09); }
.terminal-chart-legend {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 11px;
    overflow-x: auto;
    padding: 0 4px 7px;
    color: #6f7d92;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    scrollbar-width: none;
    white-space: nowrap;
}
.terminal-chart-legend::-webkit-scrollbar { display: none; }
.terminal-chart-legend strong { color: #9dadc3; font-weight: 760; }
.terminal-chart-wrap { position: relative; height: 492px; overflow: hidden; border-radius: 10px; background: rgba(5,12,22,.30); }
.terminal-chart { width: 100%; height: 100%; }
.terminal-chart-placeholder {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: grid;
    place-items: center;
    color: #718097;
    background: linear-gradient(90deg, rgba(10,20,35,.62), rgba(18,31,51,.68), rgba(10,20,35,.62));
    background-size: 220% 100%;
    animation: terminal-shimmer 1.4s linear infinite;
    font-size: 10px;
    letter-spacing: .05em;
}
.terminal-chart-placeholder[hidden] { display: none; }
.terminal-return-live {
    position: absolute;
    z-index: 6;
    right: 26px;
    bottom: 55px;
    padding: 6px 10px;
    border: 1px solid rgba(246,185,64,.25);
    border-radius: 999px;
    background: rgba(13,24,41,.94);
    color: #f3c86e;
    box-shadow: 0 8px 22px rgba(0,0,0,.25);
    font-size: 8px;
    font-weight: 820;
    letter-spacing: .07em;
}
.terminal-return-live[hidden] { display: none; }
.terminal-range-bar {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 2px 0;
}
.terminal-range-buttons { display: flex; align-items: center; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.terminal-range-buttons::-webkit-scrollbar { display: none; }
.terminal-range-buttons .terminal-chip { min-width: 36px; padding-inline: 7px; }
.terminal-note { margin: 0; color: #7d8da4; font-size: 8px; text-align: right; white-space: nowrap; }
.terminal-note.is-warning { color: #e2ba6a; }

.terminal-orderbook { min-width: 0; display: flex; flex-direction: column; background: rgba(5,12,22,.30); }
.terminal-orderbook-head { min-height: 75px; padding: 13px 14px 10px; border-bottom: 1px solid rgba(148,172,214,.08); }
.terminal-orderbook-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.terminal-orderbook-title h3 { margin: 0; color: #dce5f5; font-size: 11px; font-weight: 760; letter-spacing: .02em; }
.terminal-orderbook-title span { color: #65758e; font-size: 8px; }
.terminal-depth-track { position: relative; height: 5px; overflow: hidden; border-radius: 999px; background: rgba(148,172,214,.08); }
.terminal-depth-bid, .terminal-depth-ask { position: absolute; top: 0; bottom: 0; width: 50%; transition: width .25s ease; }
.terminal-depth-bid { left: 0; background: linear-gradient(90deg, rgba(57,215,160,.36), rgba(57,215,160,.85)); }
.terminal-depth-ask { right: 0; background: linear-gradient(90deg, rgba(255,101,119,.85), rgba(255,101,119,.36)); }
.terminal-depth-labels { justify-content: space-between; gap: 12px; margin-top: 5px; color: #607089; font-size: 7px; font-weight: 780; letter-spacing: .06em; }
.terminal-depth-labels b:first-child { color: #58d9ad; }
.terminal-depth-labels b:last-child { color: #ff7987; }

.order-book-columns,
.order-book-row {
    display: grid;
    grid-template-columns: minmax(78px,1.05fr) minmax(65px,.9fr) minmax(78px,1fr);
    gap: 8px;
    align-items: center;
}
.order-book-columns { min-height: 31px; padding: 0 13px; color: #5f6d83; font-size: 7px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.order-book-columns span:not(:first-child) { text-align: right; }
.order-book-side-label {
    min-height: 19px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 13px;
    border-top: 1px solid rgba(148,172,214,.045);
    border-bottom: 1px solid rgba(148,172,214,.045);
    background: rgba(8,17,31,.24);
    font-size: 7px;
    letter-spacing: .07em;
}
.order-book-side-label span { font-weight: 860; }
.order-book-side-label small { color: #617088; font-size: 7px; font-weight: 700; letter-spacing: .02em; }
.order-book-side-label--ask span { color: #ff7d8a; }
.order-book-side-label--bid span { color: #4cdbaa; }
.order-book-list { flex: 0 0 auto; transition: opacity .18s ease; }
.order-book-row {
    position: relative;
    min-height: 22px;
    padding: 0 13px;
    overflow: hidden;
    color: #8592a5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 8px;
    font-variant-numeric: tabular-nums;
}
.order-book-row > span:not(.order-book-depth) { position: relative; z-index: 2; }
.order-book-row > span:nth-of-type(2),
.order-book-row > span:nth-of-type(3) { text-align: right; }
.order-book-depth { position: absolute; z-index: 1; top: 1px; right: 0; bottom: 1px; width: 0; pointer-events: none; }

/* CSP-safe quantized widths for live depth bars. */
.depth-pct-0 { width: 0% !important; }
.depth-pct-1 { width: 1% !important; }
.depth-pct-2 { width: 2% !important; }
.depth-pct-3 { width: 3% !important; }
.depth-pct-4 { width: 4% !important; }
.depth-pct-5 { width: 5% !important; }
.depth-pct-6 { width: 6% !important; }
.depth-pct-7 { width: 7% !important; }
.depth-pct-8 { width: 8% !important; }
.depth-pct-9 { width: 9% !important; }
.depth-pct-10 { width: 10% !important; }
.depth-pct-11 { width: 11% !important; }
.depth-pct-12 { width: 12% !important; }
.depth-pct-13 { width: 13% !important; }
.depth-pct-14 { width: 14% !important; }
.depth-pct-15 { width: 15% !important; }
.depth-pct-16 { width: 16% !important; }
.depth-pct-17 { width: 17% !important; }
.depth-pct-18 { width: 18% !important; }
.depth-pct-19 { width: 19% !important; }
.depth-pct-20 { width: 20% !important; }
.depth-pct-21 { width: 21% !important; }
.depth-pct-22 { width: 22% !important; }
.depth-pct-23 { width: 23% !important; }
.depth-pct-24 { width: 24% !important; }
.depth-pct-25 { width: 25% !important; }
.depth-pct-26 { width: 26% !important; }
.depth-pct-27 { width: 27% !important; }
.depth-pct-28 { width: 28% !important; }
.depth-pct-29 { width: 29% !important; }
.depth-pct-30 { width: 30% !important; }
.depth-pct-31 { width: 31% !important; }
.depth-pct-32 { width: 32% !important; }
.depth-pct-33 { width: 33% !important; }
.depth-pct-34 { width: 34% !important; }
.depth-pct-35 { width: 35% !important; }
.depth-pct-36 { width: 36% !important; }
.depth-pct-37 { width: 37% !important; }
.depth-pct-38 { width: 38% !important; }
.depth-pct-39 { width: 39% !important; }
.depth-pct-40 { width: 40% !important; }
.depth-pct-41 { width: 41% !important; }
.depth-pct-42 { width: 42% !important; }
.depth-pct-43 { width: 43% !important; }
.depth-pct-44 { width: 44% !important; }
.depth-pct-45 { width: 45% !important; }
.depth-pct-46 { width: 46% !important; }
.depth-pct-47 { width: 47% !important; }
.depth-pct-48 { width: 48% !important; }
.depth-pct-49 { width: 49% !important; }
.depth-pct-50 { width: 50% !important; }
.depth-pct-51 { width: 51% !important; }
.depth-pct-52 { width: 52% !important; }
.depth-pct-53 { width: 53% !important; }
.depth-pct-54 { width: 54% !important; }
.depth-pct-55 { width: 55% !important; }
.depth-pct-56 { width: 56% !important; }
.depth-pct-57 { width: 57% !important; }
.depth-pct-58 { width: 58% !important; }
.depth-pct-59 { width: 59% !important; }
.depth-pct-60 { width: 60% !important; }
.depth-pct-61 { width: 61% !important; }
.depth-pct-62 { width: 62% !important; }
.depth-pct-63 { width: 63% !important; }
.depth-pct-64 { width: 64% !important; }
.depth-pct-65 { width: 65% !important; }
.depth-pct-66 { width: 66% !important; }
.depth-pct-67 { width: 67% !important; }
.depth-pct-68 { width: 68% !important; }
.depth-pct-69 { width: 69% !important; }
.depth-pct-70 { width: 70% !important; }
.depth-pct-71 { width: 71% !important; }
.depth-pct-72 { width: 72% !important; }
.depth-pct-73 { width: 73% !important; }
.depth-pct-74 { width: 74% !important; }
.depth-pct-75 { width: 75% !important; }
.depth-pct-76 { width: 76% !important; }
.depth-pct-77 { width: 77% !important; }
.depth-pct-78 { width: 78% !important; }
.depth-pct-79 { width: 79% !important; }
.depth-pct-80 { width: 80% !important; }
.depth-pct-81 { width: 81% !important; }
.depth-pct-82 { width: 82% !important; }
.depth-pct-83 { width: 83% !important; }
.depth-pct-84 { width: 84% !important; }
.depth-pct-85 { width: 85% !important; }
.depth-pct-86 { width: 86% !important; }
.depth-pct-87 { width: 87% !important; }
.depth-pct-88 { width: 88% !important; }
.depth-pct-89 { width: 89% !important; }
.depth-pct-90 { width: 90% !important; }
.depth-pct-91 { width: 91% !important; }
.depth-pct-92 { width: 92% !important; }
.depth-pct-93 { width: 93% !important; }
.depth-pct-94 { width: 94% !important; }
.depth-pct-95 { width: 95% !important; }
.depth-pct-96 { width: 96% !important; }
.depth-pct-97 { width: 97% !important; }
.depth-pct-98 { width: 98% !important; }
.depth-pct-99 { width: 99% !important; }
.depth-pct-100 { width: 100% !important; }

.order-book-row--ask .order-book-depth { background: linear-gradient(90deg, transparent, rgba(255,101,119,.10)); }
.order-book-row--bid .order-book-depth { background: linear-gradient(90deg, transparent, rgba(57,215,160,.10)); }
.order-book-row--ask .order-book-price { color: #ff7d8a; }
.order-book-row--bid .order-book-price { color: #4cdbaa; }
.order-book-empty { min-height: 220px; display: grid; place-items: center; color: #5f6f87; font-size: 9px; }
.terminal-spread {
    min-height: 58px;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 8px 13px;
    border-top: 1px solid rgba(148,172,214,.065);
    border-bottom: 1px solid rgba(148,172,214,.065);
    background: rgba(10,20,35,.48);
}
.terminal-mid-price { color: #eaf0f9; font-size: 15px; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.terminal-spread-copy { color: #66768e; font-size: 7px; font-variant-numeric: tabular-nums; }

.terminal-footer {
    min-height: 42px;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 17px;
    border-top: 1px solid rgba(148,172,214,.08);
    color: #65748b;
    background: rgba(4,10,19,.35);
    font-size: 8px;
}
.terminal-footer a { color: #8296b8; border-bottom: 1px solid rgba(130,150,184,.18); }
.terminal-footer a:hover { color: #b6c7e5; border-color: rgba(182,199,229,.4); }

@keyframes terminal-shimmer { to { background-position: -220% 0; } }

@media (max-width: 900px) {
    .terminal-stage { grid-template-columns: minmax(0,1fr); }
    .terminal-chart-column { border-right: 0; border-bottom: 1px solid rgba(148,172,214,.09); }
    .terminal-orderbook { min-height: 470px; }
}

@media (max-width: 680px) {
    .market-terminal-section { width: calc(100vw - 18px); margin-top: 34px; }
    .market-terminal { border-radius: 15px; }
    .terminal-head { align-items: flex-start; padding: 15px 14px; gap: 14px; }
    .terminal-btc-icon { width: 36px; height: 36px; flex-basis: 36px; }
    .terminal-btc-icon img { width: 26px; height: 26px; }
    .terminal-market-title h2 { font-size: 1.18rem; }
    .terminal-price-block { min-width: 138px; }
    .terminal-price { font-size: 1.15rem; }
    .terminal-change { min-width: 54px; font-size: 8px; }
    .terminal-controls { padding-inline: 10px; }
    .terminal-chart-column { padding: 10px 7px 8px; }
    .terminal-chart-wrap { height: 400px; }
    .terminal-chart-legend { min-height: 28px; font-size: 8px; }
    .terminal-range-bar { align-items: flex-start; flex-direction: column; padding: 7px 2px 2px; }
    .terminal-range-buttons { width: 100%; }
    .terminal-note { min-height: 13px; text-align: left; white-space: normal; }
    .terminal-return-live { right: 15px; bottom: 76px; }
    .terminal-orderbook { min-height: 390px; }
    .terminal-footer { align-items: flex-start; flex-direction: column; gap: 3px; }
}

@media (max-width: 430px) {
    .terminal-head { display: grid; grid-template-columns: 1fr; }
    .terminal-price-block { width: 100%; grid-template-columns: 1fr auto; align-items: center; justify-items: start; }
    .terminal-price-row { justify-content: flex-start; }
    .terminal-live-status { justify-self: end; }
    .terminal-market-tags span:first-child { display: none; }
    .terminal-chart-wrap { height: 365px; }
}

@media (prefers-reduced-motion: reduce) {
    .terminal-price,
    .terminal-depth-bid,
    .terminal-depth-ask { transition: none !important; }
}
