* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: #d4d4d4;
  padding: 20px;
}

.wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100vh - 40px);
}

/* Side Panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #e8e8e8;
  padding: 20px;
  border-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
}

.controls {
  order: 1;
}

.canvas-container {
  order: 3;
}

.report {
  order: 2;
}

/* Controls Section */
.controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.panel1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.panel2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.controls button {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 400;
  border: 2px outset #d4d4d4;
  border-radius: 0;
  background: #ece9d8;
  color: #000;
  cursor: pointer;
  transition: none;
}

.controls button:hover {
  background: #f5f2e8;
}

.controls button:active {
  border-style: inset;
  background: #d4d0c0;
}

/* Report Section */
.report {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-part {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.text-part div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #e0e0e0;
}

.text-part div:last-child {
  border-bottom: none;
}

.text-part label:first-child {
  font-weight: 600;
  color: #555;
}

.text-part label:last-child {
  font-weight: 700;
  color: #333;
  font-size: 18px;
}

/* Charts Section */
.chart-part {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#charts-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.chart {
  width: 100%;
  max-width: 350px;
  background: white;
  border-radius: 0;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Canvas Container */
.canvas-container {
  background: #000;
  border-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  order: 3;
}

#canvas1 {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 2px solid #333;
  border-radius: 0;
  background: #000;
}

/* Desktop layout - side by side */
@media (min-width: 1025px) {
  .wrapper {
    grid-template-columns: 400px 1fr;
    max-width: 1600px;
  }

  .side-panel {
    height: 100%;
  }

  .controls {
    order: 1;
  }

  .report {
    order: 2;
  }

  .canvas-container {
    order: 1;
    grid-column: 2;
    grid-row: 1;
  }

  /* Larger charts on desktop */
  .chart {
    max-width: 350px;
  }

  #charts-container {
    flex-direction: column;
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .wrapper {
    grid-template-columns: 1fr;
    height: auto;
  }

  .side-panel {
    height: auto;
  }

  .controls {
    order: 1;
  }

  .canvas-container {
    order: 2;
    min-height: 400px;
  }

  .report {
    order: 3;
  }

  /* Make charts side-by-side and smaller on mobile */
  #charts-container {
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    width: 100%;
    padding: 0 10px;
  }

  .chart {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 48%;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .wrapper {
    gap: 15px;
    height: auto;
  }

  .side-panel {
    padding: 15px;
    gap: 15px;
  }

  /* Larger touch targets for mobile */
  .controls button {
    padding: 14px 16px;
    font-size: 14px;
    min-height: 48px; /* Good touch target size */
  }

  .panel1 {
    gap: 12px;
  }

  /* Stack charts vertically on mobile */
  #charts-container {
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    width: 100%;
  }

  .chart {
    width: auto;
    max-width: 48%;
    flex: 0 1 auto;
  }

  .text-part {
    padding: 12px;
  }

  .text-part label:last-child {
    font-size: 16px;
  }

  .canvas-container {
    padding: 15px;
    min-height: 350px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .wrapper {
    gap: 12px;
  }

  .side-panel {
    padding: 12px;
    border-radius: 0;
  }

  .controls {
    gap: 12px;
  }

  /* Keep 2-column layout on small screens - buttons are paired well */
  .panel1 {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .controls button {
    padding: 12px 10px;
    font-size: 12px;
    min-height: 44px;
  }

  .text-part {
    padding: 10px;
    gap: 8px;
  }

  .text-part div {
    padding: 6px 0;
  }

  .text-part label:first-child {
    font-size: 13px;
  }

  .text-part label:last-child {
    font-size: 15px;
  }

  .canvas-container {
    padding: 10px;
    min-height: 300px;
  }

  #canvas1 {
    border-width: 1px;
  }
}

/* Landscape mobile orientation */
@media (max-width: 900px) and (orientation: landscape) {
  .wrapper {
    grid-template-columns: 350px 1fr;
    grid-template-rows: 1fr;
  }

  #charts-container {
    flex-direction: row;
    gap: 10px;
  }

  .chart {
    max-width: 160px;
  }

  body {
    padding: 10px;
  }
}
