* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: #0f1114;
  color: #eef0f2;
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

.panel {
  position: relative;
  width: 280px;
  height: 100vh;
  border-right: 1px solid #2b3037;
  background: #181b20;
  transition: width 160ms ease;
  caret-color: transparent;
  user-select: none;
}

.panel.collapsed {
  width: 48px;
}

.menuToggle {
  width: 34px;
  height: 34px;
  margin: 10px 7px;
  border: 1px solid #3a414b;
  border-radius: 6px;
  background: #232831;
  color: #eef0f2;
  cursor: pointer;
}

.panelBody {
  height: calc(100vh - 54px);
  overflow-y: auto;
  padding: 0 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: #3a414b #181b20;
}

.panel.collapsed .panelBody {
  display: none;
}

h1 {
  margin: 4px 0 22px;
  font-size: 22px;
}

.checks {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8dde3;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

label,
dt {
  color: #aeb6c1;
  font-size: 13px;
}

button,
input,
select {
  width: 100%;
}

button,
select {
  min-height: 38px;
  border: 1px solid #3a414b;
  border-radius: 6px;
  background: #232831;
  color: #eef0f2;
  padding: 0 10px;
}

input[type="number"] {
  min-height: 38px;
  border: 1px solid #3a414b;
  border-radius: 6px;
  background: #232831;
  color: #eef0f2;
  padding: 0 10px;
}

button {
  cursor: pointer;
  user-select: none;
}

button:hover {
  background: #2d3440;
}

button:focus {
  outline: none;
}

select:focus,
input:focus {
  outline: 1px solid #4da3ff;
}

canvas:focus {
  outline: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.ocoBox {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 12px 0;
  border-top: 1px solid #2b3037;
  border-bottom: 1px solid #2b3037;
}

.toast {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 10;
  display: none;
  min-width: 220px;
  max-width: 340px;
  border: 1px solid #3a414b;
  border-radius: 8px;
  background: #181b20;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  color: #eef0f2;
  padding: 14px 16px;
  font-size: 14px;
}

.toast.show {
  display: block;
}

.toast.gain {
  border-color: #21b26f;
}

.toast.loss {
  border-color: #e34f4f;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.modalBackdrop.show {
  display: flex;
}

.modal {
  width: min(860px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: 44px 1fr;
  border: 1px solid #3a414b;
  border-radius: 8px;
  background: #181b20;
  overflow: hidden;
}

.modal header {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid #2b3037;
}

.historyContent {
  overflow: auto;
  padding: 12px;
}

.historySummary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  color: #d8dde3;
  font-size: 13px;
}

.historySummary span {
  border: 1px solid #3a414b;
  border-radius: 6px;
  padding: 7px 9px;
  background: #232831;
}

.historyTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.historyTable th,
.historyTable td {
  padding: 9px 8px;
  border-bottom: 1px solid #2b3037;
  text-align: right;
}

.historyTable th:first-child,
.historyTable td:first-child {
  text-align: left;
}

.historyTable .gain {
  color: #21b26f;
}

.historyTable .loss {
  color: #e34f4f;
}

.stats {
  margin: 24px 0 0;
}

.stats div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #2b3037;
}

dd {
  margin: 0;
  text-align: right;
}

.workspace {
  display: flex;
  gap: 10px;
  height: 100vh;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.workspace.expanded {
  display: flex;
}

.chartPane {
  position: relative;
  display: grid;
  grid-template-rows: 34px 1fr;
  flex: 1 1 0;
  min-width: 220px;
  height: 100%;
  min-height: 260px;
  border: 1px solid #2b3037;
  border-radius: 8px;
  overflow: hidden;
  background: #0c0e11;
}

.chartPane::after {
  content: "";
  position: absolute;
  top: 34px;
  right: -6px;
  bottom: 0;
  width: 12px;
  cursor: col-resize;
  z-index: 3;
}

.chartPane.hidden::after,
.chartPane:last-of-type::after,
.workspace.expanded .chartPane::after {
  display: none;
}

.workspace.expanded .chartPane {
  flex: 1 1 100% !important;
  min-height: 0;
}

.chartPane.hidden {
  display: none;
}

.chartPane header {
  display: grid;
  grid-template-columns: 42px minmax(120px, 1fr) repeat(3, 70px) 64px 118px;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid #242a32;
  background: #15191f;
  color: #aeb6c1;
  font-size: 13px;
  user-select: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.chartPane strong {
  color: #eef0f2;
}

.paneTime {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paneZoom {
  min-width: 118px;
  width: 118px;
}

.chartType {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.studyAction {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}


canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  cursor: grab;
}

canvas.line-mode {
  cursor: crosshair;
}

canvas.dragging {
  cursor: grabbing;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: auto 1fr;
  }

  .workspace {
    height: auto;
    min-height: 100vh;
    flex-direction: column;
  }
}
