:root{
  --bg:#0b1220;
  --panel:#0f172a;
  --panel2:#111c33;
  --text:#e5e7eb;
  --muted:#a3adc2;
  --border:rgba(255,255,255,.10);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:16px;

  --btn:#1b2a4a;
  --btnHover:#24365e;
  --btnText:#e5e7eb;
  --primary:#3b82f6;

  /* высота липкого блока (JS выставит точно) */
  --stickyH: 344px;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 650px at 10% 0%, rgba(59,130,246,.18), transparent 55%),
              radial-gradient(900px 550px at 90% 30%, rgba(34,197,94,.10), transparent 60%),
              var(--bg);
  color:var(--text);
  height:100vh;
  overflow:hidden;
}

.app{
  display:grid;
  grid-template-columns: 360px 1fr;
  height:100vh;
}

.sidebar{
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent 35%), var(--panel);
  border-right:1px solid var(--border);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-width:280px;
  min-height:0;
}

.brand{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background: rgba(255,255,255,.03);
  box-shadow:var(--shadow);
}
.brandTitle{font-weight:700; font-size:14px}
.brandSub{color:var(--muted); font-size:12px; margin-top:2px}

.searchBox{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background: rgba(255,255,255,.03);
}

.input{
  width:100%;
  background: transparent;
  border:0;
  outline:none;
  color:var(--text);
  font-size:14px;
}
.input::placeholder{color: rgba(163,173,194,.8)}

.btn{
  border:1px solid rgba(255,255,255,.14);
  background: var(--btn);
  color: var(--btnText);
  border-radius: 12px;
  padding:8px 10px;
  cursor:pointer;
  font-size:13px;
}
.btn:hover{background: var(--btnHover)}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn.primary{
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.45);
}
.btn.primary:hover{background: rgba(59,130,246,.28)}
.btn.icon{width:40px; display:flex; align-items:center; justify-content:center}

.chips{display:flex; gap:10px; flex-wrap:wrap}
.chip{
  border:1px solid var(--border);
  border-radius:999px;
  padding:6px 10px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-size:12px;
}
.chip b{color:var(--text)}

.list{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  overflow:auto;
  padding:6px;
  flex:1;
  min-height:0;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px;
  border-radius: 14px;
  cursor:pointer;
}
.row:hover{background: rgba(255,255,255,.05)}
.row.active{background: rgba(59,130,246,.20); outline:1px solid rgba(59,130,246,.25)}

.iconWrap{
  width:36px; height:36px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
}
.iconWrap img{width:32px;height:32px; image-rendering: pixelated;}

.name{font-weight:650; font-size:13px; margin:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.sub{margin:2px 0 0; color:var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.txt{min-width:0}

.main{
  padding:16px;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  flex-wrap:wrap;
}

.title{min-width:0}
.h1{font-size:16px; font-weight:800}
.muted{color:var(--muted); font-size:12px; margin-top:4px}

.current{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.topIcon{
  width:44px;
  height:44px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  image-rendering: pixelated;
  flex:0 0 auto;
}
.currentTxt{min-width:0}

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


.midbar{
  /* компактная панель между графиком и таблицей */
  display:grid;
  grid-template-columns: max-content 1fr;
  gap:12px;
  align-items:center;
  margin:12px 12px 0;
}

.controls--mid{
  /* НЕ растягиваемся на всю ширину, только по содержимому */
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  box-shadow: 0 8px 20px rgba(0,0,0,.16);
}

.label-btn .labelSpacer{
  height: 14px; /* имитируем строку заголовка, чтобы кнопка встала ровно */
}

.adSlot{
  /* более лёгкий виджет, чтобы не «сливался» с контролами */
  justify-self: stretch;
  min-height: 56px;
  border:1px dashed rgba(255,255,255,.14);
  border-radius:16px;
  background:
    radial-gradient(600px 180px at 30% 0%, rgba(59,130,246,.10), transparent 60%),
    rgba(255,255,255,.018);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
}

.adInner{
  color: rgba(255,255,255,.58);
  font-size: 12px;
  text-align:center;
  user-select:none;
}

/* На узких экранах — складываем блоки вертикально */
@media (max-width: 860px){
  .midbar{ grid-template-columns: 1fr; }
  .controls--mid{ width: 100%; }
}

.label{display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted)}
.select{
  appearance:none;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 12px;
  padding:8px 10px;
  font-size:13px;
  outline:none;
}
.select:focus{border-color: rgba(59,130,246,.55)}

.toggles{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.03);
  border-radius: 999px;
  cursor:pointer;
  user-select:none;
  font-size:12px;
  color: var(--muted);
}
.toggle input{ accent-color: var(--primary); }
.toggle span{ color: var(--text); font-weight:600; }

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

.panel{
  margin-top:14px;
  flex: 1;
  min-height: 0;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.overview{
  padding:16px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
}
.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  padding:14px;
}
.cardTitle{font-weight:750; font-size:13px; margin-bottom:6px}
.cardText{color:var(--muted); font-size:12px; line-height:1.35}

.itemView{
  display:flex;
  flex-direction:column;
  height:100%;
  min-height:0;
  overflow:auto;
}

/* липкий график */
.stickyWrap{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}

.chartWrap{
  padding:12px;
  height: 320px;
}
.chartWrap canvas{
  width:100% !important;
  height:100% !important;
}

.tableWrap{
  border-top:1px solid var(--border);
  overflow: auto;
  padding: 0;
  flex: 0 0 auto;
  max-height: 260px; /* таблица скроллится внутри себя, шапка не перекрывает строки */
}

.table{
  width:100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table thead th{
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(15,23,42,.98);
  border-bottom:1px solid rgba(255,255,255,.08);
  padding:10px;
  text-align:left;
}
.table td{
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 9px 10px;
  color: var(--text);
}
.table tbody tr:nth-child(2n) td{background: rgba(255,255,255,.02)}
.table tbody tr:hover td{background: rgba(59,130,246,.08)}

@media (max-width: 980px){
  .app{grid-template-columns: 320px 1fr;}
  .overview{grid-template-columns: 1fr;}
}

/* ===== Pretty Scrollbars ===== */
.list::-webkit-scrollbar,
.itemView::-webkit-scrollbar{ width: 10px; height: 10px; }
.list::-webkit-scrollbar-track,
.itemView::-webkit-scrollbar-track{
  background: rgba(255,255,255,.03);
  border-left: 1px solid rgba(255,255,255,.06);
}
.list::-webkit-scrollbar-thumb,
.itemView::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.16);
  border: 2px solid rgba(15,23,42,.65);
  border-radius: 999px;
}
.list::-webkit-scrollbar-thumb:hover,
.itemView::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,.24); }

.list, .itemView{
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) rgba(255,255,255,.05);
}


/* ===== State + Layout fixes (selection / table width) ===== */
/* Make sure flex/grid children can shrink and content can stretch */
.main { min-width: 0; }
.panel { width: 100%; max-width: none; }
.itemView { width: 100%; min-width: 0; }

/* hint cards in overview (match .card look) */
.hint-card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  padding:14px;
}

/* Overview visible only when no selection (JS toggles body classes) */
body.has-selection #overview{ display:none; }
body.no-selection #itemView{ display:none; }

/* Table should be full width; allow horizontal scroll if too many columns */
.tableWrap{
  width: 100%;
  max-width: none;
  overflow-x: auto;
  overflow-y: visible;
}
.table{
  width:100%;
  min-width: 900px;
}

/* In case itemView is shown without a selection, hide table header/body */
body.no-selection .table thead,
body.no-selection .table tbody{
  display:none;
}


/* ===== State + Layout fixes (selection / table width) ===== */
/* Make sure flex/grid children can shrink and content can stretch */
.main { min-width: 0; }
.panel { width: 100%; max-width: none; }
.itemView { width: 100%; min-width: 0; }

/* hint cards in overview (match .card look) */
.hint-card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  padding:14px;
}

/* Overview visible only when no selection (JS toggles body classes) */
body.has-selection #overview{ display:none; }
body.no-selection #itemView{ display:none; }

/* Table should be full width; allow horizontal scroll if too many columns */
.tableWrap{
  width: 100%;
  max-width: none;
  overflow-x: auto;
  overflow-y: visible;
}
.table{
  width:100%;
  min-width: 900px;
}

/* In case itemView is shown without a selection, hide table header/body */
body.no-selection .table thead,
body.no-selection .table tbody{
  display:none;
}
.brandSub {
  font-size: 12px;
  color: #8fa3c8;
  opacity: 0.9;
}

.brandSub .tgLink {
  color: #4da3ff;
  text-decoration: none;
  font-weight: 500;
  padding-left: 2px;
}

.brandSub .tgLink:hover {
  color: #7fbaff;
  text-decoration: underline;
}

.brandSub .tgLink::before {
  content: "📢 ";
  font-size: 12px;
}
