:root {
  color-scheme: dark;
  --bg: #071015;
  --panel: #0b171d;
  --panel-2: #0e1c23;
  --line: #1a2a32;
  --line-soft: rgba(69, 96, 108, .23);
  --text: #eef6f7;
  --muted: #6f8792;
  --muted-2: #93a7ae;
  --green: #22c59a;
  --green-soft: rgba(34, 197, 154, .13);
  --red: #ef5965;
  --yellow: #f7b731;
  --blue: #6d8cff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { height: 100vh; min-height: 620px; background: radial-gradient(circle at 55% -30%, rgba(40, 109, 124, .12), transparent 35%), var(--bg); }
.topbar { height: 68px; display: flex; align-items: center; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(10, 23, 29, .96); }
.pair-button { min-width: 195px; height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid #20333c; border-radius: 12px; background: #102129; cursor: pointer; text-align: left; transition: border-color .2s, background .2s; }
.pair-button:hover, .pair-button[aria-expanded="true"] { border-color: #345160; background: #132730; }
.pair-button strong, .pair-button small { display: block; }
.pair-button strong { font-size: 13px; }
.pair-button small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.coin-icon { flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: #171717; font-weight: 900; }
.chevron { color: var(--muted); margin-left: auto; font-size: 18px; }

.quote-strip { display: flex; align-items: center; gap: 24px; min-width: 0; flex: 1; }
.quote-main { display: flex; align-items: baseline; gap: 6px; min-width: 130px; }
.quote-main span { font-size: 21px; font-weight: 800; letter-spacing: -.03em; color: var(--green); font-variant-numeric: tabular-nums; }
.quote-main small { color: var(--muted); font-size: 10px; font-weight: 700; }
.metric { display: grid; gap: 3px; min-width: 76px; }
.metric small { color: var(--muted); font-size: 9px; }
.metric strong { font-size: 11px; font-variant-numeric: tabular-nums; }
.funding-metric strong { color: #d7b870; }
.candle-metric strong { color: #c4d6dc; letter-spacing: .03em; }
.oi-metric { min-width: 135px; }
.unit-switch { display: inline-flex; margin-left: 3px; padding: 1px; border-radius: 4px; background: #071217; vertical-align: middle; }
.unit-switch button { padding: 1px 4px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 7px; cursor: pointer; }
.unit-switch button.active { background: #263d47; color: var(--text); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.status-pill { display: flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 10px; white-space: nowrap; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 10px currentColor; }
.status-pill.connected i { background: var(--green); }
.status-pill.error i { background: var(--red); }

.pair-menu { position: fixed; z-index: 40; top: 61px; left: 18px; width: 292px; padding: 10px; border: 1px solid #263c47; border-radius: 14px; background: #0f2028; box-shadow: 0 24px 70px rgba(0,0,0,.45); transform: translateY(-8px); opacity: 0; visibility: hidden; transition: .18s ease; }
.pair-menu.open { transform: translateY(0); opacity: 1; visibility: visible; }
.pair-search-wrap { height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: 9px; background: #09151b; color: var(--muted); }
.pair-search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.pair-option { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; margin-top: 5px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; text-align: left; }
.pair-option:hover, .pair-option.active { background: #162b34; }
.pair-option > span:last-child { margin-left: auto; text-align: right; }
.pair-option strong, .pair-option small { display: block; }
.pair-option strong { font-size: 12px; }
.pair-option small { margin-top: 2px; color: var(--muted); font-size: 9px; }

main { height: calc(100vh - 68px); display: grid; grid-template-columns: 44px minmax(0, 1fr) 286px; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 5px; overflow-y: auto; border-right: 1px solid var(--line); background: #09141a; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail button { width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted-2); cursor: pointer; }
.rail button:hover, .rail button.active { color: #cfdcff; background: rgba(109, 140, 255, .12); border-color: rgba(109, 140, 255, .3); }
.rail span { flex: 1; }

.tools-panel { position: fixed; z-index: 42; top: 76px; left: 51px; width: 356px; max-height: calc(100vh - 92px); overflow: hidden; border: 1px solid #29414d; border-radius: 14px; background: rgba(13, 27, 34, .98); box-shadow: 0 26px 80px rgba(0,0,0,.58); backdrop-filter: blur(20px); }
.tools-panel[hidden] { display: none; }
.tools-panel header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 9px; }
.tools-panel header strong, .tools-panel header small { display: block; }
.tools-panel header strong { font-size: 13px; }
.tools-panel header small { margin-top: 3px; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.tools-panel header button { width: 27px; height: 27px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); font-size: 18px; cursor: pointer; }
.tools-panel header button:hover { background: #1b3039; color: var(--text); }
.tools-search { height: 36px; display: flex; align-items: center; gap: 8px; margin: 0 10px 8px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: #20323b; color: var(--muted); }
.tools-search:focus-within { border-color: #4a6572; }
.tools-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 10px; }
.tools-list { max-height: calc(100vh - 190px); padding: 0 7px 10px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #314954 transparent; }
.tools-section-title { padding: 10px 9px 6px; color: #8297a0; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.tool-option { width: 100%; min-height: 38px; display: grid; grid-template-columns: 32px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 5px 9px; border: 0; border-radius: 8px; background: transparent; color: #d8e4e8; cursor: pointer; text-align: left; }
.tool-option:hover, .tool-option.active { background: #1a303a; color: #fff; }
.tool-option > span { display: grid; place-items: center; width: 30px; height: 28px; color: #9bb1ba; font-size: 18px; }
.tool-option strong { font-size: 11px; font-weight: 600; }
.tool-option small { color: #607984; font-size: 8px; }

.workspace { min-width: 0; position: relative; display: grid; grid-template-rows: 42px minmax(0, 1fr) 34px; }
.chart-toolbar { min-width: 0; display: flex; align-items: center; gap: 7px; padding: 0 10px; border-bottom: 1px solid var(--line); background: #0a161c; }
.toolbar-group { display: flex; align-items: center; gap: 3px; }
.chart-toolbar button { height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); font-size: 11px; cursor: pointer; }
.chart-toolbar button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.timeframe-group button { min-width: 36px; padding: 0 9px; font-weight: 700; }
.timeframe-group button.active { color: #fff; background: #1e3440; }
.divider { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.toolbar-action { padding: 0 9px; }
.chart-type-trigger { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chart-type-menu { position: absolute; z-index: 34; top: 47px; left: 246px; width: 208px; padding: 6px; border: 1px solid #29414d; border-radius: 11px; background: rgba(13, 27, 34, .98); box-shadow: 0 20px 60px rgba(0,0,0,.5); backdrop-filter: blur(16px); }
.chart-type-menu[hidden] { display: none; }
.chart-type-menu button { width: 100%; height: 38px; display: grid; grid-template-columns: 28px 1fr 18px; align-items: center; gap: 6px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); cursor: pointer; text-align: left; }
.chart-type-menu button:hover, .chart-type-menu button.active { background: #1a303a; color: #fff; }
.chart-type-menu button strong { font-size: 10px; }
.chart-type-menu button i { color: var(--green); font-style: normal; }
.layers-trigger b { margin-left: 3px; padding: 2px 4px; border-radius: 4px; background: #1a2b33; color: #8ca1aa; font-size: 8px; font-weight: 700; }
.layers-trigger.open { color: #dbe7ff; background: rgba(109,140,255,.13); }
.chart-note { min-width: 0; margin-left: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.icon-button { margin-left: auto; width: 30px; }

.layers-panel { position: absolute; z-index: 30; top: 48px; left: 8px; width: 304px; max-height: calc(100% - 64px); overflow: hidden; border: 1px solid #263c47; border-radius: 13px; background: rgba(14, 29, 37, .98); box-shadow: 0 24px 70px rgba(0,0,0,.52); backdrop-filter: blur(18px); }
.layers-panel[hidden] { display: none; }
.layers-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 10px; }
.layers-panel-head strong, .layers-panel-head small { display: block; }
.layers-panel-head strong { font-size: 12px; }
.layers-panel-head small { margin-top: 3px; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.layers-panel-head button { width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); font-size: 18px; cursor: pointer; }
.layers-panel-head button:hover { background: #1b3039; color: var(--text); }
.layers-search { height: 36px; display: flex; align-items: center; gap: 7px; margin: 0 10px 8px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: #263640; color: #81959e; }
.layers-search:focus-within { border-color: #47606d; }
.layers-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 10px; }
.layers-list { max-height: calc(100vh - 240px); padding: 0 6px 6px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #314954 transparent; }
.layer-item { display: grid; grid-template-columns: 12px minmax(0,1fr) 25px 31px; align-items: center; gap: 7px; min-height: 50px; padding: 6px 8px; border-radius: 9px; transition: background .16s; }
.layer-item:hover, .layer-item.enabled { background: #1a2d36; }
.layer-dot { width: 9px; height: 9px; border-radius: 50%; background: #52646c; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.layer-item.enabled .layer-dot { background: var(--layer-color, #6d8cff); box-shadow: 0 0 10px color-mix(in srgb, var(--layer-color, #6d8cff) 65%, transparent); }
.layer-copy { min-width: 0; cursor: pointer; }
.layer-copy strong, .layer-copy small { display: block; }
.layer-copy strong { font-size: 10px; }
.layer-copy small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 8px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.layer-settings { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: #617983; font-size: 11px; cursor: pointer; }
.layer-settings:hover { color: #a8bdc6; background: #223842; }
.layer-switch { position: relative; width: 30px; height: 17px; }
.layer-switch input { position: absolute; opacity: 0; }
.layer-switch span { position: absolute; inset: 0; border-radius: 20px; background: #324851; cursor: pointer; transition: .18s; }
.layer-switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #edf4f5; transition: .18s; }
.layer-switch input:checked + span { background: #667fff; }
.layer-switch input:checked + span::after { transform: translateX(13px); }
.layers-legend { display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 7px; }
.layers-legend i { width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); }

.chart-stage { min-height: 0; position: relative; overflow: hidden; contain: paint; background: #071217; }
#chart { position: absolute; inset: 0; }
#tv-attr-logo { display: none !important; }
.liquidation-heatmap { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.liquidation-heatmap[hidden] { display: none; }
.analysis-layer { position: absolute; z-index: 4; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; shape-rendering: geometricPrecision; }
.analysis-zone { stroke-width: 1; vector-effect: non-scaling-stroke; }
.analysis-liquidity-zone { vector-effect: non-scaling-stroke; }
.analysis-line { fill: none; stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.analysis-label { font: 8px Inter, sans-serif; font-weight: 700; paint-order: stroke; stroke: #071217; stroke-width: 3px; }
.analysis-marker { filter: url(#softGlow); }
.drawing-layer { position: absolute; z-index: 6; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; touch-action: none; }
.drawing-layer.active { pointer-events: auto; cursor: crosshair; }
.drawing-layer.erase { cursor: not-allowed; }
.drawing-object { stroke: #7f9cff; stroke-width: 1.5; fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.drawing-fill { fill: rgba(109, 140, 255, .08); }
.drawing-guide { stroke: rgba(127, 156, 255, .64); stroke-dasharray: 5 4; }
.drawing-highlighter { stroke: rgba(244, 211, 80, .46); stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.drawing-ghost { stroke: #a18bff; stroke-width: 2; stroke-dasharray: 7 4; opacity: .78; }
.drawing-measure.up { fill: rgba(34, 197, 154, .12); stroke: #22c59a; }
.drawing-measure.down { fill: rgba(239, 89, 101, .12); stroke: #ef5965; }
.drawing-measure-tooltip { stroke-width: 1; }
.drawing-measure-tooltip.up { fill: #0b2b24; stroke: #22c59a; }
.drawing-measure-tooltip.down { fill: #331920; stroke: #ef5965; }
.drawing-measure-text { fill: #eef8f8; stroke-width: 2px; font-weight: 800; }
.drawing-handle { fill: #f1f5f8; stroke: #6d8cff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.drawing-label { fill: #b8c8ff; font: 10px Inter, sans-serif; paint-order: stroke; stroke: #071217; stroke-width: 3px; stroke-linejoin: round; }
.drawing-hit { stroke: transparent; stroke-width: 14; fill: none; pointer-events: stroke; cursor: pointer; }
.drawing-hint { position: absolute; z-index: 8; left: 50%; top: 10px; transform: translateX(-50%); padding: 6px 9px; border: 1px solid #2b4350; border-radius: 7px; background: rgba(10,24,30,.94); color: var(--muted-2); font-size: 9px; pointer-events: none; }
.chart-watermark { position: absolute; z-index: 2; top: 20px; left: 22px; display: grid; pointer-events: none; }
.chart-watermark strong { color: rgba(211, 230, 235, .13); font-size: clamp(25px, 3vw, 46px); line-height: 1; letter-spacing: -.04em; }
.chart-watermark span { margin-top: 8px; color: rgba(148, 174, 183, .19); font-size: 10px; }
.loading-panel, .error-panel { position: absolute; z-index: 10; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(7, 18, 23, .9); text-align: center; }
.loading-panel.hidden { display: none; }
.loading-panel strong, .error-panel strong { font-size: 14px; }
.loading-panel span, .error-panel span { max-width: 330px; color: var(--muted); font-size: 11px; }
.loader { width: 30px; height: 30px; border: 2px solid #18323c; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-panel[hidden] { display: none; }
.error-panel button { margin-top: 5px; padding: 8px 15px; border: 1px solid #31505e; border-radius: 8px; background: #132731; cursor: pointer; }

.rangebar { display: flex; align-items: center; gap: 12px; padding: 0 12px; border-top: 1px solid var(--line); background: #09151b; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.range-buttons { display: flex; gap: 2px; }
.range-buttons button { height: 24px; min-width: 31px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-2); font-size: 9px; cursor: pointer; }
.range-buttons button:hover, .range-buttons button.active { color: var(--text); background: #172931; }
.timezone { margin-left: auto; }
.timezone b { color: var(--muted-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.market-panel { overflow: auto; padding: 12px 13px 18px; border-left: 1px solid var(--line); background: #0b171d; scrollbar-width: thin; scrollbar-color: #2a414b transparent; }
.market-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.eyebrow { color: var(--muted); font-size: 8px; letter-spacing: .14em; }
.market-heading h2 { margin: 5px 0 0; font-size: 14px; }
.live-badge { padding: 4px 6px; border: 1px solid rgba(34,197,154,.22); border-radius: 5px; color: var(--green); background: var(--green-soft); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.side-price { display: flex; align-items: baseline; gap: 10px; margin-top: 14px; }
.side-price strong { font-size: 27px; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.side-price span { font-size: 11px; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.stats-grid > div { min-width: 0; display: grid; gap: 5px; padding: 11px 10px; background: #0d1c23; }
.stats-grid small { color: var(--muted); font-size: 8px; }
.stats-grid strong { overflow: hidden; color: var(--muted-2); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.futures-card { display: grid; gap: 1px; margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.futures-card > div { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; background: #0d1c23; }
.futures-card small { color: var(--muted); font-size: 8px; }
.futures-card strong { color: var(--muted-2); font-size: 9px; font-variant-numeric: tabular-nums; }
.range-card { margin-top: 12px; padding: 12px 10px; border: 1px solid var(--line); border-radius: 10px; background: #0d1c23; }
.range-title, .range-values { display: flex; justify-content: space-between; align-items: center; }
.range-title span { color: var(--muted); font-size: 9px; }
.range-title strong { font-size: 9px; color: var(--green); }
.range-track { position: relative; height: 3px; margin: 14px 3px 8px; border-radius: 10px; background: #24343b; }
.range-track i { position: absolute; inset: 0 auto 0 0; width: 50%; border-radius: inherit; background: linear-gradient(90deg, #cb9b35, var(--green)); }
.range-track b { position: absolute; top: 50%; left: 50%; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: var(--green); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px rgba(34,197,154,.12); }
.range-values { color: var(--muted); font-size: 8px; font-variant-numeric: tabular-nums; }
.data-source { display: grid; gap: 4px; margin-top: 15px; padding: 11px; border-radius: 9px; background: #09141a; }
.data-source span, .data-source small { color: var(--muted); font-size: 8px; }
.data-source strong { font-size: 10px; }

@media (max-width: 1100px) {
  .quote-strip { gap: 12px; }
  .metric { min-width: 66px; }
  .oi-metric { min-width: 120px; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { min-height: 720px; }
  .topbar { height: 108px; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .pair-button { order: 1; flex: 1; min-width: 170px; }
  .status-pill { order: 2; }
  .quote-strip { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 3px; }
  .quote-main span { font-size: 18px; }
  .metric { min-width: 70px; }
  .pair-menu { top: 55px; left: 10px; width: calc(100vw - 20px); }
  main { height: calc(100vh - 108px); min-height: 610px; grid-template-columns: 38px minmax(0, 1fr); }
  .rail { grid-column: 1; }
  .workspace { grid-column: 2; }
  .market-panel { display: none; }
  .toolbar-action span { display: none; }
  .layers-panel { left: 4px; width: min(304px, calc(100vw - 50px)); }
  .tools-panel { top: 116px; width: min(356px, calc(100vw - 54px)); max-height: calc(100vh - 130px); }
  .tools-list { max-height: calc(100vh - 225px); }
}

@media (max-width: 520px) {
  .status-pill span { display: none; }
  .chart-toolbar { gap: 2px; }
  .timeframe-group { overflow-x: auto; scrollbar-width: none; }
  .chart-note { display: none; }
  .rangebar { gap: 6px; padding: 0 6px; }
  .rangebar > span:first-child { display: none; }
  .timezone { font-size: 0; }
  .timezone b { font-size: 8px; }
}
