:root{
  color-scheme: dark;

  --bg: #1f2228;
--card: #262a33;
--border: #343a46;

--text: #e6e6e6;
--muted: #3aa76d;
--accent: #f4b942;
  /* янтарный акцент */


  --r: 12px;
  --pad: 12px;
  --gap: 4px;

  .live { color: #3ecf8e; }
  .percent { color: #4cd38a; }
  

  
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
}

h1{ margin:0; font-size:18px; letter-spacing:.2px; }
h2{ margin:0; font-size:14px; }
h3{ margin:0; }

.muted{ color: var(--muted); font-size:12px; }

.pill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  color: var(--muted);
  font-size:11px;
}

input, select, button{
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
}

button{
  cursor:pointer;
  border-color:#969c6c;
}
button:hover{ border-color: var(--accent); }

label{
  display:flex;
  gap:6px;
  align-items:center;
  font-size:12px;
  color: var(--muted);
  white-space: nowrap;
}

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

.langSelect{
  padding-inline:10px;
  font-weight:700;
  letter-spacing:.5px;
}

/* ---------- Header ---------- */
.top{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:14px;
  padding: 14px 16px;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  background: rgba(55,55,55,.92);
  backdrop-filter: blur(8px);
  z-index:10;
}

.topLeft{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width: 260px;
}

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

.nyNow{
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.05;
}

.topControls{
  justify-content:flex-end;
}

/* ---------- Grid + Cards ---------- */
.grid{
  display:grid;
  gap: var(--gap);
  padding: 4px;
  grid-template-columns: 1fr;
  align-items:start;
}

@media (min-width: 1100px){
  .grid{
    grid-template-columns: 420px minmax(0, 1fr);
    grid-template-rows: auto auto; /* row1: markets, row2: kpis + history */
    align-items: stretch;
  }

  /* 1) markets full width */
  .grid > section.card:nth-child(1){
    grid-column: 1 / -1;
    grid-row: 1;
  }

  /* 2) KPI left */
  .grid > section.card:nth-child(2){
    grid-column: 1;
    grid-row: 2;
    align-self: stretch;
  }

  /* 3) Daily+Hourly+DOW right */
  .grid > section.card:nth-child(3){
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
  }
}

.card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: var(--r);
  padding: var(--pad);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);

  /* ключевое: чтобы внутренности могли тянуться */
  display:flex;
  flex-direction:column;
  min-height:0;
}

.cardHead{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  margin-bottom:10px;
  flex-wrap:wrap;
  flex: 0 0 auto;
}

/* ---------- Table ---------- */
.tableWrap{ overflow:auto; border-radius: 1px; }

table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
  min-width: 860px;
}

th, td{
  padding:4px 4px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}

th{
  text-align:left;
  color: var(--muted);
  font-weight:600;
}

tr:hover td{ background: rgba(46,92,255,.06); }
tr[data-tracking-id]{ cursor:pointer; }
tr.selected{
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* по умолчанию держим цифры в 1 строку */
#markets th, #markets td{ white-space: nowrap; }

/* ---------- KPI ---------- */
.kpisGrid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
}

@media (min-width: 700px){
  .kpisGrid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1100px){
  .kpisGrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); } /* узкая левая панель */
}

.kpis{ display: contents; }

.kpi{
  min-height: 92px;
  display:flex;
  flex-direction:column;
  padding: 10px;
  overflow:hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,.06);
}

.kpi .label{
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  -webkit-line-clamp: 2;

  overflow: hidden;
}

.kpi .value{
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.05;
  flex:1;
  overflow:hidden;
}

.kpi .value > div{
  font-size:12px;
  line-height:1.15;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

/* Range block */
.rangeOut{
  border:1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  min-height: 64px;
}

/* ---------- Charts ---------- */
.chartBox{
  width:100%;
  flex: 1 1 auto;
  min-height: 0;
}

.chartBox canvas{
  width:100% !important;
  height:100% !important;
  display:block;
}

.chartBoxDaily{
  height: clamp(220px, 28vh, 320px);
  flex: 0 0 auto;
}

/* ---------- Hourly Head ---------- */
.hourlyHead{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-top: 2px;
  flex: 0 0 auto;
}

.hourlyTitle{
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

/* ---------- Hourly + DOW in one card (your HTML: .belowCharts2 + .belowCard) ---------- */
.belowCharts2{
  display:grid;
  gap: var(--gap);
  margin-top: 10px;

  grid-template-columns: 1fr;
  align-items: stretch;

  flex: 1 1 auto;
  min-height: 0;
}

/* desktop: 2 columns under Daily chart */
@media (min-width: 1100px){
  .belowCharts2{
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.55fr);
  }
}

.belowCard{
  display:flex;
  flex-direction:column;
  min-height:0;
  height:100%;

  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0,0,0,.06);
}

/* chart areas inside mini-cards: equal height */
.chartBoxHourly,
.chartBoxDow{
  height: clamp(220px, 32vh, 360px);
  padding-bottom: 6px;
}

/* make sure mini chartBoxes stretch */
.belowCard .chartBox{
  flex: 1 1 auto;
  min-height: 0;
}

/* ---------- Footer ---------- */
.foot{ padding: 12px 16px; }

code{
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
  padding: 2px 6px;
  border-radius: 8px;
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 520px){
  .top{ align-items:flex-start; }
  .topControls{ width: 100%; justify-content: flex-start; }
  .nyNow{ font-size: 20px; }
}

/* ================================
   RESPONSIVE TABLE: Active Markets (7 колонок)
   1 Название
   2 Окно (ET)
   3 Осталось
   4 Всего
   5 Темп
   6 Среднее/день
   7 Темп %
   ================================ */
@media (max-width: 900px){
  #markets{ min-width: 0; }

  /* Название переносим */
  #markets th:first-child,
  #markets td:first-child{
    white-space: normal;
    width: 100%;
    max-width: 0;
  }
  #markets td:first-child b{
    display:block;
    white-space: normal;
    overflow-wrap:anywhere;
    word-break:break-word;
    line-height:1.15;
  }
  #markets td:first-child .muted{
    white-space: normal;
    overflow-wrap:anywhere;
  }
  #markets td:first-child .pill{
    display:inline-block;
    max-width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  /* прячем “Окно (ET)” — самое широкое */
  #markets th:nth-child(2),
  #markets td:nth-child(2){
    display:none;
  }

  /* “Среднее/день” тоже можно убрать на узком */
  #markets th:nth-child(6),
  #markets td:nth-child(6){
    display:none;
  }
}

@media (max-width: 600px){
  #markets{ font-size: 11px; }
  #markets th, #markets td{ padding: 6px 6px; }

  /* на телефоне можно спрятать “Темп %” */
  #markets th:nth-child(7),
  #markets td:nth-child(7){
    display:none;
  }
}
/* handle preset + custom input */
.handleRow{display:flex;gap:8px;align-items:center}
.handlePreset{min-width:160px}
.handleInput{min-width:140px}
/* HEADER LAYOUT */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: start;

  position: sticky;
  top: 0;
  z-index: 10;

  padding: 14px 16px;
  border-bottom: 1px solid var(--border);

  background: rgba(55, 55, 55, 0.92);
  backdrop-filter: blur(8px);
}

.topLeft h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.topMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  margin-top: 6px;
}

.nyNow {
  font-weight: 600;
}

.statusLine {
  opacity: 0.9;
}

/* Slugline (never overwritten by status anymore) */
.topSub {
  margin-top: 6px;
  line-height: 1.2;
}

/* Controls */
.topControls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: end;
  justify-content: flex-end;
}

.topControls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.handleRow {
  display: grid;
  grid-template-columns: 170px minmax(160px, 240px);
  gap: 8px;
}

.handlePreset,
.handleInput,
.langSelect,
#refresh,
#reload {
  height: 34px;
}

.handleInput {
  width: 100%;
}

/* Small screens: stack */
@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr;
  }
  .topControls {
    justify-content: flex-start;
  }
  .handleRow {
    grid-template-columns: 1fr;
  }
}
/* HEADER LAYOUT */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 6px;
  align-items: start;

  position: sticky;
  top: 0;
  z-index: 10;

  padding: 14px 16px;
  border-bottom: 1px solid var(--border);

  background: rgba(55, 55, 55, 0.92);
  backdrop-filter: blur(8px);
}

.topLeft h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.topMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  margin-top: 6px;
}

.nyNow {
  font-weight: 600;
}

.statusLine {
  opacity: 0.9;
}

/* Slugline (never overwritten by status anymore) */
.topSub {
  margin-top: 6px;
  line-height: 1.2;
}

/* Controls */
.topControls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 4px;
  align-items: end;
  justify-content: flex-end;
}

.topControls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.handleRow {
  display: grid;
  grid-template-columns: 170px minmax(160px, 240px);
  gap: 8px;
}

.handlePreset,
.handleInput,
.langSelect,
#refresh,
#reload {
  height: 34px;
}

.handleInput {
  width: 100%;
}

/* Small screens: stack */
@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr;
  }
  .topControls {
    justify-content: flex-start;
  }
  .handleRow {
    grid-template-columns: 1fr;
  }
}
/* ---------- MOBILE TABLE FIX (avg/day, pace%) ---------- */
@media (max-width: 520px) {
  /* делаем таблицы "умными" на мобиле */
  table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
  }

  /* заголовки и ячейки: меньше шрифт и паддинги */
  th, td {
    padding: 8px 6px;
    font-size: 13px;
    line-height: 1.15;
    vertical-align: top;
  }

  /* разрешаем перенос заголовков типа "Среднее/день" */
  th {
    white-space: normal;
    word-break: break-word;
  }

  /* цифры не должны разъезжаться */
  td {
    white-space: nowrap;
  }

  /* если таблица всё равно шире — пусть скроллится сама */
  .card table,
  .panel table,
  .section table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* небольшое сжатие "узких" колонок (обычно это последние 2) */
  th:last-child, td:last-child,
  th:nth-last-child(2), td:nth-last-child(2) {
    min-width: 64px;
    text-align: right;
  }
}


/* ===== MOBILE: Active Markets (hide Pace + Avg/Day, show Pace%) ===== */
@media (max-width: 600px){

  /* 1) ОТМЕНЯЕМ "Название = 100%" (иначе всё расползается) */
  #markets th:first-child,
  #markets td:first-child{
    width: auto !important;
    max-width: 260px !important;   /* можно 220/260 под вкус */
  }

  /* Название переносим аккуратно */
  #markets td:first-child b{
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* 2) СКРЫВАЕМ: Темп (5-я колонка) */
  #markets th:nth-child(5),
  #markets td:nth-child(5){
    display: none !important;
  }

  /* 3) СКРЫВАЕМ: Среднее/день (6-я колонка) */
  #markets th:nth-child(6),
  #markets td:nth-child(6){
    display: none !important;
  }

  /* 4) ПОКАЗЫВАЕМ: Темп % (7-я колонка) — даже если её раньше скрывали */
  #markets th:nth-child(7),
  #markets td:nth-child(7){
    display: table-cell !important;
  }

  /* 5) Чуть компактнее на телефоне */
  #markets th, #markets td{
    padding: 6px 4px;
    font-size: 11px;
  }
}

/* ===== Mobile: prevent overflow from "x% прошло · темп y/день" in Active Markets ===== */
@media (max-width: 600px) {

  /* строка под прогнозом НЕ должна раздвигать таблицу */
  #markets td .muted{
    display: block;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 11px;
    line-height: 1.15;
  }

  /* если где-то остался nowrap на ячейках — снимаем только с последней колонки */
  #markets td:last-child{
    white-space: normal !important;
  }
}
/* стабильная ширина цифр */
.num, .kpi .value, .nyNow, #markets td, .pill, code {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
