/* AZGARD Terminal: ciemny terminal tradingowy. Bursztynowe etykiety, fosforowa biel danych,
   kierunek zawsze kolor + znak (▲▼) + slowo. Bez zaokraglen, panele dzielone liniami 1px. */

/* ---------------- fonty (self-hosted, latin + latin-ext) ---------------- */
@font-face { font-family: 'Chivo Mono'; font-weight: 400; font-display: swap; src: url(fonts/chivo-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+2212, U+2215, U+25A0-25FF; }
@font-face { font-family: 'Chivo Mono'; font-weight: 400; font-display: swap; src: url(fonts/chivo-mono-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Chivo Mono'; font-weight: 500; font-display: swap; src: url(fonts/chivo-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+2212, U+2215, U+25A0-25FF; }
@font-face { font-family: 'Chivo Mono'; font-weight: 500; font-display: swap; src: url(fonts/chivo-mono-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Chivo Mono'; font-weight: 600; font-display: swap; src: url(fonts/chivo-mono-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+2212, U+2215, U+25A0-25FF; }
@font-face { font-family: 'Chivo Mono'; font-weight: 600; font-display: swap; src: url(fonts/chivo-mono-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Archivo Black'; font-weight: 400; font-display: swap; src: url(fonts/archivo-black-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Archivo Black'; font-weight: 400; font-display: swap; src: url(fonts/archivo-black-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; }

/* ---------------- tokeny ---------------- */
:root {
  color-scheme: dark;
  --bg: oklch(0.155 0.006 70);
  --panel: oklch(0.185 0.007 70);
  --panel-2: oklch(0.215 0.009 70);
  --line: oklch(0.30 0.012 70);
  --ink: oklch(0.93 0.012 85);
  --ink-2: oklch(0.74 0.02 80);
  --ink-3: oklch(0.60 0.018 75);
  --amber: oklch(0.80 0.155 70);
  --amber-dim: oklch(0.80 0.155 70 / 0.14);
  --up: oklch(0.80 0.17 145);
  --up-dim: oklch(0.80 0.17 145 / 0.12);
  --down: oklch(0.72 0.18 25);
  --down-dim: oklch(0.72 0.18 25 / 0.12);
  --call: #3987e5;
  --put: #e66767;
  --mono: 'Chivo Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --display: 'Archivo Black', 'Arial Black', sans-serif;
  --fs-xs: 12px;
  --fs-s: 13px;
  --fs-m: 14px;
  --fs-l: 17px;
 --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Jasny motyw (na zyczenie uzytkownika; domyslny jest ciemny) */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: oklch(0.975 0.004 85);
  --panel: oklch(0.95 0.005 85);
  --panel-2: oklch(0.925 0.007 85);
  --line: oklch(0.855 0.008 80);
  --ink: oklch(0.26 0.015 75);
  --ink-2: oklch(0.44 0.02 75);
  --ink-3: oklch(0.56 0.018 75);
  --amber: oklch(0.56 0.14 60);
  --amber-dim: oklch(0.56 0.14 60 / 0.12);
  --up: oklch(0.50 0.15 150);
  --up-dim: oklch(0.50 0.15 150 / 0.12);
  --down: oklch(0.52 0.20 27);
  --down-dim: oklch(0.52 0.20 27 / 0.12);
  --call: #1f6fd4;
  --put: #cc4040;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-m)/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Delikatne linie skanowania CRT, nad trescia, bez wplywu na klikniecia */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 2px, oklch(0 0 0 / 0.07) 2px 3px);
  z-index: 50;
}
:root[data-theme='light'] body::after { background: repeating-linear-gradient(0deg, transparent 0 2px, oklch(0 0 0 / 0.022) 2px 3px); }
@media (forced-colors: active) { body::after { display: none; } }

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
a { color: var(--amber); }
kbd {
  font: 500 var(--fs-xs)/1 var(--mono);
  padding: 2px 4px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--panel-2);
}
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
::selection { background: var(--amber); color: var(--bg); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: var(--ink-2); }
.is-call { color: var(--call); }
.is-put { color: var(--put); }

#app { min-height: 100%; }
.noscript { padding: 24px; color: var(--amber); }

/* ---------------- przyciski ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--amber);
  background: transparent;
  color: var(--amber);
  font: 600 var(--fs-m)/1 var(--mono);
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.btn-primary { background: var(--amber); color: var(--bg); }
.btn-primary:hover { background: oklch(0.86 0.14 75); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn kbd { color: inherit; border-color: currentColor; background: transparent; }

/* ---------------- ekrany: logowanie, powitanie, koniec sesji ---------------- */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 28px;
  padding: clamp(20px, 6vw, 96px);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  overflow-x: hidden;
}
.eyebrow { color: var(--amber); font-size: var(--fs-s); letter-spacing: 0.12em; }
.notice { padding: 10px 12px; border: 1px solid var(--line); background: var(--panel); max-width: 60ch; }
.notice-error { border-color: var(--down); color: var(--ink); }
.notice-error b { color: var(--down); }

.login { grid-template-columns: 1fr; row-gap: clamp(20px, 5vh, 48px); }
.login-mark {
  font: 400 clamp(2.6rem, 13vw, 9rem)/0.9 var(--display);
  letter-spacing: -0.04em;
  color: var(--ink);
  white-space: nowrap;
  max-width: 100%;
}
.login-panel, .login-mark { min-width: 0; }
.login-mark span { color: var(--amber); }
.login-panel { display: grid; gap: 22px; justify-items: start; }
.login-title { font: 500 clamp(1.15rem, 2vw, 1.5rem)/1.35 var(--mono); max-width: 30ch; }
.login-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: var(--fs-s); border-top: 1px solid var(--line); padding-top: 18px; width: 100%; }
.login-facts dt { color: var(--amber); letter-spacing: 0.08em; }
.login-facts dd { color: var(--ink-2); }

.welcome { align-content: center; }
.welcome-title { display: grid; font-family: var(--display); font-weight: 400; text-transform: uppercase; }
.welcome-hello { font-size: clamp(1.4rem, 3.2vw, 2.6rem); line-height: 1; color: var(--amber); letter-spacing: -0.02em; }
.welcome-name {
  font-size: clamp(3rem, 11vw, 10rem);
  line-height: 0.88;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
  animation: rise 700ms var(--ease) both;
}
.boot { display: grid; gap: 4px; max-width: 760px; font-size: var(--fs-m); border-top: 1px solid var(--line); padding-top: 18px; }
.boot-line { display: grid; grid-template-columns: max-content 1fr max-content; gap: 10px; align-items: baseline; animation: fade 260ms var(--ease) both; }
.boot-label { color: var(--ink-2); letter-spacing: 0.06em; }
.boot-dots { border-bottom: 1px dotted var(--line); transform: translateY(-4px); }
.boot-value { color: var(--ink-3); }
.boot-value[data-state='ok'] { color: var(--up); }
.boot-value[data-state='ok']::before { content: '✓ '; }
.boot-value[data-state='warn'] { color: var(--amber); }
.boot-value[data-state='err'] { color: var(--down); }
.boot-value[data-state='err']::before { content: '✕ '; }
.welcome-enter { justify-self: start; }

.ended { justify-items: start; }
.ended-title { font: 400 clamp(2rem, 6vw, 4.5rem)/0.95 var(--display); letter-spacing: -0.03em; text-transform: uppercase; }
.ended-text { color: var(--ink-2); max-width: 56ch; font-size: var(--fs-l); }

@keyframes rise { from { opacity: 0; transform: translateY(0.25em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- terminal ---------------- */
.term {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  height: 100vh;
  height: 100dvh;
  background: var(--line);
  gap: 1px;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 60; background: var(--amber); color: var(--bg); padding: 6px 10px; }

.topbar {
  display: flex;
  align-items: stretch;
  gap: 1px;
  background: var(--line);
  font-size: var(--fs-s);
  min-width: 0;
}
.topbar > * { background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 6px 12px; white-space: nowrap; }
.topbar > .brand { gap: 0; }
.brand { font: 400 var(--fs-l)/1 var(--display); letter-spacing: -0.02em; background: var(--amber) !important; color: var(--bg); }
.brand span { color: var(--bg); opacity: 0.7; }
.brand small { font: 600 10px/1 var(--mono); letter-spacing: 0.14em; margin-left: 6px; }
.top-label { color: var(--amber); letter-spacing: 0.1em; }
.clock { font-weight: 500; }
.market[data-state='open'] { color: var(--up); }
.market[data-state='open']::before { content: '● '; }
.market[data-state='pre'], .market[data-state='post'] { color: var(--amber); }
.market[data-state='closed'] { color: var(--ink-3); }
.top-grow { flex: 1; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.live { color: var(--ink-3); }
.live[data-state='live'] { color: var(--up); }
.live[data-state='reconnecting'], .live[data-state='connecting'] { color: var(--amber); }
.live[data-state='ended'] { color: var(--down); }
.top-user img { width: 20px; height: 20px; filter: grayscale(0.3); }
.top-user span { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.top-logout { border: 0; cursor: pointer; color: var(--ink-2); letter-spacing: 0.08em; }
.theme-toggle { border: 0; background: transparent; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.theme-toggle:hover { color: var(--amber); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.screen-theme { position: fixed; top: 14px; right: 14px; z-index: 10; width: 34px; height: 34px; border: 1px solid var(--line); background: var(--panel); }
.top-logout:hover { color: var(--down); background: var(--panel) !important; }

.cmdbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  min-width: 0;
}
.cmd-prompt { color: var(--amber); font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; }
.cmd-input {
  flex: 1 1 200px;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 9px 0;
  color: var(--ink);
  font-weight: 500;
  text-transform: uppercase;
  caret-color: var(--amber);
}
.cmd-input::placeholder { color: var(--ink-3); text-transform: none; }
.cmd-input:focus-visible { outline: none; }
.cmdbar:focus-within { box-shadow: inset 0 -2px 0 var(--amber); }
.cmd-feedback { color: var(--ink-2); font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.cmd-feedback[data-state='error'] { color: var(--down); }
.cmd-help { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: var(--fs-s); white-space: nowrap; }
.cmd-help:hover { color: var(--amber); }

.help { background: var(--panel-2); padding: 12px 16px; display: grid; gap: 10px; font-size: var(--fs-s); }
.help b { color: var(--amber); letter-spacing: 0.08em; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; }
.help dt { color: var(--ink); font-weight: 600; }
.help dd { color: var(--ink-2); }
.help kbd { margin-right: 2px; }
.help-lead { color: var(--ink-2); }
.help-tour { align-self: start; margin: 2px 0 4px; }

/* Siatka paneli: kontrakty | poziomy | GEX ; pod spodem SBT | sygnaly | makro */
.grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.25fr) minmax(320px, 1.1fr);
  grid-template-rows: var(--grid-r1, 1.3fr) var(--grid-r2, 1.1fr);
  grid-template-areas:
    'watch ladder gex'
    'sbt chart macro';
  min-height: 0;
  position: relative;
}
.row-resizer { position: absolute; left: 0; right: 0; height: 9px; transform: translateY(-50%); cursor: ns-resize; z-index: 30; touch-action: none; }
.row-resizer::after { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: var(--line); transition: background-color 120ms, height 120ms; }
.row-resizer:hover::after, .row-resizer.is-active::after, .row-resizer:focus-visible::after { background: var(--amber); top: 3px; height: 3px; }
.row-resizer:focus-visible { outline: none; }
.panel { background: var(--bg); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-watch { grid-area: watch; }
.panel-ladder { grid-area: ladder; }
.panel-gex { grid-area: gex; }
.panel-sbt { grid-area: sbt; }
.panel-chart { grid-area: chart; }
.panel-macro { grid-area: macro; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 30px;
}
.panel-title { font: 600 var(--fs-s)/1 var(--mono); letter-spacing: 0.12em; color: var(--amber); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.fkey { font-size: 10px; padding: 1px 3px; color: var(--ink-3); }
.panel-meta { color: var(--ink-3); font-size: var(--fs-xs); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.panel-user { font-size: 9px; letter-spacing: 0.12em; color: var(--ink-3); opacity: 0.4; white-space: nowrap; align-self: center; flex: none; }
.panel-body { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.loading, .empty { padding: 14px 12px; color: var(--ink-3); font-size: var(--fs-s); }
.cursor { animation: blink 1s steps(1) infinite; color: var(--amber); }
@keyframes blink { 50% { opacity: 0; } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  padding: 4px 7px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed='true'] { background: var(--amber); color: var(--bg); border-color: var(--amber); font-weight: 600; }
.chip small { color: inherit; opacity: 0.7; }
.chip kbd { font-size: 10px; padding: 0 3px; }
.chip .oi { position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--oi) * 100%); background: var(--amber); opacity: 0.55; }
.chip[aria-pressed='true'] .oi { background: var(--bg); }

/* ---------------- tabele ---------------- */
.table-scroll { overflow: auto; }
.grid-table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
.grid-table th, .grid-table td { padding: 5px 10px; text-align: left; border-bottom: 1px solid oklch(0.30 0.012 70 / 0.5); font-weight: 400; white-space: nowrap; }
.grid-table thead th { position: sticky; top: 0; background: var(--bg); color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.08em; border-bottom: 1px solid var(--line); z-index: 1; }
.grid-table th.num, .grid-table td.num { text-align: right; }
.grid-table caption { text-align: left; color: var(--amber); font-size: var(--fs-xs); letter-spacing: 0.1em; padding: 10px 10px 4px; }
.grid-table tbody tr:hover { background: var(--panel); }
.ellipsis { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- kontrakty ---------------- */
.watch { font-size: var(--fs-s); outline-offset: -2px; }
.watch-group { padding: 8px 10px 3px; color: var(--ink-3); font-size: 10px; letter-spacing: 0.14em; }
.watch-row {
  display: grid;
  grid-template-columns: 5.4ch minmax(0, 1fr) auto auto;
  grid-template-areas: 'sym name price rm' 'sym dist dist rm';
  column-gap: 8px;
  padding: 4px 10px;
  cursor: pointer;
  border-top: 1px solid oklch(0.30 0.012 70 / 0.4);
}
.watch-row:hover { background: var(--panel); }
.watch-row[aria-selected='true'] { background: var(--amber-dim); box-shadow: inset 0 0 0 1px var(--amber); }
.watch-row[data-ok='false'] { opacity: 0.45; cursor: default; }
.w-sym { grid-area: sym; font-weight: 600; color: var(--ink); align-self: center; }
.w-name { grid-area: name; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-price { grid-area: price; font-weight: 500; }
.w-dist { grid-area: dist; font-size: var(--fs-xs); }
.w-sig { grid-area: sig; font-size: var(--fs-xs); }
.w-remove { grid-area: rm; align-self: center; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 14px; padding: 0 0 0 6px; line-height: 1; }
.w-remove:hover { color: var(--down); }
.watch-add { padding: 4px 10px 10px; }
.w-add { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.w-add-input { flex: 1 1 9ch; min-width: 0; background: var(--panel); border: 1px solid var(--line); padding: 4px 6px; font-size: var(--fs-s); text-transform: uppercase; color: var(--ink); }
.w-add-input::placeholder { text-transform: none; color: var(--ink-3); }
.w-add-input:focus-visible { outline: none; border-color: var(--amber); }
.w-add-status { flex-basis: 100%; color: var(--amber); font-size: var(--fs-xs); }
.w-add-status:empty { display: none; }

.sig { font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
.live-sig { color: var(--ink-3); }

/* ---------------- poziomy ---------------- */
.chips { display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.ladder-hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 22px; padding: 12px 12px 10px; }
.hero-sym { font: 400 34px/0.9 var(--display); letter-spacing: -0.03em; display: grid; gap: 4px; }
.hero-sym small { font: 400 var(--fs-xs)/1 var(--mono); color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
.hero-price { display: grid; gap: 4px; }
.hero-price .num { font-size: 26px; font-weight: 500; line-height: 1; text-align: left; }
.hero-price small, .hero-side small { color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.06em; }
.hero-side { display: grid; gap: 4px; font-weight: 600; font-size: var(--fs-s); letter-spacing: 0.04em; padding: 6px 8px; border: 1px solid currentColor; }
.hero-side.is-up { background: var(--up-dim); }
.hero-side.is-down { background: var(--down-dim); }
.hero-side small { font-weight: 400; }

.keystats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-block: 1px solid var(--line);
}
.keystats > div { background: var(--panel); padding: 6px 10px; display: grid; gap: 2px; min-width: 0; }
.keystats dt { color: var(--ink-3); font-size: 10px; letter-spacing: 0.1em; }
.keystats dd { font-weight: 500; text-align: left; }

.panel-ladder .panel-body { display: flex; flex-direction: column; overflow: hidden; }
.panel-ladder .panel-body > * { flex: none; }
.panel-ladder .ladder-scroll { flex: 1 1 auto; min-height: 120px; overflow: auto; position: relative; }
.ladder .lvl-value { font-weight: 500; width: 1%; }
.ladder .lvl-label { color: var(--ink-2); }
.ladder .lvl-src, .ladder .lvl-pct { color: var(--ink-3); font-size: var(--fs-xs); }
.ladder .lvl-src { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
.lvl-core .lvl-label { color: var(--ink); font-weight: 600; }
.lvl-0dte .lvl-label { color: var(--amber); }
.lvl-gex .lvl-label, .lvl-gex .lvl-value { color: var(--ink-2); }
.lvl-gex.is-call-wall .lvl-label { color: color-mix(in oklch, var(--call) 80%, var(--ink-2)); }
.lvl-gex.is-put-wall .lvl-label { color: color-mix(in oklch, var(--put) 80%, var(--ink-2)); }
.lvl-price { background: var(--panel-2); }
.lvl-price td, .lvl-price th { color: var(--ink) !important; font-weight: 600 !important; border-block: 1px solid var(--ink-3) !important; }
.lvl-price .lvl-label::before { content: '▶ '; color: var(--amber); }
.lvl-hvl { background: var(--amber-dim); }
.lvl-hvl td, .lvl-hvl th { color: var(--amber) !important; font-weight: 600 !important; border-block: 1px dashed var(--amber) !important; }
.lvl-hvl-note { font-weight: 400 !important; font-size: var(--fs-xs); letter-spacing: 0.06em; }
.lvl-group td { font-size: 10px; letter-spacing: 0.1em; padding-top: 8px !important; border-bottom: 0 !important; }
.sources { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 12px 14px; color: var(--ink-3); font-size: var(--fs-xs); }
.sources .note { color: var(--ink-2); flex-basis: 100%; }

/* ---------------- GEX ---------------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 12px 4px; font-size: var(--fs-xs); color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; display: inline-block; }
.sw.is-call { background: var(--call); }
.sw.is-put { background: var(--put); }
.panel-gex .panel-body { display: flex; flex-direction: column; overflow: hidden; }
.panel-gex .legend, .panel-gex .gex-stats { flex: none; }
.panel-gex .gex-chart { flex: 1 1 auto; min-height: 140px; }
.panel-gex .table-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.gex-chart { position: relative; padding: 4px 6px; overflow: hidden; }
.gex-svg { display: block; margin: 0 auto; max-width: 100%; font-family: var(--mono); }
.gex-zero { stroke: var(--ink-3); stroke-width: 1; }
.gex-call { fill: var(--call); }
.gex-put { fill: var(--put); }
.gex-axis { fill: var(--ink-3); font-size: 10.5px; letter-spacing: 0.02em; }
.gex-hit { fill: transparent; cursor: crosshair; }
.gex-row.is-hover .gex-hit { fill: oklch(0.93 0.012 85 / 0.06); }
.gex-row.is-hover .gex-axis { fill: var(--ink); }
.gex-line { stroke-width: 1; pointer-events: none; }
.gex-line.is-price { stroke: var(--ink); }
.gex-line.is-hvl { stroke: var(--amber); stroke-dasharray: 4 3; }
.gex-line-label { font-size: 10.5px; font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.gex-line-label.is-price { fill: var(--ink); }
.gex-line-label.is-hvl { fill: var(--amber); }
.gex-tip {
  position: absolute;
  left: 0;
  top: 0;
  width: 180px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  pointer-events: none;
  z-index: 5;
}
.gex-tip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 6px; }
.gex-tip dt { color: var(--ink-3); }
.gex-tip dd { text-align: right; }
.gex-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 9px 12px; font-size: var(--fs-xs); border-top: 1px solid var(--line); }
.gex-stats > div { display: grid; gap: 2px; }
.gex-stats dt { color: var(--ink-3); letter-spacing: 0.08em; }
.gex-stats dd { font-weight: 500; text-align: left; }

/* ---------------- SBT (kafelki) ---------------- */
.sbt-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; padding: 10px; }
.sbt-tile {
  position: relative; display: grid; grid-template-rows: auto auto auto 1fr; gap: 4px;
  min-height: 104px; padding: 12px 14px 12px; text-align: left; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; overflow: hidden;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
/* Wypelnienie tla w kolorze stanu: od dolu, delikatnie — stan czytelny z daleka */
.sbt-tile::after { content: ''; position: absolute; inset: auto 0 0 0; height: 100%; pointer-events: none; opacity: 0; transition: opacity 200ms var(--ease); }
.sbt-tile[data-sig='LONG'] { border-color: color-mix(in oklch, var(--up) 45%, transparent); }
.sbt-tile[data-sig='LONG']::after { opacity: 1; background: linear-gradient(to top, var(--up-dim), transparent 70%); }
.sbt-tile[data-sig='SHORT'] { border-color: color-mix(in oklch, var(--down) 45%, transparent); }
.sbt-tile[data-sig='SHORT']::after { opacity: 1; background: linear-gradient(to top, var(--down-dim), transparent 70%); }
.sbt-tile[data-sig='gate'], .sbt-tile[data-sig='none'] { background: var(--bg); }
.sbt-tile:hover { border-color: var(--amber); }
.sbt-tile:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.sbt-tile.flash { animation: flash 900ms var(--ease); }
.sbt-tile > * { position: relative; z-index: 1; }
.sbt-tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sbt-tile-name { font: 400 22px/1 var(--display); letter-spacing: 0.01em; color: var(--ink); }
.sbt-tile-group { font-size: 10px; letter-spacing: 0.14em; color: var(--ink-3); }
.sbt-tile-desc { font-size: var(--fs-xs); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbt-tile-hours { font-size: 10px; letter-spacing: 0.1em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sbt-tile-sig { align-self: end; display: flex; align-items: center; gap: 7px; font-size: 17px; font-weight: 600; letter-spacing: 0.08em; }
.sbt-tile-glyph { font-size: 13px; }
.sbt-tile-sig.is-flat { color: var(--ink-3); font-size: var(--fs-xs); font-weight: 500; }
.sbt-tile-sig.is-gate { color: var(--amber); font-size: var(--fs-s); font-weight: 500; letter-spacing: 0.1em; }

/* ---------------- SBT ---------------- */
.sbt-row { cursor: pointer; }
.sbt th, .sbt td { padding-inline: 7px; }
.sbt th[scope='row'] { font-weight: 600; color: var(--ink); }
.sbt .wr { display: flex; align-items: center; gap: 8px; }
.sbt .wr .num { min-width: 5ch; }
.gauge { position: relative; width: 60px; height: 8px; background: var(--panel-2); display: inline-block; flex: none; }
.gauge-zone { position: absolute; top: 0; bottom: 0; }
.gauge-zone.is-down { left: 0; width: 30%; background: var(--down-dim); }
.gauge-zone.is-up { right: 0; width: 30%; background: var(--up-dim); }
.gauge b { position: absolute; top: -2px; bottom: -2px; width: 2px; left: calc(var(--pos) * 100% - 1px); background: var(--ink); transition: left 400ms var(--ease); }
.flash { animation: flash 900ms var(--ease); }
@keyframes flash { from { background: var(--amber-dim); } to { background: transparent; } }

/* ---------------- edytor instrumentow ---------------- */
.sbt th small { font-weight: 400; font-size: var(--fs-xs); }
.picker-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.picker-count { color: var(--ink-2); font-size: var(--fs-xs); letter-spacing: 0.08em; }
.picker-actions { display: flex; gap: 4px; }
.chip.is-primary { background: var(--amber); color: var(--bg); border-color: var(--amber); font-weight: 600; }
.chip:disabled { opacity: 0.5; cursor: default; }
.picker-status { padding: 0 10px; color: var(--amber); font-size: var(--fs-xs); min-height: 0; }
.picker-status:empty { display: none; }
.picker fieldset { border: 0; margin: 0; padding: 6px 10px 2px; }
.picker legend { color: var(--ink-3); font-size: 10px; letter-spacing: 0.14em; padding: 0 0 3px; }
.pick { display: grid; grid-template-columns: auto 5ch 1fr auto; align-items: center; gap: 8px; padding: 3px 4px; font-size: var(--fs-s); cursor: pointer; }
.pick:hover { background: var(--panel); }
.pick input { accent-color: var(--amber); margin: 0; }
.pick-tag { font-size: 9px; letter-spacing: 0.08em; color: var(--amber); border: 1px solid oklch(0.80 0.155 70 / 0.5); padding: 0 3px; }

/* ---------------- wykres ---------------- */
.chips-inline { display: flex; gap: 3px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chart-head-tools { display: flex; gap: 6px; align-items: center; min-width: 0; }
.panel-chart .panel-body { overflow: hidden; position: relative; }
.chip-icon { font-size: 15px; line-height: 1; padding-inline: 7px; }
/* Pelny ekran: Fullscreen API (:fullscreen) albo zastepczo panel na cale okno (.is-max) */
.panel-chart:fullscreen, .panel-chart.is-max {
  position: fixed; inset: 0; z-index: 1000;
  width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  background: var(--bg);
}
.panel-chart:fullscreen::backdrop { background: var(--bg); }
body.has-max-chart { overflow: hidden; }
.chart-host { position: absolute; inset: 0; }
.chart-svg { display: block; font-family: var(--mono); }
.ch-grid { stroke: oklch(0.30 0.012 70 / 0.55); stroke-width: 1; }
.ch-day { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-axis { fill: var(--ink-3); font-size: 10.5px; letter-spacing: 0.02em; }
.ch-axis-line { stroke: var(--line); stroke-width: 1; }
.ch-axis.is-day { fill: var(--ink-2); font-weight: 600; }
.ch-wick { stroke-width: 1; }
.ch-wick.is-up { stroke: var(--up); }
.ch-wick.is-down { stroke: var(--down); }
.ch-body.is-up { fill: var(--up); }
.ch-body.is-down { fill: var(--down); }
.ch-state.is-up { fill: var(--up); opacity: 0.75; }
.ch-state.is-down { fill: var(--down); opacity: 0.75; }
.ch-state.is-flat { fill: var(--line); }
.ch-level { stroke-width: 1; stroke: var(--ink-3); stroke-dasharray: 1 3; }
.ch-level.is-call { stroke: var(--call); stroke-dasharray: none; }
.ch-level.is-put { stroke: var(--put); stroke-dasharray: none; }
.ch-level.is-0dte { stroke-dasharray: 5 3; }
.ch-level.is-hvl { stroke: var(--amber); stroke-dasharray: 6 3; stroke-width: 1.25; }
.ch-level.is-range { stroke: var(--ink-2); stroke-dasharray: 2 2; }
.ch-level-label, .ch-edge { font-size: 10.5px; font-weight: 600; fill: var(--ink-3); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.ch-level-label.is-call, .ch-edge.is-call { fill: var(--call); }
.ch-level-label.is-put, .ch-edge.is-put { fill: var(--put); }
.ch-level-label.is-hvl, .ch-edge.is-hvl { fill: var(--amber); }
.ch-level-label.is-range, .ch-edge.is-range { fill: var(--ink-2); }
.ch-level-label.is-0dte, .ch-edge.is-0dte { fill: var(--amber); }
.ch-level-label.is-call.is-0dte, .ch-edge.is-call.is-0dte { fill: var(--call); }
.ch-level-label.is-put.is-0dte, .ch-edge.is-put.is-0dte { fill: var(--put); }
/* Sciany GEX: kolor strony (call / put), linia kropkowana i przygaszona — slabsze niz Call Res / Put Sup */
.ch-level.is-call-wall { stroke: color-mix(in oklch, var(--call) 70%, transparent); }
.ch-level.is-put-wall { stroke: color-mix(in oklch, var(--put) 70%, transparent); }
.ch-level-label.is-call-wall, .ch-edge.is-call-wall { fill: color-mix(in oklch, var(--call) 80%, var(--ink-3)); }
.ch-level-label.is-put-wall, .ch-edge.is-put-wall { fill: color-mix(in oklch, var(--put) 80%, var(--ink-3)); }
.ch-vol { opacity: 0.32; }
.ch-vol.is-up { fill: var(--up); }
.ch-vol.is-down { fill: var(--down); }
.ch-last { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 1 2; }
.ch-last-tag { fill: var(--ink); }
.ch-last-text { fill: var(--bg); font-size: 10.5px; font-weight: 600; }
.ch-hit { fill: transparent; cursor: crosshair; touch-action: none; }
.ch-axis-hit { fill: transparent; cursor: ns-resize; touch-action: none; }
.chart-host { user-select: none; }
.chart-host.is-dragging .ch-hit { cursor: grabbing; }
.gex-chart { cursor: grab; user-select: none; touch-action: none; }
.gex-chart.is-dragging { cursor: grabbing; }
.ch-cross-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.ch-cross-tag { fill: var(--panel-2); stroke: var(--ink-3); }
.ch-cross-text { fill: var(--ink); font-size: 10px; }
.ch-tip { position: absolute; left: 0; top: 0; width: 138px; padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: var(--fs-xs); pointer-events: none; z-index: 5; }
.ch-tip dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin-top: 4px; }
.ch-tip dt { color: var(--ink-3); }
.ch-tip dd { text-align: right; }

/* ---------------- makro ---------------- */
.macro-bar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.panel-macro .panel-body { display: flex; flex-direction: column; overflow: hidden; }
.macro-scroll { flex: 1; min-height: 0; overflow: auto; }
.macro .day-row th { background: var(--panel); color: var(--amber); font-size: var(--fs-xs); letter-spacing: 0.1em; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.macro tr.is-past { opacity: 0.45; }
.macro.cal th[scope='row'] { white-space: normal; min-width: 18ch; }
.macro .imp { color: var(--amber); }
.macro .imp.is-mid { color: var(--ink-3); }
.panel-macro .small { padding: 8px 10px 12px; }

/* Logowanie w dwoch kolumnach dopiero gdy jest na to miejsce */
@media (min-width: 960px) {
  .login { grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr); align-items: center; column-gap: clamp(24px, 5vw, 80px); }
  .login-mark { font-size: clamp(4rem, 7vw, 7.5rem); }
}

/* ---------------- przewodnik ---------------- */
.tour { position: fixed; inset: 0; z-index: 200; }
.tour-scrim { position: absolute; inset: 0; }
.tour-hole { position: absolute; border: 1px solid var(--amber); box-shadow: 0 0 0 9999px oklch(0.1 0.01 70 / 0.7); transition: all 240ms var(--ease); pointer-events: none; border-radius: 1px; }
:root[data-theme='light'] .tour-hole { box-shadow: 0 0 0 9999px oklch(0.35 0.01 70 / 0.45); }
.tour-pop { position: absolute; background: var(--panel-2); border: 1px solid var(--amber); padding: 14px 16px; display: grid; gap: 8px; box-shadow: 0 8px 28px oklch(0 0 0 / 0.4); transition: top 240ms var(--ease), left 240ms var(--ease); }
.tour-title { font: 400 var(--fs-l)/1 var(--display); color: var(--amber); letter-spacing: 0.01em; }
.tour-text { color: var(--ink); font-size: var(--fs-s); line-height: 1.5; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.tour-count { color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.1em; }
.tour-btns { display: flex; gap: 6px; }
.tour-x { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; }
.tour-x:hover { color: var(--down); }

/* ---------------- responsywnosc ---------------- */
@media (max-width: 1280px) {
  .grid {
    grid-template-columns: minmax(200px, 0.7fr) minmax(0, 1.3fr);
    grid-template-rows: minmax(520px, auto) minmax(420px, auto) minmax(300px, auto);
    grid-template-areas:
      'watch ladder'
      'gex ladder'
      'sbt chart'
      'macro macro';
  }
  .term { height: auto; min-height: 100vh; }
  .grid { grid-template-rows: none; grid-auto-rows: auto; }
  .row-resizer { display: none; }
  .panel-watch, .panel-ladder { max-height: 80vh; }
  .panel-gex { max-height: 70vh; }
  .panel-sbt, .panel-macro { max-height: 60vh; }
  .panel-chart { height: 56vh; }
}
@media (max-width: 820px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'ladder' 'watch' 'chart' 'gex' 'sbt' 'macro'; }
  .term { height: auto; min-height: 100vh; min-height: 100dvh; }
  .panel-watch { max-height: 46vh; }
  .panel-ladder .ladder-scroll, .panel-gex, .panel-sbt, .panel-macro, .panel-chart { max-height: 72vh; }
  .panel-chart { height: 62vh; }
  .topbar { flex-wrap: wrap; row-gap: 1px; }
  .topbar > * { padding: 6px 9px; }
  .top-grow, .top-user { display: none; }
  .brand { flex: 1 0 auto; }
  .cmd-feedback, .cmd-help { display: none; }
  .cmd-input { font-size: 16px; }
  .chips-inline { flex-wrap: wrap; overflow-x: visible; }
  .chart-head-tools { flex-wrap: wrap; }
  .gex-stats, .sources { gap: 6px 14px; }
  /* wieksze cele dotykowe */
  .chip, .top-logout, .w-remove, .cmd-help { min-height: 34px; }
  .watch-row, .sbt-row, .lvl, .pick { min-height: 32px; }
  .keystats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { grid-template-columns: 1fr; }
  .ladder .lvl-src { display: none; }
  .panel-ladder .ladder-scroll { max-height: 60vh; }
  .lvl-group td { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
