/* ─────────────────────────────────────────────
   style.css — ToxaCapital · Blue + Green theme
   Dark / Light / Mobile
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════
   DARK THEME (default)
   ══════════════════════════════════════════════ */
:root {
  --bg:      #07080d;
  --bg2:     #0b0d14;
  --bg3:     #10121a;
  --bg4:     #161922;
  --bg5:     #1c2030;
  --border:  #181b28;
  --border2: #1e2235;
  --border3: #262d45;
  --text:    #e8eef8;
  --text2:   #7a8fab;
  --text3:   #3a4560;
  --shadow:  rgba(0,0,0,.5);

  --blue:      #3db8f5;
  --blue2:     #1a9de0;
  --blue-dim:  rgba(61,184,245,.07);
  --blue-glow: rgba(61,184,245,.25);
  --green:     #00d97e;
  --green2:    #00a85e;
  --green-dim: rgba(0,217,126,.08);
  --red:       #ff3d5a;
  --yellow:    #f5c842;
  --purple:    #b57aff;
  --teal:      #00c4b4;
  --orange:    #3db8f5; /* alias */

  --topbar-bg:  linear-gradient(180deg,#0e1018 0%,#0b0d14 100%);
  --sidebar-bg: linear-gradient(180deg,#0c0e16 0%,#090b12 100%);

  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
  --topbar-h:  46px;
  --sidebar-w: 182px;
}

/* ══════════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:      #f4f5f8;
  --bg2:     #ffffff;
  --bg3:     #f0f1f5;
  --bg4:     #e8eaf0;
  --bg5:     #dde0ea;
  --border:  #dde1ec;
  --border2: #cdd2e0;
  --border3: #b8bfd0;
  --text:    #0f1624;
  --text2:   #4a5878;
  --text3:   #8a96b0;
  --shadow:  rgba(0,0,0,.1);

  --blue:      #1a7ec8;
  --blue2:     #1265a8;
  --blue-dim:  rgba(26,126,200,.08);
  --blue-glow: rgba(26,126,200,.2);
  --green:     #00935a;
  --green2:    #007045;
  --green-dim: rgba(0,147,90,.08);
  --red:       #d42b42;
  --yellow:    #b07d00;
  --purple:    #7c3aed;
  --teal:      #0891b2;

  --topbar-bg:  linear-gradient(180deg,#ffffff 0%,#f8f9fc 100%);
  --sidebar-bg: linear-gradient(180deg,#ffffff 0%,#f8f9fc 100%);
}

/* ══════════════════════════════════════════════
   BASE
   ══════════════════════════════════════════════ */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}

/* ══════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  gap: 0;
}

.logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-decoration: none;
  margin-right: 28px;
  white-space: nowrap;
  background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
}

#main-nav {
  display: flex;
  height: var(--topbar-h);
  overflow-x: auto;
  scrollbar-width: none;
}
#main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  padding: 0 13px;
  height: var(--topbar-h);
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: .07em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-link:hover  { color: var(--text2); }
.nav-link.active { color: var(--blue); border-bottom-color: var(--blue); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.clock {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: .04em;
  white-space: nowrap;
}

/* ── THEME TOGGLE BUTTON ── */
.theme-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all .15s;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--blue); color: var(--blue); }

/* ── MOBILE MENU BUTTON ── */
.burger {
  display: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  border-radius: 2px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.burger-line {
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transition: all .2s;
}

/* ══════════════════════════════════════════════
   MOBILE NAV OVERLAY
   ══════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  z-index: 190;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
}
.mobile-nav.open { display: flex; }

.mobile-nav-link {
  display: block;
  padding: 13px 24px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  border-left: 3px solid transparent;
  letter-spacing: .03em;
  transition: all .15s;
}
.mobile-nav-link:hover  { background: var(--bg3); color: var(--text); }
.mobile-nav-link.active { color: var(--blue); border-left-color: var(--blue); background: var(--blue-dim); }

/* ══════════════════════════════════════════════
   PAGE LAYOUTS
   ══════════════════════════════════════════════ */
.page-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
}

.page-with-sidebar {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  padding: 10px 0;
  overflow-y: auto;
  transition: transform .25s;
}

.vtab {
  display: block;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text3);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.4;
}
.vtab:hover  { background: rgba(61,184,245,.04); color: var(--text2); }
.vtab.active { background: var(--blue-dim); color: var(--blue); border-left-color: var(--blue); }

[data-theme="light"] .vtab:hover { background: rgba(26,126,200,.06); }

/* ══════════════════════════════════════════════
   CONTENT
   ══════════════════════════════════════════════ */
.content {
  flex: 1;
  overflow: auto;
  padding: 18px 24px 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

#panel-stocks.active, #panel-ipo.active, #panel-idx_eq.active,
#panel-idx_bd.active, #panel-ofz.active, #panel-corp.active,
#panel-assets.active { display: flex; flex-direction: column; overflow: hidden; }

/* ══════════════════════════════════════════════
   SECTION HEADER
   ══════════════════════════════════════════════ */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sec-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.sec-cnt { font-family: var(--mono); font-size: 10px; color: var(--text3); }

/* ══════════════════════════════════════════════
   BUTTONS & CONTROLS
   ══════════════════════════════════════════════ */
.btn-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.idx-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  padding: 4px 12px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  border-radius: 2px;
}
.idx-btn:hover  { border-color: var(--blue); color: var(--blue); }
.idx-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

[data-theme="light"] .idx-btn.active { color: #fff; }

.mode-toggle { display: flex; }
.mt-btn {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  padding: 0 14px;
  height: 28px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
}
.mt-btn:first-child { border-radius: 2px 0 0 2px; }
.mt-btn:last-child  { border-radius: 0 2px 2px 0; border-left: none; }
.mt-btn:hover  { color: var(--text2); border-color: var(--border3); }
.mt-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

/* ══════════════════════════════════════════════
   FILTERS
   ══════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 14px;
}

.fi {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 10px;
  height: 28px;
  outline: none;
  transition: border-color .15s;
  border-radius: 2px;
}
.fi:focus { border-color: var(--blue); }
.fi::placeholder { color: var(--text3); }
select.fi { cursor: pointer; }
select.fi option { background: var(--bg3); color: var(--text); }

[data-theme="light"] select.fi option { background: #fff; }

.rf-item {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 0 6px;
  height: 28px;
  border-radius: 2px;
}
.rf-label  { font-family: var(--mono); font-size: 9px; color: var(--blue); text-transform: uppercase; width: 28px; flex-shrink: 0; }
.rf-input  { background: none; border: none; color: var(--text); font-family: var(--mono); font-size: 10px; width: 36px; outline: none; text-align: center; }
.rf-input::placeholder { color: var(--text3); }
.rf-sep    { color: var(--text3); font-size: 9px; }

/* ══════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 11px; }

thead tr { background: var(--bg3); border-bottom: 1px solid var(--blue); }

th {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
th:hover  { color: var(--text2); }
th.sorted { color: var(--green); }
th.right  { text-align: right; }

.arr { display: inline-block; font-size: 8px; margin-left: 3px; opacity: .35; vertical-align: middle; }
th.sorted .arr { opacity: 1; color: var(--green); }

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--blue-dim); }
tbody tr:last-child { border-bottom: none; }

td { padding: 8px 12px; font-family: var(--mono); font-size: 11px; color: var(--text2); white-space: nowrap; }
td.right { text-align: right; }
td.tk    { color: var(--blue); font-weight: 500; font-size: 12px; }
td.pos   { color: var(--green); font-weight: 500; text-align: right; }
td.neg   { color: var(--red); font-weight: 500; text-align: right; }
td.z     { color: var(--text3); text-align: right; }
td.dt    { color: var(--blue); opacity: .8; }
td.wt    { color: var(--yellow); text-align: right; }
td.sec   { color: var(--text3); font-size: 10px; }
td.lnk a { color: var(--blue); text-decoration: none; }
td.lnk a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════
   LEADERS
   ══════════════════════════════════════════════ */
.leaders-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.leaders-block { background: var(--bg2); border: 1px solid var(--border); border-radius: 2px; }
.leaders-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.leaders-head.up { color: var(--green); border-left: 3px solid var(--green); }
.leaders-head.dn { color: var(--red);   border-left: 3px solid var(--red); }

/* ══════════════════════════════════════════════
   PAGER
   ══════════════════════════════════════════════ */
.pager { display: flex; align-items: center; gap: 3px; margin-top: 12px; flex-wrap: wrap; }
.pg-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all .15s;
  min-width: 28px;
  text-align: center;
  border-radius: 2px;
}
.pg-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.pg-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.pg-btn:disabled { opacity: .2; cursor: default; }
.pg-info { font-family: var(--mono); font-size: 10px; color: var(--text3); margin-left: 8px; }

/* ══════════════════════════════════════════════
   STATUS
   ══════════════════════════════════════════════ */
.st { padding: 40px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--text3); }
.st.er { color: var(--red); }

/* ══════════════════════════════════════════════
   CHART
   ══════════════════════════════════════════════ */
.chart-layout { display: flex; overflow: hidden; }

.chart-sidebar {
  width: 210px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.cs-section { display: flex; flex-direction: column; flex: 1; min-height: 0; border-bottom: 1px solid var(--border); }
.cs-section:last-child { border-bottom: none; }
.cs-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: var(--bg3);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cs-head-title { font-family: var(--mono); font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; }
.cs-clear { font-family: var(--mono); font-size: 9px; color: var(--blue); cursor: pointer; background: none; border: none; }
.cs-clear:hover { text-decoration: underline; }
.cs-search {
  width: 100%; background: var(--bg3); border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 10px;
  padding: 6px 12px; outline: none; flex-shrink: 0;
}
.cs-search::placeholder { color: var(--text3); }
.cs-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.cs-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; transition: background .1s; }
.cs-item:hover { background: rgba(255,255,255,.03); }
.cs-item.sel   { background: var(--blue-dim); }
.cs-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--border3); flex-shrink: 0; }
.cs-name { font-family: var(--mono); font-size: 10px; color: var(--text2); flex: 1; }
.cs-item.sel .cs-name { color: var(--text); }

.chart-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chart-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg3); flex-shrink: 0; flex-wrap: wrap;
}
.pp {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 3px 10px; border: 1px solid var(--border2);
  background: var(--bg4); color: var(--text3); cursor: pointer; transition: all .15s; border-radius: 2px;
}
.pp:hover  { border-color: var(--blue); color: var(--blue); }
.pp.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.chart-hint { margin-left: auto; font-family: var(--mono); font-size: 9px; color: var(--text3); font-style: italic; }

.chart-area { flex: 1; position: relative; background: var(--bg2); min-height: 0; }
canvas { display: block; position: absolute; top: 0; left: 0; }
.chart-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.chart-empty-icon { font-size: 28px; opacity: .1; }
.chart-empty-text { font-family: var(--mono); font-size: 11px; color: var(--text3); }

.tip {
  position: absolute; background: var(--bg2);
  border: 1px solid var(--border2); padding: 10px 12px;
  font-family: var(--mono); font-size: 10px; color: var(--text);
  pointer-events: none; display: none; z-index: 20;
  min-width: 160px; box-shadow: 0 4px 24px var(--shadow); border-radius: 2px;
}
.tip-date { color: var(--blue); font-size: 9px; margin-bottom: 6px; }
.tip-row  { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tip-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tip-name { color: var(--text2); flex: 1; }
.tip-val  { color: var(--text); font-weight: 500; }

.chart-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: var(--bg3); flex-shrink: 0;
}
.chart-li { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; color: var(--text2); cursor: pointer; }
.chart-li:hover { color: var(--text); }
.chart-li-line { width: 14px; height: 2px; border-radius: 1px; flex-shrink: 0; }

/* ══════════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* ══════════════════════════════════════════════
   MOBILE — 768px и меньше
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; --topbar-h: 48px; }

  /* Скрываем десктопную навигацию */
  #main-nav { display: none; }
  .burger   { display: flex; }
  .clock    { display: none; }

  /* Топбар */
  .topbar { padding: 0 16px; }
  .logo   { margin-right: auto; font-size: 12px; }

  /* Page layout — вертикальный стек */
  .page-wrap { height: auto; min-height: calc(100vh - var(--topbar-h)); }
  .page-with-sidebar { flex-direction: column; overflow: visible; }

  /* Сайдбар становится горизонтальным скроллируемым меню */
  .sidebar {
    width: 100%;
    flex-direction: row;
    display: flex;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
    min-height: 44px;
    max-height: 44px;
    background: var(--bg2);
  }
  .sidebar::-webkit-scrollbar { display: none; }

  .vtab {
    padding: 0 16px;
    height: 44px;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }
  .vtab.active {
    border-left: none;
    border-bottom-color: var(--blue);
    background: var(--blue-dim);
  }

  /* Контент */
  .content { padding: 14px 16px 20px; }

  /* Таблицы — горизонтальный скролл */
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
  td, th { padding: 7px 10px; font-size: 10px; }
  td.tk  { font-size: 11px; }

  /* Leaders grid — одна колонка */
  .leaders-grid { grid-template-columns: 1fr; }

  /* Filter bar — вертикальный стек */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .fi { width: 100%; min-width: unset !important; }
  .rf-group, .rf-wrap { flex-wrap: wrap; }
  .rf-item { flex: 1; min-width: 80px; }

  /* Idx buttons — мелкий шрифт */
  .idx-btn { font-size: 9px; padding: 4px 8px; }

  /* Chart — sidebar убирается, список под графиком */
  .chart-layout { flex-direction: column; }
  .chart-sidebar { width: 100%; max-height: 160px; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); }
  .cs-section { min-height: 0; max-height: 160px; }

  /* Панели Trading */
  #panel-stocks.active, #panel-ipo.active, #panel-idx_eq.active,
  #panel-idx_bd.active, #panel-ofz.active, #panel-corp.active,
  #panel-assets.active { overflow: visible; height: auto; }

  .tbl-panel { overflow: visible; }

  /* Mode toggle */
  .mode-toggle { width: 100%; }
  .mt-btn { flex: 1; justify-content: center; }

  /* Sec head */
  .sec-head { flex-wrap: wrap; }

  /* Pager */
  .pager { justify-content: center; }

  /* Home news grid */
  .news-grid { grid-template-columns: 1fr !important; }
  .home-wrap { padding: 12px !important; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .content { padding: 12px 12px 16px; }
  th { font-size: 8px; padding: 7px 8px; }
  td { font-size: 10px; padding: 6px 8px; }
}
