body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #17202a;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
}

.header p {
  margin: 0 0 24px;
  color: #52616f;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 14px;
  align-items: end;
  background: white;
  padding: 18px;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 13px;
  color: #52616f;
  font-weight: 600;
}

.field input {
  height: 38px;
  border: 1px solid #c9d3dd;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 15px;
  background: white;
}

.wide {
  min-width: 190px;
}

button {
  height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #1f6feb;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.error {
  min-height: 22px;
  margin: 14px 0;
  color: #b42318;
  font-weight: 600;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.panel,
.plot-panel {
  background: white;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
}

.panel {
  padding: 16px;
  overflow-x: auto;
}

.plot-panel {
  padding: 10px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.panel p {
  margin: 6px 0;
}

.coefficients {
  color: #52616f;
  font-size: 13px;
  line-height: 1.4;
}

.latex-matrix {
  min-width: 360px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid #edf1f5;
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
}

.matrix-table th {
  color: #52616f;
  font-weight: 600;
  text-align: left;
}

#plot {
  min-height: 760px;
}

@media (max-width: 980px) {
  .controls,
  .summary {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
