/* Vantage chart surface contract.
 * This is the only owner of chart layout. mobile.css keeps legacy base rules
 * for non-chart screens; this file is loaded last and has no business logic.
 */
:root {
  --chart-safe-top: env(safe-area-inset-top, 0px);
  --chart-nav-space: calc(98px + env(safe-area-inset-bottom, 0px));
  --chart-surface: var(--mt-page-bg, #000000);
  --chart-divider: var(--mt-row, rgba(255, 255, 255, 0.12));
}

#chartSection.screen.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 46px - var(--chart-nav-space));
  height: calc(100dvh - 46px - var(--chart-nav-space));
  padding: 0;
  overflow: hidden;
  background: var(--chart-surface);
}

#chartSection .panel-title {
  order: 1;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 96px;
  align-items: center;
  flex: 0 0 70px;
  min-height: 70px;
  margin: 0;
  padding: 0 15px;
  border-bottom: 1px solid var(--chart-divider);
  background: var(--chart-surface);
}

#chartSection .panel-title h2 {
  grid-column: 1;
  justify-self: start;
  margin: 0;
  color: var(--mt-text, #f5f5f7);
  font-size: 22px;
  font-weight: 760;
}

#chartSection .panel-title span,
#chartSection .panel-title::before,
#chartSection .panel-title::after {
  display: none;
  content: none;
}

#chartSection .timeframes {
  order: 2;
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 0 0 38px;
  min-height: 38px;
  gap: 0;
  margin: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--chart-divider);
  background: var(--chart-surface);
}

#chartSection .timeframes button {
  min-width: 0;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  color: var(--mt-muted, #8f8f95);
  background: transparent;
  font-size: 12px;
  font-weight: 760;
}

#chartSection .timeframes button.active {
  color: var(--mt-blue, #2f8cff);
  background: transparent;
  box-shadow: inset 0 -2px var(--mt-blue, #2f8cff);
}

#chartSection .chart-quick-trade {
  order: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 1.34fr) minmax(0, 1fr);
  flex: 0 0 49px;
  min-height: 49px;
  height: 49px;
  border-bottom: 1px solid var(--chart-divider);
  background: var(--chart-surface);
}

#chartSection .chart-quote-action {
  min-width: 0;
  min-height: 49px;
  padding: 3px 14px 4px;
  border: 0;
  border-radius: 0;
  color: #ffffff;
  text-align: left;
}

#chartSection .chart-quote-action.sell { background: var(--mt-red, #df4b3f); }
#chartSection .chart-quote-action.buy { background: var(--mt-blue, #2f8cff); }

#chartSection .chart-lot-control {
  min-width: 0;
  min-height: 49px;
  border-left: 1px solid var(--chart-divider);
  border-right: 1px solid var(--chart-divider);
  background: var(--chart-surface);
  color: var(--mt-text, #f5f5f7);
  contain: layout paint;
  overflow: hidden;
}

#chartSection .chart-volume-input {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  outline: 0;
  color: inherit;
  background: transparent;
  text-align: center;
  font: inherit;
  font-variant-numeric: tabular-nums;
  caret-color: var(--mt-blue, #2f8cff);
  -webkit-appearance: none;
  appearance: none;
}

#chartSection .chart-volume-input:focus {
  box-shadow: inset 0 -2px var(--mt-blue, #2f8cff);
}

#chartSection .chart-wrap {
  order: 4;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  border: 0;
  border-bottom: 1px solid var(--chart-divider);
  border-radius: 0;
  overflow: hidden;
  background: var(--chart-bg, #000000);
}

#chartSection .chart-wrap canvas,
#chartSection canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  image-rendering: auto;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

#chartSection .chart-tools {
  display: none !important;
}

#chartSection .chart-tools button,
#chartSection .chart-tools span {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--chart-divider);
  border-radius: 0;
  color: var(--mt-text, #f5f5f7);
  background: var(--mt-panel, #111111);
}

#chartSection .chart-meta {
  display: none !important;
}

#chartSection .chart-symbol-row,
#chartSection .chart-statbar,
#chartSection .mt5-chart-actions {
  display: none !important;
}

@media (max-width: 600px) {
  #chartSection .chart-wrap {
    min-height: 280px;
  }
}

@media (min-width: 601px) {
  #chartSection .panel-title {
    flex-basis: 76px;
    min-height: 76px;
  }

  #chartSection .chart-wrap {
    min-height: 360px;
  }
}

html[data-theme="light"] #chartSection .panel-title,
html[data-theme="light"] #chartSection .chart-quick-trade,
html[data-theme="light"] #chartSection .chart-lot-control,
html[data-theme="light"] #chartSection .chart-tools button,
html[data-theme="light"] #chartSection .chart-tools span {
  background: var(--chart-bg, #ffffff);
  border-color: rgba(0, 0, 0, 0.16);
}
