:root {
    --bg: #0b0f17;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --white: #ffffff;
    --border: rgba(255, 255, 255, 0.08);

    --accent: #22c55e;
    --accent-soft: rgba(34, 197, 94, 0.08);
    --accent-strong: rgba(34, 197, 94, 0.14);
    --accent-active: rgba(34, 197, 94, 0.55);
    --accent-hover: rgba(34, 197, 94, 0.18);
    --accent-solid: rgba(34, 197, 94, 1);
    --accent-border-strong: rgb(12, 72, 34);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.08);
    --danger-border: rgba(239, 68, 68, 0.25);
    --danger-text: #fecaca;
    --danger-solid: rgba(239, 68, 68, 1);
    --danger-border-strong: rgb(72, 20, 20);

    --info-soft: rgba(59, 130, 246, 0.08);
    --button-blue-bg: rgba(34, 99, 197, 0.12);
    --button-blue-border: rgba(34, 91, 197, 0.25);

    --panel-bg: rgba(15, 23, 42, 0.7);
    --panel-bg-soft: rgba(15, 23, 42, 0.35);
    --panel-bg-faint: rgba(15, 23, 42, 0.18);

    --button-color: var(--panel-bg);
    --button-active: var(--accent-active);
    --toggle-background: var(--panel-bg);

    --header-bg: rgba(17, 24, 39, 0.6);
    --header-bg-sticky: rgba(17, 24, 39, 0.92);
    --tooltip-bg: rgba(17, 24, 39, 0.97);

    --hover-bg: rgba(255, 255, 255, 0.06);
    --chip-bg: rgba(255, 255, 255, 0.03);
    --icon-bg: rgba(255, 255, 255, 0.04);
    --icon-bg-transparent: rgba(255, 255, 255, 0);
    --q-bg: rgba(255, 255, 255, 0.08);
    --dot-ring: rgba(255, 255, 255, 0.03);

    --text-soft: rgba(229, 231, 235, 0.95);
    --text-soft-2: rgba(229, 231, 235, 0.92);
    --text-soft-3: rgba(229, 231, 235, 0.9);
    --text-dim: rgba(229, 231, 235, 0.7);
    --pi-default: rgba(229, 231, 235, 0.55);

    --card-grad-top: rgba(8, 11, 19, 0.65);
    --card-grad-bottom: rgba(6, 9, 17, 0.55);

    --shadow-lg: rgba(0, 0, 0, 0.35);

    --code-text: #cbd5e1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    background: radial-gradient(1200px 600px at 20% 0%, var(--accent-soft), transparent 50%),
    radial-gradient(1200px 600px at 80% 0%, var(--info-soft), transparent 50%),
    var(--bg);
    color: var(--text);
}

header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--header-bg);
    backdrop-filter: blur(10px);

    /* IMPORTANT: header itself should NOT be sticky */
    position: static;
}

.status {
    margin: 0;
    padding: 0;
    position: fixed;
    left: 6px;
    bottom: 6px;
}

.row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.title {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.title h1 {
    margin: 0;
    font-size: 16px;
    letter-spacing: 0.3px;
}

/* ===== CHART SELECTOR BAR (below title, top-left) ===== */
.title-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.selector button {
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--button-color);
    color: var(--text);
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.selector button:hover {
    background: var(--hover-bg);
}

.selector button:active {
    transform: translateY(1px);
}

.selector button.active {
    border-color: var(--button-active);
    background: var(--button-color);
}

.selector img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--icon-bg);
}

.selector .label {
    font-size: 12px;
    color: var(--text-soft-2);
    white-space: nowrap;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

select, input, button {
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: var(--text);
    padding: 0 10px;
    outline: none;
}

input {
    width: 90px;
}

select {
    width: 170px;
}

button {
    cursor: pointer;
    padding: 0 14px;
    background: var(--button-blue-bg);
    border: 1px solid var(--button-blue-border);
}

button:hover {
    background: var(--accent-hover);
}

button:active {
    transform: translateY(1px);
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--toggle-background);
    border-radius: 10px;
    user-select: none;
}

.toggle input {
    width: auto;
    height: auto;
    margin: 0;
}

/* ===== PRESSURE HELP TOOLTIP ===== */

.help {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    border-radius: 10px;
    font-size: 12px;
    color: var(--muted);
}

.help .q {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    color: var(--white);
    background: var(--q-bg);
    border: 1px solid var(--border);
}

.help .tip {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 360px;
    max-width: 85vw;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--tooltip-bg);
    color: var(--text-soft-2);
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 10px 30px var(--shadow-lg);
    display: none;
    z-index: 50;
}

.help:hover .tip {
    display: block;
}

.help .tip b {
    color: var(--white);
}

.help .tip::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 14px;
    width: 10px;
    height: 10px;
    background: var(--tooltip-bg);
    transform: rotate(45deg);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
}

main {
    padding: 18px 20px 28px;
    margin: 0 auto;
}

.badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--chip-bg);
    white-space: nowrap;
}

.item {
    color: var(--text-soft);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: 0.3px;
}

.status {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.dot.red {
    background: var(--danger);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: var(--code-text);
}

.error {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--danger-border);
    background: var(--danger-soft);
    color: var(--danger-text);
    font-size: 12px;
    display: none;
    white-space: pre-wrap;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 3000px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }

    .full {
        grid-column: 1 / -1;
    }
}

.card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--card-grad-top), var(--card-grad-bottom));
    overflow: hidden;
    min-width: 0;
}

.card-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-head .left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.card-head .name {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.chart {
    height: calc(80vh - 60px);
    position: relative; /* needed for left labels overlay */
}

.full .chart {
    height: 520px;
}

/* ===== Chart + Orderbook depth (right sidebar) ===== */
.card-main {
    display: flex;
    min-width: 0;
}

.card-main .chart {
    flex: 1 1 auto;
    min-width: 0;
}

.card-main .depth {
    flex: 0 0 auto;
    max-width: 150px;
    min-width: 150px;
    height: calc(80vh - 60px);
    border-left: 1px solid var(--border);
    position: relative;
    background: var(--panel-bg-faint);
}

.full .card-main .depth {
    height: 520px;
}

.depth-head {
    position: absolute;
    top: 8px;
    left: 10px;
    right: 10px;
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.depth-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.panel-status {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ===== PRESSURE INDICATOR (pill) ===== */
.indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    height: 26px;
    padding: 0 10px;
    border-radius: 999px;

    border: 1px solid var(--border);
    background: rgba(8, 13, 24, 0.55);

    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1px;

    color: var(--text-soft-3);
    user-select: none;

    /* controlled from JS */
    --pi-color: var(--pi-default);
}

.indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pi-color);
    box-shadow: 0 0 0 3px var(--dot-ring);
}

.indicator.is-muted {
    opacity: 0.7;
}

/* Custom left-side wall labels (synced to RIGHT scale via priceToCoordinate) */
.wall-labels {
    position: absolute;
    left: 60px;
    top: 0;
    bottom: 0;
    width: 140px;
    pointer-events: none;
    z-index: 5;
}

.wall-label {
    position: absolute;
    transform: translateY(-50%);
    padding: 3px 3px;
    border-radius: 0 6px 6px 0;
    font-size: 11px;
    margin-left: -9px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;

    /* TEXT COLOR */
    color: var(--white);

    /* cleaner label look */
    border: none;
    font-weight: 600;
}

.wall-label.bid {
    color: var(--white);
    background-color: var(--accent-solid);
    border: 1px solid var(--accent-border-strong);
}

.wall-label.ask {
    color: var(--white);
    background-color: var(--danger-solid);
    border: 1px solid var(--danger-border-strong);
}

#tv-attr-logo {
    display: none
}

/* ===== GROUPED MULTI-SELECTOR ===== */
.selector {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    max-width: 100%;
}

/* Kleine obere Reihe (Count + All/None) soll NICHT die ganze Breite ziehen */
.selector-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    width: auto;
}

/* Jede Gruppe ist ein "Kärtchen", mehrere nebeneinander */
.selector-group {
    border: 1px solid var(--border);
    background: var(--panel-bg-soft);
    border-radius: 12px;
    padding: 10px;
    width: auto;
    min-width: 180px;
}

/* Items in Gruppe bleiben wrap */
.selector-items {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.selector-item {
    height: 34px;
    width: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.selector-item img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--icon-bg-transparent);
}

.selector-item.active {
    border-color: var(--accent-active);
    background: var(--accent-strong);
}

/* Sticky controls bar (left), selector scrolls away */
header .row {
    align-items: flex-start;
    justify-content: flex-start;
}

/* Put selector and controls next to each other naturally */
header .title-stack {
    flex: 0 1 auto;
}

/* Make the header-controls sticky */
header > .row > .controls {
    position: sticky;
    top: 0;
    z-index: 50;

    background: var(--header-bg-sticky);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;

    margin-left: 0;
}

/* Optional: keep some spacing between selector and sticky controls */
header .row {
    gap: 14px;
}

/* SMA buttons look like item selection chips, but wider for text */
.sma-btns { gap: 8px; }

.selector-item.sma-btn{
    width: auto;
    padding: 0 12px;
    font-size: 12px;
    color: var(--text-soft-2);
}

.card-head .right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.exporting .dl-btn,
.exporting .share-btn {
    visibility: hidden;
}